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_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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 // the 90% case down. When *chrome* is the process that requests maximizing | 561 // the 90% case down. When *chrome* is the process that requests maximizing |
562 // or restoring bounds, we can record the current bounds before we request | 562 // or restoring bounds, we can record the current bounds before we request |
563 // maximization, and clear it when we detect a state change. | 563 // maximization, and clear it when we detect a state change. |
564 if (!restored_bounds_in_pixels_.IsEmpty()) | 564 if (!restored_bounds_in_pixels_.IsEmpty()) |
565 return ToDIPRect(restored_bounds_in_pixels_); | 565 return ToDIPRect(restored_bounds_in_pixels_); |
566 | 566 |
567 return GetWindowBoundsInScreen(); | 567 return GetWindowBoundsInScreen(); |
568 } | 568 } |
569 | 569 |
570 std::string DesktopWindowTreeHostX11::GetWorkspace() const { | 570 std::string DesktopWindowTreeHostX11::GetWorkspace() const { |
571 int workspace_id; | 571 if (workspace_.empty()) |
572 if (ui::GetIntProperty(xwindow_, "_NET_WM_DESKTOP", &workspace_id)) | 572 const_cast<DesktopWindowTreeHostX11*>(this)->UpdateWorkspace(); |
573 return base::IntToString(workspace_id); | 573 return workspace_; |
574 return std::string(); | 574 } |
| 575 |
| 576 bool DesktopWindowTreeHostX11::UpdateWorkspace() { |
| 577 int workspace_int; |
| 578 if (!ui::GetWindowDesktop(xwindow_, &workspace_int)) |
| 579 return false; |
| 580 std::string workspace_str = base::IntToString(workspace_int); |
| 581 if (workspace_ == workspace_str) |
| 582 return false; |
| 583 workspace_ = workspace_str; |
| 584 return true; |
575 } | 585 } |
576 | 586 |
577 gfx::Rect DesktopWindowTreeHostX11::GetWorkAreaBoundsInScreen() const { | 587 gfx::Rect DesktopWindowTreeHostX11::GetWorkAreaBoundsInScreen() const { |
578 return ToDIPRect(GetWorkAreaBoundsInPixels()); | 588 return ToDIPRect(GetWorkAreaBoundsInPixels()); |
579 } | 589 } |
580 | 590 |
581 void DesktopWindowTreeHostX11::SetShape(SkRegion* native_region) { | 591 void DesktopWindowTreeHostX11::SetShape(SkRegion* native_region) { |
582 custom_window_shape_ = false; | 592 custom_window_shape_ = false; |
583 window_shape_.reset(); | 593 window_shape_.reset(); |
584 | 594 |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 state_atom_list.push_back( | 1233 state_atom_list.push_back( |
1224 atom_cache_.GetAtom("_NET_WM_STATE_SKIP_TASKBAR")); | 1234 atom_cache_.GetAtom("_NET_WM_STATE_SKIP_TASKBAR")); |
1225 } | 1235 } |
1226 | 1236 |
1227 // If the window should stay on top of other windows, add the | 1237 // If the window should stay on top of other windows, add the |
1228 // _NET_WM_STATE_ABOVE property. | 1238 // _NET_WM_STATE_ABOVE property. |
1229 is_always_on_top_ = params.keep_on_top; | 1239 is_always_on_top_ = params.keep_on_top; |
1230 if (is_always_on_top_) | 1240 if (is_always_on_top_) |
1231 state_atom_list.push_back(atom_cache_.GetAtom("_NET_WM_STATE_ABOVE")); | 1241 state_atom_list.push_back(atom_cache_.GetAtom("_NET_WM_STATE_ABOVE")); |
1232 | 1242 |
| 1243 workspace_.clear(); |
1233 if (params.visible_on_all_workspaces) { | 1244 if (params.visible_on_all_workspaces) { |
1234 state_atom_list.push_back(atom_cache_.GetAtom("_NET_WM_STATE_STICKY")); | 1245 state_atom_list.push_back(atom_cache_.GetAtom("_NET_WM_STATE_STICKY")); |
1235 ui::SetIntProperty(xwindow_, "_NET_WM_DESKTOP", "CARDINAL", kAllDesktops); | 1246 ui::SetIntProperty(xwindow_, "_NET_WM_DESKTOP", "CARDINAL", kAllDesktops); |
1236 } else if (!params.workspace.empty()) { | 1247 } else if (!params.workspace.empty()) { |
1237 int workspace; | 1248 int workspace; |
1238 if (base::StringToInt(params.workspace, &workspace)) | 1249 if (base::StringToInt(params.workspace, &workspace)) |
1239 ui::SetIntProperty(xwindow_, "_NET_WM_DESKTOP", "CARDINAL", workspace); | 1250 ui::SetIntProperty(xwindow_, "_NET_WM_DESKTOP", "CARDINAL", workspace); |
1240 } | 1251 } |
1241 | 1252 |
1242 // Setting _NET_WM_STATE by sending a message to the root_window (with | 1253 // Setting _NET_WM_STATE by sending a message to the root_window (with |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1989 break; | 2000 break; |
1990 } | 2001 } |
1991 } | 2002 } |
1992 | 2003 |
1993 ui::MouseEvent mouseev(xev); | 2004 ui::MouseEvent mouseev(xev); |
1994 DispatchMouseEvent(&mouseev); | 2005 DispatchMouseEvent(&mouseev); |
1995 break; | 2006 break; |
1996 } | 2007 } |
1997 case PropertyNotify: { | 2008 case PropertyNotify: { |
1998 ::Atom changed_atom = xev->xproperty.atom; | 2009 ::Atom changed_atom = xev->xproperty.atom; |
1999 if (changed_atom == atom_cache_.GetAtom("_NET_WM_STATE")) | 2010 if (changed_atom == atom_cache_.GetAtom("_NET_WM_STATE")) { |
2000 OnWMStateUpdated(); | 2011 OnWMStateUpdated(); |
2001 else if (changed_atom == atom_cache_.GetAtom("_NET_FRAME_EXTENTS")) | 2012 } else if (changed_atom == atom_cache_.GetAtom("_NET_FRAME_EXTENTS")) { |
2002 OnFrameExtentsUpdated(); | 2013 OnFrameExtentsUpdated(); |
2003 else if (changed_atom == atom_cache_.GetAtom("_NET_WM_DESKTOP")) | 2014 } else if (changed_atom == atom_cache_.GetAtom("_NET_WM_DESKTOP")) { |
2004 OnHostWorkspaceChanged(); | 2015 if (UpdateWorkspace()) |
| 2016 OnHostWorkspaceChanged(); |
| 2017 } |
2005 break; | 2018 break; |
2006 } | 2019 } |
2007 case SelectionNotify: { | 2020 case SelectionNotify: { |
2008 drag_drop_client_->OnSelectionNotify(xev->xselection); | 2021 drag_drop_client_->OnSelectionNotify(xev->xselection); |
2009 break; | 2022 break; |
2010 } | 2023 } |
2011 } | 2024 } |
2012 return ui::POST_DISPATCH_STOP_PROPAGATION; | 2025 return ui::POST_DISPATCH_STOP_PROPAGATION; |
2013 } | 2026 } |
2014 | 2027 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2070 if (linux_ui) { | 2083 if (linux_ui) { |
2071 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 2084 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
2072 if (native_theme) | 2085 if (native_theme) |
2073 return native_theme; | 2086 return native_theme; |
2074 } | 2087 } |
2075 | 2088 |
2076 return ui::NativeThemeAura::instance(); | 2089 return ui::NativeThemeAura::instance(); |
2077 } | 2090 } |
2078 | 2091 |
2079 } // namespace views | 2092 } // namespace views |
OLD | NEW |