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

Side by Side Diff: app/active_window_watcher_x.cc

Issue 1076007: Fixes bug in ActiveWindowWatcherX. It appears that in newer versions... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <X11/Xlib.h> 5 #include <X11/Xlib.h>
6 #include <gdk/gdk.h> 6 #include <gdk/gdk.h>
7 #include <gdk/gdkx.h> 7 #include <gdk/gdkx.h>
8 8
9 #include "app/active_window_watcher_x.h" 9 #include "app/active_window_watcher_x.h"
10 10
(...skipping 12 matching lines...) Expand all
23 ActiveWindowWatcherX::ActiveWindowWatcherX() { 23 ActiveWindowWatcherX::ActiveWindowWatcherX() {
24 Init(); 24 Init();
25 } 25 }
26 26
27 void ActiveWindowWatcherX::Init() { 27 void ActiveWindowWatcherX::Init() {
28 GdkAtom kNetActiveWindow = gdk_atom_intern("_NET_ACTIVE_WINDOW", FALSE); 28 GdkAtom kNetActiveWindow = gdk_atom_intern("_NET_ACTIVE_WINDOW", FALSE);
29 kNetActiveWindowAtom = gdk_x11_atom_to_xatom_for_display( 29 kNetActiveWindowAtom = gdk_x11_atom_to_xatom_for_display(
30 gdk_screen_get_display(gdk_screen_get_default()), kNetActiveWindow); 30 gdk_screen_get_display(gdk_screen_get_default()), kNetActiveWindow);
31 31
32 GdkWindow* root = gdk_get_default_root_window(); 32 GdkWindow* root = gdk_get_default_root_window();
33
33 // Set up X Event filter to listen for PropertyChange X events. These events 34 // Set up X Event filter to listen for PropertyChange X events. These events
34 // tell us when the active window changes. 35 // tell us when the active window changes.
35 gdk_window_add_filter(root, &ActiveWindowWatcherX::OnWindowXEvent, this); 36 // Don't use XSelectInput directly here, as gdk internally seems to cache the
36 XSelectInput( 37 // mask and reapply XSelectInput after this, resetting any mask we set here.
37 GDK_WINDOW_XDISPLAY(root), GDK_WINDOW_XID(root), PropertyChangeMask); 38 gdk_window_set_events(root,
39 static_cast<GdkEventMask>(gdk_window_get_events(root) |
40 GDK_PROPERTY_CHANGE_MASK));
41 gdk_window_add_filter(NULL, &ActiveWindowWatcherX::OnWindowXEvent, this);
38 } 42 }
39 43
40 void ActiveWindowWatcherX::NotifyActiveWindowChanged() { 44 void ActiveWindowWatcherX::NotifyActiveWindowChanged() {
41 // We don't use gdk_screen_get_active_window() because it caches 45 // We don't use gdk_screen_get_active_window() because it caches
42 // whether or not the window manager supports _NET_ACTIVE_WINDOW. 46 // whether or not the window manager supports _NET_ACTIVE_WINDOW.
43 // This causes problems at startup for chromiumos. 47 // This causes problems at startup for chromiumos.
44 Atom type = None; 48 Atom type = None;
45 int format = 0; // size in bits of each item in 'property' 49 int format = 0; // size in bits of each item in 'property'
46 long unsigned int num_items = 0, remaining_bytes = 0; 50 long unsigned int num_items = 0, remaining_bytes = 0;
47 unsigned char* property = NULL; 51 unsigned char* property = NULL;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 window_watcher); 85 window_watcher);
82 XEvent* xev = static_cast<XEvent*>(xevent); 86 XEvent* xev = static_cast<XEvent*>(xevent);
83 87
84 if (xev->xany.type == PropertyNotify && 88 if (xev->xany.type == PropertyNotify &&
85 xev->xproperty.atom == kNetActiveWindowAtom) { 89 xev->xproperty.atom == kNetActiveWindowAtom) {
86 watcher->NotifyActiveWindowChanged(); 90 watcher->NotifyActiveWindowChanged();
87 } 91 }
88 92
89 return GDK_FILTER_CONTINUE; 93 return GDK_FILTER_CONTINUE;
90 } 94 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698