Commit Graph

53046 Commits

Author SHA1 Message Date
Matthias Clasen
8b1b9f8c55 Drop api that is only for unmanaged dnd
These functions are not needed as public api anymore.
2017-12-03 06:24:24 +01:00
Matthias Clasen
e74c46fc4e dnd: Handle rootwin drop in gdk
This lets us drop the only use of the drag protocol in gtk.
2017-12-03 06:22:25 +01:00
Matthias Clasen
6cfb55a396 dnd: Remove much of the unmanaged dnd 2017-12-03 06:17:42 +01:00
Benjamin Otte
ff577e6c2c wayland: Add primary clipboard subclass
I decided to put this in a custom subclass, because then I could keep
the whole gtk primary protocol self-contained.

The other option would have been reusing GdkWaylandClipboard, but that
didn't seem worth it, especially because that code needs to interact
with the DND machinery, while the primary doesn't.
2017-12-03 05:46:49 +01:00
Benjamin Otte
ef69daacdf wayland: Implement taking over the clipboard
The clipboard is now complete.
That was fast.
2017-12-03 05:46:49 +01:00
Benjamin Otte
82002eabfe wayland: Implement reading the clipboard
We now keep track of what's in the clipboard and allow people to read
its contents.
2017-12-03 05:46:49 +01:00
Benjamin Otte
00192266a1 wayland: Add skeleton for a GdkClipboardWayland
Creates the source file and a custom subclass and makes sure it's used
by GDK.
2017-12-03 05:46:49 +01:00
Benjamin Otte
437d70f569 gdk: Get rid of owner change events
They're unused now.
2017-12-03 05:46:49 +01:00
Benjamin Otte
2d5c82b4ec gtk: Remove GtkClipboard 2017-12-03 05:46:49 +01:00
Benjamin Otte
c8edc6ed58 icon-browser: Port to new clipboard 2017-12-03 05:46:49 +01:00
Benjamin Otte
c833b47b21 gtk-demo: Port to GdkClipboard 2017-12-03 05:46:49 +01:00
Benjamin Otte
18bf0eb61a clipboard: Change image convenience APIs
Don't use pixbufs anymore, use textures.
2017-12-03 05:46:49 +01:00
Benjamin Otte
a34836f35b gdk: Add (de)serializers for GDK_TYPE_TEXTURE
We want to use textures more, so we should be able to use them for
copy/paste and dnd.
2017-12-03 05:46:49 +01:00
Benjamin Otte
ead67a7c17 x11: Handle case where clipboard was reclaimed quickly
When the reply to a TARGETS request comes in, the clipboard may already
be reclaimed by the local app. Deal with that case (in an ugly way,
strictly speaking we should use a cancellable here).

This happens for example at startup when the initial TARGETS requests
have not been answered until after the main widow popped up. And if such
a window immediately claims the primary clipboard (like when the initial
focus is inside an entry), this race will happen.
2017-12-03 05:46:49 +01:00
Benjamin Otte
24c934f8c0 entry: Port to GdkClipboard 2017-12-03 05:46:49 +01:00
Benjamin Otte
5abd7a39a2 x11: Implement storing the clipboard 2017-12-03 05:46:49 +01:00
Benjamin Otte
b75546d0fb x11: Implement MULTIPLE requests 2017-12-03 05:46:48 +01:00
Benjamin Otte
3ea258de26 tests: Don't crash if widgets go away before clipboard
Don't g_signal_connect() to the clipboard without protection - the
clipboard might outlast you and still emit signals.
2017-12-03 05:46:48 +01:00
Benjamin Otte
ea18793965 x11: Introduce GdkX11PendingSelectionNotify
This object tracks the SelectionNotifyEvent that has to be sent in
response to a SelectionRequest.

Currently it just looks like code reshuffling, but it's a prerequisite
for handling MULTIPLE, which requires to only send the notify after
every stream has writtten at least once.

But anyway, code is cleaner now, so it's a win!
2017-12-03 05:46:48 +01:00
Benjamin Otte
bcc0d4b5f0 x11: Split out a function
This will be necessary for MULTIPLE handling.
2017-12-03 05:46:48 +01:00
Benjamin Otte
0ff3340da7 main: Implement storing all clipboards 2017-12-03 05:46:48 +01:00
Benjamin Otte
4cce109e16 application: Put shared code into a common function 2017-12-03 05:46:48 +01:00
Benjamin Otte
fe7c283aea clipboard: Add infrastructure to store clipboards
Clipboard managers will be so happy once the backends actually implement
it!
2017-12-03 05:46:48 +01:00
Benjamin Otte
51e46cc898 contentprovider: Add ref_storable_formats()
This is to be used for advocating to clipboard managers.
2017-12-03 05:46:48 +01:00
Benjamin Otte
ca96fac488 filechooserwidget: Port to new clipboard
We use the new GDK_TYPE_FILE_LIST here.
2017-12-03 05:46:48 +01:00
Benjamin Otte
6b326b14c0 gdk: Add GDK_TYPE_FILE_LIST with serializers
This is a GSList of GFile and we want it so we can operate with lists of
files and text/uri-list.

I chose GSList over GList because that's what the GtkFileChooser API
uses, too.
2017-12-03 05:46:48 +01:00
Benjamin Otte
928c98a84e gdk: Add serializers and deserializers for GFile
in particular, support:
GFile <=> text/uri-list
GFile  => text/plain
2017-12-03 05:46:48 +01:00
Benjamin Otte
39d4622563 tests: Improve formats list for testclipboard2 2017-12-03 05:46:48 +01:00
Benjamin Otte
5632d0eabb label: Port to new clipboard 2017-12-03 05:46:48 +01:00
Benjamin Otte
f53848c360 textview: Redo clipboard handling
Instead of using GtkClipboard and handling everything ourselves, we now
put GtkTextBuffer into the GdkClipboard and register (de)serializers for
text/plain.
2017-12-03 05:46:48 +01:00
Benjamin Otte
4e06aaeaa8 gdk: Add gdk_content_formats_new_for_gtype()
Many places create formats for a single tpye, so make it easy for them
to get this without having to create a builder first.
2017-12-03 05:46:48 +01:00
Benjamin Otte
cc07800570 gdk: Allow setting task data on (de)serializers
This mirrors GTask.
2017-12-03 05:46:48 +01:00
Benjamin Otte
c146132a4a gtk-demo: Port clipboards example to new clipboard 2017-12-03 05:46:48 +01:00
Benjamin Otte
8cd5e0af1a recentchooser: Port to GdkClipboard 2017-12-03 05:46:48 +01:00
Benjamin Otte
909b6877bd linkbutton: Port to GdkClipboard 2017-12-03 05:46:48 +01:00
Benjamin Otte
825612b419 a11y: Port to GdkClipboard 2017-12-03 05:46:47 +01:00
Benjamin Otte
54c8a4b3b7 widget: Add gtk_widget_get_clipboard()
... and gtk_widget_get_primary_clipboard().

They both give out the new GdkClipboard.
2017-12-03 05:46:47 +01:00
Benjamin Otte
a59572f96d widget: gtk_widget_get_clipboard => gtk_widget_get_old_clipboard
Just rename the function, so the previous one can be used for the
new clipboard.
2017-12-03 05:46:47 +01:00
Benjamin Otte
6fffa5b171 tests: Open a 2nd display in testclipboard2
This allows testing local transfer of data as well as remote transfer
(by transferring data between clipboards of both Displays).
2017-12-03 05:46:47 +01:00
Benjamin Otte
134076e738 x11: Implement claiming the X Selection with the clipboard
... and of course support writing to other apps.
2017-12-03 05:46:47 +01:00
Benjamin Otte
e2014850b9 tests: Add possibility to set invalid UTF-8 and clear clipboard 2017-12-03 05:46:47 +01:00
Benjamin Otte
c66a61d896 x11: Add gdk_x11_display_get_max_request_size()
There's multiple places in the clipboard code where I need it, so make
it a custom function.
2017-12-03 05:46:47 +01:00
Benjamin Otte
8e132ef0c4 clipboard: Allow claiming the clipboard to fail
Also make clipboard_claim() a vfunc so backends can override it.

Because the whole operation a vfunc, backends have the option of adding
code before the actual claim is done and potentially even fail or do
something after the successful claim.
2017-12-03 05:46:47 +01:00
Benjamin Otte
7426f1a16b gdkcontentformats: Change the matching API
Instead of having just one function that has the gtype and mime type as
out arguments, have 3 functions: 1 that finds any match, 1 that finds a
GType match and one for a mime type match.

This makes the API way more convenient to use.
2017-12-03 05:46:47 +01:00
Benjamin Otte
25c3895836 clipboard: Add serialization
This completes the local clipboard code.
2017-12-03 05:46:47 +01:00
Benjamin Otte
12ca641ff5 clipboard: Implement local fallback clipboard transfers
This requires implementing a "pipe" so we can have 2 streams running:
  contentprovider => serializer => outputstream
  inputstream => deserializer => reader
And the pipe shoves the data from the outputstream into the inputstream.
2017-12-03 05:46:47 +01:00
Benjamin Otte
888e5257e0 clipboard: Introduce GdkContentProvider
GdkContentProvider is the object that represents local data in the
clipboard.

This patch only introduces the object and adds the clipboard properties,
it does not yet provide a way for the actual implementations to access
it.

The only access that is implemented is the local shortcut GValue access.
2017-12-03 05:46:47 +01:00
Benjamin Otte
3023d254dd clipboard: Make value getters set the passed in value
Don't return a const GValue, that's ugly API. Instead require people to
pass in a preinitialized GValue and set that one.
2017-12-03 05:46:47 +01:00
Benjamin Otte
9b78d76873 x11: Improve fallbacks for text
(1) Try all passed in formats in order if one of them fails.
(2) Don't blindly accept all formats, make sure they are mime types
(3) Add a bunch of special non-mime types that plug converters to
    get to mime types
2017-12-03 05:46:46 +01:00
Benjamin Otte
88684baecf clipboard: Add gdk_clipboard_read_text_async()
Also add deserializers for G_TYPE_STRING.
2017-12-03 05:46:28 +01:00