summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2022-02-07 13:06:28 -0500
committerAndreas Kling <kling@serenityos.org>2022-02-08 16:37:46 +0100
commit3d7e70145105660498a02f11bb3b3f49bad13736 (patch)
tree30f188eae1ee780c1169d455e069919a2dff2020
parentd3c25b8ea2c5bab449983ae61fbb1aa8c1832301 (diff)
downloadserenity-3d7e70145105660498a02f11bb3b3f49bad13736.zip
WindowServer: Rename Window::tiled() => tile_type() and add is_tiled()
This seems more consistent with naming conventions across the system and makes conditionals easier to read.
-rw-r--r--Userland/Services/WindowServer/Window.cpp46
-rw-r--r--Userland/Services/WindowServer/Window.h5
-rw-r--r--Userland/Services/WindowServer/WindowFrame.cpp2
-rw-r--r--Userland/Services/WindowServer/WindowManager.cpp12
4 files changed, 33 insertions, 32 deletions
diff --git a/Userland/Services/WindowServer/Window.cpp b/Userland/Services/WindowServer/Window.cpp
index b072da2ecf..dadb571e15 100644
--- a/Userland/Services/WindowServer/Window.cpp
+++ b/Userland/Services/WindowServer/Window.cpp
@@ -477,7 +477,7 @@ void Window::set_maximized(bool maximized, Optional<Gfx::IntPoint> fixed_point)
return;
if (maximized && (!is_resizable() || resize_aspect_ratio().has_value()))
return;
- m_tiled = WindowTileType::None;
+ m_tile_type = WindowTileType::None;
m_maximized = maximized;
update_window_menu_items();
if (maximized) {
@@ -931,7 +931,7 @@ void Window::set_fullscreen(bool fullscreen)
set_rect(new_window_rect);
}
-Gfx::IntRect Window::tiled_rect(Screen* target_screen, WindowTileType tiled) const
+Gfx::IntRect Window::tiled_rect(Screen* target_screen, WindowTileType tile_type) const
{
if (!target_screen) {
// If no explicit target screen was supplied,
@@ -939,7 +939,7 @@ Gfx::IntRect Window::tiled_rect(Screen* target_screen, WindowTileType tiled) con
target_screen = &Screen::closest_to_rect(frame().rect());
}
- VERIFY(tiled != WindowTileType::None);
+ VERIFY(tile_type != WindowTileType::None);
int frame_width = (m_frame.rect().width() - m_rect.width()) / 2;
int titlebar_height = m_frame.titlebar_rect().height();
@@ -949,7 +949,7 @@ Gfx::IntRect Window::tiled_rect(Screen* target_screen, WindowTileType tiled) con
auto& screen = *target_screen;
auto screen_location = screen.rect().location();
- switch (tiled) {
+ switch (tile_type) {
case WindowTileType::Left:
return Gfx::IntRect(0,
menu_height,
@@ -1028,13 +1028,13 @@ WindowTileType Window::tile_type_based_on_rect(Gfx::IntRect const& rect) const
auto& window_screen = Screen::closest_to_rect(this->rect()); // based on currently used rect
auto tile_type = WindowTileType::None;
if (window_screen.rect().contains(rect)) {
- auto current_tiled = tiled();
- bool tiling_to_top = current_tiled == WindowTileType::Top || current_tiled == WindowTileType::TopLeft || current_tiled == WindowTileType::TopRight;
- bool tiling_to_bottom = current_tiled == WindowTileType::Bottom || current_tiled == WindowTileType::BottomLeft || current_tiled == WindowTileType::BottomRight;
- bool tiling_to_left = current_tiled == WindowTileType::Left || current_tiled == WindowTileType::TopLeft || current_tiled == WindowTileType::BottomLeft;
- bool tiling_to_right = current_tiled == WindowTileType::Right || current_tiled == WindowTileType::TopRight || current_tiled == WindowTileType::BottomRight;
+ auto current_tile_type = this->tile_type();
+ bool tiling_to_top = current_tile_type == WindowTileType::Top || current_tile_type == WindowTileType::TopLeft || current_tile_type == WindowTileType::TopRight;
+ bool tiling_to_bottom = current_tile_type == WindowTileType::Bottom || current_tile_type == WindowTileType::BottomLeft || current_tile_type == WindowTileType::BottomRight;
+ bool tiling_to_left = current_tile_type == WindowTileType::Left || current_tile_type == WindowTileType::TopLeft || current_tile_type == WindowTileType::BottomLeft;
+ bool tiling_to_right = current_tile_type == WindowTileType::Right || current_tile_type == WindowTileType::TopRight || current_tile_type == WindowTileType::BottomRight;
- auto ideal_tiled_rect = tiled_rect(&window_screen, current_tiled);
+ auto ideal_tiled_rect = tiled_rect(&window_screen, current_tile_type);
bool same_top = ideal_tiled_rect.top() == rect.top();
bool same_left = ideal_tiled_rect.left() == rect.left();
bool same_right = ideal_tiled_rect.right() == rect.right();
@@ -1074,19 +1074,19 @@ void Window::check_untile_due_to_resize(Gfx::IntRect const& new_rect)
dbgln("Untiling because new rect {} does not fit into screen #{} rect {}", new_rect, window_screen.index(), window_screen.rect());
else
dbgln("Untiling because new rect {} does not touch screen #{} rect {}", new_rect, window_screen.index(), window_screen.rect());
- } else if (new_tile_type != m_tiled)
- dbgln("Changing tile type from {} to {}", (int)m_tiled, (int)new_tile_type);
+ } else if (new_tile_type != m_tile_type)
+ dbgln("Changing tile type from {} to {}", (int)m_tile_type, (int)new_tile_type);
}
- m_tiled = new_tile_type;
+ m_tile_type = new_tile_type;
}
bool Window::set_untiled(Optional<Gfx::IntPoint> fixed_point)
{
- if (m_tiled == WindowTileType::None)
+ if (m_tile_type == WindowTileType::None)
return false;
VERIFY(!resize_aspect_ratio().has_value());
- m_tiled = WindowTileType::None;
+ m_tile_type = WindowTileType::None;
if (fixed_point.has_value()) {
auto new_rect = Gfx::IntRect(m_rect);
@@ -1101,21 +1101,21 @@ bool Window::set_untiled(Optional<Gfx::IntPoint> fixed_point)
return true;
}
-void Window::set_tiled(Screen* screen, WindowTileType tiled)
+void Window::set_tiled(Screen* screen, WindowTileType tile_type)
{
- VERIFY(tiled != WindowTileType::None);
+ VERIFY(tile_type != WindowTileType::None);
- if (m_tiled == tiled)
+ if (m_tile_type == tile_type)
return;
if (resize_aspect_ratio().has_value())
return;
- if (m_tiled == WindowTileType::None)
+ if (m_tile_type == WindowTileType::None)
m_untiled_rect = m_rect;
- m_tiled = tiled;
+ m_tile_type = tile_type;
- set_rect(tiled_rect(screen, tiled));
+ set_rect(tiled_rect(screen, tile_type));
Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect));
}
@@ -1130,8 +1130,8 @@ void Window::recalculate_rect()
return;
bool send_event = true;
- if (m_tiled != WindowTileType::None) {
- set_rect(tiled_rect(nullptr, m_tiled));
+ if (is_tiled()) {
+ set_rect(tiled_rect(nullptr, m_tile_type));
} else if (is_maximized()) {
set_rect(WindowManager::the().maximized_window_rect(*this));
} else if (type() == WindowType::Desktop) {
diff --git a/Userland/Services/WindowServer/Window.h b/Userland/Services/WindowServer/Window.h
index 3dfbfaa1ef..261cbcf4f4 100644
--- a/Userland/Services/WindowServer/Window.h
+++ b/Userland/Services/WindowServer/Window.h
@@ -116,7 +116,8 @@ public:
bool is_fullscreen() const { return m_fullscreen; }
void set_fullscreen(bool);
- WindowTileType tiled() const { return m_tiled; }
+ WindowTileType tile_type() const { return m_tile_type; }
+ bool is_tiled() const { return m_tile_type != WindowTileType::None; }
void set_tiled(Screen*, WindowTileType);
WindowTileType tile_type_based_on_rect(Gfx::IntRect const&) const;
void check_untile_due_to_resize(Gfx::IntRect const&);
@@ -434,7 +435,7 @@ private:
bool m_moving_to_another_stack { false };
bool m_invalidate_last_render_rects { false };
Vector<i32> m_stealable_by_client_ids;
- WindowTileType m_tiled { WindowTileType::None };
+ WindowTileType m_tile_type { WindowTileType::None };
Gfx::IntRect m_untiled_rect;
bool m_occluded { false };
RefPtr<Gfx::Bitmap> m_backing_store;
diff --git a/Userland/Services/WindowServer/WindowFrame.cpp b/Userland/Services/WindowServer/WindowFrame.cpp
index 230e7948d1..b77bd51a2c 100644
--- a/Userland/Services/WindowServer/WindowFrame.cpp
+++ b/Userland/Services/WindowServer/WindowFrame.cpp
@@ -532,7 +532,7 @@ Gfx::IntRect WindowFrame::rect() const
Gfx::IntRect WindowFrame::constrained_render_rect_to_screen(const Gfx::IntRect& render_rect) const
{
- if (m_window.is_maximized() || m_window.tiled() != WindowTileType::None)
+ if (m_window.is_maximized() || m_window.is_tiled())
return render_rect.intersected(Screen::closest_to_rect(rect()).rect());
return render_rect;
}
diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp
index 084c6465f0..805be5be30 100644
--- a/Userland/Services/WindowServer/WindowManager.cpp
+++ b/Userland/Services/WindowServer/WindowManager.cpp
@@ -797,7 +797,7 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event)
m_move_window->set_tiled(&cursor_screen, WindowTileType::Top);
} else if (is_resizable && event_location_relative_to_screen.y() >= desktop_relative_to_screen.bottom() - secondary_deadzone) {
m_move_window->set_tiled(&cursor_screen, WindowTileType::Bottom);
- } else if (m_move_window->tiled() == WindowTileType::None) {
+ } else if (!m_move_window->is_tiled()) {
Gfx::IntPoint pos = m_move_window_origin.translated(event.position() - m_move_origin);
m_move_window->set_position_without_repaint(pos);
// "Bounce back" the window if it would end up too far outside the screen.
@@ -941,7 +941,7 @@ bool WindowManager::process_ongoing_window_resize(MouseEvent const& event)
if (m_resize_window->rect() == new_rect)
return true;
- if (m_resize_window->tiled() != WindowTileType::None) {
+ if (m_resize_window->is_tiled()) {
// Check if we should be un-tiling the window. This should happen when one side touching
// the screen border changes. We need to un-tile because while it is tiled, rendering is
// constrained to the screen where it's tiled on, and if one of these sides move we should
@@ -1639,9 +1639,9 @@ void WindowManager::process_key_event(KeyEvent& event)
return;
}
if (event.key() == Key_Left) {
- if (active_input_window->tiled() == WindowTileType::Left)
+ if (active_input_window->tile_type() == WindowTileType::Left)
return;
- if (active_input_window->tiled() != WindowTileType::None) {
+ if (active_input_window->is_tiled()) {
active_input_window->set_untiled();
return;
}
@@ -1651,9 +1651,9 @@ void WindowManager::process_key_event(KeyEvent& event)
return;
}
if (event.key() == Key_Right) {
- if (active_input_window->tiled() == WindowTileType::Right)
+ if (active_input_window->tile_type() == WindowTileType::Right)
return;
- if (active_input_window->tiled() != WindowTileType::None) {
+ if (active_input_window->is_tiled()) {
active_input_window->set_untiled();
return;
}