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

Unified Diff: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc

Issue 407893002: Prevent a window from being put into fullscreen upon startup on desktop Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
index ebbd90410c82818939a494bc89e5a802eaab9d76..fe3610d1c9efab9244adbfa1355f90053c075831 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
@@ -30,6 +30,7 @@
#include "ui/events/x/device_data_manager_x11.h"
#include "ui/events/x/device_list_cache_x.h"
#include "ui/events/x/touch_factory_x11.h"
+#include "ui/gfx/display.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/insets.h"
@@ -385,7 +386,8 @@ bool DesktopWindowTreeHostX11::IsVisible() const {
return window_mapped_;
}
-void DesktopWindowTreeHostX11::SetSize(const gfx::Size& size) {
+void DesktopWindowTreeHostX11::SetSize(const gfx::Size& requested_size) {
+ gfx::Size size = AdjustSize(requested_size);
bool size_changed = bounds_.size() != size;
XResizeWindow(xdisplay_, xwindow_, size.width(), size.height());
bounds_.set_size(size);
@@ -520,6 +522,20 @@ bool DesktopWindowTreeHostX11::IsActive() const {
}
void DesktopWindowTreeHostX11::Maximize() {
+ if (HasWMSpecProperty("_NET_WM_STATE_FULLSCREEN")) {
pkotwicz 2014/07/25 19:31:51 It is possible for a user to still inadvertently p
+ // Unfullscreen the window if it is fullscreen.
+ SetWMSpecState(false,
+ atom_cache_.GetAtom("_NET_WM_STATE_FULLSCREEN"),
+ None);
+
+ // Resize the window so that it does not have the same size as a monitor.
+ // (Otherwise, some window managers immediately put the window back in
+ // fullscreen mode).
+ gfx::Rect adjusted_bounds(bounds_.origin(), AdjustSize(bounds_.size()));
+ if (adjusted_bounds != bounds_)
+ SetBounds(adjusted_bounds);
+ }
+
// When we are in the process of requesting to maximize a window, we can
// accurately keep track of our restored bounds instead of relying on the
// heuristics that are in the PropertyNotify and ConfigureNotify handlers.
@@ -850,7 +866,9 @@ gfx::Rect DesktopWindowTreeHostX11::GetBounds() const {
return bounds_;
}
-void DesktopWindowTreeHostX11::SetBounds(const gfx::Rect& bounds) {
+void DesktopWindowTreeHostX11::SetBounds(const gfx::Rect& requested_bounds) {
+ gfx::Rect bounds(requested_bounds.origin(),
+ AdjustSize(requested_bounds.size()));
bool origin_changed = bounds_.origin() != bounds.origin();
bool size_changed = bounds_.size() != bounds.size();
XWindowChanges changes = {0};
@@ -1038,7 +1056,8 @@ void DesktopWindowTreeHostX11::InitX11Window(
}
}
- bounds_ = params.bounds;
+ bounds_ = gfx::Rect(params.bounds.origin(),
+ AdjustSize(params.bounds.size()));
xwindow_ = XCreateWindow(
xdisplay_, x_root_window_,
bounds_.x(), bounds_.y(),
@@ -1171,6 +1190,21 @@ void DesktopWindowTreeHostX11::InitX11Window(
CreateCompositor(GetAcceleratedWidget());
}
+gfx::Size DesktopWindowTreeHostX11::AdjustSize(
+ const gfx::Size& requested_size) {
+ std::vector<gfx::Display> displays =
+ gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)->GetAllDisplays();
+ // Compare against all monitor sizes. The window manager can move the window
+ // to whichever monitor it wants.
+ for (size_t i = 0; i < displays.size(); ++i) {
+ if (requested_size == displays[i].size()) {
+ return gfx::Size(requested_size.width() - 1,
+ requested_size.height() - 1);
pkotwicz 2014/07/25 19:31:51 Ensuring that the window's non-maximized size does
+ }
+ }
+ return requested_size;
+}
+
void DesktopWindowTreeHostX11::OnWMStateUpdated() {
std::vector< ::Atom> atom_list;
if (!ui::GetAtomArrayProperty(xwindow_, "_NET_WM_STATE", &atom_list))
« 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