Commit Graph

8608 Commits

Author SHA1 Message Date
Ernestas Kulik
6adaf7c33d Remove GDestroyNotify casts in g_clear_pointer() uses
GLib master propagates argument types in g_clear_pointer(), which causes
the usual function pointer casts to GDestroyNotify to trip compiler
warnings. Additionally, this commit changes some cleanup functions where
appropriate (wl_data_source_destroy ->
gtk_primary_selection_source_destroy for struct
gtk_primary_selection_source).
2018-07-25 10:05:39 +03:00
Benjamin Otte
259be23ff2 broadway: Remove unused variable 2018-07-24 20:55:45 +02:00
Nirbheek Chauhan
5df4d27752 meson: libgdk-broadway.a depends on broadwayjs.h
Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1218

Also fix another dependency error I found.
2018-07-23 20:15:44 +05:30
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
bef8a3a0e9 Merge branch 'content-provider-autoptr' into 'master'
gdk: Add auto cleanup func for GdkContentProvider

See merge request GNOME/gtk!251
2018-07-19 18:04:24 +00:00
Ernestas Kulik
96d0368290 gdk: contentdeserializer: Fix deserializer not returning
file_uri_deserializer does not return on success, only on failure. This
commit fixes clipboard reads never finishing for some types.
2018-07-19 15:55:58 +03:00
Ernestas Kulik
9a0ec5b1e0 gdk: contentdeserializer: Fix stream usage
file_uri_deserializer splices a memory stream, as opposed to
string_deserializer, which uses a converter and filter stream. This
commit fixes erroneous use of GMemoryOutputStream as
GFilterOutputStream.
2018-07-19 15:53:08 +03:00
Ernestas Kulik
7b5a0a829a gdk: Add auto cleanup func for GdkContentProvider 2018-07-19 11:28:21 +03:00
Timm Bäder
446b2e25d3 Avoid a g_object_get path
We can use gdk_device_get_n_axes instead and will get the same result.
2018-07-17 17:33:46 +02:00
Matthias Clasen
bf5f27c6d5 Handle configure events in gdk
The previous attempt at removing configure events entirely
was causing some dialogs not to show up under Wayland.
Presumably due to ordering issues with emitting ::size-change
out of the backend.

Instead, keep configure events in the event queue, but handle
them on the gdk side. This keeps the ordering intact, while
still removing configure events from the api. The dialogs
show up now.
2018-07-15 20:23:45 -04:00
Matthias Clasen
7a1073c3ae Revert "gdk: Drop configure events"
This reverts commit a8926c9d87.
2018-07-15 20:23:45 -04:00
Matthias Clasen
e2fd33f78a Revert "broadway: Stop using configure events"
This reverts commit 9c827cbff4.
2018-07-15 20:23:45 -04:00
Matthias Clasen
3c8b3cbf41 win32: Stop accessing GdkDrag members 2018-07-15 16:58:22 -04:00
Matthias Clasen
410d4bca83 wayland: Set actions on drag
We should pass the actions to the newly created
drag in drag_begin.
2018-07-15 16:52:16 -04:00
Matthias Clasen
168523264c x11: Set actions on drag
We should pass the actions to the newly created
drag object in drag_begin.
2018-07-15 16:50:06 -04:00
Matthias Clasen
435f143e2e x11: Rename a file
Keep in line with the parent class.
2018-07-15 16:47:17 -04:00
Matthias Clasen
98ccb67277 drop: stop accessing GdkDrag fields 2018-07-15 16:43:28 -04:00
Matthias Clasen
2d83bb1b91 x11: Stop using GdkDrag fields 2018-07-15 16:43:28 -04:00
Matthias Clasen
298b6ee81a wayland: Stop accessing GdkDrag members 2018-07-15 16:43:28 -04:00
Matthias Clasen
5ce3520a2a Add a GdkDrag::surface property 2018-07-15 16:43:28 -04:00
Matthias Clasen
9cc3e2c8ef gdkdrag: remove an unused member
The drag surface is stored in the subclasses and obtained
by via the get_drag_surface vfunc.
2018-07-15 16:42:07 -04:00
Matthias Clasen
034f89b17f wayland: Drop an unused api
Nothing was calling gdk_wayland_drag_set_source_surface.
2018-07-15 16:42:07 -04:00
Matthias Clasen
1ea09a327a Add a private struct to GdkDrag
This will force subclasses to use proper api.
2018-07-15 16:42:00 -04:00
Matthias Clasen
bc2f484ae9 Revert "GdkDrop: drop the priv struct"
This reverts commit d927c3bee0.

I was wrong. Better to hide the struct fields from subclasses.
2018-07-15 15:58:05 -04:00
Matthias Clasen
228f813c43 dnd: Drop gdk_drag_drop
This is an inconsistently used private api, and just adds
a vfunc indirection for no other benefit.
2018-07-15 15:58:05 -04:00
Matthias Clasen
288086b899 Fix up some doc mishaps
When GdkWindow was renamed to GdkSurface, 'window managers'
turned into 'surface managers'. Thats not cool.
2018-07-15 15:36:19 -04:00
Matthias Clasen
d148f26658 Drop gdk_surface_withdraw
'withdrawn' is an X11-centric concept, and the function
can just as well be replaced by gdk_surface_hide.
2018-07-15 15:29:58 -04:00
Matthias Clasen
7ca6440f4d gdk: Drop map events
We are really inconsistent about generating these,
and they are not actually used in GTK+. Instead,
add a boolean GdkSurface::mapped property.
2018-07-15 15:10:56 -04:00
Matthias Clasen
1172810768 win32: Stop using expose and configure events
These no longer exist.
2018-07-15 14:07:40 -04:00
Matthias Clasen
9c827cbff4 broadway: Stop using configure events
These no longer exist.
2018-07-15 14:01:59 -04:00
Matthias Clasen
da3aaf39b9 gdk: Drop expose events
Replace expose events with a GdkSurface::expose signal.
This is part of the move to use events only for input.
2018-07-15 13:13:07 -04:00
Matthias Clasen
a8926c9d87 gdk: Drop configure events
Replace configure events with a GdkSurface::size-changed signal.
This is part of the move to use events only for input.
2018-07-15 11:51:09 -04:00
Benjamin Otte
6afb6bb9d2 x11: Set BackPixmap = None unconditionally
Makes it more obvious what we actually want.

Related: #1134
2018-07-14 05:27:54 +02:00
Benjamin Otte
1a5e60be7c paintable: Fix return_if_fail() statements
I always switch them up...
2018-07-13 14:56:04 +02:00
Matthias Clasen
00a61f92b6 docs: Small updates
Remove a few references to no-longer-existing APIs.
2018-07-13 10:13:00 +02:00
Matthias Clasen
f432c937cc dnd: Drop gdk_drag_abort
This function is never called, so drop it, its vfunc,
and all the backend implementations.
2018-07-12 13:57:45 +02:00
Matthias Clasen
1dd15b5237 dnd: Some documentation updates
Don't mention dnd protocols, and do mention the new,
split objects.
2018-07-12 13:57:45 +02:00
Matthias Clasen
5cdbbc6e61 win32: Build fixes 2018-07-12 13:02:42 +02:00
Matthias Clasen
0e2ac0ebf2 wayland: Rename a source file
Rename gdkdnd-wayland.c to gdkdrag-wayland.c to go along
with gdkdrop-wayland.c.
2018-07-12 13:02:42 +02:00
Matthias Clasen
c73cb2c154 wayland: Drop an unused field
Nothing was using the foreign_dnd_surface anymore, so no
need to create it in the first place.
2018-07-12 13:02:42 +02:00
Matthias Clasen
a756caa106 dnd: Drop suggested_action
The only user of this field was the x11 backend, and it
turns out that it does not need to store the value at all.
2018-07-12 13:02:42 +02:00
Matthias Clasen
da22ba3b86 drag: Split a setter
In preparation for moving the suggested action
to the x11 backend, split the setter off.
2018-07-12 13:02:42 +02:00
Matthias Clasen
7a0a92f2b6 win32: Stop using gdk_drag_get_suggested_action
The suggested action is not set or used in the win32
information, so don't put it in logs either.
2018-07-12 13:02:42 +02:00
Matthias Clasen
d927c3bee0 GdkDrop: drop the priv struct
Its not needed.
2018-07-12 13:02:42 +02:00
Matthias Clasen
59c2efbcd6 Add a GdkDrag::actions property
To go along the GdkDrop::actions property.
2018-07-12 13:02:42 +02:00
Matthias Clasen
94af080fb6 Rename a property
Change GdkDrag::action to GdkDrag::selected-action, which is
more clearly different from actions, and follows the existing
name of the struct field and getter.
2018-07-12 13:02:42 +02:00
Matthias Clasen
40841ec3be GdkDrag: Drop the priv struct
We don't need it.
2018-07-12 13:02:42 +02:00
Matthias Clasen
f69bb2fb2b wayland: set a cursor when starting a drag
Otherwise, we wont have one.
2018-07-12 13:02:42 +02:00
Matthias Clasen
db0b9f61ae dnd: Add a GdkDrag::action property
This lets us drop the ::action-changed signal for the
property change notification. But, can just as well move
the signal class handers which just update the cursor
to the ::action setter. No need to do this in the backends.
2018-07-12 13:02:42 +02:00
Matthias Clasen
63ab523146 wayland: Remove an unused field
GdkDragWayland.suggested_action was entirely unused, so drop it.
2018-07-12 13:02:42 +02:00
Matthias Clasen
12464731f1 Merge branch 'dnd-cleanups' into 'master'
Dnd cleanups

See merge request GNOME/gtk!226
2018-07-02 21:19:45 +00:00
Matthias Clasen
c8e082f296 win32: Adapt to dnd api changes
Follow the GdkDragContext -> GdkDrag change.
2018-07-02 22:52:59 +02:00
Matthias Clasen
64f5afe608 dnd: Rename headers
Rename gdkdnd.h to gdkdrag.h, to go along with gdkdrop.h

This commit includes the necessary updates to the X11, Wayland
and Broadway backends. Other backends have to be updated separately.
2018-07-02 15:00:50 +02:00
Matthias Clasen
7733f646d6 gdk: Rename GdkDragContext to GdkDrag
This is to go along with the newly introduced GdkDrop.

This commit includes the necessary updates to the X11, Wayland
and Broadway backends. Other backends have to be updated separately.
2018-07-02 14:59:26 +02:00
Matthias Clasen
9c3de51412 Merge branch 'wip/cursor-output-scale-changes' into 'master'
wayland: Update cursor surface scale when output scale changes

See merge request GNOME/gtk!224
2018-06-29 15:08:17 +00:00
Jonas Ådahl
dfd1372a9b wayland: Update cursor surface scale when output scale changes
Also update the cursor surfaces of every seat when an output changes
scale. This could for example happen when a monitor scale is changed via
Settings.
2018-06-28 12:44:22 +02:00
Rico Tzschichholz
b80942ec88 gdk: Fix some g-i annotations warnings 2018-06-27 09:00:17 +02:00
Matthias Clasen
8755d884f3 Remove a lot of Since annotations
4.0 will represent a clean epoch. We don't want to have
lots of noise in the docs about 2.x or 3.x.
2018-06-25 19:55:04 -04:00
Benjamin Otte
d13843ee2a gdk: Remove GDK_SURFACE_FOREIGN
We don't create surfaces of that type anymore.
2018-06-26 00:47:40 +02:00
Matthias Clasen
5c46c81067 x11: Fix dnd action handling
We were mistakenly assigning an Atom to a flags value.
2018-06-20 18:10:50 -04:00
Matthias Clasen
cd99f82e0c Merge branch 'master' into 'issue1084'
# Conflicts:
#   gdk/gdk.c
2018-06-20 14:21:24 +00:00
Benjamin Otte
06bba15f62 win32: Fix typo
This should fix gtk-doc erroring out.
2018-06-19 21:45:44 +02:00
Benjamin Otte
4d4ec2dbfb dnd: gdk_drag_action_is_unique() should return a boolean 2018-06-19 19:44:17 +02:00
myfreeweb
a1bcbdd02a wayland: Use shm_open(SHM_ANON) on FreeBSD
This functionality is similar to Linux's memfd. It creates anonymous shared memory without touching the filesystem, which allows it to work in Capsicum capability mode (sandbox).
2018-06-19 11:45:49 -04:00
Benjamin Otte
cbbb7604b6 x11: Set background as transparent as possible
Instead of making the background black, make it transparent black for
RGBA visuals and set a None background otherwise.
2018-06-18 23:49:53 +02:00
Benjamin Otte
a2839d157f dnd: Remove unused time arguments 2018-06-18 23:49:53 +02:00
Benjamin Otte
b3d424c2d7 dnd: Remove GdkDragContext.dest_surface
The variable is now unused
2018-06-18 23:49:53 +02:00
Руслан Ижбулатов
bf3ea24489 GDK W32: Remove gdk_win32_surface_foreign_new_for_display
That function is now unused.
2018-06-18 23:49:53 +02:00
Руслан Ижбулатов
997e8c1ae1 GDK W32: Adapt to dest_surface removal, misc changes
* There's no GdkDragContext->dest_surface anymore.
  Add dest_window field to GdkWin32DragContext,
  and use that instead.
* Remove unused function prototypes
* Add more comments
* Rename variables and fields from 'window' to 'surface'
  where appropriate
* Fix header indentation a bit
* Try to ensure that uninitialized/unknown handle variables
  and fields are set to INVALID_HANDLE_VALUE instead of NULL,
  as there may be cases where NULL is a valid handle value.
2018-06-18 23:49:53 +02:00
Benjamin Otte
aa1f0cfd4f dnd: Remove GdkDragContext.is_source
All drag contexts are sources these days, the other ones are GdkDrop
now.
2018-06-18 23:49:53 +02:00
Benjamin Otte
45a6146ca6 x11: Remove gdk_x11_surface_foreign_new_for_display()
People who want to use foreign windows should use X directly.
2018-06-18 23:49:53 +02:00
Benjamin Otte
bc63001deb x11: Store the XID instead of a GdkSurface
This might be foreign Windows and we don't want to create surfaces for
those.

Also, stop using GdkDragContext.dest_surface, that variable is meant to
go away.
2018-06-18 23:49:53 +02:00
Benjamin Otte
47b47f5835 x11: Simplify test
Now that we have gdk_drag_context_get_display(), use it.
2018-06-18 23:49:52 +02:00
Benjamin Otte
1b2dccd143 x11: xdnd_send_event() always returns TRUE
Make it return nothing instead and delete the code that handled the
FALSE case.
2018-06-18 23:49:52 +02:00
Benjamin Otte
7e09aa3caa x11: Don't multiply X values by the scale factor
This is fallout from a too eager change in
bdb442be21.
2018-06-18 23:49:52 +02:00
Benjamin Otte
6633d4130a dnd: Make the base Drag/Drop types abstract
This way, they'll be ignored by the testsuite.

And we don't want to instantiate them anyway, the backends have
their own subclasses.
2018-06-18 23:49:52 +02:00
Benjamin Otte
a960641ace dnd: GdkDragContext is no longer a GdkDrop subclass
This includes a bunch of header cleanup
2018-06-18 23:49:52 +02:00
Benjamin Otte
f982c9c8f8 dnd: Remove gdk_drag_status() and gdk_drag_finish()
Those functions are unused and have been replaced by their equivalents
gdk_drop_status() and gdk_drop_finish().
2018-06-18 23:49:52 +02:00
Benjamin Otte
a1cee7fa65 surface: Kill event masks
In particular, this patch removes:
  gdk_surface_get_events()
  gdk_surface_set_events()
  gdk_surface_get_device_events()
  gdk_surface_set_device_events()

Event masks so far still exist for grabs.
2018-06-18 23:49:52 +02:00
Benjamin Otte
d0ebdf00f8 x11: Store the source surface as an XID
Don't create a foreign GDK surface, just store the XID.

With this, we can avoid GDK APIs that we want to get rid of and just
use the X counterpart.
2018-06-18 23:49:52 +02:00
Benjamin Otte
dd30a288f2 x11: Split drag and drop contexts
While doing so, turn the drop context into a GdkDrop subclass and no
longer pretend to be a GdkDragContext.
2018-06-18 23:49:52 +02:00
Benjamin Otte
005781021e x11: Handle events on drag side differently
Instead of using the filters that the drop side uses, handle events in
the event filter installed by the DragContext.
2018-06-18 23:49:52 +02:00
Benjamin Otte
14f0a25531 x11: Change the way local Drop => Drag is shortcut
This is one step further towards untangling drag and drop parts of X11
DND.
2018-06-18 23:49:52 +02:00
Benjamin Otte
8db379d85b x11: Remove unused argument
The propagate argument is always FALSE, so just use FALSE everywhere.
2018-06-18 23:49:52 +02:00
Benjamin Otte
6b65aaab21 x11: switch a bunch of variable types
GdkDragContext => GdkDrop

This is all in preparation of separation of the drag and drop.

Also, don't check for GDK_DRAG_PROTO_XDND anymore - it's the only
possible value for the protocol on the target side.
2018-06-18 23:49:52 +02:00
Benjamin Otte
905765eed6 broadway: Remove unused variable 2018-06-18 23:49:52 +02:00
Benjamin Otte
e1206763a8 dnd: Remove gdk_drag_context_get_dest_surface()
... and gdk_drag_context_get_source_surface().

In the backends, use direct access to the variables instead.
2018-06-18 23:49:52 +02:00
Benjamin Otte
5e159e2ca0 x11: Replace the hardcoded DND filter
Use the new method of connecting to the xevent signal instead.

Also, don't consume the xevent, there might be other code listening for
it. And we don't use PropertyNotify in the generic code path anymore, so
it'll just be ignored there.
2018-06-18 23:49:52 +02:00
Руслан Ижбулатов
392071b66d GDK W32: Remove unused files 2018-06-18 23:49:52 +02:00
Руслан Ижбулатов
8ee4de804c GDK W32: Adapt to GdkDrop and GdkDragContext changes
* Remove clipdrop->dnd_target_state, it's not used anymore
* Remove non-functioning _gdk_dropfiles_store(), store dropfiles
  list in GdkWin32Drop instead
* Fix multiple comment typos
* Fix _gdk_win32_get_clipboard_format_name_as_interned_mimetype() to
  leave names that look like mime/types alone
* Refactor _gdk_win32_add_w32format_to_pairs() to populate
  GdkContentFormatsBuilder directly, instead of making a GList
* Rename context -> drag (still using GdkDragContext type,
  but [almost?] all variables and comments say "drag" now)
* Rename GdkDropContext -> GdkDrop
* Rename some parameter names for clarity
* Rewrite local protocol to look more like OLE2 protocol
  instead of mirroring the structure of the X11 API.
* Add handle_events field to GdkWin32DragContext,
  to shut off event handling (temporary fix until GTK is patched up)
* Remove _gdk_win32_drag_context_find() - the drag object is stored
  in GdkDrop instead. Use _gdk_win32_find_drag_for_dest_surface()
  to get it initially.
* Remove target_ctx_for_window, droptarget context is stored
  in the surface instead.
* Call gdk_drag_context_set_cursor() just like wayland backend does
  (slightly broken for now)
* Clean up the action choosing code (filter source actions by using
  keyboard state, pass that to GTK, get all actions supported by GTK in
  response, match them up with filtered source actions, return the
  result, falling back to COPY in case of multiple actions)
* Check drag_win32->protocol instead of the use_ole2_dnd variable where
  possible
* Remove protocol checks from functions that are only used by the local
  protocol
* Use event state to manufacture the keyboard state for WM_MOUSEMOVE
* Change function names printed by GDK_NOTE to name the actual
  functions, not their theoretical generic GDK stack ancestors
* Consistently use drag_win32 and drop_win32 variables instead of a mix
  of that and win32_drag/win32_drop
* Return FALSE from button handler to ensure that GTK gets the button
  event to break implicit grab
* Emit leave event on failed idroptarget_drop() calls
2018-06-18 23:49:52 +02:00
Benjamin Otte
dcf432d7d0 dnd: Add read_value() and read_text() functions to GdkDrop
These just copy what GdkClipboard does.
2018-06-18 23:49:52 +02:00
Benjamin Otte
ea9d6f0a95 drop: Implement shortcut for local DND
Now that we have the drop->drag, we can use the same shortcut we use in
the clipboard code to shortcut DND operations.
2018-06-18 23:49:52 +02:00
Benjamin Otte
018a17fb8e x11: Pass the drag source when creating a drop context 2018-06-18 23:49:52 +02:00
Benjamin Otte
895f381fd5 x11: Find dest drops differently
Instead of looking at the list of contexts, just look at the current
drop context. There is only one, after all.

Then remove the is_source argument from gdk_drag_context_find().
2018-06-18 23:49:52 +02:00
Benjamin Otte
66bd54d14c wayland: Store the current drag operation
Use it to detect local drags when creating drop objects.
2018-06-18 23:49:52 +02:00
Benjamin Otte
ff38d38444 dnd: Move GdkDragAction to gdktypes.h
That way, both gdkdrag.h and gdkdrop.h can use it without one having to
include the other.
2018-06-18 23:49:52 +02:00
Benjamin Otte
af749532fc gdk: Remove leftover type from autocleanup 2018-06-18 23:49:52 +02:00
Benjamin Otte
7afa0badd8 wayland: Get rid of GdkWaylandSelection
Move data source handling into the DND code instead.
2018-06-18 23:49:52 +02:00
Benjamin Otte
4eb3a9faaa wayland: Split drop context into GdkWaylandDrop
GdkWaylandDrop no longer inherits from GdkDragContext now.
2018-06-18 23:49:52 +02:00
Benjamin Otte
81e1dc9a66 wayland: Remove a bunch of unused functions 2018-06-18 23:49:52 +02:00
Benjamin Otte
c67fb57881 events: Make GdkEventDND have a GdkDrop member
... instead of a GdkDragContext.
2018-06-18 23:49:52 +02:00
Benjamin Otte
81171cc0a2 x11: Refactor DND filter
The filters now return TRUE/FALSE and no longer a GdkFilterReturn. They
also don't conform to the GdkFilterFunc typedef anymore but instead take
the arguments that they need.
2018-06-18 23:49:52 +02:00
Benjamin Otte
aa4e4dd0c7 x11: Use new DND event emitters 2018-06-18 23:49:52 +02:00
Benjamin Otte
7a9afc3a95 win32: Use new DND event emitters 2018-06-18 23:49:52 +02:00
Benjamin Otte
114ab8775a wayland: Use new DND event emitters 2018-06-18 23:49:52 +02:00
Benjamin Otte
657ebd2a78 drop: Add private API for event emission 2018-06-18 23:49:52 +02:00
Benjamin Otte
05bf87cf14 drop: Add GdkDrop:surface property
This replaces gdk_drag_context_get_dest_surface().
2018-06-18 23:49:52 +02:00
Benjamin Otte
4aedf3d003 display: Don't wake up the main loop anymore
This is not needed because GTK must be run in the main thread these days,
which is the same one that runs the main loop. So when this function is
called, the main loop is awake.

https://bugzilla.gnome.org/show_bug.cgi?id=550989
2018-06-18 23:49:52 +02:00
Benjamin Otte
b1f384eec2 x11: Don't sneakily allocate memory in initializers 2018-06-18 23:49:52 +02:00
Benjamin Otte
d02b185a87 dnd: Add gdk_event_get_drop()
And remove gdk_event_get_drag_context().

All GTK code now only uses GdkDrop for dropping.
2018-06-18 23:49:52 +02:00
Benjamin Otte
6048b69145 wayland: Fix drop operations for new semantics 2018-06-18 23:49:52 +02:00
Benjamin Otte
4b85b5299a dnd: Remove GdkDragContext::commit_drag_status() vfunc
The idea behind the vfunc doesn't work as status updates can happen
asynchronously.

A better solution needs to be found.
2018-06-18 23:49:52 +02:00
Benjamin Otte
a862ca41c5 drop: Add gdk_drop_get_drag()
For now, it'll always return NULL. We'll fix that later.
2018-06-18 23:49:20 +02:00
Benjamin Otte
316bd6a333 dnd: Add gdk_drop_finish()
and move the vfunc into GdkDrop.
2018-06-18 23:49:20 +02:00
Benjamin Otte
13ae11ee01 dnd: Rename gdk_drop_finish() => gdk_drag_finish()
This is a simple rename, so that we can reintroduce gdk_drop_finish()
with the GdkDrop object.
2018-06-18 23:49:19 +02:00
Benjamin Otte
a05af1f0f3 dnd: Move the gdk_drag_status() function
It's now gdk_drop_status().

Also clarify the intended semantics.
2018-06-18 23:49:19 +02:00
Benjamin Otte
b2dc303e5e dnd: Add gdk_drop_get_actions()
This uses the new method without GDK_ACTION_ASK:

Either it is a single action (queryable via gdk_drag_action_is_unique())
or it is not and then the drop target has to make a decision
(potentially by asking someone).
2018-06-18 23:49:19 +02:00
Benjamin Otte
2e27967814 dnd: Make actions a private member variable
Use a setter in the backends.
2018-06-18 23:49:19 +02:00
Benjamin Otte
18c3b725b4 x11: Remove unused variables 2018-06-18 23:49:19 +02:00
Benjamin Otte
6573d08b08 wayland: Set correct variable
This got messed up in commit 7f8a8f221d.
2018-06-18 23:49:19 +02:00
Benjamin Otte
74a8ffc4a8 dnd: Add gdk_drag_action_is_unique()
This will be necessary once we remove the ASK action.
2018-06-18 23:49:19 +02:00
Benjamin Otte
ac44353f9b dnd: Remove GDK_ACTION_DEFAULT and GDK_ACTION_PRIVATE
They're unused and nobody knows what they're supposed to men anyway.
2018-06-18 23:49:19 +02:00
Benjamin Otte
6919d8c532 drop: Move gdk_drop_read_async() to GdkDrop class 2018-06-18 23:49:19 +02:00
Benjamin Otte
f247d268d4 dnd: Add GdkDrop base class for GdkDragContext
The ultimate goal of this patch series is to split GdkDragContext into
GdkDrop + GdkDrag classes for the destination and source side of a dnd
operation.

The refactoring is meant to work something like this:
1. Introduce GdkDrop as a base class
2. Make all drop related code (like GdkEvent) use GdkDrop instead of
   GdkDragContext. Move/duplicate APIs to allow that.
3. Port all drop contexts in the backends from GdkDragContext to GdkDrop
4. Delete all APIs in GdkDragContext that aren't needed anymore.
5. Make GdkDragContext no longer a GdkDrop subclass
6. Rename GdkDragContext to GdkDrag
2018-06-18 23:49:19 +02:00
Matthias Clasen
841a29837e Merge branch 'lrn/misc-gtk4-fixes' into 'master'
Misc GTK4 fixes

See merge request GNOME/gtk!195
2018-06-18 21:37:42 +00:00
Matthias Clasen
5a319f66af Merge branch 'window-activate-grab-4-again' into 'master'
gdk: activate surface on keyboard grabs

Closes #85

See merge request GNOME/gtk!174
2018-06-18 11:36:09 +00:00
Samuel Thibault
35417a5a74 gdk: activate surface on keyboard grabs
In 01455399e8 ("gdk: do not deactivate surface on keyboard grabs"), we
made gdk avoid deactivating surfaces when another application takes a
keyboard grab, by using has_focus_window instead of has_focus. That however
broke activating surfaces when the gdk application acquired a grab itself,
in which case has_focus_window is false but has_focus is true.

We thus actually need to use both: surfaces should be activated either
because we have normal keyboard focus, or because we grabbed the keyboard.

This also renames HAS_FOCUS to APPEARS_FOCUSED to better reflect its
role.

Fixes #85
2018-06-18 10:31:15 +02:00
Руслан Ижбулатов
b7f9a5419f GDK W32: Use SWP_NOOWNERZORDER everywhere it can be applied
There is no reason why we shouldn't pass this flag every time
Z-order changes. We have separate routines that are used to
maintain relative Z-order, so it should be completely OK to
pass SWP_NOOWNERZORDER to let the OS know that it shouldn't try
to maintain relative Z-order of the windows when raising them.
2018-06-17 10:59:49 +00:00
Руслан Ижбулатов
6cfa799ca1 GDK W32: Don't let TEMP surfaces cause zorder side-effects
Pass SWP_NOOWNERZORDER when rising TEMP surfaces to the top. This ensures that
they don't drag anything else to the top with them. The use-case for this is
a tooltip appearing for a non-foreground surface, causing said surface to rise
above other surfaces, some of which maybe foreground at the moment.

https://bugzilla.gnome.org/show_bug.cgi?id=784766
2018-06-17 10:59:47 +00:00
Руслан Ижбулатов
0db6ee9347 GDK W32: don't unref window iconlist textures
We do not own these textures, nor do we ref them, so it's inappropriate
to unref them.
2018-06-16 18:26:29 +00:00
Руслан Ижбулатов
8a1106c639 W32: Use correct hinstance values
According to the old new thing[0], we should use the instance handle
of the GDK/GTK DLL when registering GDK-specific types in the system.
Using the instance handle for the whole application in these circumstances
is not an error, but can potentially clash with the types registered
by the application itself.

Also, extract window class icons from the GDK/GTK DLL, not from the
application executable.

[0]: https://blogs.msdn.microsoft.com/oldnewthing/20050418-59/?p=35873
2018-06-16 18:24:56 +00:00
Руслан Ижбулатов
6e085b3bf1 Pass the correct data to gdk_content_register_serializer()
The argument is eventually passed to g_conv(), so it should
be the charset, not the mime/type. Without this change the
contentype converter will fail to convert UTF-8 strings to, say,
CP-1251 later on.
2018-06-16 18:23:56 +00:00
Mohammed Sadiq
fd4bfd5050 build: Fix compiler warnings 2018-06-11 21:12:41 +05:30
Mario Sanchez Prada
938448e0ef display: Add new virtual gdk_display_get_startup_notification_id() method.
Includes implementation for Wayland and X11, which are the only backends
implementing the Startup Notification Protocol, returns NULL otherwise.

https://gitlab.gnome.org/GNOME/gtk/issues/1084
2018-06-11 16:28:24 +01:00
Mario Sanchez Prada
ef3427575f display: Avoid unsetting the DESKTOP_STARTUP_ID variable too late
Similar to what has been done recently for DESKTOP_AUTOSTART_ID [1],
we need to get rid of this call to g_unsetenv() in the displays'
backends for X11 and Wayland, so that it's guarantee to happen any
thread is created, while still being accessible when needed.

Let's stash the value of this environment variable when loading the
GDK library, and provide a private method so that it can be retrieved
from the displays' backend when implementing gdk_display_make_default().

[1] https://gitlab.gnome.org/GNOME/gtk/commit/22269902

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/979
2018-06-11 16:28:24 +01:00
Руслан Ижбулатов
cddc9ff424 Fix a typo in W32 event-handling code
It's quite old, but mostly harmless (both "message == WM_KEYUP"
and "message = WM_KEYUP" evaluate to not-FALSE, and message
value is not used after that line).
2018-06-10 21:21:19 +00:00
Руслан Ижбулатов
e73dc5c779 Fix a warning about uninitialized variable 2018-06-10 21:21:17 +00:00
Руслан Ижбулатов
93f8f3c406 Remove unused code in gdksurface-win32.c 2018-06-10 21:21:16 +00:00
Руслан Ижбулатов
3acd26c64a Fix more signedness issues in W32 backend 2018-06-10 21:21:14 +00:00
Руслан Ижбулатов
cacdef8db7 A quick and dirty fix for a circular allocation issue
query_targets() tried to write to struct that
wasn't yet allocated.
This code is going to change soon, so this is a temporary
fix until then.
2018-06-10 21:21:12 +00:00
Руслан Ижбулатов
1e2ab40539 Fix a missing default case warning
It shouldn't be possible to get DPI_STATUS_PENDING here.
If it does happen, that would be a bug that should be fixed.
2018-06-10 21:21:10 +00:00
Руслан Ижбулатов
f0103eeeb4 Remove unused functions in W32 backend 2018-06-10 21:21:09 +00:00
Руслан Ижбулатов
8bd6936533 Fix signedness issues, remove unused code 2018-06-10 21:21:07 +00:00
Руслан Ижбулатов
0e1710a372 Remove some more unused variables 2018-06-10 21:21:06 +00:00
Руслан Ижбулатов
bc47fa27d4 Fix various type mismatch warnings 2018-06-10 21:21:04 +00:00
Руслан Ижбулатов
aaa4e23a77 Fix gdk_win32_cairo_context_end_frame prototype 2018-06-10 21:21:02 +00:00
Руслан Ижбулатов
58fc1229c1 Remove unused variables (mostly in W32 code) 2018-06-10 21:21:01 +00:00
Руслан Ижбулатов
10b2f6540a Fix wrong format strings in various places 2018-06-10 21:20:59 +00:00
Benjamin Otte
40321d331f x11: Remove useless check
The check survived from GTK2 when that function could still return
GdkPixmap and GdkFont objects and was accompanied by this comment:

  /* We may receive events such as NoExpose/GraphicsExpose
   * and ShmCompletion for pixmaps
   */
2018-06-10 02:33:53 +02:00
Benjamin Otte
ce6227840d clipboard: Remove return statements from void function 2018-06-10 02:31:10 +02:00
Jonas Ådahl
c0e1044d5c gdk: Make gdk_surface_move_to_rect public
This is the API used by GtkMenu to properly position menus on the screen
without requiring GTK to query the menu window's position or the work
area of where the window is positioned. It makes it possible to position
popup windows properly when using Wayland.

Make this API available to external users so custom popup windows can be
positioned properly as well.

Related: https://gitlab.gnome.org/GNOME/gtk/issues/997
2018-06-05 17:53:05 +02:00
Matthias Clasen
60aeb15116 x11: Don't set NET_WM_PID when sandboxed
It is not useful, and some window managers misinterpret it and
add some "runs as root" indication to the window decoration.

See https://github.com/mate-desktop/marco/issues/301
2018-05-29 20:19:05 -04:00
Matthias Clasen
c83441ae4a gdk: Add a private api to find sandboxes
This will be used in more places in the future.
2018-05-29 20:17:22 -04:00
Benjamin Otte
83a80ab866 events: Mark static function as such 2018-05-29 21:54:47 +02:00
Benjamin Otte
7e574fa98c gdk: Get rid of gdk_event_free()
Events are objects, so use g_object_unref().
2018-05-29 21:53:44 +02:00
Victor Toso
d424837496 gdkseatdefault: Don't hide GdkSurface on grab failure
Application is not expecting that.

Bug found due gdk_seat_grab() failure on Lock Screen. When user
Unlock the screen, the application is visible but does not receive
enter-event any more on X11/GNOME.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1485968
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1571422

Signed-off-by: Victor Toso <victortoso@redhat.com>
Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
2018-05-29 14:05:14 +02:00
Timm Bäder
c8decbaad0 gdkscreen-x11: Remove redundant typedef
Causes warnings with clang.
2018-05-27 17:51:51 +02:00
Carlos Garnacho
d94ac2ed61 Merge branch 'issue792' into 'master'
wayland: check native surface for crossing events

Closes #792

See merge request GNOME/gtk!148
2018-05-22 11:10:26 +00:00
Matthias Clasen
daca4b9a39 Merge branch 'wip/restart-cursor-animation' into 'master'
wayland: Fix restarting cursor animation

See merge request GNOME/gtk!149
2018-05-17 09:59:45 +00:00
Chun-wei Fan
04b4c077f6 gdkcairocontext*.h: Include cairo.h consistently
The other sources include cairo.h by just using #include <cairo.h>, so
do likewise here.
2018-05-15 13:49:45 +08:00
Jonas Ådahl
a5d000cb5c wayland: Fix restarting cursor animation
When an animated cursor was set and the previous cursor animation delay
happened to be the same, we wouldn't restart the animation timeout and
just return G_SOURCE_CONTINUE assuming the timer would continue. This
assumption is however only valid if the function was called from the
timeout, which is not the case.

Instead also arm the timer also if there is no previous timer active.
2018-05-09 22:17:03 +02:00
Olivier Fourdan
d3885e92a7 wayland: check native surface for crossing events
gdk_wayland_*_grab()/ungrab() would emit crossing events which translate
as focus_in/focus_out events for keyboard.

However, the ungrab() functions compare the native toplevel as this is
what gets the Wayland pointer enter/leave events with the grab surface,
so if the grab is issued on a child gdk surface, those won't match and
we would emit more focus_out events than focus_in.

This means that a widget such as spice-gtk which issues a keyboard grab
whenever the pointer enters the surface and releases the grab when it
leaves the surface would get uneven numbers of focus_in/focus_out
events.

Also, gdk_wayland_seat_ungrab() would not emit crossing events for
keyboard devices, whereas gdk_wayland_device_ungrab() does, which adds
even more potential discrepancies between focus_in/focus_out events.

To solve this problem, introduce two new helper functions which check
the relevant native surfaces to emit crossing events when needed that
get called evenly from both gdk_wayland_seat_grab()/ungrab() and gdk
_wayland_device_grab()/ungrab() APIs.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=780422
Closes https://gitlab.gnome.org/GNOME/gtk/issues/792
2018-05-09 17:30:34 +02:00
Emmanuele Bassi
1262d0c6e5 Avoid absolute paths when building the API reference
We should always use relative paths, or include_directories objects, to
allow using GTK as a subproject.
2018-05-08 14:20:00 +01:00
Benjamin Otte
34d1ebc562 dnd: Make "formats" a construct-only property
... and hide the member variable inside the DragContextPrivate.
2018-05-07 18:55:09 +02:00
Benjamin Otte
80f5fd8435 wayland: Remove stray if
Leftover from d056be4ea2.

I need more sleep when I need to fixup the fixups of my fixups now.
2018-05-07 18:55:09 +02:00
Benjamin Otte
2ce2a80d40 win32: Remove unused file 2018-05-07 18:55:09 +02:00
Benjamin Otte
d056be4ea2 wayland: Fix memleak
7f8a8f221d forgot to free the data offer
passed to it.
2018-05-07 16:28:50 +02:00
Matthias Clasen
c7fd3ebbaf Add GdkPaintable to the docs
Just the usual pre-release doc fixups.
2018-05-07 07:47:18 -04:00
Benjamin Otte
7f8a8f221d wayland: Redo DND offer handling
Instead of tracking offers in GdkWaylandSelection objects, track the
pending offer in the GdkWaylandSeat and pass it to the GdkDragContext
once we get an enter event.
2018-05-06 02:10:20 +02:00
Benjamin Otte
03a85ff2a0 gdk: Remove unnecessary assignments
The variable is never read again.
2018-05-06 02:10:20 +02:00
Matthias Clasen
4a72cab818 Document gdk_drop_read_async 2018-05-03 22:04:28 -04:00
Matthias Clasen
45db4a5550 Merge branch 'wip/xdg-shell' into 'master'
xdg shell (stable)

See merge request GNOME/gtk!35
2018-05-04 00:43:01 +00:00
Benjamin Otte
35e74a1501 win32: Fix build 2018-05-03 01:56:44 +02:00
Benjamin Otte
eb9105acea dnd: Add a private struct
And put member veriables into it.

Also fix backends to use accessors instead of direct access.
2018-05-03 01:31:40 +02:00
Benjamin Otte
8366ef71c0 dnd: Remove gdk_drop_reply()
It was only necessary for Motif DND, and we don't support that anymore.
2018-05-03 01:31:40 +02:00
Benjamin Otte
fb53568c04 gdk: Remove gdk_drag_grop_succeeded()
It's unused and most backends don't implement it.
2018-05-03 01:31:39 +02:00
Ting-Wei Lan
7fed0b74ed wayland: Use dev/evdev/input.h on FreeBSD
The header linux/input.h used by GDK is specific to Linux. It is
possible to get a few Linux headers on FreeBSD by installing v4l_compat,
but it is usually better to use the one shipped with FreeBSD.

We prefer dev/evdev/input.h to linux/input.h here, so it will always use
dev/evdev/input.h on FreeBSD regardless of v4l_compat.

https://svnweb.freebsd.org/changeset/ports/465644
2018-05-01 22:28:57 +08:00
Jonas Ådahl
5f19421bc9 wayland: Various whitespace cleanups
Broke up a long line, added an empty one, indented another one, and re-aligned
a large amount of function parameter names that got misaligned in some past
refactoring.

https://bugzilla.gnome.org/show_bug.cgi?id=791939
2018-05-01 13:39:42 +02:00
Jonas Ådahl
a40923b03a wayland: Add support for xdg-shell stable
This commit adds support the stable version of the xdg-shell protocol.
Support for the last version of the unstable series is left intact, but
will not receive new features.

The stable version is prioritized above the older version.

https://bugzilla.gnome.org/show_bug.cgi?id=791939
2018-05-01 13:36:38 +02:00
Rico Tzschichholz
2cf55c1686 Fix some g-i annotation warnings 2018-05-01 12:35:32 +02:00
Samuel Thibault
01455399e8 gdk: do not deactivate surface on keyboard grabs
When pressing e.g. a window manager shortcut, which acquires keyboard grab,
Xorg would send FocusOut NotifyGrab then FocusIn NotifyUngrab.  Currently
gdk would then deactivate the current surface, which makes accessibility
screen readers think that we have switched to a non-accessible application
and came back again, and thus reannounce the application frame etc. which we
don't want when e.g. just raising volume.

And actually, receiving FocusOut NotifyGrab does not mean losing the
X focus, it only means an application aqcuired a grab, i.e. it is
temporarily stealing keyboard events. On Wayland, this isn't even
notified actually.

This commit makes gdk only deactivate surfaces when there was an actual
focus switch to another window, as determined by has_focus_window (instead
of just has_focus), which happens either normally through FocusOut with
NotifyNormal, or during grabs through FocusOut with NotifyWhileGrabbed.

Fixes #85
2018-04-30 10:57:53 +02:00
Matthias Clasen
3684b72121 Misc documentation fixes
Close some gaps in gdk docs.
2018-04-28 22:34:14 -04:00
Matthias Clasen
059a181f7d Document GdkMemoryTexture 2018-04-28 16:22:29 -04:00
Benjamin Otte
4aaeb7de19 dnd: Make GdkDragContext::device a (construct-only) property
Also remove gdk_drag_context_set_device() and insist on backends using
the property.
2018-04-27 14:32:28 +02:00
Benjamin Otte
a86359af2b wayland: Create drop contexts on demand
Instead of creating and reusing the same one from start to finish.
2018-04-27 14:32:28 +02:00
Benjamin Otte
ae7a677346 cairocontext: Remove fallback implementations
Now that all Cairo contexts are ported to managing cairo surfaces
themselves, the old fallback code that didi the managing is no longer
needed.

Also clarify the behavior of gdk_cairo_context_cairo_create() wrt the
vfunc by doing the early exit and the clipping outside of it.
2018-04-24 23:24:55 +02:00
Руслан Ижбулатов
7002f08cc1 GDK W32: Switch to GdkCairoContext
* Remove DC refcounting (we trust GDK to always do
  begin_frame/end_frame calls in pairs)
* Now that there's no GDK-provided double-buffer up the stack,
  double-buffering is implemented here
  (though it's disabled by default - in my tests it didn't provide
   any visual improvements, but did decrease performance).
* For some reason delaying window resizes until the point where
  we need to blit the double-buffer into the window leads
  to visual glitches, so doulbe-buffered windows are resized
  in begin_frame, same as non-double-buffered ones.
* New code to clear the paint region, for all drawing modes.
  Hopefully, it isn't duplicated anywhere up the stack.
* GL has its own context now, so remove any GL-related comments.
* Layered windows are still used (because cairo actually works
  better with them)
* A bit more code re-use for layered windows
* Some functions that were local to gdksurface-win32.c are made
  usable for the whole backend
* Drag-indicator drawing is temporarily commented out to match
  a similar change in X11 backend
2018-04-24 23:24:55 +02:00
Alexander Larsson
a329de63ea broadway: Add and use GdkBroadwayDrawContext 2018-04-24 23:24:55 +02:00
Alexander Larsson
99c46f263e broadway: Add basic GdkCairoContext implementation 2018-04-24 23:17:14 +02:00
Alexander Larsson
9421cb8b3a broadway: Call _gdk_surface_update_size when resizing surface 2018-04-24 23:17:14 +02:00
Benjamin Otte
83ea0b3714 drawcontext: Only pass the region that matters
We used to pass 2 regions to GdkDrawCotnext.end_frame() but code was
confusing what they meant. So we now don't do that anymore and only pass
the region that matters: The frame region.
2018-04-24 23:16:58 +02:00
Benjamin Otte
fd686afeb2 drawcontext: Add gdk_draw_context_in_frame() API
This makes the previous gdk_draw_context_is_drawing() function public
under a new name.

I decided against the old name because we use the term "frame" for a
drawing operation, so I wanted to have this boolean flag reuse the term.
2018-04-24 23:16:58 +02:00
Benjamin Otte
6aa89f2163 drawcontext: Move variable into private struct
... and get rid of duplicate variable in the process.
2018-04-24 23:16:58 +02:00
Benjamin Otte
a865621519 gdk: Move begin/end_frame() functions
As they require a draw context and the draw context is already bound to
the surface, it makes much more sense and reduces abiguity by moving
these APIs to the draw context.

As a side effect, we simplify GdkSurface APIs to a point where
GdkSurface now does not concern itself with drawing anymore at all,
apart from being the object that creates draw contexts.
2018-04-24 23:16:58 +02:00
Benjamin Otte
48fc18c37b gdk: Get rid of GdkDrawingContext
All information is kept in GdkDrawContext these days, so use that one.
2018-04-24 23:16:58 +02:00
Benjamin Otte
c6ae0ff2d1 gdk: Get rid of gdk_drawing_context_get_clip()
Use the identical gdk_draw_context_get_frame_region() instead.
2018-04-24 23:16:58 +02:00
Benjamin Otte
dbe4f1d766 gdk: Add gdk_draw_context_get_frame_region()
This does the same as gdk_drawing_context_get_clip().
2018-04-24 23:16:58 +02:00
Benjamin Otte
e7d6648f46 gdk: Remove gdk_gl_context_get_damage()
Remove it only form public API, because we still use the vfunc to figure
out the damage area in begin_frame().
2018-04-24 23:16:58 +02:00
Benjamin Otte
4aac0760b3 wayland: Rewrite Cairo rendering
Also, split it into its own file - which was the original reason for
looking at this code, the rewrite was an unintentional side effect.

This changes the context to create surfaces on demand.
So whenever the compositor holds onto a surface while GDK wants to
render, it just creates a new surface. If the compositor releases
surfaces, we will retain one for the next frame to be rendered, but free
all extra ones.
This way, we should get to a stage where we have exactly as many
surfaces as needed and never allocate/free any.
2018-04-24 23:16:58 +02:00
Benjamin Otte
03e6cefe73 x11: Move implementation of Cairo context backends
Also, don't implement SurfaceClass.ref_cairo_surface() anymore. This
means calls to it will crash now. But as they only happen in the generic
GdkCairoContext implementation, we shouldn't be affected by that.

Plus, once all backends have been ported, that call is going away
anyway.
2018-04-24 23:16:13 +02:00