diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-06-07 11:47:19 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-06-07 11:47:19 +0200 |
commit | 8358833bc8eb15d36086d41707ca107eb89a36ab (patch) | |
tree | ba5130de8f752fba1043a6e2423a7709b14e6aaf /Servers/WindowServer | |
parent | 76b333749899c666dee522fd064234d8b94d9cfd (diff) | |
download | serenity-8358833bc8eb15d36086d41707ca107eb89a36ab.zip |
WindowServer: Run clang-format on everything.
Diffstat (limited to 'Servers/WindowServer')
-rw-r--r-- | Servers/WindowServer/WSButton.cpp | 6 | ||||
-rw-r--r-- | Servers/WindowServer/WSCPUMonitor.cpp | 10 | ||||
-rw-r--r-- | Servers/WindowServer/WSClientConnection.cpp | 4 | ||||
-rw-r--r-- | Servers/WindowServer/WSEventLoop.cpp | 56 | ||||
-rw-r--r-- | Servers/WindowServer/WSMenu.cpp | 14 | ||||
-rw-r--r-- | Servers/WindowServer/WSMenuBar.cpp | 1 | ||||
-rw-r--r-- | Servers/WindowServer/WSScreen.cpp | 6 | ||||
-rw-r--r-- | Servers/WindowServer/WSWindow.cpp | 41 | ||||
-rw-r--r-- | Servers/WindowServer/WSWindowFrame.cpp | 19 | ||||
-rw-r--r-- | Servers/WindowServer/WSWindowManager.cpp | 64 | ||||
-rw-r--r-- | Servers/WindowServer/WSWindowSwitcher.cpp | 17 | ||||
-rw-r--r-- | Servers/WindowServer/main.cpp | 8 |
12 files changed, 133 insertions, 113 deletions
diff --git a/Servers/WindowServer/WSButton.cpp b/Servers/WindowServer/WSButton.cpp index bf26ffb552..f4dfb9f5da 100644 --- a/Servers/WindowServer/WSButton.cpp +++ b/Servers/WindowServer/WSButton.cpp @@ -1,9 +1,9 @@ +#include <SharedGraphics/CharacterBitmap.h> +#include <SharedGraphics/Painter.h> +#include <SharedGraphics/StylePainter.h> #include <WindowServer/WSButton.h> #include <WindowServer/WSEvent.h> #include <WindowServer/WSWindowManager.h> -#include <SharedGraphics/Painter.h> -#include <SharedGraphics/StylePainter.h> -#include <SharedGraphics/CharacterBitmap.h> WSButton::WSButton(WSWindowFrame& frame, Retained<CharacterBitmap>&& bitmap, Function<void(WSButton&)>&& on_click_handler) : on_click(move(on_click_handler)) diff --git a/Servers/WindowServer/WSCPUMonitor.cpp b/Servers/WindowServer/WSCPUMonitor.cpp index 1ba726c72d..71a3e6a234 100644 --- a/Servers/WindowServer/WSCPUMonitor.cpp +++ b/Servers/WindowServer/WSCPUMonitor.cpp @@ -1,8 +1,8 @@ #include <WindowServer/WSCPUMonitor.h> #include <WindowServer/WSEventLoop.h> #include <WindowServer/WSWindowManager.h> -#include <unistd.h> #include <stdio.h> +#include <unistd.h> WSCPUMonitor::WSCPUMonitor() : m_proc_all("/proc/all") @@ -10,7 +10,7 @@ WSCPUMonitor::WSCPUMonitor() if (!m_proc_all.open(CIODevice::OpenMode::ReadOnly)) ASSERT_NOT_REACHED(); - create_thread([] (void* context) -> int { + create_thread([](void* context) -> int { auto& monitor = *(WSCPUMonitor*)context; for (;;) { static unsigned last_busy; @@ -27,7 +27,8 @@ WSCPUMonitor::WSCPUMonitor() monitor.m_dirty = true; sleep(1); } - }, this); + }, + this); } void WSCPUMonitor::get_cpu_usage(unsigned& busy, unsigned& idle) @@ -65,8 +66,7 @@ void WSCPUMonitor::paint(Painter& painter, const Rect& rect) painter.draw_line( { rect.x() + i, rect.bottom() }, { rect.x() + i, (int)(rect.y() + (rect.height() - (cpu_usage * (float)rect.height()))) }, - Color::from_rgb(0xaa6d4b) - ); + Color::from_rgb(0xaa6d4b)); ++i; } } diff --git a/Servers/WindowServer/WSClientConnection.cpp b/Servers/WindowServer/WSClientConnection.cpp index 8a5c3346cc..830514e142 100644 --- a/Servers/WindowServer/WSClientConnection.cpp +++ b/Servers/WindowServer/WSClientConnection.cpp @@ -355,7 +355,7 @@ void WSClientConnection::handle_request(const WSAPISetWindowOpacityRequest& requ void WSClientConnection::handle_request(const WSAPISetWallpaperRequest& request) { - WSCompositor::the().set_wallpaper(request.wallpaper(), [&] (bool success) { + WSCompositor::the().set_wallpaper(request.wallpaper(), [&](bool success) { WSAPI_ServerMessage response; response.type = WSAPI_ServerMessage::Type::DidSetWallpaper; response.value = success; @@ -564,7 +564,7 @@ void WSClientConnection::handle_request(const WSAPIInvalidateRectRequest& reques } auto& window = *(*it).value; for (int i = 0; i < request.rects().size(); ++i) - window.request_update(request.rects()[i].intersected({ { }, window.size() })); + window.request_update(request.rects()[i].intersected({ {}, window.size() })); } void WSClientConnection::handle_request(const WSAPIDidFinishPaintingNotification& request) diff --git a/Servers/WindowServer/WSEventLoop.cpp b/Servers/WindowServer/WSEventLoop.cpp index ab59c03afd..479b7defac 100644 --- a/Servers/WindowServer/WSEventLoop.cpp +++ b/Servers/WindowServer/WSEventLoop.cpp @@ -1,21 +1,21 @@ -#include <WindowServer/WSEventLoop.h> -#include <WindowServer/WSEvent.h> +#include <Kernel/KeyCode.h> +#include <Kernel/MousePacket.h> #include <LibCore/CObject.h> -#include <WindowServer/WSWindowManager.h> -#include <WindowServer/WSScreen.h> -#include <WindowServer/WSClientConnection.h> #include <WindowServer/WSAPITypes.h> +#include <WindowServer/WSClientConnection.h> #include <WindowServer/WSCursor.h> -#include <Kernel/KeyCode.h> -#include <Kernel/MousePacket.h> -#include <sys/socket.h> +#include <WindowServer/WSEvent.h> +#include <WindowServer/WSEventLoop.h> +#include <WindowServer/WSScreen.h> +#include <WindowServer/WSWindowManager.h> +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> #include <sys/select.h> +#include <sys/socket.h> #include <sys/time.h> #include <time.h> #include <unistd.h> -#include <fcntl.h> -#include <stdio.h> -#include <errno.h> //#define WSMESSAGELOOP_DEBUG @@ -104,7 +104,7 @@ static Vector<Rect, 32> get_rects(const WSAPI_ClientMessage& message, const Byte { Vector<Rect, 32> rects; if (message.rect_count > (WSAPI_ClientMessage::max_inline_rect_count + extra_data.size() / sizeof(WSAPI_Rect))) { - return { }; + return {}; } for (int i = 0; i < min(WSAPI_ClientMessage::max_inline_rect_count, message.rect_count); ++i) rects.append(message.rects[i]); @@ -217,19 +217,19 @@ bool WSEventLoop::on_receive_from_client(int client_id, const WSAPI_ClientMessag } post_event(client, - make<WSAPICreateWindowRequest>(client_id, - message.window.rect, - String(message.text, message.text_length), - message.window.has_alpha_channel, - message.window.modal, - message.window.resizable, - message.window.fullscreen, - message.window.show_titlebar, - message.window.opacity, - message.window.base_size, - message.window.size_increment, - ws_window_type, - Color::from_rgba(message.window.background_color))); + make<WSAPICreateWindowRequest>(client_id, + message.window.rect, + String(message.text, message.text_length), + message.window.has_alpha_channel, + message.window.modal, + message.window.resizable, + message.window.fullscreen, + message.window.show_titlebar, + message.window.opacity, + message.window.base_size, + message.window.size_increment, + ws_window_type, + Color::from_rgba(message.window.background_color))); break; } case WSAPI_ClientMessage::Type::DestroyWindow: @@ -320,7 +320,7 @@ bool WSEventLoop::on_receive_from_client(int client_id, const WSAPI_ClientMessag void WSEventLoop::add_file_descriptors_for_select(fd_set& fds, int& max_fd_added) { - auto add_fd_to_set = [&max_fd_added] (int fd, auto& set) { + auto add_fd_to_set = [&max_fd_added](int fd, auto& set) { FD_SET(fd, &set); if (fd > max_fd_added) max_fd_added = fd; @@ -328,7 +328,7 @@ void WSEventLoop::add_file_descriptors_for_select(fd_set& fds, int& max_fd_added add_fd_to_set(m_keyboard_fd, fds); add_fd_to_set(m_mouse_fd, fds); add_fd_to_set(m_server_fd, fds); - WSClientConnection::for_each_client([&] (WSClientConnection& client) { + WSClientConnection::for_each_client([&](WSClientConnection& client) { add_fd_to_set(client.fd(), fds); }); } @@ -341,7 +341,7 @@ void WSEventLoop::process_file_descriptors_after_select(const fd_set& fds) drain_keyboard(); if (FD_ISSET(m_mouse_fd, &fds)) drain_mouse(); - WSClientConnection::for_each_client([&] (WSClientConnection& client) { + WSClientConnection::for_each_client([&](WSClientConnection& client) { if (FD_ISSET(client.fd(), &fds)) drain_client(client); }); diff --git a/Servers/WindowServer/WSMenu.cpp b/Servers/WindowServer/WSMenu.cpp index 3d36316f30..92a246418a 100644 --- a/Servers/WindowServer/WSMenu.cpp +++ b/Servers/WindowServer/WSMenu.cpp @@ -1,16 +1,16 @@ #include "WSMenu.h" -#include "WSMenuItem.h" -#include "WSWindow.h" #include "WSEvent.h" #include "WSEventLoop.h" -#include "WSWindowManager.h" +#include "WSMenuItem.h" #include "WSScreen.h" -#include <WindowServer/WSAPITypes.h> -#include <WindowServer/WSClientConnection.h> +#include "WSWindow.h" +#include "WSWindowManager.h" #include <SharedGraphics/CharacterBitmap.h> +#include <SharedGraphics/Font.h> #include <SharedGraphics/Painter.h> #include <SharedGraphics/StylePainter.h> -#include <SharedGraphics/Font.h> +#include <WindowServer/WSAPITypes.h> +#include <WindowServer/WSClientConnection.h> WSMenu::WSMenu(WSClientConnection* client, int menu_id, const String& name) : m_client(client) @@ -115,7 +115,7 @@ void WSMenu::draw() ASSERT(menu_window()->backing_store()); Painter painter(*menu_window()->backing_store()); - Rect rect { { }, menu_window()->size() }; + Rect rect { {}, menu_window()->size() }; painter.fill_rect(rect.shrunken(6, 6), Color::LightGray); StylePainter::paint_window_frame(painter, rect); int width = this->width(); diff --git a/Servers/WindowServer/WSMenuBar.cpp b/Servers/WindowServer/WSMenuBar.cpp index 6d642d160d..5893a6b83d 100644 --- a/Servers/WindowServer/WSMenuBar.cpp +++ b/Servers/WindowServer/WSMenuBar.cpp @@ -11,4 +11,3 @@ WSMenuBar::WSMenuBar(WSClientConnection& client, int menubar_id) WSMenuBar::~WSMenuBar() { } - diff --git a/Servers/WindowServer/WSScreen.cpp b/Servers/WindowServer/WSScreen.cpp index bfb23e46fd..3582687881 100644 --- a/Servers/WindowServer/WSScreen.cpp +++ b/Servers/WindowServer/WSScreen.cpp @@ -1,7 +1,7 @@ +#include "WSScreen.h" #include "WSCompositor.h" #include "WSEvent.h" #include "WSEventLoop.h" -#include "WSScreen.h" #include "WSWindowManager.h" #include <fcntl.h> #include <sys/ioctl.h> @@ -39,7 +39,7 @@ void WSScreen::set_resolution(int width, int height) int width; int height; }; - BXVGAResolution resolution { (int)width, (int)height}; + BXVGAResolution resolution { (int)width, (int)height }; int rc = ioctl(m_framebuffer_fd, 1985, (int)&resolution); ASSERT(rc == 0); @@ -67,7 +67,7 @@ void WSScreen::on_receive_mouse_data(int dx, int dy, int dz, unsigned buttons) unsigned prev_buttons = m_mouse_button_state; m_mouse_button_state = buttons; unsigned changed_buttons = prev_buttons ^ buttons; - auto post_mousedown_or_mouseup_if_needed = [&] (MouseButton button) { + auto post_mousedown_or_mouseup_if_needed = [&](MouseButton button) { if (!(changed_buttons & (unsigned)button)) return; auto message = make<WSMouseEvent>(buttons & (unsigned)button ? WSEvent::MouseDown : WSEvent::MouseUp, m_cursor_location, buttons, button, m_modifiers); diff --git a/Servers/WindowServer/WSWindow.cpp b/Servers/WindowServer/WSWindow.cpp index 927929bc45..d478331649 100644 --- a/Servers/WindowServer/WSWindow.cpp +++ b/Servers/WindowServer/WSWindow.cpp @@ -1,7 +1,7 @@ #include "WSWindow.h" -#include "WSWindowManager.h" #include "WSEvent.h" #include "WSEventLoop.h" +#include "WSWindowManager.h" #include <WindowServer/WSAPITypes.h> #include <WindowServer/WSClientConnection.h> @@ -77,10 +77,14 @@ void WSWindow::set_rect(const Rect& rect) static WSAPI_MouseButton to_api(MouseButton button) { switch (button) { - case MouseButton::None: return WSAPI_MouseButton::NoButton; - case MouseButton::Left: return WSAPI_MouseButton::Left; - case MouseButton::Right: return WSAPI_MouseButton::Right; - case MouseButton::Middle: return WSAPI_MouseButton::Middle; + case MouseButton::None: + return WSAPI_MouseButton::NoButton; + case MouseButton::Left: + return WSAPI_MouseButton::Left; + case MouseButton::Right: + return WSAPI_MouseButton::Right; + case MouseButton::Middle: + return WSAPI_MouseButton::Middle; } ASSERT_NOT_REACHED(); } @@ -93,12 +97,23 @@ void WSWindow::handle_mouse_event(const WSMouseEvent& event) server_message.window_id = window_id(); switch (event.type()) { - case WSEvent::MouseMove: server_message.type = WSAPI_ServerMessage::Type::MouseMove; break; - case WSEvent::MouseDown: server_message.type = WSAPI_ServerMessage::Type::MouseDown; break; - case WSEvent::MouseDoubleClick: server_message.type = WSAPI_ServerMessage::Type::MouseDoubleClick; break; - case WSEvent::MouseUp: server_message.type = WSAPI_ServerMessage::Type::MouseUp; break; - case WSEvent::MouseWheel: server_message.type = WSAPI_ServerMessage::Type::MouseWheel; break; - default: ASSERT_NOT_REACHED(); + case WSEvent::MouseMove: + server_message.type = WSAPI_ServerMessage::Type::MouseMove; + break; + case WSEvent::MouseDown: + server_message.type = WSAPI_ServerMessage::Type::MouseDown; + break; + case WSEvent::MouseDoubleClick: + server_message.type = WSAPI_ServerMessage::Type::MouseDoubleClick; + break; + case WSEvent::MouseUp: + server_message.type = WSAPI_ServerMessage::Type::MouseUp; + break; + case WSEvent::MouseWheel: + server_message.type = WSAPI_ServerMessage::Type::MouseWheel; + break; + default: + ASSERT_NOT_REACHED(); } server_message.mouse.position = event.position(); @@ -134,7 +149,7 @@ void WSWindow::set_minimized(bool minimized) return; m_minimized = minimized; if (!minimized) - request_update({ { }, size() }); + request_update({ {}, size() }); invalidate(); WSWindowManager::the().notify_minimization_state_changed(*this); } @@ -291,7 +306,7 @@ void WSWindow::set_default_icon() void WSWindow::request_update(const Rect& rect) { if (m_pending_paint_rects.is_empty()) { - deferred_invoke([this] (auto&) { + deferred_invoke([this](auto&) { client()->post_paint_message(*this); }); } diff --git a/Servers/WindowServer/WSWindowFrame.cpp b/Servers/WindowServer/WSWindowFrame.cpp index bc44c9b448..da3ea26715 100644 --- a/Servers/WindowServer/WSWindowFrame.cpp +++ b/Servers/WindowServer/WSWindowFrame.cpp @@ -90,20 +90,20 @@ WSWindowFrame::WSWindowFrame(WSWindow& window) if (!s_unmaximize_button_bitmap) s_unmaximize_button_bitmap = &CharacterBitmap::create_from_ascii(s_unmaximize_button_bitmap_data, s_unmaximize_button_bitmap_width, s_unmaximize_button_bitmap_height).leak_ref(); - m_buttons.append(make<WSButton>(*this, *s_close_button_bitmap, [this] (auto&) { + m_buttons.append(make<WSButton>(*this, *s_close_button_bitmap, [this](auto&) { WSEvent close_request(WSEvent::WindowCloseRequest); m_window.event(close_request); })); if (window.is_resizable()) { - auto button = make<WSButton>(*this, *s_maximize_button_bitmap, [this] (auto&) { + auto button = make<WSButton>(*this, *s_maximize_button_bitmap, [this](auto&) { m_window.set_maximized(!m_window.is_maximized()); }); m_maximize_button = button.ptr(); m_buttons.append(move(button)); } - m_buttons.append(make<WSButton>(*this, *s_minimize_button_bitmap, [this] (auto&) { + m_buttons.append(make<WSButton>(*this, *s_minimize_button_bitmap, [this](auto&) { m_window.set_minimized(true); })); } @@ -159,7 +159,7 @@ void WSWindowFrame::paint(Painter& painter) auto titlebar_rect = title_bar_rect(); auto titlebar_icon_rect = title_bar_icon_rect(); auto titlebar_inner_rect = title_bar_text_rect(); - Rect outer_rect = { { }, rect().size() }; + Rect outer_rect = { {}, rect().size() }; auto titlebar_title_rect = titlebar_inner_rect; titlebar_title_rect.set_width(Font::default_bold_font().width(window.title())); @@ -221,9 +221,9 @@ static Rect frame_rect_for_window(WSWindow& window, const Rect& rect) switch (type) { case WSWindowType::Normal: return { rect.x() - 3, - rect.y() - window_titlebar_height - 4 + offset, - rect.width() + 6, - rect.height() + 7 + window_titlebar_height - offset }; + rect.y() - window_titlebar_height - 4 + offset, + rect.width() + 6, + rect.height() + 7 + window_titlebar_height - offset }; default: return rect; } @@ -248,7 +248,8 @@ void WSWindowFrame::notify_window_rect_changed(const Rect& old_rect, const Rect& { int window_button_width = 15; int window_button_height = 15; - int x = title_bar_text_rect().right() + 1;; + int x = title_bar_text_rect().right() + 1; + ; for (auto& button : m_buttons) { x -= window_button_width; Rect rect { x, 0, window_button_width, window_button_height }; @@ -297,7 +298,7 @@ void WSWindowFrame::on_mouse_event(const WSMouseEvent& event) { ResizeDirection::Left, ResizeDirection::None, ResizeDirection::Right }, { ResizeDirection::DownLeft, ResizeDirection::Down, ResizeDirection::DownRight }, }; - Rect outer_rect = { { }, rect().size() }; + Rect outer_rect = { {}, rect().size() }; ASSERT(outer_rect.contains(event.position())); int window_relative_x = event.x() - outer_rect.x(); int window_relative_y = event.y() - outer_rect.y(); diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp index fd30376df0..2aaa9f5e02 100644 --- a/Servers/WindowServer/WSWindowManager.cpp +++ b/Servers/WindowServer/WSWindowManager.cpp @@ -1,3 +1,4 @@ +#include "WSWindowManager.h" #include "WSCompositor.h" #include "WSEventLoop.h" #include "WSMenu.h" @@ -5,7 +6,6 @@ #include "WSMenuItem.h" #include "WSScreen.h" #include "WSWindow.h" -#include "WSWindowManager.h" #include <AK/StdLibExtras.h> #include <AK/Vector.h> #include <LibCore/CTimer.h> @@ -43,8 +43,8 @@ WSWindowManager::WSWindowManager() reload_config(false); struct AppMenuItem { - const char *binary_name; - const char *description; + const char* binary_name; + const char* description; }; Vector<AppMenuItem> apps; @@ -65,10 +65,10 @@ WSWindowManager::WSWindowManager() m_system_menu->add_item(make<WSMenuItem>(*m_system_menu, 100, "Reload WM Config File")); m_system_menu->add_item(make<WSMenuItem>(*m_system_menu, WSMenuItem::Separator)); m_system_menu->add_item(make<WSMenuItem>(*m_system_menu, 200, "About...")); - m_system_menu->on_item_activation = [this, apps] (WSMenuItem& item) { + m_system_menu->on_item_activation = [this, apps](WSMenuItem& item) { if (item.identifier() >= 1 && item.identifier() <= 1 + apps.size() - 1) { if (fork() == 0) { - const auto& bin = apps[item.identifier() -1].binary_name; + const auto& bin = apps[item.identifier() - 1].binary_name; execl(bin, bin, nullptr); ASSERT_NOT_REACHED(); } @@ -139,7 +139,7 @@ void WSWindowManager::reload_config(bool set_screen) if (set_screen) set_resolution(m_wm_config->read_num_entry("Screen", "Width", 1920), - m_wm_config->read_num_entry("Screen", "Height", 1080)); + m_wm_config->read_num_entry("Screen", "Height", 1080)); m_arrow_cursor = get_cursor("Arrow", { 2, 2 }); m_resize_horizontally_cursor = get_cursor("ResizeH"); @@ -199,19 +199,18 @@ void WSWindowManager::tick_clock() void WSWindowManager::set_resolution(int width, int height) { WSCompositor::the().set_resolution(width, height); - WSClientConnection::for_each_client([&] (WSClientConnection& client) { + WSClientConnection::for_each_client([&](WSClientConnection& client) { client.notify_about_new_screen_rect(WSScreen::the().rect()); }); if (m_wm_config) { dbgprintf("Saving resolution: %dx%d to config file at %s.\n", width, height, - m_wm_config->file_name().characters()); + m_wm_config->file_name().characters()); m_wm_config->write_num_entry("Screen", "Width", width); m_wm_config->write_num_entry("Screen", "Height", height); m_wm_config->sync(); } } - int WSWindowManager::menubar_menu_margin() const { return 16; @@ -238,7 +237,7 @@ void WSWindowManager::set_current_menubar(WSMenuBar* menubar) #endif Point next_menu_location { menubar_menu_margin() / 2, 0 }; int index = 0; - for_each_active_menubar_menu([&] (WSMenu& menu) { + for_each_active_menubar_menu([&](WSMenu& menu) { int text_width = index == 1 ? Font::default_bold_font().width(menu.name()) : font().width(menu.name()); menu.set_rect_in_menubar({ next_menu_location.x() - menubar_menu_margin() / 2, 0, text_width + menubar_menu_margin(), menubar_rect().height() - 1 }); menu.set_text_rect_in_menubar({ next_menu_location, { text_width, menubar_rect().height() } }); @@ -263,7 +262,7 @@ void WSWindowManager::add_window(WSWindow& window) m_switcher.refresh(); if (window.listens_to_wm_events()) { - for_each_window([&] (WSWindow& other_window) { + for_each_window([&](WSWindow& other_window) { if (&window != &other_window) { tell_wm_listener_about_window(window, other_window); tell_wm_listener_about_window_icon(window, other_window); @@ -297,7 +296,7 @@ void WSWindowManager::remove_window(WSWindow& window) if (m_switcher.is_visible() && window.type() != WSWindowType::WindowSwitcher) m_switcher.refresh(); - for_each_window_listening_to_wm_events([&window] (WSWindow& listener) { + for_each_window_listening_to_wm_events([&window](WSWindow& listener) { if (!(listener.wm_event_mask() & WSAPI_WMEventMask::WindowRemovals)) return IterationDecision::Continue; if (window.client()) @@ -332,7 +331,7 @@ void WSWindowManager::tell_wm_listener_about_window_icon(WSWindow& listener, WSW void WSWindowManager::tell_wm_listeners_window_state_changed(WSWindow& window) { - for_each_window_listening_to_wm_events([&] (WSWindow& listener) { + for_each_window_listening_to_wm_events([&](WSWindow& listener) { tell_wm_listener_about_window(listener, window); return IterationDecision::Continue; }); @@ -340,7 +339,7 @@ void WSWindowManager::tell_wm_listeners_window_state_changed(WSWindow& window) void WSWindowManager::tell_wm_listeners_window_icon_changed(WSWindow& window) { - for_each_window_listening_to_wm_events([&] (WSWindow& listener) { + for_each_window_listening_to_wm_events([&](WSWindow& listener) { tell_wm_listener_about_window_icon(listener, window); return IterationDecision::Continue; }); @@ -348,7 +347,7 @@ void WSWindowManager::tell_wm_listeners_window_icon_changed(WSWindow& window) void WSWindowManager::tell_wm_listeners_window_rect_changed(WSWindow& window) { - for_each_window_listening_to_wm_events([&] (WSWindow& listener) { + for_each_window_listening_to_wm_events([&](WSWindow& listener) { tell_wm_listener_about_window_rect(listener, window); return IterationDecision::Continue; }); @@ -388,7 +387,7 @@ void WSWindowManager::notify_minimization_state_changed(WSWindow& window) void WSWindowManager::pick_new_active_window() { - for_each_visible_window_of_type_from_front_to_back(WSWindowType::Normal, [&] (WSWindow& candidate) { + for_each_visible_window_of_type_from_front_to_back(WSWindowType::Normal, [&](WSWindow& candidate) { set_active_window(&candidate); return IterationDecision::Abort; }); @@ -427,7 +426,7 @@ void WSWindowManager::close_current_menu() void WSWindowManager::handle_menubar_mouse_event(const WSMouseEvent& event) { - for_each_active_menubar_menu([&] (WSMenu& menu) { + for_each_active_menubar_menu([&](WSMenu& menu) { if (menu.rect_in_menubar().contains(event.position())) { handle_menu_mouse_event(menu, event); return false; @@ -442,7 +441,8 @@ void WSWindowManager::start_window_drag(WSWindow& window, const WSMouseEvent& ev printf("[WM] Begin dragging WSWindow{%p}\n", &window); #endif move_to_front_and_make_active(window); - m_drag_window = window.make_weak_ptr();; + m_drag_window = window.make_weak_ptr(); + ; m_drag_origin = event.position(); m_drag_window_origin = window.position(); invalidate(window); @@ -472,7 +472,8 @@ void WSWindowManager::start_window_resize(WSWindow& window, const Point& positio printf("[WM] Begin resizing WSWindow{%p}\n", &window); #endif m_resizing_mouse_button = button; - m_resize_window = window.make_weak_ptr();; + m_resize_window = window.make_weak_ptr(); + ; m_resize_origin = position; m_resize_window_original_rect = window.rect(); @@ -612,8 +613,8 @@ bool WSWindowManager::process_ongoing_window_resize(const WSMouseEvent& event, W return true; #ifdef RESIZE_DEBUG dbgprintf("[WM] Resizing [original: %s] now: %s\n", - m_resize_window_original_rect.to_string().characters(), - new_rect.to_string().characters()); + m_resize_window_original_rect.to_string().characters(), + new_rect.to_string().characters()); #endif m_resize_window->set_rect(new_rect); WSEventLoop::the().post_event(*m_resize_window, make<WSResizeEvent>(old_rect, new_rect)); @@ -628,9 +629,12 @@ void WSWindowManager::set_cursor_tracking_button(WSButton* button) CElapsedTimer& WSWindowManager::DoubleClickInfo::click_clock(MouseButton button) { switch (button) { - case MouseButton::Left: return m_left_click_clock; - case MouseButton::Right: return m_right_click_clock; - case MouseButton::Middle: return m_middle_click_clock; + case MouseButton::Left: + return m_left_click_clock; + case MouseButton::Right: + return m_right_click_clock; + case MouseButton::Middle: + return m_middle_click_clock; default: ASSERT_NOT_REACHED(); } @@ -712,7 +716,7 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& hovere for (auto* window = m_windows_in_order.tail(); window; window = window->prev()) { if (!window->global_cursor_tracking()) continue; - ASSERT(window->is_visible()); // Maybe this should be supported? Idk. Let's catch it and think about it later. + ASSERT(window->is_visible()); // Maybe this should be supported? Idk. Let's catch it and think about it later. ASSERT(!window->is_minimized()); // Maybe this should also be supported? Idk. windows_who_received_mouse_event_due_to_cursor_tracking.set(window); auto translated_event = event.translated(-window->position()); @@ -742,7 +746,7 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& hovere WSWindow* event_window_with_frame = nullptr; - for_each_visible_window_from_front_to_back([&] (WSWindow& window) { + for_each_visible_window_from_front_to_back([&](WSWindow& window) { auto window_frame_rect = window.frame().rect(); if (!window_frame_rect.contains(event.position())) return IterationDecision::Continue; @@ -797,7 +801,7 @@ void WSWindowManager::clear_resize_candidate() bool WSWindowManager::any_opaque_window_contains_rect(const Rect& rect) { bool found_containing_window = false; - for_each_window([&] (WSWindow& window) { + for_each_window([&](WSWindow& window) { if (!window.is_visible()) return IterationDecision::Continue; if (window.is_minimized()) @@ -822,7 +826,7 @@ bool WSWindowManager::any_opaque_window_above_this_one_contains_rect(const WSWin { bool found_containing_window = false; bool checking = false; - for_each_visible_window_from_back_to_front([&] (WSWindow& window) { + for_each_visible_window_from_back_to_front([&](WSWindow& window) { if (&window == &a_window) { checking = true; return IterationDecision::Continue; @@ -849,7 +853,7 @@ bool WSWindowManager::any_opaque_window_above_this_one_contains_rect(const WSWin Rect WSWindowManager::menubar_rect() const { if (active_fullscreen_window()) - return { }; + return {}; return { 0, 0, WSScreen::the().rect().width(), 18 }; } @@ -1050,7 +1054,7 @@ Rect WSWindowManager::maximized_window_rect(const WSWindow& window) const rect.set_height(rect.height() - menubar_rect().height()); // Subtract taskbar window height if present - const_cast<WSWindowManager*>(this)->for_each_visible_window_of_type_from_back_to_front(WSWindowType::Taskbar, [&rect] (WSWindow& taskbar_window) { + const_cast<WSWindowManager*>(this)->for_each_visible_window_of_type_from_back_to_front(WSWindowType::Taskbar, [&rect](WSWindow& taskbar_window) { rect.set_height(rect.height() - taskbar_window.height()); return IterationDecision::Abort; }); diff --git a/Servers/WindowServer/WSWindowSwitcher.cpp b/Servers/WindowServer/WSWindowSwitcher.cpp index 69a84ec81a..42554265df 100644 --- a/Servers/WindowServer/WSWindowSwitcher.cpp +++ b/Servers/WindowServer/WSWindowSwitcher.cpp @@ -1,9 +1,9 @@ -#include <WindowServer/WSWindowSwitcher.h> -#include <WindowServer/WSWindowManager.h> -#include <WindowServer/WSEvent.h> -#include <WindowServer/WSScreen.h> #include <SharedGraphics/Font.h> #include <SharedGraphics/StylePainter.h> +#include <WindowServer/WSEvent.h> +#include <WindowServer/WSScreen.h> +#include <WindowServer/WSWindowManager.h> +#include <WindowServer/WSWindowSwitcher.h> static WSWindowSwitcher* s_the; @@ -70,8 +70,8 @@ void WSWindowSwitcher::on_key_event(const WSKeyEvent& event) void WSWindowSwitcher::draw() { Painter painter(*m_switcher_window->backing_store()); - painter.fill_rect({ { }, m_rect.size() }, Color::LightGray); - painter.draw_rect({ { }, m_rect.size() }, Color::DarkGray); + painter.fill_rect({ {}, m_rect.size() }, Color::LightGray); + painter.draw_rect({ {}, m_rect.size() }, Color::DarkGray); for (int index = 0; index < m_windows.size(); ++index) { auto& window = *m_windows.at(index); Rect item_rect { @@ -116,14 +116,15 @@ void WSWindowSwitcher::refresh() m_selected_index = 0; int window_count = 0; int longest_title_width = 0; - wm.for_each_visible_window_of_type_from_front_to_back(WSWindowType::Normal, [&] (WSWindow& window) { + wm.for_each_visible_window_of_type_from_front_to_back(WSWindowType::Normal, [&](WSWindow& window) { ++window_count; longest_title_width = max(longest_title_width, wm.font().width(window.title())); if (selected_window == &window) m_selected_index = m_windows.size(); m_windows.append(window.make_weak_ptr()); return IterationDecision::Continue; - }, true); + }, + true); if (m_windows.is_empty()) { hide(); return; diff --git a/Servers/WindowServer/main.cpp b/Servers/WindowServer/main.cpp index d4e889c1f5..3a8aff5c40 100644 --- a/Servers/WindowServer/main.cpp +++ b/Servers/WindowServer/main.cpp @@ -1,8 +1,8 @@ +#include <LibCore/CConfigFile.h> +#include <WindowServer/WSCompositor.h> +#include <WindowServer/WSEventLoop.h> #include <WindowServer/WSScreen.h> #include <WindowServer/WSWindowManager.h> -#include <WindowServer/WSEventLoop.h> -#include <WindowServer/WSCompositor.h> -#include <LibCore/CConfigFile.h> #include <signal.h> #include <stdio.h> @@ -22,7 +22,7 @@ int main(int, char**) auto wm_config = CConfigFile::get_for_app("WindowManager"); WSScreen screen(wm_config->read_num_entry("Screen", "Width", 1024), - wm_config->read_num_entry("Screen", "Height", 768)); + wm_config->read_num_entry("Screen", "Height", 768)); WSCompositor::the(); WSWindowManager window_manager; |