diff options
author | asynts <asynts@gmail.com> | 2021-01-17 20:28:43 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-22 22:14:30 +0100 |
commit | fb8d3635d912a40a66a9e4b50454cfdd83f71d16 (patch) | |
tree | 8a5183f91957d1e3e7bf27a6411c06d96363918f /Userland/Services | |
parent | 24888457d5ee7e3df8015cdc4481ccaa25d07565 (diff) | |
download | serenity-fb8d3635d912a40a66a9e4b50454cfdd83f71d16.zip |
Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
Diffstat (limited to 'Userland/Services')
-rw-r--r-- | Userland/Services/WindowServer/Cursor.cpp | 6 | ||||
-rw-r--r-- | Userland/Services/WindowServer/MenuManager.cpp | 9 | ||||
-rw-r--r-- | Userland/Services/WindowServer/Screen.cpp | 8 | ||||
-rw-r--r-- | Userland/Services/WindowServer/WindowManager.cpp | 79 |
4 files changed, 45 insertions, 57 deletions
diff --git a/Userland/Services/WindowServer/Cursor.cpp b/Userland/Services/WindowServer/Cursor.cpp index dcc10d8e6b..f5044dc71f 100644 --- a/Userland/Services/WindowServer/Cursor.cpp +++ b/Userland/Services/WindowServer/Cursor.cpp @@ -67,7 +67,7 @@ CursorParams CursorParams::parse_from_file_name(const StringView& cursor_path, c return parsed_number.value(); }(); if (!value.has_value()) { - dbg() << "Failed to parse value for property '" << property << "' from parsed cursor path: " << cursor_path; + dbgln("Failed to parse value for property '{}' from parsed cursor path: {}", property, cursor_path); return { default_hotspot }; } switch (property) { @@ -93,7 +93,7 @@ CursorParams CursorParams::parse_from_file_name(const StringView& cursor_path, c in_display_scale_part = true; break; default: - dbg() << "Ignore unknown property '" << property << "' with value " << value.value() << " parsed from cursor path: " << cursor_path; + dbgln("Ignore unknown property '{}' with value {} parsed from cursor path: {}", property, value.value(), cursor_path); return { default_hotspot }; } } @@ -108,7 +108,7 @@ CursorParams CursorParams::constrained(const Gfx::Bitmap& bitmap) const if (rect.width() % params.m_frames == 0) { rect.set_width(rect.width() / (int)params.m_frames); } else { - dbg() << "Cannot divide cursor dimensions " << rect << " into " << params.m_frames << " frames"; + dbgln("Cannot divide cursor dimensions {} into {} frames", rect, params.m_frames); params.m_frames = 1; } } diff --git a/Userland/Services/WindowServer/MenuManager.cpp b/Userland/Services/WindowServer/MenuManager.cpp index ba2ba789f9..b50cb800b4 100644 --- a/Userland/Services/WindowServer/MenuManager.cpp +++ b/Userland/Services/WindowServer/MenuManager.cpp @@ -26,6 +26,7 @@ */ #include <AK/Badge.h> +#include <AK/Debug.h> #include <AK/QuickSort.h> #include <LibCore/DirIterator.h> #include <LibGfx/Font.h> @@ -36,8 +37,6 @@ #include <WindowServer/WindowManager.h> #include <unistd.h> -//#define DEBUG_MENUS - namespace WindowServer { static MenuManager* s_the; @@ -459,9 +458,9 @@ void MenuManager::set_current_menubar(MenuBar* menubar) m_current_menubar = *menubar; else m_current_menubar = nullptr; -#ifdef DEBUG_MENUS - dbg() << "[WM] Current menubar is now " << menubar; -#endif + + dbgln<debug_menus>("[WM] Current menubar is now {}", menubar); + Gfx::IntPoint next_menu_location { MenuManager::menubar_menu_margin() / 2, 0 }; for_each_active_menubar_menu([&](Menu& menu) { int text_width = menu.title_font().width(menu.name()); diff --git a/Userland/Services/WindowServer/Screen.cpp b/Userland/Services/WindowServer/Screen.cpp index 2c5d47108c..dac462cc52 100644 --- a/Userland/Services/WindowServer/Screen.cpp +++ b/Userland/Services/WindowServer/Screen.cpp @@ -29,6 +29,7 @@ #include "Event.h" #include "EventLoop.h" #include "WindowManager.h" +#include <AK/Debug.h> #include <Kernel/API/FB.h> #include <Kernel/API/MousePacket.h> #include <fcntl.h> @@ -81,15 +82,14 @@ bool Screen::set_resolution(int width, int height, int new_scale_factor) FBResolution physical_resolution { 0, (unsigned)new_physical_width, (unsigned)new_physical_height }; int rc = fb_set_resolution(m_framebuffer_fd, &physical_resolution); -#ifdef WSSCREEN_DEBUG - dbg() << "fb_set_resolution() - return code " << rc; -#endif + dbgln<debug_wsscreen>("fb_set_resolution() - return code {}", rc); + if (rc == 0) { on_change_resolution(physical_resolution.pitch, physical_resolution.width, physical_resolution.height, new_scale_factor); return true; } if (rc == -1) { - dbg() << "Invalid resolution " << width << "x" << height; + dbgln("Invalid resolution {}x{}", width, height); on_change_resolution(physical_resolution.pitch, physical_resolution.width, physical_resolution.height, new_scale_factor); return false; } diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index c0be674b95..d6d96d09f7 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -139,13 +139,13 @@ bool WindowManager::set_resolution(int width, int height, int scale) } if (m_config) { if (success) { - dbg() << "Saving resolution: " << Gfx::IntSize(width, height) << " @ " << scale << "x to config file at " << m_config->file_name(); + dbgln("Saving resolution: {} @ {}x to config file at {}", Gfx::IntSize(width, height), scale, m_config->file_name()); m_config->write_num_entry("Screen", "Width", width); m_config->write_num_entry("Screen", "Height", height); m_config->write_num_entry("Screen", "ScaleFactor", scale); m_config->sync(); } else { - dbg() << "Saving fallback resolution: " << resolution() << " @ 1x to config file at " << m_config->file_name(); + dbgln("Saving fallback resolution: {} @1x to config file at {}", resolution(), m_config->file_name()); m_config->write_num_entry("Screen", "Width", resolution().width()); m_config->write_num_entry("Screen", "Height", resolution().height()); m_config->write_num_entry("Screen", "ScaleFactor", 1); @@ -347,9 +347,9 @@ void WindowManager::notify_title_changed(Window& window) { if (window.type() != WindowType::Normal) return; -#ifdef WINDOWMANAGER_DEBUG - dbg() << "[WM] Window{" << &window << "} title set to \"" << window.title() << '"'; -#endif + + dbgln<debug_window_manager>("[WM] Window({}) title set to '{}'", &window, window.title()); + if (m_switcher.is_visible()) m_switcher.refresh(); @@ -360,20 +360,19 @@ void WindowManager::notify_modal_unparented(Window& window) { if (window.type() != WindowType::Normal) return; -#ifdef WINDOWMANAGER_DEBUG - dbg() << "[WM] Modal Window{" << &window << "} was unparented"; -#endif + + dbgln<debug_window_manager>("[WM] Window({}) was unparented", &window); + if (m_switcher.is_visible()) m_switcher.refresh(); tell_wm_listeners_window_state_changed(window); } -void WindowManager::notify_rect_changed(Window& window, [[maybe_unused]] const Gfx::IntRect& old_rect, [[maybe_unused]] const Gfx::IntRect& new_rect) +void WindowManager::notify_rect_changed(Window& window, const Gfx::IntRect& old_rect, const Gfx::IntRect& new_rect) { -#ifdef RESIZE_DEBUG - dbg() << "[WM] Window " << &window << " rect changed " << old_rect << " -> " << new_rect; -#endif + dbgln<debug_resize>("[WM] Window({}) rect changed {} -> {}", &window, old_rect, new_rect); + if (m_switcher.is_visible() && window.type() != WindowType::WindowSwitcher) m_switcher.refresh(); @@ -437,9 +436,8 @@ bool WindowManager::pick_new_active_window(Window* previous_active) void WindowManager::start_window_move(Window& window, const MouseEvent& event) { -#ifdef MOVE_DEBUG - dbg() << "[WM] Begin moving Window{" << &window << "}"; -#endif + dbgln<debug_move>("[WM] Begin moving Window({})", &window); + move_to_front_and_make_active(window); m_move_window = window; m_move_window->set_default_positioned(false); @@ -459,7 +457,7 @@ void WindowManager::start_window_resize(Window& window, const Gfx::IntPoint& pos Gfx::IntRect outer_rect = window.frame().rect(); if (!outer_rect.contains(position)) { // FIXME: This used to be an ASSERT but crashing WindowServer over this seems silly. - dbg() << "FIXME: !outer_rect.contains(position): outer_rect=" << outer_rect << ", position=" << position; + dbgln("FIXME: !outer_rect.contains(position): outer_rect={}, position={}", outer_rect, position); } int window_relative_x = position.x() - outer_rect.x(); int window_relative_y = position.y() - outer_rect.y(); @@ -471,9 +469,8 @@ void WindowManager::start_window_resize(Window& window, const Gfx::IntPoint& pos return; } -#ifdef RESIZE_DEBUG - dbg() << "[WM] Begin resizing Window{" << &window << "}"; -#endif + dbgln<debug_resize>("[WM] Begin resizing Window({})", &window); + m_resizing_mouse_button = button; m_resize_window = window; m_resize_origin = position; @@ -498,9 +495,8 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event, Window*& hove if (!m_move_window) return false; if (event.type() == Event::MouseUp && event.button() == MouseButton::Left) { -#ifdef MOVE_DEBUG - dbg() << "[WM] Finish moving Window{" << m_move_window << "}"; -#endif + + dbgln<debug_move>("[WM] Finish moving Window({})", m_move_window); m_move_window->invalidate(); if (m_move_window->rect().contains(event.position())) @@ -518,21 +514,17 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event, Window*& hove return true; } if (event.type() == Event::MouseMove) { - -#ifdef MOVE_DEBUG - dbg() << "[WM] Moving, origin: " << m_move_origin << ", now: " << event.position(); - if (m_move_window->is_maximized()) { - dbgln(" [!] The window is still maximized. Not moving yet."); + if constexpr (debug_move) { + dbgln("[WM] Moving, origin: {}, now: {}", m_move_origin, event.position()); + if (m_move_window->is_maximized()) + dbgln(" [!] The window is still maximized. Not moving yet."); } -#endif - const int tiling_deadzone = 10; const int secondary_deadzone = 2; if (m_move_window->is_maximized()) { auto pixels_moved_from_start = event.position().pixels_moved(m_move_origin); - // dbg() << "[WM] " << pixels_moved_from_start << " moved since start of window move"; if (pixels_moved_from_start > 5) { // dbgln("[WM] de-maximizing window"); m_move_origin = event.position(); @@ -585,9 +577,8 @@ bool WindowManager::process_ongoing_window_resize(const MouseEvent& event, Windo return false; if (event.type() == Event::MouseUp && event.button() == m_resizing_mouse_button) { -#ifdef RESIZE_DEBUG - dbg() << "[WM] Finish resizing Window{" << m_resize_window << "}"; -#endif + dbgln<debug_resize>("[WM] Finish resizing Window({})", m_resize_window); + Core::EventLoop::current().post_event(*m_resize_window, make<ResizeEvent>(m_resize_window->rect())); m_resize_window->invalidate(); if (m_resize_window->rect().contains(event.position())) @@ -693,9 +684,9 @@ bool WindowManager::process_ongoing_window_resize(const MouseEvent& event, Windo if (m_resize_window->rect() == new_rect) return true; -#ifdef RESIZE_DEBUG - dbg() << "[WM] Resizing, original: " << m_resize_window_original_rect << ", now: " << new_rect; -#endif + + dbgln<debug_resize>("[WM] Resizing, original: {}, now: {}", m_resize_window_original_rect, new_rect); + m_resize_window->set_rect(new_rect); Core::EventLoop::current().post_event(*m_resize_window, make<ResizeEvent>(new_rect)); return true; @@ -817,9 +808,9 @@ void WindowManager::start_menu_doubleclick(Window& window, const MouseEvent& eve if (&window != m_double_click_info.m_clicked_window) { // we either haven't clicked anywhere, or we haven't clicked on this // window. set the current click window, and reset the timers. -#if defined(DOUBLECLICK_DEBUG) - dbg() << "Initial mousedown on window " << &window << " for menu (previous was " << m_double_click_info.m_clicked_window << ')'; -#endif + + dbgln<debug_double_click>("Initial mousedown on Window({}) for menus (previous was {})", &window, m_double_click_info.m_clicked_window); + m_double_click_info.m_clicked_window = window; m_double_click_info.reset(); } @@ -850,9 +841,8 @@ void WindowManager::process_event_for_doubleclick(Window& window, MouseEvent& ev if (&window != m_double_click_info.m_clicked_window) { // we either haven't clicked anywhere, or we haven't clicked on this // window. set the current click window, and reset the timers. -#if defined(DOUBLECLICK_DEBUG) - dbg() << "Initial mouseup on window " << &window << " (previous was " << m_double_click_info.m_clicked_window << ')'; -#endif + dbgln<debug_double_click>("Initial mouseup on Window({}) for menus (previous was {})", &window, m_double_click_info.m_clicked_window); + m_double_click_info.m_clicked_window = window; m_double_click_info.reset(); } @@ -866,9 +856,8 @@ void WindowManager::process_event_for_doubleclick(Window& window, MouseEvent& ev // clock metadata.clock.start(); } else { -#if defined(DOUBLECLICK_DEBUG) - dbg() << "Transforming MouseUp to MouseDoubleClick (" << metadata.clock.elapsed() << " < " << m_double_click_speed << ")!"; -#endif + dbgln<debug_double_click>("Transforming MouseUp to MouseDoubleClick ({} < {})!", metadata.clock.elapsed(), m_double_click_speed); + event = MouseEvent(Event::MouseDoubleClick, event.position(), event.buttons(), event.button(), event.modifiers(), event.wheel_delta()); // invalidate this now we've delivered a doubleclick, otherwise // tripleclick will deliver two doubleclick events (incorrectly). |