mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:37:34 +00:00
LibGUI+WindowServer: Replace WindowInput{Enter,Leave} Events
with WindowInput{Preempted,Restored} Events and allow Widgets to save the state of their focus preemption. As of now, only Popups will preempt input and trigger these events.
This commit is contained in:
parent
901878bad9
commit
5d567565a4
11 changed files with 50 additions and 45 deletions
|
@ -31,8 +31,8 @@ public:
|
|||
KeyUp,
|
||||
WindowActivated,
|
||||
WindowDeactivated,
|
||||
WindowInputEntered,
|
||||
WindowInputLeft,
|
||||
WindowInputPreempted,
|
||||
WindowInputRestored,
|
||||
WindowCloseRequest,
|
||||
WindowResized,
|
||||
WindowMoved,
|
||||
|
|
|
@ -452,7 +452,7 @@ void Window::event(Core::Event& event)
|
|||
|
||||
if (blocking_modal_window()) {
|
||||
// Allow windows to process their inactivity after being blocked
|
||||
if (event.type() != Event::WindowDeactivated && event.type() != Event::WindowInputLeft)
|
||||
if (event.type() != Event::WindowDeactivated && event.type() != Event::WindowInputPreempted)
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -482,11 +482,11 @@ void Window::event(Core::Event& event)
|
|||
case Event::WindowDeactivated:
|
||||
m_client->async_window_deactivated(m_window_id);
|
||||
break;
|
||||
case Event::WindowInputEntered:
|
||||
m_client->async_window_input_entered(m_window_id);
|
||||
case Event::WindowInputPreempted:
|
||||
m_client->async_window_input_preempted(m_window_id);
|
||||
break;
|
||||
case Event::WindowInputLeft:
|
||||
m_client->async_window_input_left(m_window_id);
|
||||
case Event::WindowInputRestored:
|
||||
m_client->async_window_input_restored(m_window_id);
|
||||
break;
|
||||
case Event::WindowCloseRequest:
|
||||
m_client->async_window_close_request(m_window_id);
|
||||
|
|
|
@ -13,8 +13,8 @@ endpoint WindowClient
|
|||
mouse_wheel(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y, i32 wheel_raw_delta_x, i32 wheel_raw_delta_y) =|
|
||||
window_entered(i32 window_id) =|
|
||||
window_left(i32 window_id) =|
|
||||
window_input_entered(i32 window_id) =|
|
||||
window_input_left(i32 window_id) =|
|
||||
window_input_preempted(i32 window_id) =|
|
||||
window_input_restored(i32 window_id) =|
|
||||
key_down(i32 window_id, u32 code_point, u32 key, u32 modifiers, u32 scancode) =|
|
||||
key_up(i32 window_id, u32 code_point, u32 key, u32 modifiers, u32 scancode) =|
|
||||
window_activated(i32 window_id) =|
|
||||
|
|
|
@ -1828,20 +1828,6 @@ Window* WindowManager::set_active_input_window(Window* window)
|
|||
return previous_input_window;
|
||||
}
|
||||
|
||||
void WindowManager::notify_new_active_input_window(Window& new_input_window)
|
||||
{
|
||||
Core::EventLoop::current().post_event(new_input_window, make<Event>(Event::WindowInputEntered));
|
||||
if (new_input_window.is_capturing_input() && !new_input_window.is_frameless())
|
||||
new_input_window.invalidate(true, true);
|
||||
}
|
||||
|
||||
void WindowManager::notify_previous_active_input_window(Window& previous_input_window)
|
||||
{
|
||||
Core::EventLoop::current().post_event(previous_input_window, make<Event>(Event::WindowInputLeft));
|
||||
if (previous_input_window.is_capturing_input() && !previous_input_window.is_frameless())
|
||||
previous_input_window.invalidate(true, true);
|
||||
}
|
||||
|
||||
void WindowManager::set_active_window(Window* new_active_window, bool make_input)
|
||||
{
|
||||
if (new_active_window) {
|
||||
|
@ -1905,6 +1891,18 @@ void WindowManager::notify_previous_active_window(Window& previously_active_wind
|
|||
tell_wms_window_state_changed(previously_active_window);
|
||||
}
|
||||
|
||||
void WindowManager::notify_active_window_input_preempted()
|
||||
{
|
||||
if (active_window())
|
||||
Core::EventLoop::current().post_event(*active_window(), make<Event>(Event::WindowInputPreempted));
|
||||
}
|
||||
|
||||
void WindowManager::notify_active_window_input_restored()
|
||||
{
|
||||
if (active_window())
|
||||
Core::EventLoop::current().post_event(*active_window(), make<Event>(Event::WindowInputRestored));
|
||||
}
|
||||
|
||||
bool WindowManager::set_hovered_window(Window* window)
|
||||
{
|
||||
if (m_hovered_window == window)
|
||||
|
|
|
@ -341,9 +341,9 @@ private:
|
|||
explicit WindowManager(Gfx::PaletteImpl const&);
|
||||
|
||||
void notify_new_active_window(Window&);
|
||||
void notify_new_active_input_window(Window&);
|
||||
void notify_previous_active_window(Window&);
|
||||
void notify_previous_active_input_window(Window&);
|
||||
void notify_active_window_input_preempted();
|
||||
void notify_active_window_input_restored();
|
||||
|
||||
void process_mouse_event(MouseEvent&);
|
||||
void process_event_for_doubleclick(Window& window, MouseEvent& event);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue