mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 00:55:06 +00:00
SharedBuffer: Split the creation and share steps
This allows us to seal a buffer *before* anyone else has access to it (well, ok, the creating process still does, but you can't win them all). It also means that a SharedBuffer can be shared with multiple clients: all you need is to have access to it to share it on again.
This commit is contained in:
parent
f60d7e5d1f
commit
b907608e46
12 changed files with 58 additions and 22 deletions
|
@ -38,7 +38,7 @@ void GClipboard::set_data(const StringView& data)
|
|||
{
|
||||
WSAPI_ClientMessage request;
|
||||
request.type = WSAPI_ClientMessage::Type::SetClipboardContents;
|
||||
auto shared_buffer = SharedBuffer::create(GWindowServerConnection::the().server_pid(), data.length() + 1);
|
||||
auto shared_buffer = SharedBuffer::create_with_size(data.length() + 1);
|
||||
if (!shared_buffer) {
|
||||
dbgprintf("GClipboard::set_data() failed to create a shared buffer\n");
|
||||
return;
|
||||
|
@ -48,6 +48,7 @@ void GClipboard::set_data(const StringView& data)
|
|||
else
|
||||
((u8*)shared_buffer->data())[0] = '\0';
|
||||
shared_buffer->seal();
|
||||
shared_buffer->share_with(GWindowServerConnection::the().server_pid());
|
||||
request.clipboard.shared_buffer_id = shared_buffer->shared_buffer_id();
|
||||
request.clipboard.contents_size = data.length();
|
||||
auto response = GWindowServerConnection::the().sync_request(request, WSAPI_ServerMessage::Type::DidSetClipboardContents);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue