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

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

Issue 26427002: Add always-on-top property to app windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed file modes for test files Created 7 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
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_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
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 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 bool DesktopRootWindowHostX11::IsMinimized() const { 426 bool DesktopRootWindowHostX11::IsMinimized() const {
426 return HasWMSpecProperty("_NET_WM_STATE_HIDDEN"); 427 return HasWMSpecProperty("_NET_WM_STATE_HIDDEN");
427 } 428 }
428 429
429 430
430 bool DesktopRootWindowHostX11::HasCapture() const { 431 bool DesktopRootWindowHostX11::HasCapture() const {
431 return g_current_capture == this; 432 return g_current_capture == this;
432 } 433 }
433 434
434 void DesktopRootWindowHostX11::SetAlwaysOnTop(bool always_on_top) { 435 void DesktopRootWindowHostX11::SetAlwaysOnTop(bool always_on_top) {
436 always_on_top_ = always_on_top;
435 SetWMSpecState(always_on_top, 437 SetWMSpecState(always_on_top,
436 atom_cache_.GetAtom("_NET_WM_STATE_ABOVE"), 438 atom_cache_.GetAtom("_NET_WM_STATE_ABOVE"),
437 None); 439 None);
438 } 440 }
439 441
442 bool DesktopRootWindowHostX11::IsAlwaysOnTop() const {
443 return always_on_top_;
444 }
445
440 void DesktopRootWindowHostX11::SetWindowTitle(const string16& title) { 446 void DesktopRootWindowHostX11::SetWindowTitle(const string16& title) {
441 XStoreName(xdisplay_, xwindow_, UTF16ToUTF8(title).c_str()); 447 XStoreName(xdisplay_, xwindow_, UTF16ToUTF8(title).c_str());
442 } 448 }
443 449
444 void DesktopRootWindowHostX11::ClearNativeFocus() { 450 void DesktopRootWindowHostX11::ClearNativeFocus() {
445 // This method is weird and misnamed. Instead of clearing the native focus, 451 // This method is weird and misnamed. Instead of clearing the native focus,
446 // it sets the focus to our |content_window_|, which will trigger a cascade 452 // it sets the focus to our |content_window_|, which will trigger a cascade
447 // of focus changes into views. 453 // of focus changes into views.
448 if (content_window_ && aura::client::GetFocusClient(content_window_) && 454 if (content_window_ && aura::client::GetFocusClient(content_window_) &&
449 content_window_->Contains( 455 content_window_->Contains(
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 // mapped. So we manually change the state. 913 // mapped. So we manually change the state.
908 XChangeProperty (xdisplay_, 914 XChangeProperty (xdisplay_,
909 xwindow_, 915 xwindow_,
910 atom_cache_.GetAtom("_NET_WM_STATE"), 916 atom_cache_.GetAtom("_NET_WM_STATE"),
911 XA_ATOM, 917 XA_ATOM,
912 32, 918 32,
913 PropModeAppend, 919 PropModeAppend,
914 reinterpret_cast<unsigned char*>(&atom), 1); 920 reinterpret_cast<unsigned char*>(&atom), 1);
915 } 921 }
916 922
923 // If the window should stay on top of other windows, add the
924 // _NET_WM_STATE_ABOVE property.
925 always_on_top_ = params.keep_on_top;
926 if (always_on_top_) {
927 Atom atom = atom_cache_.GetAtom("_NET_WM_STATE_ABOVE");
928 XChangeProperty (xdisplay_,
Elliot Glaysher 2013/10/08 18:05:00 This will clobber the XChangeProperty immediately
tmdiep 2013/10/09 02:15:04 Thanks for that. Fixed.
929 xwindow_,
930 atom_cache_.GetAtom("_NET_WM_STATE"),
931 XA_ATOM,
932 32,
933 PropModeAppend,
934 reinterpret_cast<unsigned char*>(&atom), 1);
935 }
936
917 if (!params.wm_class_name.empty() || !params.wm_class_class.empty()) { 937 if (!params.wm_class_name.empty() || !params.wm_class_class.empty()) {
918 ui::SetWindowClassHint( 938 ui::SetWindowClassHint(
919 xdisplay_, xwindow_, params.wm_class_name, params.wm_class_class); 939 xdisplay_, xwindow_, params.wm_class_name, params.wm_class_class);
920 } 940 }
921 } 941 }
922 942
923 aura::RootWindow* DesktopRootWindowHostX11::InitRootWindow( 943 aura::RootWindow* DesktopRootWindowHostX11::InitRootWindow(
924 const Widget::InitParams& params) { 944 const Widget::InitParams& params) {
925 aura::RootWindow::CreateParams rw_params(bounds_); 945 aura::RootWindow::CreateParams rw_params(bounds_);
926 rw_params.host = this; 946 rw_params.host = this;
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 } else if (IsMaximized() && restored_bounds_.IsEmpty()) { 1369 } else if (IsMaximized() && restored_bounds_.IsEmpty()) {
1350 // The request that we become maximized originated from a different 1370 // The request that we become maximized originated from a different
1351 // process. |bounds_| already contains our maximized bounds. Do a 1371 // process. |bounds_| already contains our maximized bounds. Do a
1352 // best effort attempt to get restored bounds by setting it to our 1372 // best effort attempt to get restored bounds by setting it to our
1353 // previously set bounds (and if we get this wrong, we aren't any 1373 // previously set bounds (and if we get this wrong, we aren't any
1354 // worse off since we'd otherwise be returning our maximized bounds). 1374 // worse off since we'd otherwise be returning our maximized bounds).
1355 restored_bounds_ = previous_bounds_; 1375 restored_bounds_ = previous_bounds_;
1356 } 1376 }
1357 1377
1358 is_fullscreen_ = HasWMSpecProperty("_NET_WM_STATE_FULLSCREEN"); 1378 is_fullscreen_ = HasWMSpecProperty("_NET_WM_STATE_FULLSCREEN");
1379 always_on_top_ = HasWMSpecProperty("_NET_WM_STATE_ABOVE");
1359 1380
1360 // Now that we have different window properties, we may need to 1381 // Now that we have different window properties, we may need to
1361 // relayout the window. (The windows code doesn't need this because 1382 // relayout the window. (The windows code doesn't need this because
1362 // their window change is synchronous.) 1383 // their window change is synchronous.)
1363 // 1384 //
1364 // TODO(erg): While this does work, there's a quick flash showing the 1385 // TODO(erg): While this does work, there's a quick flash showing the
1365 // tabstrip/toolbar/etc. when going into fullscreen mode before hiding 1386 // tabstrip/toolbar/etc. when going into fullscreen mode before hiding
1366 // those parts of the UI because we receive the sizing event from the 1387 // those parts of the UI because we receive the sizing event from the
1367 // window manager before we receive the event that changes the 1388 // window manager before we receive the event that changes the
1368 // fullscreen state. Unsure what to do about that. 1389 // fullscreen state. Unsure what to do about that.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 if (linux_ui) { 1425 if (linux_ui) {
1405 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); 1426 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme();
1406 if (native_theme) 1427 if (native_theme)
1407 return native_theme; 1428 return native_theme;
1408 } 1429 }
1409 1430
1410 return ui::NativeTheme::instance(); 1431 return ui::NativeTheme::instance();
1411 } 1432 }
1412 1433
1413 } // namespace views 1434 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698