mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:47:37 +00:00
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.
This commit is contained in:
parent
d3c25b8ea2
commit
3d7e701451
4 changed files with 33 additions and 32 deletions
|
@ -477,7 +477,7 @@ void Window::set_maximized(bool maximized, Optional<Gfx::IntPoint> fixed_point)
|
||||||
return;
|
return;
|
||||||
if (maximized && (!is_resizable() || resize_aspect_ratio().has_value()))
|
if (maximized && (!is_resizable() || resize_aspect_ratio().has_value()))
|
||||||
return;
|
return;
|
||||||
m_tiled = WindowTileType::None;
|
m_tile_type = WindowTileType::None;
|
||||||
m_maximized = maximized;
|
m_maximized = maximized;
|
||||||
update_window_menu_items();
|
update_window_menu_items();
|
||||||
if (maximized) {
|
if (maximized) {
|
||||||
|
@ -931,7 +931,7 @@ void Window::set_fullscreen(bool fullscreen)
|
||||||
set_rect(new_window_rect);
|
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 (!target_screen) {
|
||||||
// If no explicit target screen was supplied,
|
// 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());
|
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 frame_width = (m_frame.rect().width() - m_rect.width()) / 2;
|
||||||
int titlebar_height = m_frame.titlebar_rect().height();
|
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 = *target_screen;
|
||||||
auto screen_location = screen.rect().location();
|
auto screen_location = screen.rect().location();
|
||||||
switch (tiled) {
|
switch (tile_type) {
|
||||||
case WindowTileType::Left:
|
case WindowTileType::Left:
|
||||||
return Gfx::IntRect(0,
|
return Gfx::IntRect(0,
|
||||||
menu_height,
|
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& window_screen = Screen::closest_to_rect(this->rect()); // based on currently used rect
|
||||||
auto tile_type = WindowTileType::None;
|
auto tile_type = WindowTileType::None;
|
||||||
if (window_screen.rect().contains(rect)) {
|
if (window_screen.rect().contains(rect)) {
|
||||||
auto current_tiled = tiled();
|
auto current_tile_type = this->tile_type();
|
||||||
bool tiling_to_top = current_tiled == WindowTileType::Top || current_tiled == WindowTileType::TopLeft || current_tiled == WindowTileType::TopRight;
|
bool tiling_to_top = current_tile_type == WindowTileType::Top || current_tile_type == WindowTileType::TopLeft || current_tile_type == WindowTileType::TopRight;
|
||||||
bool tiling_to_bottom = current_tiled == WindowTileType::Bottom || current_tiled == WindowTileType::BottomLeft || current_tiled == WindowTileType::BottomRight;
|
bool tiling_to_bottom = current_tile_type == WindowTileType::Bottom || current_tile_type == WindowTileType::BottomLeft || current_tile_type == WindowTileType::BottomRight;
|
||||||
bool tiling_to_left = current_tiled == WindowTileType::Left || current_tiled == WindowTileType::TopLeft || current_tiled == WindowTileType::BottomLeft;
|
bool tiling_to_left = current_tile_type == WindowTileType::Left || current_tile_type == WindowTileType::TopLeft || current_tile_type == WindowTileType::BottomLeft;
|
||||||
bool tiling_to_right = current_tiled == WindowTileType::Right || current_tiled == WindowTileType::TopRight || current_tiled == WindowTileType::BottomRight;
|
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_top = ideal_tiled_rect.top() == rect.top();
|
||||||
bool same_left = ideal_tiled_rect.left() == rect.left();
|
bool same_left = ideal_tiled_rect.left() == rect.left();
|
||||||
bool same_right = ideal_tiled_rect.right() == rect.right();
|
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());
|
dbgln("Untiling because new rect {} does not fit into screen #{} rect {}", new_rect, window_screen.index(), window_screen.rect());
|
||||||
else
|
else
|
||||||
dbgln("Untiling because new rect {} does not touch screen #{} rect {}", new_rect, window_screen.index(), window_screen.rect());
|
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)
|
} else if (new_tile_type != m_tile_type)
|
||||||
dbgln("Changing tile type from {} to {}", (int)m_tiled, (int)new_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)
|
bool Window::set_untiled(Optional<Gfx::IntPoint> fixed_point)
|
||||||
{
|
{
|
||||||
if (m_tiled == WindowTileType::None)
|
if (m_tile_type == WindowTileType::None)
|
||||||
return false;
|
return false;
|
||||||
VERIFY(!resize_aspect_ratio().has_value());
|
VERIFY(!resize_aspect_ratio().has_value());
|
||||||
|
|
||||||
m_tiled = WindowTileType::None;
|
m_tile_type = WindowTileType::None;
|
||||||
|
|
||||||
if (fixed_point.has_value()) {
|
if (fixed_point.has_value()) {
|
||||||
auto new_rect = Gfx::IntRect(m_rect);
|
auto new_rect = Gfx::IntRect(m_rect);
|
||||||
|
@ -1101,21 +1101,21 @@ bool Window::set_untiled(Optional<Gfx::IntPoint> fixed_point)
|
||||||
return true;
|
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;
|
return;
|
||||||
|
|
||||||
if (resize_aspect_ratio().has_value())
|
if (resize_aspect_ratio().has_value())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_tiled == WindowTileType::None)
|
if (m_tile_type == WindowTileType::None)
|
||||||
m_untiled_rect = m_rect;
|
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));
|
Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1130,8 +1130,8 @@ void Window::recalculate_rect()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool send_event = true;
|
bool send_event = true;
|
||||||
if (m_tiled != WindowTileType::None) {
|
if (is_tiled()) {
|
||||||
set_rect(tiled_rect(nullptr, m_tiled));
|
set_rect(tiled_rect(nullptr, m_tile_type));
|
||||||
} else if (is_maximized()) {
|
} else if (is_maximized()) {
|
||||||
set_rect(WindowManager::the().maximized_window_rect(*this));
|
set_rect(WindowManager::the().maximized_window_rect(*this));
|
||||||
} else if (type() == WindowType::Desktop) {
|
} else if (type() == WindowType::Desktop) {
|
||||||
|
|
|
@ -116,7 +116,8 @@ public:
|
||||||
bool is_fullscreen() const { return m_fullscreen; }
|
bool is_fullscreen() const { return m_fullscreen; }
|
||||||
void set_fullscreen(bool);
|
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);
|
void set_tiled(Screen*, WindowTileType);
|
||||||
WindowTileType tile_type_based_on_rect(Gfx::IntRect const&) const;
|
WindowTileType tile_type_based_on_rect(Gfx::IntRect const&) const;
|
||||||
void check_untile_due_to_resize(Gfx::IntRect const&);
|
void check_untile_due_to_resize(Gfx::IntRect const&);
|
||||||
|
@ -434,7 +435,7 @@ private:
|
||||||
bool m_moving_to_another_stack { false };
|
bool m_moving_to_another_stack { false };
|
||||||
bool m_invalidate_last_render_rects { false };
|
bool m_invalidate_last_render_rects { false };
|
||||||
Vector<i32> m_stealable_by_client_ids;
|
Vector<i32> m_stealable_by_client_ids;
|
||||||
WindowTileType m_tiled { WindowTileType::None };
|
WindowTileType m_tile_type { WindowTileType::None };
|
||||||
Gfx::IntRect m_untiled_rect;
|
Gfx::IntRect m_untiled_rect;
|
||||||
bool m_occluded { false };
|
bool m_occluded { false };
|
||||||
RefPtr<Gfx::Bitmap> m_backing_store;
|
RefPtr<Gfx::Bitmap> m_backing_store;
|
||||||
|
|
|
@ -532,7 +532,7 @@ Gfx::IntRect WindowFrame::rect() const
|
||||||
|
|
||||||
Gfx::IntRect WindowFrame::constrained_render_rect_to_screen(const Gfx::IntRect& render_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.intersected(Screen::closest_to_rect(rect()).rect());
|
||||||
return render_rect;
|
return render_rect;
|
||||||
}
|
}
|
||||||
|
|
|
@ -797,7 +797,7 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event)
|
||||||
m_move_window->set_tiled(&cursor_screen, WindowTileType::Top);
|
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) {
|
} 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);
|
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);
|
Gfx::IntPoint pos = m_move_window_origin.translated(event.position() - m_move_origin);
|
||||||
m_move_window->set_position_without_repaint(pos);
|
m_move_window->set_position_without_repaint(pos);
|
||||||
// "Bounce back" the window if it would end up too far outside the screen.
|
// "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)
|
if (m_resize_window->rect() == new_rect)
|
||||||
return true;
|
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
|
// 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
|
// 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
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
if (event.key() == Key_Left) {
|
if (event.key() == Key_Left) {
|
||||||
if (active_input_window->tiled() == WindowTileType::Left)
|
if (active_input_window->tile_type() == WindowTileType::Left)
|
||||||
return;
|
return;
|
||||||
if (active_input_window->tiled() != WindowTileType::None) {
|
if (active_input_window->is_tiled()) {
|
||||||
active_input_window->set_untiled();
|
active_input_window->set_untiled();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1651,9 +1651,9 @@ void WindowManager::process_key_event(KeyEvent& event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.key() == Key_Right) {
|
if (event.key() == Key_Right) {
|
||||||
if (active_input_window->tiled() == WindowTileType::Right)
|
if (active_input_window->tile_type() == WindowTileType::Right)
|
||||||
return;
|
return;
|
||||||
if (active_input_window->tiled() != WindowTileType::None) {
|
if (active_input_window->is_tiled()) {
|
||||||
active_input_window->set_untiled();
|
active_input_window->set_untiled();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue