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

Unified Diff: chrome/browser/extensions/extension_commands_global_registry_apitest.cc

Issue 2329323002: Avoid blocking while mapping an X11 window (Closed)
Patch Set: UpdateMinAndMaxSize in MapWindow Created 4 years, 2 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 | « AUTHORS ('k') | ui/events/platform/x11/x11_event_source.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_commands_global_registry_apitest.cc
diff --git a/chrome/browser/extensions/extension_commands_global_registry_apitest.cc b/chrome/browser/extensions/extension_commands_global_registry_apitest.cc
index f4e17f1a9062e7649b02ece130d6dbaaa45dcd6d..ac5c252e9207b157acb21c58cc68ab84beb308aa 100644
--- a/chrome/browser/extensions/extension_commands_global_registry_apitest.cc
+++ b/chrome/browser/extensions/extension_commands_global_registry_apitest.cc
@@ -17,9 +17,11 @@
#include <X11/Xlib.h>
#include <X11/extensions/XTest.h>
#include <X11/keysym.h>
-
+#include "ui/aura/window.h"
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
#include "ui/gfx/x/x11_types.h"
+#include "ui/views/widget/desktop_aura/desktop_window_tree_host_observer_x11.h"
+#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
#endif
#if defined(OS_MACOSX)
@@ -115,6 +117,26 @@ void SendNativeCommandShift(int key_code) {
}
#endif
+#if defined(OS_LINUX) && defined(USE_X11)
+class GlobalCommandTreeHostObserver
+ : public views::DesktopWindowTreeHostObserverX11 {
+ public:
+ void OnWindowMapped(unsigned long xid) override {
+ // On Linux, our infrastructure for sending keys just synthesize keyboard
+ // event and send them directly to the specified window, without notifying
+ // the X root window. It didn't work while testing global shortcut because
+ // the stuff of global shortcut on Linux need to be notified when KeyPress
+ // event is happening on X root window. So we simulate the keyboard input
+ // here.
+ SendNativeKeyEventToXDisplay(ui::VKEY_1, true, true, false);
+ SendNativeKeyEventToXDisplay(ui::VKEY_A, true, true, false);
+ SendNativeKeyEventToXDisplay(ui::VKEY_8, true, true, false);
+ }
+
+ void OnWindowUnmapped(unsigned long xid) override {}
+};
+#endif
+
// Test the basics of global commands and make sure they work when Chrome
// doesn't have focus. Also test that non-global commands are not treated as
// global and that keys beyond Ctrl+Shift+[0..9] cannot be auto-assigned by an
@@ -155,16 +177,16 @@ IN_PROC_BROWSER_TEST_F(GlobalCommandsApiTest, MAYBE_GlobalCommand) {
incognito_browser, ui::VKEY_8, true, true, false, false));
#elif defined(OS_LINUX) && defined(USE_X11)
// Create an incognito browser to capture the focus.
- CreateIncognitoBrowser();
+ Browser* incognito_browser = CreateIncognitoBrowser();
+
+ views::DesktopWindowTreeHostX11* host =
+ static_cast<views::DesktopWindowTreeHostX11*>(
+ incognito_browser->window()->GetNativeWindow()->GetHost());
+
+ GlobalCommandTreeHostObserver* observer = new GlobalCommandTreeHostObserver();
+ // The observer sends the commands after window mapping
+ host->AddObserver(observer);
- // On Linux, our infrastructure for sending keys just synthesize keyboard
- // event and send them directly to the specified window, without notifying the
- // X root window. It didn't work while testing global shortcut because the
- // stuff of global shortcut on Linux need to be notified when KeyPress event
- // is happening on X root window. So we simulate the keyboard input here.
- SendNativeKeyEventToXDisplay(ui::VKEY_1, true, true, false);
- SendNativeKeyEventToXDisplay(ui::VKEY_A, true, true, false);
- SendNativeKeyEventToXDisplay(ui::VKEY_8, true, true, false);
#elif defined(OS_MACOSX)
// Create an incognito browser to capture the focus.
CreateIncognitoBrowser();
« no previous file with comments | « AUTHORS ('k') | ui/events/platform/x11/x11_event_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698