mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:37:45 +00:00
WindowServer: Default to Desktop when picking a new active window
This commit is contained in:
parent
af706d081c
commit
d54dc22362
2 changed files with 13 additions and 23 deletions
|
@ -622,30 +622,25 @@ void WindowManager::notify_progress_changed(Window& window)
|
||||||
tell_wms_window_state_changed(window);
|
tell_wms_window_state_changed(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowManager::pick_new_active_window(Window* previous_active)
|
void WindowManager::pick_new_active_window(Window* previous_active)
|
||||||
{
|
{
|
||||||
bool new_window_picked = false;
|
Window* desktop = nullptr;
|
||||||
Window* first_candidate = nullptr;
|
auto result = for_each_visible_window_from_front_to_back([&](Window& candidate) {
|
||||||
|
if (candidate.type() == WindowType::Desktop)
|
||||||
for_each_visible_window_from_front_to_back([&](Window& candidate) {
|
desktop = &candidate;
|
||||||
if (candidate.type() != WindowType::Normal)
|
if (candidate.type() != WindowType::Normal)
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
if (candidate.is_destroyed())
|
if (candidate.is_destroyed())
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
if (previous_active != first_candidate)
|
|
||||||
first_candidate = &candidate;
|
|
||||||
if ((!previous_active && !candidate.is_capturing_input()) || (previous_active && !candidate.is_capturing_active_input_from(*previous_active))) {
|
if ((!previous_active && !candidate.is_capturing_input()) || (previous_active && !candidate.is_capturing_active_input_from(*previous_active))) {
|
||||||
set_active_window(&candidate);
|
set_active_window(&candidate);
|
||||||
new_window_picked = true;
|
|
||||||
return IterationDecision::Break;
|
return IterationDecision::Break;
|
||||||
}
|
}
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
if (!new_window_picked) {
|
|
||||||
set_active_window(first_candidate);
|
if (result != IterationDecision::Break)
|
||||||
new_window_picked = first_candidate != nullptr;
|
set_active_window(desktop);
|
||||||
}
|
|
||||||
return new_window_picked;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::check_hide_geometry_overlay(Window& window)
|
void WindowManager::check_hide_geometry_overlay(Window& window)
|
||||||
|
@ -1322,15 +1317,8 @@ void WindowManager::process_mouse_event(MouseEvent& event)
|
||||||
// 8. Hit test the window stack to see what's under the cursor.
|
// 8. Hit test the window stack to see what's under the cursor.
|
||||||
auto result = current_window_stack().hit_test(event.position());
|
auto result = current_window_stack().hit_test(event.position());
|
||||||
|
|
||||||
if (!result.has_value()) {
|
if (!result.has_value())
|
||||||
// No window is under the cursor.
|
|
||||||
if (event.type() == Event::MouseDown) {
|
|
||||||
// Clicked outside of any window -> no active window.
|
|
||||||
// FIXME: Is this actually necessary? The desktop window should catch everything anyway.
|
|
||||||
set_active_window(nullptr);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
process_mouse_event_for_window(result.value(), event);
|
process_mouse_event_for_window(result.value(), event);
|
||||||
}
|
}
|
||||||
|
@ -1780,8 +1768,10 @@ void WindowManager::restore_active_input_window(Window* window)
|
||||||
if (!window)
|
if (!window)
|
||||||
window = active_window();
|
window = active_window();
|
||||||
// If the current active window is also gone, pick some other window
|
// If the current active window is also gone, pick some other window
|
||||||
if (!window && pick_new_active_window(nullptr))
|
if (!window) {
|
||||||
|
pick_new_active_window(nullptr);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (window && !window->is_minimized() && window->is_visible())
|
if (window && !window->is_minimized() && window->is_visible())
|
||||||
set_active_input_window(window);
|
set_active_input_window(window);
|
||||||
|
|
|
@ -371,7 +371,7 @@ private:
|
||||||
void tell_wm_about_window_icon(WMConnectionFromClient& conn, Window&);
|
void tell_wm_about_window_icon(WMConnectionFromClient& conn, Window&);
|
||||||
void tell_wm_about_window_rect(WMConnectionFromClient& conn, Window&);
|
void tell_wm_about_window_rect(WMConnectionFromClient& conn, Window&);
|
||||||
void tell_wm_about_current_window_stack(WMConnectionFromClient&);
|
void tell_wm_about_current_window_stack(WMConnectionFromClient&);
|
||||||
bool pick_new_active_window(Window*);
|
void pick_new_active_window(Window*);
|
||||||
|
|
||||||
bool sync_config_to_disk();
|
bool sync_config_to_disk();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue