Chromium Code Reviews| Index: chrome/browser/chromeos/login/screen_locker.cc |
| diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc |
| index 2d8ccd08ea5d0ed9f4e6899a2e923814298f6266..5241db2628be792eb6c4ae13d212a4f0ac452ce1 100644 |
| --- a/chrome/browser/chromeos/login/screen_locker.cc |
| +++ b/chrome/browser/chromeos/login/screen_locker.cc |
| @@ -6,8 +6,11 @@ |
| #include <string> |
| #include <vector> |
| +#include <X11/extensions/XTest.h> |
| +#include <X11/keysym.h> |
| #include "app/l10n_util.h" |
| +#include "app/x11_util.h" |
|
Daniel Erat
2010/11/16 21:58:06
still needs to be sorted
oshima
2010/11/17 01:00:43
Done.
|
| #include "app/resource_bundle.h" |
| #include "base/command_line.h" |
| #include "base/metrics/histogram.h" |
| @@ -276,16 +279,60 @@ class GrabWidget : public views::WidgetGtk { |
| void ClearGrab() { |
| GtkWidget* current_grab_window; |
| - // Grab gtk input first so that the menu holding grab will close itself. |
| + // Grab gtk input first so that the menu holding gtk grab will |
| + // close itself. |
| gtk_grab_add(window_contents()); |
| - // Make sure there is no grab widget so that gtk simply propagates |
| + // Make sure there is no gtl grab widget so that gtk simply propagates |
|
Daniel Erat
2010/11/16 21:58:06
s/gtl/gtk/
oshima
2010/11/17 01:00:43
Done.
|
| // an event. This is necessary to allow message bubble and password |
| // field, button to process events simultaneously. GTK |
| // maintains grab widgets in a linked-list, so we need to remove |
| // until it's empty. |
| while ((current_grab_window = gtk_grab_get_current()) != NULL) |
| gtk_grab_remove(current_grab_window); |
| + |
| +#if !defined(NDEBUG) |
| + { |
| + int event_base, error_base; |
| + int major, minor; |
| + // Make sure we have XTest extension. |
| + DCHECK(XTestQueryExtension(x11_util::GetXDisplay(), |
| + &event_base, &error_base, |
| + &major, &minor)); |
| + } |
| +#endif |
| + |
| + // The following code is an attempt to grab inputs by closing |
| + // supposedly opened menu. This happens when a plugin has a menu |
| + // opened. |
| + if (kbd_grab_status_ == GDK_GRAB_ALREADY_GRABBED || |
| + kbd_grab_status_ == GDK_GRAB_FROZEN) { |
| + // Send escape key if the keyboard is grabbed by other client. |
| + Display* display = x11_util::GetXDisplay(); |
|
Daniel Erat
2010/11/16 21:58:06
So the reason for adding a server grab around this
|
| + KeyCode escape = XKeysymToKeycode(display, XK_Escape); // escape |
| + XTestFakeKeyEvent(display, escape, True, CurrentTime); |
| + XTestFakeKeyEvent(display, escape, False, CurrentTime); |
| + XFlush(display); |
| + } else if (mouse_grab_status_ == GDK_GRAB_ALREADY_GRABBED || |
|
Daniel Erat
2010/11/16 21:58:06
why 'else if' instead of keeping this as an indepe
|
| + mouse_grab_status_ == GDK_GRAB_FROZEN) { |
|
Daniel Erat
2010/11/16 21:58:06
nit: indent this to line up with the mouse_grab_st
|
| + // Successfully grabbed the keyboard, but pointer is still |
| + // grabbed by other client. Another attempt to close supposedly |
| + // opened menu by emulating keypress at the left top corner. |
| + Display* display = x11_util::GetXDisplay(); |
| + Window root, child; |
| + int root_x, root_y, win_x, winy; |
| + unsigned int mask; |
| + XQueryPointer(display, |
| + x11_util::GetX11WindowFromGtkWidget(window_contents()), |
| + &root, &child, &root_x, &root_y, |
| + &win_x, &winy, &mask); |
| + XTestFakeMotionEvent(display, -1, -1, -1, CurrentTime); |
|
Daniel Erat
2010/11/16 21:58:06
I'm a bit nervous about (-1, -1) being used; there
oshima
2010/11/17 01:00:43
changed to -10000, -10000
|
| + XTestFakeButtonEvent(display, 1, True, CurrentTime); |
| + XTestFakeButtonEvent(display, 1, False, CurrentTime); |
| + // Move the pointer back. |
| + XTestFakeMotionEvent(display, -1, root_x, root_y, CurrentTime); |
| + XFlush(display); |
| + } |
| } |
| virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event) { |