mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-02 06:04:15 +00:00
LibGUI+WindowServer: Store the source process' PID in the Window classes
The "Window" classes in LibGUI and WindowServer now store the PID of the process that created the window. LibGUI's Window obtains the PID in the constructor via getpid(), and passes it in Window::show() to WindowServer via the create_window() IPC route. WindowServer then saves it in its own Window class. This allows us to find the process that created a window in order to add process-specific actions to the window.
This commit is contained in:
parent
124611b256
commit
4386182be1
|
@ -75,6 +75,7 @@ Window* Window::from_window_id(int window_id)
|
|||
Window::Window(Core::EventReceiver* parent)
|
||||
: GUI::Object(parent)
|
||||
, m_menubar(Menubar::construct())
|
||||
, m_pid(getpid())
|
||||
{
|
||||
if (parent)
|
||||
set_window_mode(WindowMode::Passive);
|
||||
|
@ -154,6 +155,7 @@ void Window::show()
|
|||
|
||||
ConnectionToWindowServer::the().async_create_window(
|
||||
m_window_id,
|
||||
m_pid,
|
||||
m_rect_when_windowless,
|
||||
!m_moved_by_client,
|
||||
m_has_alpha_channel,
|
||||
|
|
|
@ -332,6 +332,8 @@ private:
|
|||
bool m_save_size_and_position_on_close { false };
|
||||
StringView m_save_domain;
|
||||
StringView m_save_group;
|
||||
|
||||
pid_t m_pid;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -611,7 +611,7 @@ Window* ConnectionFromClient::window_from_id(i32 window_id)
|
|||
return it->value.ptr();
|
||||
}
|
||||
|
||||
void ConnectionFromClient::create_window(i32 window_id, Gfx::IntRect const& rect,
|
||||
void ConnectionFromClient::create_window(i32 window_id, i32 process_id, Gfx::IntRect const& rect,
|
||||
bool auto_position, bool has_alpha_channel, bool minimizable, bool closeable, bool resizable,
|
||||
bool fullscreen, bool frameless, bool forced_shadow,
|
||||
float alpha_hit_threshold, Gfx::IntSize base_size, Gfx::IntSize size_increment,
|
||||
|
@ -642,7 +642,7 @@ void ConnectionFromClient::create_window(i32 window_id, Gfx::IntRect const& rect
|
|||
return;
|
||||
}
|
||||
|
||||
auto window = Window::construct(*this, (WindowType)type, (WindowMode)mode, window_id, minimizable, closeable, frameless, resizable, fullscreen, parent_window);
|
||||
auto window = Window::construct(*this, (WindowType)type, (WindowMode)mode, window_id, process_id, minimizable, closeable, frameless, resizable, fullscreen, parent_window);
|
||||
|
||||
if (auto* blocker = window->blocking_modal_window(); blocker && mode == to_underlying(WindowMode::Blocking)) {
|
||||
did_misbehave("CreateWindow with illegal mode: Reciprocally blocked");
|
||||
|
|
|
@ -102,7 +102,7 @@ private:
|
|||
virtual void update_menu_item(i32, i32, i32, DeprecatedString const&, bool, bool, bool, bool, bool, DeprecatedString const&, Gfx::ShareableBitmap const&) override;
|
||||
virtual void remove_menu_item(i32 menu_id, i32 identifier) override;
|
||||
virtual void flash_menubar_menu(i32, i32) override;
|
||||
virtual void create_window(i32, Gfx::IntRect const&, bool, bool, bool,
|
||||
virtual void create_window(i32, i32, Gfx::IntRect const&, bool, bool, bool,
|
||||
bool, bool, bool, bool, bool, float, Gfx::IntSize, Gfx::IntSize, Gfx::IntSize,
|
||||
Optional<Gfx::IntSize> const&, i32, i32, DeprecatedString const&, i32, Gfx::IntRect const&) override;
|
||||
virtual Messages::WindowServer::DestroyWindowResponse destroy_window(i32) override;
|
||||
|
|
|
@ -94,7 +94,7 @@ Window::Window(Core::EventReceiver& parent, WindowType type)
|
|||
frame().window_was_constructed({});
|
||||
}
|
||||
|
||||
Window::Window(ConnectionFromClient& client, WindowType window_type, WindowMode window_mode, int window_id, bool minimizable, bool closeable, bool frameless, bool resizable, bool fullscreen, Window* parent_window)
|
||||
Window::Window(ConnectionFromClient& client, WindowType window_type, WindowMode window_mode, int window_id, int process_id, bool minimizable, bool closeable, bool frameless, bool resizable, bool fullscreen, Window* parent_window)
|
||||
: Core::EventReceiver(&client)
|
||||
, m_client(&client)
|
||||
, m_type(window_type)
|
||||
|
@ -108,6 +108,7 @@ Window::Window(ConnectionFromClient& client, WindowType window_type, WindowMode
|
|||
, m_client_id(client.client_id())
|
||||
, m_icon(default_window_icon())
|
||||
, m_frame(*this)
|
||||
, m_process_id(process_id)
|
||||
{
|
||||
if (parent_window)
|
||||
set_parent_window(*parent_window);
|
||||
|
|
|
@ -374,7 +374,7 @@ public:
|
|||
void send_move_event_to_client();
|
||||
|
||||
private:
|
||||
Window(ConnectionFromClient&, WindowType, WindowMode, int window_id, bool minimizable, bool closeable, bool frameless, bool resizable, bool fullscreen, Window* parent_window = nullptr);
|
||||
Window(ConnectionFromClient&, WindowType, WindowMode, int window_id, int process_id, bool minimizable, bool closeable, bool frameless, bool resizable, bool fullscreen, Window* parent_window = nullptr);
|
||||
Window(Core::EventReceiver&, WindowType);
|
||||
|
||||
virtual void event(Core::Event&) override;
|
||||
|
@ -460,6 +460,8 @@ private:
|
|||
WindowStack* m_window_stack { nullptr };
|
||||
RefPtr<Animation> m_animation;
|
||||
|
||||
Optional<pid_t> m_process_id {};
|
||||
|
||||
public:
|
||||
using List = IntrusiveList<&Window::m_list_node>;
|
||||
};
|
||||
|
|
|
@ -44,6 +44,7 @@ endpoint WindowServer
|
|||
|
||||
create_window(
|
||||
i32 window_id,
|
||||
i32 process_id,
|
||||
Gfx::IntRect rect,
|
||||
bool auto_position,
|
||||
bool has_alpha_channel,
|
||||
|
|
Loading…
Reference in a new issue