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

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

Issue 1624793002: Make File-Picker modal on Linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove ScopedHandle 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 unified diff | Download patch
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h ('k') | 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) 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/desktop_window_tree_host_x11.h" 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
6 6
7 #include <X11/extensions/shape.h> 7 #include <X11/extensions/shape.h>
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/Xatom.h> 9 #include <X11/Xatom.h>
10 #include <X11/Xregion.h> 10 #include <X11/Xregion.h>
(...skipping 21 matching lines...) Expand all
32 #include "ui/base/ime/input_method.h" 32 #include "ui/base/ime/input_method.h"
33 #include "ui/base/x/x11_util.h" 33 #include "ui/base/x/x11_util.h"
34 #include "ui/base/x/x11_util_internal.h" 34 #include "ui/base/x/x11_util_internal.h"
35 #include "ui/base/x/x11_window_event_manager.h" 35 #include "ui/base/x/x11_window_event_manager.h"
36 #include "ui/display/display.h" 36 #include "ui/display/display.h"
37 #include "ui/display/screen.h" 37 #include "ui/display/screen.h"
38 #include "ui/events/devices/x11/device_data_manager_x11.h" 38 #include "ui/events/devices/x11/device_data_manager_x11.h"
39 #include "ui/events/devices/x11/device_list_cache_x11.h" 39 #include "ui/events/devices/x11/device_list_cache_x11.h"
40 #include "ui/events/devices/x11/touch_factory_x11.h" 40 #include "ui/events/devices/x11/touch_factory_x11.h"
41 #include "ui/events/event_utils.h" 41 #include "ui/events/event_utils.h"
42 #include "ui/events/null_event_targeter.h"
42 #include "ui/events/platform/platform_event_source.h" 43 #include "ui/events/platform/platform_event_source.h"
43 #include "ui/events/platform/x11/x11_event_source.h" 44 #include "ui/events/platform/x11/x11_event_source.h"
44 #include "ui/gfx/geometry/insets.h" 45 #include "ui/gfx/geometry/insets.h"
45 #include "ui/gfx/geometry/size_conversions.h" 46 #include "ui/gfx/geometry/size_conversions.h"
46 #include "ui/gfx/image/image_skia.h" 47 #include "ui/gfx/image/image_skia.h"
47 #include "ui/gfx/image/image_skia_rep.h" 48 #include "ui/gfx/image/image_skia_rep.h"
48 #include "ui/gfx/path.h" 49 #include "ui/gfx/path.h"
49 #include "ui/gfx/path_x11.h" 50 #include "ui/gfx/path_x11.h"
50 #include "ui/native_theme/native_theme.h" 51 #include "ui/native_theme/native_theme.h"
51 #include "ui/native_theme/native_theme_aura.h" 52 #include "ui/native_theme/native_theme_aura.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 desktop_native_widget_aura_(desktop_native_widget_aura), 200 desktop_native_widget_aura_(desktop_native_widget_aura),
200 content_window_(NULL), 201 content_window_(NULL),
201 window_parent_(NULL), 202 window_parent_(NULL),
202 custom_window_shape_(false), 203 custom_window_shape_(false),
203 urgency_hint_set_(false), 204 urgency_hint_set_(false),
204 has_pointer_grab_(false), 205 has_pointer_grab_(false),
205 activatable_(true), 206 activatable_(true),
206 has_pointer_(false), 207 has_pointer_(false),
207 has_window_focus_(false), 208 has_window_focus_(false),
208 has_pointer_focus_(false), 209 has_pointer_focus_(false),
209 close_widget_factory_(this) {} 210 modal_dialog_xid_(0),
211 close_widget_factory_(this),
212 weak_factory_(this) {}
210 213
211 DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { 214 DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() {
212 window()->ClearProperty(kHostForRootWindow); 215 window()->ClearProperty(kHostForRootWindow);
213 aura::client::SetWindowMoveClient(window(), NULL); 216 aura::client::SetWindowMoveClient(window(), NULL);
214 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); 217 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this);
215 DestroyDispatcher(); 218 DestroyDispatcher();
216 } 219 }
217 220
218 // static 221 // static
219 aura::Window* DesktopWindowTreeHostX11::GetContentWindowForXID(XID xid) { 222 aura::Window* DesktopWindowTreeHostX11::GetContentWindowForXID(XID xid) {
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 if (g_current_capture && g_current_capture != this && 1770 if (g_current_capture && g_current_capture != this &&
1768 event->type() == ui::ET_TOUCH_PRESSED) { 1771 event->type() == ui::ET_TOUCH_PRESSED) {
1769 ConvertEventToDifferentHost(event, g_current_capture); 1772 ConvertEventToDifferentHost(event, g_current_capture);
1770 g_current_capture->SendEventToProcessor(event); 1773 g_current_capture->SendEventToProcessor(event);
1771 } else { 1774 } else {
1772 SendEventToProcessor(event); 1775 SendEventToProcessor(event);
1773 } 1776 }
1774 } 1777 }
1775 1778
1776 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { 1779 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) {
1777 GetInputMethod()->DispatchKeyEvent(event); 1780 if (native_widget_delegate_->AsWidget()->IsActive())
1781 GetInputMethod()->DispatchKeyEvent(event);
1778 } 1782 }
1779 1783
1780 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( 1784 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost(
1781 ui::LocatedEvent* located_event, 1785 ui::LocatedEvent* located_event,
1782 DesktopWindowTreeHostX11* host) { 1786 DesktopWindowTreeHostX11* host) {
1783 DCHECK_NE(this, host); 1787 DCHECK_NE(this, host);
1784 const display::Display display_src = 1788 const display::Display display_src =
1785 display::Screen::GetScreen()->GetDisplayNearestWindow(window()); 1789 display::Screen::GetScreen()->GetDisplayNearestWindow(window());
1786 const display::Display display_dest = 1790 const display::Display display_dest =
1787 display::Screen::GetScreen()->GetDisplayNearestWindow(host->window()); 1791 display::Screen::GetScreen()->GetDisplayNearestWindow(host->window());
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 return gfx::ToEnclosingRect(rect_in_dip); 2293 return gfx::ToEnclosingRect(rect_in_dip);
2290 } 2294 }
2291 2295
2292 gfx::Rect DesktopWindowTreeHostX11::ToPixelRect( 2296 gfx::Rect DesktopWindowTreeHostX11::ToPixelRect(
2293 const gfx::Rect& rect_in_dip) const { 2297 const gfx::Rect& rect_in_dip) const {
2294 gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip); 2298 gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip);
2295 GetRootTransform().TransformRect(&rect_in_pixels); 2299 GetRootTransform().TransformRect(&rect_in_pixels);
2296 return gfx::ToEnclosingRect(rect_in_pixels); 2300 return gfx::ToEnclosingRect(rect_in_pixels);
2297 } 2301 }
2298 2302
2303 XID DesktopWindowTreeHostX11::GetModalDialog() {
2304 return modal_dialog_xid_;
2305 }
2306
2307 std::unique_ptr<base::Closure>
2308 DesktopWindowTreeHostX11::DisableEventListening(XID dialog) {
2309 DCHECK(dialog);
2310 DCHECK(!modal_dialog_xid_);
2311 modal_dialog_xid_ = dialog;
2312 // ScopedWindowTargeter is used to temporarily replace the event-targeter
2313 // with NullEventTargeter to make |dialog| modal.
2314 targeter_for_modal_.reset(new aura::ScopedWindowTargeter(window(),
2315 std::unique_ptr<ui::EventTargeter>(new ui::NullEventTargeter)));
2316
2317 return base::MakeUnique<base::Closure>(base::Bind(
2318 &DesktopWindowTreeHostX11::EnableEventListening,
2319 weak_factory_.GetWeakPtr()));
2320 }
2321
2322 void DesktopWindowTreeHostX11::EnableEventListening() {
2323 DCHECK(modal_dialog_xid_);
2324 modal_dialog_xid_ = 0;
2325 targeter_for_modal_.reset();
2326 }
2327
2299 //////////////////////////////////////////////////////////////////////////////// 2328 ////////////////////////////////////////////////////////////////////////////////
2300 // DesktopWindowTreeHost, public: 2329 // DesktopWindowTreeHost, public:
2301 2330
2302 // static 2331 // static
2303 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( 2332 DesktopWindowTreeHost* DesktopWindowTreeHost::Create(
2304 internal::NativeWidgetDelegate* native_widget_delegate, 2333 internal::NativeWidgetDelegate* native_widget_delegate,
2305 DesktopNativeWidgetAura* desktop_native_widget_aura) { 2334 DesktopNativeWidgetAura* desktop_native_widget_aura) {
2306 return new DesktopWindowTreeHostX11(native_widget_delegate, 2335 return new DesktopWindowTreeHostX11(native_widget_delegate,
2307 desktop_native_widget_aura); 2336 desktop_native_widget_aura);
2308 } 2337 }
2309 2338
2310 // static 2339 // static
2311 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { 2340 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) {
2312 const LinuxUI* linux_ui = LinuxUI::instance(); 2341 const LinuxUI* linux_ui = LinuxUI::instance();
2313 if (linux_ui) { 2342 if (linux_ui) {
2314 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); 2343 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window);
2315 if (native_theme) 2344 if (native_theme)
2316 return native_theme; 2345 return native_theme;
2317 } 2346 }
2318 2347
2319 return ui::NativeThemeAura::instance(); 2348 return ui::NativeThemeAura::instance();
2320 } 2349 }
2321 2350
2322 } // namespace views 2351 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698