Commit Graph

8367 Commits

Author SHA1 Message Date
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
Руслан Ижбулатов
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
Руслан Ижбулатов
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