mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:18:11 +00:00
LibGUI: Implement nested event loops to support dialog boxes.
This patch adds a simple GMessageBox that can run in a nested event loop. Here's how you use it: GMessageBox box("Message text here", "Message window title"); int result = box.exec(); The next step is to make the WindowServer respect the modality flag of these windows and prevent interaction with other windows in the same process until the modal window has been closed.
This commit is contained in:
parent
55aa819077
commit
57ff293a51
29 changed files with 275 additions and 79 deletions
|
@ -19,7 +19,7 @@ String GClipboard::data() const
|
|||
{
|
||||
WSAPI_ClientMessage request;
|
||||
request.type = WSAPI_ClientMessage::Type::GetClipboardContents;
|
||||
auto response = GEventLoop::main().sync_request(request, WSAPI_ServerMessage::Type::DidGetClipboardContents);
|
||||
auto response = GEventLoop::current().sync_request(request, WSAPI_ServerMessage::Type::DidGetClipboardContents);
|
||||
if (response.clipboard.shared_buffer_id < 0)
|
||||
return { };
|
||||
auto shared_buffer = SharedBuffer::create_from_shared_buffer_id(response.clipboard.shared_buffer_id);
|
||||
|
@ -38,7 +38,7 @@ void GClipboard::set_data(const String& data)
|
|||
{
|
||||
WSAPI_ClientMessage request;
|
||||
request.type = WSAPI_ClientMessage::Type::SetClipboardContents;
|
||||
auto shared_buffer = SharedBuffer::create(GEventLoop::main().server_pid(), data.length() + 1);
|
||||
auto shared_buffer = SharedBuffer::create(GEventLoop::current().server_pid(), data.length() + 1);
|
||||
if (!shared_buffer) {
|
||||
dbgprintf("GClipboard::set_data() failed to create a shared buffer\n");
|
||||
return;
|
||||
|
@ -50,6 +50,6 @@ void GClipboard::set_data(const String& data)
|
|||
shared_buffer->seal();
|
||||
request.clipboard.shared_buffer_id = shared_buffer->shared_buffer_id();
|
||||
request.clipboard.contents_size = data.length();
|
||||
auto response = GEventLoop::main().sync_request(request, WSAPI_ServerMessage::Type::DidSetClipboardContents);
|
||||
auto response = GEventLoop::current().sync_request(request, WSAPI_ServerMessage::Type::DidSetClipboardContents);
|
||||
ASSERT(response.clipboard.shared_buffer_id == shared_buffer->shared_buffer_id());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue