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

Side by Side Diff: ui/views/widget/desktop_aura/x11_desktop_handler.cc

Issue 1045443002: Make File-Picker modal on Linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 5 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/widget/desktop_aura/x11_desktop_handler.h" 5 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 29 matching lines...) Expand all
40 return g_handler; 40 return g_handler;
41 } 41 }
42 42
43 X11DesktopHandler::X11DesktopHandler() 43 X11DesktopHandler::X11DesktopHandler()
44 : xdisplay_(gfx::GetXDisplay()), 44 : xdisplay_(gfx::GetXDisplay()),
45 x_root_window_(DefaultRootWindow(xdisplay_)), 45 x_root_window_(DefaultRootWindow(xdisplay_)),
46 wm_user_time_ms_(0), 46 wm_user_time_ms_(0),
47 current_window_(None), 47 current_window_(None),
48 current_window_active_state_(NOT_ACTIVE), 48 current_window_active_state_(NOT_ACTIVE),
49 atom_cache_(xdisplay_, kAtomsToCache), 49 atom_cache_(xdisplay_, kAtomsToCache),
50 wm_supports_active_window_(false) { 50 wm_supports_active_window_(false),
51 modal_dialog_xid_(None) {
51 if (ui::PlatformEventSource::GetInstance()) 52 if (ui::PlatformEventSource::GetInstance())
52 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); 53 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
53 aura::Env::GetInstance()->AddObserver(this); 54 aura::Env::GetInstance()->AddObserver(this);
54 55
55 XWindowAttributes attr; 56 XWindowAttributes attr;
56 XGetWindowAttributes(xdisplay_, x_root_window_, &attr); 57 XGetWindowAttributes(xdisplay_, x_root_window_, &attr);
57 XSelectInput(xdisplay_, x_root_window_, 58 XSelectInput(xdisplay_, x_root_window_,
58 attr.your_event_mask | PropertyChangeMask | 59 attr.your_event_mask | PropertyChangeMask |
59 StructureNotifyMask | SubstructureNotifyMask); 60 StructureNotifyMask | SubstructureNotifyMask);
60 61
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 uint32_t X11DesktopHandler::DispatchEvent(const ui::PlatformEvent& event) { 164 uint32_t X11DesktopHandler::DispatchEvent(const ui::PlatformEvent& event) {
164 switch (event->type) { 165 switch (event->type) {
165 case PropertyNotify: { 166 case PropertyNotify: {
166 // Check for a change to the active window. 167 // Check for a change to the active window.
167 CHECK_EQ(x_root_window_, event->xproperty.window); 168 CHECK_EQ(x_root_window_, event->xproperty.window);
168 ::Atom active_window_atom = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); 169 ::Atom active_window_atom = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW");
169 if (event->xproperty.atom == active_window_atom) { 170 if (event->xproperty.atom == active_window_atom) {
170 ::Window window; 171 ::Window window;
171 if (ui::GetXIDProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &window) && 172 if (ui::GetXIDProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &window) &&
172 window) { 173 window) {
174 // Set focus to the modal dialog.
175 if (modal_dialog_xid_) {
176 XSetInputFocus(xdisplay_, modal_dialog_xid_, RevertToParent,
177 CurrentTime);
sadrul 2015/06/30 17:30:56 Is it necessary to maintain a separate modal_dialo
joone 2015/07/01 03:16:06 Yes, we can query the DWTHX11.
178 break;
179 }
180
173 OnActiveWindowChanged(window, ACTIVE); 181 OnActiveWindowChanged(window, ACTIVE);
174 } 182 }
175 } 183 }
176 break; 184 break;
177 } 185 }
178 186
179 case CreateNotify: 187 case CreateNotify:
180 OnWindowCreatedOrDestroyed(event->type, event->xcreatewindow.window); 188 OnWindowCreatedOrDestroyed(event->type, event->xcreatewindow.window);
181 break; 189 break;
182 case DestroyNotify: 190 case DestroyNotify:
(...skipping 26 matching lines...) Expand all
209 old_host->HandleNativeWidgetActivationChanged(false); 217 old_host->HandleNativeWidgetActivationChanged(false);
210 } 218 }
211 219
212 // Update the current window ID to effectively change the active widget. 220 // Update the current window ID to effectively change the active widget.
213 current_window_ = xid; 221 current_window_ = xid;
214 current_window_active_state_ = active_state; 222 current_window_active_state_ = active_state;
215 223
216 if (active_state == ACTIVE) { 224 if (active_state == ACTIVE) {
217 DesktopWindowTreeHostX11* new_host = 225 DesktopWindowTreeHostX11* new_host =
218 views::DesktopWindowTreeHostX11::GetHostForXID(xid); 226 views::DesktopWindowTreeHostX11::GetHostForXID(xid);
219 if (new_host) 227 if (new_host) {
220 new_host->HandleNativeWidgetActivationChanged(true); 228 new_host->HandleNativeWidgetActivationChanged(true);
229 modal_dialog_xid_ = new_host->GetModalDialog();
sadrul 2015/06/30 17:30:56 Should you set the input-focus here instead?
joone 2015/07/01 03:16:06 The file dialog doesn't pop-up well when opening t
sadrul 2015/07/01 03:58:14 Can you clarify what you mean? It should be OK to
joone 2015/07/01 21:40:37 Yes, each window can have its own modal dialog and
230 }
221 } 231 }
222 } 232 }
223 233
224 void X11DesktopHandler::OnWindowCreatedOrDestroyed(int event_type, 234 void X11DesktopHandler::OnWindowCreatedOrDestroyed(int event_type,
225 XID window) { 235 XID window) {
226 // Menus created by Chrome can be drag and drop targets. Since they are 236 // Menus created by Chrome can be drag and drop targets. Since they are
227 // direct children of the screen root window and have override_redirect 237 // direct children of the screen root window and have override_redirect
228 // we cannot use regular _NET_CLIENT_LIST_STACKING property to find them 238 // we cannot use regular _NET_CLIENT_LIST_STACKING property to find them
229 // and use a separate cache to keep track of them. 239 // and use a separate cache to keep track of them.
230 // TODO(varkha): Implement caching of all top level X windows and their 240 // TODO(varkha): Implement caching of all top level X windows and their
231 // coordinates and stacking order to eliminate repeated calls to the X server 241 // coordinates and stacking order to eliminate repeated calls to the X server
232 // during mouse movement, drag and shaping events. 242 // during mouse movement, drag and shaping events.
233 if (event_type == CreateNotify) { 243 if (event_type == CreateNotify) {
234 // The window might be destroyed if the message pump did not get a chance to 244 // The window might be destroyed if the message pump did not get a chance to
235 // run but we can safely ignore the X error. 245 // run but we can safely ignore the X error.
236 gfx::X11ErrorTracker error_tracker; 246 gfx::X11ErrorTracker error_tracker;
237 ui::XMenuList::GetInstance()->MaybeRegisterMenu(window); 247 ui::XMenuList::GetInstance()->MaybeRegisterMenu(window);
238 } else { 248 } else {
239 ui::XMenuList::GetInstance()->MaybeUnregisterMenu(window); 249 ui::XMenuList::GetInstance()->MaybeUnregisterMenu(window);
240 } 250 }
241 251
242 if (event_type == DestroyNotify) { 252 if (event_type == DestroyNotify) {
243 // Notify the XForeignWindowManager that |window| has been destroyed. 253 // Notify the XForeignWindowManager that |window| has been destroyed.
244 ui::XForeignWindowManager::GetInstance()->OnWindowDestroyed(window); 254 ui::XForeignWindowManager::GetInstance()->OnWindowDestroyed(window);
245 } 255 }
246 } 256 }
247 257
248 } // namespace views 258 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698