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

Side by Side Diff: chrome/browser/chromeos/login/screen_locker.cc

Issue 5043002: A workaround to close currently opened menu. Send escape key if screen locker fails to grab input. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 10 years, 1 month 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/chromeos/login/screen_locker.h" 5 #include "chrome/browser/chromeos/login/screen_locker.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 #include <X11/extensions/XTest.h>
10 #include <X11/keysym.h>
9 11
10 #include "app/l10n_util.h" 12 #include "app/l10n_util.h"
13 #include "app/x11_util.h"
Daniel Erat 2010/11/16 15:38:13 nit: sort
oshima 2010/11/16 21:06:29 Done.
11 #include "app/resource_bundle.h" 14 #include "app/resource_bundle.h"
12 #include "base/command_line.h" 15 #include "base/command_line.h"
13 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
14 #include "base/message_loop.h" 17 #include "base/message_loop.h"
15 #include "base/singleton.h" 18 #include "base/singleton.h"
16 #include "base/string_util.h" 19 #include "base/string_util.h"
17 #include "base/timer.h" 20 #include "base/timer.h"
18 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
19 #include "chrome/browser/browser_list.h" 22 #include "chrome/browser/browser_list.h"
20 #include "chrome/browser/browser_thread.h" 23 #include "chrome/browser/browser_thread.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 274 }
272 275
273 virtual void Show() { 276 virtual void Show() {
274 views::WidgetGtk::Show(); 277 views::WidgetGtk::Show();
275 // Now steal all inputs. 278 // Now steal all inputs.
276 TryGrabAllInputs(); 279 TryGrabAllInputs();
277 } 280 }
278 281
279 void ClearGrab() { 282 void ClearGrab() {
280 GtkWidget* current_grab_window; 283 GtkWidget* current_grab_window;
281 // Grab gtk input first so that the menu holding grab will close itself. 284 // Grab gtk input first so that the menu holding gtk grab will
285 // close itself.
282 gtk_grab_add(window_contents()); 286 gtk_grab_add(window_contents());
283 287
288 if (mouse_grab_status_ != GDK_GRAB_INVALID_TIME ||
Daniel Erat 2010/11/16 17:26:50 This is wrong: if _only_ the pointer is grabbed, y
oshima 2010/11/16 21:06:29 BTW, this *was* how view menu was implemented. Onl
289 kbd_grab_status_ != GDK_GRAB_INVALID_TIME) {
290 // Send escape key if the input is grabbed by other client.
291 // This happen when a plugin has a menu opened and sending
Daniel Erat 2010/11/16 15:38:13 s/happen/happens/
oshima 2010/11/16 21:06:29 Done.
292 // escape key should close the menu.
293 Display* display = x11_util::GetXDisplay();
294 KeyCode escape = XKeysymToKeycode(display, XK_Escape); // escape
295 int event_base, error_base;
296 int major, minor;
297 // Make sure we have XTest extension.
298 DCHECK(XTestQueryExtension(display, &event_base, &error_base,
299 &major, &minor));
300
301 XTestGrabControl(display, True);
Daniel Erat 2010/11/16 15:38:13 I don't think that you need this. It lets you sid
oshima 2010/11/16 21:06:29 Done.
302 XTestFakeKeyEvent(display, escape, True, 0);
303 XTestFakeKeyEvent(display, escape, False, 0);
304 XSync(display, False);
Daniel Erat 2010/11/16 15:38:13 This can just be XFlush(display) instead.
oshima 2010/11/16 21:06:29 Done.
305 XTestGrabControl(display, False);
306 }
307
284 // Make sure there is no grab widget so that gtk simply propagates 308 // Make sure there is no grab widget so that gtk simply propagates
285 // an event. This is necessary to allow message bubble and password 309 // an event. This is necessary to allow message bubble and password
286 // field, button to process events simultaneously. GTK 310 // field, button to process events simultaneously. GTK
287 // maintains grab widgets in a linked-list, so we need to remove 311 // maintains grab widgets in a linked-list, so we need to remove
288 // until it's empty. 312 // until it's empty.
289 while ((current_grab_window = gtk_grab_get_current()) != NULL) 313 while ((current_grab_window = gtk_grab_get_current()) != NULL)
Daniel Erat 2010/11/16 15:38:13 Should this come before the XTest code? I guess t
oshima 2010/11/16 21:06:29 I believe the order isn't important and it was arb
290 gtk_grab_remove(current_grab_window); 314 gtk_grab_remove(current_grab_window);
291 } 315 }
292 316
293 virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event) { 317 virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event) {
294 WidgetGtk::OnButtonPress(widget, event); 318 WidgetGtk::OnButtonPress(widget, event);
295 // Never propagate event to parent. 319 // Never propagate event to parent.
296 return true; 320 return true;
297 } 321 }
298 322
299 // Try to grab all inputs. It initiates another try if it fails to 323 // Try to grab all inputs. It initiates another try if it fails to
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 945
922 bool ScreenLocker::AcceleratorPressed(const views::Accelerator& accelerator) { 946 bool ScreenLocker::AcceleratorPressed(const views::Accelerator& accelerator) {
923 if (!background_view_->IsScreenSaverVisible()) { 947 if (!background_view_->IsScreenSaverVisible()) {
924 StartScreenSaver(); 948 StartScreenSaver();
925 return true; 949 return true;
926 } 950 }
927 return false; 951 return false;
928 } 952 }
929 953
930 } // namespace chromeos 954 } // namespace chromeos
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