[X11] Set tiled state for MAXIMIZED_{VERT,HORZ} windows
Change-Id: Ifed16709bc0ddc4dc0fca1e80ee7594991cb3678
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5163726
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1243568}
diff --git a/ui/base/menu_source_utils.h b/ui/base/menu_source_utils.h
index f5965b5..b799d49c 100644
--- a/ui/base/menu_source_utils.h
+++ b/ui/base/menu_source_utils.h
@@ -7,6 +7,8 @@
#include "base/component_export.h"
#include "build/branding_buildflags.h"
+#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "ui/base/ui_base_types.h"
namespace ui {
diff --git a/ui/base/ui_base_types.h b/ui/base/ui_base_types.h
index 73d3213..8bfbd2d 100644
--- a/ui/base/ui_base_types.h
+++ b/ui/base/ui_base_types.h
@@ -7,9 +7,6 @@
#include <cstdint>
-#include "build/build_config.h"
-#include "build/chromeos_buildflags.h"
-
namespace ui {
// This enum must be version-skew tolerant. It is persisted to disk by ChromeOS
@@ -32,7 +29,6 @@
SHOW_STATE_END = 6 // The end of show state enum.
};
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
// Specifies which edges of the window are tiled.
//
// Wayland can notify the application if certain edge of the window is
@@ -54,7 +50,6 @@
bottom != other.bottom;
}
};
-#endif // IS_LINUX || IS_CHROMEOS_LACROS
// Dialog button identifiers used to specify which buttons to show the user.
enum DialogButton {
diff --git a/ui/ozone/platform/x11/x11_window.cc b/ui/ozone/platform/x11/x11_window.cc
index 6bb980b..f2221946 100644
--- a/ui/ozone/platform/x11/x11_window.cc
+++ b/ui/ozone/platform/x11/x11_window.cc
@@ -1506,6 +1506,14 @@
state_ = new_state;
platform_window_delegate_->OnWindowStateChanged(old_state, state_);
}
+
+ WindowTiledEdges tiled_state = GetTiledState();
+ if (tiled_state != tiled_state_) {
+ tiled_state_ = tiled_state;
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
+ platform_window_delegate_->OnWindowTiledStateChanged(tiled_state);
+#endif
+ }
}
void X11Window::OnXWindowDamageEvent(const gfx::Rect& damage_rect) {
@@ -2510,6 +2518,14 @@
}
}
+WindowTiledEdges X11Window::GetTiledState() const {
+ const bool vert = HasWMSpecProperty(
+ window_properties_, x11::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"));
+ const bool horz = HasWMSpecProperty(
+ window_properties_, x11::GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ"));
+ return WindowTiledEdges{vert, vert, horz, horz};
+}
+
void X11Window::UpdateWindowProperties(
const base::flat_set<x11::Atom>& new_window_properties) {
// If the window is hidden, ignore new properties.
diff --git a/ui/ozone/platform/x11/x11_window.h b/ui/ozone/platform/x11/x11_window.h
index bf84b60..1d9ba6e 100644
--- a/ui/ozone/platform/x11/x11_window.h
+++ b/ui/ozone/platform/x11/x11_window.h
@@ -276,6 +276,8 @@
// Called when |xwindow_|'s _NET_WM_STATE property is updated.
void OnWMStateUpdated();
+ WindowTiledEdges GetTiledState() const;
+
// Called when |xwindow_|'s _NET_FRAME_EXTENTS property is updated.
void OnFrameExtentsUpdated();
@@ -322,6 +324,8 @@
// Stores current state of this window.
PlatformWindowState state_ = PlatformWindowState::kUnknown;
+ WindowTiledEdges tiled_state_;
+
const raw_ptr<PlatformWindowDelegate> platform_window_delegate_;
raw_ptr<WorkspaceExtensionDelegate, DanglingUntriaged>