1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:07:34 +00:00

Everywhere: Turn #if *_DEBUG into dbgln_if/if constexpr

This commit is contained in:
Gunnar Beutner 2021-05-01 21:10:08 +02:00 committed by Andreas Kling
parent 4e6f03a860
commit 6cf59b6ae9
58 changed files with 315 additions and 469 deletions

View file

@ -113,9 +113,7 @@ void LookupServer::load_etc_hosts()
Vector<DNSAnswer> LookupServer::lookup(const DNSName& name, unsigned short record_type)
{
#if LOOKUPSERVER_DEBUG
dbgln("Got request for '{}'", name.as_string());
#endif
dbgln_if(LOOKUPSERVER_DEBUG, "Got request for '{}'", name.as_string());
Vector<DNSAnswer> answers;
auto add_answer = [&](const DNSAnswer& answer) {
@ -144,9 +142,7 @@ Vector<DNSAnswer> LookupServer::lookup(const DNSName& name, unsigned short recor
for (auto& answer : cached_answers.value()) {
// TODO: Actually remove expired answers from the cache.
if (answer.type() == record_type && !answer.has_expired()) {
#if LOOKUPSERVER_DEBUG
dbgln("Cache hit: {} -> {}", name.as_string(), answer.record_data());
#endif
dbgln_if(LOOKUPSERVER_DEBUG, "Cache hit: {} -> {}", name.as_string(), answer.record_data());
add_answer(answer);
}
}
@ -156,9 +152,7 @@ Vector<DNSAnswer> LookupServer::lookup(const DNSName& name, unsigned short recor
// Third, ask the upstream nameservers.
for (auto& nameserver : m_nameservers) {
#if LOOKUPSERVER_DEBUG
dbgln("Doing lookup using nameserver '{}'", nameserver);
#endif
dbgln_if(LOOKUPSERVER_DEBUG, "Doing lookup using nameserver '{}'", nameserver);
bool did_get_response = false;
int retries = 3;
Vector<DNSAnswer> upstream_answers;

View file

@ -240,12 +240,12 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
WindowIdentifier identifier { event.client_id(), event.window_id() };
switch (event.type()) {
case GUI::Event::WM_WindowRemoved: {
#if EVENT_DEBUG
auto& removed_event = static_cast<GUI::WMWindowRemovedEvent&>(event);
dbgln("WM_WindowRemoved: client_id={}, window_id={}",
removed_event.client_id(),
removed_event.window_id());
#endif
if constexpr (EVENT_DEBUG) {
auto& removed_event = static_cast<GUI::WMWindowRemovedEvent&>(event);
dbgln("WM_WindowRemoved: client_id={}, window_id={}",
removed_event.client_id(),
removed_event.window_id());
}
if (auto* window = WindowList::the().window(identifier))
remove_window_button(*window, true);
WindowList::the().remove_window(identifier);
@ -253,13 +253,13 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
break;
}
case GUI::Event::WM_WindowRectChanged: {
#if EVENT_DEBUG
auto& changed_event = static_cast<GUI::WMWindowRectChangedEvent&>(event);
dbgln("WM_WindowRectChanged: client_id={}, window_id={}, rect={}",
changed_event.client_id(),
changed_event.window_id(),
changed_event.rect());
#endif
if constexpr (EVENT_DEBUG) {
auto& changed_event = static_cast<GUI::WMWindowRectChangedEvent&>(event);
dbgln("WM_WindowRectChanged: client_id={}, window_id={}, rect={}",
changed_event.client_id(),
changed_event.window_id(),
changed_event.rect());
}
break;
}
@ -274,15 +274,15 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
case GUI::Event::WM_WindowStateChanged: {
auto& changed_event = static_cast<GUI::WMWindowStateChangedEvent&>(event);
#if EVENT_DEBUG
dbgln("WM_WindowStateChanged: client_id={}, window_id={}, title={}, rect={}, is_active={}, is_minimized={}",
changed_event.client_id(),
changed_event.window_id(),
changed_event.title(),
changed_event.rect(),
changed_event.is_active(),
changed_event.is_minimized());
#endif
if constexpr (EVENT_DEBUG) {
dbgln("WM_WindowStateChanged: client_id={}, window_id={}, title={}, rect={}, is_active={}, is_minimized={}",
changed_event.client_id(),
changed_event.window_id(),
changed_event.title(),
changed_event.rect(),
changed_event.is_active(),
changed_event.is_minimized());
}
if (changed_event.window_type() != GUI::WindowType::Normal || changed_event.is_frameless()) {
if (auto* window = WindowList::the().window(identifier))
remove_window_button(*window, false);

View file

@ -865,9 +865,7 @@ void Compositor::recompute_occlusions()
return IterationDecision::Continue;
});
#if OCCLUSIONS_DEBUG
dbgln("OCCLUSIONS:");
#endif
dbgln_if(OCCLUSIONS_DEBUG, "OCCLUSIONS:");
auto screen_rect = Screen::the().rect();

View file

@ -97,9 +97,7 @@ void EventLoop::drain_mouse()
return;
for (size_t i = 0; i < npackets; ++i) {
auto& packet = packets[i];
#if WSMESSAGELOOP_DEBUG
dbgln("EventLoop: Mouse X {}, Y {}, Z {}, relative={}", packet.x, packet.y, packet.z, packet.is_relative);
#endif
dbgln_if(WSMESSAGELOOP_DEBUG, "EventLoop: Mouse X {}, Y {}, Z {}, relative={}", packet.x, packet.y, packet.z, packet.is_relative);
buttons = packet.buttons;
state.is_relative = packet.is_relative;
@ -115,9 +113,7 @@ void EventLoop::drain_mouse()
if (buttons != state.buttons) {
state.buttons = buttons;
#if WSMESSAGELOOP_DEBUG
dbgln("EventLoop: Mouse Button Event");
#endif
dbgln_if(WSMESSAGELOOP_DEBUG, "EventLoop: Mouse Button Event");
screen.on_receive_mouse_data(state);
if (state.is_relative) {
state.x = 0;

View file

@ -124,14 +124,10 @@ void Screen::on_receive_mouse_data(const MousePacket& packet)
auto prev_location = m_physical_cursor_location / m_scale_factor;
if (packet.is_relative) {
m_physical_cursor_location.move_by(packet.x * m_acceleration_factor, packet.y * m_acceleration_factor);
#if WSSCREEN_DEBUG
dbgln("Screen: New Relative mouse point @ {}", m_physical_cursor_location);
#endif
dbgln_if(WSSCREEN_DEBUG, "Screen: New Relative mouse point @ {}", m_physical_cursor_location);
} else {
m_physical_cursor_location = { packet.x * physical_width() / 0xffff, packet.y * physical_height() / 0xffff };
#if WSSCREEN_DEBUG
dbgln("Screen: New Absolute mouse point @ {}", m_physical_cursor_location);
#endif
dbgln_if(WSSCREEN_DEBUG, "Screen: New Absolute mouse point @ {}", m_physical_cursor_location);
}
m_physical_cursor_location.constrain(physical_rect());