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

Unified Diff: ui/aura/root_window_host_linux.cc

Issue 10913253: aura: Make sure the root-window retains the X events it was already listening for. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/root_window_host_linux.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/root_window_host_linux.cc
diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc
index 76ab200d0a47fabbad9d6ca1a218e29cd7736aff..7d0590c152f742d1f1d3107eeeadfd54f8db67bf 100644
--- a/ui/aura/root_window_host_linux.cc
+++ b/ui/aura/root_window_host_linux.cc
@@ -206,6 +206,13 @@ int CoalescePendingMotionEvents(const XEvent* xev, XEvent* last_event) {
return num_coalesed;
}
+::Window FindEventTarget(const base::NativeEvent& xev) {
+ ::Window target = xev->xany.window;
+ if (xev->type == GenericEvent)
+ target = static_cast<XIDeviceEvent*>(xev->xcookie.data)->event;
+ return target;
+}
+
void SelectEventsForRootWindow() {
XIEventMask evmask;
unsigned char mask[XIMaskLen(XI_LASTEVENT)] = {};
@@ -235,7 +242,12 @@ void SelectEventsForRootWindow() {
// Receive resize events for the root-window so |x_root_bounds_| can be
// updated.
- XSelectInput(display, root_window, StructureNotifyMask);
+ XWindowAttributes attr;
+ XGetWindowAttributes(display, root_window, &attr);
+ if (!(attr.your_event_mask & StructureNotifyMask)) {
+ XSelectInput(display, root_window,
+ StructureNotifyMask | attr.your_event_mask);
+ }
}
// We emulate Windows' WM_KEYDOWN and WM_CHAR messages. WM_CHAR events are only
@@ -380,6 +392,9 @@ bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) {
CheckXEventForConsistency(xev);
+ if (FindEventTarget(event) == x_root_window_)
+ return DispatchEventForRootWindow(event);
+
switch (xev->type) {
case EnterNotify: {
ui::MouseEvent mouseenter_event(xev);
@@ -423,44 +438,38 @@ bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) {
delegate_->OnHostLostCapture();
break;
case ConfigureNotify: {
- if (xev->xconfigure.window == xwindow_) {
- DCHECK_EQ(xwindow_, xev->xconfigure.event);
- // It's possible that the X window may be resized by some other means
- // than from within aura (e.g. the X window manager can change the
- // size). Make sure the root window size is maintained properly.
- gfx::Rect bounds(xev->xconfigure.x, xev->xconfigure.y,
- xev->xconfigure.width, xev->xconfigure.height);
- bool size_changed = bounds_.size() != bounds.size();
- bool origin_changed = bounds_.origin() != bounds.origin();
- bounds_ = bounds;
- // Always update barrier and mouse location because |bounds_| might
- // have already been updated in |SetBounds|.
- if (pointer_barriers_.get()) {
- UnConfineCursor();
- RootWindow* root = delegate_->AsRootWindow();
- client::ScreenPositionClient* client =
- client::GetScreenPositionClient(root);
- if (client) {
- gfx::Point p = gfx::Screen::GetCursorScreenPoint();
- client->ConvertPointFromScreen(root, &p);
- if (root->ContainsPoint(p)) {
- root->ConvertPointToNativeScreen(&p);
- XWarpPointer(
- xdisplay_, None, x_root_window_, 0, 0, 0, 0, p.x(), p.y());
- }
+ DCHECK_EQ(xwindow_, xev->xconfigure.event);
+ DCHECK_EQ(xwindow_, xev->xconfigure.window);
+ // It's possible that the X window may be resized by some other means
+ // than from within aura (e.g. the X window manager can change the
+ // size). Make sure the root window size is maintained properly.
+ gfx::Rect bounds(xev->xconfigure.x, xev->xconfigure.y,
+ xev->xconfigure.width, xev->xconfigure.height);
+ bool size_changed = bounds_.size() != bounds.size();
+ bool origin_changed = bounds_.origin() != bounds.origin();
+ bounds_ = bounds;
+ // Always update barrier and mouse location because |bounds_| might
+ // have already been updated in |SetBounds|.
+ if (pointer_barriers_.get()) {
+ UnConfineCursor();
+ RootWindow* root = delegate_->AsRootWindow();
+ client::ScreenPositionClient* client =
+ client::GetScreenPositionClient(root);
+ if (client) {
+ gfx::Point p = gfx::Screen::GetCursorScreenPoint();
+ client->ConvertPointFromScreen(root, &p);
+ if (root->ContainsPoint(p)) {
+ root->ConvertPointToNativeScreen(&p);
+ XWarpPointer(
+ xdisplay_, None, x_root_window_, 0, 0, 0, 0, p.x(), p.y());
}
- ConfineCursorToRootWindow();
}
- if (size_changed)
- delegate_->OnHostResized(bounds.size());
- if (origin_changed)
- delegate_->OnHostMoved(bounds_.origin());
- } else {
- DCHECK_EQ(x_root_window_, xev->xconfigure.event);
- DCHECK_EQ(x_root_window_, xev->xconfigure.window);
- x_root_bounds_.SetRect(xev->xconfigure.x, xev->xconfigure.y,
- xev->xconfigure.width, xev->xconfigure.height);
+ ConfineCursorToRootWindow();
}
+ if (size_changed)
+ delegate_->OnHostResized(bounds.size());
+ if (origin_changed)
+ delegate_->OnHostMoved(bounds_.origin());
break;
}
case GenericEvent: {
@@ -628,6 +637,20 @@ bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) {
return true;
}
+bool RootWindowHostLinux::DispatchEventForRootWindow(
+ const base::NativeEvent& event) {
+ switch (event->type) {
+ case ConfigureNotify:
+ DCHECK_EQ(x_root_window_, event->xconfigure.event);
+ DCHECK_EQ(x_root_window_, event->xconfigure.window);
+ x_root_bounds_.SetRect(event->xconfigure.x, event->xconfigure.y,
+ event->xconfigure.width, event->xconfigure.height);
+ break;
+ }
+
+ return false;
Daniel Erat 2012/09/13 19:14:09 i think that we previously returned true in this c
sadrul 2012/09/13 23:41:24 It wasn't. Incidentally, however, the return value
+}
+
RootWindow* RootWindowHostLinux::GetRootWindow() {
return delegate_->AsRootWindow();
}
« no previous file with comments | « ui/aura/root_window_host_linux.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698