Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: ui/events/x/device_data_manager_x11.cc

Issue 313913004: Block internal PlatformEvents before they are dispatched in touchview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix updating cursor on enter notify. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/events/x/device_data_manager_x11.h ('k') | ui/events/x/events_x.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/x/device_data_manager_x11.h" 5 #include "ui/events/x/device_data_manager_x11.h"
6 6
7 #include <X11/extensions/XInput.h> 7 #include <X11/extensions/XInput.h>
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/sys_info.h" 13 #include "base/sys_info.h"
14 #include "ui/events/event_constants.h" 14 #include "ui/events/event_constants.h"
15 #include "ui/events/event_switches.h" 15 #include "ui/events/event_switches.h"
16 #include "ui/events/event_utils.h"
16 #include "ui/events/x/device_list_cache_x.h" 17 #include "ui/events/x/device_list_cache_x.h"
17 #include "ui/events/x/touch_factory_x11.h" 18 #include "ui/events/x/touch_factory_x11.h"
18 #include "ui/gfx/display.h" 19 #include "ui/gfx/display.h"
19 #include "ui/gfx/point3_f.h" 20 #include "ui/gfx/point3_f.h"
20 #include "ui/gfx/x/x11_types.h" 21 #include "ui/gfx/x/x11_types.h"
21 22
22 // XIScrollClass was introduced in XI 2.1 so we need to define it here 23 // XIScrollClass was introduced in XI 2.1 so we need to define it here
23 // for backward-compatibility with older versions of XInput. 24 // for backward-compatibility with older versions of XInput.
24 #if !defined(XIScrollClass) 25 #if !defined(XIScrollClass)
25 #define XIScrollClass 3 26 #define XIScrollClass 3
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 new DeviceDataManagerX11(); 118 new DeviceDataManagerX11();
118 } 119 }
119 120
120 // static 121 // static
121 DeviceDataManagerX11* DeviceDataManagerX11::GetInstance() { 122 DeviceDataManagerX11* DeviceDataManagerX11::GetInstance() {
122 return static_cast<DeviceDataManagerX11*>(DeviceDataManager::GetInstance()); 123 return static_cast<DeviceDataManagerX11*>(DeviceDataManager::GetInstance());
123 } 124 }
124 125
125 DeviceDataManagerX11::DeviceDataManagerX11() 126 DeviceDataManagerX11::DeviceDataManagerX11()
126 : xi_opcode_(-1), 127 : xi_opcode_(-1),
128 blocked_keyboard_(false),
127 atom_cache_(gfx::GetXDisplay(), kCachedAtoms), 129 atom_cache_(gfx::GetXDisplay(), kCachedAtoms),
128 button_map_count_(0) { 130 button_map_count_(0) {
129 CHECK(gfx::GetXDisplay()); 131 CHECK(gfx::GetXDisplay());
130 InitializeXInputInternal(); 132 InitializeXInputInternal();
131 133
132 // Make sure the sizes of enum and kCachedAtoms are aligned. 134 // Make sure the sizes of enum and kCachedAtoms are aligned.
133 CHECK(arraysize(kCachedAtoms) == static_cast<size_t>(DT_LAST_ENTRY) + 1); 135 CHECK(arraysize(kCachedAtoms) == static_cast<size_t>(DT_LAST_ENTRY) + 1);
134 UpdateDeviceList(gfx::GetXDisplay()); 136 UpdateDeviceList(gfx::GetXDisplay());
135 UpdateButtonMap(); 137 UpdateButtonMap();
136 } 138 }
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 #if defined(OS_CHROMEOS) && defined(USE_XI2_MT) 662 #if defined(OS_CHROMEOS) && defined(USE_XI2_MT)
661 int64 touch_display_id = GetDisplayForTouchDevice(touch_device_id); 663 int64 touch_display_id = GetDisplayForTouchDevice(touch_device_id);
662 if (base::SysInfo::IsRunningOnChromeOS() && 664 if (base::SysInfo::IsRunningOnChromeOS() &&
663 touch_display_id == gfx::Display::InternalDisplayId()) { 665 touch_display_id == gfx::Display::InternalDisplayId()) {
664 return true; 666 return true;
665 } 667 }
666 #endif // defined(OS_CHROMEOS) && defined(USE_XI2_MT) 668 #endif // defined(OS_CHROMEOS) && defined(USE_XI2_MT)
667 return false; 669 return false;
668 } 670 }
669 671
672 void DeviceDataManagerX11::DisableKeyboard(
673 scoped_ptr<std::set<KeyboardCode> > excepted_keys) {
674 DCHECK(!blocked_keyboard_);
675 DCHECK(!blocked_keyboard_allowed_keys_.get());
676 blocked_keyboard_ = true;
677 blocked_keyboard_allowed_keys_ = excepted_keys.Pass();
678 }
679
680 void DeviceDataManagerX11::EnableKeyboard() {
681 DCHECK(blocked_keyboard_);
682 blocked_keyboard_ = false;
683 blocked_keyboard_allowed_keys_.reset();
684 }
685
686 void DeviceDataManagerX11::DisableDevice(unsigned int deviceid) {
687 blocked_devices_.set(deviceid, true);
688 }
689
690 void DeviceDataManagerX11::EnableDevice(unsigned int deviceid) {
691 blocked_devices_.set(deviceid, false);
692 }
693
694 bool DeviceDataManagerX11::IsEventBlocked(
695 const base::NativeEvent& native_event) {
696 switch (native_event->type) {
697 case KeyPress:
698 case KeyRelease:
699 return blocked_keyboard_ && (!blocked_keyboard_allowed_keys_ ||
700 blocked_keyboard_allowed_keys_->find(
701 KeyboardCodeFromNative(native_event)) ==
702 blocked_keyboard_allowed_keys_->end());
703 case GenericEvent:
704 return blocked_devices_.test(
705 static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid);
706 default:
707 break;
708 }
709 return false;
710 }
711
670 } // namespace ui 712 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/x/device_data_manager_x11.h ('k') | ui/events/x/events_x.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698