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

Side by Side Diff: ui/aura/dispatcher_linux.cc

Issue 9808010: Keep the mouse cursor within desktop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/aura/dispatcher_linux.h" 5 #include "ui/aura/dispatcher_linux.h"
6 6
7 #include <X11/extensions/XInput2.h> 7 #include <X11/extensions/XInput2.h>
8 8
9 #include "ui/aura/root_window_host_linux.h"
10 #include "ui/base/events.h" 9 #include "ui/base/events.h"
11 10
12 namespace aura { 11 namespace aura {
13 12
14 DispatcherLinux::DispatcherLinux() { 13 DispatcherLinux::DispatcherLinux() {
15 base::MessagePumpX::SetDefaultDispatcher(this); 14 base::MessagePumpX::SetDefaultDispatcher(this);
16 } 15 }
17 16
18 DispatcherLinux::~DispatcherLinux() { 17 DispatcherLinux::~DispatcherLinux() {
19 base::MessagePumpX::SetDefaultDispatcher(NULL); 18 base::MessagePumpX::SetDefaultDispatcher(NULL);
20 } 19 }
21 20
22 void DispatcherLinux::RootWindowHostCreated(::Window window, 21 void DispatcherLinux::WindowDispatcherCreated(
23 ::Window root, 22 ::Window window,
24 RootWindowHostLinux* host) { 23 MessageLoop::Dispatcher* dispatcher) {
25 hosts_.insert(std::make_pair(window, host)); 24 dispatchers_.insert(std::make_pair(window, dispatcher));
26 // Only the 1st root window listens to the root window.
27 if (hosts_.find(root) == hosts_.end())
28 hosts_.insert(std::make_pair(root, host));
29 } 25 }
30 26
31 void DispatcherLinux::RootWindowHostDestroying(::Window window, ::Window root) { 27 void DispatcherLinux::WindowDispatcherDestroying(::Window window) {
32 if (hosts_[window] == hosts_[root]) 28 dispatchers_.erase(window);
33 hosts_.erase(root);
34 hosts_.erase(window);
35 } 29 }
36 30
37 base::MessagePumpDispatcher::DispatchStatus DispatcherLinux::Dispatch( 31 base::MessagePumpDispatcher::DispatchStatus DispatcherLinux::Dispatch(
38 XEvent* xev) { 32 XEvent* xev) {
39 // XI_HierarchyChanged events are special. There is no window associated with 33 // XI_HierarchyChanged events are special. There is no window associated with
40 // these events. So process them directly from here. 34 // these events. So process them directly from here.
41 if (xev->type == GenericEvent && 35 if (xev->type == GenericEvent &&
42 xev->xgeneric.evtype == XI_HierarchyChanged) { 36 xev->xgeneric.evtype == XI_HierarchyChanged) {
43 ui::UpdateDeviceList(); 37 ui::UpdateDeviceList();
44 return EVENT_PROCESSED; 38 return EVENT_PROCESSED;
45 } 39 }
46 RootWindowHostLinux* host = GetRootWindowHostForXEvent(xev); 40 MessageLoop::Dispatcher* dispatcher = GetDispatcherForXEvent(xev);
47 return host ? host->Dispatch(xev) : EVENT_IGNORED; 41 return dispatcher ? dispatcher->Dispatch(xev) : EVENT_IGNORED;
48 } 42 }
49 43
50 RootWindowHostLinux* DispatcherLinux::GetRootWindowHostForXEvent( 44 MessageLoop::Dispatcher* DispatcherLinux::GetDispatcherForXEvent(
51 XEvent* xev) const { 45 XEvent* xev) const {
52 ::Window window = xev->xany.window; 46 ::Window window = xev->xany.window;
53 if (xev->type == GenericEvent) { 47 if (xev->type == GenericEvent) {
54 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data); 48 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data);
55 window = xievent->event; 49 window = xievent->event;
56 } 50 }
57 HostsMap::const_iterator it = hosts_.find(window); 51 DispatchersMap::const_iterator it = dispatchers_.find(window);
58 return it != hosts_.end() ? it->second : NULL; 52 return it != dispatchers_.end() ? it->second : NULL;
59 } 53 }
60 54
61 Dispatcher* CreateDispatcher() { 55 MessageLoop::Dispatcher* CreateDispatcher() {
62 return new DispatcherLinux; 56 return new DispatcherLinux;
63 } 57 }
64 58
65 } // namespace aura 59 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/dispatcher_linux.h ('k') | ui/aura/dispatcher_win.cc » ('j') | ui/aura/env.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698