mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 09:42:45 +00:00 
			
		
		
		
	WindowServer: Run clang-format on everything.
This commit is contained in:
		
							parent
							
								
									76b3337498
								
							
						
					
					
						commit
						8358833bc8
					
				
					 12 changed files with 134 additions and 114 deletions
				
			
		|  | @ -1,9 +1,9 @@ | ||||||
|  | #include <SharedGraphics/CharacterBitmap.h> | ||||||
|  | #include <SharedGraphics/Painter.h> | ||||||
|  | #include <SharedGraphics/StylePainter.h> | ||||||
| #include <WindowServer/WSButton.h> | #include <WindowServer/WSButton.h> | ||||||
| #include <WindowServer/WSEvent.h> | #include <WindowServer/WSEvent.h> | ||||||
| #include <WindowServer/WSWindowManager.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) | WSButton::WSButton(WSWindowFrame& frame, Retained<CharacterBitmap>&& bitmap, Function<void(WSButton&)>&& on_click_handler) | ||||||
|     : on_click(move(on_click_handler)) |     : on_click(move(on_click_handler)) | ||||||
|  |  | ||||||
|  | @ -1,8 +1,8 @@ | ||||||
| #include <WindowServer/WSCPUMonitor.h> | #include <WindowServer/WSCPUMonitor.h> | ||||||
| #include <WindowServer/WSEventLoop.h> | #include <WindowServer/WSEventLoop.h> | ||||||
| #include <WindowServer/WSWindowManager.h> | #include <WindowServer/WSWindowManager.h> | ||||||
| #include <unistd.h> |  | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
|  | #include <unistd.h> | ||||||
| 
 | 
 | ||||||
| WSCPUMonitor::WSCPUMonitor() | WSCPUMonitor::WSCPUMonitor() | ||||||
|     : m_proc_all("/proc/all") |     : m_proc_all("/proc/all") | ||||||
|  | @ -10,7 +10,7 @@ WSCPUMonitor::WSCPUMonitor() | ||||||
|     if (!m_proc_all.open(CIODevice::OpenMode::ReadOnly)) |     if (!m_proc_all.open(CIODevice::OpenMode::ReadOnly)) | ||||||
|         ASSERT_NOT_REACHED(); |         ASSERT_NOT_REACHED(); | ||||||
| 
 | 
 | ||||||
|     create_thread([] (void* context) -> int { |     create_thread([](void* context) -> int { | ||||||
|         auto& monitor = *(WSCPUMonitor*)context; |         auto& monitor = *(WSCPUMonitor*)context; | ||||||
|         for (;;) { |         for (;;) { | ||||||
|             static unsigned last_busy; |             static unsigned last_busy; | ||||||
|  | @ -27,7 +27,8 @@ WSCPUMonitor::WSCPUMonitor() | ||||||
|             monitor.m_dirty = true; |             monitor.m_dirty = true; | ||||||
|             sleep(1); |             sleep(1); | ||||||
|         } |         } | ||||||
|     }, this); |     }, | ||||||
|  |         this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void WSCPUMonitor::get_cpu_usage(unsigned& busy, unsigned& idle) | void WSCPUMonitor::get_cpu_usage(unsigned& busy, unsigned& idle) | ||||||
|  | @ -65,8 +66,7 @@ void WSCPUMonitor::paint(Painter& painter, const Rect& rect) | ||||||
|         painter.draw_line( |         painter.draw_line( | ||||||
|             { rect.x() + i, rect.bottom() }, |             { rect.x() + i, rect.bottom() }, | ||||||
|             { rect.x() + i, (int)(rect.y() + (rect.height() - (cpu_usage * (float)rect.height()))) }, |             { rect.x() + i, (int)(rect.y() + (rect.height() - (cpu_usage * (float)rect.height()))) }, | ||||||
|             Color::from_rgb(0xaa6d4b) |             Color::from_rgb(0xaa6d4b)); | ||||||
|         ); |  | ||||||
|         ++i; |         ++i; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -355,7 +355,7 @@ void WSClientConnection::handle_request(const WSAPISetWindowOpacityRequest& requ | ||||||
| 
 | 
 | ||||||
| void WSClientConnection::handle_request(const WSAPISetWallpaperRequest& request) | 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; |         WSAPI_ServerMessage response; | ||||||
|         response.type = WSAPI_ServerMessage::Type::DidSetWallpaper; |         response.type = WSAPI_ServerMessage::Type::DidSetWallpaper; | ||||||
|         response.value = success; |         response.value = success; | ||||||
|  | @ -564,7 +564,7 @@ void WSClientConnection::handle_request(const WSAPIInvalidateRectRequest& reques | ||||||
|     } |     } | ||||||
|     auto& window = *(*it).value; |     auto& window = *(*it).value; | ||||||
|     for (int i = 0; i < request.rects().size(); ++i) |     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) | void WSClientConnection::handle_request(const WSAPIDidFinishPaintingNotification& request) | ||||||
|  |  | ||||||
|  | @ -1,21 +1,21 @@ | ||||||
| #include <WindowServer/WSEventLoop.h> |  | ||||||
| #include <WindowServer/WSEvent.h> |  | ||||||
| #include <LibCore/CObject.h> |  | ||||||
| #include <WindowServer/WSWindowManager.h> |  | ||||||
| #include <WindowServer/WSScreen.h> |  | ||||||
| #include <WindowServer/WSClientConnection.h> |  | ||||||
| #include <WindowServer/WSAPITypes.h> |  | ||||||
| #include <WindowServer/WSCursor.h> |  | ||||||
| #include <Kernel/KeyCode.h> | #include <Kernel/KeyCode.h> | ||||||
| #include <Kernel/MousePacket.h> | #include <Kernel/MousePacket.h> | ||||||
| #include <sys/socket.h> | #include <LibCore/CObject.h> | ||||||
|  | #include <WindowServer/WSAPITypes.h> | ||||||
|  | #include <WindowServer/WSClientConnection.h> | ||||||
|  | #include <WindowServer/WSCursor.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/select.h> | ||||||
|  | #include <sys/socket.h> | ||||||
| #include <sys/time.h> | #include <sys/time.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| #include <fcntl.h> |  | ||||||
| #include <stdio.h> |  | ||||||
| #include <errno.h> |  | ||||||
| 
 | 
 | ||||||
| //#define WSMESSAGELOOP_DEBUG
 | //#define WSMESSAGELOOP_DEBUG
 | ||||||
| 
 | 
 | ||||||
|  | @ -104,7 +104,7 @@ static Vector<Rect, 32> get_rects(const WSAPI_ClientMessage& message, const Byte | ||||||
| { | { | ||||||
|     Vector<Rect, 32> rects; |     Vector<Rect, 32> rects; | ||||||
|     if (message.rect_count > (WSAPI_ClientMessage::max_inline_rect_count + extra_data.size() / sizeof(WSAPI_Rect))) { |     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) |     for (int i = 0; i < min(WSAPI_ClientMessage::max_inline_rect_count, message.rect_count); ++i) | ||||||
|         rects.append(message.rects[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, |         post_event(client, | ||||||
|                    make<WSAPICreateWindowRequest>(client_id, |             make<WSAPICreateWindowRequest>(client_id, | ||||||
|                                                   message.window.rect, |                 message.window.rect, | ||||||
|                                                   String(message.text, message.text_length), |                 String(message.text, message.text_length), | ||||||
|                                                   message.window.has_alpha_channel, |                 message.window.has_alpha_channel, | ||||||
|                                                   message.window.modal, |                 message.window.modal, | ||||||
|                                                   message.window.resizable, |                 message.window.resizable, | ||||||
|                                                   message.window.fullscreen, |                 message.window.fullscreen, | ||||||
|                                                   message.window.show_titlebar, |                 message.window.show_titlebar, | ||||||
|                                                   message.window.opacity, |                 message.window.opacity, | ||||||
|                                                   message.window.base_size, |                 message.window.base_size, | ||||||
|                                                   message.window.size_increment, |                 message.window.size_increment, | ||||||
|                                                   ws_window_type, |                 ws_window_type, | ||||||
|                                                   Color::from_rgba(message.window.background_color))); |                 Color::from_rgba(message.window.background_color))); | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
|     case WSAPI_ClientMessage::Type::DestroyWindow: |     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) | 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); |         FD_SET(fd, &set); | ||||||
|         if (fd > max_fd_added) |         if (fd > max_fd_added) | ||||||
|             max_fd_added = fd; |             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_keyboard_fd, fds); | ||||||
|     add_fd_to_set(m_mouse_fd, fds); |     add_fd_to_set(m_mouse_fd, fds); | ||||||
|     add_fd_to_set(m_server_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); |         add_fd_to_set(client.fd(), fds); | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  | @ -341,7 +341,7 @@ void WSEventLoop::process_file_descriptors_after_select(const fd_set& fds) | ||||||
|         drain_keyboard(); |         drain_keyboard(); | ||||||
|     if (FD_ISSET(m_mouse_fd, &fds)) |     if (FD_ISSET(m_mouse_fd, &fds)) | ||||||
|         drain_mouse(); |         drain_mouse(); | ||||||
|     WSClientConnection::for_each_client([&] (WSClientConnection& client) { |     WSClientConnection::for_each_client([&](WSClientConnection& client) { | ||||||
|         if (FD_ISSET(client.fd(), &fds)) |         if (FD_ISSET(client.fd(), &fds)) | ||||||
|             drain_client(client); |             drain_client(client); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  | @ -1,16 +1,16 @@ | ||||||
| #include "WSMenu.h" | #include "WSMenu.h" | ||||||
| #include "WSMenuItem.h" |  | ||||||
| #include "WSWindow.h" |  | ||||||
| #include "WSEvent.h" | #include "WSEvent.h" | ||||||
| #include "WSEventLoop.h" | #include "WSEventLoop.h" | ||||||
| #include "WSWindowManager.h" | #include "WSMenuItem.h" | ||||||
| #include "WSScreen.h" | #include "WSScreen.h" | ||||||
| #include <WindowServer/WSAPITypes.h> | #include "WSWindow.h" | ||||||
| #include <WindowServer/WSClientConnection.h> | #include "WSWindowManager.h" | ||||||
| #include <SharedGraphics/CharacterBitmap.h> | #include <SharedGraphics/CharacterBitmap.h> | ||||||
|  | #include <SharedGraphics/Font.h> | ||||||
| #include <SharedGraphics/Painter.h> | #include <SharedGraphics/Painter.h> | ||||||
| #include <SharedGraphics/StylePainter.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) | WSMenu::WSMenu(WSClientConnection* client, int menu_id, const String& name) | ||||||
|     : m_client(client) |     : m_client(client) | ||||||
|  | @ -115,7 +115,7 @@ void WSMenu::draw() | ||||||
|     ASSERT(menu_window()->backing_store()); |     ASSERT(menu_window()->backing_store()); | ||||||
|     Painter painter(*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); |     painter.fill_rect(rect.shrunken(6, 6), Color::LightGray); | ||||||
|     StylePainter::paint_window_frame(painter, rect); |     StylePainter::paint_window_frame(painter, rect); | ||||||
|     int width = this->width(); |     int width = this->width(); | ||||||
|  |  | ||||||
|  | @ -11,4 +11,3 @@ WSMenuBar::WSMenuBar(WSClientConnection& client, int menubar_id) | ||||||
| WSMenuBar::~WSMenuBar() | WSMenuBar::~WSMenuBar() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
|  | #include "WSScreen.h" | ||||||
| #include "WSCompositor.h" | #include "WSCompositor.h" | ||||||
| #include "WSEvent.h" | #include "WSEvent.h" | ||||||
| #include "WSEventLoop.h" | #include "WSEventLoop.h" | ||||||
| #include "WSScreen.h" |  | ||||||
| #include "WSWindowManager.h" | #include "WSWindowManager.h" | ||||||
| #include <fcntl.h> | #include <fcntl.h> | ||||||
| #include <sys/ioctl.h> | #include <sys/ioctl.h> | ||||||
|  | @ -39,7 +39,7 @@ void WSScreen::set_resolution(int width, int height) | ||||||
|         int width; |         int width; | ||||||
|         int height; |         int height; | ||||||
|     }; |     }; | ||||||
|     BXVGAResolution resolution { (int)width, (int)height}; |     BXVGAResolution resolution { (int)width, (int)height }; | ||||||
|     int rc = ioctl(m_framebuffer_fd, 1985, (int)&resolution); |     int rc = ioctl(m_framebuffer_fd, 1985, (int)&resolution); | ||||||
|     ASSERT(rc == 0); |     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; |     unsigned prev_buttons = m_mouse_button_state; | ||||||
|     m_mouse_button_state = buttons; |     m_mouse_button_state = buttons; | ||||||
|     unsigned changed_buttons = prev_buttons ^ 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)) |         if (!(changed_buttons & (unsigned)button)) | ||||||
|             return; |             return; | ||||||
|         auto message = make<WSMouseEvent>(buttons & (unsigned)button ? WSEvent::MouseDown : WSEvent::MouseUp, m_cursor_location, buttons, button, m_modifiers); |         auto message = make<WSMouseEvent>(buttons & (unsigned)button ? WSEvent::MouseDown : WSEvent::MouseUp, m_cursor_location, buttons, button, m_modifiers); | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| #include "WSWindow.h" | #include "WSWindow.h" | ||||||
| #include "WSWindowManager.h" |  | ||||||
| #include "WSEvent.h" | #include "WSEvent.h" | ||||||
| #include "WSEventLoop.h" | #include "WSEventLoop.h" | ||||||
|  | #include "WSWindowManager.h" | ||||||
| #include <WindowServer/WSAPITypes.h> | #include <WindowServer/WSAPITypes.h> | ||||||
| #include <WindowServer/WSClientConnection.h> | #include <WindowServer/WSClientConnection.h> | ||||||
| 
 | 
 | ||||||
|  | @ -77,10 +77,14 @@ void WSWindow::set_rect(const Rect& rect) | ||||||
| static WSAPI_MouseButton to_api(MouseButton button) | static WSAPI_MouseButton to_api(MouseButton button) | ||||||
| { | { | ||||||
|     switch (button) { |     switch (button) { | ||||||
|     case MouseButton::None: return WSAPI_MouseButton::NoButton; |     case MouseButton::None: | ||||||
|     case MouseButton::Left: return WSAPI_MouseButton::Left; |         return WSAPI_MouseButton::NoButton; | ||||||
|     case MouseButton::Right: return WSAPI_MouseButton::Right; |     case MouseButton::Left: | ||||||
|     case MouseButton::Middle: return WSAPI_MouseButton::Middle; |         return WSAPI_MouseButton::Left; | ||||||
|  |     case MouseButton::Right: | ||||||
|  |         return WSAPI_MouseButton::Right; | ||||||
|  |     case MouseButton::Middle: | ||||||
|  |         return WSAPI_MouseButton::Middle; | ||||||
|     } |     } | ||||||
|     ASSERT_NOT_REACHED(); |     ASSERT_NOT_REACHED(); | ||||||
| } | } | ||||||
|  | @ -93,12 +97,23 @@ void WSWindow::handle_mouse_event(const WSMouseEvent& event) | ||||||
|     server_message.window_id = window_id(); |     server_message.window_id = window_id(); | ||||||
| 
 | 
 | ||||||
|     switch (event.type()) { |     switch (event.type()) { | ||||||
|     case WSEvent::MouseMove: server_message.type = WSAPI_ServerMessage::Type::MouseMove; break; |     case WSEvent::MouseMove: | ||||||
|     case WSEvent::MouseDown: server_message.type = WSAPI_ServerMessage::Type::MouseDown; break; |         server_message.type = WSAPI_ServerMessage::Type::MouseMove; | ||||||
|     case WSEvent::MouseDoubleClick: server_message.type = WSAPI_ServerMessage::Type::MouseDoubleClick; break; |         break; | ||||||
|     case WSEvent::MouseUp: server_message.type = WSAPI_ServerMessage::Type::MouseUp; break; |     case WSEvent::MouseDown: | ||||||
|     case WSEvent::MouseWheel: server_message.type = WSAPI_ServerMessage::Type::MouseWheel; break; |         server_message.type = WSAPI_ServerMessage::Type::MouseDown; | ||||||
|     default: ASSERT_NOT_REACHED(); |         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(); |     server_message.mouse.position = event.position(); | ||||||
|  | @ -134,7 +149,7 @@ void WSWindow::set_minimized(bool minimized) | ||||||
|         return; |         return; | ||||||
|     m_minimized = minimized; |     m_minimized = minimized; | ||||||
|     if (!minimized) |     if (!minimized) | ||||||
|         request_update({ { }, size() }); |         request_update({ {}, size() }); | ||||||
|     invalidate(); |     invalidate(); | ||||||
|     WSWindowManager::the().notify_minimization_state_changed(*this); |     WSWindowManager::the().notify_minimization_state_changed(*this); | ||||||
| } | } | ||||||
|  | @ -291,7 +306,7 @@ void WSWindow::set_default_icon() | ||||||
| void WSWindow::request_update(const Rect& rect) | void WSWindow::request_update(const Rect& rect) | ||||||
| { | { | ||||||
|     if (m_pending_paint_rects.is_empty()) { |     if (m_pending_paint_rects.is_empty()) { | ||||||
|         deferred_invoke([this] (auto&) { |         deferred_invoke([this](auto&) { | ||||||
|             client()->post_paint_message(*this); |             client()->post_paint_message(*this); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -90,20 +90,20 @@ WSWindowFrame::WSWindowFrame(WSWindow& window) | ||||||
|     if (!s_unmaximize_button_bitmap) |     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(); |         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); |         WSEvent close_request(WSEvent::WindowCloseRequest); | ||||||
|         m_window.event(close_request); |         m_window.event(close_request); | ||||||
|     })); |     })); | ||||||
| 
 | 
 | ||||||
|     if (window.is_resizable()) { |     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_window.set_maximized(!m_window.is_maximized()); | ||||||
|         }); |         }); | ||||||
|         m_maximize_button = button.ptr(); |         m_maximize_button = button.ptr(); | ||||||
|         m_buttons.append(move(button)); |         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); |         m_window.set_minimized(true); | ||||||
|     })); |     })); | ||||||
| } | } | ||||||
|  | @ -159,7 +159,7 @@ void WSWindowFrame::paint(Painter& painter) | ||||||
|     auto titlebar_rect = title_bar_rect(); |     auto titlebar_rect = title_bar_rect(); | ||||||
|     auto titlebar_icon_rect = title_bar_icon_rect(); |     auto titlebar_icon_rect = title_bar_icon_rect(); | ||||||
|     auto titlebar_inner_rect = title_bar_text_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; |     auto titlebar_title_rect = titlebar_inner_rect; | ||||||
|     titlebar_title_rect.set_width(Font::default_bold_font().width(window.title())); |     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) { |     switch (type) { | ||||||
|     case WSWindowType::Normal: |     case WSWindowType::Normal: | ||||||
|         return { rect.x() - 3, |         return { rect.x() - 3, | ||||||
|                  rect.y() - window_titlebar_height - 4 + offset, |             rect.y() - window_titlebar_height - 4 + offset, | ||||||
|                  rect.width() + 6, |             rect.width() + 6, | ||||||
|                  rect.height() + 7 + window_titlebar_height - offset }; |             rect.height() + 7 + window_titlebar_height - offset }; | ||||||
|     default: |     default: | ||||||
|         return rect; |         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_width = 15; | ||||||
|     int window_button_height = 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) { |     for (auto& button : m_buttons) { | ||||||
|         x -= window_button_width; |         x -= window_button_width; | ||||||
|         Rect rect { x, 0, window_button_width, window_button_height }; |         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::Left, ResizeDirection::None, ResizeDirection::Right }, | ||||||
|             { ResizeDirection::DownLeft, ResizeDirection::Down, ResizeDirection::DownRight }, |             { ResizeDirection::DownLeft, ResizeDirection::Down, ResizeDirection::DownRight }, | ||||||
|         }; |         }; | ||||||
|         Rect outer_rect = { { }, rect().size() }; |         Rect outer_rect = { {}, rect().size() }; | ||||||
|         ASSERT(outer_rect.contains(event.position())); |         ASSERT(outer_rect.contains(event.position())); | ||||||
|         int window_relative_x = event.x() - outer_rect.x(); |         int window_relative_x = event.x() - outer_rect.x(); | ||||||
|         int window_relative_y = event.y() - outer_rect.y(); |         int window_relative_y = event.y() - outer_rect.y(); | ||||||
|  |  | ||||||
|  | @ -1,3 +1,4 @@ | ||||||
|  | #include "WSWindowManager.h" | ||||||
| #include "WSCompositor.h" | #include "WSCompositor.h" | ||||||
| #include "WSEventLoop.h" | #include "WSEventLoop.h" | ||||||
| #include "WSMenu.h" | #include "WSMenu.h" | ||||||
|  | @ -5,7 +6,6 @@ | ||||||
| #include "WSMenuItem.h" | #include "WSMenuItem.h" | ||||||
| #include "WSScreen.h" | #include "WSScreen.h" | ||||||
| #include "WSWindow.h" | #include "WSWindow.h" | ||||||
| #include "WSWindowManager.h" |  | ||||||
| #include <AK/StdLibExtras.h> | #include <AK/StdLibExtras.h> | ||||||
| #include <AK/Vector.h> | #include <AK/Vector.h> | ||||||
| #include <LibCore/CTimer.h> | #include <LibCore/CTimer.h> | ||||||
|  | @ -43,8 +43,8 @@ WSWindowManager::WSWindowManager() | ||||||
|     reload_config(false); |     reload_config(false); | ||||||
| 
 | 
 | ||||||
|     struct AppMenuItem { |     struct AppMenuItem { | ||||||
|         const char *binary_name; |         const char* binary_name; | ||||||
|         const char *description; |         const char* description; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     Vector<AppMenuItem> apps; |     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, 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, WSMenuItem::Separator)); | ||||||
|         m_system_menu->add_item(make<WSMenuItem>(*m_system_menu, 200, "About...")); |         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 (item.identifier() >= 1 && item.identifier() <= 1 + apps.size() - 1) { | ||||||
|                 if (fork() == 0) { |                 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); |                     execl(bin, bin, nullptr); | ||||||
|                     ASSERT_NOT_REACHED(); |                     ASSERT_NOT_REACHED(); | ||||||
|                 } |                 } | ||||||
|  | @ -139,7 +139,7 @@ void WSWindowManager::reload_config(bool set_screen) | ||||||
| 
 | 
 | ||||||
|     if (set_screen) |     if (set_screen) | ||||||
|         set_resolution(m_wm_config->read_num_entry("Screen", "Width", 1920), |         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_arrow_cursor = get_cursor("Arrow", { 2, 2 }); | ||||||
|     m_resize_horizontally_cursor = get_cursor("ResizeH"); |     m_resize_horizontally_cursor = get_cursor("ResizeH"); | ||||||
|  | @ -199,19 +199,18 @@ void WSWindowManager::tick_clock() | ||||||
| void WSWindowManager::set_resolution(int width, int height) | void WSWindowManager::set_resolution(int width, int height) | ||||||
| { | { | ||||||
|     WSCompositor::the().set_resolution(width, 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()); |         client.notify_about_new_screen_rect(WSScreen::the().rect()); | ||||||
|     }); |     }); | ||||||
|     if (m_wm_config) { |     if (m_wm_config) { | ||||||
|         dbgprintf("Saving resolution: %dx%d to config file at %s.\n", width, height, |         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", "Width", width); | ||||||
|         m_wm_config->write_num_entry("Screen", "Height", height); |         m_wm_config->write_num_entry("Screen", "Height", height); | ||||||
|         m_wm_config->sync(); |         m_wm_config->sync(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| int WSWindowManager::menubar_menu_margin() const | int WSWindowManager::menubar_menu_margin() const | ||||||
| { | { | ||||||
|     return 16; |     return 16; | ||||||
|  | @ -238,7 +237,7 @@ void WSWindowManager::set_current_menubar(WSMenuBar* menubar) | ||||||
| #endif | #endif | ||||||
|     Point next_menu_location { menubar_menu_margin() / 2, 0 }; |     Point next_menu_location { menubar_menu_margin() / 2, 0 }; | ||||||
|     int index = 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()); |         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_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() } }); |         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(); |         m_switcher.refresh(); | ||||||
| 
 | 
 | ||||||
|     if (window.listens_to_wm_events()) { |     if (window.listens_to_wm_events()) { | ||||||
|         for_each_window([&] (WSWindow& other_window) { |         for_each_window([&](WSWindow& other_window) { | ||||||
|             if (&window != &other_window) { |             if (&window != &other_window) { | ||||||
|                 tell_wm_listener_about_window(window, other_window); |                 tell_wm_listener_about_window(window, other_window); | ||||||
|                 tell_wm_listener_about_window_icon(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) |     if (m_switcher.is_visible() && window.type() != WSWindowType::WindowSwitcher) | ||||||
|         m_switcher.refresh(); |         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)) |         if (!(listener.wm_event_mask() & WSAPI_WMEventMask::WindowRemovals)) | ||||||
|             return IterationDecision::Continue; |             return IterationDecision::Continue; | ||||||
|         if (window.client()) |         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) | 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); |         tell_wm_listener_about_window(listener, window); | ||||||
|         return IterationDecision::Continue; |         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) | 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); |         tell_wm_listener_about_window_icon(listener, window); | ||||||
|         return IterationDecision::Continue; |         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) | 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); |         tell_wm_listener_about_window_rect(listener, window); | ||||||
|         return IterationDecision::Continue; |         return IterationDecision::Continue; | ||||||
|     }); |     }); | ||||||
|  | @ -388,7 +387,7 @@ void WSWindowManager::notify_minimization_state_changed(WSWindow& window) | ||||||
| 
 | 
 | ||||||
| void WSWindowManager::pick_new_active_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); |         set_active_window(&candidate); | ||||||
|         return IterationDecision::Abort; |         return IterationDecision::Abort; | ||||||
|     }); |     }); | ||||||
|  | @ -427,7 +426,7 @@ void WSWindowManager::close_current_menu() | ||||||
| 
 | 
 | ||||||
| void WSWindowManager::handle_menubar_mouse_event(const WSMouseEvent& event) | 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())) { |         if (menu.rect_in_menubar().contains(event.position())) { | ||||||
|             handle_menu_mouse_event(menu, event); |             handle_menu_mouse_event(menu, event); | ||||||
|             return false; |             return false; | ||||||
|  | @ -442,7 +441,8 @@ void WSWindowManager::start_window_drag(WSWindow& window, const WSMouseEvent& ev | ||||||
|     printf("[WM] Begin dragging WSWindow{%p}\n", &window); |     printf("[WM] Begin dragging WSWindow{%p}\n", &window); | ||||||
| #endif | #endif | ||||||
|     move_to_front_and_make_active(window); |     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_origin = event.position(); | ||||||
|     m_drag_window_origin = window.position(); |     m_drag_window_origin = window.position(); | ||||||
|     invalidate(window); |     invalidate(window); | ||||||
|  | @ -472,7 +472,8 @@ void WSWindowManager::start_window_resize(WSWindow& window, const Point& positio | ||||||
|     printf("[WM] Begin resizing WSWindow{%p}\n", &window); |     printf("[WM] Begin resizing WSWindow{%p}\n", &window); | ||||||
| #endif | #endif | ||||||
|     m_resizing_mouse_button = button; |     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_origin = position; | ||||||
|     m_resize_window_original_rect = window.rect(); |     m_resize_window_original_rect = window.rect(); | ||||||
| 
 | 
 | ||||||
|  | @ -612,8 +613,8 @@ bool WSWindowManager::process_ongoing_window_resize(const WSMouseEvent& event, W | ||||||
|         return true; |         return true; | ||||||
| #ifdef RESIZE_DEBUG | #ifdef RESIZE_DEBUG | ||||||
|     dbgprintf("[WM] Resizing [original: %s] now: %s\n", |     dbgprintf("[WM] Resizing [original: %s] now: %s\n", | ||||||
|               m_resize_window_original_rect.to_string().characters(), |         m_resize_window_original_rect.to_string().characters(), | ||||||
|               new_rect.to_string().characters()); |         new_rect.to_string().characters()); | ||||||
| #endif | #endif | ||||||
|     m_resize_window->set_rect(new_rect); |     m_resize_window->set_rect(new_rect); | ||||||
|     WSEventLoop::the().post_event(*m_resize_window, make<WSResizeEvent>(old_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) | CElapsedTimer& WSWindowManager::DoubleClickInfo::click_clock(MouseButton button) | ||||||
| { | { | ||||||
|     switch (button) { |     switch (button) { | ||||||
|     case MouseButton::Left: return m_left_click_clock; |     case MouseButton::Left: | ||||||
|     case MouseButton::Right: return m_right_click_clock; |         return m_left_click_clock; | ||||||
|     case MouseButton::Middle: return m_middle_click_clock; |     case MouseButton::Right: | ||||||
|  |         return m_right_click_clock; | ||||||
|  |     case MouseButton::Middle: | ||||||
|  |         return m_middle_click_clock; | ||||||
|     default: |     default: | ||||||
|         ASSERT_NOT_REACHED(); |         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()) { |     for (auto* window = m_windows_in_order.tail(); window; window = window->prev()) { | ||||||
|         if (!window->global_cursor_tracking()) |         if (!window->global_cursor_tracking()) | ||||||
|             continue; |             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.
 |         ASSERT(!window->is_minimized()); // Maybe this should also be supported? Idk.
 | ||||||
|         windows_who_received_mouse_event_due_to_cursor_tracking.set(window); |         windows_who_received_mouse_event_due_to_cursor_tracking.set(window); | ||||||
|         auto translated_event = event.translated(-window->position()); |         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; |     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(); |         auto window_frame_rect = window.frame().rect(); | ||||||
|         if (!window_frame_rect.contains(event.position())) |         if (!window_frame_rect.contains(event.position())) | ||||||
|             return IterationDecision::Continue; |             return IterationDecision::Continue; | ||||||
|  | @ -797,7 +801,7 @@ void WSWindowManager::clear_resize_candidate() | ||||||
| bool WSWindowManager::any_opaque_window_contains_rect(const Rect& rect) | bool WSWindowManager::any_opaque_window_contains_rect(const Rect& rect) | ||||||
| { | { | ||||||
|     bool found_containing_window = false; |     bool found_containing_window = false; | ||||||
|     for_each_window([&] (WSWindow& window) { |     for_each_window([&](WSWindow& window) { | ||||||
|         if (!window.is_visible()) |         if (!window.is_visible()) | ||||||
|             return IterationDecision::Continue; |             return IterationDecision::Continue; | ||||||
|         if (window.is_minimized()) |         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 found_containing_window = false; | ||||||
|     bool checking = 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) { |         if (&window == &a_window) { | ||||||
|             checking = true; |             checking = true; | ||||||
|             return IterationDecision::Continue; |             return IterationDecision::Continue; | ||||||
|  | @ -849,7 +853,7 @@ bool WSWindowManager::any_opaque_window_above_this_one_contains_rect(const WSWin | ||||||
| Rect WSWindowManager::menubar_rect() const | Rect WSWindowManager::menubar_rect() const | ||||||
| { | { | ||||||
|     if (active_fullscreen_window()) |     if (active_fullscreen_window()) | ||||||
|         return { }; |         return {}; | ||||||
|     return { 0, 0, WSScreen::the().rect().width(), 18 }; |     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()); |     rect.set_height(rect.height() - menubar_rect().height()); | ||||||
| 
 | 
 | ||||||
|     // Subtract taskbar window height if present
 |     // 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()); |         rect.set_height(rect.height() - taskbar_window.height()); | ||||||
|         return IterationDecision::Abort; |         return IterationDecision::Abort; | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  | @ -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/Font.h> | ||||||
| #include <SharedGraphics/StylePainter.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; | static WSWindowSwitcher* s_the; | ||||||
| 
 | 
 | ||||||
|  | @ -70,8 +70,8 @@ void WSWindowSwitcher::on_key_event(const WSKeyEvent& event) | ||||||
| void WSWindowSwitcher::draw() | void WSWindowSwitcher::draw() | ||||||
| { | { | ||||||
|     Painter painter(*m_switcher_window->backing_store()); |     Painter painter(*m_switcher_window->backing_store()); | ||||||
|     painter.fill_rect({ { }, m_rect.size() }, Color::LightGray); |     painter.fill_rect({ {}, m_rect.size() }, Color::LightGray); | ||||||
|     painter.draw_rect({ { }, m_rect.size() }, Color::DarkGray); |     painter.draw_rect({ {}, m_rect.size() }, Color::DarkGray); | ||||||
|     for (int index = 0; index < m_windows.size(); ++index) { |     for (int index = 0; index < m_windows.size(); ++index) { | ||||||
|         auto& window = *m_windows.at(index); |         auto& window = *m_windows.at(index); | ||||||
|         Rect item_rect { |         Rect item_rect { | ||||||
|  | @ -116,14 +116,15 @@ void WSWindowSwitcher::refresh() | ||||||
|     m_selected_index = 0; |     m_selected_index = 0; | ||||||
|     int window_count = 0; |     int window_count = 0; | ||||||
|     int longest_title_width = 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; |         ++window_count; | ||||||
|         longest_title_width = max(longest_title_width, wm.font().width(window.title())); |         longest_title_width = max(longest_title_width, wm.font().width(window.title())); | ||||||
|         if (selected_window == &window) |         if (selected_window == &window) | ||||||
|             m_selected_index = m_windows.size(); |             m_selected_index = m_windows.size(); | ||||||
|         m_windows.append(window.make_weak_ptr()); |         m_windows.append(window.make_weak_ptr()); | ||||||
|         return IterationDecision::Continue; |         return IterationDecision::Continue; | ||||||
|     }, true); |     }, | ||||||
|  |         true); | ||||||
|     if (m_windows.is_empty()) { |     if (m_windows.is_empty()) { | ||||||
|         hide(); |         hide(); | ||||||
|         return; |         return; | ||||||
|  |  | ||||||
|  | @ -1,8 +1,8 @@ | ||||||
|  | #include <LibCore/CConfigFile.h> | ||||||
|  | #include <WindowServer/WSCompositor.h> | ||||||
|  | #include <WindowServer/WSEventLoop.h> | ||||||
| #include <WindowServer/WSScreen.h> | #include <WindowServer/WSScreen.h> | ||||||
| #include <WindowServer/WSWindowManager.h> | #include <WindowServer/WSWindowManager.h> | ||||||
| #include <WindowServer/WSEventLoop.h> |  | ||||||
| #include <WindowServer/WSCompositor.h> |  | ||||||
| #include <LibCore/CConfigFile.h> |  | ||||||
| #include <signal.h> | #include <signal.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| 
 | 
 | ||||||
|  | @ -22,7 +22,7 @@ int main(int, char**) | ||||||
| 
 | 
 | ||||||
|     auto wm_config = CConfigFile::get_for_app("WindowManager"); |     auto wm_config = CConfigFile::get_for_app("WindowManager"); | ||||||
|     WSScreen screen(wm_config->read_num_entry("Screen", "Width", 1024), |     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(); |     WSCompositor::the(); | ||||||
|     WSWindowManager window_manager; |     WSWindowManager window_manager; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling