Commit Graph

25 Commits

Author SHA1 Message Date
Matthias Clasen
8e4e4401c5 gdk: Change some async clipboard api
The pattern we generally follow is to put the
async result right after the source object, in
finish functions. Do this for gdk_clipboard_read_finish.
2019-04-02 15:10:53 +00:00
Benjamin Otte
359bc7695c build: Reintroduce warning flags from autotools
Some of the flags got lost in the meson transition or were demoted from
error flags to warning flags.
This commit reintroduces them.

It also includes fixes for the code that had warnings with those flags.
The big one being -Wshadow.
2019-01-22 04:33:12 +01:00
Jason Crain
77c3ef48cf x11: Ignore old XFixesSelectionNotify events
GtkEntryCompletion can rapidly release and claim ownership of the
primary selection. This generates multiple XFixesSelectionNotify events,
first stating that no one owns the selection, then another stating that
we own the selection. The notification that no one owns the selection
causes GtkEntryCompletion to deselect the text, breaking inline
autocompletion.

This fixes it by ignoring any XFixesSelectionNotify with a timestamp
earlier than our clipboard timestamp.

Fixes #14
2018-07-21 15:22:04 -05:00
Matthias Clasen
89f6b8751e Remove gdk_window_add_filter
Drop the public filtering API. The x11 backend already has
the ::xevent signal as replacement. The win32 backend needs
a similar signal to replace filtering.

Reshuffle header inclusions in the x11 backend a little bit
to avoid a cyclic inclusion between gdkprivate-x11.h and
gdkdisplay-x11.h that is otherwise causing problems.
2018-02-07 15:12:03 -05:00
Emmanuele Bassi
2cbe094b91 Allow binding GdkContentFormatsBuilder
GdkContentFormatsBuilder is currently not introspectable, as it does not
have a GType. We can turn it into a boxed type, but we need to implement
memory management for it.

The current gdk_content_formats_builder_free() function returns a newly
constructed value, so we cannot use it as a GBoxedFreeFunc; additionally
copying a GdkContentFormatsBuilder contents would make it a bit odd, as
you could get multiple identical GdkContentFormats out of the copies.

A simple approach is to model the GdkContentFormatsBuilder API to follow
the GBytes one: use reference counting for memory management, and have
a function to release a reference, return a GdkContentFormats, and reset
the GdkContentFormatsBuilder state.

For language bindings, we can provide a get_formats() function that
returns the GdkContentFormats instance and resets the builder instance,
leaving the reference count untouched.

For C convenience we can keep gdk_content_formats_builder_free(), and
make it a wrapper around gdk_content_formats_builder_get_formats(), with
the guarantee that it'll free the builder instance regardless of its
current reference count.

https://bugzilla.gnome.org/show_bug.cgi?id=793097
https://blogs.gnome.org/otte/2018/02/03/builders/
2018-02-03 16:24:13 +01:00
Matthias Clasen
e151058dff Make gdk logging per-display
As far as possible, use per-display debug flags.

This will minimize the debug spew that we get from
the inspector if it is running on a separate display.
2018-01-14 17:05:04 -05:00
Benjamin Otte
65fcff87b2 gdk: Remove ability to request selection notifications
Without selections, that's kinda pointless.
2017-12-14 04:20:48 +01:00
Benjamin Otte
fb0fdddd76 x11: Refactor xevent filtering some more
We now have a GdkX11Display::xevent signal that gets emitted for every
XEvent and allows you to interrupt processing via TRUE/FALSE return
values.
These return values to correspond to GDK_FILTER_REMOVE and
GDK_FILTER_CONTINUE respectively.

The GDK_FILTER_TRANSLATE case from gdk_window_add_filter() is now meant
to be handled via gdk_display_put_event().
2017-12-13 01:55:56 +01:00
Benjamin Otte
2d86c1a869 x11: Make clipboard use translate-event signal 2017-12-13 00:56:52 +01:00
Benjamin Otte
5df527edaf x11: Refactor code
This is in preparation for DND.

It moves a lot of code from gdkclipboard-x11.c to
gdkselectionoutputstream-x11.c to untangle it from GdkX11Clipboard
usage.
2017-12-13 00:56:52 +01:00
Benjamin Otte
803cbd576f dnd: Introduce gdk_drop_read_async() and use it
This is the replacement for selection usage.

Backend implementations for X11 (missing support for backwards compat
formats like COMPOUND_TEXT) and Wayland are included.

GTK code should be adapted to use gdk_drop_read_*() functions instead
of gtk_drag_get_data().
2017-12-10 01:09:14 +01:00
Benjamin Otte
963264a73a gdk: Fix wrong usage of g_task_propagate_pointer()
The return value is transfer full, not transfer none.
2017-12-10 01:09:14 +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
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
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
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
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
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
41f70e18af clipboard: Refactor gdk_clipboard_read() to be async
This allows us not just to pass any mime type to the read function, but
it also makes it possible to pass multiple mime types and the clipboard
can then try them in order until it finds a supported one.

This is so far not implemented though.
2017-12-03 05:46:26 +01:00
Benjamin Otte
c91a38b013 clipboard: Implement gdk_clipboard_read() 2017-12-03 05:43:24 +01:00
Benjamin Otte
fe9045d82e x11: Various clipboard cleanups
(1) Turn X11 clipboard event handling into a regular filter function
(2) Maintain a timestamp in the clipboard, so we can pass it when
    querying selections.
2017-12-03 05:43:24 +01:00
Benjamin Otte
a5ab9a9671 clipboard: Add gdk_clipboard_claim_remote()
This allows the remote clipboard to take over. The X11 clipboard already
does that.
2017-12-03 05:43:24 +01:00
Benjamin Otte
4728dd0a9e x11: Add an initial clipboard implementation
This does nothing but download the targets and debug-print them.
2017-12-03 05:43:24 +01:00