Compare commits

..

267 Commits

Author SHA1 Message Date
Ernestas Kulik cb7202ac6f gtkselection: Drop gtk_selection_data_get_targets()
As the data isn’t set anywhere with the type “ATOM”, this doesn’t work
as expected and can be replaced by a target atom check.
2018-07-31 23:29:26 +03:00
Ernestas Kulik ef632da8b6 gtkselection: Drop format field
It’s not used anywhere in a meaningful way and looks safe to rip out and
replace with a hardcoded constant where appropriate.
2018-07-31 23:29:26 +03:00
Ernestas Kulik 0967f6f3fc tests: testdnd: Use G_N_ELEMENTS macro
Wasted some horizontal screen estate, but beats rolling our own thing.
2018-07-31 23:29:26 +03:00
Matthias Clasen ce7956cd50 Merge branch 'issue1214-tooltips-win32-gtk4' into 'master'
Gdk-Win32: Correct handling of transient state changes

See merge request GNOME/gtk!280
2018-07-31 11:37:28 +00:00
Luca Bacci d29b378fa0 Gdk-Win32: Correct handling of transient state changes
See merge request !248
2018-07-31 11:11:26 +02:00
Benjamin Otte 1129febd7d bindings: Remove GTK_TYPE_IDENTIFIER
bindings now treat identifiers and strings the same way.

The only difference was that one allowed lookup of enum/flags by name
while the other didn't and g_warning()ed. Now both work.
2018-07-31 06:46:36 +02:00
Matthias Clasen 47928b9e14 color picker: Better debug spew
This will help in debugging issues.
2018-07-30 18:12:14 -04:00
Marek Cernocky 01f17836ac Updated Czech translation 2018-07-30 23:14:21 +02:00
Benjamin Otte 7e919aaaa5 gdk: Fix Windows and OS X backend for keyevent.string removal 2018-07-30 20:15:16 +02:00
Benjamin Otte 03a6420c37 treeview: Fix compiler warning 2018-07-30 19:58:38 +02:00
Benjamin Otte 375fbd4e47 gdk: Remove key_event->string and key_event->length
They're unused.
2018-07-30 19:32:38 +02:00
Benjamin Otte 813957a92f gdk: Remove gdk_event_get_string()
You want to use an IM module to get strings out of keypresses, not some
crude hack that only works on X11 and Wayland anyway.
2018-07-30 19:32:38 +02:00
Piotr Drąg 36ed4c2a29 Update POTFILES.skip 2018-07-30 16:31:53 +02:00
Marek Cernocky 8e78b53378 Updated Czech translation 2018-07-30 15:11:26 +02:00
Mohammed Sadiq 76ed6cf9d8 colorpickerportal: Fix memory leak 2018-07-30 18:10:31 +05:30
Carlos Garnacho a8c6f222ed inspector: Remove unnecessary cast
Pointed out by Timm.
2018-07-30 14:21:22 +02:00
Matthias Clasen c5afea0c6b Merge branch 'gtk-4-add-spinner-to-sidebar-row' into 'master'
gtkplacessidebar: Show busy spinner in sidebar row during mount ops

See merge request GNOME/gtk!261
2018-07-30 12:04:05 +00:00
Carlos Garnacho efa42a6932 Merge branch 'wip/carlosg/event-final-cleanup' into 'master'
Wip/carlosg/event final cleanup

See merge request GNOME/gtk!279
2018-07-30 11:25:24 +00:00
Carlos Garnacho 5d1b2f627c tests: Port testwidgetfocus to using a motion controller 2018-07-30 13:14:12 +02:00
Carlos Garnacho 8f6f980e49 demos: Update changedisplay demo to using GtkGesture 2018-07-30 13:14:12 +02:00
Carlos Garnacho 25b3b90920 tests: Port motion-compression to using a motion controller 2018-07-30 13:14:12 +02:00
Carlos Garnacho 71762d3b28 gtkscrolledwindow: Use controller for motion capturing
Perform scrollbar visibility checks through a motion controller,
always based on GtkScrolledView-relative coordinates. The captured
event handler remains though, for a tiny bit of GDK_SCROLL event
handling.
2018-07-30 13:14:12 +02:00
Carlos Garnacho f15224926a gtkwindow: Replace captured event handler with motion controller 2018-07-30 13:14:12 +02:00
Carlos Garnacho 1570c41efa testsuite: Update window test to use gestures when interactive 2018-07-30 13:14:12 +02:00
Carlos Garnacho 5e0f2d7d20 tests: Use gesture in testtreepos 2018-07-30 13:14:12 +02:00
Carlos Garnacho 88743ab975 tests: Use gesture to popup menu in testiconview 2018-07-30 13:14:12 +02:00
Carlos Garnacho 6f15447633 tests: Update testgrid to use gestures 2018-07-30 13:14:12 +02:00
Carlos Garnacho 85f6995511 demos: Update hypertext demo to use controllers 2018-07-30 13:14:12 +02:00
Carlos Garnacho 4d59a00074 demos: Update search_entry2 demo to use key capturing API
No more GdkEvent juggling.
2018-07-30 13:14:12 +02:00
Carlos Garnacho 2dbb1509d8 demos: drop "Event axes" demo
It's too lowlevel to be practical anymore with gtk4, and there's
the Paint and Gestures demos to demonstrate input capabilities
better than this.
2018-07-30 13:14:12 +02:00
Carlos Garnacho 101c927c40 gtk-demo: Add pad controller handling to "Paint" demo
So it's more lifelike.
2018-07-30 13:14:12 +02:00
Carlos Garnacho 6d3eb18578 gtktreeview: Use key controller on search entry handling
Use a distinct key controller so we correctly handle navigation
across matches and search cancellation. As the events are forwarded
to the search_window, those need to be pushed down the entry manually.
2018-07-30 13:14:12 +02:00
Carlos Garnacho d301695ba1 gtktreeview: Replace event vmethod with key controller 2018-07-30 13:14:12 +02:00
Carlos Garnacho ca8008e2c9 gtkcombobox: Use keycontroller on GtkCellEditable implementation 2018-07-30 13:14:12 +02:00
Carlos Garnacho 0d7b4ecb14 gtkentry: Use keycontroller on GtkCellEditable implementation 2018-07-30 13:14:12 +02:00
Carlos Garnacho 9a541d9b91 inspector: Use gestures/controllers for inspect button 2018-07-30 13:14:12 +02:00
Carlos Garnacho cdfde6673d gtkcombobox: Use controller to handle combobox keybindings in menus
Instead of an ::event callback.
2018-07-30 13:14:12 +02:00
Matthias Clasen 7ef95734af Merge branch 'fix-gs-issue-404' into 'master'
window: Fallback to CSD titlebar in focus-chain

Closes gnome-software#404

See merge request GNOME/gtk!271
2018-07-30 10:53:22 +00:00
Matthias Clasen de17e3b525 Merge branch 'devel-styling' into 'master'
Devel styling

See merge request GNOME/gtk!168
2018-07-30 10:49:56 +00:00
Jakub Steiner f8a971a7df Adwaita: devel style
- nightly/development versions of apps should get a styled
  headerbar.

https://gitlab.gnome.org/GNOME/gtk/merge_requests/142
2018-07-30 12:09:41 +02:00
Andrea Azzarone e1a7629a85 window: Fallback to CSD titlebar in focus-chain
CSD titlebar are included in the focus-chain. The logic used makes sure that the
initial focus avoids the titlebar, but tabbing around will eventually get there.
This logic fails in case the window has no other focusable widgets apart from
the ones in the header-bar. If this happens keynav focus will be lost. To handle
the above scenario, we need to fallback to focus the header-bar (if any).

Fixes: https://gitlab.gnome.org/GNOME/gnome-software/issues/404
2018-07-30 09:30:26 +02:00
Matthias Clasen 7d3b8b0d09 treeview: Get rid of child surfaces
Drop the drag-highlight and drag surfaces. The highlighting
is broken anyway, so just drop it for now. And for dragging
the header button, we can just position it properly, that
works just as well as this reparenting approach.
2018-07-29 15:23:41 -04:00
Piotr Drąg fff2fabd7a Update Polish translation 2018-07-29 20:33:24 +02:00
Matthias Clasen 73b45ec77e Migration guide: mention size-allocate
Document the new argument here.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1245
2018-07-29 09:11:39 -04:00
Matthias Clasen 8f95a5980e Remove an outdated comment
We no longer have semi-private headers.
2018-07-29 08:45:34 -04:00
Christian Hergert 87d33470ed vulkan: fix warning from g_clear_pointer() changes 2018-07-28 10:54:14 -07:00
Christian Hergert 002e48c469 imwayland: fix potential leak of attr list
This fixes a potential leak of a PangoAttrList that is set when chaining
up to the parent get_preedit_string(). We check to see if the attr list
was created and reuse it instead of leaking the previous value.
2018-07-28 10:54:14 -07:00
Aurimas Černius f33549da91 Updated Lithuanian translation 2018-07-28 20:35:20 +03:00
Matthias Clasen f3f32b47cc Merge branch 'wip/gtk-menu-popup-no-more' into 'master'
Remove legacy GtkMenu popup APIs

See merge request GNOME/gtk!270
2018-07-27 18:57:24 +00:00
Matthias Clasen 2c5f2a2bcb Merge branch 'color-picker' into 'master'
Color picker

See merge request GNOME/gtk!273
2018-07-27 18:35:05 +00:00
Matthias Clasen b6d990af25 tests: Update a11y tests
Some things changed.
2018-07-27 14:23:20 -04:00
Matthias Clasen 16171a232a Add a color picker implementation for gnome-shell
This adds a GtkColorPicker implementation that talks
to gnome-shell to get a color.
2018-07-27 14:23:20 -04:00
Matthias Clasen 031b5cad46 Add a color picker implementation for portals
This adds a GtkColorPicker implementation that talks
to the screnshot portal to get a color.
2018-07-27 14:23:20 -04:00
Matthias Clasen 984274497d color editor: Add a color picker button
The button is shown if we have a GtkColorPicker implemenation.
Currently, there are none, so the button is never shown.
2018-07-27 14:23:20 -04:00
Matthias Clasen 0cc0714312 Add a color picker interface
This will be used in the color chooser, in subsequent commits.
2018-07-27 14:23:19 -04:00
Matthias Clasen 766e2b1e63 testsuite: Update the list of used icons
We use some more now...
2018-07-27 13:37:00 -04:00
Matthias Clasen c8be597b7f Bring back gtk-orientation icons
These are used in the page setup dialog, so we can't
just drop them.
2018-07-27 13:35:29 -04:00
Jonas Ådahl 4497ac7d75 menu: Remove legacy popup APIs
Remove gtk_menu_popup_for_device() and gtk_menu_popup(), as they cannot
be implemented in a portable manner by all backends. They have been
deprecated for proper alternative APIs for some time, so lets remove
them now before its too late.

While at it, fix the example documentation for mapping a menu.
2018-07-27 17:16:44 +02:00
Jonas Ådahl af21583d4d tests: Stop using legacy gtk_menu_popup API
Use the new portable APIs, so that menus will be positioned properly on
all backends.
2018-07-27 17:16:44 +02:00
segfault 791da76ae1 gtkplacessidebar: Show busy spinner in sidebar row during mount ops 2018-07-27 16:44:50 +02:00
Matthias Clasen d398c00d20 Fix up the resource generation for icons
The script was looking in the wrong subdirectories.
2018-07-27 09:08:27 -04:00
Matthias Clasen cb247276f5 Add emoji category icons
This is a temporary measure to make the check-icon-names
test not fail in ci. We still have to figure out the best
way to include a core icontheme with GTK+.
2018-07-27 08:05:55 -04:00
Matthias Clasen c6141dffd2 Keep picking up icons as resources
We may need to revisit this at some point. For now,
keep the mechanism in place.

This is a partial revert of 806c659efe.
2018-07-27 08:05:55 -04:00
Daniel Mustieles 755d8f8332 Updated Spanish translation 2018-07-27 13:40:20 +02:00
Matthias Clasen 32de29bb68 testsuite: Sort icon names
This is easier to keep track of.
2018-07-27 07:12:23 -04:00
Timm Bäder 540cb58169 Merge branch 'patch-1' into 'master'
doc: Fix there/their typo

See merge request GNOME/gtk!274
2018-07-27 04:47:04 +00:00
Alcaro a1a6e6a36a doc: Fix there/their typo 2018-07-27 02:28:45 +00:00
Timm Bäder 798ad9f62a Merge branch 'g-clear-pointer-propagate' into 'master'
Remove GDestroyNotify casts in g_clear_pointer() uses

See merge request GNOME/gtk!269
2018-07-26 07:34:12 +00:00
Matthias Clasen ad6255a841 Merge branch 'xfixes-timestamp' into 'master'
x11: Ignore old XFixesSelectionNotify events

Closes #14

See merge request GNOME/gtk!259
2018-07-25 11:21:01 +00:00
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 95a4eff6ba render: Make gtk_render_icon() use the snapshot API
This removes a lot of duplicated code.
2018-07-24 20:55:45 +02:00
Benjamin Otte 9675c99043 render: Make gtk_render_frame() and gtk_render_focus() use the snapshot API
This removes a lot of duplicated code.
2018-07-24 20:55:45 +02:00
Benjamin Otte 76d0e1e398 API: Remove gtk_render_frame_gap()
That function does not make sense at all in a CSS world. So better don't
support it anymore.
2018-07-24 20:55:45 +02:00
Benjamin Otte 14408b7485 render: Make gtk_render_background() use the snapshot API
This removes a lot of duplicated code.
2018-07-24 20:55:45 +02:00
Benjamin Otte 2a11baf6ea render: Make gtk_render_check/arrow/handle() use the snapshot API
This removes a lot of duplicated code.
2018-07-24 20:55:45 +02:00
Benjamin Otte 51d40ca023 render: Make gtk_render_layout() use the snapshot API
This removes a lot of duplicated code.
2018-07-24 20:55:45 +02:00
Benjamin Otte 5d9d73b090 testsuite: Fix DragContext => Drag renaming 2018-07-24 20:55:45 +02:00
Benjamin Otte 5f7e093168 gtk: Move GtkGesture declaration to gtktypes.h
That way, headers can use the gesture type without having to include
gtkgesture.h
2018-07-24 20:55:45 +02:00
Benjamin Otte 0f70e6d70a docs: Remove remains of Mir backend 2018-07-24 20:55:45 +02:00
Benjamin Otte 259be23ff2 broadway: Remove unused variable 2018-07-24 20:55:45 +02:00
Daniel Șerbănescu 337eedb513 Update Romanian translation 2018-07-24 18:09:59 +00:00
Nirbheek Chauhan 185354555c Merge branch 'nirbheek/misc-meson-fixes' into 'master'
Fix broadway backend build and graphene as a subproject

Closes #1197 and #1218

See merge request GNOME/gtk!265
2018-07-24 08:29:34 +00:00
Daniel Mustieles 29905d1ce6 Updated Spanish translation 2018-07-24 10:03:20 +02:00
Timm Bäder 73dd73c859 Merge branch 'just-popover-menu-things' into 'master'
Post-gizmo GtkPopoverMenu fixes

See merge request GNOME/gtk!264
2018-07-23 18:55:55 +00:00
Nirbheek Chauhan cfb0df14cc meson: Update pango and gdk-pixbuf wrap locations
See: https://gitlab.gnome.org/GNOME/gtk/issues/1219
2018-07-23 20:17:04 +05:30
Nirbheek Chauhan b343abfa51 meson: Support graphene as a fallback dependency
Don't assume graphene_dep is always a pkg-config dependency.

Closes https://gitlab.gnome.org/GNOME/gtk/issues/1197
2018-07-23 20:17:04 +05:30
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
Daniel Mustieles bbf5d142b3 Updated Spanish translation 2018-07-23 12:10:24 +02:00
Ernestas Kulik 1fbbaef49e testpopover: Don’t set margin in menu box
The gizmo already provides sufficient padding.
2018-07-23 13:05:57 +03:00
Ernestas Kulik d88268c142 gtkpopovermenu: Conditionally chain up in gtk_popover_menu_add()
Otherwise the stack gets parented to the wrong widget and the contents
are never drawn.
2018-07-23 13:01:01 +03:00
Ernestas Kulik 49ae68c2c7 gtkpopovermenu: Drop call to gtk_widget_show()
The stack is already visible.
2018-07-23 13:00:11 +03:00
Matthias Clasen 1d72e3e193 Drop builtin icon test
We don't have these icons anymore.
2018-07-22 17:16:20 +00: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
Bruce Cowan 20deda2bd6 Update British English translation 2018-07-21 11:08:03 +00:00
Benjamin Otte 447b166ed3 Merge branch 'wip/muktupavels/remove-gtk-css-provider-get-default' into 'master'
gtkcssprovider: remove gtk_css_provider_get_default

See merge request GNOME/gtk!256
2018-07-20 14:03:51 +00:00
Christoph Reiter 1b230324ba ci: add hicolor-icon-theme to the docker image
The tests complain about it, not sure if this helps.
2018-07-20 15:04:26 +02:00
Matthias Clasen 806c659efe Drop unused old icons
We don't need to ship the deprecated old stock-id named
icons and the drag cursors - we don't use them from resources
anyway.
2018-07-20 08:06:07 -04:00
Emin Tufan Çetin 51873ebe37 Update Turkish translation 2018-07-20 11:18:15 +00:00
Matthias Clasen 827219e214 Emoji chooser: Also check for hex boxes
We don't want to see those either.
2018-07-19 17:57:19 -04:00
Matthias Clasen 5c9b25c66e moji chooser: Try harder to avoid fallback
We don't want to see any fallback rendering.
The current check was still letting some fallback
combinations through.

Based on work by Julian Sparber.
2018-07-19 17:50:54 -04:00
Matthias Clasen 37e4ae2fbd Quiet a compiler warning
We don't need to handle GDK_CONFIGURE here, so make the
compiler not warn about it.
2018-07-19 17:48:06 -04:00
Matthias Clasen 14f86ae24d testsuite: Add emoji icon names
We check for all icon names that are used in gtk.
2018-07-19 17:48:06 -04:00
Matthias Clasen 849ffebc21 Emoji chooser: Use icons for sections
This is more reliable than using text-style Emoji
which may not be present.

Based on work by Julian Sparber.
2018-07-19 17:47:50 -04:00
Matthias Clasen 7dabc2a42c Merge branch 'master' into 'master'
widgetfactory: add separator tool item to presentation

See merge request GNOME/gtk!249
2018-07-19 18:06:25 +00: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
Matthias Clasen 31d2638088 Merge branch 'content-provider-docs' into 'master'
docs: Fix GdkContentProvider documentation

See merge request GNOME/gtk!254
2018-07-19 17:46:36 +00:00
Ernestas Kulik 40019517cf docs: Fix GdkContentProvider documentation
Currently it’s lacking properties, signals and class vfuncs.
2018-07-19 20:05:19 +03:00
Alberts Muktupāvels 7a8f5ca970 gtkcssprovider: remove gtk_css_provider_get_default
This function is unused since cdc6e82720 commit and does not
contain fallback style.

https://gitlab.gnome.org/GNOME/gtk/issues/1226
2018-07-19 19:25:17 +03:00
Benjamin Otte 4063c3dc31 Merge branch 'content-deserializer-fixes' into 'master'
Content deserializer fixes

See merge request GNOME/gtk!252
2018-07-19 13:59:21 +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
Matthias Clasen 1030d9e5b1 docs: Small updates to the migration guide
Mention that event controllers are available in 3.x, amongst others.
2018-07-18 20:22:18 -04:00
Matthias Clasen 0750b4fd28 Merge branch 'places-sidebar-dnd' into 'master'
placessidebar: Take a GdkDrag in _set_drop_targets_visible()

Closes #1220

See merge request GNOME/gtk!247
2018-07-18 00:23:08 +00:00
Günther Wutz 1d4ce5a544 widgetfactory: add separator tool item to presentation 2018-07-17 21:50:19 +02:00
Ernestas Kulik 4b2d63167e placessidebar: Take a GdkDrag in _set_drop_targets_visible()
Since the function is usually called from GtkWidget::drag-{begin,end} handlers,
taking a GdkDrop does not work, especially given that
::drag-action-requested is emitted without checking the type.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1220
2018-07-17 19:19:14 +03:00
Timm Bäder 6fe0a8c6b3 gesturestylus: Clarify a documentation comment
Use the proper gtkdoc syntax for signals.
2018-07-17 17:33:47 +02:00
Timm Bäder 04eb7eef29 Remove icon extents API 2018-07-17 17:33:47 +02:00
Timm Bäder 480a2c2770 widget: Remove another ->priv usage 2018-07-17 17:33:47 +02:00
Timm Bäder f699fff6e0 sizerequest: Pull locals into closest scope 2018-07-17 17:33:47 +02:00
Timm Bäder 4bc145549d Correctly mark an enum value in a doc comment 2018-07-17 17:33:47 +02:00
Timm Bäder cf7fa931d3 sizerequest: Only check reported baselines if requested
If the passed-in store locations for the baselines are NULL anyway, we
don't need to check the reported baselines for correctness.
2018-07-17 17:33:47 +02:00
Timm Bäder 392b4d9ac5 gl renderer: Pull a few declarations into the closest scope 2018-07-17 17:33:47 +02:00
Timm Bäder 3f126c7fc8 Remove GTK_CSS_AFFECTS_CLIP
Clips don't exist anymore and this flag is unused outside of the style
property definitions in gtkcssstylepropertyimpl.c
2018-07-17 17:33:47 +02:00
Timm Bäder 960717b273 window: Don't queue an allocate if the css clip changes
clips don't exist anymore.
2018-07-17 17:33:47 +02:00
Timm Bäder 5386cf89f2 GskRoundedRect: Typo 2018-07-17 17:33:47 +02:00
Timm Bäder b7d948af69 gl renderer: Use a GArray for the shadow cache
It's very small usually, in default Adwaita the only blurred outset
shadow we have is the one for the CSD'd toplevel window.
2018-07-17 17:33:46 +02: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
Timm Bäder 17b1e7bae9 docs: Fix scroll and motion controller titles
Controller, not Controler.
2018-07-17 17:33:46 +02:00
Emmanuele Bassi 9dc679370c Merge branch 'legacy-gl' into 'master'
fix the OpenGL renderer for legacy contexts

See merge request GNOME/gtk!240
2018-07-17 11:07:27 +00:00
Piotr Drąg 033cf4bfb7 Update POTFILES.in 2018-07-16 16:35:52 +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 89f25d1484 Merge branch 'dnd-cleanups' into 'master'
Dnd cleanups

See merge request GNOME/gtk!243
2018-07-15 22:18:11 +00: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 17386b5cf7 Merge branch 'wip/matthiasc/kill-non-input-events' into 'master'
Wip/matthiasc/kill non input events

See merge request GNOME/gtk!242
2018-07-15 19:50:37 +00: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
Matthias Clasen 443f8ddf6b popover: Drop some dead code
This will be done differently, using xdg-popup instead
of subsurfaces, so no point in keeping this.
2018-07-15 08:18:08 -04:00
Matthias Clasen 6a7de806dd text display: correct a comment 2018-07-14 13:50:14 -04:00
Elias Aebi 19873e549a gl: implement clipping for legacy contexts 2018-07-14 14:31:50 +02:00
Elias Aebi 05ca6bc189 gl: fix compilation errors for legacy context shaders 2018-07-14 14:24:21 +02:00
Benjamin Otte cbb1e74bb5 textview: Only create cairo context in gtktextdisplay.c
Everything else is done using GtkSnapshot now, including renaming the
draw_layer vfunc to snapshot_layer.
2018-07-14 05:27:54 +02: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
Piotr Drąg 60afd056e0 Update POTFILES.in 2018-07-13 15:11:45 +02:00
Benjamin Otte 4456b06853 window: Update opaque region if background-color changes
The opaque region is only set when the background color is opaque. So
we need to do something about it when the background color changes.

However, in the case where a size allocation is going to happen, we
already do this update in size_allocate(), so in that case avoid doing
it twice.
2018-07-13 14:56:04 +02:00
Benjamin Otte 2f72353e0e gtk-demo: Update aspect-ratio when selecting new puzzle 2018-07-13 14:56:04 +02:00
Benjamin Otte 88af7b44aa textview: Use snapshot on the sidebars 2018-07-13 14:56:04 +02:00
Benjamin Otte a7cd1918a8 widgetpaintable: Add a hack to make recursion not infloop
Makes the GUADEC talk not crash that I'm supposed to give in 20 minutes.
2018-07-13 14:56:04 +02:00
Benjamin Otte bcfd1bbd24 widgetpaintable: Redo implementation
Instead of instantly invalidating, we now cache the old render node and
do the update in an idle handler.
While that gives us a 1 frame delay, it avoids all the tricky things
like queueing resizes while resizing or queueing draws while drawing.

The only remaining issue (and a *big* one at that) is that a nested
widget paintable will now cause the widget to snapshot its previous
render node when creating a new one. And that one will snapshot its
previous render node, and that one will...
And nothing so far breaks this recursion.
2018-07-13 14:56:04 +02:00
Benjamin Otte 1a5e60be7c paintable: Fix return_if_fail() statements
I always switch them up...
2018-07-13 14:56:04 +02:00
Benjamin Otte 3ce3867403 gl: Don't accidentally use ints for float variables
The int was floor()ing the x/y coordinates of glyphs, which could cause
significant repositioning of glyphs when text was scaled via the MVP.
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 986daa8225 Merge branch 'dnd-cleanups' into 'master'
Dnd cleanups

See merge request GNOME/gtk!228
2018-07-13 07:45:57 +00:00
Matthias Clasen e72ca43a32 Merge branch 'fix-wayland' into 'master'
GtkIMContextSimple: Fix Wayland build when X11 support is disabled

See merge request GNOME/gtk!234
2018-07-12 12:18:59 +00: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 b94c3166bf dnd: Rename gtk_drag_begin_with_coordinates
Now that the coordiate-less variant is gone,
rename this back to the shorter gtk_drag_begin.
2018-07-12 13:02:42 +02:00
Daniel Boles 7030e08f9c Merge branch 'master' into 'master'
HighContrast: Restore expander size

Closes #1046

See merge request GNOME/gtk!167
2018-07-09 17:28:49 +00:00
Timm Bäder 2cc6a3ee5c widget factory: Use GtkPicture for background selection
Showing those background images as 16×16 icons doesn't look very nice.
2018-07-08 21:50:59 +02:00
Timm Bäder 3dd188fe7e gl renderer: Cache blurred outset shadow nodes
Since these are particularly expensive to render and we have a pretty
big one used in every client-side decorated window.
2018-07-08 21:50:59 +02:00
Timm Bäder d41603d82a aboutdialog: Remove priv pointer 2018-07-08 21:50:59 +02:00
Timm Bäder f7aff03c72 layout: Remove priv pointer 2018-07-08 21:50:59 +02:00
Timm Bäder a0b8e32462 rendernodes: Fix unconditionally impossible diffs
Some of the _diff implementations did a whole bunch of work just to
throw it away afterwards and invalidate the entire union of the two
render nodes, most notably the two clip nodes. Fix this to only call
gsk_render_node_diff_impossible if the previous if-condition is FALSE
and not always.
2018-07-08 21:50:59 +02:00
Timm Bäder 50f76eb8cc GskRenderer: Add missing nullable annotation 2018-07-08 21:50:59 +02:00
Timm Bäder 9959ea98cd Revert "snapshot: merge container nodes"
This reverts commit 622a150bb4.
2018-07-08 21:50:59 +02:00
Emmanuel Gil Peyrot 8ca3ac1970 GtkIMContextSimple: Fix Wayland build when X11 support is disabled. 2018-07-08 20:11:01 +02:00
Balázs Meskó 27ba2411f0 Update Hungarian translation 2018-07-08 14:04:15 +00:00
Timm Bäder a6920855ea Implement GtkInspectorLayoutOverlay
To properly replace the old "show layout borders" option.
2018-07-08 11:26:12 +02:00
Timm Bäder c85e2401fa treeview: Fix column visibility check
This is still fallout from the bin_window removal. We aren't moving the
GdkWindow/GdkSurface anymore so we have to account for the scrolling
ourselves.
2018-07-08 10:32:12 +02:00
Timm Bäder 6fdcafc94a treeview: Move column header widgets when scrolling
Since those are widgets and widgets need to be size-allocate'd properly,
we need to queue an allocate, as well as actually add the hadjustment's
value to the column x position.

Fixes #1202
2018-07-08 10:04:27 +02:00
Timm Bäder 9bab218314 aspectframe: Remove priv pointer 2018-07-08 10:02:43 +02:00
Timm Bäder 2854635850 scalebutton: Remove priv pointer 2018-07-08 09:41:15 +02:00
Timm Bäder a976aa9740 searchbar: Ignore key presses when unmapped
The purpose of a searchbar is to start a search on visible widgets when
a key is pressed. Starting a search on e.g. a stack page that is not
visible at all is not very useful.
2018-07-08 09:41:15 +02:00
Timm Bäder 074eb2a19d accellabel: Add newline between consecutive if statements 2018-07-08 09:41:15 +02:00
Timm Bäder 96812450fa listbox demo: Hide extra_buttons_box by default
It should only show up when hovering the row.
2018-07-08 09:41:15 +02:00
Timm Bäder 93c688cd93 range: Remove has_origin flag
It's equivalent to the highlight_widget being !NULL.
2018-07-08 09:41:15 +02:00
Timm Bäder 53afc4a9d9 dialog: Remove priv pointer 2018-07-08 09:41:15 +02:00
Timm Bäder c96077590b dialog: Remove some GtkVBox references 2018-07-08 09:41:15 +02:00
Timm Bäder 6e47d0bf4a GtkSeparatorToolItem: Remove draw flag
We can as well query the current value of the flag using
gtk_style_context_has_class.
2018-07-08 09:41:15 +02:00
Timm Bäder 50b79ae0ab GtkSeparatorToolItem: Remove priv pointer 2018-07-08 09:41:15 +02:00
Timm Bäder 6b4709ea3c GtkApplication: Remove priv pointer 2018-07-08 09:41:15 +02:00
Timm Bäder f3a83abb54 colorswatch: Remove priv pointer 2018-07-08 09:41:15 +02:00
Timm Bäder 33166b7357 render: Remove gtk_render_slider
The only thing it was doing is render background and frame, which you
get from using a widget for your slider anyway.
2018-07-08 09:41:15 +02:00
Timm Bäder bb31ce1168 renderborder: Remove some unused API 2018-07-08 09:41:15 +02:00
Timm Bäder dbf32933bf main: Don't look at first GTK_DISPLAY_DEBUG_CHECK parameter...
... if none of the debug displays have any debug flags set. This way, we
can ignore the first parameter to e.g. GTK_DISPLAY_NOTE, which is
usually a call to gtk_widget_get_display.

Before this patch, gtk_widget_get_display was the slowest part of
gtk_widget_query_size_for_orientation.
2018-07-08 09:41:15 +02:00
Timm Bäder af8fe182c8 Fix a few documentation warnings 2018-07-08 09:41:15 +02:00
Timm Bäder 731f0d4d01 Merge branch 'gtk-picture-docs' into 'master'
docs: Add GtkPicture to types list

See merge request GNOME/gtk!233
2018-07-07 06:30:37 +00:00
Thomas Bechtold e42373df89 docs: Add GtkPicture to types list
We want signals, arguments/parameters and position in the hierarchy to
be shown in the documentation for GtkPicture. So fix the types list.

See
https://developer.gnome.org/gtk-doc-manual/unstable/metafiles_types.html.en
2018-07-06 22:14:26 +02:00
Timm Bäder da8050979e fixed: Remove child list
Use the child widget list from GtkWidget and attach x/y positions via a
qdata.
2018-07-05 19:08:19 +02:00
Timm Bäder 4dd1ff6dd2 GtkLayout: Remove freeze_count member
Unused.
2018-07-05 19:08:19 +02:00
Timm Bäder 8c403c43f0 spinbutton: Keep GParamSpecs around
notify_by_pspec is more efficient and this way the source file is more
in line with the others.
2018-07-05 19:08:19 +02:00
Emmanuele Bassi 2feb5c93ca ci: Update the image for the Flatpak jobs
The gnome-nightly-oci registry was moved to gitlab.gnome.org, so we
need to change the image we use when building Flatpak bundles in our
CI pipeline.
2018-07-04 18:32:59 +01:00
Emmanuele Bassi 9924a92e70 Merge branch '1140-gtk_printer_get_hard_margins_for_paper_size-is-not-external' into 'master'
Resolve "gtk_printer_get_hard_margins_for_paper_size() is not external"

Closes #1140

See merge request GNOME/gtk!229
2018-07-04 16:55:34 +00:00
Kjell Ahlstedt 6c8988e445 gtkprinter: Make gtk_printer_get_hard_margins_for_paper_size() public
The declaration in gtkprinter.h shall be preceded by GDK_AVAILABLE_IN_ALL,
or else the function can't be used in application programs.

Closes #1140
2018-07-04 18:40:33 +02:00
Benjamin Otte 9fb3b84253 rendernode: Make offset nodes use floats
It's OpenGL stuff, use floats.
2018-07-04 15:05:37 +02:00
Benjamin Otte 3439862634 gtkmediafile: Don't leak all the images
We were leaking the GBytes for the image memory, which is a
noticeable memleak to anyone who's casually running a memory monitor.

Go KDE users!

Closes #1200
2018-07-04 15:05:02 +02:00
Benjamin Otte 93c5455796 iconhelper: Plug memleak 2018-07-04 15:04:04 +02:00
Benjamin Otte e665667bff mediafile: Check if media files are open when trying to play
If no file is open, refuse to play.
2018-07-04 06:15:33 +02:00
Benjamin Otte 3ca59b8701 css: Don't do indirections
We don't need to look up the property by name to query its ID when we
know the ID already because it's inside an enum.
2018-07-04 06:15:33 +02:00
Benjamin Otte fba0b359d4 css: Report sizes as absolute
All PangoFontDescriptions that GTK creates now use
pango_font_description_set_absolute_size().
2018-07-04 06:15:33 +02:00
Benjamin Otte e1b6496af7 image: size request is always CONSTANT_SIZE
It's always -gtk-icon-size in both directions, even for paintables.
There's no width-for-height happening.
2018-07-04 06:15:33 +02:00
Daniel Boles 14620423e8 themes: Restore default progressbar min sizes
The min size on the oriented axis used to come from style props with
default values in the source file, used if the theme did not provide a
min size in CSS. When the style props were removed, so was any notion of
a minimal size for proressbars' main axis, meaning that now progressbars
without expand or any other source of min size were just tiny specks.

The right place to do that was always the theme, so in our themes now,
fix that by copying the old default values for the style properties; see:

https://gitlab.gnome.org/GNOME/gtk/issues/1191#note_259393
https://gitlab.gnome.org/GNOME/gtk/blob/gtk-3-24/gtk/gtkprogressbar.c#L92

The result should be the same in that (A) the min size is now what it is
in GTK+ 3 & (B) an app/user can override the theme exactly the same way.

Close https://gitlab.gnome.org/GNOME/gtk/issues/1192
2018-07-03 18:55:31 +01:00
Daniel Boles 55a1f8ccfd HC: merge dupe selectors; linebreaks for legibility 2018-07-03 18:55:17 +01:00
Timm Bäder 19afe454df Merge branch 'gdk4-dnd-docs' into 'master'
docs: Add new DnD types

See merge request GNOME/gtk!227
2018-07-03 17:28:44 +00:00
Piotr Drąg 7d842cb7fc Update POTFILES.in 2018-07-03 17:11:00 +02:00
Ernestas Kulik 3137d326c5 docs: Add new DnD types
7733f646d6 renamed GdkDragContext to
GdkDrag, which broke the docs, as a reference to
gdk_drag_context_get_type() still exists. This commit renames the type
accordingly and adds GdkDrop.
2018-07-03 12:32:41 +03: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
Daniel Boles 269a9d8528 Adwaita: Drop some unneeded overrides
The pseudoclasses work fine on the subnodes without having to also apply
`parent:class subnode`.
2018-07-02 22:04:35 +01:00
Daniel Boles c892d2767a Adwaita: Regenerate CSS for text handle overhaul
Commit b3e91b7111 forgot this.
2018-07-02 22:04:35 +01:00
Matthias Clasen c8e082f296 win32: Adapt to dnd api changes
Follow the GdkDragContext -> GdkDrag change.
2018-07-02 22:52:59 +02:00
Daniel Boles 51981d562b ScrolledWindow: a couple of spelling/grammar fixes
(A) Put a space in "scrolled window" like the other doc comments
(B) Say "i.e." rather than "ie."
(C) Fix grammar from "makes [...] exactly reaches" to "exactly reach"
2018-07-02 20:14:41 +01:00
Daniel Boles 51b77a425a ScrolledWindow: Fix/improve doc of key bindings
Saying 'key + modifiers' is really weird, so reverse that, and explain
why there are 2 cited and what the difference between them is.
2018-07-02 20:14:41 +01:00
Daniel Boles ae3163b5e0 ScrolledWindow: Add missing apostrophes 2018-07-02 20:14:41 +01:00
Matthias Clasen af93646b3e Merge branch 'event-controller-key-docs' into 'master'
eventcontrollerkey: Document key-pressed and key-released

See merge request GNOME/gtk!225
2018-07-02 17:16:04 +00: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 fb98f939a5 docs: Update dnd section
Add the separate drag and drop apis.
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
Ernestas Kulik fd69f1cd79 eventcontrollerkey: Document key-pressed and key-released
None of the GtkEventControllerKey signals are documented; this commit
adds documentation for a couple of them.
2018-07-02 12:18:26 +03:00
Daniel Boles ca94ff10ce testsuite/gtk/defaultvalue: Actually build...& fix
It looks like this got dropped during the move from autotools and never
restored. I can see why, since making it work wasn't a hugely fun task!

Notes on some less then obvious details:
 * PlacesSidebar is private now and didn't seem to be to be particularly
   easy to adapt to, so this moves to checking for it by name, not TYPE.
   I couldn't find a (fast) better way; if you know how, please clean up
 * added 2 casts to avoid warnings from the new type-propagating ref()
 * GdkClipboard and GdkContentProvider need some properties dodged
 * GtkToolItemGroup is gone
 * fixed indentation and used TypeName:property-name syntax in a print()
2018-06-29 20:05:21 +01: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
Matthias Clasen d9dcfffce3 Merge branch 'wip/aplazas/modelbutton-markup-master' into 'master'
ModelButton: Add 'use-markup' property

See merge request GNOME/gtk!222
2018-06-29 14:21:24 +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
Benjamin Otte f3c670ab0c widget: Move opactiy == 0 check
If we check it too early, we will not unset priv->draw_neeeded, which
will then cause queue_draw() calls to not have an effect later. And that
causes changes in opacity to not register.

Closes #1180
2018-06-27 21:50:07 +02:00
Daniel Boles 8aa4b5150e notify test: Remove more nonexistent properties 2018-06-27 17:17:05 +01:00
Timm Bäder ecaa16c367 notify test: Remove some non-existant properties 2018-06-27 18:03:23 +02:00
Timm Bäder 2f8284a386 testsuite: Remove a GtkColorButton special case
The comment above explains neatly why subclassing GtkButton for
GtkColorButton was a bad idea. Nowadays it's a GtkWidget subclass
containing a GtkButton so let's remove the special case here.
2018-06-27 18:03:23 +02:00
Timm Bäder 73cad1e784 Remove some GtkRecentChooserMenu references
Doesn't exist anymore.
2018-06-27 18:03:23 +02:00
Adrien Plazas 0abd01e288 ModelButton: Add 'use-markup' property
Binds this property to the button's label, allowing a model button to
have text with markup.

This will be convenient for buttons like 'Online Accounts <sup>↗</sup>'.
2018-06-27 17:43:47 +02:00
Rico Tzschichholz b80942ec88 gdk: Fix some g-i annotations warnings 2018-06-27 09:00:17 +02:00
Timm Bäder 165dab8265 gl renderer: Ignore 0-sized fallback nodes 2018-06-26 21:41:29 +02:00
Emmanuele Bassi 73d736d800 Do not modify a const GdkEvent in place
When deciding whether or not to emulate a press event, we're translating
the last event coordinates and mutating the given event structure
unconditionally.

We should modify the newly created GdkEvent copy, since it's what we're
going to use when emitting the press event.

This avoids mutating a constant GdkEvent and global state, and also
avoids a compiler warning.
2018-06-26 18:06:23 +01:00
Matthias Clasen 88b4076fe5 Docs: Remove more since markers
The idea is that GTK+ 4 will be an epoch, API-wise.
Everything that was around for 4.0 has been there
since the beginning of the epoch and doesn't need
markers.
2018-06-26 12:31:41 -04:00
Matthias Clasen 36396093e6 docs: Document GtkEventControllerKey
The long description was missing.
2018-06-26 12:20:47 -04:00
Samuel Thibault bada3dbac6 HighContrast: Restore expander size
Expanders used to be 16px high. With the move from the gtk2 rendering
to gtk3 rendering they shrunk to 12px, making them hard to see, because
it's now the icon which is 16px high and the icon contains transparent
borders.

This makes the HighContrast theme use 24px icons instead, to restore
16px expanders. This may expander some containers a bit.

Closes #1046
2018-06-21 16:15:35 +02:00
Daniel Boles 9178423844 TreeView: Get expander size from CSS min-width|height
Rather than hard-coding this, get it from CSS. That way, themes will be
able to set larger expanders than a fixed 16 px, e.g. for accessibility.

See https://gitlab.gnome.org/GNOME/gtk/merge_requests/167
2018-06-21 15:49:00 +02:00
365 changed files with 18778 additions and 16997 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ msys2-mingw32:
<<: *mingw-defaults
.flatpak-defaults: &flatpak-defaults
image: registry.gitlab.com/alatiera/gnome-nightly-oci/gnome-master:latest
image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master
stage: flatpak
artifacts:
paths:
+1
View File
@@ -1,6 +1,7 @@
FROM fedora:28
RUN dnf -y install \
hicolor-icon-theme \
adwaita-icon-theme \
atk-devel \
at-spi2-atk-devel \
+13 -9
View File
@@ -87,14 +87,14 @@ find_toplevel_at_pointer (GdkDisplay *display)
return widget ? gtk_widget_get_toplevel (widget) : NULL;
}
static gboolean
release_event_cb (GtkWidget *widget,
GdkEvent *event,
gboolean *clicked)
static void
released_cb (GtkGestureMultiPress *gesture,
guint n_press,
gdouble x,
gdouble y,
gboolean *clicked)
{
if (gdk_event_get_event_type (event) == GDK_BUTTON_RELEASE)
*clicked = TRUE;
return TRUE;
*clicked = TRUE;
}
/* Asks the user to click on a window, then waits for them click
@@ -132,10 +132,12 @@ query_for_toplevel (GdkDisplay *display,
GDK_SEAT_CAPABILITY_ALL_POINTING,
FALSE, cursor, NULL, NULL, NULL) == GDK_GRAB_SUCCESS)
{
GtkGesture *gesture = gtk_gesture_multi_press_new ();
gboolean clicked = FALSE;
g_signal_connect (popup, "event",
G_CALLBACK (release_event_cb), &clicked);
g_signal_connect (gesture, "released",
G_CALLBACK (released_cb), &clicked);
gtk_widget_add_controller (popup, GTK_EVENT_CONTROLLER (gesture));
/* Process events until clicked is set by our button release event handler.
* We pass in may_block=TRUE since we want to wait if there
@@ -144,6 +146,8 @@ query_for_toplevel (GdkDisplay *display,
while (!clicked)
g_main_context_iteration (NULL, TRUE);
gdk_seat_ungrab (gdk_device_get_seat (device));
toplevel = find_toplevel_at_pointer (display);
if (toplevel == popup)
toplevel = NULL;
+3 -3
View File
@@ -120,7 +120,7 @@ get_image_paintable (GtkImage *image)
static void
drag_begin (GtkWidget *widget,
GdkDragContext *context,
GdkDrag *drag,
gpointer data)
{
GdkPaintable *paintable;
@@ -128,14 +128,14 @@ drag_begin (GtkWidget *widget,
paintable = get_image_paintable (GTK_IMAGE (widget));
if (paintable)
{
gtk_drag_set_icon_paintable (context, paintable, -2, -2);
gtk_drag_set_icon_paintable (drag, paintable, -2, -2);
g_object_unref (paintable);
}
}
void
drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GdkDrag *drag,
GtkSelectionData *selection_data,
guint info,
gpointer data)
-1
View File
@@ -161,7 +161,6 @@
<file>editable_cells.c</file>
<file>entry_buffer.c</file>
<file>entry_completion.c</file>
<file>event_axes.c</file>
<file>expander.c</file>
<file>filtermodel.c</file>
<file>fishbowl.c</file>
-666
View File
@@ -1,666 +0,0 @@
/* Touch and Drawing Tablets
*
* Demonstrates advanced handling of event information from exotic
* input devices.
*
* On one hand, this snippet demonstrates management of drawing tablets,
* those contain additional information for the pointer other than
* X/Y coordinates. Tablet pads events are mapped to actions, which
* are both defined and interpreted by the application.
*
* Input axes are dependent on hardware devices, on linux/unix you
* can see the device axes through xinput list <device>. Each time
* a different hardware device is used to move the pointer, the
* master device will be updated to match the axes it provides,
* these changes can be tracked through GdkDevice::changed, or
* checking gdk_event_get_source_device().
*
* On the other hand, this demo handles basic multitouch events,
* each event coming from an specific touchpoint will contain a
* GdkEventSequence that's unique for its lifetime, so multiple
* touchpoints can be tracked.
*/
#include <glib/gi18n.h>
#include <gtk/gtk.h>
typedef struct {
GdkDevice *last_source;
GdkDeviceTool *last_tool;
gdouble *axes;
GdkRGBA color;
gdouble x;
gdouble y;
} AxesInfo;
typedef struct {
GHashTable *pointer_info; /* GdkDevice -> AxesInfo */
GHashTable *touch_info; /* GdkEventSequence -> AxesInfo */
} EventData;
const gchar *colors[] = {
"black",
"orchid",
"fuchsia",
"indigo",
"thistle",
"sienna",
"azure",
"plum",
"lime",
"navy",
"maroon",
"burlywood"
};
static GtkPadActionEntry pad_actions[] = {
{ GTK_PAD_ACTION_BUTTON, 1, -1, N_("Nuclear strike"), "pad.nuke" },
{ GTK_PAD_ACTION_BUTTON, 2, -1, N_("Release siberian methane reserves"), "pad.heat" },
{ GTK_PAD_ACTION_BUTTON, 3, -1, N_("Release solar flare"), "pad.fry" },
{ GTK_PAD_ACTION_BUTTON, 4, -1, N_("De-stabilize Oort cloud"), "pad.fall" },
{ GTK_PAD_ACTION_BUTTON, 5, -1, N_("Ignite WR-104"), "pad.burst" },
{ GTK_PAD_ACTION_BUTTON, 6, -1, N_("Lart whoever asks about this button"), "pad.lart" },
{ GTK_PAD_ACTION_RING, -1, -1, N_("Earth axial tilt"), "pad.tilt" },
{ GTK_PAD_ACTION_STRIP, -1, -1, N_("Extent of weak nuclear force"), "pad.dissolve" },
};
static const gchar *pad_action_results[] = {
"",
"",
"",
"",
"",
"💫",
"",
""
};
static guint cur_color = 0;
static guint pad_action_timeout_id = 0;
static AxesInfo *
axes_info_new (void)
{
AxesInfo *info;
info = g_new0 (AxesInfo, 1);
gdk_rgba_parse (&info->color, colors[cur_color]);
cur_color = (cur_color + 1) % G_N_ELEMENTS (colors);
return info;
}
static EventData *
event_data_new (void)
{
EventData *data;
data = g_new0 (EventData, 1);
data->pointer_info = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) g_free);
data->touch_info = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) g_free);
return data;
}
static void
event_data_free (EventData *data)
{
g_hash_table_destroy (data->pointer_info);
g_hash_table_destroy (data->touch_info);
g_free (data);
}
static void
update_axes_from_event (GdkEvent *event,
EventData *data)
{
GdkDevice *device, *source_device;
GdkEventSequence *sequence;
GdkDeviceTool *tool;
GdkEventType type;
gdouble x, y;
AxesInfo *info;
device = gdk_event_get_device (event);
source_device = gdk_event_get_source_device (event);
sequence = gdk_event_get_event_sequence (event);
tool = gdk_event_get_device_tool (event);
type = gdk_event_get_event_type (event);
if (type == GDK_TOUCH_END ||
type == GDK_TOUCH_CANCEL)
{
g_hash_table_remove (data->touch_info, sequence);
return;
}
else if (type == GDK_LEAVE_NOTIFY)
{
g_hash_table_remove (data->pointer_info, device);
return;
}
if (!source_device)
return;
if (!sequence)
{
info = g_hash_table_lookup (data->pointer_info, device);
if (!info)
{
info = axes_info_new ();
g_hash_table_insert (data->pointer_info, device, info);
}
}
else
{
info = g_hash_table_lookup (data->touch_info, sequence);
if (!info)
{
info = axes_info_new ();
g_hash_table_insert (data->touch_info, sequence, info);
}
}
if (info->last_source != source_device)
info->last_source = source_device;
if (info->last_tool != tool)
info->last_tool = tool;
g_clear_pointer (&info->axes, g_free);
if (type == GDK_TOUCH_BEGIN ||
type == GDK_TOUCH_UPDATE)
{
gboolean emulating_pointer;
gdk_event_get_touch_emulating_pointer (event, &emulating_pointer);
if (sequence && emulating_pointer)
g_hash_table_remove (data->pointer_info, device);
}
if (type == GDK_MOTION_NOTIFY ||
type == GDK_BUTTON_PRESS ||
type == GDK_BUTTON_RELEASE)
{
gdouble *axes;
guint n_axes;
gdk_event_get_axes (event, &axes, &n_axes);
info->axes = g_memdup (axes, sizeof (double) * n_axes);
}
if (gdk_event_get_coords (event, &x, &y))
{
info->x = x;
info->y = y;
}
}
static gboolean
event_cb (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
update_axes_from_event (event, user_data);
gtk_widget_queue_draw (widget);
return FALSE;
}
static void
render_arrow (cairo_t *cr,
gdouble x_diff,
gdouble y_diff,
const gchar *label)
{
cairo_save (cr);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_new_path (cr);
cairo_move_to (cr, 0, 0);
cairo_line_to (cr, x_diff, y_diff);
cairo_stroke (cr);
cairo_move_to (cr, x_diff, y_diff);
cairo_show_text (cr, label);
cairo_restore (cr);
}
static void
draw_axes_info (cairo_t *cr,
AxesInfo *info,
int width,
int height)
{
gdouble pressure, tilt_x, tilt_y, distance, wheel, rotation, slider;
GdkAxisFlags axes = gdk_device_get_axes (info->last_source);
cairo_save (cr);
cairo_set_line_width (cr, 1);
gdk_cairo_set_source_rgba (cr, &info->color);
cairo_move_to (cr, 0, info->y);
cairo_line_to (cr, width, info->y);
cairo_move_to (cr, info->x, 0);
cairo_line_to (cr, info->x, height);
cairo_stroke (cr);
cairo_translate (cr, info->x, info->y);
if (!info->axes)
{
cairo_restore (cr);
return;
}
if (axes & GDK_AXIS_FLAG_PRESSURE)
{
cairo_pattern_t *pattern;
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_PRESSURE,
&pressure);
pattern = cairo_pattern_create_radial (0, 0, 0, 0, 0, 100);
cairo_pattern_add_color_stop_rgba (pattern, pressure, 1, 0, 0, pressure);
cairo_pattern_add_color_stop_rgba (pattern, 1, 0, 0, 1, 0);
cairo_set_source (cr, pattern);
cairo_arc (cr, 0, 0, 100, 0, 2 * G_PI);
cairo_fill (cr);
cairo_pattern_destroy (pattern);
}
if (axes & GDK_AXIS_FLAG_XTILT &&
axes & GDK_AXIS_FLAG_YTILT)
{
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_XTILT,
&tilt_x);
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_YTILT,
&tilt_y);
render_arrow (cr, tilt_x * 100, tilt_y * 100, "Tilt");
}
if (axes & GDK_AXIS_FLAG_DISTANCE)
{
double dashes[] = { 5.0, 5.0 };
cairo_text_extents_t extents;
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_DISTANCE,
&distance);
cairo_save (cr);
cairo_move_to (cr, distance * 100, 0);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_set_dash (cr, dashes, 2, 0.0);
cairo_arc (cr, 0, 0, distance * 100, 0, 2 * G_PI);
cairo_stroke (cr);
cairo_move_to (cr, 0, -distance * 100);
cairo_text_extents (cr, "Distance", &extents);
cairo_rel_move_to (cr, -extents.width / 2, 0);
cairo_show_text (cr, "Distance");
cairo_move_to (cr, 0, 0);
cairo_restore (cr);
}
if (axes & GDK_AXIS_FLAG_WHEEL)
{
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_WHEEL,
&wheel);
cairo_save (cr);
cairo_set_line_width (cr, 10);
cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
cairo_new_sub_path (cr);
cairo_arc (cr, 0, 0, 100, 0, wheel * 2 * G_PI);
cairo_stroke (cr);
cairo_restore (cr);
}
if (axes & GDK_AXIS_FLAG_ROTATION)
{
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_ROTATION,
&rotation);
rotation *= 2 * G_PI;
cairo_save (cr);
cairo_rotate (cr, - G_PI / 2);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
cairo_set_line_width (cr, 5);
cairo_new_sub_path (cr);
cairo_arc (cr, 0, 0, 100, 0, rotation);
cairo_stroke (cr);
cairo_restore (cr);
}
if (axes & GDK_AXIS_FLAG_SLIDER)
{
cairo_pattern_t *pattern, *mask;
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_SLIDER,
&slider);
cairo_save (cr);
cairo_move_to (cr, 0, -10);
cairo_rel_line_to (cr, 0, -50);
cairo_rel_line_to (cr, 10, 0);
cairo_rel_line_to (cr, -5, 50);
cairo_close_path (cr);
cairo_clip_preserve (cr);
pattern = cairo_pattern_create_linear (0, -10, 0, -60);
cairo_pattern_add_color_stop_rgb (pattern, 0, 0, 1, 0);
cairo_pattern_add_color_stop_rgb (pattern, 1, 1, 0, 0);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
mask = cairo_pattern_create_linear (0, -10, 0, -60);
cairo_pattern_add_color_stop_rgba (mask, 0, 0, 0, 0, 1);
cairo_pattern_add_color_stop_rgba (mask, slider, 0, 0, 0, 1);
cairo_pattern_add_color_stop_rgba (mask, slider, 0, 0, 0, 0);
cairo_pattern_add_color_stop_rgba (mask, 1, 0, 0, 0, 0);
cairo_mask (cr, mask);
cairo_pattern_destroy (mask);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_stroke (cr);
cairo_restore (cr);
}
cairo_restore (cr);
}
static const gchar *
tool_type_to_string (GdkDeviceToolType tool_type)
{
switch (tool_type)
{
case GDK_DEVICE_TOOL_TYPE_PEN:
return "Pen";
case GDK_DEVICE_TOOL_TYPE_ERASER:
return "Eraser";
case GDK_DEVICE_TOOL_TYPE_BRUSH:
return "Brush";
case GDK_DEVICE_TOOL_TYPE_PENCIL:
return "Pencil";
case GDK_DEVICE_TOOL_TYPE_AIRBRUSH:
return "Airbrush";
case GDK_DEVICE_TOOL_TYPE_MOUSE:
return "Mouse";
case GDK_DEVICE_TOOL_TYPE_LENS:
return "Lens cursor";
case GDK_DEVICE_TOOL_TYPE_UNKNOWN:
default:
return "Unknown";
}
}
static void
draw_device_info (GtkWidget *widget,
cairo_t *cr,
GdkEventSequence *sequence,
gint *y,
AxesInfo *info)
{
PangoLayout *layout;
GString *string;
gint height;
cairo_save (cr);
string = g_string_new (NULL);
g_string_append_printf (string, "Source: %s",
gdk_device_get_name (info->last_source));
if (sequence)
g_string_append_printf (string, "\nSequence: %d",
GPOINTER_TO_UINT (sequence));
if (info->last_tool)
{
const gchar *tool_type;
guint64 serial;
tool_type = tool_type_to_string (gdk_device_tool_get_tool_type (info->last_tool));
serial = gdk_device_tool_get_serial (info->last_tool);
g_string_append_printf (string, "\nTool: %s", tool_type);
if (serial != 0)
g_string_append_printf (string, ", Serial: %" G_GINT64_MODIFIER "x", serial);
}
cairo_move_to (cr, 10, *y);
layout = gtk_widget_create_pango_layout (widget, string->str);
pango_cairo_show_layout (cr, layout);
cairo_stroke (cr);
pango_layout_get_pixel_size (layout, NULL, &height);
gdk_cairo_set_source_rgba (cr, &info->color);
cairo_set_line_width (cr, 10);
cairo_move_to (cr, 0, *y);
*y = *y + height;
cairo_line_to (cr, 0, *y);
cairo_stroke (cr);
cairo_restore (cr);
g_object_unref (layout);
g_string_free (string, TRUE);
}
static void
draw_cb (GtkDrawingArea *da,
cairo_t *cr,
int width,
int height,
gpointer user_data)
{
GtkWidget *widget = GTK_WIDGET (da);
EventData *data = user_data;
AxesInfo *info;
GHashTableIter iter;
gpointer key, value;
gint y = 0;
/* Draw Abs info */
g_hash_table_iter_init (&iter, data->pointer_info);
while (g_hash_table_iter_next (&iter, NULL, &value))
{
info = value;
draw_axes_info (cr, info, width, height);
}
g_hash_table_iter_init (&iter, data->touch_info);
while (g_hash_table_iter_next (&iter, NULL, &value))
{
info = value;
draw_axes_info (cr, info, width, height);
}
/* Draw name, color legend and misc data */
g_hash_table_iter_init (&iter, data->pointer_info);
while (g_hash_table_iter_next (&iter, NULL, &value))
{
info = value;
draw_device_info (widget, cr, NULL, &y, info);
}
g_hash_table_iter_init (&iter, data->touch_info);
while (g_hash_table_iter_next (&iter, &key, &value))
{
info = value;
draw_device_info (widget, cr, key, &y, info);
}
}
static void
update_label_text (GtkWidget *label,
const gchar *text)
{
gchar *markup = NULL;
if (text)
markup = g_strdup_printf ("<span font='48.0'>%s</span>", text);
gtk_label_set_markup (GTK_LABEL (label), markup);
g_free (markup);
}
static gboolean
reset_label_text_timeout_cb (gpointer user_data)
{
GtkWidget *label = user_data;
update_label_text (label, NULL);
pad_action_timeout_id = 0;
return G_SOURCE_REMOVE;
}
static void
update_label_and_timeout (GtkWidget *label,
const gchar *text)
{
if (pad_action_timeout_id)
g_source_remove (pad_action_timeout_id);
update_label_text (label, text);
pad_action_timeout_id = g_timeout_add (200, reset_label_text_timeout_cb, label);
}
static void
on_action_activate (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GtkWidget *label = user_data;
const gchar *result;
gchar *str;
result = g_object_get_data (G_OBJECT (action), "action-result");
if (!parameter)
update_label_and_timeout (label, result);
else
{
str = g_strdup_printf ("%s %.2f", result, g_variant_get_double (parameter));
update_label_and_timeout (label, str);
g_free (str);
}
}
static void
init_pad_controller (GtkWidget *window,
GtkWidget *label)
{
GtkPadController *pad_controller;
GSimpleActionGroup *action_group;
GSimpleAction *action;
gint i;
action_group = g_simple_action_group_new ();
pad_controller = gtk_pad_controller_new (G_ACTION_GROUP (action_group),
NULL);
for (i = 0; i < G_N_ELEMENTS (pad_actions); i++)
{
if (pad_actions[i].type == GTK_PAD_ACTION_BUTTON)
{
action = g_simple_action_new (pad_actions[i].action_name, NULL);
}
else
{
action = g_simple_action_new_stateful (pad_actions[i].action_name,
G_VARIANT_TYPE_DOUBLE, NULL);
}
g_signal_connect (action, "activate",
G_CALLBACK (on_action_activate), label);
g_object_set_data (G_OBJECT (action), "action-result",
(gpointer) pad_action_results[i]);
g_action_map_add_action (G_ACTION_MAP (action_group), G_ACTION (action));
g_object_unref (action);
}
gtk_pad_controller_set_action_entries (pad_controller, pad_actions,
G_N_ELEMENTS (pad_actions));
gtk_widget_add_controller (window, GTK_EVENT_CONTROLLER (pad_controller));
g_object_unref (action_group);
}
GtkWidget *
do_event_axes (GtkWidget *toplevel)
{
static GtkWidget *window = NULL;
EventData *event_data;
GtkWidget *label;
GtkWidget *overlay;
GtkWidget *da;
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Touch and Drawing Tablets");
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
gtk_widget_set_support_multidevice (window, TRUE);
event_data = event_data_new ();
g_object_set_data_full (G_OBJECT (window), "gtk-demo-event-data",
event_data, (GDestroyNotify) event_data_free);
da = gtk_drawing_area_new ();
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (da), 400);
gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (da), 400);
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), draw_cb, event_data, NULL);
gtk_widget_set_can_focus (da, TRUE);
gtk_widget_grab_focus (da);
g_signal_connect (da, "event",
G_CALLBACK (event_cb), event_data);
label = gtk_label_new ("");
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_widget_set_valign (label, GTK_ALIGN_START);
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
overlay = gtk_overlay_new ();
gtk_container_add (GTK_CONTAINER (window), overlay);
gtk_container_add (GTK_CONTAINER (overlay), da);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), label);
init_pad_controller (da, label);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
return window;
}
+29 -34
View File
@@ -135,55 +135,42 @@ static void set_cursor_if_appropriate (GtkTextView *text_view,
gint x,
gint y);
/* Links can also be activated by clicking or tapping.
*/
static gboolean
event_cb (GtkWidget *text_view,
GdkEvent *ev)
static void
released_cb (GtkGestureMultiPress *gesture,
guint n_press,
gdouble x,
gdouble y,
GtkWidget *text_view)
{
GtkTextIter start, end, iter;
GtkTextBuffer *buffer;
gdouble ex, ey;
int x, y;
GdkEventType type;
int tx, ty;
type = gdk_event_get_event_type (ev);
if (gtk_gesture_single_get_button (GTK_GESTURE_SINGLE (gesture)) > 1)
return;
gdk_event_get_coords (ev, &ex, &ey);
gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
GTK_TEXT_WINDOW_WIDGET,
ex, ey, &x, &y);
if (type == GDK_BUTTON_RELEASE)
{
guint button;
gdk_event_get_button (ev, &button);
if (button != GDK_BUTTON_PRIMARY)
return FALSE;
}
else if (type == GDK_MOTION_NOTIFY)
{
set_cursor_if_appropriate (GTK_TEXT_VIEW (text_view), x, y);
return FALSE;
}
else if (type == GDK_TOUCH_END)
{
}
else
return FALSE;
x, y, &tx, &ty);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
/* we shouldn't follow a link if the user has selected something */
gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
return FALSE;
return;
if (gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y))
follow_if_link (text_view, &iter);
}
return TRUE;
static void
motion_cb (GtkEventControllerMotion *controller,
gdouble x,
gdouble y,
GtkTextView *text_view)
{
set_cursor_if_appropriate (text_view, x, y);
}
static gboolean hovering_over_link = FALSE;
@@ -259,8 +246,16 @@ do_hypertext (GtkWidget *do_widget)
controller = gtk_event_controller_key_new ();
g_signal_connect (controller, "key-pressed", G_CALLBACK (key_pressed), view);
gtk_widget_add_controller (view, controller);
g_signal_connect (view, "event",
G_CALLBACK (event_cb), NULL);
controller = GTK_EVENT_CONTROLLER (gtk_gesture_multi_press_new ());
g_signal_connect (controller, "released",
G_CALLBACK (released_cb), view);
gtk_widget_add_controller (view, controller);
controller = gtk_event_controller_motion_new ();
g_signal_connect (controller, "motion",
G_CALLBACK (motion_cb), view);
gtk_widget_add_controller (view, controller);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+1
View File
@@ -154,6 +154,7 @@
</child>
<child>
<object class="GtkBox" id="extra_buttons_box">
<property name="visible">0</property>
<property name="spacing">6</property>
<child>
<object class="GtkButton" id="reply-button">
-1
View File
@@ -22,7 +22,6 @@ demos = files([
'editable_cells.c',
'entry_buffer.c',
'entry_completion.c',
'event_axes.c',
'expander.c',
'filtermodel.c',
'fishbowl.c',
+133 -5
View File
@@ -3,14 +3,24 @@
* Demonstrates practical handling of drawing tablets in a real world
* usecase.
*/
#include <glib/gi18n.h>
#include <gtk/gtk.h>
enum {
COLOR_SET,
N_SIGNALS
};
static guint area_signals[N_SIGNALS] = { 0, };
typedef struct
{
GtkWidget parent_instance;
cairo_surface_t *surface;
cairo_t *cr;
GdkRGBA draw_color;
GtkPadController *pad_controller;
gdouble brush_size;
} DrawingArea;
typedef struct
@@ -18,8 +28,30 @@ typedef struct
GtkWidgetClass parent_class;
} DrawingAreaClass;
static GtkPadActionEntry pad_actions[] = {
{ GTK_PAD_ACTION_BUTTON, 1, -1, N_("Black"), "pad.black" },
{ GTK_PAD_ACTION_BUTTON, 2, -1, N_("Pink"), "pad.pink" },
{ GTK_PAD_ACTION_BUTTON, 3, -1, N_("Green"), "pad.green" },
{ GTK_PAD_ACTION_BUTTON, 4, -1, N_("Red"), "pad.red" },
{ GTK_PAD_ACTION_BUTTON, 5, -1, N_("Purple"), "pad.purple" },
{ GTK_PAD_ACTION_BUTTON, 6, -1, N_("Orange"), "pad.orange" },
{ GTK_PAD_ACTION_STRIP, -1, -1, N_("Brush size"), "pad.brush_size" },
};
static const gchar *pad_colors[] = {
"black",
"pink",
"green",
"red",
"purple",
"orange"
};
G_DEFINE_TYPE (DrawingArea, drawing_area, GTK_TYPE_WIDGET)
static void drawing_area_set_color (DrawingArea *area,
GdkRGBA *color);
static void
drawing_area_ensure_surface (DrawingArea *area,
gint width,
@@ -115,6 +147,82 @@ drawing_area_snapshot (GtkWidget *widget,
cairo_destroy (cr);
}
static void
on_pad_button_activate (GSimpleAction *action,
GVariant *parameter,
DrawingArea *area)
{
const gchar *color = g_object_get_data (G_OBJECT (action), "color");
GdkRGBA rgba;
gdk_rgba_parse (&rgba, color);
drawing_area_set_color (area, &rgba);
}
static void
on_pad_knob_change (GSimpleAction *action,
GVariant *parameter,
DrawingArea *area)
{
gdouble value = g_variant_get_double (parameter);
area->brush_size = value;
}
static void
drawing_area_hierarchy_changed (GtkWidget *widget,
GtkWidget *previous_toplevel)
{
DrawingArea *area = (DrawingArea *) widget;
GSimpleActionGroup *action_group;
GSimpleAction *action;
GtkWidget *toplevel;
gint i;
if (previous_toplevel && area->pad_controller)
{
gtk_widget_remove_controller (previous_toplevel,
GTK_EVENT_CONTROLLER (area->pad_controller));
area->pad_controller = NULL;
}
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (area));
if (!GTK_IS_WINDOW (toplevel))
return;
action_group = g_simple_action_group_new ();
area->pad_controller = gtk_pad_controller_new (G_ACTION_GROUP (action_group),
NULL);
for (i = 0; i < G_N_ELEMENTS (pad_actions); i++)
{
if (pad_actions[i].type == GTK_PAD_ACTION_BUTTON)
{
action = g_simple_action_new (pad_actions[i].action_name, NULL);
g_object_set_data (G_OBJECT (action), "color",
(gpointer) pad_colors[i]);
g_signal_connect (action, "activate",
G_CALLBACK (on_pad_button_activate), area);
}
else
{
action = g_simple_action_new_stateful (pad_actions[i].action_name,
G_VARIANT_TYPE_DOUBLE, NULL);
g_signal_connect (action, "activate",
G_CALLBACK (on_pad_knob_change), area);
}
g_action_map_add_action (G_ACTION_MAP (action_group), G_ACTION (action));
g_object_unref (action);
}
gtk_pad_controller_set_action_entries (area->pad_controller, pad_actions,
G_N_ELEMENTS (pad_actions));
gtk_widget_add_controller (toplevel,
GTK_EVENT_CONTROLLER (area->pad_controller));
}
static void
drawing_area_class_init (DrawingAreaClass *klass)
{
@@ -124,6 +232,14 @@ drawing_area_class_init (DrawingAreaClass *klass)
widget_class->snapshot = drawing_area_snapshot;
widget_class->map = drawing_area_map;
widget_class->unmap = drawing_area_unmap;
widget_class->hierarchy_changed = drawing_area_hierarchy_changed;
area_signals[COLOR_SET] =
g_signal_new ("color-set",
G_TYPE_FROM_CLASS (widget_class),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 1, GDK_TYPE_RGBA);
}
static void
@@ -135,12 +251,12 @@ drawing_area_apply_stroke (DrawingArea *area,
{
if (gdk_device_tool_get_tool_type (tool) == GDK_DEVICE_TOOL_TYPE_ERASER)
{
cairo_set_line_width (area->cr, 10 * pressure);
cairo_set_line_width (area->cr, 10 * pressure * area->brush_size);
cairo_set_operator (area->cr, CAIRO_OPERATOR_DEST_OUT);
}
else
{
cairo_set_line_width (area->cr, 4 * pressure);
cairo_set_line_width (area->cr, 4 * pressure * area->brush_size);
cairo_set_operator (area->cr, CAIRO_OPERATOR_SATURATE);
}
@@ -148,8 +264,6 @@ drawing_area_apply_stroke (DrawingArea *area,
area->draw_color.green, area->draw_color.blue,
area->draw_color.alpha * pressure);
//cairo_set_source_rgba (area->cr, 0, 0, 0, pressure);
cairo_line_to (area->cr, x, y);
cairo_stroke (area->cr);
cairo_move_to (area->cr, x, y);
@@ -225,11 +339,15 @@ drawing_area_new (void)
return g_object_new (drawing_area_get_type (), NULL);
}
void
static void
drawing_area_set_color (DrawingArea *area,
GdkRGBA *color)
{
if (gdk_rgba_equal (&area->draw_color, color))
return;
area->draw_color = *color;
g_signal_emit (area, area_signals[COLOR_SET], 0, &area->draw_color);
}
static void
@@ -242,6 +360,14 @@ color_button_color_set (GtkColorButton *button,
drawing_area_set_color (draw_area, &color);
}
static void
drawing_area_color_set (DrawingArea *area,
GdkRGBA *color,
GtkColorButton *button)
{
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), color);
}
GtkWidget *
do_paint (GtkWidget *toplevel)
{
@@ -263,6 +389,8 @@ do_paint (GtkWidget *toplevel)
colorbutton = gtk_color_button_new ();
g_signal_connect (colorbutton, "color-set",
G_CALLBACK (color_button_color_set), draw_area);
g_signal_connect (draw_area, "color-set",
G_CALLBACK (drawing_area_color_set), colorbutton);
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (colorbutton),
&(GdkRGBA) { 0, 0, 0, 1 });
+1 -12
View File
@@ -26,17 +26,6 @@ changed_cb (GtkEditable *editable)
g_message ("changed: %s", text);
}
static gboolean
window_event_cb (GtkWidget *widget,
GdkEvent *event,
GtkSearchBar *bar)
{
if (gdk_event_get_event_type (event) == GDK_KEY_PRESS)
return gtk_search_bar_handle_event (bar, event);
return GDK_EVENT_PROPAGATE;
}
static void
search_changed (GtkSearchEntry *entry,
GtkLabel *label)
@@ -102,7 +91,7 @@ do_search_entry2 (GtkWidget *do_widget)
gtk_box_pack_start (GTK_BOX (vbox), searchbar);
/* Hook the search bar to key presses */
g_signal_connect (window, "event", G_CALLBACK (window_event_cb), searchbar);
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (searchbar), window);
/* Help */
label = gtk_label_new ("Start Typing to search");
+1
View File
@@ -295,6 +295,7 @@ start_puzzle (GdkPaintable *puzzle)
grid = gtk_grid_new ();
gtk_widget_set_can_focus (grid, TRUE);
gtk_container_add (GTK_CONTAINER (frame), grid);
gtk_aspect_frame_set (GTK_ASPECT_FRAME (frame), 0.5, 0.5, (float) gdk_paintable_get_intrinsic_aspect_ratio (puzzle), FALSE);
/* Add a key event controller so people can use the arrow
* keys to move the puzzle */
+2 -2
View File
@@ -376,7 +376,7 @@ search_mode_toggled (GObject *searchbar, GParamSpec *pspec, IconBrowserWindow *w
static void
get_image_data (GtkWidget *widget,
GdkDragContext *context,
GdkDrag *drag,
GtkSelectionData *selection,
guint target_info,
gpointer data)
@@ -398,7 +398,7 @@ get_image_data (GtkWidget *widget,
static void
get_scalable_image_data (GtkWidget *widget,
GdkDragContext *context,
GdkDrag *drag,
GtkSelectionData *selection,
guint target_info,
gpointer data)
+25 -17
View File
@@ -966,8 +966,8 @@ background_loaded_cb (GObject *source,
return;
}
child = gtk_image_new_from_pixbuf (pixbuf);
gtk_widget_show (child);
child = gtk_picture_new_for_pixbuf (pixbuf);
gtk_widget_set_size_request (child, 110, 70);
gtk_flow_box_insert (GTK_FLOW_BOX (bd->flowbox), child, -1);
child = gtk_widget_get_parent (child);
g_object_set_data_full (G_OBJECT (child), "filename", bd->filename, g_free);
@@ -995,8 +995,7 @@ populate_flowbox (GtkWidget *flowbox)
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 110, 70);
gdk_pixbuf_fill (pixbuf, 0xffffffff);
child = gtk_image_new_from_pixbuf (pixbuf);
gtk_widget_show (child);
child = gtk_picture_new_for_pixbuf (pixbuf);
gtk_flow_box_insert (GTK_FLOW_BOX (flowbox), child, -1);
location = "/usr/share/backgrounds/gnome";
@@ -1081,7 +1080,7 @@ set_accel (GtkApplication *app, GtkWidget *widget)
typedef struct
{
GtkTextView tv;
GdkPixbuf *pixbuf;
GdkTexture *texture;
} MyTextView;
typedef GtkTextViewClass MyTextViewClass;
@@ -1094,18 +1093,23 @@ my_text_view_init (MyTextView *tv)
}
static void
my_tv_draw_layer (GtkTextView *widget,
GtkTextViewLayer layer,
cairo_t *cr)
my_tv_snapshot_layer (GtkTextView *widget,
GtkTextViewLayer layer,
GtkSnapshot *snapshot)
{
MyTextView *tv = (MyTextView *)widget;
if (layer == GTK_TEXT_VIEW_LAYER_BELOW_TEXT && tv->pixbuf)
if (layer == GTK_TEXT_VIEW_LAYER_BELOW_TEXT && tv->texture)
{
cairo_save (cr);
gdk_cairo_set_source_pixbuf (cr, tv->pixbuf, 0.0, 0.0);
cairo_paint_with_alpha (cr, 0.333);
cairo_restore (cr);
gtk_snapshot_push_opacity (snapshot, 0.333);
gtk_snapshot_append_texture (snapshot,
tv->texture,
&GRAPHENE_RECT_INIT(
0, 0,
gdk_texture_get_width (tv->texture),
gdk_texture_get_height (tv->texture)
));
gtk_snapshot_pop (snapshot);
}
}
@@ -1114,7 +1118,7 @@ my_tv_finalize (GObject *object)
{
MyTextView *tv = (MyTextView *)object;
g_clear_object (&tv->pixbuf);
g_clear_object (&tv->texture);
G_OBJECT_CLASS (my_text_view_parent_class)->finalize (object);
}
@@ -1126,20 +1130,24 @@ my_text_view_class_init (MyTextViewClass *class)
GObjectClass *o_class = G_OBJECT_CLASS (class);
o_class->finalize = my_tv_finalize;
tv_class->draw_layer = my_tv_draw_layer;
tv_class->snapshot_layer = my_tv_snapshot_layer;
}
static void
my_text_view_set_background (MyTextView *tv, const gchar *filename)
{
GError *error = NULL;
GFile *file;
g_clear_object (&tv->pixbuf);
g_clear_object (&tv->texture);
if (filename == NULL)
return;
tv->pixbuf = gdk_pixbuf_new_from_file (filename, &error);
file = g_file_new_for_path (filename);
tv->texture = gdk_texture_new_from_file (file, &error);
g_object_unref (file);
if (error)
{
g_warning ("%s", error->message);
+4 -1
View File
@@ -2226,6 +2226,9 @@ microphone-sensitivity-medium-symbolic</property>
<property name="tooltip-text" translatable="yes">Save the current document</property>
</object>
</child>
<child>
<object class="GtkSeparatorToolItem"/>
</child>
<child>
<object class="GtkToolButton">
<property name="label" translatable="yes">Search</property>
@@ -3580,4 +3583,4 @@ bad things might happen.</property>
</object>
</child>
</object>
</interface>
</interface>
+40 -20
View File
@@ -193,7 +193,6 @@ gdk_surface_is_visible
gdk_surface_is_viewable
gdk_surface_is_input_only
gdk_surface_get_state
gdk_surface_withdraw
gdk_surface_iconify
gdk_surface_deiconify
gdk_surface_stick
@@ -656,7 +655,6 @@ gdk_event_get_key_is_modifier
gdk_event_get_pad_axis_value
gdk_event_get_pad_button
gdk_event_get_pad_group_mode
gdk_event_get_string
gdk_event_get_touch_emulating_pointer
gdk_event_get_touchpad_angle_delta
gdk_event_get_touchpad_deltas
@@ -774,38 +772,60 @@ gdk_cursor_get_type
<SECTION>
<TITLE>Drag and Drop</TITLE>
<FILE>dnd</FILE>
GdkDragContext
GdkDrag
GdkDrop
GdkDragCancelReason
gdk_drag_drop_done
gdk_drag_begin
GdkDragAction
GDK_ACTION_ALL
gdk_drag_context_get_display
gdk_drag_context_get_actions
gdk_drag_context_get_suggested_action
gdk_drag_context_get_selected_action
gdk_drag_context_get_formats
gdk_drag_context_get_device
gdk_drag_context_get_drag_surface
gdk_drag_context_set_hotspot
gdk_drag_get_display
gdk_drag_get_actions
gdk_drag_get_suggested_action
gdk_drag_get_selected_action
gdk_drag_get_formats
gdk_drag_get_device
gdk_drag_get_drag_surface
gdk_drag_set_hotspot
<SUBSECTION>
gdk_drag_action_is_unique
<SUBSECTION>
gdk_drop_get_display
gdk_drop_get_device
gdk_drop_get_surface
gdk_drop_get_formats
gdk_drop_get_actions
gdk_drop_get_drag
gdk_drop_status
gdk_drop_finish
gdk_drop_read_async
gdk_drop_read_finish
gdk_drop_read_value_async
gdk_drop_read_value_finish
gdk_drop_read_text_async
gdk_drop_read_text_finish
<SUBSECTION Standard>
GDK_DRAG_CONTEXT
GDK_TYPE_DRAG_CONTEXT
GDK_IS_DRAG_CONTEXT
GDK_DRAG_CONTEXT_CLASS
GDK_DRAG_CONTEXT_GET_CLASS
GDK_IS_DRAG_CONTEXT_CLASS
GDK_DRAG
GDK_TYPE_DRAG
GDK_IS_DRAG
GDK_DRAG_CLASS
GDK_DRAG_GET_CLASS
GDK_IS_DRAG_CLASS
GDK_TYPE_DRAG_ACTION
GDK_TYPE_DRAG_PROTOCOL
GDK_TYPE_DROP
GDK_DROP
GDK_IS_DROP
<SUBSECTION Private>
GdkDragContextClass
gdk_drag_context_get_type
GdkDragClass
gdk_drag_get_type
GdkDropClass
gdk_drop_get_type
</SECTION>
<SECTION>
@@ -1244,6 +1264,7 @@ gdk_clipboard_get_type
<SECTION>
<FILE>gdkcontentprovider</FILE>
GdkContentProvider
GdkContentProviderClass
gdk_content_provider_new_for_value
gdk_content_provider_new_for_bytes
gdk_content_provider_ref_formats
@@ -1259,7 +1280,6 @@ GDK_CONTENT_PROVIDER_CLASS
GDK_CONTENT_PROVIDER_GET_CLASS
GDK_IS_CONTENT_PROVIDER
GDK_IS_CONTENT_PROVIDER_CLASS
GdkContentProviderClass
gdk_content_provider_get_type
</SECTION>
+3 -1
View File
@@ -2,6 +2,7 @@ gdk_app_launch_context_get_type
gdk_clipboard_get_type
gdk_content_deserializer_get_type
gdk_content_formats_get_type
gdk_content_provider_get_type
gdk_content_serializer_get_type
gdk_cursor_get_type
gdk_device_get_type
@@ -9,7 +10,8 @@ gdk_device_pad_get_type
gdk_device_tool_get_type
gdk_display_get_type
gdk_display_manager_get_type
gdk_drag_context_get_type
gdk_drag_get_type
gdk_drop_get_type
gdk_event_get_type
gdk_frame_clock_get_type
gdk_gl_context_get_type
-1
View File
@@ -385,7 +385,6 @@
<xi:include href="osx.sgml" />
<xi:include href="broadway.xml" />
<xi:include href="wayland.xml" />
<xi:include href="mir.xml" />
</part>
<xi:include href="glossary.xml" />
+6 -11
View File
@@ -679,8 +679,6 @@ gtk_combo_box_get_active_id
gtk_combo_box_set_active_id
gtk_combo_box_get_model
gtk_combo_box_set_model
gtk_combo_box_popup_for_device
gtk_combo_box_popup
gtk_combo_box_popdown
gtk_combo_box_get_popup_accessible
gtk_combo_box_get_row_separator_func
@@ -1724,8 +1722,6 @@ gtk_menu_attach
gtk_menu_popup_at_rect
gtk_menu_popup_at_widget
gtk_menu_popup_at_pointer
gtk_menu_popup_for_device
gtk_menu_popup
gtk_menu_set_accel_group
gtk_menu_get_accel_group
gtk_menu_set_accel_path
@@ -4907,12 +4903,10 @@ gtk_render_check
gtk_render_expander
gtk_render_focus
gtk_render_frame
gtk_render_frame_gap
gtk_render_handle
gtk_render_layout
gtk_render_line
gtk_render_option
gtk_render_slider
gtk_render_activity
gtk_render_icon
gtk_render_insertion_cursor
@@ -4936,7 +4930,6 @@ gtk_border_get_type
<FILE>gtkcssprovider</FILE>
<TITLE>GtkCssProvider</TITLE>
GtkCssProvider
gtk_css_provider_get_default
gtk_css_provider_get_named
gtk_css_provider_load_from_data
gtk_css_provider_load_from_file
@@ -5013,6 +5006,7 @@ gtk_selection_data_get_type
<TITLE>Drag and Drop</TITLE>
GtkDestDefaults
GtkDragResult
<SUBSECTION Destination Side>
gtk_drag_dest_set
gtk_drag_dest_unset
@@ -5028,8 +5022,9 @@ gtk_drag_get_data
gtk_drag_get_source_widget
gtk_drag_highlight
gtk_drag_unhighlight
<SUBSECTION Source Side>
gtk_drag_begin_with_coordinates
gtk_drag_begin
gtk_drag_cancel
gtk_drag_set_icon_widget
gtk_drag_set_icon_paintable
@@ -6463,7 +6458,7 @@ gtk_gesture_single_get_type
<SECTION>
<FILE>gtkeventcontrollerscroll</FILE>
<TITLE>GtkEventControlerScroll</TITLE>
<TITLE>GtkEventControllerScroll</TITLE>
GtkEventControllerScroll
GtkEventControllerScrollFlags
gtk_event_controller_scroll_new
@@ -6484,7 +6479,7 @@ gtk_event_controller_scroll_get_type
<SECTION>
<FILE>gtkeventcontrollermotion</FILE>
<TITLE>GtkEventControlerMotion</TITLE>
<TITLE>GtkEventControllerMotion</TITLE>
GtkEventControllerMotion
gtk_event_controller_motion_new
@@ -6502,7 +6497,7 @@ gtk_event_controller_motion_get_type
<SECTION>
<FILE>gtkeventcontrollerkey</FILE>
<TITLE>GtkEventControlerKey</TITLE>
<TITLE>GtkEventControllerKey</TITLE>
GtkEventControllerKey
gtk_event_controller_key_new
+1
View File
@@ -118,6 +118,7 @@ gtk_page_setup_get_type
@DISABLE_ON_W32@gtk_page_setup_unix_dialog_get_type
gtk_paned_get_type
gtk_paper_size_get_type
gtk_picture_get_type
gtk_popover_get_type
gtk_popover_menu_get_type
@DISABLE_ON_W32@gtk_printer_get_type
-1
View File
@@ -355,7 +355,6 @@ content_files = [
'input-handling.xml',
'migrating-2to4.xml',
'migrating-3to4.xml',
'mir.xml',
'osx.sgml',
'other_software.sgml',
'overview.xml',
+23 -7
View File
@@ -20,11 +20,11 @@
<para>
The steps outlined in the following sections assume that your
application is working with GTK+ 3.22, which is the final stable
application is working with GTK+ 3.24, which is the final stable
release of GTK+ 3.x. It includes all the necessary APIs and tools
to help you port your application to GTK+ 4. If you are still using
an older version of GTK+ 3.x, you should first get your application
to build and work with the latest minor release in the 3.22 series.
to build and work with the latest minor release in the 3.24 series.
</para>
<section>
@@ -34,7 +34,7 @@
widgets have been deprecated. These deprecations are clearly spelled
out in the API reference, with hints about the recommended replacements.
The API reference for GTK+ 3 also includes an
<ulink url="https://developer.gnome.org/gtk3/3.22/api-index-deprecated.html">index</ulink> of all deprecated symbols.
<ulink url="https://developer.gnome.org/gtk3/3.24/api-index-deprecated.html">index</ulink> of all deprecated symbols.
</para>
<para>
To verify that your program does not use any deprecated symbols,
@@ -79,13 +79,13 @@
<title>Review your window creation flags</title>
<para>
GTK+ 4 removes the GDK_WA_CURSOR flag. Instead, just use
gdk_surface_set_cursor() to set a cursor on the window after
gdk_window_set_cursor() to set a cursor on the window after
creating it.
</para>
<para>
GTK+ 4 also removes the GDK_WA_VISUAL flag, and always uses
an RGBA visual for windows. To prepare your code for this,
use gdk_surface_set_visual (gdk_screen_get_rgba_visual ()) after
use gdk_window_set_visual (gdk_screen_get_rgba_visual ()) after
creating your window.
</para>
<para>
@@ -169,6 +169,14 @@
</para>
</section>
<section>
<title>Stop using GtkWidget event signals</title>
<para>
Event controllers and #GtkGestures replace event signals in GTK+ 4. They
have been backported to GTK+ 3.x so you can prepare for this change.
</para>
</section>
</section>
<section>
@@ -311,6 +319,15 @@
</para>
</section>
<section>
<title>Adapt to GtkWidget's size allocation changes</title>
<para>
The #GtkWidget::size-allocate signal now takes the baseline as an
argument, so you no longer need to call gtk_widget_get_allocated_baseline()
to get it.
</para>
</section>
<section>
<title>Switch to GtkWidget's children APIs</title>
<para>
@@ -432,8 +449,7 @@
<title>GtkWidget event signals are removed</title>
<para>
Event controllers and #GtkGestures have already been introduced in GTK+ 3 to handle
input for many cases. In GTK+ 4, even more are available, such as #GtkEventControllerScroll
and GtkEventControllerMotion, and the traditional widget signals for handling input,
input for many cases. In GTK+ 4, the traditional widget signals for handling input,
such as #GtkWidget::motion-event or #GtkWidget::event have been removed.
</para>
</section>
-35
View File
@@ -1,35 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
]>
<refentry id="gtk-mir">
<refmeta>
<refentrytitle>Using GTK+ with Mir</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GTK Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Using GTK+ with Mir</refname>
<refpurpose>
Mir-specific aspects of using GTK+
</refpurpose>
</refnamediv>
<refsect1>
<title>Using GTK+ with Mir</title>
<para>
The GDK Mir backend provides support for running GTK+ applications
under Mir based display servers. To run your application in this way,
select the Mir backend by setting <literal>GDK_BACKEND=mir</literal>.
</para>
<para>
Currently, the Mir backend does not use any additional commandline
options or environment variables.
</para>
</refsect1>
</refentry>
-5
View File
@@ -435,11 +435,6 @@ nevertheless.
<listitem><para>Selects the Wayland backend for connecting to Wayland display servers</para></listitem>
</varlistentry>
<varlistentry>
<term>mir</term>
<listitem><para>Selects the Mir backend for connecting to Mir display servers</para></listitem>
</varlistentry>
</variablelist>
Since 3.10, this environment variable can contain a comma-separated list
of backend names, which are tried in order. The list may also contain
+26 -44
View File
@@ -24,7 +24,7 @@
#include "config.h"
#include "gdkdndprivate.h"
#include "gdkdragprivate.h"
#include "gdkinternals.h"
#include "gdkproperty.h"
@@ -34,56 +34,56 @@
#include <string.h>
#define GDK_TYPE_BROADWAY_DRAG_CONTEXT (gdk_broadway_drag_context_get_type ())
#define GDK_BROADWAY_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_DRAG_CONTEXT, GdkBroadwayDragContext))
#define GDK_BROADWAY_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_DRAG_CONTEXT, GdkBroadwayDragContextClass))
#define GDK_IS_BROADWAY_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_DRAG_CONTEXT))
#define GDK_IS_BROADWAY_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_DRAG_CONTEXT))
#define GDK_BROADWAY_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_DRAG_CONTEXT, GdkBroadwayDragContextClass))
#define GDK_TYPE_BROADWAY_DRAG (gdk_broadway_drag_get_type ())
#define GDK_BROADWAY_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_DRAG, GdkBroadwayDrag))
#define GDK_BROADWAY_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_DRAG, GdkBroadwayDragClass))
#define GDK_IS_BROADWAY_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_DRAG))
#define GDK_IS_BROADWAY_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_DRAG))
#define GDK_BROADWAY_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_DRAG, GdkBroadwayDragClass))
#ifdef GDK_COMPILATION
typedef struct _GdkBroadwayDragContext GdkBroadwayDragContext;
typedef struct _GdkBroadwayDrag GdkBroadwayDrag;
#else
typedef GdkDragContext GdkBroadwayDragContext;
typedef GdkDrag GdkBroadwayDrag;
#endif
typedef struct _GdkBroadwayDragContextClass GdkBroadwayDragContextClass;
typedef struct _GdkBroadwayDragClass GdkBroadwayDragClass;
GType gdk_broadway_drag_context_get_type (void);
GType gdk_broadway_drag_get_type (void);
struct _GdkBroadwayDragContext {
GdkDragContext context;
struct _GdkBroadwayDrag {
GdkDrag context;
};
struct _GdkBroadwayDragContextClass
struct _GdkBroadwayDragClass
{
GdkDragContextClass parent_class;
GdkDragClass parent_class;
};
static void gdk_broadway_drag_context_finalize (GObject *object);
static void gdk_broadway_drag_finalize (GObject *object);
static GList *contexts;
G_DEFINE_TYPE (GdkBroadwayDragContext, gdk_broadway_drag_context, GDK_TYPE_DRAG_CONTEXT)
G_DEFINE_TYPE (GdkBroadwayDrag, gdk_broadway_drag, GDK_TYPE_DRAG)
static void
gdk_broadway_drag_context_init (GdkBroadwayDragContext *dragcontext)
gdk_broadway_drag_init (GdkBroadwayDrag *dragcontext)
{
contexts = g_list_prepend (contexts, dragcontext);
}
static void
gdk_broadway_drag_context_finalize (GObject *object)
gdk_broadway_drag_finalize (GObject *object)
{
GdkDragContext *context = GDK_DRAG_CONTEXT (object);
GdkDrag *context = GDK_DRAG (object);
contexts = g_list_remove (contexts, context);
G_OBJECT_CLASS (gdk_broadway_drag_context_parent_class)->finalize (object);
G_OBJECT_CLASS (gdk_broadway_drag_parent_class)->finalize (object);
}
/* Drag Contexts */
GdkDragContext *
GdkDrag *
_gdk_broadway_surface_drag_begin (GdkSurface *surface,
GdkDevice *device,
GdkContentProvider *content,
@@ -91,12 +91,12 @@ _gdk_broadway_surface_drag_begin (GdkSurface *surface,
gint dx,
gint dy)
{
GdkDragContext *new_context;
GdkDrag *new_context;
g_return_val_if_fail (surface != NULL, NULL);
g_return_val_if_fail (GDK_SURFACE_IS_BROADWAY (surface), NULL);
new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG_CONTEXT,
new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG,
"device", device,
"content", content,
NULL);
@@ -104,20 +104,6 @@ _gdk_broadway_surface_drag_begin (GdkSurface *surface,
return new_context;
}
static void
gdk_broadway_drag_context_drag_drop (GdkDragContext *context,
guint32 time)
{
g_return_if_fail (context != NULL);
}
static void
gdk_broadway_drag_context_drag_abort (GdkDragContext *context,
guint32 time)
{
g_return_if_fail (context != NULL);
}
void
_gdk_broadway_surface_register_dnd (GdkSurface *surface)
{
@@ -129,13 +115,9 @@ _gdk_broadway_display_init_dnd (GdkDisplay *display)
}
static void
gdk_broadway_drag_context_class_init (GdkBroadwayDragContextClass *klass)
gdk_broadway_drag_class_init (GdkBroadwayDragClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkDragContextClass *context_class = GDK_DRAG_CONTEXT_CLASS (klass);
object_class->finalize = gdk_broadway_drag_context_finalize;
context_class->drag_abort = gdk_broadway_drag_context_drag_abort;
context_class->drag_drop = gdk_broadway_drag_context_drag_drop;
object_class->finalize = gdk_broadway_drag_finalize;
}
-1
View File
@@ -285,7 +285,6 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message)
event->key.state = message->key.state;
event->key.hardware_keycode = message->key.key;
gdk_event_set_scancode (event, message->key.key);
event->key.length = 0;
gdk_event_set_device (event, gdk_seat_get_keyboard (seat));
node = _gdk_event_queue_append (display, event);
+1 -1
View File
@@ -46,7 +46,7 @@ void gdk_broadway_surface_set_nodes (GdkSurface *surface,
GPtrArray *node_textures);
void _gdk_broadway_surface_register_dnd (GdkSurface *surface);
GdkDragContext * _gdk_broadway_surface_drag_begin (GdkSurface *surface,
GdkDrag * _gdk_broadway_surface_drag_begin (GdkSurface *surface,
GdkDevice *device,
GdkContentProvider *content,
GdkDragAction actions,
+2 -8
View File
@@ -322,10 +322,7 @@ gdk_surface_broadway_show (GdkSurface *surface,
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
impl->visible = TRUE;
_gdk_make_event (GDK_SURFACE (surface), GDK_MAP, NULL, FALSE);
if (surface->parent)
_gdk_make_event (GDK_SURFACE (surface), GDK_MAP, NULL, FALSE);
/* FIXME: update state ? */
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
if (_gdk_broadway_server_surface_show (broadway_display->server, impl->id))
@@ -342,10 +339,7 @@ gdk_surface_broadway_hide (GdkSurface *surface)
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
impl->visible = FALSE;
_gdk_make_event (GDK_SURFACE (surface), GDK_UNMAP, NULL, FALSE);
if (surface->parent)
_gdk_make_event (GDK_SURFACE (surface), GDK_UNMAP, NULL, FALSE);
/* FIXME: update state ? */
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
+12 -12
View File
@@ -43,8 +43,19 @@ clienthtml_h = custom_target('clienthtml.h',
],
)
broadwayjs_h = custom_target('broadwayjs.h',
input : ['broadway.js'],
output : 'broadwayjs.h',
command : [
gen_c_array,
'--array-name=broadway_js',
'--output=@OUTPUT@',
'@INPUT0@',
],
)
libgdk_broadway = static_library('gdk-broadway',
clienthtml_h,
clienthtml_h, broadwayjs_h,
gdk_broadway_sources, gdkconfig, gdkenum_h,
include_directories: [confinc, gdkinc],
c_args: [
@@ -58,17 +69,6 @@ libgdk_broadway = static_library('gdk-broadway',
broadwayd_syslib = os_win32 ? find_library('ws2_32') : shmlib
broadwayjs_h = custom_target('broadwayjs.h',
input : ['broadway.js'],
output : 'broadwayjs.h',
command : [
gen_c_array,
'--array-name=broadway_js',
'--output=@OUTPUT@',
'@INPUT0@',
],
)
executable('gtk4-broadwayd',
clienthtml_h, broadwayjs_h,
'broadwayd.c', 'broadway-server.c', 'broadway-output.c',
+2 -1
View File
@@ -23,11 +23,12 @@
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkAppLaunchContext, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkClipboard, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkContentProvider, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkCursor, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDevice, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDisplay, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDisplayManager, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDragContext, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDrag, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDrawContext, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkFrameClock, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkGLContext, g_object_unref)
+1 -1
View File
@@ -44,7 +44,7 @@
#include <gdk/gdkdevicetool.h>
#include <gdk/gdkdisplay.h>
#include <gdk/gdkdisplaymanager.h>
#include <gdk/gdkdnd.h>
#include <gdk/gdkdrag.h>
#include <gdk/gdkdrawcontext.h>
#include <gdk/gdkdrop.h>
#include <gdk/gdkenumtypes.h>
+3 -2
View File
@@ -716,8 +716,7 @@ file_uri_deserializer_finish (GObject *source,
return;
}
str = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (
g_filter_output_stream_get_base_stream (G_FILTER_OUTPUT_STREAM (stream))));
str = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (stream));
uris = g_uri_list_extract_uris (str);
g_free (str);
@@ -738,6 +737,8 @@ file_uri_deserializer_finish (GObject *source,
g_value_take_boxed (value, g_slist_reverse (l));
}
g_strfreev (uris);
gdk_content_deserializer_return_success (deserializer);
}
static void
+1 -18
View File
@@ -61,12 +61,7 @@
* the commonly available names that are shared with the CSS specification.
* Other names may be available, depending on the platform in use.
* Another option to create a cursor is to use gdk_cursor_new_from_texture()
* and provide an image to use for the cursor. Depending on the #GdkDisplay
* in use, the type of supported images may be limited. See
* gdk_display_supports_cursor_alpha(),
* gdk_display_supports_cursor_color(),
* gdk_display_get_default_cursor_size() and
* gdk_display_get_maximal_cursor_size() for the limitations that might apply.
* and provide an image to use for the cursor.
*
* To ease work with unsupported cursors, a fallback cursor can be provided.
* If a #GdkSurface cannot use a cursor because of the reasons mentioned above,
@@ -346,18 +341,6 @@ gdk_cursor_new_from_name (const gchar *name,
*
* Creates a new cursor from a #GdkTexture.
*
* Not all GDK backends support RGBA cursors. If they are not
* supported, a monochrome approximation will be displayed.
* The functions gdk_display_supports_cursor_alpha() and
* gdk_display_supports_cursor_color() can be used to determine
* whether RGBA cursors are supported;
* gdk_display_get_default_cursor_size() and
* gdk_display_get_maximal_cursor_size() give information about
* cursor sizes.
*
* On the X backend, support for RGBA cursors requires a
* sufficently new version of the X Render extension.
*
* Returns: a new #GdkCursor.
*/
GdkCursor *
+1 -1
View File
@@ -1282,7 +1282,7 @@ gdk_display_notify_startup_complete (GdkDisplay *display,
/**
* gdk_display_get_startup_notification_id:
* @display: (type GdkX11Display): a #GdkDisplay
* @display: a #GdkDisplay
*
* Gets the startup notification ID for a Wayland display, or %NULL
* if no ID has been defined.
-100
View File
@@ -1,100 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GDK_DND_H__
#define __GDK_DND_H__
#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <gdk/gdktypes.h>
#include <gdk/gdkdevice.h>
#include <gdk/gdkevents.h>
G_BEGIN_DECLS
#define GDK_TYPE_DRAG_CONTEXT (gdk_drag_context_get_type ())
#define GDK_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAG_CONTEXT, GdkDragContext))
#define GDK_IS_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAG_CONTEXT))
/**
* GdkDragCancelReason:
* @GDK_DRAG_CANCEL_NO_TARGET: There is no suitable drop target.
* @GDK_DRAG_CANCEL_USER_CANCELLED: Drag cancelled by the user
* @GDK_DRAG_CANCEL_ERROR: Unspecified error.
*
* Used in #GdkDragContext to the reason of a cancelled DND operation.
*/
typedef enum {
GDK_DRAG_CANCEL_NO_TARGET,
GDK_DRAG_CANCEL_USER_CANCELLED,
GDK_DRAG_CANCEL_ERROR
} GdkDragCancelReason;
GDK_AVAILABLE_IN_ALL
GType gdk_drag_context_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GdkDisplay * gdk_drag_context_get_display (GdkDragContext *context);
GDK_AVAILABLE_IN_ALL
GdkDevice * gdk_drag_context_get_device (GdkDragContext *context);
GDK_AVAILABLE_IN_ALL
GdkContentFormats *gdk_drag_context_get_formats (GdkDragContext *context);
GDK_AVAILABLE_IN_ALL
GdkDragAction gdk_drag_context_get_actions (GdkDragContext *context);
GDK_AVAILABLE_IN_ALL
GdkDragAction gdk_drag_context_get_suggested_action (GdkDragContext *context);
GDK_AVAILABLE_IN_ALL
GdkDragAction gdk_drag_context_get_selected_action (GdkDragContext *context);
GDK_AVAILABLE_IN_ALL
gboolean gdk_drag_action_is_unique (GdkDragAction action);
/* Source side */
GDK_AVAILABLE_IN_ALL
GdkDragContext * gdk_drag_begin (GdkSurface *surface,
GdkDevice *device,
GdkContentProvider *content,
GdkDragAction actions,
gint dx,
gint dy);
GDK_AVAILABLE_IN_ALL
void gdk_drag_drop_done (GdkDragContext *context,
gboolean success);
GDK_AVAILABLE_IN_ALL
GdkSurface *gdk_drag_context_get_drag_surface (GdkDragContext *context);
GDK_AVAILABLE_IN_ALL
void gdk_drag_context_set_hotspot (GdkDragContext *context,
gint hot_x,
gint hot_y);
G_END_DECLS
#endif /* __GDK_DND_H__ */
-105
View File
@@ -1,105 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2010, Red Hat, Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GDK_DND_PRIVATE_H__
#define __GDK_DND_PRIVATE_H__
#include "gdkdnd.h"
G_BEGIN_DECLS
#define GDK_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAG_CONTEXT, GdkDragContextClass))
#define GDK_IS_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DRAG_CONTEXT))
#define GDK_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DRAG_CONTEXT, GdkDragContextClass))
typedef struct _GdkDragContextClass GdkDragContextClass;
struct _GdkDragContextClass {
GObjectClass parent_class;
void (*drag_abort) (GdkDragContext *context,
guint32 time_);
void (*drag_drop) (GdkDragContext *context,
guint32 time_);
GdkSurface* (*get_drag_surface) (GdkDragContext *context);
void (*set_hotspot) (GdkDragContext *context,
gint hot_x,
gint hot_y);
void (*drop_done) (GdkDragContext *context,
gboolean success);
void (*set_cursor) (GdkDragContext *context,
GdkCursor *cursor);
void (*cancel) (GdkDragContext *context,
GdkDragCancelReason reason);
void (*drop_performed) (GdkDragContext *context,
guint32 time);
void (*dnd_finished) (GdkDragContext *context);
gboolean (*handle_event) (GdkDragContext *context,
const GdkEvent *event);
void (*action_changed) (GdkDragContext *context,
GdkDragAction action);
};
struct _GdkDragContext {
GObject parent_instance;
/*< private >*/
GdkSurface *source_surface;
GdkSurface *drag_surface;
GdkContentProvider *content;
GdkDragAction action;
guint drop_done : 1; /* Whether gdk_drag_drop_done() was performed */
};
void gdk_drag_context_set_cursor (GdkDragContext *context,
GdkCursor *cursor);
void gdk_drag_context_set_actions (GdkDragContext *context,
GdkDragAction actions,
GdkDragAction suggested_action);
void gdk_drag_context_cancel (GdkDragContext *context,
GdkDragCancelReason reason);
gboolean gdk_drag_context_handle_source_event (GdkEvent *event);
GdkCursor * gdk_drag_get_cursor (GdkDragContext *context,
GdkDragAction action);
void gdk_drag_abort (GdkDragContext *context,
guint32 time_);
void gdk_drag_drop (GdkDragContext *context,
guint32 time_);
void gdk_drag_context_write_async (GdkDragContext *context,
const char *mime_type,
GOutputStream *stream,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean gdk_drag_context_write_finish (GdkDragContext *context,
GAsyncResult *result,
GError **error);
G_END_DECLS
#endif
+275 -251
View File
@@ -24,7 +24,7 @@
#include "config.h"
#include "gdkdndprivate.h"
#include "gdkdragprivate.h"
#include "gdkdisplay.h"
#include "gdksurface.h"
#include "gdkintl.h"
@@ -35,17 +35,6 @@
#include "gdkenumtypes.h"
#include "gdkeventsprivate.h"
typedef struct _GdkDragContextPrivate GdkDragContextPrivate;
struct _GdkDragContextPrivate
{
GdkDisplay *display;
GdkDevice *device;
GdkContentFormats *formats;
GdkDragAction actions;
GdkDragAction suggested_action;
};
static struct {
GdkDragAction action;
const gchar *name;
@@ -64,6 +53,9 @@ enum {
PROP_DEVICE,
PROP_DISPLAY,
PROP_FORMATS,
PROP_SELECTED_ACTION,
PROP_ACTIONS,
PROP_SURFACE,
N_PROPERTIES
};
@@ -71,15 +63,30 @@ enum {
CANCEL,
DROP_PERFORMED,
DND_FINISHED,
ACTION_CHANGED,
N_SIGNALS
};
typedef struct _GdkDragPrivate GdkDragPrivate;
struct _GdkDragPrivate {
GdkSurface *surface;
GdkDisplay *display;
GdkDevice *device;
GdkContentFormats *formats;
GdkContentProvider *content;
GdkDragAction actions;
GdkDragAction selected_action;
guint drop_done : 1; /* Whether gdk_drag_drop_done() was performed */
};
static GParamSpec *properties[N_PROPERTIES] = { NULL, };
static guint signals[N_SIGNALS] = { 0 };
static GList *contexts = NULL;
static GList *drags = NULL;
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT)
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDrag, gdk_drag, G_TYPE_OBJECT)
/**
* SECTION:dnd
@@ -87,153 +94,139 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDragContext, gdk_drag_context, G_TYPE_OB
* @short_description: Functions for controlling drag and drop handling
*
* These functions provide a low level interface for drag and drop.
* The X backend of GDK supports both the Xdnd and Motif drag and drop
* protocols transparently, the Win32 backend supports the WM_DROPFILES
* protocol.
*
* The GdkDrag object represents the source side of an ongoing DND operation.
* It is created when a drag is started, and stays alive for duration of
* the DND operation.
*
* The GdkDrop object represents the target side of an ongoing DND operation.
*
* GTK+ provides a higher level abstraction based on top of these functions,
* and so they are not normally needed in GTK+ applications.
* See the [Drag and Drop][gtk3-Drag-and-Drop] section of
* the GTK+ documentation for more information.
* and so they are not normally needed in GTK+ applications. See the
* [Drag and Drop][gtk4-Drag-and-Drop] section of the GTK+ documentation
* for more information.
*/
/**
* GdkDragContext:
* GdkDrag:
*
* The GdkDragContext struct contains only private fields and
* The GdkDrag struct contains only private fields and
* should not be accessed directly.
*/
/**
* gdk_drag_context_get_display:
* @context: a #GdkDragContext
* gdk_drag_get_display:
* @drag: a #GdkDrag
*
* Gets the #GdkDisplay that the drag context was created for.
* Gets the #GdkDisplay that the drag object was created for.
*
* Returns: (transfer none): a #GdkDisplay
**/
GdkDisplay *
gdk_drag_context_get_display (GdkDragContext *context)
gdk_drag_get_display (GdkDrag *drag)
{
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
return priv->display;
}
/**
* gdk_drag_context_get_formats:
* @context: a #GdkDragContext
* gdk_drag_get_formats:
* @drag: a #GdkDrag
*
* Retrieves the formats supported by this context.
* Retrieves the formats supported by this GdkDrag object.
*
* Returns: (transfer none): a #GdkContentFormats
**/
GdkContentFormats *
gdk_drag_context_get_formats (GdkDragContext *context)
gdk_drag_get_formats (GdkDrag *drag)
{
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
return priv->formats;
}
/**
* gdk_drag_context_get_actions:
* @context: a #GdkDragContext
* gdk_drag_get_actions:
* @drag: a #GdkDrag
*
* Determines the bitmask of actions proposed by the source if
* gdk_drag_context_get_suggested_action() returns %GDK_ACTION_ASK.
* Determines the bitmask of possible actions proposed by the source.
*
* Returns: the #GdkDragAction flags
**/
GdkDragAction
gdk_drag_context_get_actions (GdkDragContext *context)
gdk_drag_get_actions (GdkDrag *drag)
{
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
g_return_val_if_fail (GDK_IS_DRAG (drag), 0);
return priv->actions;
}
/**
* gdk_drag_context_get_suggested_action:
* @context: a #GdkDragContext
*
* Determines the suggested drag action of the context.
*
* Returns: a #GdkDragAction value
**/
GdkDragAction
gdk_drag_context_get_suggested_action (GdkDragContext *context)
{
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
return priv->suggested_action;
}
/**
* gdk_drag_context_get_selected_action:
* @context: a #GdkDragContext
* gdk_drag_get_selected_action:
* @drag: a #GdkDrag
*
* Determines the action chosen by the drag destination.
*
* Returns: a #GdkDragAction value
**/
GdkDragAction
gdk_drag_context_get_selected_action (GdkDragContext *context)
gdk_drag_get_selected_action (GdkDrag *drag)
{
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
return context->action;
g_return_val_if_fail (GDK_IS_DRAG (drag), 0);
return priv->selected_action;
}
/**
* gdk_drag_context_get_device:
* @context: a #GdkDragContext
* gdk_drag_get_device:
* @drag: a #GdkDrag
*
* Returns the #GdkDevice associated to the drag context.
* Returns the #GdkDevice associated to the GdkDrag object.
*
* Returns: (transfer none): The #GdkDevice associated to @context.
* Returns: (transfer none): The #GdkDevice associated to @drag.
**/
GdkDevice *
gdk_drag_context_get_device (GdkDragContext *context)
gdk_drag_get_device (GdkDrag *drag)
{
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
return priv->device;
}
static void
gdk_drag_context_init (GdkDragContext *context)
gdk_drag_init (GdkDrag *drag)
{
contexts = g_list_prepend (contexts, context);
drags = g_list_prepend (drags, drag);
}
static void
gdk_drag_context_set_property (GObject *gobject,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
gdk_drag_set_property (GObject *gobject,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GdkDragContext *context = GDK_DRAG_CONTEXT (gobject);
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
GdkDrag *drag = GDK_DRAG (gobject);
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
switch (prop_id)
{
case PROP_CONTENT:
context->content = g_value_dup_object (value);
if (context->content)
priv->content = g_value_dup_object (value);
if (priv->content)
{
g_assert (priv->formats == NULL);
priv->formats = gdk_content_provider_ref_formats (context->content);
priv->formats = gdk_content_provider_ref_formats (priv->content);
}
break;
@@ -260,6 +253,25 @@ gdk_drag_context_set_property (GObject *gobject,
}
break;
case PROP_SELECTED_ACTION:
{
GdkDragAction action = g_value_get_flags (value);
gdk_drag_set_selected_action (drag, action);
}
break;
case PROP_ACTIONS:
{
GdkDragAction actions = g_value_get_flags (value);
gdk_drag_set_actions (drag, actions);
}
break;
case PROP_SURFACE:
priv->surface = g_value_dup_object (value);
g_assert (priv->surface != NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -267,18 +279,18 @@ gdk_drag_context_set_property (GObject *gobject,
}
static void
gdk_drag_context_get_property (GObject *gobject,
guint prop_id,
GValue *value,
GParamSpec *pspec)
gdk_drag_get_property (GObject *gobject,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GdkDragContext *context = GDK_DRAG_CONTEXT (gobject);
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
GdkDrag *drag = GDK_DRAG (gobject);
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
switch (prop_id)
{
case PROP_CONTENT:
g_value_set_object (value, context->content);
g_value_set_object (value, priv->content);
break;
case PROP_DEVICE:
@@ -293,6 +305,18 @@ gdk_drag_context_get_property (GObject *gobject,
g_value_set_boxed (value, priv->formats);
break;
case PROP_SELECTED_ACTION:
g_value_set_flags (value, priv->selected_action);
break;
case PROP_ACTIONS:
g_value_set_flags (value, priv->actions);
break;
case PROP_SURFACE:
g_value_set_object (value, priv->surface);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -300,36 +324,34 @@ gdk_drag_context_get_property (GObject *gobject,
}
static void
gdk_drag_context_finalize (GObject *object)
gdk_drag_finalize (GObject *object)
{
GdkDragContext *context = GDK_DRAG_CONTEXT (object);
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
GdkDrag *drag = GDK_DRAG (object);
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
contexts = g_list_remove (contexts, context);
drags = g_list_remove (drags, drag);
g_clear_object (&context->content);
g_clear_object (&priv->content);
g_clear_pointer (&priv->formats, gdk_content_formats_unref);
if (context->source_surface)
g_object_unref (context->source_surface);
g_clear_object (&priv->surface);
G_OBJECT_CLASS (gdk_drag_context_parent_class)->finalize (object);
G_OBJECT_CLASS (gdk_drag_parent_class)->finalize (object);
}
static void
gdk_drag_context_class_init (GdkDragContextClass *klass)
gdk_drag_class_init (GdkDragClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = gdk_drag_context_get_property;
object_class->set_property = gdk_drag_context_set_property;
object_class->finalize = gdk_drag_context_finalize;
object_class->get_property = gdk_drag_get_property;
object_class->set_property = gdk_drag_set_property;
object_class->finalize = gdk_drag_finalize;
/**
* GdkDragContext:content:
* GdkDrag:content:
*
* The #GdkContentProvider or %NULL if the context is not a source-side
* context.
* The #GdkContentProvider.
*/
properties[PROP_CONTENT] =
g_param_spec_object ("content",
@@ -342,7 +364,7 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
G_PARAM_EXPLICIT_NOTIFY);
/**
* GdkDragContext:device:
* GdkDrag:device:
*
* The #GdkDevice that is performing the drag.
*/
@@ -357,9 +379,9 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
G_PARAM_EXPLICIT_NOTIFY);
/**
* GdkDragContext:display:
* GdkDrag:display:
*
* The #GdkDisplay that the drag context belongs to.
* The #GdkDisplay that the drag belongs to.
*/
properties[PROP_DISPLAY] =
g_param_spec_object ("display",
@@ -371,9 +393,9 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
G_PARAM_EXPLICIT_NOTIFY);
/**
* GdkDragContext:formats:
* GdkDrag:formats:
*
* The possible formats that the context can provide its data in.
* The possible formats that the drag can provide its data in.
*/
properties[PROP_FORMATS] =
g_param_spec_boxed ("formats",
@@ -385,113 +407,91 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY);
properties[PROP_SELECTED_ACTION] =
g_param_spec_flags ("selected-action",
"Selected action",
"The currently selected action",
GDK_TYPE_DRAG_ACTION,
0,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY);
properties[PROP_ACTIONS] =
g_param_spec_flags ("actions",
"Actions",
"The possible actions",
GDK_TYPE_DRAG_ACTION,
0,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY);
properties[PROP_SURFACE] =
g_param_spec_object ("surface",
"Surface",
"The surface where the drag originates",
GDK_TYPE_SURFACE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY);
/**
* GdkDragContext::cancel:
* @context: The object on which the signal is emitted
* @reason: The reason the context was cancelled
* GdkDrag::cancel:
* @drag: The object on which the signal is emitted
* @reason: The reason the drag was cancelled
*
* The drag and drop operation was cancelled.
* The drag operation was cancelled.
*/
signals[CANCEL] =
g_signal_new (g_intern_static_string ("cancel"),
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdkDragContextClass, cancel),
G_STRUCT_OFFSET (GdkDragClass, cancel),
NULL, NULL,
g_cclosure_marshal_VOID__ENUM,
G_TYPE_NONE, 1, GDK_TYPE_DRAG_CANCEL_REASON);
/**
* GdkDragContext::drop-performed:
* @context: The object on which the signal is emitted
* GdkDrag::drop-performed:
* @drag: The object on which the signal is emitted
*
* The drag and drop operation was performed on an accepting client.
* The drag operation was performed on an accepting client.
*/
signals[DROP_PERFORMED] =
g_signal_new (g_intern_static_string ("drop-performed"),
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdkDragContextClass, drop_performed),
G_STRUCT_OFFSET (GdkDragClass, drop_performed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* GdkDragContext::dnd-finished:
* @context: The object on which the signal is emitted
* GdkDrag::dnd-finished:
* @drag: The object on which the signal is emitted
*
* The drag and drop operation was finished, the drag destination
* finished reading all data. The drag source can now free all
* miscellaneous data.
* The drag operation was finished, the destination
* finished reading all data. The drag object can now
* free all miscellaneous data.
*/
signals[DND_FINISHED] =
g_signal_new (g_intern_static_string ("dnd-finished"),
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdkDragContextClass, dnd_finished),
G_STRUCT_OFFSET (GdkDragClass, dnd_finished),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* GdkDragContext::action-changed:
* @context: The object on which the signal is emitted
* @action: The action currently chosen
*
* A new action is being chosen for the drag and drop operation.
*/
signals[ACTION_CHANGED] =
g_signal_new (g_intern_static_string ("action-changed"),
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdkDragContextClass, action_changed),
NULL, NULL,
g_cclosure_marshal_VOID__FLAGS,
G_TYPE_NONE, 1, GDK_TYPE_DRAG_ACTION);
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
}
/*
* gdk_drag_abort:
* @context: a #GdkDragContext
* @time_: the timestamp for this operation
*
* Aborts a drag without dropping.
*
* This function is called by the drag source.
*/
void
gdk_drag_abort (GdkDragContext *context,
guint32 time_)
{
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
GDK_DRAG_CONTEXT_GET_CLASS (context)->drag_abort (context, time_);
}
/*
* gdk_drag_drop:
* @context: a #GdkDragContext
* @time_: the timestamp for this operation
*
* Drops on the current destination.
*
* This function is called by the drag source.
*/
void
gdk_drag_drop (GdkDragContext *context,
guint32 time_)
{
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
GDK_DRAG_CONTEXT_GET_CLASS (context)->drag_drop (context, time_);
}
static void
gdk_drag_context_write_done (GObject *content,
GAsyncResult *result,
gpointer task)
gdk_drag_write_done (GObject *content,
GAsyncResult *result,
gpointer task)
{
GError *error = NULL;
@@ -504,9 +504,9 @@ gdk_drag_context_write_done (GObject *content,
}
static void
gdk_drag_context_write_serialize_done (GObject *content,
GAsyncResult *result,
gpointer task)
gdk_drag_write_serialize_done (GObject *content,
GAsyncResult *result,
gpointer task)
{
GError *error = NULL;
@@ -519,39 +519,40 @@ gdk_drag_context_write_serialize_done (GObject *content,
}
void
gdk_drag_context_write_async (GdkDragContext *context,
const char *mime_type,
GOutputStream *stream,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
gdk_drag_write_async (GdkDrag *drag,
const char *mime_type,
GOutputStream *stream,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
GdkContentFormats *formats, *mime_formats;
GTask *task;
GType gtype;
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
g_return_if_fail (context->content);
g_return_if_fail (GDK_IS_DRAG (drag));
g_return_if_fail (priv->content);
g_return_if_fail (mime_type != NULL);
g_return_if_fail (mime_type == g_intern_string (mime_type));
g_return_if_fail (G_IS_OUTPUT_STREAM (stream));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
g_return_if_fail (callback != NULL);
task = g_task_new (context, cancellable, callback, user_data);
task = g_task_new (drag, cancellable, callback, user_data);
g_task_set_priority (task, io_priority);
g_task_set_source_tag (task, gdk_drag_context_write_async);
g_task_set_source_tag (task, gdk_drag_write_async);
formats = gdk_content_provider_ref_formats (context->content);
formats = gdk_content_provider_ref_formats (priv->content);
if (gdk_content_formats_contain_mime_type (formats, mime_type))
{
gdk_content_provider_write_mime_type_async (context->content,
gdk_content_provider_write_mime_type_async (priv->content,
mime_type,
stream,
io_priority,
cancellable,
gdk_drag_context_write_done,
gdk_drag_write_done,
task);
gdk_content_formats_unref (formats);
return;
@@ -568,14 +569,14 @@ gdk_drag_context_write_async (GdkDragContext *context,
g_assert (gtype != G_TYPE_INVALID);
g_value_init (&value, gtype);
if (gdk_content_provider_get_value (context->content, &value, &error))
if (gdk_content_provider_get_value (priv->content, &value, &error))
{
gdk_content_serialize_async (stream,
mime_type,
&value,
io_priority,
cancellable,
gdk_drag_context_write_serialize_done,
gdk_drag_write_serialize_done,
g_object_ref (task));
}
else
@@ -597,54 +598,75 @@ gdk_drag_context_write_async (GdkDragContext *context,
}
gboolean
gdk_drag_context_write_finish (GdkDragContext *context,
GAsyncResult *result,
GError **error)
gdk_drag_write_finish (GdkDrag *drag,
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, context), FALSE);
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gdk_drag_context_write_async, FALSE);
g_return_val_if_fail (g_task_is_valid (result, drag), FALSE);
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gdk_drag_write_async, FALSE);
return g_task_propagate_boolean (G_TASK (result), error);
}
void
gdk_drag_context_set_actions (GdkDragContext *context,
GdkDragAction actions,
GdkDragAction suggested_action)
gdk_drag_set_actions (GdkDrag *drag,
GdkDragAction actions)
{
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
if (priv->actions == actions)
return;
priv->actions = actions;
priv->suggested_action = suggested_action;
g_object_notify_by_pspec (G_OBJECT (drag), properties[PROP_ACTIONS]);
}
void
gdk_drag_set_selected_action (GdkDrag *drag,
GdkDragAction action)
{
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
GdkCursor *cursor;
if (priv->selected_action == action)
return;
priv->selected_action = action;
cursor = gdk_drag_get_cursor (drag, action);
gdk_drag_set_cursor (drag, cursor);
g_object_notify_by_pspec (G_OBJECT (drag), properties[PROP_SELECTED_ACTION]);
}
/**
* gdk_drag_context_get_drag_surface:
* @context: a #GdkDragContext
* gdk_drag_get_drag_surface:
* @drag: a #GdkDrag
*
* Returns the surface on which the drag icon should be rendered
* during the drag operation. Note that the surface may not be
* available until the drag operation has begun. GDK will move
* the surface in accordance with the ongoing drag operation.
* The surface is owned by @context and will be destroyed when
* The surface is owned by @drag and will be destroyed when
* the drag operation is over.
*
* Returns: (nullable) (transfer none): the drag surface, or %NULL
*/
GdkSurface *
gdk_drag_context_get_drag_surface (GdkDragContext *context)
gdk_drag_get_drag_surface (GdkDrag *drag)
{
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->get_drag_surface)
return GDK_DRAG_CONTEXT_GET_CLASS (context)->get_drag_surface (context);
if (GDK_DRAG_GET_CLASS (drag)->get_drag_surface)
return GDK_DRAG_GET_CLASS (drag)->get_drag_surface (drag);
return NULL;
}
/**
* gdk_drag_context_set_hotspot:
* @context: a #GdkDragContext
* gdk_drag_set_hotspot:
* @drag: a #GdkDrag
* @hot_x: x coordinate of the drag surface hotspot
* @hot_y: y coordinate of the drag surface hotspot
*
@@ -653,19 +675,19 @@ gdk_drag_context_get_drag_surface (GdkDragContext *context)
* top left corner of the drag surface.
*/
void
gdk_drag_context_set_hotspot (GdkDragContext *context,
gint hot_x,
gint hot_y)
gdk_drag_set_hotspot (GdkDrag *drag,
gint hot_x,
gint hot_y)
{
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
g_return_if_fail (GDK_IS_DRAG (drag));
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->set_hotspot)
GDK_DRAG_CONTEXT_GET_CLASS (context)->set_hotspot (context, hot_x, hot_y);
if (GDK_DRAG_GET_CLASS (drag)->set_hotspot)
GDK_DRAG_GET_CLASS (drag)->set_hotspot (drag, hot_x, hot_y);
}
/**
* gdk_drag_drop_done:
* @context: a #GdkDragContext
* @drag: a #GdkDrag
* @success: whether the drag was ultimatively successful
*
* Inform GDK if the drop ended successfully. Passing %FALSE
@@ -673,60 +695,62 @@ gdk_drag_context_set_hotspot (GdkDragContext *context,
*
* This function is called by the drag source, and should
* be the last call before dropping the reference to the
* @context.
* @drag.
*
* The #GdkDragContext will only take the first gdk_drag_drop_done()
* The #GdkDrag will only take the first gdk_drag_drop_done()
* call as effective, if this function is called multiple times,
* all subsequent calls will be ignored.
*/
void
gdk_drag_drop_done (GdkDragContext *context,
gboolean success)
gdk_drag_drop_done (GdkDrag *drag,
gboolean success)
{
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
if (context->drop_done)
g_return_if_fail (GDK_IS_DRAG (drag));
if (priv->drop_done)
return;
context->drop_done = TRUE;
priv->drop_done = TRUE;
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->drop_done)
GDK_DRAG_CONTEXT_GET_CLASS (context)->drop_done (context, success);
if (GDK_DRAG_GET_CLASS (drag)->drop_done)
GDK_DRAG_GET_CLASS (drag)->drop_done (drag, success);
}
void
gdk_drag_context_set_cursor (GdkDragContext *context,
GdkCursor *cursor)
gdk_drag_set_cursor (GdkDrag *drag,
GdkCursor *cursor)
{
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
g_return_if_fail (GDK_IS_DRAG (drag));
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->set_cursor)
GDK_DRAG_CONTEXT_GET_CLASS (context)->set_cursor (context, cursor);
if (GDK_DRAG_GET_CLASS (drag)->set_cursor)
GDK_DRAG_GET_CLASS (drag)->set_cursor (drag, cursor);
}
void
gdk_drag_context_cancel (GdkDragContext *context,
GdkDragCancelReason reason)
gdk_drag_cancel (GdkDrag *drag,
GdkDragCancelReason reason)
{
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
g_return_if_fail (GDK_IS_DRAG (drag));
g_signal_emit (context, signals[CANCEL], 0, reason);
g_signal_emit (drag, signals[CANCEL], 0, reason);
}
gboolean
gdk_drag_context_handle_source_event (GdkEvent *event)
gdk_drag_handle_source_event (GdkEvent *event)
{
GdkDragContext *context;
GdkDrag *drag;
GList *l;
for (l = contexts; l; l = l->next)
for (l = drags; l; l = l->next)
{
context = l->data;
drag = l->data;
if (!GDK_DRAG_CONTEXT_GET_CLASS (context)->handle_event)
if (!GDK_DRAG_GET_CLASS (drag)->handle_event)
continue;
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->handle_event (context, event))
if (GDK_DRAG_GET_CLASS (drag)->handle_event (drag, event))
return TRUE;
}
@@ -734,8 +758,8 @@ gdk_drag_context_handle_source_event (GdkEvent *event)
}
GdkCursor *
gdk_drag_get_cursor (GdkDragContext *context,
GdkDragAction action)
gdk_drag_get_cursor (GdkDrag *drag,
GdkDragAction action)
{
gint i;
+96
View File
@@ -0,0 +1,96 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GDK_DND_H__
#define __GDK_DND_H__
#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <gdk/gdktypes.h>
#include <gdk/gdkdevice.h>
#include <gdk/gdkevents.h>
G_BEGIN_DECLS
#define GDK_TYPE_DRAG (gdk_drag_get_type ())
#define GDK_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAG, GdkDrag))
#define GDK_IS_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAG))
/**
* GdkDragCancelReason:
* @GDK_DRAG_CANCEL_NO_TARGET: There is no suitable drop target.
* @GDK_DRAG_CANCEL_USER_CANCELLED: Drag cancelled by the user
* @GDK_DRAG_CANCEL_ERROR: Unspecified error.
*
* Used in #GdkDrag to the reason of a cancelled DND operation.
*/
typedef enum {
GDK_DRAG_CANCEL_NO_TARGET,
GDK_DRAG_CANCEL_USER_CANCELLED,
GDK_DRAG_CANCEL_ERROR
} GdkDragCancelReason;
GDK_AVAILABLE_IN_ALL
GType gdk_drag_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GdkDisplay * gdk_drag_get_display (GdkDrag *drag);
GDK_AVAILABLE_IN_ALL
GdkDevice * gdk_drag_get_device (GdkDrag *drag);
GDK_AVAILABLE_IN_ALL
GdkContentFormats *gdk_drag_get_formats (GdkDrag *drag);
GDK_AVAILABLE_IN_ALL
GdkDragAction gdk_drag_get_actions (GdkDrag *drag);
GDK_AVAILABLE_IN_ALL
GdkDragAction gdk_drag_get_selected_action (GdkDrag *drag);
GDK_AVAILABLE_IN_ALL
gboolean gdk_drag_action_is_unique (GdkDragAction action);
GDK_AVAILABLE_IN_ALL
GdkDrag * gdk_drag_begin (GdkSurface *surface,
GdkDevice *device,
GdkContentProvider *content,
GdkDragAction actions,
gint dx,
gint dy);
GDK_AVAILABLE_IN_ALL
void gdk_drag_drop_done (GdkDrag *drag,
gboolean success);
GDK_AVAILABLE_IN_ALL
GdkSurface *gdk_drag_get_drag_surface (GdkDrag *drag);
GDK_AVAILABLE_IN_ALL
void gdk_drag_set_hotspot (GdkDrag *drag,
gint hot_x,
gint hot_y);
G_END_DECLS
#endif /* __GDK_DND_H__ */
+86
View File
@@ -0,0 +1,86 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2010, Red Hat, Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GDK_DND_PRIVATE_H__
#define __GDK_DND_PRIVATE_H__
#include "gdkdrag.h"
G_BEGIN_DECLS
#define GDK_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAG, GdkDragClass))
#define GDK_IS_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DRAG))
#define GDK_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DRAG, GdkDragClass))
typedef struct _GdkDragClass GdkDragClass;
struct _GdkDragClass {
GObjectClass parent_class;
GdkSurface* (*get_drag_surface) (GdkDrag *drag);
void (*set_hotspot) (GdkDrag *drag,
gint hot_x,
gint hot_y);
void (*drop_done) (GdkDrag *drag,
gboolean success);
void (*set_cursor) (GdkDrag *drag,
GdkCursor *cursor);
void (*cancel) (GdkDrag *drag,
GdkDragCancelReason reason);
void (*drop_performed) (GdkDrag *drag,
guint32 time);
void (*dnd_finished) (GdkDrag *drag);
gboolean (*handle_event) (GdkDrag *drag,
const GdkEvent *event);
};
struct _GdkDrag {
GObject parent_instance;
};
void gdk_drag_set_cursor (GdkDrag *drag,
GdkCursor *cursor);
void gdk_drag_set_actions (GdkDrag *drag,
GdkDragAction actions);
void gdk_drag_set_selected_action (GdkDrag *drag,
GdkDragAction action);
void gdk_drag_cancel (GdkDrag *drag,
GdkDragCancelReason reason);
gboolean gdk_drag_handle_source_event (GdkEvent *event);
GdkCursor * gdk_drag_get_cursor (GdkDrag *drag,
GdkDragAction action);
void gdk_drag_write_async (GdkDrag *drag,
const char *mime_type,
GOutputStream *stream,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean gdk_drag_write_finish (GdkDrag *drag,
GAsyncResult *result,
GError **error);
G_END_DECLS
#endif
+18 -7
View File
@@ -38,7 +38,7 @@ typedef struct _GdkDropPrivate GdkDropPrivate;
struct _GdkDropPrivate {
GdkDevice *device;
GdkDragContext *drag;
GdkDrag *drag;
GdkContentFormats *formats;
GdkSurface *surface;
GdkDragAction actions;
@@ -78,7 +78,7 @@ gdk_drop_read_local_write_done (GObject *drag,
gpointer stream)
{
/* we don't care about the error, we just want to clean up */
gdk_drag_context_write_finish (GDK_DRAG_CONTEXT (drag), result, NULL);
gdk_drag_write_finish (GDK_DRAG (drag), result, NULL);
/* XXX: Do we need to close_async() here? */
g_output_stream_close (stream, NULL, NULL);
@@ -98,6 +98,7 @@ gdk_drop_read_local_async (GdkDrop *self,
GdkContentFormats *content_formats;
const char *mime_type;
GTask *task;
GdkContentProvider *content;
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_priority (task, io_priority);
@@ -111,7 +112,9 @@ gdk_drop_read_local_async (GdkDrop *self,
return;
}
content_formats = gdk_content_provider_ref_formats (priv->drag->content);
g_object_get (priv->drag, "content", &content, NULL);
content_formats = gdk_content_provider_ref_formats (content);
g_object_unref (content);
content_formats = gdk_content_formats_union_serialize_mime_types (content_formats);
mime_type = gdk_content_formats_match_mime_type (content_formats, formats);
@@ -122,7 +125,7 @@ gdk_drop_read_local_async (GdkDrop *self,
stream = gdk_pipe_io_stream_new ();
output_stream = g_io_stream_get_output_stream (stream);
gdk_drag_context_write_async (priv->drag,
gdk_drag_write_async (priv->drag,
mime_type,
output_stream,
io_priority,
@@ -321,7 +324,7 @@ gdk_drop_class_init (GdkDropClass *klass)
g_param_spec_object ("drag",
"Drag",
"The drag that initiated this drop",
GDK_TYPE_DRAG_CONTEXT,
GDK_TYPE_DRAG,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS |
@@ -492,7 +495,7 @@ gdk_drop_set_actions (GdkDrop *self,
*
* Returns: (transfer none) (nullable): the corresponding #GdkDrag
**/
GdkDragContext *
GdkDrag *
gdk_drop_get_drag (GdkDrop *self)
{
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
@@ -724,8 +727,16 @@ gdk_drop_read_value_internal (GdkDrop *self,
if (priv->drag)
{
GError *error = NULL;
GdkContentProvider *content;
gboolean res;
if (gdk_content_provider_get_value (priv->drag->content, value, &error))
g_object_get (priv->drag, "content", &content, NULL);
res = gdk_content_provider_get_value (content, value, &error);
g_object_unref (content);
if (res)
{
g_task_return_pointer (task, value, NULL);
g_object_unref (task);
+3 -3
View File
@@ -50,7 +50,7 @@ GdkContentFormats * gdk_drop_get_formats (GdkDrop
GDK_AVAILABLE_IN_ALL
GdkDragAction gdk_drop_get_actions (GdkDrop *self);
GDK_AVAILABLE_IN_ALL
GdkDragContext * gdk_drop_get_drag (GdkDrop *self);
GdkDrag * gdk_drop_get_drag (GdkDrop *self);
GDK_AVAILABLE_IN_ALL
void gdk_drop_status (GdkDrop *self,
@@ -83,12 +83,12 @@ const GValue * gdk_drop_read_value_finish (GdkDrop
GAsyncResult *result,
GError **error);
GDK_AVAILABLE_IN_ALL
void gdk_drop_read_text_async (GdkDrop *drop,
void gdk_drop_read_text_async (GdkDrop *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GDK_AVAILABLE_IN_ALL
char * gdk_drop_read_text_finish (GdkDrop *drop,
char * gdk_drop_read_text_finish (GdkDrop *self,
GAsyncResult *result,
GError **error);
+5 -59
View File
@@ -28,7 +28,7 @@
#include "gdkeventsprivate.h"
#include "gdkinternals.h"
#include "gdkdisplayprivate.h"
#include "gdkdndprivate.h"
#include "gdkdragprivate.h"
#include "gdkdropprivate.h"
#include "gdk-private.h"
@@ -165,7 +165,10 @@ gdk_event_class_init (GdkEventClass *klass)
void
_gdk_event_emit (GdkEvent *event)
{
if (gdk_drag_context_handle_source_event (event))
if (gdk_drag_handle_source_event (event))
return;
if (gdk_surface_handle_event (event))
return;
if (_gdk_event_func)
@@ -628,11 +631,6 @@ gdk_event_copy (const GdkEvent *event)
switch ((guint) event->any.type)
{
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
new_event->key.string = g_strdup (event->key.string);
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
if (event->crossing.child_surface != NULL)
@@ -646,11 +644,6 @@ gdk_event_copy (const GdkEvent *event)
g_object_ref (event->dnd.drop);
break;
case GDK_EXPOSE:
if (event->expose.region)
new_event->expose.region = cairo_region_copy (event->expose.region);
break;
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
if (event->button.axes)
@@ -700,11 +693,6 @@ gdk_event_finalize (GObject *object)
switch ((guint) event->any.type)
{
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
g_free (event->key.string);
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
g_clear_object (&event->crossing.child_surface);
@@ -730,11 +718,6 @@ gdk_event_finalize (GObject *object)
g_free (event->touch.axes);
break;
case GDK_EXPOSE:
if (event->expose.region)
cairo_region_destroy (event->expose.region);
break;
case GDK_MOTION_NOTIFY:
g_clear_object (&event->motion.tool);
g_free (event->motion.axes);
@@ -832,9 +815,6 @@ gdk_event_get_time (const GdkEvent *event)
case GDK_NOTHING:
case GDK_DELETE:
case GDK_DESTROY:
case GDK_EXPOSE:
case GDK_MAP:
case GDK_UNMAP:
case GDK_GRAB_BROKEN:
case GDK_EVENT_LAST:
default:
@@ -908,9 +888,6 @@ gdk_event_get_state (const GdkEvent *event,
case GDK_NOTHING:
case GDK_DELETE:
case GDK_DESTROY:
case GDK_EXPOSE:
case GDK_MAP:
case GDK_UNMAP:
case GDK_GRAB_BROKEN:
case GDK_PAD_BUTTON_PRESS:
case GDK_PAD_BUTTON_RELEASE:
@@ -1306,37 +1283,6 @@ gdk_event_get_key_group (const GdkEvent *event,
return fetched;
}
/**
* gdk_event_get_string:
* @event: a #GdkEvent
* @string: (out) (transfer none): return location for the string
*
* Extracts a string from an event. The string is an
* approximation of the keyval in a key event.
*
* Returns: %TRUE on success, otherwise %FALSE
**/
gboolean
gdk_event_get_string (const GdkEvent *event,
const char **string)
{
gboolean fetched = TRUE;
switch ((guint) event->any.type)
{
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
*string = event->key.string;
break;
default:
*string = NULL;
fetched = FALSE;
break;
}
return fetched;
}
/**
* gdk_event_get_key_is_modifier:
* @event: a #GdkEvent
+1 -12
View File
@@ -31,7 +31,7 @@
#include <gdk/gdkversionmacros.h>
#include <gdk/gdktypes.h>
#include <gdk/gdkdnd.h>
#include <gdk/gdkdrag.h>
#include <gdk/gdkdevice.h>
#include <gdk/gdkdevicetool.h>
@@ -104,7 +104,6 @@ G_BEGIN_DECLS
typedef struct _GdkEventAny GdkEventAny;
typedef struct _GdkEventExpose GdkEventExpose;
typedef struct _GdkEventMotion GdkEventMotion;
typedef struct _GdkEventButton GdkEventButton;
typedef struct _GdkEventTouch GdkEventTouch;
@@ -145,8 +144,6 @@ typedef void (*GdkEventFunc) (GdkEvent *event,
* hidden or destroyed, usually when the user clicks on a special icon in the
* title bar.
* @GDK_DESTROY: the surface has been destroyed.
* @GDK_EXPOSE: all or part of the surface has become visible and needs to be
* redrawn.
* @GDK_MOTION_NOTIFY: the pointer (usually a mouse) has moved.
* @GDK_BUTTON_PRESS: a mouse button has been pressed.
* @GDK_BUTTON_RELEASE: a mouse button has been released.
@@ -157,8 +154,6 @@ typedef void (*GdkEventFunc) (GdkEvent *event,
* @GDK_FOCUS_CHANGE: the keyboard focus has entered or left the surface.
* @GDK_CONFIGURE: the size, position or stacking order of the surface has changed.
* Note that GTK+ discards these events for %GDK_SURFACE_CHILD surfaces.
* @GDK_MAP: the surface has been mapped.
* @GDK_UNMAP: the surface has been unmapped.
* @GDK_PROXIMITY_IN: an input device has moved into contact with a sensing
* surface (e.g. a touchscreen or graphics tablet).
* @GDK_PROXIMITY_OUT: an input device has moved out of contact with a sensing
@@ -206,7 +201,6 @@ typedef enum
GDK_NOTHING,
GDK_DELETE,
GDK_DESTROY,
GDK_EXPOSE,
GDK_MOTION_NOTIFY,
GDK_BUTTON_PRESS,
GDK_BUTTON_RELEASE,
@@ -216,8 +210,6 @@ typedef enum
GDK_LEAVE_NOTIFY,
GDK_FOCUS_CHANGE,
GDK_CONFIGURE,
GDK_MAP,
GDK_UNMAP,
GDK_PROXIMITY_IN,
GDK_PROXIMITY_OUT,
GDK_DRAG_ENTER,
@@ -411,9 +403,6 @@ gboolean gdk_event_get_key_is_modifier (const GdkEvent *event,
GDK_AVAILABLE_IN_ALL
gboolean gdk_event_get_key_group (const GdkEvent *event,
guint *group);
GDK_AVAILABLE_IN_ALL
gboolean gdk_event_get_string (const GdkEvent *event,
const char **string);
GDK_AVAILABLE_IN_ALL
gboolean gdk_event_get_scroll_direction (const GdkEvent *event,
+1 -34
View File
@@ -26,7 +26,7 @@
#define __GDK_EVENTS_PRIVATE_H__
#include <gdk/gdktypes.h>
#include <gdk/gdkdnd.h>
#include <gdk/gdkdrag.h>
#include <gdk/gdkdevice.h>
#include <gdk/gdkdevicetool.h>
@@ -63,23 +63,6 @@ struct _GdkEventAny
GdkDisplay *display;
};
/*
* GdkEventExpose:
* @type: the type of the event (%GDK_EXPOSE)
* @surface: the surface which received the event.
* @send_event: %TRUE if the event was sent explicitly.
* @area: bounding box of @region.
* @region: the region that needs to be redrawn.
*
* Generated when all or part of a surface becomes visible and needs to be
* redrawn.
*/
struct _GdkEventExpose
{
GdkEventAny any;
cairo_region_t *region;
};
/*
* GdkEventMotion:
* @type: the type of the event.
@@ -261,18 +244,6 @@ struct _GdkEventScroll
* @keyval: the key that was pressed or released. See the
* `gdk/gdkkeysyms.h` header file for a
* complete list of GDK key codes.
* @length: the length of @string.
* @string: a string containing an approximation of the text that
* would result from this keypress. The only correct way to handle text
* input of text is using input methods (see #GtkIMContext), so this
* field is deprecated and should never be used.
* (gdk_unicode_to_keyval() provides a non-deprecated way of getting
* an approximate translation for a key.) The string is encoded in the
* encoding of the current locale (Note: this for backwards compatibility:
* strings in GTK+ and GDK are typically in UTF-8.) and NUL-terminated.
* In some cases, the translation of the key code will be a single
* NUL byte, in which case looking at @length is necessary to distinguish
* it from the an empty translation.
* @hardware_keycode: the raw code of the key that was pressed or released.
* @group: the keyboard group.
* @is_modifier: a flag that indicates if @hardware_keycode is mapped to a
@@ -286,8 +257,6 @@ struct _GdkEventKey
guint32 time;
guint state;
guint keyval;
gint length;
gchar *string;
guint16 hardware_keycode;
guint16 key_scancode;
guint8 group;
@@ -593,7 +562,6 @@ struct _GdkEventPadGroupMode {
* GdkEvent:
* @type: the #GdkEventType
* @any: a #GdkEventAny
* @expose: a #GdkEventExpose
* @motion: a #GdkEventMotion
* @button: a #GdkEventButton
* @touch: a #GdkEventTouch
@@ -645,7 +613,6 @@ struct _GdkEventPadGroupMode {
union _GdkEvent
{
GdkEventAny any;
GdkEventExpose expose;
GdkEventMotion motion;
GdkEventButton button;
GdkEventTouch touch;
+3 -1
View File
@@ -32,7 +32,7 @@
#include "gdkdisplay.h"
#include "gdkeventsprivate.h"
#include "gdkenumtypes.h"
#include "gdkdndprivate.h"
#include "gdkdragprivate.h"
G_BEGIN_DECLS
@@ -291,6 +291,8 @@ GdkGLContext * gdk_surface_get_paint_gl_context (GdkSurface *surface,
void gdk_surface_get_unscaled_size (GdkSurface *surface,
int *unscaled_width,
int *unscaled_height);
gboolean gdk_surface_handle_event (GdkEvent *event);
/*****************************************
* Interfaces provided by windowing code *
+2 -2
View File
@@ -643,8 +643,8 @@ gdk_paintable_new_empty (int intrinsic_width,
{
GdkEmptyPaintable *result;
g_return_val_if_fail (intrinsic_width < 0, NULL);
g_return_val_if_fail (intrinsic_height < 0, NULL);
g_return_val_if_fail (intrinsic_width >= 0, NULL);
g_return_val_if_fail (intrinsic_height >= 0, NULL);
result = g_object_new (GDK_TYPE_EMPTY_PAINTABLE, NULL);
+73 -79
View File
@@ -97,6 +97,8 @@
enum {
MOVED_TO_RECT,
SIZE_CHANGED,
RENDER,
LAST_SIGNAL
};
@@ -105,6 +107,7 @@ enum {
PROP_CURSOR,
PROP_DISPLAY,
PROP_STATE,
PROP_MAPPED,
LAST_PROP
};
@@ -271,6 +274,13 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
GDK_TYPE_SURFACE_STATE, GDK_SURFACE_STATE_WITHDRAWN,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
properties[PROP_MAPPED] =
g_param_spec_boolean ("mapped",
P_("Mapped"),
P_("Mapped"),
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, LAST_PROP, properties);
/**
@@ -310,6 +320,31 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
G_TYPE_POINTER,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN);
signals[SIZE_CHANGED] =
g_signal_new (g_intern_static_string ("size-changed"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL,
NULL,
NULL,
G_TYPE_NONE,
2,
G_TYPE_INT,
G_TYPE_INT);
signals[RENDER] =
g_signal_new (g_intern_static_string ("render"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled,
NULL,
NULL,
G_TYPE_BOOLEAN,
1,
CAIRO_GOBJECT_TYPE_REGION);
}
static void
@@ -416,6 +451,10 @@ gdk_surface_get_property (GObject *object,
g_value_set_flags (value, surface->state);
break;
case PROP_MAPPED:
g_value_set_boolean (value, GDK_SURFACE_IS_MAPPED (surface));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -946,6 +985,7 @@ _gdk_surface_destroy_hierarchy (GdkSurface *surface,
surface_remove_from_pointer_info (surface, display);
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_STATE]);
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_MAPPED]);
break;
}
}
@@ -1617,20 +1657,13 @@ static void
gdk_surface_process_updates_recurse (GdkSurface *surface,
cairo_region_t *expose_region)
{
GdkEvent *event;
gboolean handled;
if (surface->destroyed)
return;
/* Paint the surface before the children, clipped to the surface region */
event = gdk_event_new (GDK_EXPOSE);
event->any.surface = g_object_ref (surface);
event->any.send_event = FALSE;
event->expose.region = cairo_region_reference (expose_region);
_gdk_event_emit (event);
g_object_unref (event);
g_signal_emit (surface, signals[RENDER], 0, expose_region, &handled);
}
/* Process and remove any invalid area on the native surface by creating
@@ -2250,6 +2283,7 @@ gdk_surface_show_internal (GdkSurface *surface, gboolean raise)
{
surface->state = 0;
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_STATE]);
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_MAPPED]);
}
did_show = _gdk_surface_update_viewable (surface);
@@ -2265,14 +2299,6 @@ gdk_surface_show_internal (GdkSurface *surface, gboolean raise)
impl_class->show (surface, !did_show ? was_mapped : TRUE);
}
if (!was_mapped && !gdk_surface_has_impl (surface))
{
_gdk_make_event (surface, GDK_MAP, NULL, FALSE);
if (surface->parent)
_gdk_make_event (surface, GDK_MAP, NULL, FALSE);
}
if (!was_mapped || did_raise)
{
recompute_visible_regions (surface, FALSE);
@@ -2308,7 +2334,7 @@ gdk_surface_show_unraised (GdkSurface *surface)
* other surfaces with the same parent surface appear below @surface.
* This is true whether or not the surfaces are visible.
*
* If @surface is a toplevel, the surface manager may choose to deny the
* If @surface is a toplevel, the window manager may choose to deny the
* request to move the surface in the Z-order, gdk_surface_raise() only
* requests the restack, does not guarantee it.
*/
@@ -2529,6 +2555,7 @@ gdk_surface_hide (GdkSurface *surface)
{
surface->state = GDK_SURFACE_STATE_WITHDRAWN;
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_STATE]);
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_MAPPED]);
}
if (was_mapped)
@@ -2575,62 +2602,11 @@ G_GNUC_END_IGNORE_DEPRECATIONS
recompute_visible_regions (surface, FALSE);
if (was_mapped && !gdk_surface_has_impl (surface))
{
_gdk_make_event (surface, GDK_UNMAP, NULL, FALSE);
if (surface->parent)
_gdk_make_event (surface, GDK_UNMAP, NULL, FALSE);
}
/* Invalidate the rect */
if (was_mapped)
gdk_surface_invalidate_in_parent (surface);
}
/**
* gdk_surface_withdraw:
* @surface: a toplevel #GdkSurface
*
* Withdraws a surface (unmaps it and asks the surface manager to forget about it).
* This function is not really useful as gdk_surface_hide() automatically
* withdraws toplevel surfaces before hiding them.
**/
void
gdk_surface_withdraw (GdkSurface *surface)
{
GdkSurfaceImplClass *impl_class;
gboolean was_mapped;
GdkGLContext *current_context;
g_return_if_fail (GDK_IS_SURFACE (surface));
if (surface->destroyed)
return;
was_mapped = GDK_SURFACE_IS_MAPPED (surface);
if (gdk_surface_has_impl (surface))
{
impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
impl_class->withdraw (surface);
if (was_mapped)
{
_gdk_make_event (surface, GDK_UNMAP, NULL, FALSE);
if (surface->parent)
_gdk_make_event (surface, GDK_UNMAP, NULL, FALSE);
}
current_context = gdk_gl_context_get_current ();
if (current_context != NULL && gdk_gl_context_get_surface (current_context) == surface)
gdk_gl_context_clear_current ();
recompute_visible_regions (surface, FALSE);
}
}
static void
gdk_surface_move_resize_toplevel (GdkSurface *surface,
gboolean with_move,
@@ -2917,7 +2893,7 @@ gdk_surface_get_cursor (GdkSurface *surface)
*
* Note that @cursor must be for the same display as @surface.
*
* Use gdk_cursor_new_for_display() or gdk_cursor_new_from_texture() to
* Use gdk_cursor_new_from_name() or gdk_cursor_new_from_texture() to
* create the cursor. To make the cursor invisible, use %GDK_BLANK_CURSOR.
* Passing %NULL for the @cursor argument to gdk_surface_set_cursor() means
* that @surface will use the cursor of its parent surface. Most surfaces
@@ -3004,7 +2980,7 @@ gdk_surface_get_device_cursor (GdkSurface *surface,
* @cursor: a #GdkCursor
*
* Sets a specific #GdkCursor for a given device when it gets inside @surface.
* Use gdk_cursor_new_for_display() or gdk_cursor_new_from_texture() to create
* Use gdk_cursor_new_fromm_name() or gdk_cursor_new_from_texture() to create
* the cursor. To make the cursor invisible, use %GDK_BLANK_CURSOR. Passing
* %NULL for the @cursor argument to gdk_surface_set_cursor() means that
* @surface will use the cursor of its parent surface. Most surfaces should
@@ -3445,7 +3421,7 @@ gdk_surface_merge_child_input_shapes (GdkSurface *surface)
* gdk_surface_get_modal_hint:
* @surface: A toplevel #GdkSurface.
*
* Determines whether or not the surface manager is hinted that @surface
* Determines whether or not the window manager is hinted that @surface
* has modal behaviour.
*
* Returns: whether or not the surface has the modal hint set.
@@ -3909,11 +3885,8 @@ _gdk_make_event (GdkSurface *surface,
case GDK_FOCUS_CHANGE:
case GDK_CONFIGURE:
case GDK_MAP:
case GDK_UNMAP:
case GDK_DELETE:
case GDK_DESTROY:
case GDK_EXPOSE:
default:
break;
}
@@ -4427,7 +4400,7 @@ gdk_surface_set_transient_for (GdkSurface *surface,
* @x: (out): return location for X position of surface frame
* @y: (out): return location for Y position of surface frame
*
* Obtains the top-left corner of the surface manager frame in root
* Obtains the top-left corner of the window manager frame in root
* surface coordinates.
*
**/
@@ -5140,10 +5113,10 @@ gdk_surface_register_dnd (GdkSurface *surface)
*
* This function is called by the drag source.
*
* Returns: (transfer full) (nullable): a newly created #GdkDragContext or
* Returns: (transfer full) (nullable): a newly created #GdkDrag or
* %NULL on error.
*/
GdkDragContext *
GdkDrag *
gdk_drag_begin (GdkSurface *surface,
GdkDevice *device,
GdkContentProvider *content,
@@ -5467,6 +5440,7 @@ void
gdk_surface_set_state (GdkSurface *surface,
GdkSurfaceState new_state)
{
gboolean was_mapped, mapped;
g_return_if_fail (GDK_IS_SURFACE (surface));
if (new_state == surface->state)
@@ -5477,8 +5451,12 @@ gdk_surface_set_state (GdkSurface *surface,
* inconsistent state to the user.
*/
was_mapped = GDK_SURFACE_IS_MAPPED (surface);
surface->state = new_state;
mapped = GDK_SURFACE_IS_MAPPED (surface);
_gdk_surface_update_viewable (surface);
/* We only really send the event to toplevels, since
@@ -5490,12 +5468,15 @@ gdk_surface_set_state (GdkSurface *surface,
{
case GDK_SURFACE_TOPLEVEL:
case GDK_SURFACE_TEMP: /* ? */
g_object_notify (G_OBJECT (surface), "state");
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_STATE]);
break;
case GDK_SURFACE_CHILD:
default:
break;
}
if (was_mapped != mapped)
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_MAPPED]);
}
void
@@ -5505,3 +5486,16 @@ gdk_synthesize_surface_state (GdkSurface *surface,
{
gdk_surface_set_state (surface, (surface->state | set_flags) & ~unset_flags);
}
gboolean
gdk_surface_handle_event (GdkEvent *event)
{
if (gdk_event_get_event_type (event) == GDK_CONFIGURE)
{
g_signal_emit (gdk_event_get_surface (event), signals[SIZE_CHANGED], 0,
event->configure.width, event->configure.height);
return TRUE;
}
return FALSE;
}
-2
View File
@@ -460,8 +460,6 @@ void gdk_surface_show (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_hide (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_withdraw (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_show_unraised (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_move (GdkSurface *surface,
+1 -1
View File
@@ -193,7 +193,7 @@ struct _GdkSurfaceImplClass
gdouble opacity);
void (* destroy_notify) (GdkSurface *surface);
void (* register_dnd) (GdkSurface *surface);
GdkDragContext * (*drag_begin) (GdkSurface *surface,
GdkDrag * (*drag_begin) (GdkSurface *surface,
GdkDevice *device,
GdkContentProvider*content,
GdkDragAction actions,
+2 -2
View File
@@ -123,7 +123,7 @@ typedef struct _GdkContentProvider GdkContentProvider;
typedef struct _GdkCursor GdkCursor;
typedef struct _GdkTexture GdkTexture;
typedef struct _GdkDevice GdkDevice;
typedef struct _GdkDragContext GdkDragContext;
typedef struct _GdkDrag GdkDrag;
typedef struct _GdkDrop GdkDrop;
typedef struct _GdkClipboard GdkClipboard;
@@ -571,7 +571,7 @@ typedef enum
* useful if source and destination agree on what it means.
* @GDK_ACTION_ASK: Ask the user what to do with the data.
*
* Used in #GdkDragContext to indicate what the destination
* Used in #GdkDrag to indicate what the destination
* should do with the dropped data.
*/
typedef enum
+2 -2
View File
@@ -15,7 +15,7 @@ gdk_public_sources = files([
'gdkdevicetool.c',
'gdkdisplay.c',
'gdkdisplaymanager.c',
'gdkdnd.c',
'gdkdrag.c',
'gdkdrawcontext.c',
'gdkdrop.c',
'gdkevents.c',
@@ -65,7 +65,7 @@ gdk_public_headers = files([
'gdkdevicetool.h',
'gdkdisplay.h',
'gdkdisplaymanager.h',
'gdkdnd.h',
'gdkdrag.h',
'gdkdrawcontext.h',
'gdkdrop.h',
'gdkevents.h',
-40
View File
@@ -1113,8 +1113,6 @@ fill_key_event (GdkSurface *window,
{
GdkEventPrivate *priv;
GdkQuartzDeviceManagerCore *device_manager;
gchar buf[7];
gunichar c = 0;
priv = (GdkEventPrivate *) event;
priv->windowing_data = [nsevent retain];
@@ -1189,44 +1187,6 @@ fill_key_event (GdkSurface *window,
gdk_keymap_add_virtual_modifiers (gdk_display_get_keymap (_gdk_display),
&event->key.state);
event->key.string = NULL;
/* Fill in ->string since apps depend on it, taken from the x11 backend. */
if (event->key.keyval != GDK_KEY_VoidSymbol)
c = gdk_keyval_to_unicode (event->key.keyval);
if (c)
{
gsize bytes_written;
gint len;
len = g_unichar_to_utf8 (c, buf);
buf[len] = '\0';
event->key.string = g_locale_from_utf8 (buf, len,
NULL, &bytes_written,
NULL);
if (event->key.string)
event->key.length = bytes_written;
}
else if (event->key.keyval == GDK_KEY_Escape)
{
event->key.length = 1;
event->key.string = g_strdup ("\033");
}
else if (event->key.keyval == GDK_KEY_Return ||
event->key.keyval == GDK_KEY_KP_Enter)
{
event->key.length = 1;
event->key.string = g_strdup ("\r");
}
if (!event->key.string)
{
event->key.length = 0;
event->key.string = g_strdup ("");
}
GDK_NOTE(EVENTS,
g_message ("key %s:\t\twindow: %p key: %12s %d",
type == GDK_KEY_PRESS ? "press" : "release",
+2 -2
View File
@@ -52,13 +52,13 @@ static void
gdk_wayland_clipboard_discard_offer (GdkWaylandClipboard *cb)
{
g_clear_pointer (&cb->offer_formats, gdk_content_formats_unref);
g_clear_pointer (&cb->offer, (GDestroyNotify) wl_data_offer_destroy);
g_clear_pointer (&cb->offer, wl_data_offer_destroy);
}
static void
gdk_wayland_clipboard_discard_source (GdkWaylandClipboard *cb)
{
g_clear_pointer (&cb->source, (GDestroyNotify) wl_data_source_destroy);
g_clear_pointer (&cb->source, wl_data_source_destroy);
}
static void
+13 -87
View File
@@ -247,12 +247,9 @@ struct _GdkWaylandSeat
GdkClipboard *clipboard;
GdkClipboard *primary_clipboard;
struct wl_data_device *data_device;
GdkDragContext *drag;
GdkDrag *drag;
GdkDrop *drop;
/* Source/dest for non-local dnd */
GdkSurface *foreign_dnd_surface;
/* Some tracking on gesture events */
guint gesture_n_fingers;
gdouble gesture_scale;
@@ -1090,7 +1087,7 @@ gdk_wayland_seat_discard_pending_offer (GdkWaylandSeat *seat)
gdk_content_formats_unref (ignore);
seat->pending_builder = NULL;
}
g_clear_pointer (&seat->pending_offer, (GDestroyNotify) wl_data_offer_destroy);
g_clear_pointer (&seat->pending_offer, wl_data_offer_destroy);
seat->pending_source_actions = 0;
seat->pending_action = 0;
}
@@ -2012,73 +2009,6 @@ keyboard_handle_leave (void *data,
static gboolean keyboard_repeat (gpointer data);
static void
translate_keyboard_string (GdkEventKey *event)
{
gunichar c = 0;
gchar buf[7];
/* Fill in event->string crudely, since various programs
* depend on it.
*/
event->string = NULL;
if (event->keyval != GDK_KEY_VoidSymbol)
c = gdk_keyval_to_unicode (event->keyval);
if (c)
{
gsize bytes_written;
gint len;
/* Apply the control key - Taken from Xlib */
if (event->state & GDK_CONTROL_MASK)
{
if ((c >= '@' && c < '\177') || c == ' ')
c &= 0x1F;
else if (c == '2')
{
event->string = g_memdup ("\0\0", 2);
event->length = 1;
buf[0] = '\0';
return;
}
else if (c >= '3' && c <= '7')
c -= ('3' - '\033');
else if (c == '8')
c = '\177';
else if (c == '/')
c = '_' & 0x1F;
}
len = g_unichar_to_utf8 (c, buf);
buf[len] = '\0';
event->string = g_locale_from_utf8 (buf, len,
NULL, &bytes_written,
NULL);
if (event->string)
event->length = bytes_written;
}
else if (event->keyval == GDK_KEY_Escape)
{
event->length = 1;
event->string = g_strdup ("\033");
}
else if (event->keyval == GDK_KEY_Return ||
event->keyval == GDK_KEY_KP_Enter)
{
event->length = 1;
event->string = g_strdup ("\r");
}
if (!event->string)
{
event->length = 0;
event->string = g_strdup ("");
}
}
static GSettings *
get_keyboard_settings (GdkWaylandSeat *seat)
{
@@ -2194,17 +2124,15 @@ deliver_key_event (GdkWaylandSeat *seat,
event->key.keyval = sym;
event->key.is_modifier = _gdk_wayland_keymap_key_is_modifier (keymap, key);
translate_keyboard_string (&event->key);
_gdk_wayland_display_deliver_event (seat->display, event);
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("keyboard %s event%s, code %d, sym %d, "
"string %s, mods 0x%x",
"mods 0x%x",
(state ? "press" : "release"),
(from_key_repeat ? " (repeat)" : ""),
event->key.hardware_keycode, event->key.keyval,
event->key.string, event->key.state));
event->key.state));
if (!xkb_keymap_key_repeats (xkb_keymap, key))
return;
@@ -4516,6 +4444,12 @@ pointer_surface_update_scale (GdkDevice *device)
gdk_wayland_device_update_surface_cursor (device);
}
void
gdk_wayland_seat_update_cursor_scale (GdkWaylandSeat *seat)
{
pointer_surface_update_scale (seat->master_pointer);
}
static void
pointer_surface_enter (void *data,
struct wl_surface *wl_surface,
@@ -4556,12 +4490,6 @@ static const struct wl_surface_listener pointer_surface_listener = {
pointer_surface_leave
};
static GdkSurface *
create_foreign_dnd_surface (GdkDisplay *display)
{
return gdk_surface_new_popup (display, &(GdkRectangle) { 0, 0, 1, 1 });
}
static void
gdk_wayland_pointer_data_finalize (GdkWaylandPointerData *pointer)
{
@@ -4596,7 +4524,6 @@ gdk_wayland_seat_finalize (GObject *object)
g_clear_object (&seat->clipboard);
g_clear_object (&seat->primary_clipboard);
g_hash_table_destroy (seat->touches);
gdk_surface_destroy (seat->foreign_dnd_surface);
zwp_tablet_seat_v2_destroy (seat->wp_tablet_seat);
stop_key_repeat (seat);
@@ -4938,7 +4865,6 @@ _gdk_wayland_display_create_seat (GdkWaylandDisplay *display_wayland,
seat->keymap = _gdk_wayland_keymap_new (display);
seat->display = display;
seat->touches = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) g_free);
seat->foreign_dnd_surface = create_foreign_dnd_surface (display);
seat->wl_seat = wl_seat;
wl_seat_add_listener (seat->wl_seat, &seat_listener, seat);
@@ -5133,12 +5059,12 @@ gdk_wayland_seat_set_global_cursor (GdkSeat *seat,
}
void
gdk_wayland_seat_set_drag (GdkSeat *seat,
GdkDragContext *context)
gdk_wayland_seat_set_drag (GdkSeat *seat,
GdkDrag *drag)
{
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
g_set_object (&wayland_seat->drag, context);
g_set_object (&wayland_seat->drag, drag);
}
struct wl_data_device *
+12
View File
@@ -38,6 +38,7 @@
#include "gdkdisplay.h"
#include "gdkdisplay-wayland.h"
#include "gdkmonitor-wayland.h"
#include "gdkseat-wayland.h"
#include "gdkinternals.h"
#include "gdkdeviceprivate.h"
#include "gdkkeysprivate.h"
@@ -1883,9 +1884,20 @@ transform_to_string (int transform)
static void
update_scale (GdkDisplay *display)
{
GList *seats;
GList *l;
g_list_foreach (gdk_wayland_display_get_toplevel_surfaces (display),
(GFunc)gdk_wayland_surface_update_scale,
NULL);
seats = gdk_display_list_seats (display);
for (l = seats; l; l = l->next)
{
GdkSeat *seat = l->data;
gdk_wayland_seat_update_cursor_scale (GDK_WAYLAND_SEAT (seat));
}
g_list_free (seats);
}
static void
-440
View File
@@ -1,440 +0,0 @@
/*
* Copyright © 2010 Intel Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkdndprivate.h"
#include "gdkinternals.h"
#include "gdkproperty.h"
#include "gdkprivate-wayland.h"
#include "gdkcontentformats.h"
#include "gdkdisplay-wayland.h"
#include "gdkintl.h"
#include "gdkseat-wayland.h"
#include "gdkdeviceprivate.h"
#include <glib-unix.h>
#include <gio/gunixinputstream.h>
#include <gio/gunixoutputstream.h>
#include <string.h>
#define GDK_TYPE_WAYLAND_DRAG_CONTEXT (gdk_wayland_drag_context_get_type ())
#define GDK_WAYLAND_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_DRAG_CONTEXT, GdkWaylandDragContext))
#define GDK_WAYLAND_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_DRAG_CONTEXT, GdkWaylandDragContextClass))
#define GDK_IS_WAYLAND_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DRAG_CONTEXT))
#define GDK_IS_WAYLAND_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_DRAG_CONTEXT))
#define GDK_WAYLAND_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_DRAG_CONTEXT, GdkWaylandDragContextClass))
typedef struct _GdkWaylandDragContext GdkWaylandDragContext;
typedef struct _GdkWaylandDragContextClass GdkWaylandDragContextClass;
struct _GdkWaylandDragContext
{
GdkDragContext context;
GdkSurface *dnd_surface;
struct wl_surface *dnd_wl_surface;
struct wl_data_source *data_source;
struct wl_data_offer *offer;
GdkDragAction selected_action;
uint32_t serial;
gint hot_x;
gint hot_y;
};
struct _GdkWaylandDragContextClass
{
GdkDragContextClass parent_class;
};
static GList *contexts;
GType gdk_wayland_drag_context_get_type (void);
G_DEFINE_TYPE (GdkWaylandDragContext, gdk_wayland_drag_context, GDK_TYPE_DRAG_CONTEXT)
static void
gdk_wayland_drag_context_finalize (GObject *object)
{
GdkWaylandDragContext *wayland_context = GDK_WAYLAND_DRAG_CONTEXT (object);
GdkDragContext *context = GDK_DRAG_CONTEXT (object);
GdkSurface *dnd_surface;
contexts = g_list_remove (contexts, context);
gdk_drag_context_set_cursor (context, NULL);
g_clear_pointer (&wayland_context->data_source, (GDestroyNotify) wl_data_source_destroy);
g_clear_pointer (&wayland_context->offer, (GDestroyNotify) wl_data_offer_destroy);
dnd_surface = wayland_context->dnd_surface;
G_OBJECT_CLASS (gdk_wayland_drag_context_parent_class)->finalize (object);
if (dnd_surface)
gdk_surface_destroy (dnd_surface);
}
static inline uint32_t
gdk_to_wl_actions (GdkDragAction action)
{
uint32_t dnd_actions = 0;
if (action & (GDK_ACTION_COPY | GDK_ACTION_LINK))
dnd_actions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
if (action & GDK_ACTION_MOVE)
dnd_actions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
if (action & GDK_ACTION_ASK)
dnd_actions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
return dnd_actions;
}
static void
gdk_wayland_drag_context_drag_abort (GdkDragContext *context,
guint32 time)
{
}
static void
gdk_wayland_drag_context_drag_drop (GdkDragContext *context,
guint32 time)
{
}
static void
gdk_wayland_drag_context_init (GdkWaylandDragContext *context_wayland)
{
GdkDragContext *context;
context = GDK_DRAG_CONTEXT (context_wayland);
contexts = g_list_prepend (contexts, context);
context->action = GDK_ACTION_COPY;
}
static GdkSurface *
gdk_wayland_drag_context_get_drag_surface (GdkDragContext *context)
{
return GDK_WAYLAND_DRAG_CONTEXT (context)->dnd_surface;
}
static void
gdk_wayland_drag_context_set_hotspot (GdkDragContext *context,
gint hot_x,
gint hot_y)
{
GdkWaylandDragContext *context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context);
gint prev_hot_x = context_wayland->hot_x;
gint prev_hot_y = context_wayland->hot_y;
const GdkRectangle damage_rect = { .width = 1, .height = 1 };
context_wayland->hot_x = hot_x;
context_wayland->hot_y = hot_y;
if (prev_hot_x == hot_x && prev_hot_y == hot_y)
return;
_gdk_wayland_surface_offset_next_wl_buffer (context_wayland->dnd_surface,
-hot_x, -hot_y);
gdk_surface_invalidate_rect (context_wayland->dnd_surface, &damage_rect);
}
static void
gdk_wayland_drag_context_set_cursor (GdkDragContext *context,
GdkCursor *cursor)
{
GdkDevice *device = gdk_drag_context_get_device (context);
gdk_wayland_seat_set_global_cursor (gdk_device_get_seat (device), cursor);
}
static void
gdk_wayland_drag_context_action_changed (GdkDragContext *context,
GdkDragAction action)
{
GdkCursor *cursor;
cursor = gdk_drag_get_cursor (context, action);
gdk_drag_context_set_cursor (context, cursor);
}
static void
gdk_wayland_drag_context_drop_performed (GdkDragContext *context,
guint32 time_)
{
gdk_drag_context_set_cursor (context, NULL);
}
static void
gdk_wayland_drag_context_cancel (GdkDragContext *context,
GdkDragCancelReason reason)
{
gdk_drag_context_set_cursor (context, NULL);
}
static void
gdk_wayland_drag_context_drop_done (GdkDragContext *context,
gboolean success)
{
GdkWaylandDragContext *context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context);
GdkDevice *device = gdk_drag_context_get_device (context);
gdk_wayland_seat_set_drag (gdk_device_get_seat (device), context);
if (success)
{
if (context_wayland->dnd_surface)
gdk_surface_hide (context_wayland->dnd_surface);
}
}
static void
gdk_wayland_drag_context_class_init (GdkWaylandDragContextClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkDragContextClass *context_class = GDK_DRAG_CONTEXT_CLASS (klass);
object_class->finalize = gdk_wayland_drag_context_finalize;
context_class->drag_abort = gdk_wayland_drag_context_drag_abort;
context_class->drag_drop = gdk_wayland_drag_context_drag_drop;
context_class->get_drag_surface = gdk_wayland_drag_context_get_drag_surface;
context_class->set_hotspot = gdk_wayland_drag_context_set_hotspot;
context_class->drop_done = gdk_wayland_drag_context_drop_done;
context_class->set_cursor = gdk_wayland_drag_context_set_cursor;
context_class->action_changed = gdk_wayland_drag_context_action_changed;
context_class->drop_performed = gdk_wayland_drag_context_drop_performed;
context_class->cancel = gdk_wayland_drag_context_cancel;
}
void
_gdk_wayland_surface_register_dnd (GdkSurface *surface)
{
}
static GdkSurface *
create_dnd_surface (GdkDisplay *display)
{
GdkSurface *surface;
surface = gdk_surface_new_popup (display, &(GdkRectangle) { 0, 0, 100, 100 });
gdk_surface_set_type_hint (surface, GDK_SURFACE_TYPE_HINT_DND);
return surface;
}
static inline GdkDragAction
_wl_to_gdk_actions (uint32_t dnd_actions)
{
GdkDragAction actions = 0;
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
actions |= GDK_ACTION_COPY;
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
actions |= GDK_ACTION_MOVE;
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
actions |= GDK_ACTION_ASK;
return actions;
}
static void
data_source_target (void *data,
struct wl_data_source *source,
const char *mime_type)
{
GDK_NOTE (EVENTS,
g_message ("data source target, source = %p, mime_type = %s",
source, mime_type));
}
static void
gdk_wayland_drag_context_write_done (GObject *context,
GAsyncResult *result,
gpointer user_data)
{
GError *error = NULL;
if (!gdk_drag_context_write_finish (GDK_DRAG_CONTEXT (context), result, &error))
{
GDK_DISPLAY_NOTE (gdk_drag_context_get_display (GDK_DRAG_CONTEXT (context)), DND, g_message ("%p: failed to write stream: %s", context, error->message));
g_error_free (error);
}
}
static void
data_source_send (void *data,
struct wl_data_source *source,
const char *mime_type,
int32_t fd)
{
GdkDragContext *context = data;
GOutputStream *stream;
GDK_DISPLAY_NOTE (gdk_drag_context_get_display (context), DND, g_message ("%p: data source send request for %s on fd %d\n",
source, mime_type, fd));
//mime_type = gdk_intern_mime_type (mime_type);
mime_type = g_intern_string (mime_type);
stream = g_unix_output_stream_new (fd, TRUE);
gdk_drag_context_write_async (context,
mime_type,
stream,
G_PRIORITY_DEFAULT,
NULL,
gdk_wayland_drag_context_write_done,
context);
g_object_unref (stream);
}
static void
data_source_cancelled (void *data,
struct wl_data_source *source)
{
GdkDragContext *context = data;
GDK_DISPLAY_NOTE (gdk_drag_context_get_display (context), EVENTS,
g_message ("data source cancelled, source = %p", source));
gdk_drag_context_cancel (context, GDK_DRAG_CANCEL_ERROR);
}
static void
data_source_dnd_drop_performed (void *data,
struct wl_data_source *source)
{
GdkDragContext *context = data;
g_signal_emit_by_name (context, "drop-performed");
}
static void
data_source_dnd_finished (void *data,
struct wl_data_source *source)
{
GdkDragContext *context = data;
g_signal_emit_by_name (context, "dnd-finished");
}
static void
data_source_action (void *data,
struct wl_data_source *source,
uint32_t action)
{
GdkDragContext *context = data;
GDK_DISPLAY_NOTE (gdk_drag_context_get_display (context), EVENTS,
g_message ("data source action, source = %p action=%x",
source, action));
context->action = _wl_to_gdk_actions (action);
g_signal_emit_by_name (context, "action-changed", context->action);
}
static const struct wl_data_source_listener data_source_listener = {
data_source_target,
data_source_send,
data_source_cancelled,
data_source_dnd_drop_performed,
data_source_dnd_finished,
data_source_action,
};
static void
gdk_wayland_drag_context_create_data_source (GdkDragContext *context)
{
GdkWaylandDragContext *context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context);
GdkDisplay *display = gdk_drag_context_get_display (context);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
const char *const *mimetypes;
gsize i, n_mimetypes;
context_wayland->data_source = wl_data_device_manager_create_data_source (display_wayland->data_device_manager);
wl_data_source_add_listener (context_wayland->data_source,
&data_source_listener,
context);
mimetypes = gdk_content_formats_get_mime_types (gdk_drag_context_get_formats (context), &n_mimetypes);
for (i = 0; i < n_mimetypes; i++)
{
wl_data_source_offer (context_wayland->data_source, mimetypes[i]);
}
}
GdkDragContext *
_gdk_wayland_surface_drag_begin (GdkSurface *surface,
GdkDevice *device,
GdkContentProvider *content,
GdkDragAction actions,
gint dx,
gint dy)
{
GdkWaylandDragContext *context_wayland;
GdkDragContext *context;
GdkSeat *seat;
GdkWaylandDisplay *display_wayland;
display_wayland = GDK_WAYLAND_DISPLAY (gdk_device_get_display (device));
seat = gdk_device_get_seat (device);
context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT,
"device", device,
"content", content,
NULL);
context = GDK_DRAG_CONTEXT (context_wayland);
context->source_surface = g_object_ref (surface);
context_wayland->dnd_surface = create_dnd_surface (gdk_surface_get_display (surface));
context_wayland->dnd_wl_surface = gdk_wayland_surface_get_wl_surface (context_wayland->dnd_surface);
gdk_wayland_drag_context_create_data_source (context);
if (display_wayland->data_device_manager_version >=
WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION)
{
wl_data_source_set_actions (context_wayland->data_source,
gdk_to_wl_actions (actions));
}
gdk_wayland_seat_set_drag (seat, context);
wl_data_device_start_drag (gdk_wayland_device_get_data_device (device),
context_wayland->data_source,
gdk_wayland_surface_get_wl_surface (surface),
context_wayland->dnd_wl_surface,
_gdk_wayland_display_get_serial (display_wayland));
gdk_seat_ungrab (seat);
return context;
}
void
_gdk_wayland_drag_context_set_source_surface (GdkDragContext *context,
GdkSurface *surface)
{
if (context->source_surface)
g_object_unref (context->source_surface);
context->source_surface = surface ? g_object_ref (surface) : NULL;
}
+409
View File
@@ -0,0 +1,409 @@
/*
* Copyright © 2010 Intel Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkdragprivate.h"
#include "gdkinternals.h"
#include "gdkproperty.h"
#include "gdkprivate-wayland.h"
#include "gdkcontentformats.h"
#include "gdkdisplay-wayland.h"
#include "gdkintl.h"
#include "gdkseat-wayland.h"
#include "gdkdeviceprivate.h"
#include <glib-unix.h>
#include <gio/gunixinputstream.h>
#include <gio/gunixoutputstream.h>
#include <string.h>
#define GDK_TYPE_WAYLAND_DRAG (gdk_wayland_drag_get_type ())
#define GDK_WAYLAND_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_DRAG, GdkWaylandDrag))
#define GDK_WAYLAND_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_DRAG, GdkWaylandDragClass))
#define GDK_IS_WAYLAND_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DRAG))
#define GDK_IS_WAYLAND_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_DRAG))
#define GDK_WAYLAND_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_DRAG, GdkWaylandDragClass))
typedef struct _GdkWaylandDrag GdkWaylandDrag;
typedef struct _GdkWaylandDragClass GdkWaylandDragClass;
struct _GdkWaylandDrag
{
GdkDrag drag;
GdkSurface *dnd_surface;
struct wl_surface *dnd_wl_surface;
struct wl_data_source *data_source;
struct wl_data_offer *offer;
uint32_t serial;
gint hot_x;
gint hot_y;
};
struct _GdkWaylandDragClass
{
GdkDragClass parent_class;
};
static GList *drags;
GType gdk_wayland_drag_get_type (void);
G_DEFINE_TYPE (GdkWaylandDrag, gdk_wayland_drag, GDK_TYPE_DRAG)
static void
gdk_wayland_drag_finalize (GObject *object)
{
GdkWaylandDrag *wayland_drag = GDK_WAYLAND_DRAG (object);
GdkDrag *drag = GDK_DRAG (object);
GdkSurface *dnd_surface;
drags = g_list_remove (drags, drag);
gdk_drag_set_cursor (drag, NULL);
g_clear_pointer (&wayland_drag->data_source, wl_data_source_destroy);
g_clear_pointer (&wayland_drag->offer, wl_data_offer_destroy);
dnd_surface = wayland_drag->dnd_surface;
G_OBJECT_CLASS (gdk_wayland_drag_parent_class)->finalize (object);
if (dnd_surface)
gdk_surface_destroy (dnd_surface);
}
static inline uint32_t
gdk_to_wl_actions (GdkDragAction action)
{
uint32_t dnd_actions = 0;
if (action & (GDK_ACTION_COPY | GDK_ACTION_LINK))
dnd_actions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
if (action & GDK_ACTION_MOVE)
dnd_actions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
if (action & GDK_ACTION_ASK)
dnd_actions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
return dnd_actions;
}
static void
gdk_wayland_drag_init (GdkWaylandDrag *drag_wayland)
{
GdkDrag *drag;
drag = GDK_DRAG (drag_wayland);
drags = g_list_prepend (drags, drag);
gdk_drag_set_selected_action (drag, GDK_ACTION_COPY);
}
static GdkSurface *
gdk_wayland_drag_get_drag_surface (GdkDrag *drag)
{
return GDK_WAYLAND_DRAG (drag)->dnd_surface;
}
static void
gdk_wayland_drag_set_hotspot (GdkDrag *drag,
gint hot_x,
gint hot_y)
{
GdkWaylandDrag *drag_wayland = GDK_WAYLAND_DRAG (drag);
gint prev_hot_x = drag_wayland->hot_x;
gint prev_hot_y = drag_wayland->hot_y;
const GdkRectangle damage_rect = { .width = 1, .height = 1 };
drag_wayland->hot_x = hot_x;
drag_wayland->hot_y = hot_y;
if (prev_hot_x == hot_x && prev_hot_y == hot_y)
return;
_gdk_wayland_surface_offset_next_wl_buffer (drag_wayland->dnd_surface,
-hot_x, -hot_y);
gdk_surface_invalidate_rect (drag_wayland->dnd_surface, &damage_rect);
}
static void
gdk_wayland_drag_set_cursor (GdkDrag *drag,
GdkCursor *cursor)
{
GdkDevice *device = gdk_drag_get_device (drag);
if (device != NULL)
gdk_wayland_seat_set_global_cursor (gdk_device_get_seat (device), cursor);
}
static void
gdk_wayland_drag_drop_performed (GdkDrag *drag,
guint32 time_)
{
gdk_drag_set_cursor (drag, NULL);
}
static void
gdk_wayland_drag_cancel (GdkDrag *drag,
GdkDragCancelReason reason)
{
gdk_drag_set_cursor (drag, NULL);
}
static void
gdk_wayland_drag_drop_done (GdkDrag *drag,
gboolean success)
{
GdkWaylandDrag *drag_wayland = GDK_WAYLAND_DRAG (drag);
GdkDevice *device = gdk_drag_get_device (drag);
gdk_wayland_seat_set_drag (gdk_device_get_seat (device), drag);
if (success)
{
if (drag_wayland->dnd_surface)
gdk_surface_hide (drag_wayland->dnd_surface);
}
}
static void
gdk_wayland_drag_class_init (GdkWaylandDragClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkDragClass *drag_class = GDK_DRAG_CLASS (klass);
object_class->finalize = gdk_wayland_drag_finalize;
drag_class->get_drag_surface = gdk_wayland_drag_get_drag_surface;
drag_class->set_hotspot = gdk_wayland_drag_set_hotspot;
drag_class->drop_done = gdk_wayland_drag_drop_done;
drag_class->set_cursor = gdk_wayland_drag_set_cursor;
drag_class->drop_performed = gdk_wayland_drag_drop_performed;
drag_class->cancel = gdk_wayland_drag_cancel;
}
void
_gdk_wayland_surface_register_dnd (GdkSurface *surface)
{
}
static GdkSurface *
create_dnd_surface (GdkDisplay *display)
{
GdkSurface *surface;
surface = gdk_surface_new_popup (display, &(GdkRectangle) { 0, 0, 100, 100 });
gdk_surface_set_type_hint (surface, GDK_SURFACE_TYPE_HINT_DND);
return surface;
}
static inline GdkDragAction
_wl_to_gdk_actions (uint32_t dnd_actions)
{
GdkDragAction actions = 0;
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
actions |= GDK_ACTION_COPY;
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
actions |= GDK_ACTION_MOVE;
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
actions |= GDK_ACTION_ASK;
return actions;
}
static void
data_source_target (void *data,
struct wl_data_source *source,
const char *mime_type)
{
GDK_NOTE (EVENTS,
g_message ("data source target, source = %p, mime_type = %s",
source, mime_type));
}
static void
gdk_wayland_drag_write_done (GObject *drag,
GAsyncResult *result,
gpointer user_data)
{
GError *error = NULL;
if (!gdk_drag_write_finish (GDK_DRAG (drag), result, &error))
{
GDK_DISPLAY_NOTE (gdk_drag_get_display (GDK_DRAG (drag)), DND, g_message ("%p: failed to write stream: %s", drag, error->message));
g_error_free (error);
}
}
static void
data_source_send (void *data,
struct wl_data_source *source,
const char *mime_type,
int32_t fd)
{
GdkDrag *drag = data;
GOutputStream *stream;
GDK_DISPLAY_NOTE (gdk_drag_get_display (drag), DND, g_message ("%p: data source send request for %s on fd %d\n",
source, mime_type, fd));
//mime_type = gdk_intern_mime_type (mime_type);
mime_type = g_intern_string (mime_type);
stream = g_unix_output_stream_new (fd, TRUE);
gdk_drag_write_async (drag,
mime_type,
stream,
G_PRIORITY_DEFAULT,
NULL,
gdk_wayland_drag_write_done,
drag);
g_object_unref (stream);
}
static void
data_source_cancelled (void *data,
struct wl_data_source *source)
{
GdkDrag *drag = data;
GDK_DISPLAY_NOTE (gdk_drag_get_display (drag), EVENTS,
g_message ("data source cancelled, source = %p", source));
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_ERROR);
}
static void
data_source_dnd_drop_performed (void *data,
struct wl_data_source *source)
{
GdkDrag *drag = data;
g_signal_emit_by_name (drag, "drop-performed");
}
static void
data_source_dnd_finished (void *data,
struct wl_data_source *source)
{
GdkDrag *drag = data;
g_signal_emit_by_name (drag, "dnd-finished");
}
static void
data_source_action (void *data,
struct wl_data_source *source,
uint32_t action)
{
GdkDrag *drag = data;
GDK_DISPLAY_NOTE (gdk_drag_get_display (drag), EVENTS,
g_message ("data source action, source = %p action=%x",
source, action));
gdk_drag_set_selected_action (drag, _wl_to_gdk_actions (action));
}
static const struct wl_data_source_listener data_source_listener = {
data_source_target,
data_source_send,
data_source_cancelled,
data_source_dnd_drop_performed,
data_source_dnd_finished,
data_source_action,
};
static void
gdk_wayland_drag_create_data_source (GdkDrag *drag)
{
GdkWaylandDrag *drag_wayland = GDK_WAYLAND_DRAG (drag);
GdkDisplay *display = gdk_drag_get_display (drag);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
const char *const *mimetypes;
gsize i, n_mimetypes;
drag_wayland->data_source = wl_data_device_manager_create_data_source (display_wayland->data_device_manager);
wl_data_source_add_listener (drag_wayland->data_source,
&data_source_listener,
drag);
mimetypes = gdk_content_formats_get_mime_types (gdk_drag_get_formats (drag), &n_mimetypes);
for (i = 0; i < n_mimetypes; i++)
{
wl_data_source_offer (drag_wayland->data_source, mimetypes[i]);
}
}
GdkDrag *
_gdk_wayland_surface_drag_begin (GdkSurface *surface,
GdkDevice *device,
GdkContentProvider *content,
GdkDragAction actions,
gint dx,
gint dy)
{
GdkWaylandDrag *drag_wayland;
GdkDrag *drag;
GdkSeat *seat;
GdkWaylandDisplay *display_wayland;
GdkCursor *cursor;
display_wayland = GDK_WAYLAND_DISPLAY (gdk_device_get_display (device));
seat = gdk_device_get_seat (device);
drag_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG,
"surface", surface,
"device", device,
"content", content,
"actions", actions,
NULL);
drag = GDK_DRAG (drag_wayland);
drag_wayland->dnd_surface = create_dnd_surface (gdk_surface_get_display (surface));
drag_wayland->dnd_wl_surface = gdk_wayland_surface_get_wl_surface (drag_wayland->dnd_surface);
gdk_wayland_drag_create_data_source (drag);
if (display_wayland->data_device_manager_version >=
WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION)
{
wl_data_source_set_actions (drag_wayland->data_source,
gdk_to_wl_actions (actions));
}
gdk_wayland_seat_set_drag (seat, drag);
wl_data_device_start_drag (gdk_wayland_device_get_data_device (device),
drag_wayland->data_source,
gdk_wayland_surface_get_wl_surface (surface),
drag_wayland->dnd_wl_surface,
_gdk_wayland_display_get_serial (display_wayland));
cursor = gdk_drag_get_cursor (drag, gdk_drag_get_selected_action (drag));
gdk_drag_set_cursor (drag, cursor);
gdk_seat_ungrab (seat);
return drag;
}
+2 -2
View File
@@ -69,7 +69,7 @@ gdk_wayland_drop_finalize (GObject *object)
{
GdkWaylandDrop *wayland_drop = GDK_WAYLAND_DROP (object);
g_clear_pointer (&wayland_drop->offer, (GDestroyNotify) wl_data_offer_destroy);
g_clear_pointer (&wayland_drop->offer, wl_data_offer_destroy);
G_OBJECT_CLASS (gdk_wayland_drop_parent_class)->finalize (object);
}
@@ -261,7 +261,7 @@ gdk_wayland_drop_init (GdkWaylandDrop *drop)
GdkDrop *
gdk_wayland_drop_new (GdkDevice *device,
GdkDragContext *drag,
GdkDrag *drag,
GdkContentFormats *formats,
GdkSurface *surface,
struct wl_data_offer *offer,
+3 -3
View File
@@ -62,20 +62,20 @@ gdk_wayland_primary_discard_pending (GdkWaylandPrimary *cb)
gdk_content_formats_unref (ignore);
cb->pending_builder = NULL;
}
g_clear_pointer (&cb->pending, (GDestroyNotify) gtk_primary_selection_offer_destroy);
g_clear_pointer (&cb->pending, gtk_primary_selection_offer_destroy);
}
static void
gdk_wayland_primary_discard_offer (GdkWaylandPrimary *cb)
{
g_clear_pointer (&cb->offer_formats, gdk_content_formats_unref);
g_clear_pointer (&cb->offer, (GDestroyNotify) gtk_primary_selection_offer_destroy);
g_clear_pointer (&cb->offer, gtk_primary_selection_offer_destroy);
}
static void
gdk_wayland_primary_discard_source (GdkWaylandPrimary *cb)
{
g_clear_pointer (&cb->source, (GDestroyNotify) wl_data_source_destroy);
g_clear_pointer (&cb->source, gtk_primary_selection_source_destroy);
}
static void
+8 -11
View File
@@ -95,7 +95,7 @@ void gdk_wayland_surface_attach_image (GdkSurface
const cairo_region_t *damage);
void _gdk_wayland_surface_register_dnd (GdkSurface *surface);
GdkDragContext *_gdk_wayland_surface_drag_begin (GdkSurface *surface,
GdkDrag *_gdk_wayland_surface_drag_begin (GdkSurface *surface,
GdkDevice *device,
GdkContentProvider *content,
GdkDragAction actions,
@@ -105,7 +105,7 @@ void _gdk_wayland_surface_offset_next_wl_buffer (GdkSurface *surface,
int x,
int y);
GdkDrop * gdk_wayland_drop_new (GdkDevice *device,
GdkDragContext *drag,
GdkDrag *drag,
GdkContentFormats *formats,
GdkSurface *surface,
struct wl_data_offer *offer,
@@ -115,13 +115,10 @@ void gdk_wayland_drop_set_source_actions (GdkDrop
void gdk_wayland_drop_set_action (GdkDrop *drop,
uint32_t action);
void _gdk_wayland_drag_context_set_source_surface (GdkDragContext *context,
GdkSurface *surface);
void _gdk_wayland_display_create_surface_impl (GdkDisplay *display,
GdkSurface *surface,
GdkSurface *real_parent,
GdkSurfaceAttr *attributes);
void _gdk_wayland_display_create_surface_impl (GdkDisplay *display,
GdkSurface *surface,
GdkSurface *real_parent,
GdkSurfaceAttr *attributes);
gint _gdk_wayland_display_text_property_to_utf8_list (GdkDisplay *display,
GdkAtom encoding,
@@ -147,7 +144,7 @@ struct wl_data_device * gdk_wayland_device_get_data_device (GdkDevice *gdk_devic
void gdk_wayland_device_set_selection (GdkDevice *gdk_device,
struct wl_data_source *source);
GdkDragContext * gdk_wayland_device_get_drop_context (GdkDevice *gdk_device);
GdkDrag* gdk_wayland_device_get_drop_context (GdkDevice *gdk_device);
void gdk_wayland_device_unset_touch_grab (GdkDevice *device,
GdkEventSequence *sequence);
@@ -193,7 +190,7 @@ struct gtk_surface1 * gdk_wayland_surface_get_gtk_surface (GdkSurface *surface);
void gdk_wayland_seat_set_global_cursor (GdkSeat *seat,
GdkCursor *cursor);
void gdk_wayland_seat_set_drag (GdkSeat *seat,
GdkDragContext *drag);
GdkDrag *drag);
struct wl_output *gdk_wayland_surface_get_wl_output (GdkSurface *surface);
+2
View File
@@ -41,4 +41,6 @@ struct _GdkWaylandSeatClass
GType gdk_wayland_seat_get_type (void) G_GNUC_CONST;
void gdk_wayland_seat_update_cursor_scale (GdkWaylandSeat *seat);
#endif /* __GDK_WAYLAND_SEAT_H__ */
-1
View File
@@ -28,7 +28,6 @@
#include "gdkprivate-wayland.h"
#include "gdkdisplay-wayland.h"
#include "gdkcontentformatsprivate.h"
#include "gdkdndprivate.h"
#include "gdkproperty.h"
#include <string.h>
-2
View File
@@ -2639,8 +2639,6 @@ gdk_wayland_surface_show (GdkSurface *surface,
gdk_wayland_surface_create_surface (surface);
gdk_wayland_surface_map (surface);
_gdk_make_event (surface, GDK_MAP, NULL, FALSE);
}
static void
+1 -1
View File
@@ -5,7 +5,7 @@ gdk_wayland_sources = files([
'gdkcursor-wayland.c',
'gdkdevice-wayland.c',
'gdkdisplay-wayland.c',
'gdkdnd-wayland.c',
'gdkdrag-wayland.c',
'gdkdrop-wayland.c',
'gdkeventsource.c',
'gdkglcontext-wayland.c',
+1 -1
View File
@@ -280,7 +280,7 @@ Otherwise it's similar to how the clipboard works. Only the DnD server
#include "gdkclipboard-win32.h"
#include "gdkclipdrop-win32.h"
#include "gdkhdataoutputstream-win32.h"
#include "gdk/gdkdndprivate.h"
#include "gdk/gdkdragprivate.h"
#include "gdkwin32dnd.h"
#include "gdkwin32dnd-private.h"
#include "gdkwin32.h"
+183 -221
View File
@@ -130,7 +130,7 @@
* From that point forward the context gets any events emitted
* by GDK, and can prevent these events from going anywhere else.
* They are all handled in
* S: gdk_drag_context_handle_source_event() -> backend:handle_event()
* S: gdk_drag_handle_source_event() -> backend:handle_event()
* (except for wayland backend - it doesn't have that function).
*
* That function catches the following events:
@@ -195,14 +195,14 @@
/* For C-style COM wrapper macros */
#define COBJMACROS
#include "gdkdnd.h"
#include "gdkdrag.h"
#include "gdkproperty.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
#include "gdkwin32.h"
#include "gdkwin32dnd.h"
#include "gdkdisplayprivate.h"
#include "gdk/gdkdndprivate.h"
#include "gdk/gdkdragprivate.h"
#include "gdkwin32dnd-private.h"
#include "gdkdisplay-win32.h"
#include "gdkdeviceprivate.h"
@@ -226,12 +226,12 @@ typedef struct
IDropSource ids;
IDropSourceNotify idsn;
gint ref_count;
GdkDragContext *drag;
GdkDrag *drag;
/* These are thread-local
* copies of the similar fields from GdkWin32DragContext
* copies of the similar fields from GdkWin32Drag
*/
GdkWin32DragContextUtilityData util_data;
GdkWin32DragUtilityData util_data;
/* Cached here, so that we don't have to look in
* the context every time.
@@ -249,7 +249,7 @@ typedef struct
typedef struct {
IDataObject ido;
int ref_count;
GdkDragContext *drag;
GdkDrag *drag;
GArray *formats;
} data_object;
@@ -342,8 +342,8 @@ struct _GdkWin32DnDThreadUpdateDragState
{
GdkWin32DnDThreadQueueItem base;
gpointer opaque_ddd;
GdkWin32DragContextUtilityData produced_util_data;
gpointer opaque_ddd;
GdkWin32DragUtilityData produced_util_data;
};
typedef struct _GdkWin32DnDThread GdkWin32DnDThread;
@@ -485,10 +485,10 @@ process_dnd_queue (gboolean timed,
}
void
_gdk_win32_local_drag_context_drop_response (GdkDragContext *drag,
GdkDragAction action)
_gdk_win32_local_drag_drop_response (GdkDrag *drag,
GdkDragAction action)
{
GDK_NOTE (DND, g_print ("_gdk_win32_local_drag_context_drop_response: 0x%p\n",
GDK_NOTE (DND, g_print ("_gdk_win32_local_drag_drop_response: 0x%p\n",
drag));
g_signal_emit_by_name (drag, "dnd-finished");
@@ -500,8 +500,8 @@ do_drag_drop_response (gpointer user_data)
{
GdkWin32DnDThreadDoDragDrop *ddd = (GdkWin32DnDThreadDoDragDrop *) user_data;
HRESULT hr = ddd->received_result;
GdkDragContext *drag = GDK_DRAG_CONTEXT (ddd->base.opaque_context);
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkDrag *drag = GDK_DRAG (ddd->base.opaque_context);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
gpointer table_value = g_hash_table_lookup (clipdrop->active_source_drags, drag);
@@ -560,7 +560,7 @@ received_drag_context_data (GObject *drag,
GdkWin32DnDThreadGetData *getdata = (GdkWin32DnDThreadGetData *) user_data;
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
if (!gdk_drag_context_write_finish (GDK_DRAG_CONTEXT (drag), result, &error))
if (!gdk_drag_write_finish (GDK_DRAG (drag), result, &error))
{
HANDLE handle;
gboolean is_hdata;
@@ -593,7 +593,7 @@ get_data_response (gpointer user_data)
{
GdkWin32DnDThreadGetData *getdata = (GdkWin32DnDThreadGetData *) user_data;
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
GdkDragContext *drag = GDK_DRAG_CONTEXT (getdata->base.opaque_context);
GdkDrag *drag = GDK_DRAG (getdata->base.opaque_context);
gpointer ddd = g_hash_table_lookup (clipdrop->active_source_drags, drag);
GDK_NOTE (DND, g_print ("idataobject_getdata will request target 0x%p (%s)",
@@ -610,7 +610,7 @@ get_data_response (gpointer user_data)
if (stream)
{
getdata->stream = GDK_WIN32_HDATA_OUTPUT_STREAM (stream);
gdk_drag_context_write_async (drag,
gdk_drag_write_async (drag,
getdata->pair.contentformat,
stream,
G_PRIORITY_DEFAULT,
@@ -721,16 +721,16 @@ typedef enum {
static gboolean use_ole2_dnd = TRUE;
static gboolean drag_context_grab (GdkDragContext *drag);
static gboolean drag_context_grab (GdkDrag *drag);
G_DEFINE_TYPE (GdkWin32DragContext, gdk_win32_drag_context, GDK_TYPE_DRAG_CONTEXT)
G_DEFINE_TYPE (GdkWin32Drag, gdk_win32_drag, GDK_TYPE_DRAG)
static void
move_drag_surface (GdkDragContext *drag,
guint x_root,
guint y_root)
move_drag_surface (GdkDrag *drag,
guint x_root,
guint y_root)
{
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
g_assert (_win32_main_thread == NULL ||
_win32_main_thread == g_thread_self ());
@@ -742,7 +742,7 @@ move_drag_surface (GdkDragContext *drag,
}
static void
gdk_win32_drag_context_init (GdkWin32DragContext *drag)
gdk_win32_drag_init (GdkWin32Drag *drag)
{
g_assert (_win32_main_thread == NULL ||
_win32_main_thread == g_thread_self ());
@@ -750,32 +750,32 @@ gdk_win32_drag_context_init (GdkWin32DragContext *drag)
drag->handle_events = TRUE;
drag->dest_window = INVALID_HANDLE_VALUE;
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_init %p\n", drag));
GDK_NOTE (DND, g_print ("gdk_win32_drag_init %p\n", drag));
}
static void
gdk_win32_drag_context_finalize (GObject *object)
gdk_win32_drag_finalize (GObject *object)
{
GdkDragContext *drag;
GdkWin32DragContext *drag_win32;
GdkDrag *drag;
GdkWin32Drag *drag_win32;
GdkSurface *drag_surface;
g_assert (_win32_main_thread == NULL ||
_win32_main_thread == g_thread_self ());
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_finalize %p\n", object));
GDK_NOTE (DND, g_print ("gdk_win32_drag_finalize %p\n", object));
g_return_if_fail (GDK_IS_WIN32_DRAG_CONTEXT (object));
g_return_if_fail (GDK_IS_WIN32_DRAG (object));
drag = GDK_DRAG_CONTEXT (object);
drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
drag = GDK_DRAG (object);
drag_win32 = GDK_WIN32_DRAG (drag);
gdk_drag_context_set_cursor (drag, NULL);
gdk_drag_set_cursor (drag, NULL);
g_set_object (&drag_win32->grab_surface, NULL);
drag_surface = drag_win32->drag_surface;
G_OBJECT_CLASS (gdk_win32_drag_context_parent_class)->finalize (object);
G_OBJECT_CLASS (gdk_win32_drag_parent_class)->finalize (object);
if (drag_surface)
gdk_surface_destroy (drag_surface);
@@ -783,30 +783,32 @@ gdk_win32_drag_context_finalize (GObject *object)
/* Drag Contexts */
static GdkDragContext *
gdk_drag_context_new (GdkDisplay *display,
GdkContentProvider *content,
GdkDragAction actions,
GdkDevice *device,
GdkDragProtocol protocol)
static GdkDrag *
gdk_drag_new (GdkDisplay *display,
GdkSurface *surface,
GdkContentProvider *content,
GdkDragAction actions,
GdkDevice *device,
GdkDragProtocol protocol)
{
GdkWin32DragContext *drag_win32;
GdkWin32Drag *drag_win32;
GdkWin32Display *win32_display = GDK_WIN32_DISPLAY (display);
GdkDragContext *drag;
GdkDrag *drag;
drag_win32 = g_object_new (GDK_TYPE_WIN32_DRAG_CONTEXT,
"device", device,
"content", content,
NULL);
drag_win32 = g_object_new (GDK_TYPE_WIN32_DRAG,
"device", device,
"content", content,
"surface", surface,
"actions", actions,
NULL);
drag = GDK_DRAG_CONTEXT (drag_win32);
drag = GDK_DRAG (drag_win32);
if (win32_display->has_fixed_scale)
drag_win32->scale = win32_display->surface_scale;
else
drag_win32->scale = _gdk_win32_display_get_monitor_scale_factor (win32_display, NULL, NULL, NULL);
gdk_drag_context_set_actions (drag, actions, actions);
drag_win32->protocol = protocol;
return drag;
@@ -828,15 +830,15 @@ gdk_drag_context_new (GdkDisplay *display,
static enum_formats *enum_formats_new (GArray *formats);
/* Finds a GdkDragContext object that corresponds to a DnD operation
/* Finds a GdkDrag object that corresponds to a DnD operation
* which is currently targetting the dest_window
* Does not give a reference.
*/
GdkDragContext *
GdkDrag *
_gdk_win32_find_drag_for_dest_window (HWND dest_window)
{
GHashTableIter iter;
GdkWin32DragContext *drag_win32;
GdkWin32Drag *drag_win32;
GdkWin32DnDThreadDoDragDrop *ddd;
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
@@ -844,7 +846,7 @@ _gdk_win32_find_drag_for_dest_window (HWND dest_window)
while (g_hash_table_iter_next (&iter, (gpointer *) &drag_win32, (gpointer *) &ddd))
if (ddd->src_context->dest_window_handle == dest_window)
return GDK_DRAG_CONTEXT (drag_win32);
return GDK_DRAG (drag_win32);
return NULL;
}
@@ -888,7 +890,7 @@ static gboolean
notify_dnd_enter (gpointer user_data)
{
GdkWin32DnDEnterLeaveNotify *notify = (GdkWin32DnDEnterLeaveNotify *) user_data;
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (notify->opaque_context);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (notify->opaque_context);
drag_win32->dest_window = notify->target_window_handle;
@@ -901,7 +903,7 @@ static gboolean
notify_dnd_leave (gpointer user_data)
{
GdkWin32DnDEnterLeaveNotify *notify = (GdkWin32DnDEnterLeaveNotify *) user_data;
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (notify->opaque_context);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (notify->opaque_context);
if (notify->target_window_handle != drag_win32->dest_window)
g_warning ("DnD leave says that the window handle is 0x%p, but drag has 0x%p", notify->target_window_handle, drag_win32->dest_window);
@@ -998,7 +1000,7 @@ idropsource_queryinterface (LPDROPSOURCE This,
static gboolean
unref_context_in_main_thread (gpointer opaque_context)
{
GdkDragContext *drag = GDK_DRAG_CONTEXT (opaque_context);
GdkDrag *drag = GDK_DRAG (opaque_context);
g_clear_object (&drag);
@@ -1066,21 +1068,21 @@ idropsource_querycontinuedrag (LPDROPSOURCE This,
}
static void
maybe_emit_action_changed (GdkWin32DragContext *drag_win32,
maybe_emit_action_changed (GdkWin32Drag *drag_win32,
GdkDragAction actions)
{
if (actions != drag_win32->current_action)
{
drag_win32->current_action = actions;
g_signal_emit_by_name (GDK_DRAG_CONTEXT (drag_win32), "action-changed", actions);
gdk_drag_set_selected_action (GDK_DRAG (drag_win32), actions);
}
}
void
_gdk_win32_local_drag_give_feedback (GdkDragContext *drag,
_gdk_win32_local_drag_give_feedback (GdkDrag *drag,
GdkDragAction actions)
{
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
if (drag_win32->drag_status == GDK_DRAG_STATUS_MOTION_WAIT)
drag_win32->drag_status = GDK_DRAG_STATUS_DRAG;
@@ -1088,7 +1090,6 @@ _gdk_win32_local_drag_give_feedback (GdkDragContext *drag,
GDK_NOTE (DND, g_print ("_gdk_win32_local_drag_give_feedback: 0x%p\n",
drag));
drag->action = actions;
maybe_emit_action_changed (drag_win32, actions);
}
@@ -1101,14 +1102,13 @@ give_feedback (gpointer user_data)
if (ddd)
{
GdkDragContext *drag = GDK_DRAG_CONTEXT (feedback->base.opaque_context);
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkDrag *drag = GDK_DRAG (feedback->base.opaque_context);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
GDK_NOTE (DND, g_print ("gdk_dnd_handle_drag_status: 0x%p\n",
drag));
drag->action = action_for_drop_effect (feedback->received_drop_effect);
maybe_emit_action_changed (drag_win32, drag->action);
maybe_emit_action_changed (drag_win32, action_for_drop_effect (feedback->received_drop_effect));
}
free_queue_item (&feedback->base);
@@ -1587,31 +1587,36 @@ static IEnumFORMATETCVtbl ief_vtbl = {
};
static source_drag_context *
source_context_new (GdkDragContext *drag,
source_context_new (GdkDrag *drag,
GdkContentFormats *formats)
{
GdkWin32DragContext *drag_win32;
GdkWin32Drag *drag_win32;
source_drag_context *result;
GdkSurface *surface;
drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
drag_win32 = GDK_WIN32_DRAG (drag);
g_object_get (drag, "surface", &surface, NULL);
result = g_new0 (source_drag_context, 1);
result->drag = g_object_ref (drag);
result->ids.lpVtbl = &ids_vtbl;
result->idsn.lpVtbl = &idsn_vtbl;
result->ref_count = 1;
result->source_window_handle = GDK_SURFACE_HWND (drag->source_surface);
result->source_window_handle = GDK_SURFACE_HWND (surface);
result->scale = drag_win32->scale;
result->util_data.state = GDK_WIN32_DND_PENDING; /* Implicit */
result->dest_window_handle = INVALID_HANDLE_VALUE;
g_object_unref (surface);
GDK_NOTE (DND, g_print ("source_context_new: %p (drag %p)\n", result, result->drag));
return result;
}
static data_object *
data_object_new (GdkDragContext *drag)
data_object_new (GdkDrag *drag)
{
data_object *result;
const char * const *mime_types;
@@ -1624,7 +1629,7 @@ data_object_new (GdkDragContext *drag)
result->drag = drag;
result->formats = g_array_new (FALSE, FALSE, sizeof (GdkWin32ContentFormatPair));
mime_types = gdk_content_formats_get_mime_types (gdk_drag_context_get_formats (drag), &n_mime_types);
mime_types = gdk_content_formats_get_mime_types (gdk_drag_get_formats (drag), &n_mime_types);
for (i = 0; i < n_mime_types; i++)
{
@@ -1701,7 +1706,7 @@ create_drag_surface (GdkDisplay *display)
return surface;
}
GdkDragContext *
GdkDrag *
_gdk_win32_surface_drag_begin (GdkSurface *surface,
GdkDevice *device,
GdkContentProvider *content,
@@ -1709,21 +1714,20 @@ _gdk_win32_surface_drag_begin (GdkSurface *surface,
gint dx,
gint dy)
{
GdkDragContext *drag;
GdkWin32DragContext *drag_win32;
GdkDrag *drag;
GdkWin32Drag *drag_win32;
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
int x_root, y_root;
g_return_val_if_fail (surface != NULL, NULL);
drag = gdk_drag_context_new (gdk_surface_get_display (surface),
content,
actions,
device,
use_ole2_dnd ? GDK_DRAG_PROTO_OLE2 : GDK_DRAG_PROTO_LOCAL);
drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
g_set_object (&drag->source_surface, surface);
drag = gdk_drag_new (gdk_surface_get_display (surface),
surface,
content,
actions,
device,
use_ole2_dnd ? GDK_DRAG_PROTO_OLE2 : GDK_DRAG_PROTO_LOCAL);
drag_win32 = GDK_WIN32_DRAG (drag);
GDK_NOTE (DND, g_print ("_gdk_win32_surface_drag_begin\n"));
@@ -1752,8 +1756,7 @@ _gdk_win32_surface_drag_begin (GdkSurface *surface,
source_drag_context *source_ctx;
data_object *data_obj;
source_ctx = source_context_new (drag,
gdk_drag_context_get_formats (drag));
source_ctx = source_context_new (drag, gdk_drag_get_formats (drag));
data_obj = data_object_new (drag);
ddd->base.item_type = GDK_WIN32_DND_THREAD_QUEUE_ITEM_DO_DRAG_DROP;
@@ -1830,12 +1833,12 @@ find_window_enum_proc (HWND hwnd,
* drop targets about drags that move over them.
*/
static HWND
gdk_win32_drag_context_find_window (GdkDragContext *drag,
GdkSurface *drag_surface,
gint x_root,
gint y_root)
gdk_win32_drag_find_window (GdkDrag *drag,
GdkSurface *drag_surface,
gint x_root,
gint y_root)
{
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
find_window_enum_arg a;
HWND result;
@@ -1848,14 +1851,14 @@ gdk_win32_drag_context_find_window (GdkDragContext *drag,
a.result = INVALID_HANDLE_VALUE;
GDK_NOTE (DND,
g_print ("gdk_win32_drag_context_find_window: %p %+d%+d\n",
g_print ("gdk_win32_drag_find_window: %p %+d%+d\n",
(drag_surface ? GDK_SURFACE_HWND (drag_surface) : NULL),
a.x, a.y));
EnumWindows (find_window_enum_proc, (LPARAM) &a);
GDK_NOTE (DND,
g_print ("gdk_win32_drag_context_find_window: %p %+d%+d: %p\n",
g_print ("gdk_win32_drag_find_window: %p %+d%+d: %p\n",
(drag_surface ? GDK_SURFACE_HWND (drag_surface) : NULL),
x_root, y_root,
a.result));
@@ -1900,7 +1903,7 @@ _gdk_win32_get_drop_for_dest_window (HWND dest_window)
}
static gboolean
gdk_win32_local_drag_motion (GdkDragContext *drag,
gdk_win32_local_drag_motion (GdkDrag *drag,
HWND dest_window,
gint x_root,
gint y_root,
@@ -1908,7 +1911,7 @@ gdk_win32_local_drag_motion (GdkDragContext *drag,
DWORD key_state,
guint32 time_)
{
GdkWin32DragContext *drag_win32;
GdkWin32Drag *drag_win32;
GdkDrop *drop;
GdkDragAction actions;
@@ -1917,20 +1920,19 @@ gdk_win32_local_drag_motion (GdkDragContext *drag,
g_return_val_if_fail (drag != NULL, FALSE);
drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
drag_win32 = GDK_WIN32_DRAG (drag);
drop = _gdk_win32_get_drop_for_dest_window (drag_win32->dest_window);
actions = gdk_drag_context_get_actions (drag);
actions = gdk_drag_get_actions (drag);
GDK_NOTE (DND, g_print ("gdk_win32_local_drag_motion: @ %+d:%+d possible=%s\n"
" dest=%p (current %p) drop=%p drag=%p:{actions=%s,suggested=%s,action=%s}\n",
" dest=%p (current %p) drop=%p drag=%p:{actions=%s,action=%s}\n",
x_root, y_root,
_gdk_win32_drag_action_to_string (possible_actions),
dest_window, drag_win32->dest_window, drop, drag,
_gdk_win32_drag_action_to_string (actions),
_gdk_win32_drag_action_to_string (gdk_drag_context_get_suggested_action (drag)),
_gdk_win32_drag_action_to_string (drag->action)));
_gdk_win32_drag_action_to_string (gdk_drag_get_selected_action (drag))));
if (drag_win32->dest_window != dest_window)
{
@@ -1962,7 +1964,7 @@ gdk_win32_local_drag_motion (GdkDragContext *drag,
drag_win32->drag_status == GDK_DRAG_STATUS_DRAG &&
_gdk_win32_local_drop_target_will_emit_motion (drop, x_root, y_root, key_state))
{
actions = gdk_drag_context_get_actions (drag);
actions = gdk_drag_get_actions (drag);
drag_win32->drag_status = GDK_DRAG_STATUS_MOTION_WAIT;
_gdk_win32_local_drop_target_dragover (drop, drag, x_root, y_root, key_state, time_, &actions);
@@ -1971,34 +1973,33 @@ gdk_win32_local_drag_motion (GdkDragContext *drag,
}
GDK_NOTE (DND, g_print (" returning %s\n"
" drag=%p:{actions=%s,suggested=%s,action=%s}\n",
" drag=%p:{actions=%s,action=%s}\n",
(drop != NULL && drag_win32->drag_status == GDK_DRAG_STATUS_DRAG) ? "TRUE" : "FALSE",
drag,
_gdk_win32_drag_action_to_string (gdk_drag_context_get_actions (drag)),
_gdk_win32_drag_action_to_string (gdk_drag_context_get_suggested_action (drag)),
_gdk_win32_drag_action_to_string (drag->action)));
_gdk_win32_drag_action_to_string (gdk_drag_get_actions (drag)),
_gdk_win32_drag_action_to_string (gdk_drag_get_selected_action (drag))));
return (drop != NULL && drag_win32->drag_status == GDK_DRAG_STATUS_DRAG);
}
static void
send_source_state_update (GdkWin32Clipdrop *clipdrop,
GdkWin32DragContext *context_win32,
GdkWin32Drag *drag_win32,
gpointer *ddd)
{
GdkWin32DnDThreadUpdateDragState *status = g_new0 (GdkWin32DnDThreadUpdateDragState, 1);
status->base.item_type = GDK_WIN32_DND_THREAD_QUEUE_ITEM_UPDATE_DRAG_STATE;
status->opaque_ddd = ddd;
status->produced_util_data = context_win32->util_data;
status->produced_util_data = drag_win32->util_data;
increment_dnd_queue_counter ();
g_async_queue_push (clipdrop->dnd_queue, status);
API_CALL (PostThreadMessage, (clipdrop->dnd_thread_id, thread_wakeup_message, 0, 0));
}
static void
gdk_win32_drag_context_drag_drop (GdkDragContext *drag,
guint32 time_)
gdk_win32_drag_drop (GdkDrag *drag,
guint32 time_)
{
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
g_assert (_win32_main_thread == NULL ||
@@ -2006,7 +2007,7 @@ gdk_win32_drag_context_drag_drop (GdkDragContext *drag,
g_return_if_fail (drag != NULL);
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_drag_drop\n"));
GDK_NOTE (DND, g_print ("gdk_win32_drag_drop\n"));
if (drag_win32->protocol == GDK_DRAG_PROTO_LOCAL)
{
@@ -2016,10 +2017,10 @@ gdk_win32_drag_context_drag_drop (GdkDragContext *drag,
{
GdkDragAction actions;
actions = gdk_drag_context_get_actions (drag);
actions = gdk_drag_get_actions (drag);
_gdk_win32_local_drop_target_drop (drop, drag, time_, &actions);
maybe_emit_action_changed (drag_win32, actions);
_gdk_win32_local_drag_context_drop_response (drag, actions);
_gdk_win32_local_drag_drop_response (drag, actions);
}
}
else if (drag_win32->protocol == GDK_DRAG_PROTO_OLE2)
@@ -2034,37 +2035,12 @@ gdk_win32_drag_context_drag_drop (GdkDragContext *drag,
}
static void
gdk_win32_drag_context_drag_abort (GdkDragContext *drag,
guint32 time_)
gdk_win32_drag_set_cursor (GdkDrag *drag,
GdkCursor *cursor)
{
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
g_assert (_win32_main_thread == NULL ||
_win32_main_thread == g_thread_self ());
g_return_if_fail (drag != NULL);
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_drag_abort\n"));
if (drag_win32->protocol == GDK_DRAG_PROTO_OLE2)
{
gpointer ddd = g_hash_table_lookup (clipdrop->active_source_drags, drag);
drag_win32->util_data.state = GDK_WIN32_DND_NONE;
if (ddd)
send_source_state_update (clipdrop, drag_win32, ddd);
}
}
static void
gdk_win32_drag_context_set_cursor (GdkDragContext *drag,
GdkCursor *cursor)
{
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_set_cursor: 0x%p 0x%p\n", drag, cursor));
GDK_NOTE (DND, g_print ("gdk_win32_drag_set_cursor: 0x%p 0x%p\n", drag, cursor));
if (!g_set_object (&drag_win32->cursor, cursor))
return;
@@ -2092,7 +2068,7 @@ ease_out_cubic (double t)
typedef struct _GdkDragAnim GdkDragAnim;
struct _GdkDragAnim {
GdkWin32DragContext *drag;
GdkWin32Drag *drag;
GdkFrameClock *frame_clock;
gint64 start_time;
};
@@ -2108,7 +2084,7 @@ static gboolean
gdk_drag_anim_timeout (gpointer data)
{
GdkDragAnim *anim = data;
GdkWin32DragContext *drag = anim->drag;
GdkWin32Drag *drag = anim->drag;
GdkFrameClock *frame_clock = anim->frame_clock;
gint64 current_time;
double f;
@@ -2136,10 +2112,10 @@ gdk_drag_anim_timeout (gpointer data)
}
static void
gdk_win32_drag_context_drop_done (GdkDragContext *drag,
gboolean success)
gdk_win32_drag_drop_done (GdkDrag *drag,
gboolean success)
{
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
GdkDragAnim *anim;
/*
cairo_surface_t *win_surface;
@@ -2148,7 +2124,7 @@ gdk_win32_drag_context_drop_done (GdkDragContext *drag,
*/
guint id;
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_drop_done: 0x%p %s\n",
GDK_NOTE (DND, g_print ("gdk_win32_drag_drop_done: 0x%p %s\n",
drag,
success ? "dropped successfully" : "dropped unsuccessfully"));
@@ -2207,7 +2183,7 @@ gdk_win32_drag_context_drop_done (GdkDragContext *drag,
anim->frame_clock = gdk_surface_get_frame_clock (drag_win32->drag_surface);
anim->start_time = gdk_frame_clock_get_frame_time (anim->frame_clock);
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_drop_done: animate the drag window from %d : %d to %d : %d\n",
GDK_NOTE (DND, g_print ("gdk_win32_drag_drop_done: animate the drag window from %d : %d to %d : %d\n",
drag_win32->util_data.last_x, drag_win32->util_data.last_y,
drag_win32->start_x, drag_win32->start_y));
@@ -2218,9 +2194,9 @@ gdk_win32_drag_context_drop_done (GdkDragContext *drag,
}
static gboolean
drag_context_grab (GdkDragContext *drag)
drag_context_grab (GdkDrag *drag)
{
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
GdkSeatCapabilities capabilities;
GdkSeat *seat;
GdkCursor *cursor;
@@ -2232,11 +2208,11 @@ drag_context_grab (GdkDragContext *drag)
if (!drag_win32->grab_surface)
return FALSE;
seat = gdk_device_get_seat (gdk_drag_context_get_device (drag));
seat = gdk_device_get_seat (gdk_drag_get_device (drag));
capabilities = GDK_SEAT_CAPABILITY_ALL;
cursor = gdk_drag_get_cursor (drag, gdk_drag_context_get_selected_action (drag));
cursor = gdk_drag_get_cursor (drag, gdk_drag_get_selected_action (drag));
g_set_object (&drag_win32->cursor, cursor);
if (gdk_seat_grab (seat, drag_win32->grab_surface,
@@ -2252,9 +2228,9 @@ drag_context_grab (GdkDragContext *drag)
}
static void
drag_context_ungrab (GdkDragContext *drag)
drag_context_ungrab (GdkDrag *drag)
{
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
GDK_NOTE (DND, g_print ("drag_context_ungrab: 0x%p 0x%p\n",
drag,
@@ -2271,10 +2247,10 @@ drag_context_ungrab (GdkDragContext *drag)
}
static void
gdk_win32_drag_context_cancel (GdkDragContext *drag,
GdkDragCancelReason reason)
gdk_win32_drag_cancel (GdkDrag *drag,
GdkDragCancelReason reason)
{
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
const gchar *reason_str = NULL;
switch (reason)
@@ -2293,7 +2269,7 @@ gdk_win32_drag_context_cancel (GdkDragContext *drag,
break;
}
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_cancel: 0x%p %s\n",
GDK_NOTE (DND, g_print ("gdk_win32_drag_cancel: 0x%p %s\n",
drag,
reason_str));
@@ -2305,20 +2281,21 @@ gdk_win32_drag_context_cancel (GdkDragContext *drag,
drop = NULL;
}
gdk_drag_context_set_cursor (drag, NULL);
gdk_drag_set_cursor (drag, NULL);
drag_context_ungrab (drag);
gdk_drag_drop_done (drag, FALSE);
}
static void
gdk_win32_drag_context_drop_performed (GdkDragContext *drag,
guint32 time_)
gdk_win32_drag_drop_performed (GdkDrag *drag,
guint32 time_)
{
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_drop_performed: 0x%p %u\n",
GDK_NOTE (DND, g_print ("gdk_win32_drag_drop_performed: 0x%p %u\n",
drag,
time_));
gdk_drag_drop (drag, time_);
gdk_drag_context_set_cursor (drag, NULL);
gdk_win32_drag_drop (drag, time_);
gdk_drag_set_cursor (drag, NULL);
drag_context_ungrab (drag);
}
@@ -2326,33 +2303,33 @@ gdk_win32_drag_context_drop_performed (GdkDragContext *drag,
#define SMALL_STEP 1
static void
gdk_local_drag_update (GdkDragContext *drag,
gdouble x_root,
gdouble y_root,
DWORD grfKeyState,
guint32 evtime)
gdk_local_drag_update (GdkDrag *drag,
gdouble x_root,
gdouble y_root,
DWORD grfKeyState,
guint32 evtime)
{
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
HWND dest_window;
g_assert (_win32_main_thread == NULL ||
_win32_main_thread == g_thread_self ());
dest_window = gdk_win32_drag_context_find_window (drag,
drag_win32->drag_surface,
x_root, y_root);
dest_window = gdk_win32_drag_find_window (drag,
drag_win32->drag_surface,
x_root, y_root);
gdk_win32_local_drag_motion (drag, dest_window, x_root, y_root,
gdk_drag_context_get_actions (drag),
gdk_drag_get_actions (drag),
grfKeyState, evtime);
}
static gboolean
gdk_dnd_handle_motion_event (GdkDragContext *drag,
gdk_dnd_handle_motion_event (GdkDrag *drag,
const GdkEventMotion *event)
{
GdkModifierType state;
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
DWORD key_state;
if (!gdk_event_get_state ((GdkEvent *) event, &state))
@@ -2391,10 +2368,10 @@ gdk_dnd_handle_motion_event (GdkDragContext *drag,
}
static gboolean
gdk_dnd_handle_key_event (GdkDragContext *drag,
gdk_dnd_handle_key_event (GdkDrag *drag,
const GdkEventKey *event)
{
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
GdkModifierType state;
GdkDevice *pointer;
gint dx, dy;
@@ -2413,7 +2390,7 @@ gdk_dnd_handle_key_event (GdkDragContext *drag,
switch (event->keyval)
{
case GDK_KEY_Escape:
gdk_drag_context_cancel (drag, GDK_DRAG_CANCEL_USER_CANCELLED);
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_USER_CANCELLED);
return TRUE;
case GDK_KEY_space:
@@ -2421,13 +2398,13 @@ gdk_dnd_handle_key_event (GdkDragContext *drag,
case GDK_KEY_ISO_Enter:
case GDK_KEY_KP_Enter:
case GDK_KEY_KP_Space:
if ((gdk_drag_context_get_selected_action (drag) != 0) &&
if ((gdk_drag_get_selected_action (drag) != 0) &&
(drag_win32->dest_window != INVALID_HANDLE_VALUE))
{
g_signal_emit_by_name (drag, "drop-performed");
}
else
gdk_drag_context_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET);
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET);
return TRUE;
@@ -2477,10 +2454,10 @@ gdk_dnd_handle_key_event (GdkDragContext *drag,
}
static gboolean
gdk_dnd_handle_grab_broken_event (GdkDragContext *drag,
gdk_dnd_handle_grab_broken_event (GdkDrag *drag,
const GdkEventGrabBroken *event)
{
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
GDK_NOTE (DND, g_print ("gdk_dnd_handle_grab_broken_event: 0x%p\n",
drag));
@@ -2495,15 +2472,15 @@ gdk_dnd_handle_grab_broken_event (GdkDragContext *drag,
return FALSE;
if (gdk_event_get_device ((GdkEvent *) event) !=
gdk_drag_context_get_device (drag))
gdk_drag_get_device (drag))
return FALSE;
gdk_drag_context_cancel (drag, GDK_DRAG_CANCEL_ERROR);
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_ERROR);
return TRUE;
}
static gboolean
gdk_dnd_handle_button_event (GdkDragContext *drag,
gdk_dnd_handle_button_event (GdkDrag *drag,
const GdkEventButton *event)
{
GDK_NOTE (DND, g_print ("gdk_dnd_handle_button_event: 0x%p\n",
@@ -2515,22 +2492,22 @@ gdk_dnd_handle_button_event (GdkDragContext *drag,
return FALSE;
#endif
if ((gdk_drag_context_get_selected_action (drag) != 0))
if ((gdk_drag_get_selected_action (drag) != 0))
{
g_signal_emit_by_name (drag, "drop-performed");
}
else
gdk_drag_context_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET);
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET);
/* Make sure GTK gets mouse release button event */
return FALSE;
}
gboolean
gdk_win32_drag_context_handle_event (GdkDragContext *drag,
const GdkEvent *event)
gdk_win32_drag_handle_event (GdkDrag *drag,
const GdkEvent *event)
{
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
if (!drag_win32->grab_seat)
return FALSE;
@@ -2559,30 +2536,20 @@ gdk_win32_drag_context_handle_event (GdkDragContext *drag,
return FALSE;
}
void
gdk_win32_drag_context_action_changed (GdkDragContext *drag,
GdkDragAction action)
{
GdkCursor *cursor;
cursor = gdk_drag_get_cursor (drag, action);
gdk_drag_context_set_cursor (drag, cursor);
}
static GdkSurface *
gdk_win32_drag_context_get_drag_surface (GdkDragContext *drag)
gdk_win32_drag_get_drag_surface (GdkDrag *drag)
{
return GDK_WIN32_DRAG_CONTEXT (drag)->drag_surface;
return GDK_WIN32_DRAG (drag)->drag_surface;
}
static void
gdk_win32_drag_context_set_hotspot (GdkDragContext *drag,
gint hot_x,
gint hot_y)
gdk_win32_drag_set_hotspot (GdkDrag *drag,
gint hot_x,
gint hot_y)
{
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
GDK_NOTE (DND, g_print ("gdk_drag_context_set_hotspot: 0x%p %d:%d\n",
GDK_NOTE (DND, g_print ("gdk_drag_set_hotspot: 0x%p %d:%d\n",
drag,
hot_x, hot_y));
@@ -2597,23 +2564,18 @@ gdk_win32_drag_context_set_hotspot (GdkDragContext *drag,
}
static void
gdk_win32_drag_context_class_init (GdkWin32DragContextClass *klass)
gdk_win32_drag_class_init (GdkWin32DragClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkDragContextClass *context_class = GDK_DRAG_CONTEXT_CLASS (klass);
GdkDragClass *drag_class = GDK_DRAG_CLASS (klass);
object_class->finalize = gdk_win32_drag_context_finalize;
context_class->drag_abort = gdk_win32_drag_context_drag_abort;
context_class->drag_drop = gdk_win32_drag_context_drag_drop;
context_class->get_drag_surface = gdk_win32_drag_context_get_drag_surface;
context_class->set_hotspot = gdk_win32_drag_context_set_hotspot;
context_class->drop_done = gdk_win32_drag_context_drop_done;
context_class->set_cursor = gdk_win32_drag_context_set_cursor;
context_class->cancel = gdk_win32_drag_context_cancel;
context_class->drop_performed = gdk_win32_drag_context_drop_performed;
context_class->handle_event = gdk_win32_drag_context_handle_event;
context_class->action_changed = gdk_win32_drag_context_action_changed;
object_class->finalize = gdk_win32_drag_finalize;
drag_class->get_drag_surface = gdk_win32_drag_get_drag_surface;
drag_class->set_hotspot = gdk_win32_drag_set_hotspot;
drag_class->drop_done = gdk_win32_drag_drop_done;
drag_class->set_cursor = gdk_win32_drag_set_cursor;
drag_class->cancel = gdk_win32_drag_cancel;
drag_class->drop_performed = gdk_win32_drag_drop_performed;
drag_class->handle_event = gdk_win32_drag_handle_event;
}
+11 -11
View File
@@ -41,7 +41,7 @@
#include "gdkdropprivate.h"
#include "gdkdnd.h"
#include "gdkdrag.h"
#include "gdkproperty.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
@@ -172,7 +172,7 @@ gdk_win32_drop_finalize (GObject *object)
static GdkDrop *
gdk_drop_new (GdkDisplay *display,
GdkDevice *device,
GdkDragContext *drag,
GdkDrag *drag,
GdkContentFormats *formats,
GdkSurface *surface,
GdkDragProtocol protocol)
@@ -453,7 +453,7 @@ set_source_actions_helper (GdkDrop *drop,
}
void
_gdk_win32_local_drop_target_dragenter (GdkDragContext *drag,
_gdk_win32_local_drop_target_dragenter (GdkDrag *drag,
GdkSurface *dest_surface,
gint x_root,
gint y_root,
@@ -478,7 +478,7 @@ _gdk_win32_local_drop_target_dragenter (GdkDragContext *drag,
drop = gdk_drop_new (display,
gdk_seat_get_pointer (gdk_display_get_default_seat (display)),
drag,
gdk_content_formats_ref (gdk_drag_context_get_formats (drag)),
gdk_content_formats_ref (gdk_drag_get_formats (drag)),
dest_surface,
GDK_DRAG_PROTO_LOCAL);
drop_win32 = GDK_WIN32_DROP (drop);
@@ -518,7 +518,7 @@ idroptarget_dragenter (LPDROPTARGET This,
GdkDisplay *display;
gint pt_x;
gint pt_y;
GdkDragContext *drag;
GdkDrag *drag;
GdkDragAction source_actions;
GdkDragAction dest_actions;
@@ -531,7 +531,7 @@ idroptarget_dragenter (LPDROPTARGET This,
g_clear_object (&ctx->drop);
/* Try to find the GdkDragContext object for this DnD operation,
/* Try to find the GdkDrag object for this DnD operation,
* if it originated in our own application.
*/
drag = NULL;
@@ -593,7 +593,7 @@ _gdk_win32_local_drop_target_will_emit_motion (GdkDrop *drop,
void
_gdk_win32_local_drop_target_dragover (GdkDrop *drop,
GdkDragContext *drag,
GdkDrag *drag,
gint x_root,
gint y_root,
DWORD grfKeyState,
@@ -710,7 +710,7 @@ idroptarget_dragleave (LPDROPTARGET This)
void
_gdk_win32_local_drop_target_drop (GdkDrop *drop,
GdkDragContext *drag,
GdkDrag *drag,
guint32 time_,
GdkDragAction *actions)
{
@@ -1065,7 +1065,7 @@ gdk_win32_drop_status (GdkDrop *drop,
GdkDragAction actions)
{
GdkWin32Drop *drop_win32 = GDK_WIN32_DROP (drop);
GdkDragContext *drag;
GdkDrag *drag;
g_return_if_fail (drop != NULL);
@@ -1090,7 +1090,7 @@ static void
gdk_win32_drop_finish (GdkDrop *drop,
GdkDragAction action)
{
GdkDragContext *drag;
GdkDrag *drag;
GdkWin32Drop *drop_win32 = GDK_WIN32_DROP (drop);
g_return_if_fail (drop != NULL);
@@ -1107,7 +1107,7 @@ gdk_win32_drop_finish (GdkDrop *drop,
drag = gdk_drop_get_drag (drop);
if (drag != NULL)
_gdk_win32_local_drag_context_drop_response (drag, action);
_gdk_win32_local_drag_drop_response (drag, action);
*/
}
+6 -121
View File
@@ -59,7 +59,7 @@
#include "gdkwin32dnd-private.h"
#include "gdkdisplay-win32.h"
//#include "gdkselection-win32.h"
#include "gdkdndprivate.h"
#include "gdkdragprivate.h"
#include <windowsx.h>
@@ -738,8 +738,6 @@ build_wm_ime_composition_event (GdkEvent *event,
build_key_event_state (event, key_state);
event->key.hardware_keycode = 0; /* FIXME: What should it be? */
event->key.string = NULL;
event->key.length = 0;
event->key.keyval = gdk_unicode_to_keyval (wc);
}
@@ -768,7 +766,7 @@ print_event_state (guint state)
void
_gdk_win32_print_event (const GdkEvent *event)
{
gchar *escaped, *kvname;
gchar *kvname;
g_print ("%s%*s===> ", (debug_indent > 0 ? "\n" : ""), debug_indent, "");
switch (event->any.type)
@@ -777,7 +775,6 @@ _gdk_win32_print_event (const GdkEvent *event)
CASE (GDK_NOTHING);
CASE (GDK_DELETE);
CASE (GDK_DESTROY);
CASE (GDK_EXPOSE);
CASE (GDK_MOTION_NOTIFY);
CASE (GDK_BUTTON_PRESS);
CASE (GDK_BUTTON_RELEASE);
@@ -786,9 +783,6 @@ _gdk_win32_print_event (const GdkEvent *event)
CASE (GDK_ENTER_NOTIFY);
CASE (GDK_LEAVE_NOTIFY);
CASE (GDK_FOCUS_CHANGE);
CASE (GDK_CONFIGURE);
CASE (GDK_MAP);
CASE (GDK_UNMAP);
CASE (GDK_PROXIMITY_IN);
CASE (GDK_PROXIMITY_OUT);
CASE (GDK_DRAG_ENTER);
@@ -807,8 +801,6 @@ _gdk_win32_print_event (const GdkEvent *event)
switch (event->any.type)
{
case GDK_EXPOSE:
break;
case GDK_MOTION_NOTIFY:
g_print ("(%.4g,%.4g) (%.4g,%.4g)",
event->motion.x, event->motion.y,
@@ -825,17 +817,10 @@ _gdk_win32_print_event (const GdkEvent *event)
break;
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
if (event->key.length == 0)
escaped = g_strdup ("");
else
escaped = g_strescape (event->key.string, NULL);
kvname = gdk_keyval_name (event->key.keyval);
g_print ("%#.02x group:%d %s %d:\"%s\" ",
g_print ("%#.02x group:%d %s",
event->key.hardware_keycode, event->key.group,
(kvname ? kvname : "??"),
event->key.length,
escaped);
g_free (escaped);
(kvname ? kvname : "??"));
print_event_state (event->key.state);
break;
case GDK_ENTER_NOTIFY:
@@ -861,11 +846,6 @@ _gdk_win32_print_event (const GdkEvent *event)
case GDK_FOCUS_CHANGE:
g_print ("%s", (event->focus_change.in ? "IN" : "OUT"));
break;
case GDK_CONFIGURE:
g_print ("x:%d y:%d w:%d h:%d",
event->configure.x, event->configure.y,
event->configure.width, event->configure.height);
break;
case GDK_DRAG_ENTER:
case GDK_DRAG_LEAVE:
case GDK_DRAG_MOTION:
@@ -873,7 +853,7 @@ _gdk_win32_print_event (const GdkEvent *event)
if (event->dnd.drop != NULL)
g_print ("ctx:%p: %s",
event->dnd.drop,
_gdk_win32_drag_protocol_to_string (GDK_WIN32_DRAG_CONTEXT (event->dnd.drop)->protocol));
_gdk_win32_drag_protocol_to_string (GDK_WIN32_DRAG (event->dnd.drop)->protocol));
break;
case GDK_SCROLL:
g_print ("(%.4g,%.4g) (%.4g,%.4g) %s ",
@@ -951,73 +931,6 @@ _gdk_win32_append_event (GdkEvent *event)
#endif
}
static void
fill_key_event_string (GdkEvent *event)
{
gunichar c;
gchar buf[256];
/* Fill in event->string crudely, since various programs
* depend on it.
*/
c = 0;
if (event->key.keyval != GDK_KEY_VoidSymbol)
c = gdk_keyval_to_unicode (event->key.keyval);
if (c)
{
gsize bytes_written;
gint len;
/* Apply the control key - Taken from Xlib
*/
if (event->key.state & GDK_CONTROL_MASK)
{
if ((c >= '@' && c < '\177') || c == ' ')
c &= 0x1F;
else if (c == '2')
{
event->key.string = g_memdup ("\0\0", 2);
event->key.length = 1;
return;
}
else if (c >= '3' && c <= '7')
c -= ('3' - '\033');
else if (c == '8')
c = '\177';
else if (c == '/')
c = '_' & 0x1F;
}
len = g_unichar_to_utf8 (c, buf);
buf[len] = '\0';
event->key.string = g_locale_from_utf8 (buf, len,
NULL, &bytes_written,
NULL);
if (event->key.string)
event->key.length = bytes_written;
}
else if (event->key.keyval == GDK_KEY_Escape)
{
event->key.length = 1;
event->key.string = g_strdup ("\033");
}
else if (event->key.keyval == GDK_KEY_Return ||
event->key.keyval == GDK_KEY_KP_Enter)
{
event->key.length = 1;
event->key.string = g_strdup ("\r");
}
if (!event->key.string)
{
event->key.length = 0;
event->key.string = g_strdup ("");
}
}
static GdkWin32MessageFilterReturn
apply_message_filters (GdkDisplay *display,
MSG *msg,
@@ -1429,17 +1342,7 @@ _gdk_win32_do_emit_configure_event (GdkSurface *window,
_gdk_surface_update_size (window);
event = gdk_event_new (GDK_CONFIGURE);
event->any.surface = window;
event->configure.width = window->width;
event->configure.height = window->height;
event->configure.x = window->x;
event->configure.y = window->y;
_gdk_win32_append_event (event);
g_signal_emit_by_name (window, "size-changed", window->width, window->height);
}
void
@@ -2309,8 +2212,6 @@ gdk_event_translate (MSG *msg,
event->any.surface = window;
event->key.time = _gdk_win32_get_next_tick (msg->time);
event->key.keyval = GDK_KEY_VoidSymbol;
event->key.string = NULL;
event->key.length = 0;
event->key.hardware_keycode = msg->wParam;
/* save original scancode */
gdk_event_set_scancode (event, msg->lParam >> 16);
@@ -2381,8 +2282,6 @@ gdk_event_translate (MSG *msg,
else
impl->leading_surrogate_keyup = 0;
fill_key_event_string (event);
/* Only one release key event is fired when both shift keys are pressed together
and then released. In order to send the missing event, press events for shift
keys are recorded and sent together when the release event occurs.
@@ -3125,15 +3024,6 @@ gdk_event_translate (MSG *msg,
gdk_device_ungrab (device, msg -> time);
}
/* Send MAP events */
if ((windowpos->flags & SWP_SHOWWINDOW) &&
!GDK_SURFACE_DESTROYED (window))
{
event = gdk_event_new (GDK_MAP);
event->any.surface = window;
_gdk_win32_append_event (event);
}
/* Update window state */
if (windowpos->flags & (SWP_STATECHANGED | SWP_SHOWWINDOW | SWP_HIDEWINDOW))
{
@@ -3192,11 +3082,6 @@ gdk_event_translate (MSG *msg,
if ((windowpos->flags & SWP_HIDEWINDOW) &&
!GDK_SURFACE_DESTROYED (window))
{
/* Send UNMAP events */
event = gdk_event_new (GDK_UNMAP);
event->any.surface = window;
_gdk_win32_append_event (event);
/* Make transient parent the forground window when window unmaps */
impl = GDK_SURFACE_IMPL_WIN32 (window->impl);
+6 -6
View File
@@ -423,12 +423,12 @@ void _gdk_win32_display_create_surface_impl (GdkDisplay *display,
void _gdk_win32_surface_register_dnd (GdkSurface *window);
void _gdk_win32_surface_unregister_dnd (GdkSurface *window);
GdkDragContext *_gdk_win32_surface_drag_begin (GdkSurface *window,
GdkDevice *device,
GdkContentProvider *content,
GdkDragAction actions,
gint x_root,
gint y_root);
GdkDrag *_gdk_win32_surface_drag_begin (GdkSurface *window,
GdkDevice *device,
GdkContentProvider *content,
GdkDragAction actions,
gint x_root,
gint y_root);
/* Stray GdkWin32Screen members */
gboolean _gdk_win32_get_setting (const gchar *name, GValue *value);
+17 -21
View File
@@ -760,17 +760,11 @@ gdk_win32_surface_destroy (GdkSurface *window,
_gdk_remove_modal_window (window);
/* Remove all our transient children */
tmp = surface_impl->transient_children;
while (tmp != NULL)
while (surface_impl->transient_children != NULL)
{
GdkSurface *child = tmp->data;
GdkSurfaceImplWin32 *child_impl = GDK_SURFACE_IMPL_WIN32 (GDK_SURFACE (child)->impl);
child_impl->transient_owner = NULL;
tmp = tmp->next;
GdkSurface *child = surface_impl->transient_children->data;
gdk_surface_set_transient_for (child, NULL);
}
g_slist_free (surface_impl->transient_children);
surface_impl->transient_children = NULL;
/* Remove ourself from our transient owner */
if (surface_impl->transient_owner != NULL)
@@ -1672,27 +1666,29 @@ gdk_win32_surface_set_transient_for (GdkSurface *window,
return;
}
if (parent == NULL)
if (surface_impl->transient_owner == parent)
return;
if (GDK_IS_SURFACE (surface_impl->transient_owner))
{
GdkSurfaceImplWin32 *trans_impl = GDK_SURFACE_IMPL_WIN32 (surface_impl->transient_owner->impl);
if (trans_impl->transient_children != NULL)
{
item = g_slist_find (trans_impl->transient_children, window);
item->data = NULL;
trans_impl->transient_children = g_slist_delete_link (trans_impl->transient_children, item);
trans_impl->num_transients--;
item = g_slist_find (trans_impl->transient_children, window);
item->data = NULL;
trans_impl->transient_children = g_slist_delete_link (trans_impl->transient_children, item);
trans_impl->num_transients--;
if (!trans_impl->num_transients)
{
trans_impl->transient_children = NULL;
}
if (!trans_impl->num_transients)
{
trans_impl->transient_children = NULL;
}
g_object_unref (G_OBJECT (surface_impl->transient_owner));
g_object_unref (G_OBJECT (window));
surface_impl->transient_owner = NULL;
}
else
if (parent)
{
parent_impl = GDK_SURFACE_IMPL_WIN32 (parent->impl);
+17 -17
View File
@@ -26,12 +26,12 @@
G_BEGIN_DECLS
typedef struct _GdkWin32DragContextUtilityData GdkWin32DragContextUtilityData;
typedef struct _GdkWin32DragUtilityData GdkWin32DragUtilityData;
/* This structure is deliberately designed to be
* copyable with memcpy(), i.e. no pointers inside.
*/
struct _GdkWin32DragContextUtilityData
struct _GdkWin32DragUtilityData
{
gint last_x; /* Coordinates from last event, in GDK space */
gint last_y;
@@ -39,15 +39,15 @@ struct _GdkWin32DragContextUtilityData
GdkWin32DndState state;
};
struct _GdkWin32DragContext
struct _GdkWin32Drag
{
GdkDragContext drag;
GdkDrag drag;
/* The drag protocol being used */
GdkDragProtocol protocol;
/* The surface used for grabs.
* Usually the same as GdkDragContext->source_surface
* Usually the same as GdkDrag->source_surface
*/
GdkSurface *grab_surface;
@@ -71,7 +71,7 @@ struct _GdkWin32DragContext
*/
GdkDragAction current_action;
GdkWin32DragContextUtilityData util_data;
GdkWin32DragUtilityData util_data;
guint scale; /* Temporarily caches the HiDPI scale */
gint hot_x; /* Hotspot offset from the top-left of the drag-window, scaled (can be added to GDK space coordinates) */
@@ -84,23 +84,23 @@ struct _GdkWin32DragContext
guint handle_events : 1; /* Whether handle_event() should do anything */
};
struct _GdkWin32DragContextClass
struct _GdkWin32DragClass
{
GdkDragContextClass parent_class;
GdkDragClass parent_class;
};
gpointer _gdk_win32_dnd_thread_main (gpointer data);
GdkDragContext *_gdk_win32_find_drag_for_dest_window (HWND dest_window);
GdkDrop *_gdk_win32_get_drop_for_dest_surface (GdkSurface *dest);
GdkDrag *_gdk_win32_find_drag_for_dest_window (HWND dest_window);
GdkDrop *_gdk_win32_get_drop_for_dest_surface (GdkSurface *dest);
gboolean _gdk_win32_local_drop_target_will_emit_motion (GdkDrop *drop,
gint x_root,
gint y_root,
DWORD grfKeyState);
void _gdk_win32_local_drop_target_dragenter (GdkDragContext *drag,
void _gdk_win32_local_drop_target_dragenter (GdkDrag *drag,
GdkSurface *dest_surface,
gint x_root,
gint y_root,
@@ -108,22 +108,22 @@ void _gdk_win32_local_drop_target_dragenter (GdkDragContext *drag,
guint32 time_,
GdkDragAction *actions);
void _gdk_win32_local_drop_target_dragover (GdkDrop *drop,
GdkDragContext *drag,
GdkDrag *drag,
gint x_root,
gint y_root,
DWORD grfKeyState,
guint32 time_,
GdkDragAction *actions);
void _gdk_win32_local_drop_target_dragleave (GdkDrop *drop,
guint32 time_);
void _gdk_win32_local_drop_target_dragleave (GdkDrop *drop,
guint32 time_);
void _gdk_win32_local_drop_target_drop (GdkDrop *drop,
GdkDragContext *drag,
GdkDrag *drag,
guint32 time_,
GdkDragAction *actions);
void _gdk_win32_local_drag_give_feedback (GdkDragContext *drag,
void _gdk_win32_local_drag_give_feedback (GdkDrag *drag,
GdkDragAction actions);
void _gdk_win32_local_drag_context_drop_response (GdkDragContext *drag,
void _gdk_win32_local_drag_drop_response (GdkDrag *drag,
GdkDragAction action);
+11 -11
View File
@@ -26,23 +26,23 @@
G_BEGIN_DECLS
#define GDK_TYPE_WIN32_DRAG_CONTEXT (gdk_win32_drag_context_get_type ())
#define GDK_WIN32_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WIN32_DRAG_CONTEXT, GdkWin32DragContext))
#define GDK_WIN32_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WIN32_DRAG_CONTEXT, GdkWin32DragContextClass))
#define GDK_IS_WIN32_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WIN32_DRAG_CONTEXT))
#define GDK_IS_WIN32_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WIN32_DRAG_CONTEXT))
#define GDK_WIN32_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WIN32_DRAG_CONTEXT, GdkWin32DragContextClass))
#define GDK_TYPE_WIN32_DRAG (gdk_win32_drag_get_type ())
#define GDK_WIN32_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WIN32_DRAG, GdkWin32Drag))
#define GDK_WIN32_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WIN32_DRAG, GdkWin32DragClass))
#define GDK_IS_WIN32_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WIN32_DRAG))
#define GDK_IS_WIN32_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WIN32_DRAG))
#define GDK_WIN32_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WIN32_DRAG, GdkWin32DragClass))
#ifdef GDK_COMPILATION
typedef struct _GdkWin32DragContext GdkWin32DragContext;
typedef struct _GdkWin32Drag GdkWin32Drag;
#else
typedef GdkDragContext GdkWin32DragContext;
typedef GdkDrag GdkWin32Drag;
#endif
typedef struct _GdkWin32DragContextClass GdkWin32DragContextClass;
typedef struct _GdkWin32DragClass GdkWin32DragClass;
GDK_AVAILABLE_IN_ALL
GType gdk_win32_drag_context_get_type (void);
GType gdk_win32_drag_get_type (void);
G_END_DECLS
#endif /* __GDK_WIN32_DRAG_CONTEXT_H__ */
#endif /* __GDK_WIN32_DRAG_H__ */
+8
View File
@@ -491,6 +491,14 @@ gdk_x11_clipboard_xevent (GdkDisplay *display,
if (sn->selection != cb->xselection)
return FALSE;
if (sn->selection_timestamp < cb->timestamp)
{
GDK_DISPLAY_NOTE (display, CLIPBOARD,
g_printerr ("%s: Ignoring XFixesSelectionNotify with too old timestamp (%lu vs %lu)\n",
cb->selection, sn->selection_timestamp, cb->timestamp));
return FALSE;
}
if (sn->owner == GDK_X11_DISPLAY (display)->leader_window)
{
GDK_DISPLAY_NOTE (display, CLIPBOARD,
-70
View File
@@ -221,8 +221,6 @@ translate_key_event (GdkDisplay *display,
event->key.is_modifier = gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode);
_gdk_x11_event_translate_keyboard_string (&event->key);
#ifdef G_ENABLE_DEBUG
if (GDK_DISPLAY_DEBUG_CHECK (display, EVENTS))
{
@@ -231,10 +229,6 @@ translate_key_event (GdkDisplay *display,
xevent->xkey.window,
event->key.keyval ? gdk_keyval_name (event->key.keyval) : "(none)",
event->key.keyval);
if (event->key.length > 0)
g_message ("\t\tlength: %4d string: \"%s\"",
event->key.length, event->key.string);
}
#endif /* G_ENABLE_DEBUG */
return;
@@ -724,70 +718,6 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
return return_val;
}
void
_gdk_x11_event_translate_keyboard_string (GdkEventKey *event)
{
gunichar c = 0;
gchar buf[7];
/* Fill in event->string crudely, since various programs
* depend on it.
*/
event->string = NULL;
if (event->keyval != GDK_KEY_VoidSymbol)
c = gdk_keyval_to_unicode (event->keyval);
if (c)
{
gsize bytes_written;
gint len;
/* Apply the control key - Taken from Xlib
*/
if (event->state & GDK_CONTROL_MASK)
{
if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F;
else if (c == '2')
{
event->string = g_memdup ("\0\0", 2);
event->length = 1;
buf[0] = '\0';
return;
}
else if (c >= '3' && c <= '7') c -= ('3' - '\033');
else if (c == '8') c = '\177';
else if (c == '/') c = '_' & 0x1F;
}
len = g_unichar_to_utf8 (c, buf);
buf[len] = '\0';
event->string = g_locale_from_utf8 (buf, len,
NULL, &bytes_written,
NULL);
if (event->string)
event->length = bytes_written;
}
else if (event->keyval == GDK_KEY_Escape)
{
event->length = 1;
event->string = g_strdup ("\033");
}
else if (event->keyval == GDK_KEY_Return ||
event->keyval == GDK_KEY_KP_Enter)
{
event->length = 1;
event->string = g_strdup ("\r");
}
if (!event->string)
{
event->length = 0;
event->string = g_strdup ("");
}
}
/* We only care about focus events that indicate that _this_
* surface (not a ancestor or child) got or lost the focus
*/
+1 -4
View File
@@ -1104,8 +1104,7 @@ translate_axes (GdkDevice *device,
gdouble *axes;
gdouble *vals;
g_object_get (device, "n-axes", &n_axes, NULL);
n_axes = gdk_device_get_n_axes (device);
axes = g_new0 (gdouble, n_axes);
vals = valuators->values;
@@ -1472,8 +1471,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
_gdk_x11_keymap_add_virt_mods (keymap, &state);
event->key.state |= state;
_gdk_x11_event_translate_keyboard_string (&event->key);
if (ev->evtype == XI_KeyPress)
set_user_time (event);
+4 -6
View File
@@ -848,9 +848,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
g_message ("unmap notify:\t\twindow: %ld",
xevent->xmap.window));
event->any.type = GDK_UNMAP;
event->any.surface = surface;
if (surface && !is_substructure)
{
/* If the WM supports the _NET_WM_STATE_HIDDEN hint, we do not want to
@@ -885,6 +882,8 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
_gdk_x11_surface_grab_check_unmap (surface, xevent->xany.serial);
}
return_val = FALSE;
break;
case MapNotify:
@@ -892,9 +891,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
g_message ("map notify:\t\twindow: %ld",
xevent->xmap.window));
event->any.type = GDK_MAP;
event->any.surface = surface;
if (surface && !is_substructure)
{
/* Unset iconified if it was set */
@@ -907,6 +903,8 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
gdk_surface_thaw_toplevel_updates (surface);
}
return_val = FALSE;
break;
case ReparentNotify:
File diff suppressed because it is too large Load Diff
+8 -8
View File
@@ -32,7 +32,7 @@
#include "gdkclipboard-x11.h"
#include "gdkdeviceprivate.h"
#include "gdkdisplay-x11.h"
#include "gdkdndprivate.h"
#include "gdkdragprivate.h"
#include "gdkinternals.h"
#include "gdkintl.h"
#include "gdkproperty.h"
@@ -336,7 +336,7 @@ gdk_x11_drop_read_actions (GdkDrop *drop)
{
GdkX11Drop *drop_x11 = GDK_X11_DROP (drop);
GdkDisplay *display = gdk_drop_get_display (drop);
GdkDragContext *drag;
GdkDrag *drag;
GdkDragAction actions = GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK;
Atom type;
int format;
@@ -398,7 +398,7 @@ gdk_x11_drop_read_actions (GdkDrop *drop)
}
else
{
actions = gdk_drag_context_get_actions (drag);
actions = gdk_drag_get_actions (drag);
drop_x11->xdnd_have_actions = TRUE;
}
@@ -468,7 +468,7 @@ xdnd_enter_filter (GdkSurface *surface,
GdkX11Display *display_x11;
GdkDrop *drop;
GdkX11Drop *drop_x11;
GdkDragContext *drag;
GdkDrag *drag;
GdkSeat *seat;
gint i;
Atom type;
@@ -548,7 +548,7 @@ xdnd_enter_filter (GdkSurface *surface,
print_target_list (content_formats);
#endif /* G_ENABLE_DEBUG */
drag = gdk_x11_drag_context_find (display, source_window, GDK_SURFACE_XID (surface));
drag = gdk_x11_drag_find (display, source_window, GDK_SURFACE_XID (surface));
drop_x11 = g_object_new (GDK_TYPE_X11_DROP,
"device", gdk_seat_get_pointer (seat),
@@ -768,7 +768,7 @@ gdk_x11_drop_status (GdkDrop *drop,
if (gdk_drop_get_drag (drop))
{
gdk_x11_drag_context_handle_status (display, &xev);
gdk_x11_drag_handle_status (display, &xev);
}
else
{
@@ -821,7 +821,7 @@ gdk_x11_drop_finish (GdkDrop *drop,
if (gdk_drop_get_drag (drop))
{
gdk_x11_drag_context_handle_status (display, &xev);
gdk_x11_drag_handle_status (display, &xev);
}
else
{
@@ -849,7 +849,7 @@ gdk_x11_drop_class_init (GdkX11DropClass *klass)
}
static void
gdk_x11_drop_init (GdkX11Drop *context)
gdk_x11_drop_init (GdkX11Drop *drag)
{
}
+11 -13
View File
@@ -166,8 +166,6 @@ void gdk_x11_device_xi2_store_axes (GdkX11DeviceXI2 *device,
gint n_axes);
#endif
void _gdk_x11_event_translate_keyboard_string (GdkEventKey *event);
GdkAtom _gdk_x11_display_manager_atom_intern (GdkDisplayManager *manager,
const gchar *atom_name,
gboolean copy_name);
@@ -196,16 +194,16 @@ Atom _gdk_x11_get_xatom_for_display_printf (GdkDisplay *display,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
GdkDragContext *gdk_x11_drag_context_find (GdkDisplay *display,
Window source_xid,
Window dest_xid);
void gdk_x11_drag_context_handle_status (GdkDisplay *display,
const XEvent *xevent);
void gdk_x11_drag_context_handle_finished (GdkDisplay *display,
const XEvent *xevent);
void gdk_x11_drop_read_actions (GdkDrop *drop);
gboolean gdk_x11_drop_filter (GdkSurface *surface,
const XEvent *xevent);
GdkDrag *gdk_x11_drag_find (GdkDisplay *display,
Window source_xid,
Window dest_xid);
void gdk_x11_drag_handle_status (GdkDisplay *display,
const XEvent *xevent);
void gdk_x11_drag_handle_finished (GdkDisplay *display,
const XEvent *xevent);
void gdk_x11_drop_read_actions (GdkDrop *drop);
gboolean gdk_x11_drop_filter (GdkSurface *surface,
const XEvent *xevent);
typedef struct _GdkSurfaceCache GdkSurfaceCache;
@@ -225,7 +223,7 @@ void _gdk_x11_cursor_display_finalize (GdkDisplay *display);
void _gdk_x11_surface_register_dnd (GdkSurface *window);
GdkDragContext * _gdk_x11_surface_drag_begin (GdkSurface *window,
GdkDrag * _gdk_x11_surface_drag_begin (GdkSurface *window,
GdkDevice *device,
GdkContentProvider *content,
GdkDragAction actions,
+31 -39
View File
@@ -880,16 +880,8 @@ _gdk_x11_display_create_surface_impl (GdkDisplay *display,
{
class = InputOutput;
if (gdk_display_is_rgba (display))
{
xattributes.background_pixel = 0;
xattributes_mask |= CWBackPixel;
}
else
{
xattributes.background_pixmap = None;
xattributes_mask |= CWBackPixmap;
}
xattributes.background_pixmap = None;
xattributes_mask |= CWBackPixmap;
xattributes.border_pixel = BlackPixel (xdisplay, x11_screen->screen_num);
xattributes_mask |= CWBorderPixel;
@@ -1292,35 +1284,6 @@ gdk_surface_x11_show (GdkSurface *surface, gboolean already_mapped)
gdk_x11_surface_apply_fullscreen_mode (surface);
}
static void
gdk_surface_x11_hide (GdkSurface *surface)
{
/* We'll get the unmap notify eventually, and handle it then,
* but checking here makes things more consistent if we are
* just doing stuff ourself.
*/
_gdk_x11_surface_grab_check_unmap (surface,
NextRequest (GDK_SURFACE_XDISPLAY (surface)));
/* You can't simply unmap toplevel surfaces. */
switch (surface->surface_type)
{
case GDK_SURFACE_TOPLEVEL:
case GDK_SURFACE_TEMP: /* ? */
gdk_surface_withdraw (surface);
return;
case GDK_SURFACE_CHILD:
default:
break;
}
_gdk_surface_clear_update_area (surface);
XUnmapWindow (GDK_SURFACE_XDISPLAY (surface),
GDK_SURFACE_XID (surface));
}
static void
gdk_surface_x11_withdraw (GdkSurface *surface)
{
@@ -1338,6 +1301,35 @@ gdk_surface_x11_withdraw (GdkSurface *surface)
}
}
static void
gdk_surface_x11_hide (GdkSurface *surface)
{
/* We'll get the unmap notify eventually, and handle it then,
* but checking here makes things more consistent if we are
* just doing stuff ourself.
*/
_gdk_x11_surface_grab_check_unmap (surface,
NextRequest (GDK_SURFACE_XDISPLAY (surface)));
/* You can't simply unmap toplevel surfaces. */
switch (surface->surface_type)
{
case GDK_SURFACE_TOPLEVEL:
case GDK_SURFACE_TEMP: /* ? */
gdk_surface_x11_withdraw (surface);
return;
case GDK_SURFACE_CHILD:
default:
break;
}
_gdk_surface_clear_update_area (surface);
XUnmapWindow (GDK_SURFACE_XDISPLAY (surface),
GDK_SURFACE_XID (surface));
}
static inline void
surface_x11_move (GdkSurface *surface,
gint x,
+1 -1
View File
@@ -27,7 +27,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceManagerCore, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceManagerXI2, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceXI2, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Display, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DragContext, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Drag, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11GLContext, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Keymap, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Screen, g_object_unref)
+11 -11
View File
@@ -26,23 +26,23 @@
G_BEGIN_DECLS
#define GDK_TYPE_X11_DRAG_CONTEXT (gdk_x11_drag_context_get_type ())
#define GDK_X11_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_X11_DRAG_CONTEXT, GdkX11DragContext))
#define GDK_X11_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_X11_DRAG_CONTEXT, GdkX11DragContextClass))
#define GDK_IS_X11_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_X11_DRAG_CONTEXT))
#define GDK_IS_X11_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_X11_DRAG_CONTEXT))
#define GDK_X11_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_X11_DRAG_CONTEXT, GdkX11DragContextClass))
#define GDK_TYPE_X11_DRAG (gdk_x11_drag_get_type ())
#define GDK_X11_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_X11_DRAG, GdkX11Drag))
#define GDK_X11_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_X11_DRAG, GdkX11DragClass))
#define GDK_IS_X11_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_X11_DRAG))
#define GDK_IS_X11_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_X11_DRAG))
#define GDK_X11_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_X11_DRAG, GdkX11DragClass))
#ifdef GDK_COMPILATION
typedef struct _GdkX11DragContext GdkX11DragContext;
typedef struct _GdkX11Drag GdkX11Drag;
#else
typedef GdkDragContext GdkX11DragContext;
typedef GdkDrag GdkX11Drag;
#endif
typedef struct _GdkX11DragContextClass GdkX11DragContextClass;
typedef struct _GdkX11DragClass GdkX11DragClass;
GDK_AVAILABLE_IN_ALL
GType gdk_x11_drag_context_get_type (void);
GType gdk_x11_drag_get_type (void);
G_END_DECLS
#endif /* __GDK_X11_DRAG_CONTEXT_H__ */
#endif /* __GDK_X11_DRAG_H__ */
+2 -2
View File
@@ -11,7 +11,7 @@ gdk_x11_sources = files([
'gdkdevicemanager-x11.c',
'gdkdevicemanager-xi2.c',
'gdkdisplay-x11.c',
'gdkdnd-x11.c',
'gdkdrag-x11.c',
'gdkdrop-x11.c',
'gdkeventsource.c',
'gdkeventtranslator.c',
@@ -70,7 +70,7 @@ gdk_x11_deps = [
xinerama_dep,
]
libgdk_x11 = static_library('gdk-x11',
libgdk_x11 = static_library('gdk-x11', gdkmarshal_h,
gdk_x11_sources, gdkconfig, gdkenum_h,
include_directories: [ confinc, gdkinc, ],
c_args: [
+97 -71
View File
@@ -13,6 +13,7 @@
#include "gskglglyphcacheprivate.h"
#include "gskglrenderopsprivate.h"
#include "gskcairoblurprivate.h"
#include "gskglshadowcacheprivate.h"
#include "gskprivate.h"
@@ -53,7 +54,6 @@
glGetUniformLocation(program_ptr->id, "u_" #uniform_basename);\
}G_STMT_END
static void G_GNUC_UNUSED
print_render_node_tree (GskRenderNode *root, int level)
{
@@ -266,6 +266,7 @@ struct _GskGLRenderer
GArray *render_ops;
GskGLGlyphCache glyph_cache;
GskGLShadowCache shadow_cache;
#ifdef G_ENABLE_DEBUG
struct {
@@ -321,13 +322,19 @@ render_fallback_node (GskGLRenderer *self,
const GskQuadVertex *vertex_data)
{
const float scale = ops_get_scale (builder);
const int surface_width = ceilf (node->bounds.size.width) * scale;
const int surface_height = ceilf (node->bounds.size.height) * scale;
cairo_surface_t *surface;
cairo_t *cr;
int texture_id;
if (surface_width <= 0 ||
surface_height <= 0)
return;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
ceilf (node->bounds.size.width) * scale,
ceilf (node->bounds.size.height) * scale);
surface_width,
surface_height);
cairo_surface_set_device_scale (surface, scale, scale);
cr = cairo_create (surface);
@@ -349,8 +356,8 @@ render_fallback_node (GskGLRenderer *self,
/* Upload the Cairo surface to a GL texture */
texture_id = gsk_gl_driver_create_texture (self->gl_driver,
cairo_image_surface_get_width (surface),
cairo_image_surface_get_height (surface));
surface_width,
surface_height);
gsk_gl_driver_bind_source_texture (self->gl_driver, texture_id);
gsk_gl_driver_init_texture_with_surface (self->gl_driver,
@@ -378,8 +385,8 @@ render_text_node (GskGLRenderer *self,
guint num_glyphs = gsk_text_node_get_num_glyphs (node);
int i;
int x_position = 0;
int x = gsk_text_node_get_x (node) + builder->dx;
int y = gsk_text_node_get_y (node) + builder->dy;
float x = gsk_text_node_get_x (node) + builder->dx;
float y = gsk_text_node_get_y (node) + builder->dy;
/* If the font has color glyphs, we don't need to recolor anything */
if (!force_color && font_has_color_glyphs (font))
@@ -398,7 +405,7 @@ render_text_node (GskGLRenderer *self,
{
const PangoGlyphInfo *gi = &glyphs[i];
const GskGLCachedGlyph *glyph;
int glyph_x, glyph_y, glyph_w, glyph_h;
float glyph_x, glyph_y, glyph_w, glyph_h;
float tx, ty, tx2, ty2;
double cx;
double cy;
@@ -1067,10 +1074,8 @@ render_outset_shadow_node (GskGLRenderer *self,
graphene_matrix_t prev_modelview;
graphene_rect_t prev_viewport;
graphene_matrix_t item_proj;
GskRoundedRect prev_clip, blit_clip;
int prev_render_target;
int texture_id, render_target;
int blurred_texture_id, blurred_render_target;
int blurred_texture_id;
int cached_tid;
/* offset_outline is the minimal outline we need to draw the given drop shadow,
* enlarged by the spread and offset by the blur radius. */
@@ -1092,77 +1097,97 @@ render_outset_shadow_node (GskGLRenderer *self,
texture_width = offset_outline.bounds.size.width + blur_extra;
texture_height = offset_outline.bounds.size.height + blur_extra;
texture_id = gsk_gl_driver_create_texture (self->gl_driver, texture_width, texture_height);
gsk_gl_driver_bind_source_texture (self->gl_driver, texture_id);
gsk_gl_driver_init_texture_empty (self->gl_driver, texture_id);
render_target = gsk_gl_driver_create_render_target (self->gl_driver, texture_id, FALSE, FALSE);
cached_tid = gsk_gl_shadow_cache_get_texture_id (&self->shadow_cache,
self->gl_driver,
&offset_outline,
blur_radius);
if (cached_tid == 0)
{
int texture_id, render_target;
int blurred_render_target;
int prev_render_target;
GskRoundedRect prev_clip, blit_clip;
texture_id = gsk_gl_driver_create_texture (self->gl_driver, texture_width, texture_height);
gsk_gl_driver_bind_source_texture (self->gl_driver, texture_id);
gsk_gl_driver_init_texture_empty (self->gl_driver, texture_id);
render_target = gsk_gl_driver_create_render_target (self->gl_driver, texture_id, FALSE, FALSE);
graphene_matrix_init_ortho (&item_proj,
0, texture_width, 0, texture_height,
ORTHO_NEAR_PLANE, ORTHO_FAR_PLANE);
graphene_matrix_scale (&item_proj, 1, -1, 1);
graphene_matrix_init_identity (&identity);
graphene_matrix_init_ortho (&item_proj,
0, texture_width, 0, texture_height,
ORTHO_NEAR_PLANE, ORTHO_FAR_PLANE);
graphene_matrix_scale (&item_proj, 1, -1, 1);
graphene_matrix_init_identity (&identity);
prev_render_target = ops_set_render_target (builder, render_target);
op.op = OP_CLEAR;
ops_add (builder, &op);
prev_projection = ops_set_projection (builder, &item_proj);
prev_modelview = ops_set_modelview (builder, &identity);
prev_viewport = ops_set_viewport (builder, &GRAPHENE_RECT_INIT (0, 0, texture_width, texture_height));
prev_render_target = ops_set_render_target (builder, render_target);
op.op = OP_CLEAR;
ops_add (builder, &op);
prev_projection = ops_set_projection (builder, &item_proj);
prev_modelview = ops_set_modelview (builder, &identity);
prev_viewport = ops_set_viewport (builder, &GRAPHENE_RECT_INIT (0, 0, texture_width, texture_height));
/* Draw outline */
ops_set_program (builder, &self->color_program);
prev_clip = ops_set_clip (builder, &offset_outline);
ops_set_color (builder, gsk_outset_shadow_node_peek_color (node));
ops_draw (builder, (GskQuadVertex[GL_N_VERTICES]) {
{ { 0, }, { 0, 1 }, },
{ { 0, texture_height }, { 0, 0 }, },
{ { texture_width, }, { 1, 1 }, },
/* Draw outline */
ops_set_program (builder, &self->color_program);
prev_clip = ops_set_clip (builder, &offset_outline);
ops_set_color (builder, gsk_outset_shadow_node_peek_color (node));
ops_draw (builder, (GskQuadVertex[GL_N_VERTICES]) {
{ { 0, }, { 0, 1 }, },
{ { 0, texture_height }, { 0, 0 }, },
{ { texture_width, }, { 1, 1 }, },
{ { texture_width, texture_height }, { 1, 0 }, },
{ { 0, texture_height }, { 0, 0 }, },
{ { texture_width, }, { 1, 1 }, },
});
{ { texture_width, texture_height }, { 1, 0 }, },
{ { 0, texture_height }, { 0, 0 }, },
{ { texture_width, }, { 1, 1 }, },
});
blurred_texture_id = gsk_gl_driver_create_texture (self->gl_driver, texture_width, texture_height);
gsk_gl_driver_bind_source_texture (self->gl_driver, blurred_texture_id);
gsk_gl_driver_init_texture_empty (self->gl_driver, blurred_texture_id);
blurred_render_target = gsk_gl_driver_create_render_target (self->gl_driver, blurred_texture_id, TRUE, TRUE);
blurred_texture_id = gsk_gl_driver_create_permanent_texture (self->gl_driver, texture_width, texture_height);
gsk_gl_driver_bind_source_texture (self->gl_driver, blurred_texture_id);
gsk_gl_driver_init_texture_empty (self->gl_driver, blurred_texture_id);
blurred_render_target = gsk_gl_driver_create_render_target (self->gl_driver, blurred_texture_id, TRUE, TRUE);
ops_set_render_target (builder, blurred_render_target);
op.op = OP_CLEAR;
ops_add (builder, &op);
ops_set_render_target (builder, blurred_render_target);
op.op = OP_CLEAR;
ops_add (builder, &op);
gsk_rounded_rect_init_from_rect (&blit_clip,
&GRAPHENE_RECT_INIT (0, 0, texture_width, texture_height), 0.0f);
gsk_rounded_rect_init_from_rect (&blit_clip,
&GRAPHENE_RECT_INIT (0, 0, texture_width, texture_height), 0.0f);
ops_set_program (builder, &self->blur_program);
op.op = OP_CHANGE_BLUR;
op.blur.size.width = texture_width;
op.blur.size.height = texture_height;
op.blur.radius = blur_radius;
ops_add (builder, &op);
ops_set_program (builder, &self->blur_program);
op.op = OP_CHANGE_BLUR;
op.blur.size.width = texture_width;
op.blur.size.height = texture_height;
op.blur.radius = blur_radius;
ops_add (builder, &op);
ops_set_clip (builder, &blit_clip);
ops_set_texture (builder, texture_id);
ops_draw (builder, (GskQuadVertex[GL_N_VERTICES]) {
{ { 0, 0 }, { 0, 1 }, },
{ { 0, texture_height }, { 0, 0 }, },
{ { texture_width, 0 }, { 1, 1 }, },
ops_set_clip (builder, &blit_clip);
ops_set_texture (builder, texture_id);
ops_draw (builder, (GskQuadVertex[GL_N_VERTICES]) {
{ { 0, 0 }, { 0, 1 }, },
{ { 0, texture_height }, { 0, 0 }, },
{ { texture_width, 0 }, { 1, 1 }, },
{ { texture_width, texture_height }, { 1, 0 }, },
{ { 0, texture_height }, { 0, 0 }, },
{ { texture_width, 0 }, { 1, 1 }, },
});
{ { texture_width, texture_height }, { 1, 0 }, },
{ { 0, texture_height }, { 0, 0 }, },
{ { texture_width, 0 }, { 1, 1 }, },
});
ops_set_clip (builder, &prev_clip);
ops_set_clip (builder, &prev_clip);
ops_set_viewport (builder, &prev_viewport);
ops_set_modelview (builder, &prev_modelview);
ops_set_projection (builder, &prev_projection);
ops_set_render_target (builder, prev_render_target);
ops_set_viewport (builder, &prev_viewport);
ops_set_modelview (builder, &prev_modelview);
ops_set_projection (builder, &prev_projection);
ops_set_render_target (builder, prev_render_target);
gsk_gl_shadow_cache_commit (&self->shadow_cache,
&offset_outline,
blur_radius,
blurred_texture_id);
}
else
{
blurred_texture_id = cached_tid;
}
ops_set_program (builder, &self->outset_shadow_program);
ops_set_texture (builder, blurred_texture_id);
@@ -1387,8 +1412,6 @@ render_outset_shadow_node (GskGLRenderer *self,
}
}
ops_set_clip (builder, &prev_clip);
}
static inline void
@@ -2000,6 +2023,7 @@ gsk_gl_renderer_realize (GskRenderer *renderer,
return FALSE;
gsk_gl_glyph_cache_init (&self->glyph_cache, renderer, self->gl_driver);
gsk_gl_shadow_cache_init (&self->shadow_cache);
return TRUE;
}
@@ -2024,6 +2048,7 @@ gsk_gl_renderer_unrealize (GskRenderer *renderer)
glDeleteProgram (self->programs[i].id);
gsk_gl_glyph_cache_free (&self->glyph_cache);
gsk_gl_shadow_cache_free (&self->shadow_cache, self->gl_driver);
g_clear_object (&self->gl_profiler);
g_clear_object (&self->gl_driver);
@@ -2518,6 +2543,7 @@ gsk_gl_renderer_do_render (GskRenderer *renderer,
gsk_gl_driver_begin_frame (self->gl_driver);
gsk_gl_glyph_cache_begin_frame (&self->glyph_cache);
gsk_gl_shadow_cache_begin_frame (&self->shadow_cache, self->gl_driver);
memset (&render_op_builder, 0, sizeof (render_op_builder));
render_op_builder.renderer = self;
+142
View File
@@ -0,0 +1,142 @@
#include "gskglshadowcacheprivate.h"
typedef struct
{
GskRoundedRect outline;
float blur_radius;
} CacheKey;
typedef struct
{
GskRoundedRect outline;
float blur_radius;
int texture_id;
guint used : 1;
} CacheItem;
static gboolean
key_equal (const void *x,
const void *y)
{
const CacheKey *a = x;
const CacheKey *b = y;
return graphene_size_equal (&a->outline.corner[0], &b->outline.corner[0]) &&
graphene_size_equal (&a->outline.corner[1], &b->outline.corner[1]) &&
graphene_size_equal (&a->outline.corner[2], &b->outline.corner[2]) &&
graphene_size_equal (&a->outline.corner[3], &b->outline.corner[3]) &&
graphene_rect_equal (&a->outline.bounds, &b->outline.bounds) &&
a->blur_radius == b->blur_radius;
}
void
gsk_gl_shadow_cache_init (GskGLShadowCache *self)
{
self->textures = g_array_new (FALSE, TRUE, sizeof (CacheItem));
}
void
gsk_gl_shadow_cache_free (GskGLShadowCache *self,
GskGLDriver *gl_driver)
{
guint i, p;
for (i = 0, p = self->textures->len; i < p; i ++)
{
const CacheItem *item = &g_array_index (self->textures, CacheItem, i);
gsk_gl_driver_destroy_texture (gl_driver, item->texture_id);
}
g_array_free (self->textures, TRUE);
self->textures = NULL;
}
void
gsk_gl_shadow_cache_begin_frame (GskGLShadowCache *self,
GskGLDriver *gl_driver)
{
guint i, p;
/* We remove all textures with used = FALSE since those have not been used in the
* last frame. For all others, we reset the `used` value to FALSE instead and see
* if they end up with TRUE in the next call to begin_frame. */
for (i = 0, p = self->textures->len; i < p; i ++)
{
CacheItem *item = &g_array_index (self->textures, CacheItem, i);
if (!item->used)
{
gsk_gl_driver_destroy_texture (gl_driver, item->texture_id);
g_array_remove_index_fast (self->textures, i);
p --;
i --;
}
else
{
item->used = FALSE;
}
}
}
/* XXX
* The offset origin should always be at 0/0, or the blur radius should just go
* away since it defines the origin position anyway?
*/
int
gsk_gl_shadow_cache_get_texture_id (GskGLShadowCache *self,
GskGLDriver *gl_driver,
const GskRoundedRect *shadow_rect,
float blur_radius)
{
CacheItem *item= NULL;
guint i;
g_assert (self != NULL);
g_assert (gl_driver != NULL);
g_assert (shadow_rect != NULL);
for (i = 0; i < self->textures->len; i ++)
{
CacheItem *k = &g_array_index (self->textures, CacheItem, i);
if (key_equal (&(CacheKey){*shadow_rect, blur_radius},
&(CacheKey){k->outline, k->blur_radius}))
{
item = k;
break;
}
}
if (item == NULL)
return 0;
item->used = TRUE;
g_assert (item->texture_id != 0);
return item->texture_id;
}
void
gsk_gl_shadow_cache_commit (GskGLShadowCache *self,
const GskRoundedRect *shadow_rect,
float blur_radius,
int texture_id)
{
CacheItem *item;
g_assert (self != NULL);
g_assert (shadow_rect != NULL);
g_assert (texture_id > 0);
g_array_set_size (self->textures, self->textures->len + 1);
item = &g_array_index (self->textures, CacheItem, self->textures->len - 1);
item->outline = *shadow_rect;
item->blur_radius = blur_radius;
item->used = TRUE;
item->texture_id = texture_id;
}
+31
View File
@@ -0,0 +1,31 @@
#ifndef __GSK_GL_SHADOW_CACHE_H__
#define __GSK_GL_SHADOW_CACHE_H__
#include <glib.h>
#include "gskgldriverprivate.h"
#include "gskroundedrect.h"
typedef struct
{
GArray *textures;
} GskGLShadowCache;
void gsk_gl_shadow_cache_init (GskGLShadowCache *self);
void gsk_gl_shadow_cache_free (GskGLShadowCache *self,
GskGLDriver *gl_driver);
void gsk_gl_shadow_cache_begin_frame (GskGLShadowCache *self,
GskGLDriver *gl_driver);
int gsk_gl_shadow_cache_get_texture_id (GskGLShadowCache *self,
GskGLDriver *gl_driver,
const GskRoundedRect *shadow_rect,
float blur_radius);
void gsk_gl_shadow_cache_commit (GskGLShadowCache *self,
const GskRoundedRect *shadow_rect,
float blur_radius,
int texture_id);
#endif
+2 -2
View File
@@ -448,8 +448,8 @@ gsk_renderer_render_texture (GskRenderer *renderer,
* gsk_renderer_render:
* @renderer: a #GskRenderer
* @root: a #GskRenderNode
* @region: the #cairo_region_t that must be redrawn or %NULL for the whole
* window
* @region: (nullable): the #cairo_region_t that must be redrawn or %NULL
* for the whole window
*
* Renders the scene graph, described by a tree of #GskRenderNode instances,
* ensuring that the given @region gets redrawn.
+4 -4
View File
@@ -205,14 +205,14 @@ const graphene_matrix_t *
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_offset_node_new (GskRenderNode *child,
double x_offset,
double y_offset);
float x_offset,
float y_offset);
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_offset_node_get_child (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
double gsk_offset_node_get_x_offset (GskRenderNode *node);
float gsk_offset_node_get_x_offset (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
double gsk_offset_node_get_y_offset (GskRenderNode *node);
float gsk_offset_node_get_y_offset (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_opacity_node_new (GskRenderNode *child,
+20 -14
View File
@@ -2561,8 +2561,8 @@ struct _GskOffsetNode
GskRenderNode render_node;
GskRenderNode *child;
double x_offset;
double y_offset;
float x_offset;
float y_offset;
};
static void
@@ -2694,8 +2694,8 @@ static const GskRenderNodeClass GSK_OFFSET_NODE_CLASS = {
*/
GskRenderNode *
gsk_offset_node_new (GskRenderNode *child,
double x_offset,
double y_offset)
float x_offset,
float y_offset)
{
GskOffsetNode *self;
@@ -2732,7 +2732,7 @@ gsk_offset_node_get_child (GskRenderNode *node)
return self->child;
}
double
float
gsk_offset_node_get_x_offset (GskRenderNode *node)
{
GskOffsetNode *self = (GskOffsetNode *) node;
@@ -2742,7 +2742,7 @@ gsk_offset_node_get_x_offset (GskRenderNode *node)
return self->x_offset;
}
double
float
gsk_offset_node_get_y_offset (GskRenderNode *node)
{
GskOffsetNode *self = (GskOffsetNode *) node;
@@ -3565,7 +3565,7 @@ gsk_clip_node_diff (GskRenderNode *node1,
{
cairo_region_t *sub;
cairo_rectangle_int_t clip_rect;
sub = cairo_region_create();
gsk_render_node_diff (self1->child, self2->child, sub);
rectangle_init_from_graphene (&clip_rect, &self1->clip);
@@ -3573,8 +3573,10 @@ gsk_clip_node_diff (GskRenderNode *node1,
cairo_region_union (region, sub);
cairo_region_destroy (sub);
}
gsk_render_node_diff_impossible (node1, node2, region);
else
{
gsk_render_node_diff_impossible (node1, node2, region);
}
}
#define GSK_CLIP_NODE_VARIANT_TYPE "(dddduv)"
@@ -3737,7 +3739,7 @@ gsk_rounded_clip_node_diff (GskRenderNode *node1,
{
cairo_region_t *sub;
cairo_rectangle_int_t clip_rect;
sub = cairo_region_create();
gsk_render_node_diff (self1->child, self2->child, sub);
rectangle_init_from_graphene (&clip_rect, &self1->clip.bounds);
@@ -3745,8 +3747,10 @@ gsk_rounded_clip_node_diff (GskRenderNode *node1,
cairo_region_union (region, sub);
cairo_region_destroy (sub);
}
gsk_render_node_diff_impossible (node1, node2, region);
else
{
gsk_render_node_diff_impossible (node1, node2, region);
}
}
#define GSK_ROUNDED_CLIP_NODE_VARIANT_TYPE "(dddddddddddduv)"
@@ -4262,8 +4266,10 @@ gsk_blend_node_diff (GskRenderNode *node1,
gsk_render_node_diff (self1->top, self2->top, region);
gsk_render_node_diff (self1->bottom, self2->bottom, region);
}
gsk_render_node_diff_impossible (node1, node2, region);
else
{
gsk_render_node_diff_impossible (node1, node2, region);
}
}
#define GSK_BLEND_NODE_VARIANT_TYPE "(uvuvu)"
+1 -1
View File
@@ -50,7 +50,7 @@ G_BEGIN_DECLS
* @bounds: the bounds of the rectangle
* @corner: the size of the 4 rounded corners
*
* A rectanglular region with rounded corners.
* A rectangular region with rounded corners.
*
* Application code should normalize rectangles using gsk_rounded_rect_normalize();
* this function will ensure that the bounds of the rectanlge are normalized
+2 -1
View File
@@ -41,7 +41,8 @@ gsk_private_sources = files([
'gl/gskglglyphcache.c',
'gl/gskglimage.c',
'gl/gskgldriver.c',
'gl/gskglrenderops.c'
'gl/gskglrenderops.c',
'gl/gskglshadowcache.c',
])
gsk_public_headers = files([
+92 -5
View File
@@ -1,15 +1,102 @@
uniform mat4 uMVP;
uniform sampler2D uSource;
uniform sampler2D uMask;
uniform float uAlpha;
uniform sampler2D u_source;
uniform sampler2D u_mask;
uniform mat4 u_projection;
uniform mat4 u_modelview;
uniform float u_alpha;
uniform int uBlendMode;
uniform vec4 u_viewport;
// In GtkSnapshot coordinates
uniform vec4 u_clip;
uniform vec4 u_clip_corner_widths;
uniform vec4 u_clip_corner_heights;
varying vec2 vUv;
struct RoundedRect
{
vec4 bounds;
vec4 corner_widths;
vec4 corner_heights;
};
float
ellipsis_dist (vec2 p, vec2 radius)
{
if (radius == vec2(0, 0))
return 0.0;
vec2 p0 = p / radius;
vec2 p1 = 2.0 * p0 / radius;
return (dot(p0, p0) - 1.0) / length (p1);
}
float
ellipsis_coverage (vec2 point, vec2 center, vec2 radius)
{
float d = ellipsis_dist (point - center, radius);
return clamp (0.5 - d, 0.0, 1.0);
}
float
rounded_rect_coverage (RoundedRect r, vec2 p)
{
if (p.x < r.bounds.x || p.y < r.bounds.y ||
p.x >= r.bounds.z || p.y >= r.bounds.w)
return 0.0;
vec2 rad_tl = vec2(r.corner_widths.x, r.corner_heights.x);
vec2 rad_tr = vec2(r.corner_widths.y, r.corner_heights.y);
vec2 rad_br = vec2(r.corner_widths.z, r.corner_heights.z);
vec2 rad_bl = vec2(r.corner_widths.w, r.corner_heights.w);
vec2 ref_tl = r.bounds.xy + vec2( r.corner_widths.x, r.corner_heights.x);
vec2 ref_tr = r.bounds.zy + vec2(-r.corner_widths.y, r.corner_heights.y);
vec2 ref_br = r.bounds.zw + vec2(-r.corner_widths.z, -r.corner_heights.z);
vec2 ref_bl = r.bounds.xw + vec2( r.corner_widths.w, -r.corner_heights.w);
float d_tl = ellipsis_coverage(p, ref_tl, rad_tl);
float d_tr = ellipsis_coverage(p, ref_tr, rad_tr);
float d_br = ellipsis_coverage(p, ref_br, rad_br);
float d_bl = ellipsis_coverage(p, ref_bl, rad_bl);
vec4 corner_coverages = 1.0 - vec4(d_tl, d_tr, d_br, d_bl);
bvec4 is_out = bvec4(p.x < ref_tl.x && p.y < ref_tl.y,
p.x > ref_tr.x && p.y < ref_tr.y,
p.x > ref_br.x && p.y > ref_br.y,
p.x < ref_bl.x && p.y > ref_bl.y);
return 1.0 - dot(vec4(is_out), corner_coverages);
}
RoundedRect
rounded_rect_shrink (RoundedRect r, vec4 amount)
{
vec4 new_bounds = r.bounds + vec4(1.0,1.0,-1.0,-1.0) * amount.wxyz;
vec4 new_widths = max (r.corner_widths - amount.wyyw, 0.0);
vec4 new_heights = max (r.corner_heights - amount.xxzz, 0.0);
return RoundedRect (new_bounds, new_widths, new_heights);
}
vec4 Texture(sampler2D sampler, vec2 texCoords) {
return texture2D(sampler, texCoords);
}
void setOutputColor(vec4 color) {
gl_FragColor = color;
vec4 clipBounds = u_clip;
vec4 f = gl_FragCoord;
f.x += u_viewport.x;
f.y = (u_viewport.y + u_viewport.w) - f.y;
clipBounds.z = clipBounds.x + clipBounds.z;
clipBounds.w = clipBounds.y + clipBounds.w;
RoundedRect r = RoundedRect(clipBounds, u_clip_corner_widths, u_clip_corner_heights);
gl_FragColor = color * rounded_rect_coverage(r, f.xy);
}
+2 -1
View File
@@ -1,4 +1,5 @@
uniform mat4 uMVP;
uniform mat4 u_projection;
uniform mat4 u_modelview;
attribute vec2 aPosition;
attribute vec2 aUv;
+1 -1
View File
@@ -147,7 +147,7 @@ gsk_vulkan_renderer_unrealize (GskRenderer *renderer)
data->renderer = NULL;
gdk_texture_clear_render_data (data->texture);
}
g_clear_pointer (&self->textures, (GDestroyNotify) g_slist_free);
g_clear_pointer (&self->textures, g_slist_free);
g_clear_pointer (&self->render, gsk_vulkan_render_free);
+2 -10
View File
@@ -116,13 +116,11 @@ atk_key_event_from_gdk_event_key (GdkEventKey *key,
GdkModifierType state;
guint keyval;
guint16 keycode;
const char *string;
type = gdk_event_get_event_type ((GdkEvent *)key);
gdk_event_get_state ((GdkEvent *)key, &state);
gdk_event_get_keyval ((GdkEvent *)key, &keyval);
gdk_event_get_keycode ((GdkEvent *)key, &keycode);
gdk_event_get_string ((GdkEvent *)key, &string);
if (type == GDK_KEY_PRESS)
event->type = ATK_KEY_EVENT_PRESS;
@@ -133,14 +131,8 @@ atk_key_event_from_gdk_event_key (GdkEventKey *key,
event->state = state;
event->keyval = keyval;
if (string && string[0] &&
(state & GDK_CONTROL_MASK ||
g_unichar_isgraph (g_utf8_get_char (string))))
event->string = (char *) string;
else
event->string = gdk_keyval_name (keyval);
event->length = strlen (string);
event->string = gdk_keyval_name (keyval);
event->length = strlen (event->string);
event->keycode = keycode;
event->timestamp = gdk_event_get_time ((GdkEvent *)key);
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 B

Some files were not shown because too many files have changed in this diff Show More