| OLD | NEW |
| 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_root_window_host_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_root_window_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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 DesktopNativeWidgetAura* desktop_native_widget_aura, | 117 DesktopNativeWidgetAura* desktop_native_widget_aura, |
| 118 const gfx::Rect& initial_bounds) | 118 const gfx::Rect& initial_bounds) |
| 119 : close_widget_factory_(this), | 119 : close_widget_factory_(this), |
| 120 xdisplay_(gfx::GetXDisplay()), | 120 xdisplay_(gfx::GetXDisplay()), |
| 121 xwindow_(0), | 121 xwindow_(0), |
| 122 x_root_window_(DefaultRootWindow(xdisplay_)), | 122 x_root_window_(DefaultRootWindow(xdisplay_)), |
| 123 atom_cache_(xdisplay_, kAtomsToCache), | 123 atom_cache_(xdisplay_, kAtomsToCache), |
| 124 window_mapped_(false), | 124 window_mapped_(false), |
| 125 focus_when_shown_(false), | 125 focus_when_shown_(false), |
| 126 is_fullscreen_(false), | 126 is_fullscreen_(false), |
| 127 is_always_on_top_(false), |
| 127 current_cursor_(ui::kCursorNull), | 128 current_cursor_(ui::kCursorNull), |
| 128 native_widget_delegate_(native_widget_delegate), | 129 native_widget_delegate_(native_widget_delegate), |
| 129 desktop_native_widget_aura_(desktop_native_widget_aura) { | 130 desktop_native_widget_aura_(desktop_native_widget_aura) { |
| 130 } | 131 } |
| 131 | 132 |
| 132 DesktopRootWindowHostX11::~DesktopRootWindowHostX11() { | 133 DesktopRootWindowHostX11::~DesktopRootWindowHostX11() { |
| 133 root_window_->ClearProperty(kHostForRootWindow); | 134 root_window_->ClearProperty(kHostForRootWindow); |
| 134 aura::client::SetFocusClient(root_window_, NULL); | 135 aura::client::SetFocusClient(root_window_, NULL); |
| 135 aura::client::SetActivationClient(root_window_, NULL); | 136 aura::client::SetActivationClient(root_window_, NULL); |
| 136 } | 137 } |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 bool DesktopRootWindowHostX11::IsMinimized() const { | 427 bool DesktopRootWindowHostX11::IsMinimized() const { |
| 427 return HasWMSpecProperty("_NET_WM_STATE_HIDDEN"); | 428 return HasWMSpecProperty("_NET_WM_STATE_HIDDEN"); |
| 428 } | 429 } |
| 429 | 430 |
| 430 | 431 |
| 431 bool DesktopRootWindowHostX11::HasCapture() const { | 432 bool DesktopRootWindowHostX11::HasCapture() const { |
| 432 return g_current_capture == this; | 433 return g_current_capture == this; |
| 433 } | 434 } |
| 434 | 435 |
| 435 void DesktopRootWindowHostX11::SetAlwaysOnTop(bool always_on_top) { | 436 void DesktopRootWindowHostX11::SetAlwaysOnTop(bool always_on_top) { |
| 437 is_always_on_top_ = always_on_top; |
| 436 SetWMSpecState(always_on_top, | 438 SetWMSpecState(always_on_top, |
| 437 atom_cache_.GetAtom("_NET_WM_STATE_ABOVE"), | 439 atom_cache_.GetAtom("_NET_WM_STATE_ABOVE"), |
| 438 None); | 440 None); |
| 439 } | 441 } |
| 440 | 442 |
| 443 bool DesktopRootWindowHostX11::IsAlwaysOnTop() const { |
| 444 return is_always_on_top_; |
| 445 } |
| 446 |
| 441 void DesktopRootWindowHostX11::SetWindowTitle(const string16& title) { | 447 void DesktopRootWindowHostX11::SetWindowTitle(const string16& title) { |
| 442 XStoreName(xdisplay_, xwindow_, UTF16ToUTF8(title).c_str()); | 448 XStoreName(xdisplay_, xwindow_, UTF16ToUTF8(title).c_str()); |
| 443 } | 449 } |
| 444 | 450 |
| 445 void DesktopRootWindowHostX11::ClearNativeFocus() { | 451 void DesktopRootWindowHostX11::ClearNativeFocus() { |
| 446 // This method is weird and misnamed. Instead of clearing the native focus, | 452 // This method is weird and misnamed. Instead of clearing the native focus, |
| 447 // it sets the focus to our |content_window_|, which will trigger a cascade | 453 // it sets the focus to our |content_window_|, which will trigger a cascade |
| 448 // of focus changes into views. | 454 // of focus changes into views. |
| 449 if (content_window_ && aura::client::GetFocusClient(content_window_) && | 455 if (content_window_ && aura::client::GetFocusClient(content_window_) && |
| 450 content_window_->Contains( | 456 content_window_->Contains( |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 reinterpret_cast<unsigned char*>(&pid), 1); | 897 reinterpret_cast<unsigned char*>(&pid), 1); |
| 892 | 898 |
| 893 XChangeProperty(xdisplay_, | 899 XChangeProperty(xdisplay_, |
| 894 xwindow_, | 900 xwindow_, |
| 895 atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE"), | 901 atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE"), |
| 896 XA_ATOM, | 902 XA_ATOM, |
| 897 32, | 903 32, |
| 898 PropModeReplace, | 904 PropModeReplace, |
| 899 reinterpret_cast<unsigned char*>(&window_type), 1); | 905 reinterpret_cast<unsigned char*>(&window_type), 1); |
| 900 | 906 |
| 907 // List of window state properties (_NET_WM_STATE) to set, if any. |
| 908 std::vector< ::Atom> state_atom_list; |
| 909 |
| 901 // Remove popup windows from taskbar. | 910 // Remove popup windows from taskbar. |
| 902 if (params.type == Widget::InitParams::TYPE_POPUP || | 911 if (params.type == Widget::InitParams::TYPE_POPUP || |
| 903 params.type == Widget::InitParams::TYPE_BUBBLE) { | 912 params.type == Widget::InitParams::TYPE_BUBBLE) { |
| 904 Atom atom = atom_cache_.GetAtom("_NET_WM_STATE_SKIP_TASKBAR"); | 913 state_atom_list.push_back( |
| 914 atom_cache_.GetAtom("_NET_WM_STATE_SKIP_TASKBAR")); |
| 915 } |
| 905 | 916 |
| 906 // Setting _NET_WM_STATE by sending a message to the root_window (with | 917 // If the window should stay on top of other windows, add the |
| 907 // SetWMSpecState) has no effect here since the window has not yet been | 918 // _NET_WM_STATE_ABOVE property. |
| 908 // mapped. So we manually change the state. | 919 is_always_on_top_ = params.keep_on_top; |
| 909 XChangeProperty (xdisplay_, | 920 if (is_always_on_top_) |
| 910 xwindow_, | 921 state_atom_list.push_back(atom_cache_.GetAtom("_NET_WM_STATE_ABOVE")); |
| 911 atom_cache_.GetAtom("_NET_WM_STATE"), | 922 |
| 912 XA_ATOM, | 923 // Setting _NET_WM_STATE by sending a message to the root_window (with |
| 913 32, | 924 // SetWMSpecState) has no effect here since the window has not yet been |
| 914 PropModeAppend, | 925 // mapped. So we manually change the state. |
| 915 reinterpret_cast<unsigned char*>(&atom), 1); | 926 if (!state_atom_list.empty()) { |
| 927 ui::SetAtomArrayProperty(xwindow_, |
| 928 "_NET_WM_STATE", |
| 929 "ATOM", |
| 930 state_atom_list); |
| 916 } | 931 } |
| 917 | 932 |
| 918 if (!params.wm_class_name.empty() || !params.wm_class_class.empty()) { | 933 if (!params.wm_class_name.empty() || !params.wm_class_class.empty()) { |
| 919 ui::SetWindowClassHint( | 934 ui::SetWindowClassHint( |
| 920 xdisplay_, xwindow_, params.wm_class_name, params.wm_class_class); | 935 xdisplay_, xwindow_, params.wm_class_name, params.wm_class_class); |
| 921 } | 936 } |
| 922 } | 937 } |
| 923 | 938 |
| 924 aura::RootWindow* DesktopRootWindowHostX11::InitRootWindow( | 939 aura::RootWindow* DesktopRootWindowHostX11::InitRootWindow( |
| 925 const Widget::InitParams& params) { | 940 const Widget::InitParams& params) { |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 } else if (IsMaximized() && restored_bounds_.IsEmpty()) { | 1363 } else if (IsMaximized() && restored_bounds_.IsEmpty()) { |
| 1349 // The request that we become maximized originated from a different | 1364 // The request that we become maximized originated from a different |
| 1350 // process. |bounds_| already contains our maximized bounds. Do a | 1365 // process. |bounds_| already contains our maximized bounds. Do a |
| 1351 // best effort attempt to get restored bounds by setting it to our | 1366 // best effort attempt to get restored bounds by setting it to our |
| 1352 // previously set bounds (and if we get this wrong, we aren't any | 1367 // previously set bounds (and if we get this wrong, we aren't any |
| 1353 // worse off since we'd otherwise be returning our maximized bounds). | 1368 // worse off since we'd otherwise be returning our maximized bounds). |
| 1354 restored_bounds_ = previous_bounds_; | 1369 restored_bounds_ = previous_bounds_; |
| 1355 } | 1370 } |
| 1356 | 1371 |
| 1357 is_fullscreen_ = HasWMSpecProperty("_NET_WM_STATE_FULLSCREEN"); | 1372 is_fullscreen_ = HasWMSpecProperty("_NET_WM_STATE_FULLSCREEN"); |
| 1373 is_always_on_top_ = HasWMSpecProperty("_NET_WM_STATE_ABOVE"); |
| 1358 | 1374 |
| 1359 // Now that we have different window properties, we may need to | 1375 // Now that we have different window properties, we may need to |
| 1360 // relayout the window. (The windows code doesn't need this because | 1376 // relayout the window. (The windows code doesn't need this because |
| 1361 // their window change is synchronous.) | 1377 // their window change is synchronous.) |
| 1362 // | 1378 // |
| 1363 // TODO(erg): While this does work, there's a quick flash showing the | 1379 // TODO(erg): While this does work, there's a quick flash showing the |
| 1364 // tabstrip/toolbar/etc. when going into fullscreen mode before hiding | 1380 // tabstrip/toolbar/etc. when going into fullscreen mode before hiding |
| 1365 // those parts of the UI because we receive the sizing event from the | 1381 // those parts of the UI because we receive the sizing event from the |
| 1366 // window manager before we receive the event that changes the | 1382 // window manager before we receive the event that changes the |
| 1367 // fullscreen state. Unsure what to do about that. | 1383 // fullscreen state. Unsure what to do about that. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1403 if (linux_ui) { | 1419 if (linux_ui) { |
| 1404 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); | 1420 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); |
| 1405 if (native_theme) | 1421 if (native_theme) |
| 1406 return native_theme; | 1422 return native_theme; |
| 1407 } | 1423 } |
| 1408 | 1424 |
| 1409 return ui::NativeTheme::instance(); | 1425 return ui::NativeTheme::instance(); |
| 1410 } | 1426 } |
| 1411 | 1427 |
| 1412 } // namespace views | 1428 } // namespace views |
| OLD | NEW |