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

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

Issue 1927203003: Add support for X11 workspaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove newline Created 4 years, 7 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_window_tree_host_x11.h" 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/Xregion.h> 8 #include <X11/Xregion.h>
9 #include <X11/Xutil.h> 9 #include <X11/Xutil.h>
10 #include <X11/extensions/XInput2.h> 10 #include <X11/extensions/XInput2.h>
11 #include <X11/extensions/shape.h> 11 #include <X11/extensions/shape.h>
12 12
13 #include <utility> 13 #include <utility>
14 14
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
19 #include "base/trace_event/trace_event.h" 20 #include "base/trace_event/trace_event.h"
20 #include "third_party/skia/include/core/SkPath.h" 21 #include "third_party/skia/include/core/SkPath.h"
21 #include "ui/aura/client/cursor_client.h" 22 #include "ui/aura/client/cursor_client.h"
22 #include "ui/aura/client/focus_client.h" 23 #include "ui/aura/client/focus_client.h"
23 #include "ui/aura/window.h" 24 #include "ui/aura/window.h"
24 #include "ui/aura/window_event_dispatcher.h" 25 #include "ui/aura/window_event_dispatcher.h"
25 #include "ui/aura/window_property.h" 26 #include "ui/aura/window_property.h"
26 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" 27 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h"
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 // We can't reliably track the restored bounds of a window, but we can get 558 // We can't reliably track the restored bounds of a window, but we can get
558 // the 90% case down. When *chrome* is the process that requests maximizing 559 // the 90% case down. When *chrome* is the process that requests maximizing
559 // or restoring bounds, we can record the current bounds before we request 560 // or restoring bounds, we can record the current bounds before we request
560 // maximization, and clear it when we detect a state change. 561 // maximization, and clear it when we detect a state change.
561 if (!restored_bounds_in_pixels_.IsEmpty()) 562 if (!restored_bounds_in_pixels_.IsEmpty())
562 return ToDIPRect(restored_bounds_in_pixels_); 563 return ToDIPRect(restored_bounds_in_pixels_);
563 564
564 return GetWindowBoundsInScreen(); 565 return GetWindowBoundsInScreen();
565 } 566 }
566 567
568 std::string DesktopWindowTreeHostX11::GetWorkspace() const {
569 int workspace_id;
570 if (ui::GetIntProperty(xwindow_, "_NET_WM_DESKTOP", &workspace_id))
571 return base::IntToString(workspace_id);
572 return "";
sky 2016/05/03 17:40:53 std::string()
Tom (Use chromium acct) 2016/05/03 19:38:39 Done.
573 }
574
567 gfx::Rect DesktopWindowTreeHostX11::GetWorkAreaBoundsInScreen() const { 575 gfx::Rect DesktopWindowTreeHostX11::GetWorkAreaBoundsInScreen() const {
568 return ToDIPRect(GetWorkAreaBoundsInPixels()); 576 return ToDIPRect(GetWorkAreaBoundsInPixels());
569 } 577 }
570 578
571 void DesktopWindowTreeHostX11::SetShape(SkRegion* native_region) { 579 void DesktopWindowTreeHostX11::SetShape(SkRegion* native_region) {
572 custom_window_shape_ = false; 580 custom_window_shape_ = false;
573 window_shape_.reset(); 581 window_shape_.reset();
574 582
575 if (native_region) { 583 if (native_region) {
576 gfx::Transform transform = GetRootTransform(); 584 gfx::Transform transform = GetRootTransform();
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 1227
1220 // If the window should stay on top of other windows, add the 1228 // If the window should stay on top of other windows, add the
1221 // _NET_WM_STATE_ABOVE property. 1229 // _NET_WM_STATE_ABOVE property.
1222 is_always_on_top_ = params.keep_on_top; 1230 is_always_on_top_ = params.keep_on_top;
1223 if (is_always_on_top_) 1231 if (is_always_on_top_)
1224 state_atom_list.push_back(atom_cache_.GetAtom("_NET_WM_STATE_ABOVE")); 1232 state_atom_list.push_back(atom_cache_.GetAtom("_NET_WM_STATE_ABOVE"));
1225 1233
1226 if (params.visible_on_all_workspaces) { 1234 if (params.visible_on_all_workspaces) {
1227 state_atom_list.push_back(atom_cache_.GetAtom("_NET_WM_STATE_STICKY")); 1235 state_atom_list.push_back(atom_cache_.GetAtom("_NET_WM_STATE_STICKY"));
1228 ui::SetIntProperty(xwindow_, "_NET_WM_DESKTOP", "CARDINAL", kAllDesktops); 1236 ui::SetIntProperty(xwindow_, "_NET_WM_DESKTOP", "CARDINAL", kAllDesktops);
1237 } else if (params.workspace.size()) {
sky 2016/05/03 17:40:53 !params.workspace.empty()
Tom (Use chromium acct) 2016/05/03 19:38:39 Done.
1238 int workspace;
1239 if (base::StringToInt(params.workspace, &workspace))
1240 ui::SetIntProperty(xwindow_, "_NET_WM_DESKTOP", "CARDINAL", workspace);
1229 } 1241 }
1230 1242
1231 // Setting _NET_WM_STATE by sending a message to the root_window (with 1243 // Setting _NET_WM_STATE by sending a message to the root_window (with
1232 // SetWMSpecState) has no effect here since the window has not yet been 1244 // SetWMSpecState) has no effect here since the window has not yet been
1233 // mapped. So we manually change the state. 1245 // mapped. So we manually change the state.
1234 if (!state_atom_list.empty()) { 1246 if (!state_atom_list.empty()) {
1235 ui::SetAtomArrayProperty(xwindow_, 1247 ui::SetAtomArrayProperty(xwindow_,
1236 "_NET_WM_STATE", 1248 "_NET_WM_STATE",
1237 "ATOM", 1249 "ATOM",
1238 state_atom_list); 1250 state_atom_list);
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 break; 1995 break;
1984 } 1996 }
1985 } 1997 }
1986 1998
1987 ui::MouseEvent mouseev(xev); 1999 ui::MouseEvent mouseev(xev);
1988 DispatchMouseEvent(&mouseev); 2000 DispatchMouseEvent(&mouseev);
1989 break; 2001 break;
1990 } 2002 }
1991 case PropertyNotify: { 2003 case PropertyNotify: {
1992 ::Atom changed_atom = xev->xproperty.atom; 2004 ::Atom changed_atom = xev->xproperty.atom;
1993 if (changed_atom == atom_cache_.GetAtom("_NET_WM_STATE")) 2005 if (changed_atom == atom_cache_.GetAtom("_NET_WM_STATE")) {
sky 2016/05/03 17:40:53 nit: no {} here as all branches are a single line.
Tom (Use chromium acct) 2016/05/03 19:38:39 Done.
1994 OnWMStateUpdated(); 2006 OnWMStateUpdated();
1995 else if (changed_atom == atom_cache_.GetAtom("_NET_FRAME_EXTENTS")) 2007 } else if (changed_atom == atom_cache_.GetAtom("_NET_FRAME_EXTENTS")) {
1996 OnFrameExtentsUpdated(); 2008 OnFrameExtentsUpdated();
2009 } else if (changed_atom == atom_cache_.GetAtom("_NET_WM_DESKTOP")) {
2010 OnHostWorkspaceChanged();
2011 }
1997 break; 2012 break;
1998 } 2013 }
1999 case SelectionNotify: { 2014 case SelectionNotify: {
2000 drag_drop_client_->OnSelectionNotify(xev->xselection); 2015 drag_drop_client_->OnSelectionNotify(xev->xselection);
2001 break; 2016 break;
2002 } 2017 }
2003 } 2018 }
2004 return ui::POST_DISPATCH_STOP_PROPAGATION; 2019 return ui::POST_DISPATCH_STOP_PROPAGATION;
2005 } 2020 }
2006 2021
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 if (linux_ui) { 2077 if (linux_ui) {
2063 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); 2078 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window);
2064 if (native_theme) 2079 if (native_theme)
2065 return native_theme; 2080 return native_theme;
2066 } 2081 }
2067 2082
2068 return ui::NativeThemeAura::instance(); 2083 return ui::NativeThemeAura::instance();
2069 } 2084 }
2070 2085
2071 } // namespace views 2086 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698