Compare commits

...

477 Commits

Author SHA1 Message Date
Emmanuele Bassi d50301ee6a ci: Use the latest Fedora images 2020-10-17 15:40:52 +01:00
Emmanuele Bassi cb4d2d4153 ci: Rebase the Fedora images 2020-10-17 15:40:35 +01:00
Emmanuele Bassi 8854ecdb2b ci: Update base Fedora image to f32 2020-10-17 15:40:10 +01:00
Emmanuele Bassi e9eb385f25 Merge branch 'patch-1' into 'master'
Add some missing nullable return annotations

See merge request GNOME/gtk!2707
2020-10-17 14:08:29 +00:00
Sophie Herold cd0bef9390 Add some missing nullable return annotations 2020-10-17 15:32:36 +02:00
Matthias Clasen 5a79cc4d70 Merge branch 'wip/chergert/fix-macos-fps-calculation' into 'master'
macos: fix fps calculation for frame timings

See merge request GNOME/gtk!2705
2020-10-17 12:20:04 +00:00
Piotr Drąg 954855783a Update POTFILES.in 2020-10-17 11:11:24 +02:00
Christian Hergert 7ae8ed82c9 macos: fix fps calculation for frame timings
We need to mark the timings as complete after adding the
presentation time so that we have a valid FPS for the overlay
widget and/or fishbowl demo.
2020-10-15 21:04:51 -07:00
Matthias Clasen 1021e12121 3.99.3 2020-10-15 23:03:03 -04:00
Matthias Clasen 5833e8afa6 Merge branch 'win32.modal' into 'master'
GDK/Win32: Fix modal window handling and window stacking (for GTK4)

See merge request GNOME/gtk!2675
2020-10-16 03:01:38 +00:00
Matthias Clasen 34625142f4 docs: Expand opacity docs
Explain the situation with popovers and opacity.

Fixes: #3246
2020-10-15 22:39:01 -04:00
Matthias Clasen 6cbf1d0379 Merge branch 'a11y-action-fixes' into 'master'
A11y action fixes

See merge request GNOME/gtk!2703
2020-10-16 02:19:08 +00:00
Chun-wei Fan 2cc650ced2 gdk/Win32: Fix mouse pointer capture
Call SetCapture() explcitly for the (new) modal window so that we make the
modal window respond to mouse input, and also call SetCapture() to the parent
of the transient window that we are destroying so that mouse input capture is
returned to the parent window.

This attempts to fix the following:

*  Upon creating a new modal window, the new modal window does not receive
   pointer input unless one switches to another program and back

*  Upon closing a transient window, the parent window that activated the
   transient window does not receive pointer input unless one switches to
   another and back
2020-10-16 10:03:50 +08:00
Matthias Clasen 7165deb630 Merge branch 'fix-listbox-selection' into 'master'
Revert "listbox: Activate single-click rows if n_press >= 1"

Closes #3263

See merge request GNOME/gtk!2704
2020-10-16 02:03:16 +00:00
Руслан Ижбулатов 6a0c181886 GDK W32: Remove stacking functions
Stacking functions enforce non-native stacking behaviour that is
mostly unneeded, and doing so introduces bugs and complicates things.
2020-10-16 10:02:57 +08:00
Руслан Ижбулатов 89286af620 Revert "GDK W32: Use SWP_NOOWNERZORDER everywhere it can be applied"
This reverts commit fc2008f2.

Turns out, we *don't* have code to maintain Z-order. Restacking
code is not doint that, it just enforces a few weird Z-order-related
behaviours.
2020-10-16 10:01:46 +08:00
Chun-wei Fan bc142b9c43 GDK/Win32: Fix modal window handling
Make sure that we get the state of the modal window properly, and send out the
corresponding notification signals.

This will ensure that we do not try to activate windows that should have become
inactivated due to it opening modal windows and render the program unresponsive
because we are not activating the correct window that is due to receive user
input.
2020-10-16 09:56:42 +08:00
Matthias Clasen 8eb6e876bd Revert "listbox: Activate single-click rows if n_press >= 1"
This reverts commit e669433cde.

This broke selection in several listbox examples.

Fixes: #3263
2020-10-15 21:46:58 -04:00
Matthias Clasen ab61b7b9ae atspi: Properly filter out parent actions
We only want to show relevant, local actions for
widgets, but _gtk_widget_get_action_muxer() will
return the muxer of a parent widget (all the way
up to the toplevel), if the widget does not have
any actions of its own. To detect this situation,
compare what _gtk_widget_get_action_muxer() returns
for the parent widget, and act accordingly.
2020-10-15 21:32:11 -04:00
Matthias Clasen 3eae91255d atspi: Fix a thinko in action filtering
get_action_at_index() was trying hard to find out
which actions are valid, only to then return the
invalid ones anyway.
2020-10-15 21:31:58 -04:00
Matthias Clasen 5bbacc647c Merge branch 'a11y/atspi-action' into 'master'
A11y/atspi action

See merge request GNOME/gtk!2699
2020-10-16 00:13:23 +00:00
Emmanuele Bassi cfb327974b a11y: Add atspi.Action for GtkPasswordEntry 2020-10-16 00:34:01 +01:00
Emmanuele Bassi a83d3078c2 Allow toggling the password entry visibility programmatically
We are going to need a method for toggling the visibility from the
accessibility layer.
2020-10-16 00:34:01 +01:00
Emmanuele Bassi f67345eb55 a11y: Add atspi.Action for GtkEntry
We need to handle the activation on the entry widget, as well as the
activation of the primary and secondary icons.
2020-10-16 00:34:01 +01:00
Emmanuele Bassi c10bcf0a60 Add GtkEntry icon signals emitter
We need a (private) way to programmatically trigger the activation of
the entry's icons, so that we can call it from the accessibility layer.
2020-10-16 00:34:01 +01:00
Emmanuele Bassi 9ae08fc0f0 a11y: Add atspi.Action for GtkExpander 2020-10-16 00:34:01 +01:00
Emmanuele Bassi 5f1128899c a11y: De-duplicate some action code
The widgets with hard coded actions should share more code, instead of
copy-pasting it.
2020-10-16 00:34:01 +01:00
Emmanuele Bassi e44f27a7ed a11y: Special case buttons and switches
These widgets have specific actions.
2020-10-16 00:34:01 +01:00
Emmanuele Bassi 374bd21340 Initial ATSPI Action implementation for widget
Use the actions from the GtkActionMuxer of each widget to populate the
list of actions available.
2020-10-16 00:34:01 +01:00
Matthias Clasen 916ef485d1 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3245

See merge request GNOME/gtk!2702
2020-10-15 21:00:44 +00:00
Matthias Clasen 92585b75fa Fix compiler warnings 2020-10-15 16:33:35 -04:00
Matthias Clasen 4bd2595421 actionmuxer: Make it possible to enumerate local actions
This will be useful for exposing actions via the
AT-SPI Actions interface.

Update all callers.
2020-10-15 16:32:55 -04:00
Matthias Clasen aa4c0bf272 spinbutton: Hide the buttons from accessibility
The buttons here are not really buttons (the action
is not tied to the "clicked" signal), so triggering
the buttons via a11y does not have the expected effect.

And we expose the Value interface that ATs can use
to set the value.
2020-10-15 16:32:55 -04:00
Matthias Clasen 4e04c39609 emojicompletion: Avoid a memory overrun
Don't read beyond the beginning of the string.

Fixes: #3245
2020-10-15 16:32:55 -04:00
Matthias Clasen 0bd5a96d71 gtk-demo: Fix some issues with the multi view demo
The nested window was not modal, causing it to be
inoperable. And the nested views within were all
shrunk down to nothingness. Give them some width.

Fixes: #3257
2020-10-15 14:42:43 -04:00
Matthias Clasen 7d22616a0e Merge branch 'a11y-list-view-selection-fixes' into 'master'
atspi: Add fold markers

See merge request GNOME/gtk!2701
2020-10-15 17:36:47 +00:00
Matthias Clasen 8a14f019d0 atspi: Add fold markers
This makes it much easier to navigate in these
multi-implementation files.
2020-10-15 13:14:56 -04:00
Matthias Clasen 329efee643 Merge branch 'a11y-list-view-selection-fixes' into 'master'
A11y list view selection fixes

See merge request GNOME/gtk!2700
2020-10-15 17:10:00 +00:00
Matthias Clasen bf58b6f88c Merge branch 'ebassi/for-master' into 'master'
GdkWayland API cleanups

Closes #3249

See merge request GNOME/gtk!2688
2020-10-15 16:55:19 +00:00
Matthias Clasen 8701e65635 atspi: Implement Selection more correctly
The Selection interface is defined in terms of child
positions, so we need to always translate from that
to model positions if we want to use the selection
model apis.
2020-10-15 12:46:52 -04:00
Matthias Clasen 5f22ad8848 Remove debug spew 2020-10-15 12:19:58 -04:00
Matthias Clasen 1d40f29776 wayland: Make gdk_wayland_device_pad_set_feedback private
It is not a generally useful api, and awkwardly named.
2020-10-15 12:00:00 -04:00
Matthias Clasen 6d1dcaa92a docs: Explain the symbolic icon paintable situation
Add a paragraph to the migration guide that explains
how to properly render symbolic GtkIconPaintables.

Also mention this in the GtkIconPaintable docs.

There's a reason you can't spell 'paintable' without
'pain'...
2020-10-15 11:42:50 -04:00
Matthias Clasen 9c28ecb0da Merge branch 'a11y/atspi' into 'master'
A11y/atspi

See merge request GNOME/gtk!2698
2020-10-15 14:59:24 +00:00
Matthias Clasen 2488d71a0a Merge branch 'clipboard-emo' into 'master'
gtk-demo: Fix up image handling in the clipboard demo

Closes #3252

See merge request GNOME/gtk!2697
2020-10-15 14:50:54 +00:00
Matthias Clasen 5c8663e383 Merge branch 'wip/wayland-dont-respond-to-destroyed-surface-configure' into 'master'
wayland/surface: Clear has_uncommitted_ack_configure when hiding

Closes #3262

See merge request GNOME/gtk!2696
2020-10-15 14:25:55 +00:00
Matthias Clasen 4b36bceb26 Merge branch 'meson-epoxy-subproject' into 'master'
meson: Fix error when epoxy is a subproject on Windows

See merge request GNOME/gtk!2695
2020-10-15 13:41:47 +00:00
Matthias Clasen 8cf955731f gtk-demo: Fix up image handling in the clipboard demo
Using GtkIconPaintable+GtkPicture is not good for symbolic
icons - they don't get properly colored that way. So change
things around to use the icon name if we have it.

Fixes: #3252
2020-10-15 09:19:17 -04:00
Jonas Ådahl 7dfb25f124 wayland/surface: Clear has_uncommitted_ack_configure when hiding
The 'has_uncommitted_ack_configure' state was added to make sure we're
responding to 'xdg_surface.configure' events with
'xdg_surface.ack_configure' requests, as is necessary according to spec.
What we didn't do was to clear this state when hiding, meaning that if
we hid the surface after a configure event, but before the frame
finished and we processed the 'has_uncommitted_ack_configure', we'd try
to acknowledge the surface configuration after having destroyed the
surface.

Closes: #3262
2020-10-15 14:56:06 +02:00
Matthias Clasen 8737692b2b atspi: Implement Selection for list views
This implementation works for both GtkListView and
GtkGridView, and by extension, also for GtkColumnView
and GtkDropDown, since those just use a list view
internally.
2020-10-15 08:35:06 -04:00
Xavier Claessens fe89fd2317 meson: Fix error when epoxy is a subproject on Windows
epoxy_dep cannot be used in a configure time check when it comes from a
subproject. Use variables set in pc file instead.

This requires https://github.com/anholt/libepoxy/pull/231.
2020-10-15 08:01:16 -04:00
Matthias Clasen c7bf33a3de columnview: Set accessible roles
Use the TREE_GRID, ROW, COLUMN_HEADER and GRID_CELL roles
for the various widgets involved in a GtkColumnView. To
enable this, we subclass GtkListView for the internal
list in the column view.
2020-10-15 00:16:25 -04:00
Matthias Clasen 6d562b6176 listview: Set accessible roles
Use the LIST and LIST_ITEM roles for GtkListView
and its children. Use the GRID and GRID_CELL roles
for GtkGridView and its children.
2020-10-14 23:34:51 -04:00
Matthias Clasen 1bf21d3dba Document accessible roles for stacks and notebooks
This was forgotten when I implemented the Tabs pattern.
2020-10-14 22:27:09 -04:00
Matthias Clasen 14640cec85 flowbox: Set accessible roles
Use the GRID and GRID_CELL roles for GtkFlowBox
and GtkFlowBoxChild.
2020-10-14 22:20:43 -04:00
Matthias Clasen 147868a30c listbox: Set accessible roles
Use the LIST and LIST_ITEM roles for GtkListBox
and GtkListBoxRow.
2020-10-14 22:18:21 -04:00
Matthias Clasen 57ebc351a9 Merge branch 'wip/chergert/fix-macos-popup-events' into 'master'
macos: fix popup motion and button event delivery

See merge request GNOME/gtk!2694
2020-10-15 01:41:42 +00:00
Matthias Clasen 375bd5e691 Merge branch 'wip/chergert/gdk-macos-fixes' into 'master'
macos: fix crash when displaying a context menu

See merge request GNOME/gtk!2693
2020-10-15 01:41:06 +00:00
Matthias Clasen f4f732694a atspi: Add some docs
Add a comment that explains a few of the more subtle
points of the Atspi context tree contstruction.
2020-10-14 21:04:25 -04:00
Matthias Clasen bf04beb711 atspi: Implement Selection for notebook tabs
This is a bit different from the way things were done
in GTK 3 - we follow what was done for GtkStackSwitcher,
and make the tab bar carry the GTK_ACCESSIBLE_TAB_LIST
role, and implement Selection there.
2020-10-14 21:04:25 -04:00
Matthias Clasen 08b586bb57 notebook: Set accessible roles and properties
Set up the necessary roles, relations and properties
for the tab patterns. This parallels what we have done
for GtkStackSwitcher, and implements the Tabs pattern
as described in the ARIA authoring guidelines.
2020-10-14 21:04:25 -04:00
Matthias Clasen 41d4c37563 atspi: Don't crash on unnamed stack pages
GtkNotebook creates unnamed stack pages, and we should
not crash when that happens.
2020-10-14 21:04:25 -04:00
Matthias Clasen 984e8ac5e3 gizmo: Add a way to set accessible role
This will be used for some of the gizmo used
inside GtkNotebook.
2020-10-14 21:04:25 -04:00
Matthias Clasen 512387afcc atspi: Implement Selection for GtkStackSwitcher 2020-10-14 21:04:25 -04:00
Matthias Clasen b39684b692 stackswitcher: Set up relations and states
Set up a CONTROLS relation between each tab button
and its page, and update the SELECTED property of
the buttons to match their active state.
2020-10-14 21:04:25 -04:00
Matthias Clasen 380488f829 stackswitcher: Use the tablist and tab roles
Set the tablist role on the stackswitcher itself, and
the tab role on the buttons. This is another step towards
implementing the tabs pattern for GtkStack.
2020-10-14 21:04:25 -04:00
Matthias Clasen 2370429752 accessible: Avoid realizing the context prematurely
platform change is called from gtk_widget_set_focusable
which is likely to be called early on in init(). We don't
want to create an AT context that early if we can help
it, e.g. since it makes it impossible to override the
accessible-role with a construct property.
2020-10-14 21:04:25 -04:00
Matthias Clasen 7c6c718e19 stack: Turn pages into accessibles
This requires some cleanup to remove assumptions
about accessibles being widgets in the backend,
and some code to navigate the tree with these
extra objects in between widgets.

The accessibles for stack pages have the role
GTK_ACCESSIBLE_ROLE_TAB_PANEL. This is the first
step towards implementing the tabs patterns
as described in the aria authoring guidelines
for GtkStack.
2020-10-14 21:04:17 -04:00
Christian Hergert 6e84c7c59e macos: fix discover of surface under cursor
This was incorrectly reporting the toplevel surface instead of the
popup surface that was placed above it. This fixes event delivery
to popups for selecting menu items and more.
2020-10-14 16:59:38 -07:00
Christian Hergert 0af3d21573 macos: only emit popup-layout-changed after initial present
Otherwise we risk being re-entrant where GtkPopover will not have a
GdkPopupLayout causing other issues.
2020-10-14 16:28:44 -07:00
Christian Hergert e089bba4f5 macos: ensure we have access to a GdkMonitor 2020-10-14 16:28:44 -07:00
Matthias Clasen 2dfced7edc Merge branch 'wip/chergert/gdk-macos-fixes' into 'master'
macos: fix button release events outside of window during grabs

See merge request GNOME/gtk!2692
2020-10-14 23:04:03 +00:00
Christian Hergert b462bc35c0 macos: allow pointer release event outside surface coords
This helps with grab situations so that we can end it when releasing
the pointer buttons outside of the window coordinates.
2020-10-14 15:45:50 -07:00
Christian Hergert d700cfa2ef macos: break grabs after sending release event 2020-10-14 15:45:50 -07:00
Christian Hergert cdb2c1698c macos: dont send crossing events during grab
Fixes an issue where we can't drag scrollbars or text selections while
outside of the application window.
2020-10-14 15:45:50 -07:00
Matthias Clasen 85394b04e0 Merge branch 'wip/chergert/gdk-macos-fixes' into 'master'
GTK4: fix macos device state query for surfaces

See merge request GNOME/gtk!2690
2020-10-14 19:10:11 +00:00
Matthias Clasen a772d8fcac Merge branch 'wip/baedert/for-master'
Leaving out the gboolean -> bool change.
2020-10-14 15:07:09 -04:00
Timm Bäder f93784f9e7 pixbufutils: Pass calculated height value along 2020-10-14 15:06:13 -04:00
Timm Bäder d695b15f1a main: Make sure we don't leak axes
Mainly a change to appease the static analyzer
2020-10-14 15:06:13 -04:00
Timm Bäder e1e53cd8cc infobar: Remove unused include 2020-10-14 15:06:12 -04:00
Timm Bäder 211d669ae7 overlay: Remove empty finalize implementation 2020-10-14 15:06:12 -04:00
Timm Bäder 20bd8e56ee gtk4-demo: Add missing margin-bottom
This was setting margin-end twice
2020-10-14 15:06:12 -04:00
Timm Bäder df2d7c56c7 gtk4-demo: Remove connection to removed signal 2020-10-14 15:06:12 -04:00
Timm Bäder 8f24b7ad27 stacksidebar: Fold some functions into their only callers 2020-10-14 15:06:12 -04:00
Timm Bäder 61afb0984c stacksidebar: Set GtkListBox:show-separators
Instead of doing this ourselves
2020-10-14 15:06:12 -04:00
Timm Bäder 93b12a8110 frame: Remove need_resize logic
gtk_widget_set_parent() will queue a resize anyway.
2020-10-14 15:06:12 -04:00
Timm Bäder d9cc589339 windowcontrols: gtk_widget_get_root() can return NULL 2020-10-14 15:06:12 -04:00
Timm Bäder 557a363b4f windowcontrols: decoration-layout is nullable 2020-10-14 15:06:12 -04:00
Timm Bäder ae009b344f stylecontext: Remove some unnused includes 2020-10-14 15:06:12 -04:00
Timm Bäder 78c343ba96 snapshot: Refactor some device code
Make a bit clearer what this does.
2020-10-14 15:06:12 -04:00
Timm Bäder eca3eab96f Remove unneeded gtkstylecontext.h includes 2020-10-14 15:06:12 -04:00
Timm Bäder 2bcef7f030 stylecontext: Remove render_insertion_cursor()
This is unused and there already is a snapshot alternative.
2020-10-14 15:06:12 -04:00
Timm Bäder 18c4bdad6f widget: Remove gtk_widget_list_devices() from private header 2020-10-14 15:06:12 -04:00
Timm Bäder f20795471c window: Remove unused struct member 2020-10-14 15:06:12 -04:00
Timm Bäder ec8f329332 widget: Slightly update opacity docs 2020-10-14 15:06:12 -04:00
Timm Bäder 07fb33c033 gl renderer: Fix private function name
It's a GskGLRenderer, not a GskGLRender
2020-10-14 15:06:12 -04:00
Timm Bäder 1fe7043be4 gl renderer: Add more scale_x/scale_y code
We really need all of this to be aware of both dimensions of course...
2020-10-14 15:06:12 -04:00
Timm Bäder 0e6014f2f6 gl renderer: Remove two unused uniforms 2020-10-14 15:06:12 -04:00
Timm Bäder 0a4d442849 gl renderer: return empty texture for too small blurred nodes 2020-10-14 15:06:12 -04:00
Timm Bäder 5f9fa13c65 gl renderer: Use op builder to render flipped texture
Otherwise, we don't know about the uniform state
2020-10-14 15:06:12 -04:00
Timm Bäder da0abfce3a showrendernode: Plug GOptionContext memory leak 2020-10-14 15:06:12 -04:00
Timm Bäder 161b171004 gl renderer: Remove unused parameter 2020-10-14 15:06:12 -04:00
Timm Bäder 4eee6e732b filechooserwidget: Cosmetics 2020-10-14 15:06:12 -04:00
Timm Bäder 958e4be86d testfilechooser: Stop listening to ::selection-changed
Doesn't exist anymore.
2020-10-14 15:06:12 -04:00
Timm Bäder eb345cd033 gl renderer: Use nearest filtering for textures in render_texture()
Makes the output in the node editor a bit more bearable.
2020-10-14 15:06:12 -04:00
Timm Bäder ef7c5747c4 build: Only add -Wcast-align for gcc
Either we or clang needs to get its shit together about this warning.
But using it during development with clang just makes actually usable
warnings get lost in a flood of -Wcast-align warnings.
2020-10-14 15:06:12 -04:00
Timm Bäder f456438051 vulkan: Remove double initialization
Clang said:

../gsk/vulkan/gskvulkanrenderpass.c:250:5: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
    .render.node = node
    ^~~~~~~~~~~~~~~~~~~
../gsk/vulkan/gskvulkanrenderpass.c:249:13: note: previous initialization is here
    .type = GSK_VULKAN_OP_FALLBACK,
            ^~~~~~~~~~~~~~~~~~~~~~
2020-10-14 15:06:12 -04:00
Timm Bäder 4735c27e69 gl renderer: Avoid some code duplication 2020-10-14 15:06:12 -04:00
Timm Bäder 44f10c5861 gl renderer: Flip texture in render_texture() 2020-10-14 15:06:12 -04:00
Timm Bäder 44d1e81ae9 glsl: Add a comment 2020-10-14 15:06:12 -04:00
Timm Bäder c5909d4dc4 gtkbuilder: Remove pointless function prototype 2020-10-14 15:06:12 -04:00
Timm Bäder 9698cd67a1 gdkgl: Remove flipping when downloading GL texture
This fix is correct and fixes:

  1) GL textures being upside down in the inspector. They are getting
     downloaded because they've been created in a different GL context
  2) GL textures being upside down in the cairo renderer (same reason)

However, it breaks the testsuite. We do the flipping via the projection
matrix, but most of the shaders don't care about that.
2020-10-14 15:06:12 -04:00
Timm Bäder d4efb5b738 gdkgl: Stop getting the clip region from cairo
Unused
2020-10-14 15:06:12 -04:00
Timm Bäder ddcff9eb0f gl renderer: simplify ->render() implementation a bit
We already use self->scale_factor when initialized whole_surface,
so set self->scale_factor first.
2020-10-14 15:06:12 -04:00
Timm Bäder 9fe21b7181 shaderbuilder: Print error message after source code
My terminal scrolls down, so showing the error message last makes sense.
2020-10-14 15:06:12 -04:00
Timm Bäder 7bf858b9d0 gl renderer: Add a helper to setup projection matrix 2020-10-14 15:06:12 -04:00
Timm Bäder bc034d1190 gl renderer: Ignore rendering if accumulated opacity is too small 2020-10-14 15:06:12 -04:00
Timm Bäder 904772c719 gdkgl: Rename function
This returns the name of the shader type.
2020-10-14 15:06:12 -04:00
Timm Bäder 7222a0901d unblurred outset shadow shader: Use premultiply() 2020-10-14 15:06:12 -04:00
Timm Bäder a0bb248bb3 gl renderer: Use premultiply() in inset shadow shader` 2020-10-14 15:06:12 -04:00
Timm Bäder 0dc0b03d6f glarea demo: Add min size to gl area 2020-10-14 15:06:12 -04:00
Timm Bäder 9f574a596f gdkgl: Remove unused cairo_get_matrix() call 2020-10-14 15:06:12 -04:00
Timm Bäder 4b8f3e9b92 colorscale: Refactor creating the hue texture
Make this a bit shorter and don't call gtk_hsv_to_rgb in the inner
loop as that is unnecessary.
2020-10-14 15:06:12 -04:00
Timm Bäder 769b15c29b colorplane: Remove (un)realize handlers
Creating the texture in realize() is unnecessary these days, since we
can just rely on size_allocate to do that.
2020-10-14 15:06:12 -04:00
Timm Bäder 8e9a810045 colorutils: Refactor hsv_to_rgb and fold into only caller 2020-10-14 15:06:12 -04:00
Timm Bäder 663ae67935 colorplane: Refactor create_texture()
Create a R8G8B8 texture here so we don't waste memory and do work for
an alpha channel we don't care about.
2020-10-14 15:06:12 -04:00
Timm Bäder 76e4002226 colorutils: Remove unused macro 2020-10-14 15:06:12 -04:00
Timm Bäder ae71fe3739 colorplane: Whitespace 2020-10-14 15:06:12 -04:00
Emmanuele Bassi 66ce0cbec0 Generate introspection for GdkWayland API
Like we do for GdkX11. We can't use all of the public C API, but we can
expose enough type information to allow non-C developers to actually
check if they are running the Wayland GDK backend or not—plus some
additional Wayland-specific API.
2020-10-14 15:06:12 -04:00
Emmanuele Bassi fe871f9d46 Add type annotations for GdkWayland API
The GdkWayland API takes generic GDK types and performs a run time
check, which means we need to properly annotate the actual expected
type in order to have methods recognised as such.
2020-10-14 15:06:12 -04:00
Emmanuele Bassi 40e4f3758e Skip GdkWayland symbols that use wayland-client types
The wayland-client API does not have introspection annotations, so we
can't use these types anyway.
2020-10-14 15:06:12 -04:00
Aurimas Černius 2fb1f4a747 Updated Lithuanian translation 2020-10-14 15:06:12 -04:00
Christian Hergert fb02c99868 macos: port gtk to GDK_WINDOWING_MACOS
For the various uses of GDK_WINDOWING_QUARTZ, we need to use
alternatives from GDK_WINDOWING_MACOS.

Some minor loss of functionality is here, such as icons sent with
application menus. That can certainly be added back at a future
point.
2020-10-14 15:06:12 -04:00
Christian Hergert 036b56a43b gtk: use GDK_WINDOWING_MACOS in gentypefuncs.py 2020-10-14 15:06:12 -04:00
Christian Hergert 9279c2cbd1 gdk: remove quartz subdirectory from backends 2020-10-14 15:06:12 -04:00
Christian Hergert aed279ed4e macos: add key equivalent helper
This is needed by quartz code in gtk/.
2020-10-14 15:06:12 -04:00
Christian Hergert cc2e69cbd8 macos: remove workaround for scroll delta
This gets handled differently in gtk/ and so we shouldn't translate it here.
2020-10-14 15:06:12 -04:00
Christian Hergert ff279d03b2 macos: track various changes in GDK 2020-10-14 15:06:12 -04:00
Christian Hergert 1519b40ffa macos: lookup NSEvent by translated GdkEvent
This will be needed by the quartz imcontext.
2020-10-14 15:06:12 -04:00
Christian Hergert 28d2e608f9 macos: move input method names to private header 2020-10-14 15:06:12 -04:00
Piotr Drąg c753f8f30b Update Polish translation 2020-10-14 15:05:46 -04:00
Marek Černocký 58769467cf Updated Czech translation 2020-10-14 15:05:46 -04:00
Matthias Clasen 8a361f901d gtk-demo: Keep undisplayable resources out of view
No point in showing an apologetic tab for a blob of binary data.
gtk4-demo shows the resources under /DEMONAME/ for each demo,
so move the data to /DEMONAME_data/.
2020-10-14 15:05:46 -04:00
Matthias Clasen 9b26660095 Send focus events to the root
We are not propagating focus change events, and that is the only
place where we are listening for focus change events. If GtkWindow
does not see focus-in events for its popovers, we end up with
inadvertendly inactive windows.

Fixes: #3240
2020-10-14 15:05:46 -04:00
Matthias Clasen 8dce92e82b window: Be more careful when looking for focus
When passing focus up to a parent, make sure the
newly chosen focus widget actually accepts the focus.
2020-10-14 15:05:46 -04:00
Matthias Clasen 2d927d0ee0 build: Require sysprof 3.38.0
We use sysprof_collector_request_counters, which
was introduced in sysprof 3.38.0.
2020-10-14 15:05:46 -04:00
Matthias Clasen 2273e27808 gtk-demo: Ellipsize columns in the characters demo
some of the columns have uneven widths, causing them
to bounce around as you scroll. Ellipsize them and
give them a fixed with.
2020-10-14 15:05:46 -04:00
Matthias Clasen 2bdc8c7d9e docs: Add more details to the migration guide
Add some details about GdkSurface and GtkWindow api changes.

Fixes: #3242
2020-10-14 15:05:45 -04:00
Christian Hergert 9f01d4fe44 macos: fix coordinates and state when querying device
When querying a device, we need to ensure we are providing coordinates
in the coordinate system of the surface. Further, we need to actually
provide the button and keyboard state.

This fixes some issues related to dragging scrollbars and selecting list
box rows more reliably.
2020-10-14 11:34:44 -07:00
Christian Hergert d5b5410b8f macos: use simple monotonic for event serial 2020-10-14 11:34:44 -07:00
Christian Hergert d6abc125ad macos: fix compiler warnings 2020-10-14 11:34:44 -07:00
Matthias Clasen 2142c6c086 docs: Fix a copy-paste error 2020-10-14 08:23:06 -04:00
Emmanuele Bassi 9377192102 Correctly annotate gdk_wayland_seat_get_wl_seat()
We expect a `GdkWaylandSeat` as the instance parameter.
2020-10-14 11:57:06 +01:00
Emmanuele Bassi da007ac97b Add a public header for GdkWaylandSeat
We have public API requiring it as a type.
2020-10-14 11:55:34 +01:00
Jakub Steiner 974ce500d6 Merge branch 'wip/jimmac/sidebar-hover-selected-focus' into 'master'
Adwaita: selected:hover and focus:selected:hover states

Closes #3251

See merge request GNOME/gtk!2686
2020-10-14 07:36:06 +00:00
Matthias Clasen b818b34143 Cosmetics
Fix a few copy-paste errors.
2020-10-13 21:27:56 -04:00
Matthias Clasen 32d8db103a Cosmetics
Avoid typo-prone repetition of the full interface names.
We have them in the introspection data already.
2020-10-13 18:58:25 -04:00
Matthias Clasen 9955d900db dropdown: Use the combox accessible role
Its really just a combobox with another name.
2020-10-13 18:31:53 -04:00
Matthias Clasen e3620bdc22 combobox: Use the combobox accessible role
Makes sense.
2020-10-13 17:53:39 -04:00
Matthias Clasen b15328e0d6 atspi: Implement Selection for GtkFlowBox
This is a copy of the listbox implementation.
2020-10-13 17:24:06 -04:00
Matthias Clasen 2664c29454 flowbox: Update accessible state for children
Set the SELECTED state to reflect whether the selected
is selected, unselected, or unselectable. This is
enough to make selection changes appear in Accerciser.

While we are at it, also set the multi-selectable
property for the flowbox itself.
2020-10-13 17:24:06 -04:00
Matthias Clasen db97f99359 atspi: Implement Selection for GtkComboBox
This doesn't really work in Accerciser. But then,
neither does the GTK 3 implementation from which
this is copied.
2020-10-13 17:24:06 -04:00
Matthias Clasen caeea0e368 Remove excessively spammy debug messages
Non need to announce the same things for every context
we create, and the path is not really that interesting.
without knowing what it belongs to. I would suggest to
make it visible in the inspector instead, so you can
look it up for the widgets you are interested in.
2020-10-13 17:24:06 -04:00
Matthias Clasen d0753f645e Fix compiler warnings 2020-10-13 17:24:06 -04:00
Matthias Clasen 81e107885c Remove some unused code 2020-10-13 17:24:06 -04:00
Matthias Clasen 8f4bc4a65d atspi: Fix a variant parser oversight
When you pass a variant, the format needs an @.
GVariant is not your friend.
2020-10-13 17:24:06 -04:00
Matthias Clasen 08f57d5c3d atspi: Implement Selection for listbox
Implement the selection interface for GtkListBox.

This also includes a convenience api for context
addresses: gtk_at_spi_context_to_ref.
2020-10-13 17:24:06 -04:00
Matthias Clasen 3cc9ac406d listbox: Update accessible state for rows
Set the SELECTED state to reflect whether the row
is selected, unselected, or unselectable. This is
enough to make selection changes appear in Accerciser.

While we are at it, also set the multi-selectable
property for the listbox itself.
2020-10-13 17:24:06 -04:00
Jakub Steiner f1e9f853de Adwaita: selected:hover and focus:selected:hover states
- getting pretty deep, but visually seems to make sense. Selected row hovers
  increase contrast.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3251
2020-10-13 21:27:17 +02:00
Matthias Clasen 18b6c4e69d Merge branch 'wip/carlosg/for-master' into 'master'
Cascade-close popovers by default

Closes #3200

See merge request GNOME/gtk!2685
2020-10-13 19:25:59 +00:00
Matthias Clasen ccbacb5cce Fix the build
I forgot a few casts in a02c50e72f.
2020-10-13 11:23:13 -04:00
Carlos Garnacho a939203e6e gtkmodelbutton: Drop special case to close GtkPopoverMenu
With ::cascade-popdown in place, this special case is not necessary
anymore.
2020-10-13 16:55:53 +02:00
Carlos Garnacho 3ba60b06fe gtkpopover: Remove GtkPopoverMenu special case
Now that there's ::cascade-popdown, we don't need to treat
GtkPopoverMenu especially here.
2020-10-13 16:55:53 +02:00
Carlos Garnacho 024d832d94 gtkpopover: Add cascade-popdown property/functions
And honor it in gtk_popover_popdown(). By default, a GtkPopover
pops down automatically if a child popover was closed, if this
property is FALSE, the popover will remain opened.
2020-10-13 16:55:53 +02:00
Matthias Clasen b909455154 atspi: Fix up the role for password entries
We use to set the the 'password text' role for entries with
visibility = FALSE. Nowadays, we have a separate class for
password entries, so fix up the role mapping based on that.
2020-10-13 10:52:43 -04:00
Matthias Clasen bf0f3a82cf atspi: Make text change notification work
Make text change notification work for editables, by connecting
to the ::insert-text and ::delete-text signals on the wrapped
GtkText widget, and for GtkTextView by connecting to the
corresponding GtkTextBuffer signals.

This code is more or less directly copied from GtkTextViewAccessible
and GtkEntryAccessible in GTK 3.
2020-10-13 09:44:04 -04:00
Matthias Clasen a02c50e72f text: Make editable signals work again
Since the big editable reorg, GtkText was not emitting
::insert-text and ::delete-text, as is expected of
editables. We want to use those signals for a11y
change notification, so make them work again.
2020-10-13 00:49:10 -04:00
Matthias Clasen 81440675af atspi: Set placeholder-text attribute
This is how GTK3 passes placeholder-text to orca,
and it works - orca reads it.
2020-10-12 23:31:03 -04:00
Matthias Clasen 3af56f5216 atspi: Implement EditableText interface for the entry wrappers
Drop the EditableText implementation for GtkText,
and implement it for all the wrapper widgets instead.
2020-10-12 22:07:18 -04:00
Matthias Clasen 63dd0405c7 accessible: Add some docs
Explain briefly how a11y works for entry wrappers
(since I won't remember a few months from now).
2020-10-12 21:58:49 -04:00
Matthias Clasen b7ac660f37 atspi: Implement Text interface for the entry wrappers
Drop the Text implementation for GtkText, and implement
it for all the wrapper widgets instead.
2020-10-12 21:45:48 -04:00
Matthias Clasen 76b87272a6 spinbutton: Implement GtkAccessible
This copies what was done for GtkEntry: get
the focused state from the GtkText within.

We also add a private getter for the text widget,
which was missing here.
2020-10-12 21:45:48 -04:00
Matthias Clasen 852c72fa28 passwordentry: Implement GtkAccessible
This copies what was done for GtkEntry: get
the focused state from the GtkText within.
2020-10-12 21:45:48 -04:00
Matthias Clasen f796d02fea searchentry: Implement GtkAccessible
This copies what was done for GtkEntry: get
the focused state from the GtkText within.
2020-10-12 21:45:48 -04:00
Matthias Clasen 8faf1f64ee entry: Implement GtkAccessible
Override the get_platform_state vfunc to get
the focused state from the GtkText widget within.
2020-10-12 21:45:48 -04:00
Matthias Clasen 8182fab4d9 text: Ignore text widgets for a11y
We want to implement the Text interface on the
wrapper entries.
2020-10-12 21:45:48 -04:00
Matthias Clasen d0d7848cf2 atspi: Use gtk_accessible_get_platform_state 2020-10-12 21:45:48 -04:00
Matthias Clasen ade9e4b82a accessible: Add gtk_accessible_get_platform_state
As a companion to go with the platform_change api,
add a gtk_accessible_get_platform_state() function
that can be used by backends to get the platform
state.

This is in preparation for making entries inherit
their focus states from the text widget within.
2020-10-12 21:45:41 -04:00
Matthias Clasen 663934b2dc atspi: Use gtk_accessible_should_present
Replace explicit visibility check by this
more general method of determining whether
an accessible should be presented to the
a11y layer.
2020-10-12 21:43:17 -04:00
Matthias Clasen d9adc1b5aa accessible: Add a way to hide accessibles
Similar to gtk_widget_should_layout(), add a
gtk_accessible_should_present() function that backends can
use to determine whether an accessible should be presented
or not.

Ways to make a widget not presented in a11y:
- hide the widget
- set its role to NONE
- make it have a NULL AT context

We will use this in future to hide the GtkText inside
an entry, since the Text implementation will be done
by the wrapper.
2020-10-12 21:43:17 -04:00
Matthias Clasen 3bfb32e699 Cosmetics 2020-10-12 21:43:17 -04:00
Matthias Clasen 5eb482ebaa atspi: Treat all entries the same for collecting state
We are determining editable state based on the
accessible role (although we could make it platform
state now), so cover all the roles that we use for
entry wrappers.
2020-10-12 21:43:17 -04:00
Matthias Clasen 61474b5a94 atspi: Fix collecting states
This is somewhat embarrassing.
2020-10-12 21:42:51 -04:00
Matthias Clasen 8f63443393 Fix the build 2020-10-12 21:37:09 -04:00
Matthias Clasen dd650ff90e atspi: D-Bus methods return tuples
I've learned this the hard way: When returning a
value from a D-Bus call, the variant construct must
*always* be g_variant_new ("(...)"...
2020-10-12 15:50:36 -04:00
Matthias Clasen 101cbe690e Don't unref a floating variant
It gets consumed somewhere along the way.
2020-10-12 15:10:40 -04:00
Matthias Clasen 62747eb243 atspi: Unregister objects on the bus
When a widget is going away, we need to remove
the context from the bus, or else ATs might have
the idea to call methods on them, leading to badness.
2020-10-12 15:10:40 -04:00
Matthias Clasen d432cbb02b atspi: Emit property changes for focus
With this orca, actually speaks \o/.  Sadly, it only
says 'gtk modelbutton widget' so far, but its a start.
2020-10-12 15:10:40 -04:00
Matthias Clasen 45e82adf87 atspi: Cosmetics
Use simple wrappers instead of opencoding bit twiddling
all over the place.
2020-10-12 15:10:40 -04:00
Matthias Clasen a2d220edfa widget: Notify a11y of focus changes
This is using the new 'platform changes' mechanism
to tell the a11y backends when focus changes.
2020-10-12 15:10:40 -04:00
Matthias Clasen b5ee73d299 a11y: Pass on platform changes
Add an enum for 'platform changes' to the at context
change notification mechanism. This will let us pass
along things that ARIA considers 'platform state' such
as focus or editability. The difference between the
platform state and other ARIA states is that we don't
keep the platform state separately in the at context
- backends are expected to just query the widgets.

This is just about avoiding notify listeners for
change notification.
2020-10-12 15:10:40 -04:00
Matthias Clasen 578c8b5068 atspi: Be more careful about indexes
Don't return a number for IndexInParent when we
don't have one.
2020-10-12 15:10:40 -04:00
Matthias Clasen f9ee23825e atspi: Set some more atspi states
Pass on more of the states that are represented
as properties in aria: modal, multi-line, orientation.
2020-10-12 15:10:40 -04:00
Matthias Clasen 35f70d5a99 Pass orientation property to accessible
We should set the accessible properties we have,
where they make sense. So set orientation, if the
widget is orientable.
2020-10-12 15:10:40 -04:00
Matthias Clasen 54f1eb4c04 wip: Emit StateChanged signals
This is not fully baked, but it is enough to make accerciser
notice when a text entry goes from editable to not editable.
2020-10-12 15:10:40 -04:00
Matthias Clasen 66a81f1187 atspi: Derive readonly state from aria properties
We can use the read-only property, together with the
accessible role, to determine whether to set editable
and read-only states for at-spi. This lets us avoid
directly poking at the widgets.
2020-10-12 15:10:40 -04:00
Matthias Clasen 2a5af4e1d6 text: Set the readonly accessible property
This mirrors what we already do for GtkTextView.
2020-10-12 15:10:40 -04:00
Matthias Clasen d37b0357b3 atspi: Set editable state
ATs look at not just the implemented interfaces, but
also the states to decide what to do. It turns out that
the EditableText interface is only used by accerciser
if the editable state is set. So set it.
2020-10-12 15:10:40 -04:00
Matthias Clasen aea25cbbe5 atspi: Implement EditableText interface
Implement EditableText for GtkText and GtkTextView.
2020-10-12 15:10:40 -04:00
Matthias Clasen a72a7d4aeb atspi: Break out the Value implementation
This isn't necessarily very big, but it keeps
the widget checks out of gtkatspicontext.c, and
it is a nice pattern.
2020-10-12 15:10:40 -04:00
Matthias Clasen d38182bb5d atspi: Break out the Text implementations
Move the implementation of the Text interface
to its own source file, and split it up along
widget lines, to avoid it becoming too messy.
2020-10-12 15:10:40 -04:00
Matthias Clasen f22edccb2a scalebutton: Set accessible value properties
This is what we did in GTK 3.
2020-10-12 15:10:40 -04:00
Matthias Clasen dc9fee6185 paned: Set accessible value properties
This is what we did in GTK 3.
2020-10-12 15:10:40 -04:00
Matthias Clasen 776b4aee0c Simplify GetInterfaces handling
It is error prone to keep the same conditions in sync
in two places. Instead, just assemble the list of interfaces
as we register objects, and use when GetInterfaces is called.
2020-10-12 15:10:40 -04:00
Matthias Clasen d37782c533 atspi: Implement Value for more widgets
Apply the Value implementation to the widgets where
we had one in GTK 3: GtkLevelBar, GtkRange, GtkScaleButton,
GtkSpinButton, GtkPaned, GtkProgressBar. To make these
work, the widgets need to set the accessible value properties.
2020-10-12 15:10:40 -04:00
Matthias Clasen 8c3e5124c2 atspi: Implement Value interface for ranges 2020-10-12 15:10:40 -04:00
Matthias Clasen 190059dca1 atspi: Implement Text interface for text views
With this, all relevant widgets support the
Text interface.
2020-10-12 15:10:40 -04:00
Matthias Clasen 925ef1f90f atspi: Add textview utilities
These are very similar to the pango utilities,
and are copying code from the textview accessible
implementation in GTK 3.
2020-10-12 15:10:40 -04:00
Matthias Clasen ba63daa1d2 atspi: Export more pango utils
We are going to reuse some of the code that does
the pango -> atspi attribute conversion for text
tags.
2020-10-12 15:10:40 -04:00
Matthias Clasen 5b076fee12 atspi: Implement text for GtkText widgets too
There is some open question here whether the interface
should be implemented on the outer or the inner widget
of the entry-text pairs. For now, our hand is forced,
since only GtkText provides access to the layout that
we need for implementing many of the interface methods.
2020-10-12 15:10:40 -04:00
Matthias Clasen b80272a7e7 atspi: Implement Text interface for labels
This is a not-quite-complete implementation of the
Text interface for GtkLabel. The missing parts are
anything around extents and positions, as well as
the ScrollSubstring apis.
2020-10-12 15:10:40 -04:00
Matthias Clasen 7c8a16812e atspi: Add pango utilities
This code is more or less a direct copy of what
we had in gtkpango.c in 3.x.
2020-10-12 15:10:40 -04:00
Matthias Clasen ddb72accc0 atspicontext: Fix GetIndexInParent for toplevels
For toplevels, we need to return the index in the
list of toplevels, since that is what GtkAtspiRoot
is using.
2020-10-12 15:10:40 -04:00
Matthias Clasen 824ab7e4ed atcontext: labelled-by has a reference list
This is unclear - our docs state that all the
relations have value type reference, but in fact
they all have value type reference list.
2020-10-12 15:10:40 -04:00
Matthias Clasen 3a867e26d0 atspicontext: Implement GetRelationSet
This translates relations as far as the match.

I'm not sure yet what we can do about the fact that
atspi expects relations to be bidirectional (ie have
label-for *and* labelled-by) while aria has only one
direction.
2020-10-12 15:10:40 -04:00
Matthias Clasen e269cb7a81 atspiroot: Stub out GetRelationSet
This needs to be fully implemented, for now sending
an empty relation set back prevents accerciser from
getting hung up.
2020-10-12 15:10:40 -04:00
Matthias Clasen 0ae2ae7944 atspi: Add the AtspiRelationType enum
This is what we need to map the aria relation
types to.
2020-10-12 15:10:40 -04:00
Matthias Clasen 5db6c4b038 Move atspi enums to gtkatspiprivate.h 2020-10-12 15:10:40 -04:00
Matthias Clasen db6bd018ca Add a GetInterfaces method
It turns out that accerciser depends on this undocumented
method that is not in the xml at all, otherwise interface
sections in the accerciser ui never get enabled.
2020-10-12 15:10:40 -04:00
Matthias Clasen 9d43e5bd59 Don't pass NULL to g_variant_new_string
That does not work.
2020-10-12 15:10:40 -04:00
Matthias Clasen edfc55ae89 atspi utils: Fix an oversight
gtk_accessible_role_to_atspi_role must always return
an atspi role. The fallback was returning an aria
role.
2020-10-12 15:10:40 -04:00
Matthias Clasen d6b64b5e29 Fixup: Add a forgotten #pragma once 2020-10-12 15:10:40 -04:00
Emmanuele Bassi 13aa053f6b Rename libgtk_only symbol in GdkWaylandToplevel
All public non-exported symbols in GDK can be used by GTK.
2020-10-12 16:49:10 +01:00
Emmanuele Bassi 4f316f3249 docs: Remove private GdkWayland API from the reference 2020-10-12 16:44:36 +01:00
Emmanuele Bassi 38304fc138 Hide gdk_wayland_display_prefers_ssd()
The function is not exported, so it should not be in a public header.
2020-10-12 16:44:05 +01:00
Emmanuele Bassi da6c0f3ecb Move private GdkSurface Wayland API into its own header
This allows us to hide private API from installed headers,
documentation, and introspection.
2020-10-12 16:40:19 +01:00
Emmanuele Bassi 9ce790032d a11y: Convenience API for referencing ATSPI root node
We turn the root node into a reference fairly often, so it's worth it to
have a utility function that does this for us.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi 35163bd7cc a11y: Add utility function for null refs
ATSPI was written for CORBA, which allows passing around "nil"
as valid object references.
2020-10-12 16:19:32 +01:00
Matthias Clasen 9d0952bd7f atspicontext: Implement GetState
Translate the aria states to at-spi's interpretation
of atk states.
2020-10-12 16:19:32 +01:00
Matthias Clasen e189ccc8ed atspiroot: Fix GetState implementation
When the GetState signature says 'au', it actually
means a bitset that is sent as a pair of 32bit integers.
2020-10-12 16:19:32 +01:00
Matthias Clasen 762fbf34fc atspiroot: Implement GetIndexInParent
Just for good measure
2020-10-12 16:19:32 +01:00
Matthias Clasen 9f73638d43 atspicontext: Implement GetIndexInParent
This is needed for ATs to take our tree seriously.
2020-10-12 16:19:32 +01:00
Matthias Clasen 057b447137 atspicontext: Implement more accessible api
Implement GetChildAtIndex, GetChildren and ChildCount.
2020-10-12 16:19:32 +01:00
Matthias Clasen 78690845b1 atspiroot: Implement GetChildren
No surprises here.
2020-10-12 16:19:32 +01:00
Matthias Clasen 2ea338a8cf atspiroot: Don't leak references
The reffing getter trap, lurking behind g_list_model_get_item().
2020-10-12 16:19:32 +01:00
Matthias Clasen e2f3039663 atspiroot: Implement GetLocale 2020-10-12 16:19:32 +01:00
Matthias Clasen 8f20133769 atspicontext: Print out the a11y bus address
Make our debug spew useful: Having the bus address
makes it easy to jump on the a11y bus to look around
with dbus tools.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi 55b1fbd0f3 a11y: Localise the role name of the root node 2020-10-12 16:19:32 +01:00
Emmanuele Bassi b57f1588df a11y: Register the Accessible interface on all AtSpiContext instances
This is not a complement implementation.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi 60acdb9cad a11y: Implement more ATSPI methods on the root node 2020-10-12 16:19:32 +01:00
Emmanuele Bassi 07759b158a a11y: Add method to extract desktop data
We are going to need the desktop name and path to populate the parent
property of AtSpiContexts associated to top level widgets.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi 9511c8273a a11y: Validate the DBus context path
UUIDs use dashes to separate the various blocks; unfortunately, this
results in an invalid DBus object path. Replace the dashes with an
underscore.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi b85b1f5b51 a11y: Turn accessible roles to string
Add a simple utility function to turn GtkAccessibleRole values into the
appropriate string, including localization.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi 716024d882 a11y: Convert GTK roles to ATSPI ones
There's not a precise, 1:1 mapping between the newer ARIA roles and the
older ATSPI ones. We make do with what we have.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi 21482e8264 a11y: Compute the label for a GtkATContext
The ARIA spec defines the mechanism for determining the name of an
accessible element—see §4.3 of the WAI-ARIA spec.

We follow the specification as much as it makes sense for GTK to do
so:

 1. if the element is hidden, return an empty string
 1. if the element has a labelled-by relation set, retrieve the
    label of the related element
 2. if the element has a label property set, use the value of
    the property
 3. if neither labelled-by nor label attributes are set, we use
    the role to compute the name:
   - for a `range` role, we return the contents of the value of
     the `value-text` or `value-now` properties
   - for any other role, we return a textual representation of
     the GtkAccessibleRole enumeration value
2020-10-12 16:19:32 +01:00
Emmanuele Bassi 88113956a3 tests: Use the test ATContext for every test
Otherwise we're going to need a full desktop session in order to run the
test suite.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi e6c5d57ffe a11y: Return the ATSPI role for the root element 2020-10-12 16:19:32 +01:00
Emmanuele Bassi d7ebf18723 a11y: Add AT-SPI cache object
Right now, the cache is unused, and we still need to implement the
serialisation method and emit the signals.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi 658d910967 a11y: Ignore widgets during destruction
There's no point in creating a GtkATContext when a widget is getting
destroyed.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi bd43e9cfc5 a11y: Register the accessible root object
When we create the first AT-SPI context we also need to register the
accessible root on the accessibility bus. The accessible root object is
the main entry point of an accessible application, and it holds the
global state to present to the ATs that connect to the bus.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi 8c18480092 a11y: Add a display to GtkATContext
Since we need to check at run time what kind of AT context to use, we
need a hook into the whole GDK backend machinery. The display connection
seems to be the best choice, in this case, as it allows us to determine
whether we're running on an X11 or Wayland system, and thus whether we
should create a GtkAtSpiContext.

This requires some surgery to fix the GtkATContext creation function, in
order to include a GdkDisplay instance.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi 8f19bb0832 a11y: Add dummy AT-SPI context
Does not do anything, at the moment, but it's going to get filled out
soon.

The backend is selected depending on the platform being compiled in;
since we're using AT-SPI on X11 and Wayland, and we don't have other
accessibility implementations, we currently don't care about run time
selection, but we're going to have to deal with that.
2020-10-12 16:19:31 +01:00
Emmanuele Bassi c50916d27b a11y: Add the AT-SPI DBus descriptions
And generate the code for the DBus interfaces.

We don't want the full object manager experience, here, because we're
going to have a single object responding to various interfaces and
remote method calls. For this reason, we're not using the gnome module
in Meson to call gdbus-codegen for us: we need to use the interface info
command line arguments, and those are not available from Meson.
2020-10-12 16:19:31 +01:00
Emmanuele Bassi 4b60e7470a Use test AT context with installed tests
Otherwise we're going to need an AT-SPI service on the session, and the
accessibility bus.
2020-10-12 16:19:31 +01:00
Matthias Clasen 77d4729483 Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!2683
2020-10-12 14:39:39 +00:00
Emmanuele Bassi daac36ea4c Generate introspection for GdkWayland API
Like we do for GdkX11. We can't use all of the public C API, but we can
expose enough type information to allow non-C developers to actually
check if they are running the Wayland GDK backend or not—plus some
additional Wayland-specific API.
2020-10-12 14:07:26 +01:00
Emmanuele Bassi f83ee2ab6a Add type annotations for GdkWayland API
The GdkWayland API takes generic GDK types and performs a run time
check, which means we need to properly annotate the actual expected
type in order to have methods recognised as such.
2020-10-12 14:07:26 +01:00
Emmanuele Bassi 33e84edf0c Skip GdkWayland symbols that use wayland-client types
The wayland-client API does not have introspection annotations, so we
can't use these types anyway.
2020-10-12 14:07:26 +01:00
Aurimas Černius 08fb8c1c2a Updated Lithuanian translation 2020-10-11 17:25:45 +03:00
Matthias Clasen 035e303f83 Merge branch 'wip/chergert/gdk-macos-fixes' into 'master'
various build fixes for GDK/GTK on macos

See merge request GNOME/gtk!2680
2020-10-10 11:55:01 +00:00
Piotr Drąg 91ba0a31e7 Update Polish translation 2020-10-10 12:45:37 +02:00
Marek Černocký 72ea3a1655 Updated Czech translation 2020-10-10 12:17:27 +02:00
Christian Hergert 07bb07abbe macos: port gtk to GDK_WINDOWING_MACOS
For the various uses of GDK_WINDOWING_QUARTZ, we need to use
alternatives from GDK_WINDOWING_MACOS.

Some minor loss of functionality is here, such as icons sent with
application menus. That can certainly be added back at a future
point.
2020-10-09 20:08:23 -07:00
Christian Hergert 41101673c3 gtk: use GDK_WINDOWING_MACOS in gentypefuncs.py 2020-10-09 20:05:20 -07:00
Christian Hergert 97f03edae4 gdk: remove quartz subdirectory from backends 2020-10-09 20:04:27 -07:00
Christian Hergert d8ba916586 macos: add key equivalent helper
This is needed by quartz code in gtk/.
2020-10-09 20:03:52 -07:00
Christian Hergert 3f519e4d9b macos: remove workaround for scroll delta
This gets handled differently in gtk/ and so we shouldn't translate it here.
2020-10-09 20:02:38 -07:00
Christian Hergert 58f9413464 macos: track various changes in GDK 2020-10-09 20:02:18 -07:00
Christian Hergert 59cdd7ae69 macos: lookup NSEvent by translated GdkEvent
This will be needed by the quartz imcontext.
2020-10-09 19:59:21 -07:00
Christian Hergert a30adfe1e0 macos: move input method names to private header 2020-10-09 19:56:21 -07:00
Christian Hergert 6706623731 demo: fix out of bounds array index usage 2020-10-09 19:55:25 -07:00
Matthias Clasen 758675f44e Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3242 and #3240

See merge request GNOME/gtk!2679
2020-10-09 13:35:57 +00:00
Matthias Clasen 8fcd4ac0f9 gtk-demo: Keep undisplayable resources out of view
No point in showing an apologetic tab for a blob of binary data.
gtk4-demo shows the resources under /DEMONAME/ for each demo,
so move the data to /DEMONAME_data/.
2020-10-09 07:52:29 -04:00
Matthias Clasen 4c3eb7c6f7 Merge branch 'ebassi/for-master' into 'master'
Tone down a user visible message

See merge request GNOME/gtk!2678
2020-10-09 11:47:38 +00:00
Matthias Clasen 115ed005e6 Send focus events to the root
We are not propagating focus change events, and that is the only
place where we are listening for focus change events. If GtkWindow
does not see focus-in events for its popovers, we end up with
inadvertendly inactive windows.

Fixes: #3240
2020-10-09 07:43:40 -04:00
Matthias Clasen 6a0704aeb4 window: Be more careful when looking for focus
When passing focus up to a parent, make sure the
newly chosen focus widget actually accepts the focus.
2020-10-09 07:43:25 -04:00
Matthias Clasen eb647299d4 build: Require sysprof 3.38.0
We use sysprof_collector_request_counters, which
was introduced in sysprof 3.38.0.
2020-10-09 07:43:25 -04:00
Matthias Clasen e7aa10342b gtk-demo: Ellipsize columns in the characters demo
some of the columns have uneven widths, causing them
to bounce around as you scroll. Ellipsize them and
give them a fixed with.
2020-10-09 07:43:25 -04:00
Matthias Clasen c835df5602 docs: Add more details to the migration guide
Add some details about GdkSurface and GtkWindow api changes.

Fixes: #3242
2020-10-09 07:43:25 -04:00
Emmanuele Bassi 43300b4047 Tone down a user visible message
Self-deprecating humour badly translates to a demo message.
2020-10-09 10:14:41 +01:00
Timm Bäder cdd2a2af1b Merge branch 'kjellahl/gdkseat' into 'master'
gdkseat: Make gdk_seat_get_tools() public

Closes #3241

See merge request GNOME/gtk!2677
2020-10-08 15:05:57 +00:00
Kjell Ahlstedt cb98a732e4 gdkseat: Make gdk_seat_get_tools() public
Fixes #3241
2020-10-08 16:22:05 +02:00
Timm Bäder 4450f64421 Merge branch 'fix.builder.msvc' into 'master'
testsuite/gtk/builder.c: Fix running on Visual Studio

See merge request GNOME/gtk!2676
2020-10-08 09:42:04 +00:00
Chun-wei Fan 1e4d3b6ca1 testsuite/gtk/builder.c: Fix running on Visual Studio
Explicitly say in the code that we are exporting the symbols so that when the
test program runs, it can find the required builder symbols.
2020-10-08 16:11:35 +08:00
Matthias Clasen 08ecf779f9 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2674
2020-10-08 02:19:42 +00:00
Matthias Clasen 5d7907caa5 gdk: Drop gdk_surface_new_temp
It is not used anymore.
2020-10-07 21:18:25 -04:00
Matthias Clasen 606ab611bd win32: Stop using gdk_surface_new_temp
No need to roundtrip through the frontend to create
one of our own surfaces.
2020-10-07 21:07:40 -04:00
Matthias Clasen 27ef9d9e5e broadway: Stop using gdk_surface_new_temp
No need to roundtrip through the frontend to create
one of our own surfaces.
2020-10-07 21:04:05 -04:00
Matthias Clasen 839baf2bef x11: Stop using gdk_surface_new_temp
No need to roundtrip through the frontend to create
one of our own surfaces.
2020-10-07 21:02:22 -04:00
Matthias Clasen e602d67e59 wayland: Stop using gdk_surface_new_temp
No need to roundtrip through the frontend to create
one of our own surfaces.
2020-10-07 21:02:22 -04:00
Matthias Clasen ba108f261f gdk: Drop some unused private api
No users of gdk_display_peek_event, gdk_display_has_pending
_gdk_display_event_data_copy or _gdk_display_event_data_free,
so drop all of these, and related vfuncs.
2020-10-07 21:02:22 -04:00
Matthias Clasen 668868fb1f Merge branch 'master' into 'master'
Allow LPR backend to print PDF and PS file formats

See merge request GNOME/gtk!418
2020-10-07 20:51:40 +00:00
Benjamin Otte bc5723a846 Merge branch 'wip/otte/for-master' into 'master'
textbuffer: Don't serialize the \0 byte

See merge request GNOME/gtk!2672
2020-10-07 20:33:25 +00:00
Matthias Clasen 98c7de4aa3 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3237

See merge request GNOME/gtk!2673
2020-10-07 20:30:52 +00:00
Benjamin Otte 0fdb33e82a textbuffer: Don't serialize the \0 byte
... when converting to text/plain.
2020-10-07 22:14:18 +02:00
Matthias Clasen cfb316799a colorchooser: Bring color names back
These are useful for accessibility.

Fixes: #3237
2020-10-07 15:56:11 -04:00
Jan Alexander Steffens (heftig) fb0c062506 gtkplacessidebar: Disconnect and unref cloud_manager in dispose
The manager's providers-changed signal can fire after the sidebar has
been freed. Make sure we disconnect the sidebar from the manager.

https://bugs.archlinux.org/task/57984
https://bugs.archlinux.org/task/68123
2020-10-07 15:16:31 -04:00
Matthias Clasen 3d9eb61bba gtk-demo: Fix an off-by-one error
This was found by the asan build in our ci.
2020-10-07 15:16:31 -04:00
Timm Bäder 4993cde0cb Merge branch 'migration-guide-fix' into 'master'
migration guide: Remove stray html tags

See merge request GNOME/gtk!2670
2020-10-07 08:00:43 +00:00
Nicola Fontana 35b0796a1f migration guide: Remove stray html tags 2020-10-07 08:38:26 +02:00
Matthias Clasen d839c1beab Merge branch 'svg-demo' into 'master'
Svg demo

See merge request GNOME/gtk!2668
2020-10-06 20:55:28 +00:00
Matthias Clasen 5a9547da41 gtk-demo: Add an svg paintable demo
It is a little annoying that this demo will not show up
if we don't find librsvg, but I think showing how easy
this paintable is outweights the annoyance.
2020-10-06 15:12:09 -04:00
Matthias Clasen 25cbc1a15a gtk-demo: Recognize .svg as images
We can't guarantee that we can load it, but worst
case you'll get a missing image.
2020-10-06 15:11:08 -04:00
Matthias Clasen 043207133d Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3235

See merge request GNOME/gtk!2667
2020-10-06 18:25:48 +00:00
Matthias Clasen 490163efcd Merge branch 'aboutwindow' into 'master'
gtkaboutdialog: Directly specialize GtkWindow

See merge request GNOME/gtk!2666
2020-10-06 18:25:27 +00:00
Matthias Clasen 44fd0c18c8 aboutdialog: Fix updating license tab
We need to update the license button visibility
whenever the license type changes.
2020-10-06 12:53:46 -04:00
Adrien Plazas a17f33b1fe gtkaboutdialog: Directly specialize GtkWindow
As it doesn't act as a dialog, there is no point specializing GtkDialog,
so his makes it specialize GtkWindow directly.
2020-10-06 18:46:48 +02:00
Matthias Clasen 22eac2f407 window: Fix setting min size
We were inadvertedly setting the windows min size
to the default size, making it so that you can never
shrink a window below its default size.

Fixes: #3235
2020-10-06 11:06:36 -04:00
Matthias Clasen bdbfaef4d8 gdk: Tweak our GL debug message callback
Go back to installing our debug message callback
unconditionally if G_ENABLE_CONSISTENCY_CHECKS is
defined, and allow opting into it using GDK_DEBUG=gl-debug
otherwise.
2020-10-06 10:34:30 -04:00
Matthias Clasen 214c35ffc7 gdk: Docs tweaks
We don't have library initialization api anymore,
update the section title to reflect that.
2020-10-06 07:58:01 -04:00
Matthias Clasen 7698b4dd63 treelistrowsorter: Add a bandaid
The GtkTreeListRowSortKeys implementation doesn't
know how it wants to cache its keys, and just crashes.

Since that is not cool, add a bandaid fix that forces
it to recreate its keys instead. Extra work, but hey,
no crash.

Related: #3228
2020-10-06 07:58:01 -04:00
Emmanuele Bassi e532f2322b Merge branch 'FixWin32PopupFocus' into 'master'
Gtk4/Win32: Fix popup focus stealing when CSD is disabled

See merge request GNOME/gtk!2665
2020-10-06 10:30:07 +00:00
firox263 f0a8c6311e Fix Win32 popup focus when using SSD
Prevents GDK Popups from stealing focus from the parent window when
using Server Side Decorations on win32.

It uses `ShowWindow` and the `SW_SHOWNOACTIVATE` flag.
2020-10-06 22:37:35 +13:00
Matthias Clasen b6d4067717 Merge branch 'wip/carlosg/for-master' into 'master'
gtkpopover: Revert focus to parent on hide()

Closes #3214

See merge request GNOME/gtk!2653
2020-10-06 02:14:54 +00:00
Matthias Clasen ac164d240b Cosmetic
Don't call gtk_root_get_focus when we already have
the GtkWindowPrivate struct at hand. And use
gtk_window_set_focus to update the focus, like the
old code did.
2020-10-05 21:53:05 -04:00
Carlos Garnacho 38547120b2 gtkwindow: Ensure to revert focus to a parent on hide()
When a widget is hidden, check harder for the keyboard focus being
contained in that widget, in order to reset it. Portions of the
focus child hierarchy may be outdated at the time, so it is more
reliable to check GtkRoot::focus (i.e. the property we intend to
update here).

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3214
2020-10-06 03:29:13 +02:00
Matthias Clasen 7f5deed2eb Merge branch 'simple-resizing-fixes' into 'master'
Simple resizing fixes

Closes #3076

See merge request GNOME/gtk!2661
2020-10-06 01:25:25 +00:00
Matthias Clasen ccdc10d9df Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3196

See merge request GNOME/gtk!2662
2020-10-06 00:57:30 +00:00
Timm Bäder 982ebf1b69 gradient shaders: Reduce out values as well
We only do 6 color stops here now. Also works around a driver bug.

Fixes #3196
2020-10-05 20:35:34 -04:00
Matthias Clasen 20fb7812df window: Fix window size snapping back
We were not updating the remembered size at all when
the window is interactively resized, causing it to
snap back to its default size the next time we call
gdk_toplevel_present().

This is a bandaid fix to prevent very broken resizing
behavior, until we have properly redone toplevel sizing.

Fixes: #3076
2020-10-05 20:24:19 -04:00
Matthias Clasen 082edd957e wayland: Don't forget to reapply margins
When using the saved size because the compositor
told us to, we were forgetting to readd the margins.

The visible symptom of this was the window getting
smaller every time we went to tiled state and back.
2020-10-05 20:17:50 -04:00
Matthias Clasen e5cd2568c8 wayland: Don't save size when tiled
Don't remember the surface size when we are in tiled
state either. This matches the 'fixed_size' condition
in gdk_wayland_surface_configure_toplevel.

This change fixes an issue where moving a window first
to tiled, then to maximized state and back would lead
to the unmaximized window having the tiled dimensions.
2020-10-05 20:15:33 -04:00
Matthias Clasen d51608a2c9 wayland: Don't emit premature configure events
We should not emit configure events before we are realized - size
changes at this point are not relevant.

This gets rid of a mysterious emission of GdkSurface::size-changed
with a size of 52x52, that is happening when GtkWindow sets the
shadow_width before the window is mapped.
2020-10-05 17:18:14 -04:00
Matthias Clasen 67c6f0a08a gtk-demo: Mention dataset size for Characters 2020-10-05 14:43:38 -04:00
Matthias Clasen 7311464c67 gl: Install the debug message callback for gl-debug
Always install the debug message callback when we can
and GDK_DEBUG=gl-debug is specified. Previously, we
were only installing the callback when the build was
a non-optimized debug build.
2020-10-05 14:43:31 -04:00
Matthias Clasen aaab461c27 Merge branch 'fix-texture-cache' into 'master'
gl renderer: Fix up texture cache key

See merge request GNOME/gtk!2659
2020-10-05 14:58:20 +00:00
Matthias Clasen 6b0c65cc38 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2660
2020-10-05 14:23:08 +00:00
Matthias Clasen 74d99766e4 gtk-demo: Fix up the Characters demo
Move the Unicode names to a separate source file,
and only build the demo if we have harfbuzz (since
we use script names, and those are only available
with harfbuzz).

Also, fix a forgotten type name.
2020-10-05 09:56:04 -04:00
Alexander Larsson 24a27ba44f gl renderer: Fix up texture cache key
The commit e14d2be1 forgot to actually set the parent_rect in the texture
key in the case it is necessary.
2020-10-05 15:43:04 +02:00
Matthias Clasen 6156c3583d NEWS: Updates
Trying a new scheme - when updating NEWS outside of doing
a release, keep the version out, to make the it clear that
this is just about the tip of the branch, not a complete
release.
2020-10-05 08:18:56 -04:00
Matthias Clasen 2b03674464 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2658
2020-10-05 11:29:10 +00:00
Matthias Clasen 5d26d11868 gtk-demo: Add a column view demo
Make a column view that is showing some Unicode data.
2020-10-04 22:53:45 -04:00
Matthias Clasen 34f33b36f8 Prevent a crash with script names
We can't pass NULL to gettext().
2020-10-04 21:20:48 -04:00
Matthias Clasen bea3bc5d27 Update the copy in gtk-demo too 2020-10-04 19:48:46 -04:00
Matthias Clasen 5d5625dec8 Update script names to Unicode 13
It would be better if this was provided elsewhere...
2020-10-04 16:15:09 -04:00
Matthias Clasen cb833d52fb Merge branch 'emoji-data-cldr' into 'master'
Update Emoji data

Closes #1511 and #950

See merge request GNOME/gtk!2656
2020-10-04 13:56:40 +00:00
Matthias Clasen 9007d153c8 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2657
2020-10-04 13:56:30 +00:00
Matthias Clasen 8ca612c966 scale: Make draw-value default to FALSE
This is rarely what you want, so lets turn it off
by default.

Update the one place in our demos where we want to
draw a value, add support for this to gtk-builder-tool,
add a test and mention this change in the migration
guide.
2020-10-04 08:26:44 -04:00
Matthias Clasen 452c909b64 Redo the handling of Emoji data
Use the data files from https://github.com/milesj/emojibase.git
as source for our Emoji data. Slightly change our data format by
adding a group to each item, in both the Emoji data and in the
setting for recent-emoji.

Install translated versions of the data as separate resource
bundles in $prefix/gtk-4.0/emoji, and load them when appropriate.

Currently, we have data for de, en, es, fr, zh, with data taken
from Unicode 13 and CLDR 13.

Fixes: #950 #1511
2020-10-04 01:14:42 -04:00
Matthias Clasen 7ef5921022 Emoji: Drop the shortname field from emoji.data
Match the name for Emoji completion, and display
it too. 'man worker' looks a lot more natural in
the UI than ':man_worker:'.
2020-10-03 20:06:31 -04:00
Matthias Clasen 1d9d5fcf39 Do case-folding and tokenization when creating emoji.data
We can avoid doing the extra work of case-folding and
tokenization whenever we filter in the Emoji chooser.
2020-10-03 19:46:46 -04:00
Matthias Clasen ed724ebc35 emoji: Add keywords to the data
And use them for matching in the Emoji chooser.
2020-10-03 19:46:46 -04:00
Matthias Clasen 44448016e8 emoji: Some work on the conversion tool
Document the variant format, and write out json
format if asked to.
2020-10-03 19:46:46 -04:00
Matthias Clasen a4284569c0 Fix Emoji completion
This is some late fallout from the container removal.
2020-10-03 19:42:19 -04:00
Matthias Clasen 9a2faf2197 widget-factory: Enable emoji completion somewhere
Without a quick way to test this, it is bound to
fall apart. As it has.
2020-10-03 19:41:26 -04:00
Matthias Clasen 6e594da5f2 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #506

See merge request GNOME/gtk!2655
2020-10-03 19:27:15 +00:00
Matthias Clasen ac79c0e799 textbuffer: Improve some get_iter apis
Make these functions return FALSE if they did not
return the exact position that was requested.

Adapt tests.

Based on a patch by Sebastien Wilmet

Fixes: #506
2020-10-03 14:29:07 -04:00
Matthias Clasen d0b7a4a4ec testsuite: Add a test that checks for property accessors
Make sure that every object property in GTK has accessors for getting
its value (if the property is readable) or setting it (if it is
writable).

Since we are still missing accessors, the test is allowed to
fail for now. Sadly, mesons xfail support is busted, so we just
disable the test entirely :(

Based on initial work by Benjamin Otte.

Related: #2440
2020-10-03 14:28:37 -04:00
Matthias Clasen 60b1b4669e spinbutton: Add some missing accessors
Add a setter and getter for the climb-rate property.
2020-10-03 13:11:20 -04:00
Matthias Clasen 9d0d4cef03 Cosmetics 2020-10-03 13:11:20 -04:00
Matthias Clasen 1b1bf6c90a text: Add some missing setters and getters
Add getters and setters for the enable-emoji-completion,
propagate-text-width and truncate-multiline properties.
2020-10-03 13:11:20 -04:00
Matthias Clasen 38bd4439e8 directorylist: Drop the item-type property
No need for this to be a property.
This showed up in a test for missing accessors.
2020-10-03 13:11:20 -04:00
Matthias Clasen 9fdb71cbd2 icontheme: Add a missing getter
We want to have a get_display() method on every object
that is tied to the display, so add one here.
2020-10-03 13:11:20 -04:00
Matthias Clasen ff7bcf738c colorbutton: Properly override interface properties
This showed up in a test for missing property accessors.
2020-10-03 13:11:20 -04:00
Matthias Clasen 5640208f31 node-editor: Don't insert hyphens
This can be a bit confusing in multi-line strings.
2020-10-03 13:11:20 -04:00
Matthias Clasen cef1cd19ff gsk: Avoid long lines in serialized nodes
When encoding big blobs of data in base64, insert newlines.
Base64 allows it, CSS allows it, so not need to make GtkTextView
struggle with multi-megabyte lines.

Update nodeparser tests to reflect this change.
2020-10-03 13:10:55 -04:00
Matthias Clasen 279d3c08a9 gtk-demo: Rename the transition shader files
Easier to find them when their name matches the title
that we show in the UI.
2020-10-03 00:01:25 -04:00
Matthias Clasen 949f22b8b2 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #2261 and #1002

See merge request GNOME/gtk!2654
2020-10-03 03:55:32 +00:00
Matthias Clasen 19d760f9dd gtk-demo: Fix a typo 2020-10-02 23:54:15 -04:00
Matthias Clasen a9809b0f67 Allow inserting newlines in css strings
Rename _gtk_css_print_string to strip the _ and add
an insert_newlines argument to it. Update all callers,
and make the render node serializer insert newlines.
2020-10-02 23:40:16 -04:00
Matthias Clasen 9033336a23 css: Move _gtk_css_print_string around
Move this to a separate header, since it is not
parser functionality, and kill the duplicate
gtkcssparserprivate.h header.
2020-10-02 23:40:16 -04:00
Jakub Steiner 68ae8506d5 Merge branch 'stackswitcher-button-styling' into 'master'
Adwaita: Simplify stackswitcher button styling

See merge request GNOME/gtk!2498
2020-10-02 15:09:07 +00:00
Matthias Clasen da8ee53e2d emojichooser: Allow inserting multiple Emoji
Don't close the Emoji chooser when the Control
key is held while clicking. So you can insert
multiple Emoji without having to reopen the
chooser every time.

Fixes: #1002
2020-10-01 23:45:05 -04:00
Matthias Clasen f6bd2f4d3f Add a test for gsk_gl_shader_compile
This is not super useful, but at least we can
test that we get an error message including the
shader text.
2020-10-01 23:45:05 -04:00
Matthias Clasen c9f3034e82 gdk: Remove an unused variable 2020-10-01 19:33:43 -04:00
Matthias Clasen 3cf8904d0b Add GTK_INPUT_HINT_PRIVATE
Add a flag that requests that input methods should not
update personalized data (such as typing history).

Fixes: #2261
2020-10-01 17:14:58 -04:00
Matthias Clasen c43d535aab docs: Fix a copy-paste error 2020-10-01 17:07:53 -04:00
Matthias Clasen f4bfa16136 Update the release script
If things go according to plan, we don't need to include
gtk-doc as a subproject in the next snapshot.
2020-10-01 15:14:33 -04:00
Matthias Clasen 4d90259b9b Use gtk-doc from master
I've merged the relevant parts from the gtk-doc-for-gtk4
branch.
2020-10-01 15:11:37 -04:00
Matthias Clasen ffb51b6888 Require gtk-doc 1.33
We'll hopefully get a gtk-doc release out with that
version number soon.
2020-10-01 15:09:26 -04:00
Matthias Clasen dc3b140fd7 Cosmetics 2020-10-01 13:48:24 -04:00
Matthias Clasen ce29545470 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3220

See merge request GNOME/gtk!2652
2020-10-01 14:21:34 +00:00
Matthias Clasen cbe3de9ce7 Merge branch 'master' into 'matthiasc/for-master'
# Conflicts:
#   .gitlab-ci/test-msys2.sh
2020-10-01 13:56:37 +00:00
Matthias Clasen 6de7022458 Merge branch 'ci-win32-introspection-enabled' into 'master'
CI: Enable introspection again for the Windows build

See merge request GNOME/gtk!2651
2020-10-01 13:50:02 +00:00
Christoph Reiter 9601863569 CI: Enable introspection again for the Windows build
The underlying bug was fixed in glib and backported in MSYS2:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1665
2020-10-01 15:16:18 +02:00
Matthias Clasen c278261be0 Merge branch 'wip/jimmac/infosearch-close' into 'master'
Adwaita: close button for infobar, searchbar

Closes #3215

See merge request GNOME/gtk!2650
2020-10-01 12:01:23 +00:00
Matthias Clasen 028cd1e23a Revert "Fix the build with cups < 2.3"
This reverts commit d761e3cf2c.

I am seeing PPD_CUSTOM_UNKNOWN in the cups headers in our
ci images, and that is cups 2.2.12. So this commit was
mistaken.
2020-10-01 07:59:30 -04:00
Matthias Clasen 6e7c0ce06b ci: Give up on sysprof for now
Using sysprof and glib as subprojects of the same
project sadly does not work. Subprojects are not
as robust as they should be.
2020-10-01 07:37:44 -04:00
Jakub Steiner 81cfcba5ad Adwaita: close button for infobar, searchbar
fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3215
2020-10-01 13:14:25 +02:00
Matthias Clasen 9bac129707 ci: Try to get everything building again
It turns out that the sysprof meson setup does not
work with meson 0.54 :( So version 25 of our ci images
bumps the meson version to 0.55.3.
2020-09-30 23:43:03 -04:00
Matthias Clasen 91c8f6b7df build: Try to fix docs+subprojects
Apparently, subprojects don't have pkgconfig variables :(
2020-09-30 16:21:39 -04:00
Matthias Clasen 103080c384 build: Remove an unneeded version check
We are requiring a newer meson than we were checking
for here.
2020-09-30 16:09:56 -04:00
Matthias Clasen b936419125 ci: Remove --fatal-meson-warnings
meson adds features that then trigger warnings when we run
a newer meson over some of our subprojects. This is all too
fragile.
2020-09-30 15:53:15 -04:00
Matthias Clasen 72eb89eda7 gtk-demo: Add the shader paintable sources
This is currently not public GTK api, just part of
the demo. So we should show it here.
2020-09-30 15:41:05 -04:00
Matthias Clasen b0da095944 gsk: Fix compiler warnings
We forgot to teach the broadway renderer about new enum
values, and our ci didn't catch it because werror didn't
actually work there until now.
2020-09-30 15:39:30 -04:00
Matthias Clasen 21c8bc2b47 build: Require meson 0.54 2020-09-30 15:26:20 -04:00
Matthias Clasen 7780b89e8a ci: Really enable werror
We wanted to enable werror for gtk without enabling it
for all our subprojects. Sadly, we failed. Try again
2020-09-30 15:26:20 -04:00
Matthias Clasen 517a8406b0 ci: Use the v24 images
These images have meson 0.54.
2020-09-30 15:26:20 -04:00
Matthias Clasen dfd16e3982 ci: Use a newer meson in images
We need meson 0.54.
2020-09-30 15:26:20 -04:00
Xavier Claessens fd1e8afe9d meson: Change introspection option to yielding feature
Yielding option means that if pango is built as a subproject, it will
take the value of that option from the parent project (e.g. gst-build).
For that to work it must be of the same type, which is "feature" instead
of "boolean" in all GStreamer modules.
2020-09-30 15:11:27 -04:00
Benjamin Otte 5829bc7c91 Use correct child widget when measuring
Fixes a copy/paste error.

Fixed #3220
2020-09-30 15:11:27 -04:00
Matthias Clasen 5a3aed8ade Merge branch 'introspection' into 'master'
meson: Change introspection option to yielding feature

See merge request GNOME/gtk!2648
2020-09-30 17:50:21 +00:00
Benjamin Otte 5b89253fd9 Use correct child widget when measuring
Fixes a copy/paste error.

Fixed #3220
2020-09-30 17:48:24 +00:00
Matthias Clasen fd631937f3 transition demo: Make buttons symbolic
It looks better.
2020-09-30 13:43:36 -04:00
Matthias Clasen 77ec961126 Merge branch 'ebassi/for-master' into 'master'
demo: Replace g_print with g_debug

See merge request GNOME/gtk!2645
2020-09-30 15:22:57 +00:00
Matthias Clasen 924e510512 gtk-demo: Update text for the transitions demo
The fire is gone, but we have wobbly widgets!
2020-09-30 11:19:12 -04:00
Matthias Clasen 97ffd94d20 Merge branch 'snazzy-demo' into 'master'
gtk-demo: Make gltransitions demo a bit snazzier

See merge request GNOME/gtk!2644
2020-09-30 15:00:58 +00:00
Alexander Larsson d6648871b1 gtk-demo/gltransition: Replace fire background with more mellow blobs 2020-09-30 16:38:50 +02:00
Alexander Larsson 5d4a6940fa gtk-demo: Use duck in transitions to get some alpha example 2020-09-30 16:25:30 +02:00
Xavier Claessens 0e5dac8c25 meson: Change introspection option to yielding feature
Yielding option means that if pango is built as a subproject, it will
take the value of that option from the parent project (e.g. gst-build).
For that to work it must be of the same type, which is "feature" instead
of "boolean" in all GStreamer modules.
2020-09-30 09:50:24 -04:00
Matthias Clasen 2dcf750198 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2647
2020-09-30 13:42:55 +00:00
Matthias Clasen 5fa765b284 Mention icon theme in the migration guide
This was requested in #3216.
2020-09-30 08:55:39 -04:00
Matthias Clasen 9d701129cc icontheme: Clarify the docs
Mention that icons directly in /$app_id/icons/ are treated
as unthemed icons.

See #3216
2020-09-30 08:55:39 -04:00
Alexander Larsson e14d2be1e8 gl renderer: Fix render node texture cache
We're caching two things, either a node itself being rendered, or a
parent storing a cached version of a child as rendered to an offscreen
the size and location of the parent.

If both the parent and child uses the cache this will cause a conflict in
the cache as it is currently use keying of a node pointer which will have
the same value for the node-as-itself and the child-node-of-the-parent.

We fix this by adding another part to the key "pointer_is_child" which means
we can have the same node pointer twice in the cache.

Additionally, in the child-is-rendered-offscreen case the offscreen
result actually depends on the position and size of the parent viewport,
so we need to store the parent bounds in that case.
2020-09-30 14:53:13 +02:00
Emmanuele Bassi b0a0f07bd7 demo: Replace g_print with g_debug
The GtkGears widget is a bit too chatty, especially when used inside
demos like the fishbowl. Let's use g_debug() instead of g_print() for
the GL debugging message.
2020-09-30 12:35:31 +01:00
Matthias Clasen 7defc3b759 Fix the release script some more
Still trying to master the tar commandline.
2020-09-30 06:51:46 -04:00
Alexander Larsson e9885f9cde gtk-demo: Make gltransitions demo a bit snazzier
This adds a bunch of snazz to the gltransitions demo. It is perhaps
a bit overloaded now, but it demos everything that we can do.

Changes:
 * The fire shader is now not a bin, it just renders an animating
   background with no textures involved.
 * The stacks don't all start on the same page.
 * The shaderbin passes the mouse coordinate to the shader.
 * The shaderbin allows specifying a "border" so that you can
   cause effects outside the bin child (something that is new to gtk4).
 * All the buttons and the stacks are now in shader-bins that runs
   a wobbly-widget effect based on the mouse position that
   wobbles outside the child allocation.
2020-09-30 11:40:37 +02:00
Matthias Clasen 87393c7fb6 Merge branch 'small-cleanup' into 'master'
menubutton: Remove obsolete private method

See merge request GNOME/gtk!2643
2020-09-29 21:52:37 +00:00
Matthias Clasen 76d616909f Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!2642
2020-09-29 20:45:00 +00:00
Matthias Clasen 31069d5e96 release script: Fix doc tarball generation
Strip one level from the directories.
2020-09-29 15:07:13 -04:00
Florian Müllner 7ad42df727 menubutton: Remove obsolete private method
It was only added for the fallback app menu in headerbars, which
has been removed in the meantime.
2020-09-29 20:58:25 +02:00
Emmanuele Bassi c6cedf608a Add annotations for GtkBuildable virtual functions
Now that the functions that wrap them have gone away from the public
API, we need proper annotations for the virtual functions, otherwise
languages will not have enough information on nullable arguments and
ownership transfer.
2020-09-29 19:48:55 +01:00
Matthias Clasen 218b905a88 3.99.2 2020-09-29 14:44:31 -04:00
Matthias Clasen 00c6340777 gsk: Add some more shader docs
Do a pass over the docs and address minor inconsistencies,
cosmetics and formatting differences.

Mention GSK_DEBUG=shaders.
2020-09-29 14:44:31 -04:00
Matthias Clasen 687ed74d46 Merge branch 'snapshot-stack-optimize' into 'master'
Minor optimizations to GtkSnapshot state stack

See merge request GNOME/gtk!2641
2020-09-29 18:44:07 +00:00
Emmanuele Bassi 97276a5cd4 Remove gtk-doc stanzas from private GtkBuildable API
Various functions were moved to the private GtkBuildable header by
commit 2715b3ec31, but the functions still
have gtk-doc stanzas.
2020-09-29 19:39:34 +01:00
Alexander Larsson 796e6ee306 snapshot: Preallocate and don't memset the state stack
Most of the time the snapshot is less than 16 levels deep (did some testing
in gtk-demo), so lets pre-allocate 16 levels of state stack to avoid the
extra allocation most of the time.
2020-09-29 16:03:06 +02:00
Alexander Larsson 18b8b499de gdkarray: Add support for GDK_ARRAY_NO_MEMSET
If all your callers already initialize the array element as needed,
then we don't need to memset it to zero first.

This is pretty useful for the snapshot state stack, because due
to the per-node-type data area the elements on the stack are
quite large, but often a lot of it is not used.
2020-09-29 16:02:59 +02:00
Alexander Larsson 8a0dd452d2 gdkarray: Inline splice and reserve
This inlines the splice and reserver GdkArray calls. These are
typically only called from the gdk_array_(append/set_size) functions
anyway, and inlining the caller means we can constant propagate the
constant arguments in those calls. Its hard to get exact numbers, but
in fishbowl i noticed a significant decrease in the time spent in
the array code when pushing and poping states.
2020-09-29 15:57:33 +02:00
Matthias Clasen 4cfa9ee19f Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2639
2020-09-29 12:57:36 +00:00
Matthias Clasen 719c44a610 Merge branch 'glshader-track-uniform-state' into 'master'
gl: Track the current uniform state for custom programs

See merge request GNOME/gtk!2638
2020-09-29 12:49:22 +00:00
Matthias Clasen 4a2c817690 docs: Document various entry ::activate signals 2020-09-29 07:04:07 -04:00
Matthias Clasen aac9414117 statusbar: Remove a misleading doc comment 2020-09-29 07:04:07 -04:00
Matthias Clasen c897daf797 snapshot: Document radial gradient apis 2020-09-29 07:04:07 -04:00
Matthias Clasen f1299410bf docs: Fix a typo 2020-09-29 07:04:07 -04:00
Matthias Clasen 165768b6ad wayland: Match header and doc arguments
gtk-doc doesn't take this lightly.
2020-09-29 07:04:07 -04:00
Matthias Clasen 07c338b487 gsk: Document radial gradient api 2020-09-29 07:04:07 -04:00
Matthias Clasen 3af249c046 Silence a compiler warning
These variables are not used anymore since
commit 11e4a46967.
2020-09-29 07:04:07 -04:00
Matthias Clasen 91c3edba35 NEWS: Updates 2020-09-29 07:04:07 -04:00
Alexander Larsson 51ab56d33a gl: Track the current uniform state for custom programs
This allows us to avoid updating uniforms if that is not necessary. This
in turn allows us to sometimes reuse the same draw op by just extending the
vertex array size we draw rather than doing a separate glDraw call.

For example, in the fishbowl demo, all the icons added at the same
time will have the same time and size, so we emit single draw calls
with 100s of triangles instead of 100s of draw calls with 2 triangles.
2020-09-29 11:52:39 +02:00
Alexander Larsson 2e5caa68bc Merge branch 'glshader-node' into 'master'
Add support for GLShader nodes

See merge request GNOME/gtk!2594
2020-09-29 08:30:48 +00:00
Matthias Clasen 4e55220d76 Add some shader tests
These are just basic api usage tests, no rendering.
They found the issues fixed in the preceding commits.
2020-09-29 09:51:16 +02:00
Alexander Larsson e76cb3e1e4 gtk-demo: Add a shader paintable to the fishbowl
This gets around 500 instances at 60fps on my system.
2020-09-29 09:51:16 +02:00
Alexander Larsson 8bcb031418 gtk-demo: Add GskGLShaderNode demo
Add adds a demo showing off GskGLShaderNode in various ways.

It has a transistion widget, using some examples from
gl-transitions.com, with child widgets being both images, a GL area
and real widgets (that let you edit the transition shaders
themselves.

It also has a fancy fire effect on hove on the buttons.
2020-09-29 09:51:16 +02:00
Alexander Larsson 4d697283ae Support GLShaderNode in backends
For vulkan/broadway this just means to ignore it, but for the gl
backend we support (with up to 4 texture inputs, which is similar to
what shadertoy does, so should be widely supported).
2020-09-29 09:51:16 +02:00
Alexander Larsson 950cc41e15 GtkSnapshot: Add gtk_snapshot_push_glshader() 2020-09-29 09:51:16 +02:00
Alexander Larsson 7ea755e206 Add GskGLShaderNode and GskGLShader
A GskGLShader is an abstraction of a GLSL fragment shader that
can produce pixel values given inputs:
 * N (currently max 4) textures
 * Current arguments for the shader uniform
Uniform types are: float,(u)int,bool,vec234)
There is also a builder for the uniform arguments which are
passed around as immutable GBytes in the built form.

A GskGLShaderNode is a render node that renders a GskGLShader inside a
specified rectangular bounds. It renders its child nodes as textures
and passes those as texture arguments to the shader. You also pass it
a uniform arguments object.
2020-09-29 09:51:16 +02:00
Matthias Clasen 6e9b58b6f0 gsk: Add more shader debug spew
Print out the full assembled shader sources when
GSK_DEBUG=shaders is given. This is very verbose,
but may be useful to see what we actually pass
to the compiler.
2020-09-29 09:51:16 +02:00
Alexander Larsson 645fc6a9a5 GtkWindow: Create renderer before realizing child widgets
This way the child widgets can rely on the renderer (for example what
type it is) to decide details about how they render (such as if they
should use OpenGL shaders).
2020-09-29 09:51:16 +02:00
Matthias Clasen a91b6b4786 css: Move the last parser api to the new header
This lets us use it from the render node parser
in gsk.
2020-09-29 09:51:16 +02:00
Alexander Larsson 16cdb33c6c shadertoy demo: Fix GLSL on GLES
I was getting "assignment to varying fragColor" errors
2020-09-29 09:51:16 +02:00
Alexander Larsson bacb3affb3 gl: Add some namespacing to the preamble symbols
This adds a gsk prefix to the stuff in the preamble, as we want to
avoid it conflicting with things in the main shader. Especially once
we start allow some customization of shaders.
2020-09-29 09:51:16 +02:00
Alexander Larsson 9460d0131f gl backend: Add line numbers to source in glsl compilation errors
Almost always the source is created by combining various sources, which
means the line numbers in the error messages are hard to use. Adding
the line numbers to the source in the error message helps with this.
2020-09-29 09:51:16 +02:00
Alexander Larsson 7edcd1748c gl: Properly report error if shader linking fails
In gsk_gl_shader_builder_create_program(), if linking fails we
need to return -1 to indicate error, rather than the old deleted
program id.
2020-09-29 09:51:16 +02:00
Alexander Larsson 6887d0ce24 glrenderer: Move ProgramState into Program
There is no real reason to have this on the side indexed via the
index, as it is stored next to each other anyway. Plus, storing them
together lets use use `Program` structures not in the array.
2020-09-29 09:51:10 +02:00
Matthias Clasen e29c586b7c Merge branch 'arnaudb/menubutton-direction' into 'master'
Make GtkMenuButton::direction more useful.

Closes #2811

See merge request GNOME/gtk!2636
2020-09-29 01:55:24 +00:00
Matthias Clasen 4f8a211c51 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3202

See merge request GNOME/gtk!2637
2020-09-29 01:53:02 +00:00
Matthias Clasen 30b7545fb5 Add a reftest for flipping transforms
Verify that a scale of -1 does in fact cause a
gradient to go the other direction.
2020-09-28 21:07:51 -04:00
Matthias Clasen a799c86edb textbuffer: Elaborate docs
Explain a bit more what gtk_text_buffer_get_content_provider()
is for.

Fixes: #3202
2020-09-28 20:51:13 -04:00
Matthias Clasen 68bb532290 window: Don't get surfaces needlessly
There is a 1-1 correspondence between natives and
surfaces, so we can just compare the natives, no
need to get the surface for every single one.
2020-09-28 20:51:13 -04:00
Matthias Clasen d2f0e3fa6b doc: Document some apis as widget implementor only
A better solution for this would be nice. For the
time being, just add a sentence to the docs.
2020-09-28 20:51:13 -04:00
Arnaud Bonatti 4684082232 Make GtkMenuButton::direction more useful.
This property was only used until now when
there was neither an icon nor a label set,
for arrow direction and popover placement.

Starting with Gtk4, a GtkMenuButton with a
label shows an arrow at the right (in LTR)
of the label. Allow disabling the arrow or
changing its direction using the direction
property, to have a way to restore a Gtk3-
like look or to improve popover placement.

Fixes #2811.
2020-09-29 02:26:13 +02:00
Matthias Clasen 5536a2ffe6 Merge branch 'wip/carlosg/for-master' into 'master'
gtkeventcontrollerscroll: Drop device type checks

Closes #3210

See merge request GNOME/gtk!2635
2020-09-28 22:03:36 +00:00
Carlos Garnacho 11e4a46967 gtkeventcontrollerscroll: Drop device type checks
Kinetic scrolling (and begin/end tracking) broke with commit cab1dcb696
since the pointing device used on X11 does not get as much GdkInputSource
granularity as the source device used to have in GTK3.

Actually this is kinda pointless, devices incapable of smooth scroll
should send discrete events, without those devices in the picture, we
want kinetic scroll to apply on every other device capable of smooth
scroll, so just do that.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3210
2020-09-28 23:35:36 +02:00
Yosef Or Boczko 01ddc181f9 Update Hebrew translation
(cherry picked from commit f6e3dfd73e)
2020-09-28 19:00:52 +00:00
Yosef Or Boczko 2b3c2962ab Update Hebrew translation
(cherry picked from commit 02d1d9714e)
2020-09-28 18:59:32 +00:00
Matthias Clasen 27b3bb59eb Merge branch 'another-attempt-to-fix-shadertoy' into 'master'
Flip GLArea textures

See merge request GNOME/gtk!2634
2020-09-28 16:16:51 +00:00
Matthias Clasen ff61f35b77 Merge branch 'cloudproviders-ci' into 'master'
Cloudproviders ci

Closes #2480

See merge request GNOME/gtk!2632
2020-09-28 15:45:08 +00:00
Matthias Clasen 5206cfa837 Merge branch 'wip/otte/for-master' into 'master'
snapshot: Don't flip textures

See merge request GNOME/gtk!2633
2020-09-28 15:43:02 +00:00
Matthias Clasen b711c12bbe glarea: Flip our texture
The texture that produce is upside-down, compared to what
GSK expects, so flip things around with a transform.

This fixes the shadertoy demo being upside-down after a
recent fix to avoid downloading and reuploading the texture.
2020-09-28 11:34:23 -04:00
Matthias Clasen 431f144f37 gsk: Normalize when transforming bounds
Bounds are assumed to be normalized, and transforms
with negative scales or 3d rotations can make us get
negative sizes.

Fix by Benjamin Otte.
2020-09-28 11:34:16 -04:00
Benjamin Otte 651c92c0ed snapshot: Don't flip textures
... or gradients or borders or shadows. Instead, ensure that affines
have non-negative scale factors. Otherwise add a transform node.

The only place where this check is not necessary is color nodes, but
special casing them seems not worth it.
2020-09-28 16:14:28 +02:00
Milo Casagrande 8487e82133 Update Italian translation 2020-09-28 07:41:47 +00:00
Matthias Clasen 3aa2519c2b ci: Use v23 images
I added libcloudproviders to the base image, but
now I see that we already enabled libcloudproviders
in the build anyway, so I'm a bit confused.

Fixes: #2480
2020-09-27 11:48:19 -04:00
Matthias Clasen 55bd6d08d4 ci: Add libcloudproviders to the image
Add libcloudproviders to fedora-base:v23 and fedora:v23.
This is so we can enable the cloud-providers feature in
our ci builds.
2020-09-27 11:41:04 -04:00
nana-4 68379c3ff7 Adwaita: Simplify stackswitcher button styling
Simply use negative margins against the padding.

Also remove the indicator only when the .needs-attention style class is
removed.
2020-08-28 22:06:44 +09:00
Sean Farley 99dfdfcd5e Allow LPR backend to print PDF and PS file formats
At least from GTK v3.22.30, the code disallows attempts to print PDF and
PS files using the LPR backend. Although it is not easy or possible for
GTK to determine if the printer can print these formats by querying lpr,
the print backend should allow lpr to try.

There are two uses cases:
- A filter is being used by lpr, specified in the printcap file, to process the
  files prior to printing them.
- The printer can print PDF and PS files directly. There are many printers that
  can print these formats, so GTK should allow for the possibility.
2018-11-17 13:04:35 -05:00
449 changed files with 24914 additions and 55158 deletions
+5 -5
View File
@@ -16,13 +16,13 @@ stages:
# Common variables
variables:
COMMON_MESON_FLAGS: "--fatal-meson-warnings -Dgtk:werror=true"
COMMON_MESON_FLAGS: "-Dwerror=true -Dglib:werror=false -Dpango:werror=false -Dgtk-doc:werror=false -Dwayland-protocols:werror=false -Dsysprof:werror=false"
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v22"
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v26"
FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"
DOCS_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora-docs:v19"
DOCS_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora-docs:v26"
.only-default:
only:
@@ -74,7 +74,6 @@ fedora-x86_64:
script:
- meson subprojects update
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
-Dsysprof=enabled
_build
- ninja -C _build
- .gitlab-ci/run-tests.sh _build x11
@@ -100,6 +99,7 @@ installed-tests:
needs: []
variables:
EXTRA_MESON_FLAGS: "--prefix=/usr --libdir=/usr/lib64 -Dinstall-tests=true"
G_TEST_ACCESSIBLE: 1
script:
- meson subprojects update
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
@@ -223,7 +223,7 @@ asan-build:
needs: []
variables:
script:
- CC=clang meson --buildtype=debugoptimized -Db_sanitize=address -Db_lundef=false -Dintrospection=false _build
- CC=clang meson --buildtype=debugoptimized -Db_sanitize=address -Db_lundef=false -Dintrospection=disabled _build
- ninja -C _build
- .gitlab-ci/run-tests.sh _build wayland
artifacts:
+6 -3
View File
@@ -1,4 +1,4 @@
FROM fedora:31
FROM fedora:32
RUN dnf -y install \
adwaita-icon-theme \
@@ -44,8 +44,12 @@ RUN dnf -y install \
lcov \
libasan \
libattr-devel \
libcloudproviders-devel \
libepoxy-devel \
libffi-devel \
libglvnd-devel \
libglvnd-egl \
libglvnd-glx \
libmount-devel \
librsvg2 \
libselinux-devel \
@@ -64,7 +68,6 @@ RUN dnf -y install \
libxslt \
mesa-dri-drivers \
mesa-libEGL-devel \
mesa-libwayland-egl-devel \
ninja-build \
pango-devel \
pcre-devel \
@@ -86,5 +89,5 @@ RUN dnf -y install \
xorg-x11-server-Xvfb \
&& dnf clean all
RUN pip3 install meson==0.53.1
RUN pip3 install meson==0.55.3
+1 -1
View File
@@ -1,4 +1,4 @@
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v19
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v26
RUN dnf -y install pandoc
+1 -1
View File
@@ -1,4 +1,4 @@
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v21
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v26
# Enable sudo for wheel users
RUN sed -i -e 's/# %wheel/%wheel/' -e '0,/%wheel/{s/%wheel/# %wheel/}' /etc/sudoers
+1 -1
View File
@@ -22,7 +22,7 @@ flatpak build ${builddir} meson \
-Dprint-backends=file \
-Dbuild-tests=false \
-Dbuild-examples=false \
-Dintrospection=false \
-Dintrospection=disabled \
-Ddemos=true \
_flatpak_build
+1 -3
View File
@@ -60,14 +60,12 @@ pkg-config --modversion pango
ccache --zero-stats
ccache --show-stats
export CCACHE_DISABLE=true
# FIXME: introspection disabled for now because of
# https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/340
meson \
-Dx11-backend=false \
-Dwayland-backend=false \
-Dwin32-backend=true \
-Dvulkan=disabled \
-Dintrospection=false \
-Dintrospection=enabled \
-Dgtk:werror=true \
_build
unset CCACHE_DISABLE
+92 -23
View File
@@ -1,19 +1,103 @@
Overview of Changes in 3.99.3
=============================
* Accessibility:
- Add an initial AT-SPI backend
* GtkEmojiChooser:
- Allow inserting multiple Emoji by pressing Control
- Update Emoji data to Unicode 13 / CLDR 37
- Use translations
- The recent-emoji setting type changed. Call
gsettings reset org.gtk.gtk4.Settings.EmojiChooser recent-emoji
* GtkTextBuffer:
- Add boolean returns to some get_iter functions
* GtkScale:
- Change the default value of the :draw-value property
* GtkPopover:
- Avoid losing focus when popovers are close
* GtkColorChooser:
- Add color names back for accessibility
* Input methods:
- Add a 'private' input hint
* GL Renderer:
- Fix issues with texture caching
- Fix texture flipping problems
* Build:
- Use meson yield feature for some options
- Require gtk-doc 1.33
- Require sysprof 3.38
* Wayland:
- Clean up Wayland backend api, add annotations
- Generate introspection for Wayland backend api
* Windows:
- Fix modal window handling and window stacking
* MacOS:
- Fix the build
- Define GDK_WINDOWING_MACOS
- Fix various event handling issues
* Demos:
- Add another column view demo
- Add an svg paintable demo
* Translation updates
Czech
Lithuanian
Polish
Overview of Changes in GTK 3.99.2
=================================
* GtkButton:
- Check coordinates for button releases
* GtkColorChooser:
- Update the default palette
* GtkEntry:
- Fix issues with Emoji insertion
- Fix issues with dnd
- Set correct hotspot for dnd icon
* GtkFileChooser:
- Fix a crash
- Fix setting unlisted filters
* GtkFontChooser:
- Determine sample text based on font coverage (requires fontconfig)
- Allow filtering by language (requires fontconfig)
- Don't center the list
* GtkMenuButton:
- Always use the direction property for the arrow
* GtkPasswordEntry:
- Use non-pageable memory
- Add an ::activate signal
* GtkRevealer:
- Fix clipping issues in the swing transitions
* GtkScrolledWindow:
- Fix kinetic scrolling in X11
* GtkSearchEntry:
- Don't handle forwarded events twice
* GtkPasswordEntry:
- Add an ::activate signal
* GtkStack:
- Add gtk_stack_add_child
* GtkTextView:
- Fix dnd
@@ -22,30 +106,9 @@ Overview of Changes in GTK 3.99.2
- Make clickable links work again
- Fix handling of anchored children
* GtkRevealer:
- Fix clipping issues in the swing transitions
* GtkColorChooser:
- Update the default palette
* GtkFileChooser:
- Fix a crash
- Fix setting unlisted filters
* GtkFontChooser:
- Determine sample text based on font coverage
- Allow filtering by language
- Don't center the list
* GtkStack:
- Add gtk_stack_add_child
* GtkVideo:
- Make autoplay work
* GtkButton:
- Check coordinates for button releases
* CSS:
- Allow more than 64 selectors per rule
- Avoid some allocation overhead
@@ -62,12 +125,15 @@ Overview of Changes in GTK 3.99.2
* GSK:
- Add radial gradient nodes
- Add GskGLShader and shader nodes
* GL renderer:
- Fix clipping with projective transforms
- Use linear interpolation for offscreen rendering
with non-axis-aligned transforms
- Fix texture caching to avoid size mismatches
- Avoid downloading GL textures when possible,
improving GtkGLArea performance
* Vulkan renderer:
- Fix swapchain creation
@@ -77,6 +143,7 @@ Overview of Changes in GTK 3.99.2
* Wayland
- Always ack configure to avoid jumping windows
- Use the primary-selection-unstable-v1 protocol
* API cleanups:
- Make filter and sorter constructors return exact types
@@ -95,6 +162,7 @@ Overview of Changes in GTK 3.99.2
- Cosmetic improvements for several demos
- Improve search in the sidebar
- Add a Shadertoy demo
- Add a OpenGL transitions demo
- Add an Emblem demo
- Add a demo for input validation and error states
- Add a demo for context menus
@@ -114,6 +182,7 @@ Overview of Changes in GTK 3.99.2
French
Galician
German
Hebrew
Hungarian
Indonesian
Italian
+26
View File
@@ -0,0 +1,26 @@
uniform float u_time;
void
mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv)
{
vec2 pos = (fragCoord.xy * 2.0 - resolution.xy)/ min (resolution.x, resolution.y) ;
float t0 = sin ((u_time + 0.00)*1.0);
float t1 = sin ((u_time + 0.30)*0.4);
float t2 = cos ((u_time + 0.23)*0.9);
float t3 = cos ((u_time + 0.41)*0.6);
float t4 = cos ((u_time + 0.11)*0.3);
vec2 p0 = vec2 (t1, t0) ;
vec2 p1 = vec2 (t2, t3) ;
vec2 p2 = vec2 (t4, t3) ;
float r = 1.0/distance (pos, p0);
float g = 1.0/distance (pos, p1);
float b = 1.0/distance (pos, p2);
float sum = r + g + b;
float alpha = 1.0 - pow (1.0/(sum), 40)*pow (10.0, 40*0.7);
fragColor = vec4 (r*0.5, g*0.5, b*0.5, 1.0) * alpha;
}
-1
View File
@@ -158,7 +158,6 @@ do_builder (GtkWidget *do_widget)
about = GTK_WIDGET (gtk_builder_get_object (builder, "aboutdialog1"));
gtk_window_set_transient_for (GTK_WINDOW (about), GTK_WINDOW (window));
gtk_window_set_hide_on_close (GTK_WINDOW (about), TRUE);
g_signal_connect (about, "response", G_CALLBACK (gtk_widget_hide), NULL);
g_object_set_data_full (G_OBJECT (window), "about",
about, (GDestroyNotify)gtk_window_destroy);
+226
View File
@@ -0,0 +1,226 @@
uniform float iTime;
// Originally from: https://www.shadertoy.com/view/3ljyDD
// License CC0: Hexagonal tiling + cog wheels
// Nothing fancy, just hexagonal tiling + cog wheels
#define PI 3.141592654
#define TAU (2.0*PI)
#define MROT(a) mat2(cos(a), sin(a), -sin(a), cos(a))
float hash(in vec2 co) {
return fract(sin(dot(co.xy ,vec2(12.9898,58.233))) * 13758.5453);
}
float pcos(float a) {
return 0.5 + 0.5*cos(a);
}
void rot(inout vec2 p, float a) {
float c = cos(a);
float s = sin(a);
p = vec2(c*p.x + s*p.y, -s*p.x + c*p.y);
}
float modPolar(inout vec2 p, float repetitions) {
float angle = 2.0*PI/repetitions;
float a = atan(p.y, p.x) + angle/2.;
float r = length(p);
float c = floor(a/angle);
a = mod(a,angle) - angle/2.;
p = vec2(cos(a), sin(a))*r;
// For an odd number of repetitions, fix cell index of the cell in -x direction
// (cell index would be e.g. -5 and 5 in the two halves of the cell):
if (abs(c) >= (repetitions/2.0)) c = abs(c);
return c;
}
float pmin(float a, float b, float k) {
float h = clamp( 0.5+0.5*(b-a)/k, 0.0, 1.0 );
return mix( b, a, h ) - k*h*(1.0-h);
}
const vec2 sz = vec2(1.0, sqrt(3.0));
const vec2 hsz = 0.5*sz;
const float smallCount = 16.0;
vec2 hextile(inout vec2 p) {
// See Art of Code: Hexagonal Tiling Explained!
// https://www.youtube.com/watch?v=VmrIDyYiJBA
vec2 p1 = mod(p, sz)-hsz;
vec2 p2 = mod(p - hsz*1.0, sz)-hsz;
vec2 p3 = mix(p2, p1, vec2(length(p1) < length(p2)));
vec2 n = p3 - p;
p = p3;
return n;
}
float circle(vec2 p, float r) {
return length(p) - r;
}
float box(vec2 p, vec2 b) {
vec2 d = abs(p)-b;
return length(max(d,0.0)) + min(max(d.x,d.y),0.0);
}
float unevenCapsule(vec2 p, float r1, float r2, float h) {
p.x = abs(p.x);
float b = (r1-r2)/h;
float a = sqrt(1.0-b*b);
float k = dot(p,vec2(-b,a));
if( k < 0.0 ) return length(p) - r1;
if( k > a*h ) return length(p-vec2(0.0,h)) - r2;
return dot(p, vec2(a,b) ) - r1;
}
float cogwheel(vec2 p, float innerRadius, float outerRadius, float cogs, float holes) {
float cogWidth = 0.25*innerRadius*TAU/cogs;
float d0 = circle(p, innerRadius);
vec2 icp = p;
modPolar(icp, holes);
icp -= vec2(innerRadius*0.55, 0.0);
float d1 = circle(icp, innerRadius*0.25);
vec2 cp = p;
modPolar(cp, cogs);
cp -= vec2(innerRadius, 0.0);
float d2 = unevenCapsule(cp.yx, cogWidth, cogWidth*0.75, (outerRadius-innerRadius));
float d3 = circle(p, innerRadius*0.20);
float d = 1E6;
d = min(d, d0);
d = pmin(d, d2, 0.5*cogWidth);
d = min(d, d2);
d = max(d, -d1);
d = max(d, -d3);
return d;
}
float ccell1(vec2 p, float r) {
float d = 1E6;
const float bigCount = 60.0;
vec2 cp0 = p;
rot(cp0, -iTime*TAU/bigCount);
float d0 = cogwheel(cp0, 0.36, 0.38, bigCount, 5.0);
vec2 cp1 = p;
float nm = modPolar(cp1, 6.0);
cp1 -= vec2(0.5, 0.0);
rot(cp1, 0.2+TAU*nm/2.0 + iTime*TAU/smallCount);
float d1 = cogwheel(cp1, 0.11, 0.125, smallCount, 5.0);
d = min(d, d0);
d = min(d, d1);
return d;
}
float ccell2(vec2 p, float r) {
float d = 1E6;
vec2 cp0 = p;
float nm = modPolar(cp0, 6.0);
vec2 cp1 = cp0;
const float off = 0.275;
const float count = smallCount + 2.0;
cp0 -= vec2(off, 0.0);
rot(cp0, 0.+TAU*nm/2.0 - iTime*TAU/count);
float d0 = cogwheel(cp0, 0.09, 0.105, count, 5.0);
cp1 -= vec2(0.5, 0.0);
rot(cp1, 0.2+TAU*nm/2.0 + iTime*TAU/smallCount);
float d1 = cogwheel(cp1, 0.11, 0.125, smallCount, 5.0);
float l = length(p);
float d2 = l - (off+0.055);
float d3 = d2 + 0.020;;
vec2 tp0 = p;
modPolar(tp0, 60.0);
tp0.x -= off;
float d4 = box(tp0, vec2(0.0125, 0.005));
float ctime = -(iTime*0.05 + r)*TAU;
vec2 tp1 = p;
rot(tp1, ctime*12.0);
tp1.x -= 0.13;
float d5 = box(tp1, vec2(0.125, 0.005));
vec2 tp2 = p;
rot(tp2, ctime);
tp2.x -= 0.13*0.5;
float d6 = box(tp2, vec2(0.125*0.5, 0.0075));
float d7 = l - 0.025;
float d8 = l - 0.0125;
d = min(d, d0);
d = min(d, d1);
d = min(d, d2);
d = max(d, -d3);
d = min(d, d4);
d = min(d, d5);
d = min(d, d6);
d = min(d, d7);
d = max(d, -d8);
return d;
}
float df(vec2 p, float scale, inout vec2 nn) {
p /= scale;
nn = hextile(p);
nn = round(nn);
float r = hash(nn);
float d;;
if (r < 0.5) {
d = ccell1(p, r);
} else {
d = ccell2(p, r);
}
return d*scale;
}
vec3 postProcess(vec3 col, vec2 q) {
//col = saturate(col);
col=pow(clamp(col,0.0,1.0),vec3(0.75));
col=col*0.6+0.4*col*col*(3.0-2.0*col); // contrast
col=mix(col, vec3(dot(col, vec3(0.33))), -0.4); // satuation
col*=0.5+0.5*pow(19.0*q.x*q.y*(1.0-q.x)*(1.0-q.y),0.7); // vigneting
return col;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv) {
vec2 q = fragCoord/resolution.xy;
vec2 p = -1.0 + 2.0*q;
p.x *= resolution.x/resolution.y;
float tm = iTime*0.1;
p += vec2(cos(tm), sin(tm*sqrt(0.5)));
float z = mix(0.5, 1.0, pcos(tm*sqrt(0.3)));
float aa = 4.0 / resolution.y;
vec2 nn = vec2(0.0);
float d = df(p, z, nn);
vec3 col = vec3(160.0)/vec3(255.0);
vec3 baseCol = vec3(0.3);
vec4 logoCol = vec4(baseCol, 1.0)*smoothstep(-aa, 0.0, -d);
col = mix(col, logoCol.xyz, pow(logoCol.w, 8.0));
col += 0.4*pow(abs(sin(20.0*d)), 0.6);
col = postProcess(col, q);
fragColor = vec4(col, 1.0);
}
+27
View File
@@ -0,0 +1,27 @@
uniform float progress;
uniform sampler2D u_texture1;
uniform sampler2D u_texture2;
vec4 getFromColor (vec2 uv) {
return GskTexture(u_texture1, uv);
}
vec4 getToColor (vec2 uv) {
return GskTexture(u_texture2, uv);
}
// Source: https://gl-transitions.com/editor/crosswarp
// Author: Eke Péter <peterekepeter@gmail.com>
// License: MIT
vec4 transition(vec2 p) {
float x = progress;
x=smoothstep(.0,1.0,(x*2.0+p.x-1.0));
return mix(getFromColor((p-.5)*(1.-x)+.5), getToColor((p-.5)*x+.5), x);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv)
{
fragColor = transition(uv);
}
+24
View File
@@ -133,6 +133,21 @@
<file>cogs.glsl</file>
<file>glowingstars.glsl</file>
</gresource>
<gresource prefix="/gltransition">
<file>gtkshaderstack.c</file>
<file>gtkshaderstack.h</file>
<file>gtkshaderbin.h</file>
<file>gtkshaderbin.c</file>
<file>gskshaderpaintable.h</file>
<file>gskshaderpaintable.c</file>
<file>wind.glsl</file>
<file>radial.glsl</file>
<file>crosswarp.glsl</file>
<file>kaleidoscope.glsl</file>
<file>cogs2.glsl</file>
<file>ripple.glsl</file>
<file>background.glsl</file>
</gresource>
<gresource prefix="/iconscroll">
<file>iconscroll.ui</file>
</gresource>
@@ -169,6 +184,9 @@
<gresource prefix="/listview_settings">
<file>listview_settings.ui</file>
</gresource>
<gresource prefix="/listview_ucd_data/">
<file>ucdnames.data</file>
</gresource>
<gresource prefix="/listview_weather">
<file compressed="true">listview_weather.txt</file>
</gresource>
@@ -186,6 +204,9 @@
<file>demo3widget.h</file>
<file>demo3widget.ui</file>
</gresource>
<gresource prefix="/paintable_svg">
<file>org.gtk.gtk4.NodeEditor.Devel.svg</file>
</gresource>
<gresource prefix="/shortcuts">
<file>shortcuts.ui</file>
<file>shortcuts-builder.ui</file>
@@ -247,6 +268,7 @@
<file>gears.c</file>
<file>gestures.c</file>
<file>glarea.c</file>
<file>gltransition.c</file>
<file>headerbar.c</file>
<file>hypertext.c</file>
<file>iconscroll.c</file>
@@ -265,6 +287,7 @@
<file>listview_filebrowser.c</file>
<file>listview_minesweeper.c</file>
<file>listview_settings.c</file>
<file>listview_ucd.c</file>
<file>listview_weather.c</file>
<file>listview_words.c</file>
<file>list_store.c</file>
@@ -279,6 +302,7 @@
<file>paintable_animated.c</file>
<file>paintable_emblem.c</file>
<file>paintable_mediastream.c</file>
<file>paintable_svg.c</file>
<file>panes.c</file>
<file>password_entry.c</file>
<file>peg_solitaire.c</file>
+33 -7
View File
@@ -47,6 +47,38 @@ get_image_paintable (GtkImage *image)
}
}
static void
update_drag_icon (DemoImage *demo,
GtkDragIcon *icon)
{
const char *icon_name;
GdkPaintable *paintable;
GtkWidget *image;
switch (gtk_image_get_storage_type (GTK_IMAGE (demo->image)))
{
case GTK_IMAGE_PAINTABLE:
paintable = gtk_image_get_paintable (GTK_IMAGE (demo->image));
image = gtk_image_new_from_paintable (paintable);
break;
case GTK_IMAGE_ICON_NAME:
icon_name = gtk_image_get_icon_name (GTK_IMAGE (demo->image));
image = gtk_image_new_from_icon_name (icon_name);
break;
case GTK_IMAGE_EMPTY:
case GTK_IMAGE_GICON:
default:
g_warning ("Image storage type %d not handled",
gtk_image_get_storage_type (GTK_IMAGE (demo->image)));
return;
}
gtk_image_set_pixel_size (GTK_IMAGE (image),
gtk_image_get_pixel_size (GTK_IMAGE (demo->image)));
gtk_drag_icon_set_child (icon, image);
}
static void
drag_begin (GtkDragSource *source,
GdkDrag *drag,
@@ -54,14 +86,8 @@ drag_begin (GtkDragSource *source,
{
GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
DemoImage *demo = DEMO_IMAGE (widget);
GdkPaintable *paintable;
paintable = get_image_paintable (GTK_IMAGE (demo->image));
if (paintable)
{
gtk_drag_icon_set_from_paintable (drag, paintable, -2, -2);
g_object_unref (paintable);
}
update_drag_icon (demo, GTK_DRAG_ICON (gtk_drag_icon_get_for_drag (drag)));
}
static GdkContentProvider *
+34
View File
@@ -9,6 +9,7 @@
#include "gtkfishbowl.h"
#include "gtkgears.h"
#include "gskshaderpaintable.h"
const char *const css =
".blurred-button {"
@@ -149,6 +150,38 @@ create_switch (void)
return w;
}
static gboolean
update_paintable (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer user_data)
{
GskShaderPaintable *paintable;
gint64 frame_time;
paintable = GSK_SHADER_PAINTABLE (gtk_picture_get_paintable (GTK_PICTURE (widget)));
frame_time = gdk_frame_clock_get_frame_time (frame_clock);
gsk_shader_paintable_update_time (paintable, 0, frame_time);
return G_SOURCE_CONTINUE;
}
static GtkWidget *
create_cogs (void)
{
GtkWidget *picture;
static GskGLShader *cog_shader = NULL;
GdkPaintable *paintable;
if (cog_shader == NULL)
cog_shader = gsk_gl_shader_new_from_resource ("/gltransition/cogs2.glsl");
paintable = gsk_shader_paintable_new (g_object_ref (cog_shader), NULL);
picture = gtk_picture_new_for_paintable (paintable);
gtk_widget_set_size_request (picture, 150, 75);
gtk_widget_add_tick_callback (picture, update_paintable, NULL, NULL);
return picture;
}
static void
mapped (GtkWidget *w)
{
@@ -185,6 +218,7 @@ static const struct {
{ "Gears", create_gears },
{ "Switch", create_switch },
{ "Menubutton", create_menu_button },
{ "Shader", create_cogs },
};
static int selected_widget_type = -1;
+1
View File
@@ -406,6 +406,7 @@ create_glarea_window (GtkWidget *do_widget)
gl_area = gtk_gl_area_new ();
gtk_widget_set_hexpand (gl_area, TRUE);
gtk_widget_set_vexpand (gl_area, TRUE);
gtk_widget_set_size_request (gl_area, 100, 200);
gtk_box_append (GTK_BOX (box), gl_area);
/* We need to initialize and free GL resources, so we use
+350
View File
@@ -0,0 +1,350 @@
/* OpenGL/Transitions
* #Keywords: OpenGL, shader, effect
*
* Create transitions between pages using a custom fragment shader.
*
* The example transitions here are taken from gl-transitions.com, and you
* can edit the shader code itself on the last page of the stack.
*
* The transitions work with arbitrary content. We use images, shaders
* GL areas and plain old widgets to demonstrate this.
*
* The demo also shows some over-the-top effects like wobbly widgets,
* and animated backgrounds.
*/
#include <math.h>
#include <gtk/gtk.h>
#include "gtkshaderstack.h"
#include "gtkshaderbin.h"
#include "gtkshadertoy.h"
#include "gskshaderpaintable.h"
static GtkWidget *demo_window = NULL;
static void
close_window (GtkWidget *widget)
{
/* Reset the state */
demo_window = NULL;
}
static void
text_changed (GtkTextBuffer *buffer,
GtkWidget *button)
{
gtk_widget_show (button);
}
static void
apply_text (GtkWidget *button,
GtkTextBuffer *buffer)
{
GtkWidget *stack;
GskGLShader *shader;
GtkTextIter start, end;
char *text;
stack = g_object_get_data (G_OBJECT (button), "the-stack");
gtk_text_buffer_get_bounds (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
GBytes *bytes = g_bytes_new_take (text, strlen (text));
shader = gsk_gl_shader_new_from_bytes (bytes);
gtk_shader_stack_set_shader (GTK_SHADER_STACK (stack), shader);
g_object_unref (shader);
g_bytes_unref (bytes);
gtk_widget_hide (button);
}
static void
go_back (GtkWidget *button,
GtkWidget *stack)
{
gtk_shader_stack_transition (GTK_SHADER_STACK (stack), FALSE);
}
static void
go_forward (GtkWidget *button,
GtkWidget *stack)
{
gtk_shader_stack_transition (GTK_SHADER_STACK (stack), TRUE);
}
static void
clicked_cb (GtkGestureClick *gesture,
guint n_pressed,
double x,
double y,
gpointer data)
{
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
}
static GtkWidget *
ripple_bin_new (void)
{
GtkWidget *bin = gtk_shader_bin_new ();
static GskGLShader *shader = NULL;
if (shader == NULL)
shader = gsk_gl_shader_new_from_resource ("/gltransition/ripple.glsl");
gtk_shader_bin_add_shader (GTK_SHADER_BIN (bin), shader, GTK_STATE_FLAG_PRELIGHT, GTK_STATE_FLAG_PRELIGHT, 20);
return bin;
}
static GtkWidget *
new_shadertoy (const char *path)
{
GBytes *shader;
GtkWidget *toy;
toy = gtk_shadertoy_new ();
shader = g_resources_lookup_data (path, 0, NULL);
gtk_shadertoy_set_image_shader (GTK_SHADERTOY (toy),
g_bytes_get_data (shader, NULL));
g_bytes_unref (shader);
return toy;
}
static gboolean
update_paintable (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer user_data)
{
GskShaderPaintable *paintable;
gint64 frame_time;
paintable = GSK_SHADER_PAINTABLE (gtk_picture_get_paintable (GTK_PICTURE (widget)));
frame_time = gdk_frame_clock_get_frame_time (frame_clock);
gsk_shader_paintable_update_time (paintable, 0, frame_time);
return G_SOURCE_CONTINUE;
}
static GtkWidget *
make_shader_stack (const char *name,
const char *resource_path,
int active_child,
GtkWidget *scale)
{
GtkWidget *stack, *child, *widget, *vbox, *hbox, *bin;
GtkWidget *label, *button, *tv;
GskGLShader *shader;
GObjectClass *class;
GParamSpecFloat *pspec;
GtkAdjustment *adjustment;
GtkTextBuffer *buffer;
GBytes *bytes;
GtkEventController *controller;
GtkCssProvider *provider;
GdkPaintable *paintable;
stack = gtk_shader_stack_new ();
shader = gsk_gl_shader_new_from_resource (resource_path);
gtk_shader_stack_set_shader (GTK_SHADER_STACK (stack), shader);
g_object_unref (shader);
child = gtk_picture_new_for_resource ("/css_blendmodes/ducky.png");
gtk_picture_set_can_shrink (GTK_PICTURE (child), TRUE);
gtk_shader_stack_add_child (GTK_SHADER_STACK (stack), child);
shader = gsk_gl_shader_new_from_resource ("/gltransition/cogs2.glsl");
paintable = gsk_shader_paintable_new (shader, NULL);
child = gtk_picture_new_for_paintable (paintable);
gtk_widget_add_tick_callback (child, update_paintable, NULL, NULL);
gtk_picture_set_can_shrink (GTK_PICTURE (child), TRUE);
gtk_shader_stack_add_child (GTK_SHADER_STACK (stack), child);
child = gtk_picture_new_for_resource ("/transparent/portland-rose.jpg");
gtk_picture_set_can_shrink (GTK_PICTURE (child), TRUE);
gtk_shader_stack_add_child (GTK_SHADER_STACK (stack), child);
child = new_shadertoy ("/shadertoy/neon.glsl");
gtk_shader_stack_add_child (GTK_SHADER_STACK (stack), child);
child = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
class = g_type_class_ref (GTK_TYPE_SHADER_STACK);
pspec = G_PARAM_SPEC_FLOAT (g_object_class_find_property (class, "duration"));
adjustment = gtk_range_get_adjustment (GTK_RANGE (scale));
if (gtk_adjustment_get_lower (adjustment) == 0.0 &&
gtk_adjustment_get_upper (adjustment) == 0.0)
{
gtk_adjustment_configure (adjustment,
pspec->default_value,
pspec->minimum,
pspec->maximum,
0.1, 0.5, 0);
}
g_type_class_unref (class);
g_object_bind_property (adjustment, "value",
stack, "duration",
G_BINDING_DEFAULT);
widget = gtk_scrolled_window_new ();
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (widget), TRUE);
gtk_widget_set_hexpand (widget, TRUE);
gtk_widget_set_vexpand (widget, TRUE);
controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0);
g_signal_connect (controller, "released", G_CALLBACK (clicked_cb), NULL);
gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_BUBBLE);
gtk_widget_add_controller (GTK_WIDGET (widget), controller);
tv = gtk_text_view_new ();
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (tv), 4);
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (tv), 4);
gtk_text_view_set_top_margin (GTK_TEXT_VIEW (tv), 4);
gtk_text_view_set_bottom_margin (GTK_TEXT_VIEW (tv), 4);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tv));
bytes = g_resources_lookup_data (resource_path, 0, NULL);
gtk_text_buffer_set_text (buffer,
(const char *)g_bytes_get_data (bytes, NULL),
g_bytes_get_size (bytes));
g_bytes_unref (bytes);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (widget), tv);
gtk_box_append (GTK_BOX (child), widget);
gtk_shader_stack_add_child (GTK_SHADER_STACK (stack), child);
gtk_shader_stack_set_active (GTK_SHADER_STACK (stack), active_child);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
widget = gtk_center_box_new ();
label = gtk_label_new (name);
gtk_widget_add_css_class (label, "title-4");
gtk_widget_set_size_request (label, -1, 26);
gtk_center_box_set_center_widget (GTK_CENTER_BOX (widget), label);
button = gtk_button_new_from_icon_name ("view-refresh-symbolic");
g_signal_connect (buffer, "changed", G_CALLBACK (text_changed), button);
g_object_set_data (G_OBJECT (button), "the-stack", stack);
g_signal_connect (button, "clicked", G_CALLBACK (apply_text), buffer);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, "button.small { padding: 0; }", -1);
gtk_style_context_add_provider (gtk_widget_get_style_context (button),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_widget_add_css_class (button, "small");
gtk_widget_hide (button);
gtk_center_box_set_end_widget (GTK_CENTER_BOX (widget), button);
gtk_box_append (GTK_BOX (vbox), widget);
GtkWidget *bin2 = ripple_bin_new ();
gtk_shader_bin_set_child (GTK_SHADER_BIN (bin2), stack);
gtk_box_append (GTK_BOX (vbox), bin2);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_widget_set_halign (hbox, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (vbox), hbox);
button = gtk_button_new_from_icon_name ("go-previous-symbolic");
g_signal_connect (button, "clicked", G_CALLBACK (go_back), stack);
bin = ripple_bin_new ();
gtk_shader_bin_set_child (GTK_SHADER_BIN (bin), button);
gtk_box_append (GTK_BOX (hbox), bin);
button = gtk_button_new_from_icon_name ("go-next-symbolic");
g_signal_connect (button, "clicked", G_CALLBACK (go_forward), stack);
bin = ripple_bin_new ();
gtk_shader_bin_set_child (GTK_SHADER_BIN (bin), button);
gtk_box_append (GTK_BOX (hbox), bin);
return vbox;
}
static GtkWidget *
create_gltransition_window (GtkWidget *do_widget)
{
GtkWidget *window, *headerbar, *scale, *outer_grid, *grid, *background;
GdkPaintable *paintable;
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Transitions");
headerbar = gtk_header_bar_new ();
scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, NULL);
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
gtk_widget_set_size_request (scale, 100, -1);
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), scale);
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);
outer_grid = gtk_grid_new ();
gtk_window_set_child (GTK_WINDOW (window), outer_grid);
paintable = gsk_shader_paintable_new (gsk_gl_shader_new_from_resource ("/gltransition/background.glsl"), NULL);
background = gtk_picture_new_for_paintable (paintable);
gtk_widget_add_tick_callback (background, update_paintable, NULL, NULL);
gtk_grid_attach (GTK_GRID (outer_grid),
background,
0, 0, 1, 1);
grid = gtk_grid_new ();
gtk_grid_attach (GTK_GRID (outer_grid),
grid,
0, 0, 1, 1);
gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
gtk_widget_set_valign (grid, GTK_ALIGN_CENTER);
gtk_widget_set_margin_start (grid, 12);
gtk_widget_set_margin_end (grid, 12);
gtk_widget_set_margin_top (grid, 12);
gtk_widget_set_margin_bottom (grid, 12);
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);
gtk_grid_attach (GTK_GRID (grid),
make_shader_stack ("Wind", "/gltransition/wind.glsl", 0, scale),
0, 0, 1, 1);
gtk_grid_attach (GTK_GRID (grid),
make_shader_stack ("Radial", "/gltransition/radial.glsl", 1, scale),
1, 0, 1, 1);
gtk_grid_attach (GTK_GRID (grid),
make_shader_stack ("Crosswarp", "/gltransition/crosswarp.glsl", 2, scale),
0, 1, 1, 1);
gtk_grid_attach (GTK_GRID (grid),
make_shader_stack ("Kaleidoscope", "/gltransition/kaleidoscope.glsl", 3, scale),
1, 1, 1, 1);
return window;
}
GtkWidget *
do_gltransition (GtkWidget *do_widget)
{
if (!demo_window)
demo_window = create_gltransition_window (do_widget);
if (!gtk_widget_get_visible (demo_window))
gtk_widget_show (demo_window);
else
gtk_window_destroy (GTK_WINDOW (demo_window));
return demo_window;
}
+337
View File
@@ -0,0 +1,337 @@
/*
* Copyright © 2020 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.1 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/>.
*
* Authors: Matthias Clasen <mclasen@redhat.com>
*/
#include "config.h"
#include <gtk/gtk.h>
#include "gskshaderpaintable.h"
/**
* SECTION:gskshaderpaintable
* @Short_description: Drawing with shaders
* @Title: GskShaderPaintable
* @see_also: #GdkPaintable
*
* GskShaderPaintable is an implementation of the #GdkPaintable interface
* that uses a #GskGLShader to create pixels.
*
* You can set the uniform data that the shader needs for rendering
* using gsk_shader_paintable_set_args(). This function can
* be called repeatedly to change the uniform data for the next
* snapshot.
*
* Commonly, time is passed to shaders as a float uniform containing
* the elapsed time in seconds. The convenience API
* gsk_shader_paintable_update_time() can be called from a #GtkTickCallback
* to update the time based on the frame time of the frame clock.
*/
struct _GskShaderPaintable
{
GObject parent_instance;
GskGLShader *shader;
GBytes *args;
gint64 start_time;
};
struct _GskShaderPaintableClass
{
GObjectClass parent_class;
};
enum {
PROP_0,
PROP_SHADER,
PROP_ARGS,
N_PROPS,
};
static GParamSpec *properties[N_PROPS] = { NULL, };
static void
gsk_shader_paintable_paintable_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
double width,
double height)
{
GskShaderPaintable *self = GSK_SHADER_PAINTABLE (paintable);
gtk_snapshot_push_gl_shader (snapshot, self->shader, &GRAPHENE_RECT_INIT(0, 0, width, height), g_bytes_ref (self->args));
gtk_snapshot_pop (snapshot);
}
static void
gsk_shader_paintable_paintable_init (GdkPaintableInterface *iface)
{
iface->snapshot = gsk_shader_paintable_paintable_snapshot;
}
G_DEFINE_TYPE_EXTENDED (GskShaderPaintable, gsk_shader_paintable, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
gsk_shader_paintable_paintable_init))
static void
gsk_shader_paintable_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GskShaderPaintable *self = GSK_SHADER_PAINTABLE (object);
switch (prop_id)
{
case PROP_SHADER:
gsk_shader_paintable_set_shader (self, g_value_get_object (value));
break;
case PROP_ARGS:
gsk_shader_paintable_set_args (self, g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gsk_shader_paintable_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GskShaderPaintable *self = GSK_SHADER_PAINTABLE (object);
switch (prop_id)
{
case PROP_SHADER:
g_value_set_object (value, self->shader);
break;
case PROP_ARGS:
g_value_set_boxed (value, self->args);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gsk_shader_paintable_finalize (GObject *object)
{
GskShaderPaintable *self = GSK_SHADER_PAINTABLE (object);
g_clear_pointer (&self->args, g_bytes_unref);
g_clear_object (&self->shader);
G_OBJECT_CLASS (gsk_shader_paintable_parent_class)->finalize (object);
}
static void
gsk_shader_paintable_class_init (GskShaderPaintableClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->get_property = gsk_shader_paintable_get_property;
gobject_class->set_property = gsk_shader_paintable_set_property;
gobject_class->finalize = gsk_shader_paintable_finalize;
properties[PROP_SHADER] =
g_param_spec_object ("shader", "Shader", "The shader",
GSK_TYPE_GL_SHADER,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
properties[PROP_ARGS] =
g_param_spec_boxed ("args", "Arguments", "The uniform arguments",
G_TYPE_BYTES,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
}
static void
gsk_shader_paintable_init (GskShaderPaintable *self)
{
}
/**
* gsk_shader_paintable_new:
* @shader: (transfer full) (nullable): the shader to use
* @data: (transfer full) (nullable): uniform data
*
* Creates a paintable that uses the @shader to create
* pixels. The shader must not require input textures.
* If @data is %NULL, all uniform values are set to zero.
*
* Returns: (transfer full): a new #GskShaderPaintable
*/
GdkPaintable *
gsk_shader_paintable_new (GskGLShader *shader,
GBytes *data)
{
GdkPaintable *ret;
g_return_val_if_fail (shader == NULL || GSK_IS_GL_SHADER (shader), NULL);
if (shader && !data)
{
int size = gsk_gl_shader_get_args_size (shader);
data = g_bytes_new_take (g_new0 (guchar, size), size);
}
ret = g_object_new (GSK_TYPE_SHADER_PAINTABLE,
"shader", shader,
"args", data,
NULL);
g_clear_object (&shader);
g_clear_pointer (&data, g_bytes_unref);
return ret;
}
/**
* gsk_shader_paintable_set_shader:
* @self: a #GskShaderPaintable
* @shader: the #GskGLShader to use
*
* Sets the shader that the paintable will use
* to create pixels. The shader must not require
* input textures.
*/
void
gsk_shader_paintable_set_shader (GskShaderPaintable *self,
GskGLShader *shader)
{
g_return_if_fail (GSK_IS_SHADER_PAINTABLE (self));
g_return_if_fail (shader == NULL || GSK_IS_GL_SHADER (shader));
g_return_if_fail (shader == NULL || gsk_gl_shader_get_n_textures (shader) == 0);
if (!g_set_object (&self->shader, shader))
return;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHADER]);
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
g_clear_pointer (&self->args, g_bytes_unref);
}
/**
* gsk_shader_paintable_get_shader:
* @self: a #GskShaderPaintable
*
* Returns the shader that the paintable is using.
*
* Returns: (transfer none): the #GskGLShader that is used
*/
GskGLShader *
gsk_shader_paintable_get_shader (GskShaderPaintable *self)
{
g_return_val_if_fail (GSK_IS_SHADER_PAINTABLE (self), NULL);
return self->shader;
}
/**
* gsk_shader_paintable_set_args:
* @self: a #GskShaderPaintable
* @data: Data block with uniform data for the shader
*
* Sets the uniform data that will be passed to the
* shader when rendering. The @data will typically
* be produced by a #GskUniformDataBuilder.
*
* Note that the @data should be considered immutable
* after it has been passed to this function.
*/
void
gsk_shader_paintable_set_args (GskShaderPaintable *self,
GBytes *data)
{
g_return_if_fail (GSK_IS_SHADER_PAINTABLE (self));
g_return_if_fail (data == NULL || g_bytes_get_size (data) == gsk_gl_shader_get_args_size (self->shader));
g_clear_pointer (&self->args, g_bytes_unref);
if (data)
self->args = g_bytes_ref (data);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ARGS]);
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
}
/**
* gsk_shader_paintable_get_args:
* @self: a #GskShaderPaintable
*
* Returns the uniform data set with
* gsk_shader_paintable_get_args().
*
* Returns: (transfer none): the uniform data
*/
GBytes *
gsk_shader_paintable_get_args (GskShaderPaintable *self)
{
g_return_val_if_fail (GSK_IS_SHADER_PAINTABLE (self), NULL);
return self->args;
}
/**
* gsk_shader_paintable_update_time:
* @self: a #GskShaderPaintable
* @time_idx: the index of the uniform for time in seconds as float
* @frame_time: the current frame time, as returned by #GdkFrameClock
*
* This function is a convenience wrapper for
* gsk_shader_paintable_set_args() that leaves all
* uniform values unchanged, except for the uniform with
* index @time_idx, which will be set to the elapsed time
* in seconds, since the first call to this function.
*
* This function is usually called from a #GtkTickCallback.
*/
void
gsk_shader_paintable_update_time (GskShaderPaintable *self,
int time_idx,
gint64 frame_time)
{
GskShaderArgsBuilder *builder;
GBytes *args;
float time;
if (self->start_time == 0)
self->start_time = frame_time;
time = (frame_time - self->start_time) / (float)G_TIME_SPAN_SECOND;
builder = gsk_shader_args_builder_new (self->shader, self->args);
gsk_shader_args_builder_set_float (builder, time_idx, time);
args = gsk_shader_args_builder_free_to_args (builder);
gsk_shader_paintable_set_args (self, args);
g_bytes_unref (args);
}
+53
View File
@@ -0,0 +1,53 @@
/*
* Copyright © 2020 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.1 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/>.
*
* Authors: Matthias Clasen <mclasen@redhat.com>
*/
#ifndef __GSK_SHADER_PAINTABLE_H__
#define __GSK_SHADER_PAINTABLE_H__
#include <gdk/gdk.h>
#include <gsk/gsk.h>
G_BEGIN_DECLS
#define GSK_TYPE_SHADER_PAINTABLE (gsk_shader_paintable_get_type ())
GDK_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (GskShaderPaintable, gsk_shader_paintable, GSK, SHADER_PAINTABLE, GObject)
GDK_AVAILABLE_IN_ALL
GdkPaintable * gsk_shader_paintable_new (GskGLShader *shader,
GBytes *data);
GDK_AVAILABLE_IN_ALL
GskGLShader * gsk_shader_paintable_get_shader (GskShaderPaintable *self);
GDK_AVAILABLE_IN_ALL
void gsk_shader_paintable_set_shader (GskShaderPaintable *self,
GskGLShader *shader);
GDK_AVAILABLE_IN_ALL
GBytes * gsk_shader_paintable_get_args (GskShaderPaintable *self);
GDK_AVAILABLE_IN_ALL
void gsk_shader_paintable_set_args (GskShaderPaintable *self,
GBytes *data);
GDK_AVAILABLE_IN_ALL
void gsk_shader_paintable_update_time (GskShaderPaintable *self,
int time_idx,
gint64 frame_time);
G_END_DECLS
#endif /* __GSK_SHADER_PAINTABLE_H__ */
+3 -3
View File
@@ -764,7 +764,7 @@ gtk_gears_realize (GtkWidget *widget)
glShaderSource(v, 1, &p, NULL);
glCompileShader(v);
glGetShaderInfoLog(v, sizeof msg, NULL, msg);
g_print ("vertex shader info: %s\n", msg);
g_debug ("vertex shader info: %s\n", msg);
/* Compile the fragment shader */
if (gdk_gl_context_get_use_es (context))
@@ -775,7 +775,7 @@ gtk_gears_realize (GtkWidget *widget)
glShaderSource(f, 1, &p, NULL);
glCompileShader(f);
glGetShaderInfoLog(f, sizeof msg, NULL, msg);
g_print ("fragment shader info: %s\n", msg);
g_debug ("fragment shader info: %s\n", msg);
/* Create and link the shader program */
program = glCreateProgram();
@@ -786,7 +786,7 @@ gtk_gears_realize (GtkWidget *widget)
glLinkProgram(program);
glGetProgramInfoLog(program, sizeof msg, NULL, msg);
g_print ("program info: %s\n", msg);
g_debug ("program info: %s\n", msg);
glDeleteShader (v);
glDeleteShader (f);
+264
View File
@@ -0,0 +1,264 @@
#include "gtkshaderbin.h"
typedef struct {
GskGLShader *shader;
GtkStateFlags state;
GtkStateFlags state_mask;
float extra_border;
gboolean compiled;
gboolean compiled_ok;
} ShaderInfo;
struct _GtkShaderBin
{
GtkWidget parent_instance;
GtkWidget *child;
ShaderInfo *active_shader;
GPtrArray *shaders;
guint tick_id;
float time;
float mouse_x, mouse_y;
gint64 first_frame_time;
};
struct _GtkShaderBinClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE (GtkShaderBin, gtk_shader_bin, GTK_TYPE_WIDGET)
static void
shader_info_free (ShaderInfo *info)
{
g_object_unref (info->shader);
g_free (info);
}
static void
gtk_shader_bin_finalize (GObject *object)
{
GtkShaderBin *self = GTK_SHADER_BIN (object);
g_ptr_array_free (self->shaders, TRUE);
G_OBJECT_CLASS (gtk_shader_bin_parent_class)->finalize (object);
}
static void
gtk_shader_bin_dispose (GObject *object)
{
GtkShaderBin *self = GTK_SHADER_BIN (object);
g_clear_pointer (&self->child, gtk_widget_unparent);
G_OBJECT_CLASS (gtk_shader_bin_parent_class)->dispose (object);
}
static gboolean
gtk_shader_bin_tick (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer unused)
{
GtkShaderBin *self = GTK_SHADER_BIN (widget);
gint64 frame_time;
frame_time = gdk_frame_clock_get_frame_time (frame_clock);
if (self->first_frame_time == 0)
self->first_frame_time = frame_time;
self->time = (frame_time - self->first_frame_time) / (float)G_USEC_PER_SEC;
gtk_widget_queue_draw (widget);
return G_SOURCE_CONTINUE;
}
static void
motion_cb (GtkEventControllerMotion *controller,
double x,
double y,
GtkShaderBin *self)
{
self->mouse_x = x;
self->mouse_y = y;
}
static void
gtk_shader_bin_init (GtkShaderBin *self)
{
GtkEventController *controller;
self->shaders = g_ptr_array_new_with_free_func ((GDestroyNotify)shader_info_free);
controller = gtk_event_controller_motion_new ();
g_signal_connect (controller, "motion", G_CALLBACK (motion_cb), self);
gtk_widget_add_controller (GTK_WIDGET (self), controller);
}
void
gtk_shader_bin_update_active_shader (GtkShaderBin *self)
{
GtkStateFlags new_state = gtk_widget_get_state_flags (GTK_WIDGET (self));
ShaderInfo *new_shader = NULL;
for (int i = 0; i < self->shaders->len; i++)
{
ShaderInfo *info = g_ptr_array_index (self->shaders, i);
if ((info->state_mask & new_state) == info->state)
{
new_shader = info;
break;
}
}
if (self->active_shader == new_shader)
return;
self->active_shader = new_shader;
self->first_frame_time = 0;
if (self->active_shader)
{
if (self->tick_id == 0)
self->tick_id = gtk_widget_add_tick_callback (GTK_WIDGET (self),
gtk_shader_bin_tick,
NULL, NULL);
}
else
{
if (self->tick_id != 0)
{
gtk_widget_remove_tick_callback (GTK_WIDGET (self), self->tick_id);
self->tick_id = 0;
}
}
gtk_widget_queue_draw (GTK_WIDGET (self));
}
static void
gtk_shader_bin_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state_flags)
{
GtkShaderBin *self = GTK_SHADER_BIN (widget);
gtk_shader_bin_update_active_shader (self);
}
void
gtk_shader_bin_add_shader (GtkShaderBin *self,
GskGLShader *shader,
GtkStateFlags state,
GtkStateFlags state_mask,
float extra_border)
{
ShaderInfo *info = g_new0 (ShaderInfo, 1);
info->shader = g_object_ref (shader);
info->state = state;
info->state_mask = state_mask;
info->extra_border = extra_border;
g_ptr_array_add (self->shaders, info);
gtk_shader_bin_update_active_shader (self);
}
void
gtk_shader_bin_set_child (GtkShaderBin *self,
GtkWidget *child)
{
if (self->child == child)
return;
g_clear_pointer (&self->child, gtk_widget_unparent);
if (child)
{
self->child = child;
gtk_widget_set_parent (child, GTK_WIDGET (self));
}
}
GtkWidget *
gtk_shader_bin_get_child (GtkShaderBin *self)
{
return self->child;
}
static void
gtk_shader_bin_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkShaderBin *self = GTK_SHADER_BIN (widget);
int width, height;
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
if (self->active_shader)
{
if (!self->active_shader->compiled)
{
GtkNative *native = gtk_widget_get_native (widget);
GskRenderer *renderer = gtk_native_get_renderer (native);
GError *error = NULL;
self->active_shader->compiled = TRUE;
self->active_shader->compiled_ok =
gsk_gl_shader_compile (self->active_shader->shader,
renderer, &error);
if (!self->active_shader->compiled_ok)
{
g_warning ("GtkShaderBin failed to compile shader: %s", error->message);
g_error_free (error);
}
}
if (self->active_shader->compiled_ok)
{
float border = self->active_shader->extra_border;
graphene_vec2_t mouse;
graphene_vec2_init (&mouse, self->mouse_x + border, self->mouse_y + border);
gtk_snapshot_push_gl_shader (snapshot, self->active_shader->shader,
&GRAPHENE_RECT_INIT(-border, -border, width+2*border, height+2*border),
gsk_gl_shader_format_args (self->active_shader->shader,
"u_time", self->time,
"u_mouse", &mouse,
NULL));
gtk_widget_snapshot_child (widget, self->child, snapshot);
gtk_snapshot_gl_shader_pop_texture (snapshot);
gtk_snapshot_pop (snapshot);
return;
}
}
/* Non-shader fallback */
gtk_widget_snapshot_child (widget, self->child, snapshot);
}
static void
gtk_shader_bin_class_init (GtkShaderBinClass *class)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = gtk_shader_bin_finalize;
object_class->dispose = gtk_shader_bin_dispose;
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
widget_class->snapshot = gtk_shader_bin_snapshot;
widget_class->state_flags_changed = gtk_shader_bin_state_flags_changed;
}
GtkWidget *
gtk_shader_bin_new (void)
{
GtkShaderBin *self;
self = g_object_new (GTK_TYPE_SHADER_BIN, NULL);
return GTK_WIDGET (self);
}
+23
View File
@@ -0,0 +1,23 @@
#ifndef __GTK_SHADER_BIN_H__
#define __GTK_SHADER_BIN_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define GTK_TYPE_SHADER_BIN (gtk_shader_bin_get_type ())
G_DECLARE_FINAL_TYPE (GtkShaderBin, gtk_shader_bin, GTK, SHADER_BIN, GtkWidget)
GtkWidget *gtk_shader_bin_new (void);
void gtk_shader_bin_add_shader (GtkShaderBin *self,
GskGLShader *shader,
GtkStateFlags state,
GtkStateFlags state_mask,
float extra_border);
void gtk_shader_bin_set_child (GtkShaderBin *self,
GtkWidget *child);
GtkWidget *gtk_shader_bin_get_child (GtkShaderBin *self);
G_END_DECLS
#endif /* __GTK_SHADER_BIN_H__ */
+361
View File
@@ -0,0 +1,361 @@
#include "gtkshaderstack.h"
struct _GtkShaderStack
{
GtkWidget parent_instance;
GskGLShader *shader;
GPtrArray *children;
int current;
int next;
gboolean backwards;
guint tick_id;
float time;
float duration;
gint64 start_time;
};
struct _GtkShaderStackClass
{
GtkWidgetClass parent_class;
};
enum {
PROP_DURATION = 1,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL };
G_DEFINE_TYPE (GtkShaderStack, gtk_shader_stack, GTK_TYPE_WIDGET)
static void
gtk_shader_stack_finalize (GObject *object)
{
GtkShaderStack *self = GTK_SHADER_STACK (object);
g_object_unref (self->shader);
G_OBJECT_CLASS (gtk_shader_stack_parent_class)->finalize (object);
}
static void
update_child_visible (GtkShaderStack *self)
{
int i;
for (i = 0; i < self->children->len; i++)
{
GtkWidget *child = g_ptr_array_index (self->children, i);
gtk_widget_set_child_visible (child,
i == self->current || i == self->next);
}
}
static gboolean
transition_cb (GtkWidget *widget,
GdkFrameClock *clock,
gpointer unused)
{
GtkShaderStack *self = GTK_SHADER_STACK (widget);
gint64 frame_time;
frame_time = gdk_frame_clock_get_frame_time (clock);
if (self->start_time == 0)
self->start_time = frame_time;
self->time = (frame_time - self->start_time) / (float)G_USEC_PER_SEC;
gtk_widget_queue_draw (widget);
if (self->time >= self->duration)
{
self->current = self->next;
self->next = -1;
update_child_visible (self);
return G_SOURCE_REMOVE;
}
else
return G_SOURCE_CONTINUE;
}
static void
start_transition (GtkShaderStack *self)
{
self->start_time = 0;
self->tick_id = gtk_widget_add_tick_callback (GTK_WIDGET (self),
transition_cb,
NULL, NULL);
}
static void
stop_transition (GtkShaderStack *self)
{
if (self->tick_id != 0)
{
gtk_widget_remove_tick_callback (GTK_WIDGET (self), self->tick_id);
self->tick_id = 0;
}
if (self->next != -1)
self->current = self->next;
self->next = -1;
update_child_visible (self);
}
static void
gtk_shader_stack_dispose (GObject *object)
{
GtkShaderStack *self = GTK_SHADER_STACK (object);
stop_transition (self);
g_clear_pointer (&self->children, g_ptr_array_unref);
G_OBJECT_CLASS (gtk_shader_stack_parent_class)->dispose (object);
}
void
gtk_shader_stack_transition (GtkShaderStack *self,
gboolean forward)
{
stop_transition (self);
self->backwards = !forward;
if (self->backwards)
self->next = (self->current + self->children->len - 1) % self->children->len;
else
self->next = (self->current + 1) % self->children->len;
update_child_visible (self);
start_transition (self);
}
static void
gtk_shader_stack_init (GtkShaderStack *self)
{
self->children = g_ptr_array_new_with_free_func ((GDestroyNotify)gtk_widget_unparent);
self->current = -1;
self->next = -1;
self->backwards = FALSE;
self->duration = 1.0;
}
static void
gtk_shader_stack_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline)
{
GtkShaderStack *self = GTK_SHADER_STACK (widget);
int i;
*minimum = 0;
*natural = 0;
for (i = 0; i < self->children->len; i++)
{
GtkWidget *child = g_ptr_array_index (self->children, i);
int child_min, child_nat;
if (gtk_widget_get_visible (child))
{
gtk_widget_measure (child, orientation, for_size, &child_min, &child_nat, NULL, NULL);
*minimum = MAX (*minimum, child_min);
*natural = MAX (*natural, child_nat);
}
}
}
static void
gtk_shader_stack_size_allocate (GtkWidget *widget,
int width,
int height,
int baseline)
{
GtkShaderStack *self = GTK_SHADER_STACK (widget);
GtkAllocation child_allocation;
GtkWidget *child;
int i;
child_allocation.x = 0;
child_allocation.y = 0;
child_allocation.width = width;
child_allocation.height = height;
for (i = 0; i < self->children->len; i++)
{
child = g_ptr_array_index (self->children, i);
if (gtk_widget_get_visible (child))
gtk_widget_size_allocate (child, &child_allocation, -1);
}
}
static void
gtk_shader_stack_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkShaderStack *self = GTK_SHADER_STACK (widget);
int width, height;
GtkWidget *current, *next;
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
current = g_ptr_array_index (self->children, self->current);
if (self->next == -1)
{
gtk_widget_snapshot_child (widget, current, snapshot);
}
else
{
GtkNative *native = gtk_widget_get_native (widget);
GskRenderer *renderer = gtk_native_get_renderer (native);
float progress;
next = g_ptr_array_index (self->children, self->next);
progress = self->time / self->duration;
if (self->backwards)
{
GtkWidget *tmp = next;
next = current;
current = tmp;
progress = 1. - progress;
}
if (gsk_gl_shader_compile (self->shader, renderer, NULL))
{
gtk_snapshot_push_gl_shader (snapshot,
self->shader,
&GRAPHENE_RECT_INIT(0, 0, width, height),
gsk_gl_shader_format_args (self->shader,
"progress", progress,
NULL));
gtk_widget_snapshot_child (widget, current, snapshot);
gtk_snapshot_gl_shader_pop_texture (snapshot); /* current child */
gtk_widget_snapshot_child (widget, next, snapshot);
gtk_snapshot_gl_shader_pop_texture (snapshot); /* next child */
gtk_snapshot_pop (snapshot);
}
else
{
/* Non-shader fallback */
gtk_widget_snapshot_child (widget, current, snapshot);
}
}
}
static void
gtk_shader_stack_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkShaderStack *self = GTK_SHADER_STACK (object);
switch (prop_id)
{
case PROP_DURATION:
g_value_set_float (value, self->duration);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_shader_stack_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkShaderStack *self = GTK_SHADER_STACK (object);
switch (prop_id)
{
case PROP_DURATION:
self->duration = g_value_get_float (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_shader_stack_class_init (GtkShaderStackClass *class)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = gtk_shader_stack_finalize;
object_class->dispose = gtk_shader_stack_dispose;
object_class->get_property = gtk_shader_stack_get_property;
object_class->set_property = gtk_shader_stack_set_property;
widget_class->snapshot = gtk_shader_stack_snapshot;
widget_class->measure = gtk_shader_stack_measure;
widget_class->size_allocate = gtk_shader_stack_size_allocate;
properties[PROP_DURATION] =
g_param_spec_float ("duration", "Duration", "Duration",
0.1, 3.0, 1.0,
G_PARAM_READWRITE);
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
}
GtkWidget *
gtk_shader_stack_new (void)
{
return g_object_new (GTK_TYPE_SHADER_STACK, NULL);
}
void
gtk_shader_stack_set_shader (GtkShaderStack *self,
GskGLShader *shader)
{
g_set_object (&self->shader, shader);
}
void
gtk_shader_stack_add_child (GtkShaderStack *self,
GtkWidget *child)
{
g_ptr_array_add (self->children, child);
gtk_widget_set_parent (child, GTK_WIDGET (self));
gtk_widget_queue_resize (GTK_WIDGET (self));
if (self->current == -1)
self->current = 0;
else
gtk_widget_set_child_visible (child, FALSE);
}
void
gtk_shader_stack_set_active (GtkShaderStack *self,
int index)
{
stop_transition (self);
self->current = MIN (index, self->children->len);
update_child_visible (self);
}
+23
View File
@@ -0,0 +1,23 @@
#ifndef __GTK_SHADER_STACK_H__
#define __GTK_SHADER_STACK_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define GTK_TYPE_SHADER_STACK (gtk_shader_stack_get_type ())
G_DECLARE_FINAL_TYPE (GtkShaderStack, gtk_shader_stack, GTK, SHADER_STACK, GtkWidget)
GtkWidget * gtk_shader_stack_new (void);
void gtk_shader_stack_set_shader (GtkShaderStack *self,
GskGLShader *shader);
void gtk_shader_stack_add_child (GtkShaderStack *self,
GtkWidget *child);
void gtk_shader_stack_transition (GtkShaderStack *self,
gboolean forward);
void gtk_shader_stack_set_active (GtkShaderStack *self,
int index);
G_END_DECLS
#endif /* __GTK_SHADER_STACK_H__ */
+4 -2
View File
@@ -56,13 +56,15 @@ const char *fragment_prefix =
"uniform float iSampleRate; // sound sample rate (i.e., 44100)\n"
"\n"
"in vec2 fragCoord;\n"
"out vec4 fragColor;\n";
"out vec4 vFragColor;\n";
// Fragment shader suffix
const char *fragment_suffix =
" void main() {\n"
" mainImage(fragColor, fragCoord);\n"
" vec4 c;\n"
" mainImage(c, fragCoord);\n"
" vFragColor = c;\n"
" }\n";
typedef struct {
+41
View File
@@ -0,0 +1,41 @@
uniform float progress;
uniform sampler2D u_texture1;
uniform sampler2D u_texture2;
vec4 getFromColor (vec2 uv) {
return GskTexture(u_texture1, uv);
}
vec4 getToColor (vec2 uv) {
return GskTexture(u_texture2, uv);
}
// Source: https://gl-transitions.com/editor/kaleidoscope
// Author: nwoeanhinnogaehr
// License: MIT
const float speed = 1.0;
const float angle = 1.0;
const float power = 1.5;
vec4 transition(vec2 uv) {
vec2 p = uv.xy / vec2(1.0).xy;
vec2 q = p;
float t = pow(progress, power)*speed;
p = p -0.5;
for (int i = 0; i < 7; i++) {
p = vec2(sin(t)*p.x + cos(t)*p.y, sin(t)*p.y - cos(t)*p.x);
t += angle;
p = abs(mod(p, 2.0) - 1.0);
}
abs(mod(p, 1.0));
return mix(
mix(getFromColor(q), getToColor(q), progress),
mix(getFromColor(p), getToColor(p), progress), 1.0 - 2.0*abs(progress - 0.5));
}
void mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv)
{
fragColor = transition(uv);
}
+374
View File
@@ -0,0 +1,374 @@
/* Lists/Characters
*
* This demo shows a multi-column representation of some parts
* of the Unicode Character Database, or UCD.
*
* The dataset used here has 33796 items.
*/
#include <gtk/gtk.h>
#include "script-names.h"
#include "unicode-names.h"
#define UCD_TYPE_ITEM (ucd_item_get_type ())
G_DECLARE_FINAL_TYPE (UcdItem, ucd_item, UCD, ITEM, GObject)
struct _UcdItem
{
GObject parent_instance;
gunichar codepoint;
const char *name;
};
struct _UcdItemClass
{
GObjectClass parent_class;
};
G_DEFINE_TYPE (UcdItem, ucd_item, G_TYPE_OBJECT)
static void
ucd_item_init (UcdItem *item)
{
}
static void
ucd_item_class_init (UcdItemClass *class)
{
}
static UcdItem *
ucd_item_new (gunichar codepoint,
const char *name)
{
UcdItem *item;
item = g_object_new (UCD_TYPE_ITEM, NULL);
item->codepoint = codepoint;
item->name = name;
return item;
}
static gunichar
ucd_item_get_codepoint (UcdItem *item)
{
return item->codepoint;
}
static const char *
ucd_item_get_name (UcdItem *item)
{
return item->name;
}
static GListModel *
ucd_model_new (void)
{
GBytes *bytes;
GVariant *v;
GVariantIter *iter;
GListStore *store;
guint u;
char *name;
bytes = g_resources_lookup_data ("/listview_ucd_data/ucdnames.data", 0, NULL);
v = g_variant_ref_sink (g_variant_new_from_bytes (G_VARIANT_TYPE ("a(us)"), bytes, TRUE));
iter = g_variant_iter_new (v);
store = g_list_store_new (G_TYPE_OBJECT);
while (g_variant_iter_next (iter, "(us)", &u, &name))
{
if (u == 0)
continue;
UcdItem *item = ucd_item_new (u, name);
g_list_store_append (store, item);
g_object_unref (item);
}
g_variant_iter_free (iter);
g_variant_unref (v);
g_bytes_unref (bytes);
return G_LIST_MODEL (store);
}
static void
setup_centered_label (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
label = gtk_label_new ("");
gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label);
}
static void
setup_label (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
label = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label);
}
static void
setup_ellipsizing_label (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
label = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gtk_label_set_width_chars (GTK_LABEL (label), 20);
gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label);
}
static void
bind_codepoint (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
GObject *item;
gunichar codepoint;
char buffer[16] = { 0, };
label = gtk_list_item_get_child (GTK_LIST_ITEM (listitem));
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
g_snprintf (buffer, 10, "%#06x", codepoint);
gtk_label_set_label (GTK_LABEL (label), buffer);
}
static void
bind_char (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
GObject *item;
gunichar codepoint;
char buffer[16] = { 0, };
label = gtk_list_item_get_child (GTK_LIST_ITEM (listitem));
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
if (g_unichar_isprint (codepoint))
g_unichar_to_utf8 (codepoint, buffer);
gtk_label_set_label (GTK_LABEL (label), buffer);
}
static void
bind_name (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
GObject *item;
const char *name;
label = gtk_list_item_get_child (GTK_LIST_ITEM (listitem));
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
name = ucd_item_get_name (UCD_ITEM (item));
gtk_label_set_label (GTK_LABEL (label), name);
}
static void
bind_type (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
GObject *item;
gunichar codepoint;
label = gtk_list_item_get_child (GTK_LIST_ITEM (listitem));
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
gtk_label_set_label (GTK_LABEL (label), get_unicode_type_name (g_unichar_type (codepoint)));
}
static void
bind_break_type (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
GObject *item;
gunichar codepoint;
label = gtk_list_item_get_child (GTK_LIST_ITEM (listitem));
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
gtk_label_set_label (GTK_LABEL (label), get_break_type_name (g_unichar_break_type (codepoint)));
}
static void
bind_combining_class (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
GObject *item;
gunichar codepoint;
label = gtk_list_item_get_child (GTK_LIST_ITEM (listitem));
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
gtk_label_set_label (GTK_LABEL (label), get_combining_class_name (g_unichar_combining_class (codepoint)));
}
static void
bind_script (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
GObject *item;
gunichar codepoint;
GUnicodeScript script;
label = gtk_list_item_get_child (GTK_LIST_ITEM (listitem));
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
script = g_unichar_get_script (codepoint);
gtk_label_set_label (GTK_LABEL (label), get_script_name (script));
}
static void
selection_changed (GObject *object,
GParamSpec *pspec,
GtkWidget *label)
{
UcdItem *item;
guint codepoint;
char buffer[16] = { 0, };
item = gtk_single_selection_get_selected_item (GTK_SINGLE_SELECTION (object));
codepoint = ucd_item_get_codepoint (item);
if (g_unichar_isprint (codepoint))
g_unichar_to_utf8 (codepoint, buffer);
gtk_label_set_label (GTK_LABEL (label), buffer);
}
static GtkWidget *
create_ucd_view (GtkWidget *label)
{
GtkWidget *cv;
GListModel *ucd_model;
GtkSingleSelection *selection;
GtkListItemFactory *factory;
GtkColumnViewColumn *column;
ucd_model = ucd_model_new ();
selection = gtk_single_selection_new (ucd_model);
gtk_single_selection_set_autoselect (selection, TRUE);
gtk_single_selection_set_can_unselect (selection, FALSE);
g_signal_connect (selection, "notify::selected", G_CALLBACK (selection_changed), label);
cv = gtk_column_view_new (GTK_SELECTION_MODEL (selection));
gtk_column_view_set_show_column_separators (GTK_COLUMN_VIEW (cv), TRUE);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_centered_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_codepoint), NULL);
column = gtk_column_view_column_new ("Codepoint", factory);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_centered_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_char), NULL);
column = gtk_column_view_column_new ("Char", factory);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_ellipsizing_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_name), NULL);
column = gtk_column_view_column_new ("Name", factory);
gtk_column_view_column_set_resizable (column, TRUE);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_ellipsizing_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_type), NULL);
column = gtk_column_view_column_new ("Type", factory);
gtk_column_view_column_set_resizable (column, TRUE);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_ellipsizing_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_break_type), NULL);
column = gtk_column_view_column_new ("Break Type", factory);
gtk_column_view_column_set_resizable (column, TRUE);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_combining_class), NULL);
column = gtk_column_view_column_new ("Combining Class", factory);
gtk_column_view_column_set_resizable (column, TRUE);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_script), NULL);
column = gtk_column_view_column_new ("Script", factory);
gtk_column_view_column_set_resizable (column, TRUE);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
return cv;
}
static GtkWidget *window;
GtkWidget *
do_listview_ucd (GtkWidget *do_widget)
{
if (window == NULL)
{
GtkWidget *listview, *sw;
GtkWidget *box, *label;
GtkCssProvider *provider;
window = gtk_window_new ();
gtk_window_set_default_size (GTK_WINDOW (window), 800, 400);
gtk_window_set_title (GTK_WINDOW (window), "Characters");
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
label = gtk_label_new ("");
gtk_label_set_width_chars (GTK_LABEL (label), 2);
gtk_widget_add_css_class (label, "enormous");
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, "label.enormous { font-size: 80px; }", -1);
gtk_style_context_add_provider (gtk_widget_get_style_context (label), GTK_STYLE_PROVIDER (provider), 800);
gtk_widget_set_hexpand (label, TRUE);
gtk_box_append (GTK_BOX (box), label);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_propagate_natural_width (GTK_SCROLLED_WINDOW (sw), TRUE);
listview = create_ucd_view (label);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
gtk_box_prepend (GTK_BOX (box), sw);
gtk_window_set_child (GTK_WINDOW (window), box);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}
+2 -1
View File
@@ -391,7 +391,7 @@ display_nothing (const char *resource)
GtkWidget *widget;
char *str;
str = g_strdup_printf ("The lazy GTK developers forgot to add a way to display the resource '%s'", resource);
str = g_strdup_printf ("The contents of the resource at '%s' cannot be displayed", resource);
widget = gtk_label_new (str);
gtk_label_set_wrap (GTK_LABEL (widget), TRUE);
@@ -410,6 +410,7 @@ static struct {
{ ".gif", NULL, display_image },
{ ".jpg", NULL, display_image },
{ ".png", NULL, display_image },
{ ".svg", NULL, display_image },
{ ".c", "c", display_text },
{ ".css", "css", display_text },
{ ".glsl", NULL, display_text },
+13 -2
View File
@@ -32,6 +32,7 @@ demos = files([
'gears.c',
'gestures.c',
'glarea.c',
'gltransition.c',
'headerbar.c',
'hypertext.c',
'iconscroll.c',
@@ -102,7 +103,10 @@ extra_demo_sources = files(['main.c',
'gtkfishbowl.c',
'fontplane.c',
'gtkgears.c',
'gtkshaderbin.c',
'gtkshadertoy.c',
'gtkshaderstack.c',
'gskshaderpaintable.c',
'puzzlepiece.c',
'bluroverlay.c',
'demoimage.c',
@@ -117,8 +121,8 @@ extra_demo_sources = files(['main.c',
'demo3widget.c'])
if harfbuzz_dep.found() and pangoft_dep.found()
demos += files('font_features.c')
extra_demo_sources += files(['script-names.c', 'language-names.c'])
demos += files(['font_features.c', 'listview_ucd.c'])
extra_demo_sources += files(['script-names.c', 'language-names.c', 'unicode-names.c'])
gtkdemo_deps += [ harfbuzz_dep, epoxy_dep ]
endif
@@ -126,6 +130,13 @@ if os_unix
demos += files('pagesetup.c')
endif
librsvg_dep = dependency('librsvg-2.0', version: '>= 2.46.0', required: false)
if librsvg_dep.found()
demos += files('paintable_svg.c')
gtkdemo_deps += [ librsvg_dep ]
endif
gtkdemo_args = [ '-DGDK_DISABLE_DEPRECATED', '-DGTK_DISABLE_DEPRECATED', ]
demos_h = custom_target('gtk4 demo header',
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="128px" viewBox="0 0 128 128" width="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<linearGradient id="a" gradientUnits="userSpaceOnUse" x1="43.000351" x2="85.000351" y1="39.000164" y2="39.000164">
<stop offset="0" stop-color="#26a269"/>
<stop offset="0.0934161" stop-color="#84e3b7"/>
<stop offset="0.330831" stop-color="#26a269"/>
<stop offset="0.686952" stop-color="#26a269"/>
<stop offset="0.89736" stop-color="#175e3c"/>
<stop offset="1" stop-color="#26a269"/>
</linearGradient>
<linearGradient id="b" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#c0bfbc"/>
<stop offset="0.154754" stop-color="#ffffff"/>
<stop offset="0.433722" stop-color="#bdbbb5"/>
<stop offset="0.650505" stop-color="#c1c0ba"/>
<stop offset="0.825253" stop-color="#ffffff"/>
<stop offset="1" stop-color="#c0bfbc"/>
</linearGradient>
<linearGradient id="c" gradientTransform="matrix(0.0811899 -0.046875 0.069079 0.119648 307.03142 127.069456)" x1="-1710.210571" x2="-1774.45166" xlink:href="#b" y1="-1202.376709" y2="-1202.376709"/>
<linearGradient id="d" gradientTransform="matrix(-0.0811899 -0.046875 -0.069079 0.119648 -177.242852 127.069447)" x1="-1710.210571" x2="-1774.45166" xlink:href="#b" y1="-1202.376709" y2="-1202.376709"/>
<linearGradient id="e" gradientUnits="userSpaceOnUse" x1="14" x2="56" y1="94.999964" y2="94.999964">
<stop offset="0" stop-color="#813d9c"/>
<stop offset="0.109119" stop-color="#b378ca"/>
<stop offset="0.241583" stop-color="#813d9c"/>
<stop offset="0.731841" stop-color="#813d9c"/>
<stop offset="0.872163" stop-color="#4d255d"/>
<stop offset="1" stop-color="#813d9c"/>
</linearGradient>
<linearGradient id="f" gradientUnits="userSpaceOnUse" x1="72" x2="114" y1="94.999964" y2="94.999964">
<stop offset="0" stop-color="#e66100"/>
<stop offset="0.0678478" stop-color="#ff903e"/>
<stop offset="0.168852" stop-color="#e66100"/>
<stop offset="0.886626" stop-color="#e66100"/>
<stop offset="1" stop-color="#9d4200"/>
</linearGradient>
<clipPath id="g">
<rect height="128" width="128"/>
</clipPath>
<clipPath id="h">
<rect height="128" width="128"/>
</clipPath>
<filter id="i" height="100%" width="100%" x="0%" y="0%">
<feColorMatrix in="SourceGraphic" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/>
</filter>
<mask id="j">
<g clip-path="url(#h)" filter="url(#i)">
<g clip-path="url(#g)">
<path d="m 51 18 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#a)"/>
<path d="m 51 12 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#57e389"/>
<path d="m 76.976562 55.453125 c 1.480469 -0.855469 3.371094 -0.347656 4.226563 1.132813 l 6.742187 11.679687 c 0.855469 1.480469 0.347657 3.371094 -1.132812 4.226563 c -1.480469 0.851562 -3.371094 0.347656 -4.226562 -1.132813 l -6.742188 -11.679687 c -0.855469 -1.480469 -0.347656 -3.371094 1.132812 -4.226563 z m 0 0" fill="url(#c)"/>
<path d="m 52.8125 55.453125 c -1.480469 -0.855469 -3.371094 -0.347656 -4.226562 1.132813 l -6.742188 11.679687 c -0.855469 1.480469 -0.347656 3.371094 1.132812 4.226563 c 1.480469 0.851562 3.371094 0.347656 4.226563 -1.132813 l 6.742187 -11.679687 c 0.855469 -1.480469 0.347657 -3.371094 -1.132812 -4.226563 z m 0 0" fill="url(#d)"/>
<path d="m 22 74 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#e)"/>
<path d="m 22 68 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#dc8add"/>
<path d="m 80 74 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#f)"/>
<path d="m 80 68 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#ffa348"/>
</g>
</g>
</mask>
<mask id="k">
<g filter="url(#i)">
<rect fill-opacity="0.8" height="128" width="128"/>
</g>
</mask>
<linearGradient id="l" gradientTransform="matrix(0 0.37 -0.98462 0 295.38501 -30.360001)" gradientUnits="userSpaceOnUse" x1="300" x2="428" y1="235" y2="235">
<stop offset="0" stop-color="#f9f06b"/>
<stop offset="1" stop-color="#f5c211"/>
</linearGradient>
<clipPath id="m">
<rect height="128" width="128"/>
</clipPath>
<clipPath id="n">
<rect height="128" width="128"/>
</clipPath>
<path d="m 51 18 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#a)"/>
<path d="m 51 12 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#57e389"/>
<path d="m 76.976562 55.453125 c 1.480469 -0.855469 3.371094 -0.347656 4.226563 1.132813 l 6.742187 11.679687 c 0.855469 1.480469 0.347657 3.371094 -1.132812 4.226563 c -1.480469 0.851562 -3.371094 0.347656 -4.226562 -1.132813 l -6.742188 -11.679687 c -0.855469 -1.480469 -0.347656 -3.371094 1.132812 -4.226563 z m 0 0" fill="url(#c)"/>
<path d="m 52.8125 55.453125 c -1.480469 -0.855469 -3.371094 -0.347656 -4.226562 1.132813 l -6.742188 11.679687 c -0.855469 1.480469 -0.347656 3.371094 1.132812 4.226563 c 1.480469 0.851562 3.371094 0.347656 4.226563 -1.132813 l 6.742187 -11.679687 c 0.855469 -1.480469 0.347657 -3.371094 -1.132812 -4.226563 z m 0 0" fill="url(#d)"/>
<path d="m 22 74 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#e)"/>
<path d="m 22 68 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#dc8add"/>
<path d="m 80 74 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#f)"/>
<path d="m 80 68 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#ffa348"/>
<g clip-path="url(#n)" mask="url(#j)">
<g clip-path="url(#m)" mask="url(#k)">
<path d="m 128 80.640625 v 47.359375 h -128 v -47.359375 z m 0 0" fill="url(#l)"/>
<path d="m 13.308594 80.640625 l 47.355468 47.359375 h 21.214844 l -47.359375 -47.359375 z m 42.421875 0 l 47.363281 47.359375 h 21.214844 l -47.363282 -47.359375 z m 42.429687 0 l 29.839844 29.839844 v -21.210938 l -8.628906 -8.628906 z m -98.160156 7.90625 v 21.214844 l 18.238281 18.238281 h 21.214844 z m 0 0"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.4 KiB

+241
View File
@@ -0,0 +1,241 @@
/* Paintable/SVG
*
* This demo shows wrapping a librsvg RsvgHandle in a GdkPaintable
* to display an SVG image that can be scaled by resizing the window.
*
* This demo relies on librsvg, which GTK itself does not link against.
*/
#include <gtk/gtk.h>
#include <librsvg/rsvg.h>
#define SVG_TYPE_PAINTABLE (svg_paintable_get_type ())
G_DECLARE_FINAL_TYPE (SvgPaintable, svg_paintable, SVG, PAINTABLE, GObject)
struct _SvgPaintable
{
GObject parent_instance;
GFile *file;
RsvgHandle *handle;
};
struct _SvgPaintableClass
{
GObjectClass parent_class;
};
enum {
PROP_FILE = 1,
NUM_PROPERTIES
};
static void
svg_paintable_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
double width,
double height)
{
SvgPaintable *self = SVG_PAINTABLE (paintable);
cairo_t *cr;
GError *error = NULL;
cr = gtk_snapshot_append_cairo (GTK_SNAPSHOT (snapshot),
&GRAPHENE_RECT_INIT (0, 0, width, height));
if (!rsvg_handle_render_document (self->handle, cr,
&(RsvgRectangle) {0, 0, width, height},
&error))
{
g_error ("%s", error->message);
}
cairo_destroy (cr);
}
static int
svg_paintable_get_intrinsic_width (GdkPaintable *paintable)
{
SvgPaintable *self = SVG_PAINTABLE (paintable);
RsvgDimensionData data;
rsvg_handle_get_dimensions (self->handle, &data);
return data.width;
}
static int
svg_paintable_get_intrinsic_height (GdkPaintable *paintable)
{
SvgPaintable *self = SVG_PAINTABLE (paintable);
RsvgDimensionData data;
rsvg_handle_get_dimensions (self->handle, &data);
return data.height;
}
static void
svg_paintable_init_interface (GdkPaintableInterface *iface)
{
iface->snapshot = svg_paintable_snapshot;
iface->get_intrinsic_width = svg_paintable_get_intrinsic_width;
iface->get_intrinsic_height = svg_paintable_get_intrinsic_height;
}
G_DEFINE_TYPE_WITH_CODE (SvgPaintable, svg_paintable, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
svg_paintable_init_interface))
static void
svg_paintable_init (SvgPaintable *self)
{
}
static void
svg_paintable_dispose (GObject *object)
{
SvgPaintable *self = SVG_PAINTABLE (object);
g_clear_object (&self->file);
g_clear_object (&self->handle);
G_OBJECT_CLASS (svg_paintable_parent_class)->dispose (object);
}
static void
svg_paintable_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SvgPaintable *self = SVG_PAINTABLE (object);
switch (prop_id)
{
case PROP_FILE:
{
GFile *file = g_value_get_object (value);
RsvgHandle *handle = rsvg_handle_new_from_gfile_sync (file,
RSVG_HANDLE_FLAGS_NONE,
NULL,
NULL);
rsvg_handle_set_dpi (handle, 90);
g_set_object (&self->file, file);
g_set_object (&self->handle, handle);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
svg_paintable_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SvgPaintable *self = SVG_PAINTABLE (object);
switch (prop_id)
{
case PROP_FILE:
g_value_set_object (value, self->file);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
svg_paintable_class_init (SvgPaintableClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = svg_paintable_dispose;
object_class->set_property = svg_paintable_set_property;
object_class->get_property = svg_paintable_get_property;
g_object_class_install_property (object_class, PROP_FILE,
g_param_spec_object ("file", "File", "File",
G_TYPE_FILE,
G_PARAM_READWRITE));
}
static SvgPaintable *
svg_paintable_new (GFile *file)
{
return g_object_new (SVG_TYPE_PAINTABLE,
"file", file,
NULL);
}
static void
file_set (GtkFileChooserButton *button,
GtkWidget *picture)
{
GFile *file;
SvgPaintable *paintable;
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (button));
paintable = svg_paintable_new (file);
gtk_picture_set_paintable (GTK_PICTURE (picture), GDK_PAINTABLE (paintable));
g_object_unref (paintable);
g_object_unref (file);
}
static GtkWidget *window;
GtkWidget *
do_paintable_svg (GtkWidget *do_widget)
{
GtkWidget *header;
GtkWidget *picture;
GtkFileFilter *filter;
GtkWidget *button;
GFile *file;
SvgPaintable *paintable;
if (!window)
{
window = gtk_window_new ();
header = gtk_header_bar_new ();
gtk_window_set_titlebar (GTK_WINDOW (window), header);
gtk_window_set_default_size (GTK_WINDOW (window), 300, 200);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
button = gtk_file_chooser_button_new ("Select an SVG file", GTK_FILE_CHOOSER_ACTION_OPEN);
filter = gtk_file_filter_new ();
gtk_file_filter_add_mime_type (filter, "image/svg+xml");
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (button), filter);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);
picture = gtk_picture_new ();
gtk_picture_set_can_shrink (GTK_PICTURE (picture), TRUE);
gtk_widget_set_size_request (picture, 16, 16);
g_signal_connect (button, "file-set", G_CALLBACK (file_set), picture);
gtk_window_set_child (GTK_WINDOW (window), picture);
file = g_file_new_for_uri ("resource:///paintable_svg/org.gtk.gtk4.NodeEditor.Devel.svg");
paintable = svg_paintable_new (file);
gtk_picture_set_paintable (GTK_PICTURE (picture), GDK_PAINTABLE (paintable));
g_object_unref (paintable);
g_object_unref (file);
}
if (!gtk_widget_get_visible (window))
gtk_window_present (GTK_WINDOW (window));
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}
+34
View File
@@ -0,0 +1,34 @@
uniform float progress;
uniform sampler2D u_texture1;
uniform sampler2D u_texture2;
vec4 getFromColor (vec2 uv) {
return GskTexture(u_texture1, uv);
}
vec4 getToColor (vec2 uv) {
return GskTexture(u_texture2, uv);
}
// Source: https://gl-transitions.com/editor/Radial
// License: MIT
// Author: Xaychru
const float smoothness = 1.0;
const float PI = 3.141592653589;
vec4 transition(vec2 p) {
vec2 rp = p*2.-1.;
return mix(
getToColor(p),
getFromColor(p),
smoothstep(0., smoothness, atan(rp.y,rp.x) - (progress-.5) * PI * 2.5)
);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv)
{
fragColor = transition(uv);
}
+43
View File
@@ -0,0 +1,43 @@
uniform float u_time;
uniform vec2 u_mouse;
uniform sampler2D u_texture1;
#define PI 3.141592654
float decay(float v, float t)
{
return v * (1.0 / (1.0 + t*t));
}
void mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv)
{
// Temporary to loop time every 1 sec
float time = u_time;
// we normalize all the effects according to the min height/width
float size = min(resolution.x, resolution.y);
// Animate one wave over size in 0.3 sec
float wave_speed = size / 0.3;
float wave_length = size / 1.0;
float wave_height = size * 0.1;
vec2 center = u_mouse;
vec2 direction_from_center = fragCoord - center;
float distance_from_center = length(direction_from_center);
/* Normalize direction */
direction_from_center = direction_from_center / distance_from_center;
float propagation_length = time * wave_speed;
float t = (propagation_length - distance_from_center) / wave_length;
float offset_magnitude = 0;
if (t > 0.0)
offset_magnitude = decay(wave_height * sin(t * 2.0 * PI), t);
vec2 offset = direction_from_center * min(offset_magnitude, distance_from_center);
vec2 source = fragCoord - offset;
vec2 uv2 = source / resolution;
fragColor = GskTexture(u_texture1, vec2(uv2.x, 1.0-uv2.y));
}
+42 -7
View File
@@ -91,7 +91,7 @@ static struct {
{ G_UNICODE_SCRIPT_LYDIAN, HB_SCRIPT_LYDIAN, NC_("Script", "Lydian") },
{ G_UNICODE_SCRIPT_AVESTAN, HB_SCRIPT_AVESTAN, NC_("Script", "Avestan") },
{ G_UNICODE_SCRIPT_BAMUM, HB_SCRIPT_BAMUM, NC_("Script", "Bamum") },
{ G_UNICODE_SCRIPT_EGYPTIAN_HIEROGLYPHS, HB_SCRIPT_EGYPTIAN_HIEROGLYPHS, NC_("Script", "Egyptian Hieroglpyhs") },
{ G_UNICODE_SCRIPT_EGYPTIAN_HIEROGLYPHS, HB_SCRIPT_EGYPTIAN_HIEROGLYPHS, NC_("Script", "Egyptian Hieroglyphs") },
{ G_UNICODE_SCRIPT_IMPERIAL_ARAMAIC, HB_SCRIPT_IMPERIAL_ARAMAIC, NC_("Script", "Imperial Aramaic") },
{ G_UNICODE_SCRIPT_INSCRIPTIONAL_PAHLAVI, HB_SCRIPT_INSCRIPTIONAL_PAHLAVI, NC_("Script", "Inscriptional Pahlavi") },
{ G_UNICODE_SCRIPT_INSCRIPTIONAL_PARTHIAN, HB_SCRIPT_INSCRIPTIONAL_PARTHIAN, NC_("Script", "Inscriptional Parthian") },
@@ -119,7 +119,7 @@ static struct {
{ G_UNICODE_SCRIPT_DUPLOYAN, HB_SCRIPT_DUPLOYAN, NC_("Script", "Duployan") },
{ G_UNICODE_SCRIPT_ELBASAN, HB_SCRIPT_ELBASAN, NC_("Script", "Elbasan") },
{ G_UNICODE_SCRIPT_GRANTHA, HB_SCRIPT_GRANTHA, NC_("Script", "Grantha") },
{ G_UNICODE_SCRIPT_KHOJKI, HB_SCRIPT_KHOJKI, NC_("Script", "Kjohki") },
{ G_UNICODE_SCRIPT_KHOJKI, HB_SCRIPT_KHOJKI, NC_("Script", "Khojki") },
{ G_UNICODE_SCRIPT_KHUDAWADI, HB_SCRIPT_KHUDAWADI, NC_("Script", "Khudawadi, Sindhi") },
{ G_UNICODE_SCRIPT_LINEAR_A, HB_SCRIPT_LINEAR_A, NC_("Script", "Linear A") },
{ G_UNICODE_SCRIPT_MAHAJANI, HB_SCRIPT_MAHAJANI, NC_("Script", "Mahajani") },
@@ -149,10 +149,40 @@ static struct {
{ G_UNICODE_SCRIPT_NEWA, HB_SCRIPT_NEWA, NC_("Script", "Newa") },
{ G_UNICODE_SCRIPT_OSAGE, HB_SCRIPT_OSAGE, NC_("Script", "Osage") },
{ G_UNICODE_SCRIPT_TANGUT, HB_SCRIPT_TANGUT, NC_("Script", "Tangut") },
{ G_UNICODE_SCRIPT_MASARAM_GONDI, HB_SCRIPT_INVALID, NC_("Script", "Masaram Gondi") },
{ G_UNICODE_SCRIPT_NUSHU, HB_SCRIPT_INVALID, NC_("Script", "Nushu") },
{ G_UNICODE_SCRIPT_SOYOMBO, HB_SCRIPT_INVALID, NC_("Script", "Soyombo") },
{ G_UNICODE_SCRIPT_ZANABAZAR_SQUARE, HB_SCRIPT_INVALID, NC_("Script", "Zanabazar Square") },
{ G_UNICODE_SCRIPT_MASARAM_GONDI, HB_SCRIPT_MASARAM_GONDI, NC_("Script", "Masaram Gondi") },
{ G_UNICODE_SCRIPT_NUSHU, HB_SCRIPT_NUSHU, NC_("Script", "Nushu") },
{ G_UNICODE_SCRIPT_SOYOMBO, HB_SCRIPT_SOYOMBO, NC_("Script", "Soyombo") },
{ G_UNICODE_SCRIPT_ZANABAZAR_SQUARE, HB_SCRIPT_ZANABAZAR_SQUARE, NC_("Script", "Zanabazar Square") },
{ G_UNICODE_SCRIPT_DOGRA, HB_SCRIPT_DOGRA, NC_("Script", "Dogra") },
{ G_UNICODE_SCRIPT_GUNJALA_GONDI, HB_SCRIPT_GUNJALA_GONDI, NC_("Script", "Gunjala Gondi") },
{ G_UNICODE_SCRIPT_HANIFI_ROHINGYA, HB_SCRIPT_HANIFI_ROHINGYA, NC_("Script", "Hanifi Rohingya") },
{ G_UNICODE_SCRIPT_MAKASAR, HB_SCRIPT_MAKASAR, NC_("Script", "Makasar") },
{ G_UNICODE_SCRIPT_MEDEFAIDRIN, HB_SCRIPT_MEDEFAIDRIN, NC_("Script", "Medefaidrin") },
{ G_UNICODE_SCRIPT_OLD_SOGDIAN, HB_SCRIPT_OLD_SOGDIAN, NC_("Script", "Old Sogdian") },
{ G_UNICODE_SCRIPT_SOGDIAN, HB_SCRIPT_SOGDIAN, NC_("Script", "Sogdian") },
#if HB_VERSION_ATLEAST(2,4,0)
{ G_UNICODE_SCRIPT_ELYMAIC, HB_SCRIPT_ELYMAIC, NC_("Script", "Elym") },
{ G_UNICODE_SCRIPT_NANDINAGARI, HB_SCRIPT_NANDINAGARI, NC_("Script", "Nand") },
{ G_UNICODE_SCRIPT_NYIAKENG_PUACHUE_HMONG, HB_SCRIPT_NYIAKENG_PUACHUE_HMONG, NC_("Script", "Rohg") },
{ G_UNICODE_SCRIPT_WANCHO, HB_SCRIPT_WANCHO, NC_("Script", "Wcho") },
#else
{ G_UNICODE_SCRIPT_ELYMAIC, HB_SCRIPT_INVALID, NC_("Script", "Elym") },
{ G_UNICODE_SCRIPT_NANDINAGARI, HB_SCRIPT_INVALID, NC_("Script", "Nand") },
{ G_UNICODE_SCRIPT_NYIAKENG_PUACHUE_HMONG, HB_SCRIPT_INVALID, NC_("Script", "Rohg") },
{ G_UNICODE_SCRIPT_WANCHO, HB_SCRIPT_INVALID, NC_("Script", "Wcho") },
#endif
#if HB_VERSION_ATLEAST(2,6,7)
{ G_UNICODE_SCRIPT_CHORASMIAN, HB_SCRIPT_CHORASMIAN, NC_("Script", "Chorasmian") },
{ G_UNICODE_SCRIPT_DIVES_AKURU, HB_SCRIPT_DIVES_AKURU, NC_("Script", "Dives Akuru") },
{ G_UNICODE_SCRIPT_KHITAN_SMALL_SCRIPT, HB_SCRIPT_KHITAN_SMALL_SCRIPT, NC_("Script", "Khitan small script") },
{ G_UNICODE_SCRIPT_YEZIDI, HB_SCRIPT_YEZIDI, NC_("Script", "Yezidi") },
#else
{ G_UNICODE_SCRIPT_CHORASMIAN, HB_SCRIPT_INVALID, NC_("Script", "Chorasmian") },
{ G_UNICODE_SCRIPT_DIVES_AKURU, HB_SCRIPT_INVALID, NC_("Script", "Dives Akuru") },
{ G_UNICODE_SCRIPT_KHITAN_SMALL_SCRIPT, HB_SCRIPT_INVALID, NC_("Script", "Khitan small script") },
{ G_UNICODE_SCRIPT_YEZIDI, HB_SCRIPT_INVALID, NC_("Script", "Yezidi") },
#endif
};
const char *
@@ -163,7 +193,12 @@ get_script_name (GUnicodeScript script)
for (i = 0; i < G_N_ELEMENTS (scripts); i++)
{
if (scripts[i].script == script)
return g_dpgettext2 (GETTEXT_PACKAGE, "Script", scripts[i].name);
{
if (scripts[i].name)
return g_dpgettext2 (GETTEXT_PACKAGE, "Script", scripts[i].name);
else
return "";
}
}
return NULL;
+1 -1
View File
@@ -8,7 +8,7 @@
<property name="margin-start">50</property>
<property name="margin-end">50</property>
<property name="margin-top">50</property>
<property name="margin-end">50</property>
<property name="margin-bottom">50</property>
<property name="spacing">10</property>
<child>
<object class="GtkButton">
+3
View File
@@ -545,6 +545,7 @@ recursive_attach_view (int depth,
return;
child_view = gtk_text_view_new_with_buffer (gtk_text_view_get_buffer (view));
gtk_widget_set_size_request (child_view, 260 - 20 * depth, -1);
/* Frame is to add a black border around each child view */
frame = gtk_frame_new (NULL);
@@ -590,6 +591,8 @@ easter_egg_callback (GtkWidget *button,
g_object_unref (buffer);
window = gtk_window_new ();
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (gtk_widget_get_root (button)));
gtk_window_set_modal (GTK_WINDOW (window), TRUE);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
Binary file not shown.
+174
View File
@@ -0,0 +1,174 @@
#include "unicode-names.h"
const char *
get_unicode_type_name (GUnicodeType type)
{
const char *names[] = {
"Other, Control",
"Other, Format",
"Other, Not Assigned",
"Other, Private Use",
"Other, Surrogate",
"Letter, Lowercase",
"Letter, Modifier",
"Letter, Other",
"Letter, Titlecase",
"Letter, Uppercase",
"Mark, Spacing",
"Mark, Enclosing",
"Mark, Nonspacing",
"Number, Decimal Digit",
"Number, Letter",
"Number, Other",
"Punctuation, Connector",
"Punctuation, Dash",
"Punctuation, Close",
"Punctuation, Final quote",
"Punctuation, Initial quote",
"Punctuation, Other",
"Punctuation, Open",
"Symbol, Currency",
"Symbol, Modifier",
"Symbol, Math",
"Symbol, Other",
"Separator, Line",
"Separator, Paragraph",
"Separator, Space",
};
if (type < G_N_ELEMENTS (names))
return names[type];
return "Unknown";
}
const char *
get_break_type_name (GUnicodeBreakType type)
{
const char *names[] = {
"Mandatory Break",
"Carriage Return",
"Line Feed",
"Attached Characters and Combining Marks",
"Surrogates",
"Zero Width Space",
"Inseparable",
"Non-breaking (\"Glue\")",
"Contingent Break Opportunity",
"Space",
"Break Opportunity After",
"Break Opportunity Before",
"Break Opportunity Before and After",
"Hyphen",
"Nonstarter",
"Opening Punctuation",
"Closing Punctuation",
"Ambiguous Quotation",
"Exclamation/Interrogation",
"Ideographic",
"Numeric",
"Infix Separator (Numeric)",
"Symbols Allowing Break After",
"Ordinary Alphabetic and Symbol Characters",
"Prefix (Numeric)",
"Postfix (Numeric)",
"Complex Content Dependent (South East Asian)",
"Ambiguous (Alphabetic or Ideographic)",
"Unknown",
"Next Line",
"Word Joiner",
"Hangul L Jamo",
"Hangul V Jamo",
"Hangul T Jamo",
"Hangul LV Syllable",
"Hangul LVT Syllable",
"Closing Parenthesis",
"Conditional Japanese Starter",
"Hebrew Letter",
"Regional Indicator",
"Emoji Base",
"Emoji Modifier",
"Zero Width Joiner",
};
if (type < G_N_ELEMENTS (names))
return names[type];
return "Unknown";
}
const char *
get_combining_class_name (int cclass)
{
const char *classes[256] = { 0, };
classes[0] = "Not Reordered";
classes[1] = "Overlay";
classes[7] = "Nukta";
classes[8] = "Kana Voicing";
classes[9] = "Virama";
classes[10] = "CCC10 (Hebrew)";
classes[11] = "CCC11 (Hebrew)";
classes[12] = "CCC12 (Hebrew)";
classes[13] = "CCC13 (Hebrew)";
classes[14] = "CCC14 (Hebrew)";
classes[15] = "CCC15 (Hebrew)";
classes[16] = "CCC16 (Hebrew)";
classes[17] = "CCC17 (Hebrew)";
classes[18] = "CCC18 (Hebrew)";
classes[19] = "CCC19 (Hebrew)";
classes[20] = "CCC20 (Hebrew)";
classes[21] = "CCC21 (Hebrew)";
classes[22] = "CCC22 (Hebrew)";
classes[23] = "CCC23 (Hebrew)";
classes[24] = "CCC24 (Hebrew)";
classes[25] = "CCC25 (Hebrew)";
classes[26] = "CCC26 (Hebrew)";
classes[27] = "CCC27 (Arabic)";
classes[28] = "CCC28 (Arabic)";
classes[29] = "CCC29 (Arabic)";
classes[30] = "CCC30 (Arabic)";
classes[31] = "CCC31 (Arabic)";
classes[32] = "CCC32 (Arabic)";
classes[33] = "CCC33 (Arabic)";
classes[34] = "CCC34 (Arabic)";
classes[35] = "CCC35 (Arabic)";
classes[36] = "CCC36 (Syriac)";
classes[84] = "CCC84 (Telugu)";
classes[85] = "CCC85 (Telugu)";
classes[103] = "CCC103 (Thai)";
classes[107] = "CCC107 (Thai)";
classes[118] = "CCC118 (Lao)";
classes[122] = "CCC122 (Lao)";
classes[129] = "CCC129 (Tibetan)";
classes[130] = "CCC130 (Tibetan)";
classes[133] = "CCC133 (Tibetan)";
classes[200] = "Attached Below Left";
classes[202] = "Attached Below";
classes[214] = "Attached Above";
classes[216] = "Attached Above Right";
classes[218] = "Below Left";
classes[220] = "Below";
classes[222] = "Below Right";
classes[224] = "Left";
classes[226] = "Right";
classes[228] = "Above Left";
classes[230] = "Above";
classes[232] = "Above Right";
classes[233] = "Double Below";
classes[234] = "Double Above";
classes[240] = "Iota Subscript";
classes[255] = "Invalid";
if (cclass < 256 && classes[cclass] != NULL)
return classes[cclass];
return "Unknown";
}
+7
View File
@@ -0,0 +1,7 @@
#pragma once
#include <glib.h>
const char * get_unicode_type_name (GUnicodeType type);
const char * get_break_type_name (GUnicodeBreakType type);
const char * get_combining_class_name (int cclass);
+33
View File
@@ -0,0 +1,33 @@
uniform float progress;
uniform sampler2D u_texture1;
uniform sampler2D u_texture2;
vec4 getFromColor (vec2 uv) {
return GskTexture(u_texture1, uv);
}
vec4 getToColor (vec2 uv) {
return GskTexture(u_texture2, uv);
}
// Source: https://gl-transitions.com/editor/wind
// Author: gre
// License: MIT
const float size = 0.2;
float rand(vec2 co) {
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
vec4 transition(vec2 p) {
float r = rand(vec2(0, p.y));
float m = smoothstep(0.0, -size, p.x*(1.0-size) + size*r - (progress * (1.0 + size)));
return mix(getFromColor(p), getToColor(p), m);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv)
{
fragColor = transition(uv);
}
+11 -2
View File
@@ -171,6 +171,8 @@ text_changed (GtkTextBuffer *buffer,
GskRenderNode *node;
char *text;
GBytes *bytes;
GtkTextIter iter;
GtkTextIter start, end;
g_array_remove_range (self->errors, 0, self->errors->len);
text = get_current_text (self->text_buffer);
@@ -208,8 +210,6 @@ text_changed (GtkTextBuffer *buffer,
gtk_picture_set_paintable (GTK_PICTURE (self->picture), NULL);
}
GtkTextIter iter;
gtk_text_buffer_get_start_iter (self->text_buffer, &iter);
while (!gtk_text_iter_is_end (&iter))
@@ -272,6 +272,10 @@ text_changed (GtkTextBuffer *buffer,
gtk_text_iter_forward_char (&iter);
}
gtk_text_buffer_get_bounds (self->text_buffer, &start, &end);
gtk_text_buffer_apply_tag_by_name (self->text_buffer, "no-hyphens",
&start, &end);
}
static gboolean
@@ -898,6 +902,11 @@ node_editor_window_init (NodeEditorWindow *self)
"name", "number",
"foreground-rgba", &(GdkRGBA) { 0.8, 0.52, 0.43, 1},
NULL));
gtk_text_tag_table_add (self->tag_table,
g_object_new (GTK_TYPE_TEXT_TAG,
"name", "no-hyphens",
"insert-hyphens", FALSE,
NULL));
self->text_buffer = gtk_text_buffer_new (self->tag_table);
g_signal_connect (self->text_buffer, "changed", G_CALLBACK (text_changed), self);
+3 -2
View File
@@ -517,7 +517,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkEntry" id="entry2">
<property name="sensitive">0</property>
<property name="invisible-char">•</property>
<property name="text" translatable="yes">entry</property>
</object>
</child>
@@ -528,7 +527,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
</style>
<child>
<object class="GtkEntry" id="entry24">
<property name="invisible-char"></property>
<property name="enable-emoji-completion">1</property>
<property name="text" translatable="yes">entry</property>
<property name="hexpand">1</property>
</object>
@@ -1012,6 +1011,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="restrict-to-fill-level">0</property>
<property name="fill-level">75</property>
<property name="digits">-1</property>
<property name="draw-value">1</property>
<property name="halign">end</property>
</object>
</child>
@@ -1024,6 +1024,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="restrict-to-fill-level">0</property>
<property name="fill-level">75</property>
<property name="digits">-1</property>
<property name="draw-value">1</property>
<property name="halign">start</property>
</object>
</child>
-5
View File
@@ -961,7 +961,6 @@ gdk_wayland_display_query_registry
gdk_wayland_display_set_cursor_theme
gdk_wayland_display_get_startup_notification_id
gdk_wayland_display_set_startup_notification_id
gdk_wayland_display_prefers_ssd
gdk_wayland_display_query_registry
<SUBSECTION Device>
@@ -970,7 +969,6 @@ gdk_wayland_device_get_wl_seat
gdk_wayland_device_get_wl_pointer
gdk_wayland_device_get_wl_keyboard
gdk_wayland_device_get_node_ath
gdk_wayland_device_pad_set_feedback
<SUBSECTION Monitor>
gdk_wayland_monitor_get_wl_output
@@ -982,9 +980,6 @@ gdk_wayland_toplevel_export_handle
gdk_wayland_toplevel_unexport_handle
gdk_wayland_toplevel_set_transient_for_exported
gdk_wayland_toplevel_set_application_id
gdk_wayland_toplevel_announce_csd
gdk_wayland_toplevel_inhibit_idle
gdk_wayland_toplevel_uninhibit_idle
<SUBSECTION Standard>
GDK_TYPE_WAYLAND_DEVICE
+1
View File
@@ -20,6 +20,7 @@
<xi:include href="xml/GskRenderNode.xml" />
<xi:include href="xml/GskRoundedRect.xml" />
<xi:include href="xml/GskTransform.xml" />
<xi:include href="xml/GskGLShader.xml" />
</reference>
<index id="api-index-full">
+51
View File
@@ -48,6 +48,7 @@ GskShadowNode
GskTextNode
GskTextureNode
GskTransformNode
GskGLShaderNode
gsk_render_node_ref
gsk_render_node_unref
GskRenderNodeType
@@ -152,6 +153,11 @@ gsk_blur_node_get_radius
gsk_debug_node_new
gsk_debug_node_get_child
gsk_debug_node_get_message
gsk_gl_shader_node_new
gsk_gl_shader_node_get_n_children
gsk_gl_shader_node_get_child
gsk_gl_shader_node_get_args
gsk_gl_shader_node_get_shader
<SUBSECTION Standard>
GSK_IS_RENDER_NODE
GSK_RENDER_NODE
@@ -177,6 +183,7 @@ GSK_TYPE_SHADOW_NODE
GSK_TYPE_TEXT_NODE
GSK_TYPE_TEXTURE_NODE
GSK_TYPE_TRANSFORM_NODE
GSK_TYPE_GLSHADER_NODE
GskRenderNodeClass
gsk_blend_node_get_type
gsk_blur_node_get_type
@@ -202,6 +209,7 @@ gsk_shadow_node_get_type
gsk_text_node_get_type
gsk_texture_node_get_type
gsk_transform_node_get_type
gsk_gl_shader_node_get_type
GSK_TYPE_BLEND_MODE
<SUBSECTION Standard>
gsk_serialization_error_quark
@@ -266,3 +274,46 @@ gsk_transform_get_type
gsk_transform_new
</SECTION>
<SECTION>
<FILE>GskGLShader</FILE>
GskGLShader
gsk_gl_shader_new_from_bytes
gsk_gl_shader_new_from_resource
gsk_gl_shader_compile
gsk_gl_shader_get_source
gsk_gl_shader_get_n_textures
gsk_gl_shader_get_n_uniforms
gsk_gl_shader_get_uniform_name
gsk_gl_shader_find_uniform_by_name
gsk_gl_shader_get_uniform_type
gsk_gl_shader_get_uniform_offset
gsk_gl_shader_get_args_size
<SUBSECTION Uniform Data>
gsk_gl_shader_get_arg_float
gsk_gl_shader_get_arg_int
gsk_gl_shader_get_arg_uint
gsk_gl_shader_get_arg_bool
gsk_gl_shader_get_arg_vec2
gsk_gl_shader_get_arg_vec3
gsk_gl_shader_get_arg_vec4
gsk_gl_shader_format_args_va
gsk_gl_shader_format_args
<SUBSECTION Shader Args Builder>
GskShaderArgsBuilder
gsk_shader_args_builder_new
gsk_shader_args_builder_to_args
gsk_shader_args_builder_free_to_args
gsk_shader_args_builder_unref
gsk_shader_args_builder_ref
gsk_shader_args_builder_set_float
gsk_shader_args_builder_set_int
gsk_shader_args_builder_set_uint
gsk_shader_args_builder_set_bool
gsk_shader_args_builder_set_vec2
gsk_shader_args_builder_set_vec3
gsk_shader_args_builder_set_vec4
</SECTION>
+1
View File
@@ -1,2 +1,3 @@
gsk_render_node_get_type
gsk_renderer_get_type
gsk_gl_shader_get_type
+25 -13
View File
@@ -1030,6 +1030,12 @@ gtk_text_get_tabs
gtk_text_grab_focus_without_selecting
gtk_text_set_extra_menu
gtk_text_get_extra_menu
gtk_text_set_enable_emoji_completion
gtk_text_get_enable_emoji_completion
gtk_text_set_propagate_text_width
gtk_text_get_propagate_text_width
gtk_text_set_truncate_multiline
gtk_text_get_truncate_multiline
<SUBSECTION Private>
gtk_text_get_type
</SECTION>
@@ -2780,24 +2786,26 @@ gtk_spin_button_new_with_range
gtk_spin_button_set_adjustment
gtk_spin_button_get_adjustment
gtk_spin_button_set_digits
gtk_spin_button_get_digits
gtk_spin_button_set_increments
gtk_spin_button_get_increments
gtk_spin_button_set_range
gtk_spin_button_get_range
gtk_spin_button_get_value_as_int
gtk_spin_button_set_value
gtk_spin_button_set_update_policy
gtk_spin_button_set_numeric
gtk_spin_button_spin
gtk_spin_button_set_wrap
gtk_spin_button_set_snap_to_ticks
gtk_spin_button_update
gtk_spin_button_get_digits
gtk_spin_button_get_increments
gtk_spin_button_get_numeric
gtk_spin_button_get_range
gtk_spin_button_get_snap_to_ticks
gtk_spin_button_get_update_policy
gtk_spin_button_get_value
gtk_spin_button_set_update_policy
gtk_spin_button_get_update_policy
gtk_spin_button_set_numeric
gtk_spin_button_get_numeric
gtk_spin_button_set_wrap
gtk_spin_button_get_wrap
gtk_spin_button_set_snap_to_ticks
gtk_spin_button_get_snap_to_ticks
gtk_spin_button_set_climb_rate
gtk_spin_button_get_climb_rate
gtk_spin_button_spin
gtk_spin_button_update
GTK_INPUT_ERROR
<SUBSECTION Standard>
GTK_SPIN_BUTTON
@@ -4299,6 +4307,7 @@ gtk_snapshot_push_blend
gtk_snapshot_push_blur
gtk_snapshot_push_shadow
gtk_snapshot_push_debug
gtk_snapshot_push_gl_shader
gtk_snapshot_pop
gtk_snapshot_save
gtk_snapshot_restore
@@ -4740,7 +4749,7 @@ gtk_is_initialized
GTK_PRIORITY_RESIZE
<SUBSECTION>
GtkDebugFlag
GtkDebugFlags
gtk_get_debug_flags
gtk_set_debug_flags
@@ -4927,6 +4936,7 @@ GTK_TYPE_ICON_LOOKUP_FLAGS
GtkIconThemeError
gtk_icon_theme_new
gtk_icon_theme_get_for_display
gtk_icon_theme_get_display
gtk_icon_theme_set_search_path
gtk_icon_theme_get_search_path
gtk_icon_theme_add_search_path
@@ -6140,6 +6150,8 @@ gtk_popover_get_has_arrow
gtk_popover_set_offset
gtk_popover_get_offset
gtk_popover_set_default_widget
gtk_popover_set_cascade_popdown
gtk_popover_get_cascade_popdown
<SUBSECTION Standard>
GTK_TYPE_POPOVER
GTK_IS_POPOVER
+63 -11
View File
@@ -220,6 +220,18 @@ replace many uses of gtk_container_add() with equivalent container-specific
APIs such as gtk_box_pack_start() or gtk_grid_attach(), and thereby reduce
the amount of work you have to do at the time of the switch.
### Review your use of icon resources
When using icons as resources, the behavior of GTK 4 is different in one
respect: Icons that are directly in $APP_ID/icons/ are treated as unthemed
icons, which also means that symbolic icons are not recolored. If you want
your icon resources to have icon theme semantics, they need to be placed
into theme subdirectories such as $APP_ID/icons/16x16/actions or
$APP_ID/icons/scalable/status.
This location works fine in GTK 3 too, so you can prepare for this change
before switching to GTK 4.
## Changes that need to be done at the time of the switch
This section outlines porting tasks that you need to tackle when
@@ -265,15 +277,22 @@ with surfaces, you may have to change it to call the API in these
interfaces, depending on whether the surface you are dealing with
is a toplevel or a popup.
As part of this reorganization, X11-only concepts such as sticky or
keep-below have been removed. If you need to use them on your X11 windows,
you will have to set the corresponding X11 properties (as specified in the
EWMH) yourself. Subsurfaces are only supported with the Wayland backend,
using gdk_wayland_surface_new_subsurface(). Native and foreign subwindows
are no longer supported. These concepts were complicating the code and
could not be supported across backends.
As part of this reorganization, X11-only concepts such as sticky,
keep-below, urgency, skip-taskbar or window groups have either been
removed or moved to X11 backend api. If you need to use them on your
X11 windows, you will have to use those backend apis or set the
corresponding X11 properties (as specified in the EWMH) yourself.
gdk_window_reparent() is no longer available.
Subsurfaces are only supported with the Wayland backend, using
gdk_wayland_surface_new_subsurface(). Native and foreign subwindows
are no longer supported. These concepts were complicating the code
and could not be supported across backends.
A number of GdkWindow APIs are no longer available. This includes
gdk_window_reparent(), gdk_window_set_geometry_hints(), gdk_window_raise(),
gdk_window_restack(), gdk_window_move(), gdk_window_resize(). If
you need to manually control the position or stacking of your X11
windows, you you will have to use Xlib apis.
A number of minor API cleanups have happened in GdkSurface
as well. For example, gdk_surface_input_shape_combine_region()
@@ -286,9 +305,9 @@ gdk_toplevel_begin_resize().
The %GDK_TOPLEVEL_STATE_ICONIFIED value of the #GdkSurfaceState enumeration
is now %GDK_TOPLEVEL_STATE_MINIMIZED in the #GdkToplevelState enumeration.
The #GdkWindow functions <function>gdk_window_iconify()</function>
and <function>gdk_window_deiconify()</function> have been renamed to
gdk_toplevel_minimize() and gdk_toplevel_present(), respectively.
The #GdkWindow functions gdk_window_iconify() and gdk_window_deiconify()
have been renamed to gdk_toplevel_minimize() and gdk_toplevel_present(),
respectively.
The behavior of the minimization and unminimization operations have
not been changed, and they still require support from the underlying
@@ -447,6 +466,17 @@ GtkButtonBox has been removed. Use a GtkBox instead.
The GtkBox pack-start and -end methods have been replaced by gtk_box_prepend()
and gtk_box_append(). You can also reorder box children as necessary.
### Adapt to GtkWindow API changes
Following the GdkSurface changes, a number of GtkWindow APIs that were
X11-specific have been removed. This includes gtk_window_set_geometry_hints(),
gtk_window_set_gravity(), gtk_window_move(), gtk_window_parse_geometry(),
gtk_window_set_keep_above(), gtk_window_set_keep_below(),
gtk_window_begin_resize_drag(), gtk_window_begin_move_drag().
Most likely, you should just stop using them. In some cases, you can
fall back to using the underlying #GdkToplevel APIS (for example,
gdk_toplevel_begin_resize()).
### Adapt to GtkHeaderBar and GtkActionBar API changes
The gtk_header_bar_set_show_close_button() function has been renamed to
@@ -879,6 +909,15 @@ gtk_search_entry_handle_event() has been dropped and replaced by
gtk_search_entry_set_key_capture_widget() and
gtk_event_controller_key_forward().
### Adapt to GtkScale changes
The default value of #GtkScale:draw-value has been changed to %FALSE.
If you want your scales to draw values, you will have to set this
property explicitly now.
gtk4-builder-tool can help with this conversion, with the --3to4 option
of the simplify command.
### Stop using gtk_window_activate_default()
The handling of default widgets has been changed, and activating
@@ -998,6 +1037,14 @@ of a #GtkIconInfo. It always returns a paintable in the requested size, and
never fails. A number of no-longer-relevant lookup flags and API variants
have been removed.
Note that while GTK 4 is moving towards #GdkPaintable as a primary API
for paintable content, it is meant to be a 'pure' content producer, therefore
a #GtkIconPaintable for a symbolic icon will *not* get recolored depending
on the context it is rendered it. To properly render a symbolic icon that
is provided in the form of a #GtkIconPaintable (this can be checked with
gtk_icon_paintable_is_symbolic()), you have to call
gtk_icon_paintable_get_icon_name() and set the icon name on a #GtkImage.
### Update to GtkFileChooser API changes
GtkFileChooser moved to a GFile-based API. If you need to convert a
@@ -1048,6 +1095,11 @@ getter function to retrieve the buildable ID. If you are
using gtk_buildable_get_name() you should replace it with
gtk_buildable_get_buildable_id().
### Adapt to GtkAboutDialog API changes
GtkAboutDialog now directly derives from GtkWindow, the GtkDialog API can no
longer be used on it.
## Changes to consider after the switch
GTK 4 has a number of new features that you may want to take
@@ -48,18 +48,28 @@ Each role name is part of the #GtkAccessibleRole enumeration.
| `BUTTON` | A control that performs an action when pressed | #GtkButton, #GtkLinkButton, #GtkExpander |
| `CHECKBOX` | A control that has three possible value: `true`, `false`, or `undefined` | #GtkCheckButton |
| `COMBOBOX` | A control that can be expanded to show a list of possible values to select | #GtkComboBox |
| `COLUMN_HEADER` | A header in a columned list | #GtkColumnView |
| `DIALOG` | A dialog that prompts the user to enter information or require a response | #GtkDialog and subclasses |
| `GRID` | A grid of items | #GtkFlowBox, #GtkGridView |
| `GRID_CELL` | An item in a grid | #GtkFlowBoxChild, #GtkGridView, #GtkColumnView |
| `IMG` | An image | #GtkImage, #GtkPicture |
| `LABEL` | A visible name or caption for a user interface component | #GtkLabel |
| `LIST` | A list of items | #GtkListBox |
| `LIST_ITEM` | An item in a list | #GtkListBoxRow |
| `METER` | Represents a value within a known range | #GtkLevelBar |
| `PROGRESS_BAR` | An element that display progress | #GtkProgressBar |
| `RADIO` | A checkable input in a group of radio roles | #GtkCheckButton |
| `ROW` | A row in a columned list | #GtkColumnView |
| `SCROLLBAR` | A graphical object controlling the scrolling of content | #GtkScrollbar |
| `SEARCH_BOX` | A text box for entering search criteria | #GtkSearchEntry |
| `SEPARATOR` | A divider that separates sections of content or groups of items | #GtkSeparator |
| `SPIN_BUTTON` | A range control that allows seelcting among discrete choices | #GtkSpinButton |
| `SWITCH` | A control that represents on/off values | #GtkSwitch |
| `TAB` | A tab in a list of tabs for switching pages | #GtkStackSwitcher, #GtkNotebook |
| `TAB_LIST` | A list of tabs for switching pages | #GtkStackSwitcher, #GtkNotebook |
| `TAB_PANEL` | A page in a notebook or stack | #GtkStack |
| `TEXT_BOX` | A type of input that allows free-form text as its value. | #GtkEntry, #GtkPasswordEntry, #GtkTextView |
| `TREE_GRID` | A treeview-like columned list | #GtkColumnView |
| `WINDOW` | An application window | #GtkWindow |
| `...` | … |
+3 -7
View File
@@ -1,15 +1,11 @@
if get_option('gtk_doc')
if not meson.version().version_compare('>=0.52.0')
error('Building the GTK documentation requires Meson 0.52.0')
endif
glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix')
glib_prefix = dependency('glib-2.0').get_variable(pkgconfig: 'prefix', default_value: '/usr')
glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html')
cairo_prefix = dependency('cairo-gobject').get_pkgconfig_variable('prefix')
cairo_prefix = dependency('cairo-gobject').get_variable(pkgconfig: 'prefix', default_value: '/usr')
cairo_docpath = join_paths(cairo_prefix, 'share', 'gtk-doc', 'html', 'cairo')
gdkpixbuf_prefix = dependency('gdk-pixbuf-2.0').get_pkgconfig_variable('prefix')
gdkpixbuf_prefix = dependency('gdk-pixbuf-2.0').get_variable(pkgconfig: 'prefix', default_value: '/usr')
gdkpixbuf_docpath = join_paths(gdkpixbuf_prefix, 'share', 'gtk-doc', 'html', 'gdk-pixbuf')
docpath = join_paths(gtk_datadir, 'gtk-doc', 'html')
+5 -2
View File
@@ -1101,11 +1101,14 @@ create_moveresize_surface (MoveResizeData *mv_resize,
GdkGrabStatus status;
GdkSeat *seat;
GdkDevice *pointer;
GdkRectangle rect = { -100, -100, 1, 1 };
g_assert (mv_resize->moveresize_emulation_surface == NULL);
mv_resize->moveresize_emulation_surface = gdk_surface_new_temp (mv_resize->display, &rect);
mv_resize->moveresize_emulation_surface =
_gdk_broadway_display_create_surface (mv_resize->display,
GDK_SURFACE_TEMP,
NULL,
-100, -100, 1, 1);
gdk_broadway_surface_show (mv_resize->moveresize_emulation_surface, FALSE);
+3 -3
View File
@@ -49,11 +49,11 @@
/**
* SECTION:general
* @Short_description: Library initialization and miscellaneous functions
* @Short_description: Library initialization and versioning
* @Title: General
*
* This section describes the GDK initialization functions and miscellaneous
* utility functions, as well as deprecation facilities.
* This section describes miscellaneous macros and utility functions
* related to library versioning, as well as deprecation facilities.
*
* The GDK and GTK headers annotate deprecated APIs in a way that produces
* compiler warnings if these deprecated APIs are used. The warnings
+5 -3
View File
@@ -141,7 +141,7 @@ gdk_array(is_empty) (const GdkArray *self)
return self->end == self->start;
}
G_GNUC_UNUSED static void
G_GNUC_UNUSED static inline void
gdk_array(reserve) (GdkArray *self,
gsize n)
{
@@ -178,7 +178,7 @@ gdk_array(reserve) (GdkArray *self,
#endif
}
G_GNUC_UNUSED static void
G_GNUC_UNUSED static inline void
gdk_array(splice) (GdkArray *self,
gsize pos,
gsize removed,
@@ -208,8 +208,10 @@ gdk_array(splice) (GdkArray *self,
memcpy (gdk_array(index) (self, pos),
additions,
added * sizeof (_T_));
#ifndef GDK_ARRAY_NO_MEMSET
else
memset (gdk_array(index) (self, pos), 0, added * sizeof (_T_));
#endif
}
@@ -279,5 +281,5 @@ gdk_array(get) (const GdkArray *self,
#undef GDK_ARRAY_NULL_TERMINATED
#undef GDK_ARRAY_PREALLOC
#undef GDK_ARRAY_TYPE_NAME
#undef GDK_ARRAY_NO_MEMSET
#endif
+1 -1
View File
@@ -681,7 +681,7 @@ gdk_clipboard_read_async (GdkClipboard *clipboard,
*
* Finishes an asynchronous clipboard read started with gdk_clipboard_read_async().
*
* Returns: (transfer full): a #GInputStream or %NULL on error.
* Returns: (transfer full) (nullable): a #GInputStream or %NULL on error.
**/
GInputStream *
gdk_clipboard_read_finish (GdkClipboard *clipboard,
+1 -1
View File
@@ -385,7 +385,7 @@ gdk_content_formats_match_gtype (const GdkContentFormats *first,
* in @second. If no matching mime type is found, %NULL is
* returned.
*
* Returns: The first common mime type or %NULL if none.
* Returns: (nullable): The first common mime type or %NULL if none.
**/
const char *
gdk_content_formats_match_mime_type (const GdkContentFormats *first,
+4 -78
View File
@@ -131,19 +131,6 @@ gdk_display_real_opened (GdkDisplay *display)
_gdk_display_manager_add_display (gdk_display_manager_get (), display);
}
static void
gdk_display_real_event_data_copy (GdkDisplay *display,
GdkEvent *src,
GdkEvent *dst)
{
}
static void
gdk_display_real_event_data_free (GdkDisplay *display,
GdkEvent *dst)
{
}
static GdkSeat *
gdk_display_real_get_default_seat (GdkDisplay *display)
{
@@ -165,8 +152,6 @@ gdk_display_class_init (GdkDisplayClass *class)
class->get_app_launch_context = gdk_display_real_get_app_launch_context;
class->opened = gdk_display_real_opened;
class->make_default = gdk_display_real_make_default;
class->event_data_copy = gdk_display_real_event_data_copy;
class->event_data_free = gdk_display_real_event_data_free;
class->get_default_seat = gdk_display_real_get_default_seat;
/**
@@ -408,13 +393,13 @@ gdk_display_is_closed (GdkDisplay *display)
return display->closed;
}
/**
/*<private>
* gdk_display_get_event:
* @display: a #GdkDisplay
*
*
* Gets the next #GdkEvent to be processed for @display, fetching events from the
* windowing system if necessary.
*
*
* Returns: (nullable) (transfer full): the next #GdkEvent to be processed,
* or %NULL if no events are pending
*/
@@ -429,33 +414,6 @@ gdk_display_get_event (GdkDisplay *display)
return _gdk_event_unqueue (display);
}
/**
* gdk_display_peek_event:
* @display: a #GdkDisplay
*
* Gets a copy of the first #GdkEvent in the @displays event queue, without
* removing the event from the queue. (Note that this function will
* not get more events from the windowing system. It only checks the events
* that have already been moved to the GDK event queue.)
*
* Returns: (nullable) (transfer full): the first #GdkEvent on the
* event queue
**/
GdkEvent *
gdk_display_peek_event (GdkDisplay *display)
{
GList *tmp_list;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
tmp_list = _gdk_event_queue_find_first (display);
if (tmp_list != NULL)
return gdk_event_ref (tmp_list->data);
return NULL;
}
/**
* gdk_display_put_event:
* @display: a #GdkDisplay
@@ -1113,23 +1071,6 @@ gdk_display_open (const char *display_name)
display_name);
}
/**
* gdk_display_has_pending:
* @display: a #GdkDisplay
*
* Returns whether the display has events that are waiting
* to be processed.
*
* Returns: %TRUE if there are events ready to be processed.
*/
gboolean
gdk_display_has_pending (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
return GDK_DISPLAY_GET_CLASS (display)->has_pending (display);
}
gulong
_gdk_display_get_next_serial (GdkDisplay *display)
{
@@ -1166,7 +1107,7 @@ gdk_display_notify_startup_complete (GdkDisplay *display,
* Gets the startup notification ID for a Wayland display, or %NULL
* if no ID has been defined.
*
* Returns: the startup notification ID for @display, or %NULL
* Returns: (nullable): the startup notification ID for @display, or %NULL
*/
const char *
gdk_display_get_startup_notification_id (GdkDisplay *display)
@@ -1193,21 +1134,6 @@ _gdk_display_unpause_events (GdkDisplay *display)
display->event_pause_count--;
}
void
_gdk_display_event_data_copy (GdkDisplay *display,
GdkEvent *event,
GdkEvent *new_event)
{
GDK_DISPLAY_GET_CLASS (display)->event_data_copy (display, event, new_event);
}
void
_gdk_display_event_data_free (GdkDisplay *display,
GdkEvent *event)
{
GDK_DISPLAY_GET_CLASS (display)->event_data_free (display, event);
}
GdkSurface *
gdk_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
-12
View File
@@ -135,11 +135,6 @@ struct _GdkDisplayClass
const char *startup_id);
const char * (*get_startup_notification_id) (GdkDisplay *display);
void (*event_data_copy) (GdkDisplay *display,
GdkEvent *event,
GdkEvent *new_event);
void (*event_data_free) (GdkDisplay *display,
GdkEvent *event);
GdkSurface * (*create_surface) (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
@@ -208,11 +203,6 @@ void _gdk_display_pointer_info_foreach (GdkDisplay *display
gulong _gdk_display_get_next_serial (GdkDisplay *display);
void _gdk_display_pause_events (GdkDisplay *display);
void _gdk_display_unpause_events (GdkDisplay *display);
void _gdk_display_event_data_copy (GdkDisplay *display,
GdkEvent *event,
GdkEvent *new_event);
void _gdk_display_event_data_free (GdkDisplay *display,
GdkEvent *event);
GdkSurface * gdk_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
@@ -241,8 +231,6 @@ void gdk_display_setting_changed (GdkDisplay *display
const char *name);
GdkEvent * gdk_display_get_event (GdkDisplay *display);
GdkEvent * gdk_display_peek_event (GdkDisplay *display);
gboolean gdk_display_has_pending (GdkDisplay *display);
GdkKeymap * gdk_display_get_keymap (GdkDisplay *display);
-4
View File
@@ -147,10 +147,6 @@ value_event_lcopy_value (const GValue *value,
static void
gdk_event_finalize (GdkEvent *self)
{
GdkDisplay *display = gdk_event_get_display (self);
if (display != NULL)
_gdk_display_event_data_free (display, self);
g_clear_object (&self->surface);
g_clear_object (&self->device);
+3 -16
View File
@@ -27,7 +27,7 @@
#include <string.h>
static const char *
get_vertex_type_name (int type)
get_shader_type_name (int type)
{
switch (type)
{
@@ -64,7 +64,7 @@ create_shader (int type,
buffer = g_malloc (log_len + 1);
glGetShaderInfoLog (shader, log_len, NULL, buffer);
g_warning ("Compile failure in %s shader:\n%s", get_vertex_type_name (type), buffer);
g_warning ("Compile failure in %s shader:\n%s", get_shader_type_name (type), buffer);
g_free (buffer);
glDeleteShader (shader);
@@ -328,10 +328,8 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
{
GdkGLContext *paint_context;
cairo_surface_t *image;
cairo_matrix_t matrix;
guint framebuffer;
int alpha_size = 0;
cairo_region_t *clip_region;
GdkGLContextPaintData *paint_data;
int major, minor, version;
gboolean es_use_bgra = FALSE;
@@ -343,7 +341,6 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
return;
}
clip_region = gdk_cairo_region_from_clip (cr);
es_use_bgra = gdk_gl_context_use_es_bgra (paint_context);
gdk_gl_context_make_current (paint_context);
@@ -372,8 +369,6 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
return;
}
cairo_get_matrix (cr, &matrix);
gdk_gl_context_get_version (paint_context, &major, &minor);
version = major * 100 + minor;
@@ -382,7 +377,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
*/
if (gdk_gl_context_get_use_es (paint_context) &&
!(version >= 300 || gdk_gl_context_has_unpack_subimage (paint_context)))
goto out;
return;
/* TODO: avoid reading back non-required data due to dest clip */
image = cairo_surface_create_similar_image (cairo_get_target (cr),
@@ -424,17 +419,9 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
cairo_surface_mark_dirty (image);
/* Invert due to opengl having different origin */
cairo_scale (cr, 1, -1);
cairo_translate (cr, 0, -height / buffer_scale);
cairo_set_source_surface (cr, image, 0, 0);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_paint (cr);
cairo_surface_destroy (image);
out:
if (clip_region)
cairo_region_destroy (clip_region);
}
+10 -10
View File
@@ -864,7 +864,6 @@ gdk_gl_context_get_use_es (GdkGLContext *context)
return priv->use_es > 0;
}
#ifdef G_ENABLE_CONSISTENCY_CHECKS
static void
gl_debug_message_callback (GLenum source,
GLenum type,
@@ -955,7 +954,6 @@ gl_debug_message_callback (GLenum source,
g_warning ("OPENGL:\n Source: %s\n Type: %s\n Severity: %s\n Message: %s",
message_source, message_type, message_severity, message);
}
#endif
/**
* gdk_gl_context_realize:
@@ -1008,15 +1006,22 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
priv->has_debug_output = epoxy_has_gl_extension ("GL_ARB_debug_output") ||
epoxy_has_gl_extension ("GL_KHR_debug");
#ifdef G_ENABLE_CONSISTENCY_CHECKS
if (priv->has_debug_output)
#ifdef G_ENABLE_DEBUG
display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
gl_debug = GDK_DISPLAY_DEBUG_CHECK (display, GL_DEBUG);
#endif
if (priv->has_debug_output
#ifndef G_ENABLE_CONSISTENCY_CHECKS
&& gl_debug
#endif
)
{
gdk_gl_context_make_current (context);
glEnable (GL_DEBUG_OUTPUT);
glEnable (GL_DEBUG_OUTPUT_SYNCHRONOUS);
glDebugMessageCallback (gl_debug_message_callback, NULL);
}
#endif
if (priv->use_es)
{
@@ -1039,11 +1044,6 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
priv->is_legacy = TRUE;
}
#ifdef G_ENABLE_DEBUG
display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
gl_debug = GDK_DISPLAY_DEBUG_CHECK (display, GL_DEBUG);
#endif
if (priv->has_khr_debug && gl_debug)
{
priv->use_khr_debug = TRUE;
-1
View File
@@ -30,4 +30,3 @@
#include <stdio.h>
guint _gdk_debug_flags = 0;
GList *_gdk_default_filters = NULL;
+1
View File
@@ -78,6 +78,7 @@ GDK_AVAILABLE_IN_ALL
GList * gdk_seat_get_devices (GdkSeat *seat,
GdkSeatCapabilities capabilities);
GDK_AVAILABLE_IN_ALL
GList * gdk_seat_get_tools (GdkSeat *seat);
GDK_AVAILABLE_IN_ALL
-23
View File
@@ -816,29 +816,6 @@ gdk_surface_new_toplevel (GdkDisplay *display)
NULL, 0, 0, 1, 1);
}
/**
* gdk_surface_new_temp: (constructor)
* @display: the display to create the surface on
* @position: position of the surface on screen
*
* Creates a new temporary surface.
* The surface will bypass surface management.
*
* Returns: (transfer full): the new #GdkSurface
**/
GdkSurface *
gdk_surface_new_temp (GdkDisplay *display,
const GdkRectangle *position)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_return_val_if_fail (position != NULL, NULL);
return gdk_surface_new (display, GDK_SURFACE_TEMP,
NULL,
position->x, position->y,
position->width, position->height);
}
/**
* gdk_surface_new_popup: (constructor)
* @parent: the parent surface to attach the surface to
-3
View File
@@ -277,9 +277,6 @@ void gdk_surface_enter_monitor (GdkSurface *surface,
void gdk_surface_leave_monitor (GdkSurface *surface,
GdkMonitor *monitor);
GdkSurface * gdk_surface_new_temp (GdkDisplay *display,
const GdkRectangle *position);
void gdk_surface_destroy_notify (GdkSurface *surface);
void gdk_synthesize_surface_state (GdkSurface *surface,
-13
View File
@@ -30,19 +30,6 @@
#include "gdkmacosdisplay-private.h"
#include "gdkmacossurface-private.h"
/* Text Input Client */
#define TIC_MARKED_TEXT "tic-marked-text"
#define TIC_SELECTED_POS "tic-selected-pos"
#define TIC_SELECTED_LEN "tic-selected-len"
#define TIC_INSERT_TEXT "tic-insert-text"
#define TIC_IN_KEY_DOWN "tic-in-key-down"
/* GtkIMContext */
#define GIC_CURSOR_RECT "gic-cursor-rect"
#define GIC_FILTER_KEY "gic-filter-key"
#define GIC_FILTER_PASSTHRU 0
#define GIC_FILTER_FILTERED 1
@implementation GdkMacosBaseView
-(id)initWithFrame:(NSRect)frameRect
+4 -3
View File
@@ -28,6 +28,7 @@
#import "GdkMacosWindow.h"
#include "gdkmacosdisplay-private.h"
#include "gdkmacosmonitor-private.h"
#include "gdkmacossurface-private.h"
#include "gdkmacospopupsurface-private.h"
#include "gdkmacostoplevelsurface-private.h"
@@ -125,8 +126,6 @@
GdkDisplay *display = gdk_surface_get_display (GDK_SURFACE (gdk_surface));
double time = ((double)[event timestamp]) * 1000.0;
_gdk_macos_display_break_all_grabs (GDK_MACOS_DISPLAY (display), time);
inManualMove = NO;
inManualResize = NO;
inMove = NO;
@@ -139,6 +138,8 @@
*/
_gdk_macos_display_send_button_event ([self gdkDisplay], event);
_gdk_macos_display_break_all_grabs (GDK_MACOS_DISPLAY (display), time);
break;
}
@@ -352,7 +353,7 @@
monitor = _gdk_macos_display_get_monitor_at_display_coords ([self gdkDisplay],
currentLocation.x,
currentLocation.y);
gdk_macos_monitor_get_geometry (monitor, &geometry);
gdk_monitor_get_geometry (monitor, &geometry);
gdk_macos_monitor_get_workarea (monitor, &workarea);
_edge_snapping_set_monitor (&self->snapping, &geometry, &workarea);
+2 -1
View File
@@ -28,8 +28,9 @@
#include "gdkmacoscursor-private.h"
#include "gdkmacosdevice.h"
#include "gdkmacosdisplay-private.h"
#include "gdkmacosdevice-private.h"
#include "gdkmacosdisplay-private.h"
#include "gdkmacossurface-private.h"
struct _GdkMacosDevice
{
+14
View File
@@ -30,6 +30,19 @@
G_BEGIN_DECLS
/* Text Input Client */
#define TIC_MARKED_TEXT "tic-marked-text"
#define TIC_SELECTED_POS "tic-selected-pos"
#define TIC_SELECTED_LEN "tic-selected-len"
#define TIC_INSERT_TEXT "tic-insert-text"
#define TIC_IN_KEY_DOWN "tic-in-key-down"
/* GtkIMContext */
#define GIC_CURSOR_RECT "gic-cursor-rect"
#define GIC_FILTER_KEY "gic-filter-key"
#define GIC_FILTER_PASSTHRU 0
#define GIC_FILTER_FILTERED 1
struct _GdkMacosDisplay
{
GdkDisplay parent_instance;
@@ -148,6 +161,7 @@ void _gdk_macos_display_send_button_event (GdkMacosDisp
void _gdk_macos_display_warp_pointer (GdkMacosDisplay *self,
int x,
int y);
NSEvent *_gdk_macos_display_get_nsevent (GdkEvent *event);
G_END_DECLS
+35 -42
View File
@@ -209,11 +209,6 @@ fill_button_event (GdkMacosDisplay *display,
g_assert (GDK_IS_MACOS_DISPLAY (display));
g_assert (GDK_IS_MACOS_SURFACE (surface));
/* Ignore button events outside the window coords */
if (x < 0 || x > GDK_SURFACE (surface)->width ||
y < 0 || y > GDK_SURFACE (surface)->height)
return NULL;
seat = gdk_display_get_default_seat (GDK_DISPLAY (display));
state = get_keyboard_modifiers_from_ns_event (nsevent) |
_gdk_macos_display_get_current_mouse_modifiers (display);
@@ -238,11 +233,18 @@ fill_button_event (GdkMacosDisplay *display,
g_assert_not_reached ();
}
/* Ignore button press events outside the window coords but
* allow for button release which can happen during grabs.
*/
if (type == GDK_BUTTON_PRESS &&
(x < 0 || x > GDK_SURFACE (surface)->width ||
y < 0 || y > GDK_SURFACE (surface)->height))
return NULL;
return gdk_button_event_new (type,
GDK_SURFACE (surface),
gdk_seat_get_pointer (seat),
NULL,
NULL,
get_time_from_ns_event (nsevent),
state,
get_mouse_button_from_ns_event (nsevent),
@@ -283,7 +285,6 @@ synthesize_crossing_event (GdkMacosDisplay *display,
return gdk_crossing_event_new (event_type,
GDK_SURFACE (surface),
gdk_seat_get_pointer (seat),
NULL,
get_time_from_ns_event (nsevent),
state,
x,
@@ -410,7 +411,6 @@ fill_key_event (GdkMacosDisplay *display,
return gdk_key_event_new (type,
GDK_SURFACE (surface),
gdk_seat_get_keyboard (seat),
NULL,
get_time_from_ns_event (nsevent),
[nsevent keyCode],
state,
@@ -526,7 +526,6 @@ fill_pinch_event (GdkMacosDisplay *display,
return gdk_touchpad_event_new_pinch (GDK_SURFACE (surface),
gdk_seat_get_pointer (seat),
NULL,
get_time_from_ns_event (nsevent),
get_keyboard_modifiers_from_ns_event (nsevent),
phase,
@@ -570,7 +569,6 @@ fill_motion_event (GdkMacosDisplay *display,
return gdk_motion_event_new (GDK_SURFACE (surface),
gdk_seat_get_pointer (seat),
NULL,
NULL,
get_time_from_ns_event (nsevent),
state,
x,
@@ -609,21 +607,13 @@ fill_scroll_event (GdkMacosDisplay *self,
double sx;
double sy;
/*
* TODO: We probably need another event type for the
* high precision scroll events since sx and dy
* are in a unit we don't quite support. For now,
* to slow it down multiply by .1.
*/
sx = [nsevent scrollingDeltaX] * .1;
sy = [nsevent scrollingDeltaY] * .1;
sx = [nsevent scrollingDeltaX];
sy = [nsevent scrollingDeltaY];
if (sx != 0.0 || dx != 0.0)
ret = gdk_scroll_event_new (GDK_SURFACE (surface),
pointer,
NULL,
NULL,
get_time_from_ns_event (nsevent),
state,
-sx,
@@ -661,7 +651,6 @@ fill_scroll_event (GdkMacosDisplay *self,
emulated = gdk_scroll_event_new_discrete (GDK_SURFACE (surface),
pointer,
NULL,
NULL,
get_time_from_ns_event (nsevent),
state,
direction,
@@ -675,7 +664,6 @@ fill_scroll_event (GdkMacosDisplay *self,
ret = gdk_scroll_event_new (GDK_SURFACE (surface),
pointer,
NULL,
NULL,
get_time_from_ns_event (nsevent),
state,
dx,
@@ -725,29 +713,23 @@ find_surface_under_pointer (GdkMacosDisplay *self,
int *y)
{
GdkPointerSurfaceInfo *info;
GdkSurface *surface;
GdkMacosSurface *found;
GdkSurface *surface = NULL;
GdkSeat *seat;
int x_tmp, y_tmp;
seat = gdk_display_get_default_seat (GDK_DISPLAY (self));
info = _gdk_display_get_pointer_info (GDK_DISPLAY (self),
gdk_seat_get_pointer (seat));
surface = info->surface_under_pointer;
if (surface == NULL)
if ((found = _gdk_macos_display_get_surface_at_display_coords (self,
screen_point.x,
screen_point.y,
&x_tmp,
&y_tmp)))
{
GdkMacosSurface *found;
found = _gdk_macos_display_get_surface_at_display_coords (self,
screen_point.x,
screen_point.y,
&x_tmp, &y_tmp);
if (found)
{
surface = GDK_SURFACE (found);
info->surface_under_pointer = g_object_ref (surface);
}
g_set_object (&info->surface_under_pointer, surface);
surface = GDK_SURFACE (found);
}
if (surface)
@@ -1135,10 +1117,21 @@ _gdk_macos_display_translate (GdkMacosDisplay *self,
break;
case NSEventTypeMouseExited:
[[NSCursor arrowCursor] set];
/* fallthrough */
case NSEventTypeMouseEntered:
ret = synthesize_crossing_event (self, surface, nsevent, x, y);
{
GdkSeat *seat = gdk_display_get_default_seat (GDK_DISPLAY (self));
GdkDevice *pointer = gdk_seat_get_pointer (seat);
GdkDeviceGrabInfo *grab = _gdk_display_get_last_device_grab (GDK_DISPLAY (self), pointer);
if (grab == NULL)
{
if (event_type == NSEventTypeMouseExited)
[[NSCursor arrowCursor] set];
ret = synthesize_crossing_event (self, surface, nsevent, x, y);
}
}
break;
case NSEventTypeKeyDown:
@@ -1188,14 +1181,14 @@ _gdk_macos_display_synthesize_motion (GdkMacosDisplay *self,
event = gdk_motion_event_new (GDK_SURFACE (surface),
gdk_seat_get_pointer (seat),
NULL,
NULL,
get_time_from_ns_event ([NSApp currentEvent]),
state,
x,
y,
NULL);
node = _gdk_event_queue_append (GDK_DISPLAY (self), event);
_gdk_windowing_got_event (GDK_DISPLAY (self), node, event, 0);
_gdk_windowing_got_event (GDK_DISPLAY (self), node, event,
_gdk_display_get_next_serial (GDK_DISPLAY (self)));
}
void
+63 -12
View File
@@ -74,7 +74,17 @@
G_DEFINE_TYPE (GdkMacosDisplay, gdk_macos_display, GDK_TYPE_DISPLAY)
#define EVENT_MAP_MAX_SIZE 10
typedef struct
{
GList link;
GdkEvent *gdk_event;
NSEvent *nsevent;
} GdkToNSEventMap;
static GSource *event_source;
static GQueue event_map = G_QUEUE_INIT;
static GdkMacosMonitor *
get_monitor (GdkMacosDisplay *self,
@@ -370,7 +380,8 @@ gdk_macos_display_sync (GdkDisplay *display)
static gulong
gdk_macos_display_get_next_serial (GdkDisplay *display)
{
return 0;
static gulong serial = 0;
return ++serial;
}
static gboolean
@@ -387,6 +398,28 @@ gdk_macos_display_notify_startup_complete (GdkDisplay *display,
/* Not Supported */
}
static void
push_nsevent (GdkEvent *gdk_event,
NSEvent *nsevent)
{
GdkToNSEventMap *map = g_slice_new0 (GdkToNSEventMap);
map->link.data = map;
map->gdk_event = gdk_event_ref (gdk_event);
map->nsevent = g_steal_pointer (&nsevent);
g_queue_push_tail_link (&event_map, &map->link);
if (event_map.length > EVENT_MAP_MAX_SIZE)
{
map = g_queue_pop_head_link (&event_map)->data;
gdk_event_unref (map->gdk_event);
[map->nsevent release];
g_slice_free (GdkToNSEventMap, map);
}
}
static void
gdk_macos_display_queue_events (GdkDisplay *display)
{
@@ -400,14 +433,18 @@ gdk_macos_display_queue_events (GdkDisplay *display)
GdkEvent *event = _gdk_macos_display_translate (self, nsevent);
if (event != NULL)
_gdk_windowing_got_event (GDK_DISPLAY (self),
_gdk_event_queue_append (GDK_DISPLAY (self), event),
event,
0);
{
push_nsevent (event, nsevent);
_gdk_windowing_got_event (GDK_DISPLAY (self),
_gdk_event_queue_append (GDK_DISPLAY (self), event),
event,
_gdk_display_get_next_serial (GDK_DISPLAY (self)));
}
else
[NSApp sendEvent:nsevent];
[nsevent release];
{
[NSApp sendEvent:nsevent];
[nsevent release];
}
}
}
@@ -467,7 +504,7 @@ _gdk_macos_display_surface_became_key (GdkMacosDisplay *self,
seat = gdk_display_get_default_seat (GDK_DISPLAY (self));
keyboard = gdk_seat_get_keyboard (seat);
event = gdk_focus_event_new (GDK_SURFACE (surface), keyboard, NULL, TRUE);
event = gdk_focus_event_new (GDK_SURFACE (surface), keyboard, TRUE);
_gdk_event_queue_append (GDK_DISPLAY (self), event);
/* We just became the active window. Unlike X11, Mac OS X does
@@ -493,7 +530,7 @@ _gdk_macos_display_surface_resigned_key (GdkMacosDisplay *self,
seat = gdk_display_get_default_seat (GDK_DISPLAY (self));
keyboard = gdk_seat_get_keyboard (seat);
event = gdk_focus_event_new (GDK_SURFACE (surface), keyboard, NULL, FALSE);
event = gdk_focus_event_new (GDK_SURFACE (surface), keyboard, FALSE);
_gdk_event_queue_append (GDK_DISPLAY (self), event);
}
@@ -861,11 +898,11 @@ _gdk_macos_display_break_all_grabs (GdkMacosDisplay *self,
event = gdk_grab_broken_event_new (grab->surface,
device,
NULL,
grab->surface,
TRUE);
node = _gdk_event_queue_append (GDK_DISPLAY (self), event);
_gdk_windowing_got_event (GDK_DISPLAY (self), node, event, 0);
_gdk_windowing_got_event (GDK_DISPLAY (self), node, event,
_gdk_display_get_next_serial (GDK_DISPLAY (self)));
}
}
}
@@ -1069,3 +1106,17 @@ _gdk_macos_display_warp_pointer (GdkMacosDisplay *self,
CGWarpMouseCursorPosition ((CGPoint) { x, y });
}
NSEvent *
_gdk_macos_display_get_nsevent (GdkEvent *event)
{
for (const GList *iter = event_map.head; iter; iter = iter->next)
{
const GdkToNSEventMap *map = iter->data;
if (map->gdk_event == event)
return map->nsevent;
}
return NULL;
}
+1
View File
@@ -30,6 +30,7 @@ G_BEGIN_DECLS
GdkMacosKeymap *_gdk_macos_keymap_new (GdkMacosDisplay *display);
GdkEventType _gdk_macos_keymap_get_event_type (NSEvent *event);
gboolean _gdk_macos_keymap_is_modifier (guint keycode);
gunichar _gdk_macos_keymap_get_equivalent (guint key);
G_END_DECLS
+147
View File
@@ -696,3 +696,150 @@ _gdk_macos_keymap_is_modifier (guint keycode)
return FALSE;
}
/*
* Code for key code conversion
*
* Copyright (C) 2009 Paul Davis
*/
gunichar
_gdk_macos_keymap_get_equivalent (guint key)
{
if (key >= GDK_KEY_A && key <= GDK_KEY_Z)
return key + (GDK_KEY_a - GDK_KEY_A);
if (key >= GDK_KEY_space && key <= GDK_KEY_asciitilde)
return key;
switch (key)
{
case GDK_KEY_BackSpace:
return NSBackspaceCharacter;
case GDK_KEY_Delete:
return NSDeleteFunctionKey;
case GDK_KEY_Pause:
return NSPauseFunctionKey;
case GDK_KEY_Scroll_Lock:
return NSScrollLockFunctionKey;
case GDK_KEY_Sys_Req:
return NSSysReqFunctionKey;
case GDK_KEY_Home:
return NSHomeFunctionKey;
case GDK_KEY_Left:
case GDK_KEY_leftarrow:
return NSLeftArrowFunctionKey;
case GDK_KEY_Up:
case GDK_KEY_uparrow:
return NSUpArrowFunctionKey;
case GDK_KEY_Right:
case GDK_KEY_rightarrow:
return NSRightArrowFunctionKey;
case GDK_KEY_Down:
case GDK_KEY_downarrow:
return NSDownArrowFunctionKey;
case GDK_KEY_Page_Up:
return NSPageUpFunctionKey;
case GDK_KEY_Page_Down:
return NSPageDownFunctionKey;
case GDK_KEY_End:
return NSEndFunctionKey;
case GDK_KEY_Begin:
return NSBeginFunctionKey;
case GDK_KEY_Select:
return NSSelectFunctionKey;
case GDK_KEY_Print:
return NSPrintFunctionKey;
case GDK_KEY_Execute:
return NSExecuteFunctionKey;
case GDK_KEY_Insert:
return NSInsertFunctionKey;
case GDK_KEY_Undo:
return NSUndoFunctionKey;
case GDK_KEY_Redo:
return NSRedoFunctionKey;
case GDK_KEY_Menu:
return NSMenuFunctionKey;
case GDK_KEY_Find:
return NSFindFunctionKey;
case GDK_KEY_Help:
return NSHelpFunctionKey;
case GDK_KEY_Break:
return NSBreakFunctionKey;
case GDK_KEY_Mode_switch:
return NSModeSwitchFunctionKey;
case GDK_KEY_F1:
return NSF1FunctionKey;
case GDK_KEY_F2:
return NSF2FunctionKey;
case GDK_KEY_F3:
return NSF3FunctionKey;
case GDK_KEY_F4:
return NSF4FunctionKey;
case GDK_KEY_F5:
return NSF5FunctionKey;
case GDK_KEY_F6:
return NSF6FunctionKey;
case GDK_KEY_F7:
return NSF7FunctionKey;
case GDK_KEY_F8:
return NSF8FunctionKey;
case GDK_KEY_F9:
return NSF9FunctionKey;
case GDK_KEY_F10:
return NSF10FunctionKey;
case GDK_KEY_F11:
return NSF11FunctionKey;
case GDK_KEY_F12:
return NSF12FunctionKey;
case GDK_KEY_F13:
return NSF13FunctionKey;
case GDK_KEY_F14:
return NSF14FunctionKey;
case GDK_KEY_F15:
return NSF15FunctionKey;
case GDK_KEY_F16:
return NSF16FunctionKey;
case GDK_KEY_F17:
return NSF17FunctionKey;
case GDK_KEY_F18:
return NSF18FunctionKey;
case GDK_KEY_F19:
return NSF19FunctionKey;
case GDK_KEY_F20:
return NSF20FunctionKey;
case GDK_KEY_F21:
return NSF21FunctionKey;
case GDK_KEY_F22:
return NSF22FunctionKey;
case GDK_KEY_F23:
return NSF23FunctionKey;
case GDK_KEY_F24:
return NSF24FunctionKey;
case GDK_KEY_F25:
return NSF25FunctionKey;
case GDK_KEY_F26:
return NSF26FunctionKey;
case GDK_KEY_F27:
return NSF27FunctionKey;
case GDK_KEY_F28:
return NSF28FunctionKey;
case GDK_KEY_F29:
return NSF29FunctionKey;
case GDK_KEY_F30:
return NSF30FunctionKey;
case GDK_KEY_F31:
return NSF31FunctionKey;
case GDK_KEY_F32:
return NSF32FunctionKey;
case GDK_KEY_F33:
return NSF33FunctionKey;
case GDK_KEY_F34:
return NSF34FunctionKey;
case GDK_KEY_F35:
return NSF35FunctionKey;
default:
break;
}
return '\0';
}
+7 -4
View File
@@ -36,10 +36,13 @@ typedef struct _GdkMacosMonitorClass GdkMacosMonitorClass;
#define GDK_IS_MACOS_MONITOR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MACOS_MONITOR))
GDK_AVAILABLE_IN_ALL
GType gdk_macos_monitor_get_type (void);
void gdk_macos_monitor_get_workarea (GdkMonitor *monitor,
GdkRectangle *geometry);
GType gdk_macos_monitor_get_type (void);
GDK_AVAILABLE_IN_ALL
void gdk_macos_monitor_get_geometry (GdkMonitor *self,
GdkRectangle *geometry);
GDK_AVAILABLE_IN_ALL
void gdk_macos_monitor_get_workarea (GdkMonitor *self,
GdkRectangle *geometry);
G_END_DECLS
+11 -9
View File
@@ -25,6 +25,7 @@
#include "gdkpopupprivate.h"
#include "gdkmacosdisplay-private.h"
#include "gdkmacosmonitor.h"
#include "gdkmacospopupsurface-private.h"
#include "gdkmacosutils-private.h"
@@ -54,14 +55,15 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self,
g_assert (layout != NULL);
g_assert (GDK_SURFACE (self)->parent);
if (layout != self->layout)
{
g_clear_pointer (&self->layout, gdk_popup_layout_unref);
self->layout = gdk_popup_layout_ref (layout);
}
gdk_popup_layout_ref (layout);
g_clear_pointer (&self->layout, gdk_popup_layout_unref);
self->layout = layout;
monitor = gdk_surface_get_layout_monitor (surface, layout,
monitor = gdk_surface_get_layout_monitor (GDK_SURFACE (self),
self->layout,
gdk_macos_monitor_get_workarea);
if (monitor == NULL)
monitor = _gdk_macos_surface_get_best_monitor (GDK_MACOS_SURFACE (self));
gdk_macos_monitor_get_workarea (monitor, &bounds);
gdk_surface_layout_popup_helper (GDK_SURFACE (self),
@@ -69,7 +71,7 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self,
height,
monitor,
&bounds,
layout,
self->layout,
&final_rect);
gdk_surface_get_origin (GDK_SURFACE (self)->parent, &x, &y);
@@ -119,8 +121,6 @@ gdk_macos_popup_surface_present (GdkPopup *popup,
gdk_macos_popup_surface_layout (self, width, height, layout);
GDK_MACOS_SURFACE (self)->did_initial_present = TRUE;
if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self)))
return TRUE;
@@ -142,6 +142,8 @@ gdk_macos_popup_surface_present (GdkPopup *popup,
show_popup (GDK_MACOS_POPUP_SURFACE (self));
}
GDK_MACOS_SURFACE (self)->did_initial_present = TRUE;
return GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self));
}
+13 -11
View File
@@ -84,7 +84,7 @@ _gdk_macos_surface_reposition_children (GdkMacosSurface *self)
_gdk_macos_popup_surface_reposition (GDK_MACOS_POPUP_SURFACE (child));
}
if (GDK_IS_POPUP (self) || self->did_initial_present)
if (GDK_IS_POPUP (self) && self->did_initial_present)
g_signal_emit_by_name (self, "popup-layout-changed");
}
@@ -238,8 +238,6 @@ gdk_macos_surface_get_device_state (GdkSurface *surface,
GdkDisplay *display;
NSWindow *nswindow;
NSPoint point;
int x_tmp;
int y_tmp;
g_assert (GDK_IS_MACOS_SURFACE (surface));
g_assert (GDK_IS_MACOS_DEVICE (device));
@@ -247,18 +245,20 @@ gdk_macos_surface_get_device_state (GdkSurface *surface,
g_assert (y != NULL);
g_assert (mask != NULL);
if (GDK_SURFACE_DESTROYED (surface))
return FALSE;
display = gdk_surface_get_display (surface);
nswindow = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (surface));
point = [nswindow mouseLocationOutsideOfEventStream];
_gdk_macos_display_from_display_coords (GDK_MACOS_DISPLAY (display),
point.x, point.y,
&x_tmp, &y_tmp);
*mask = _gdk_macos_display_get_current_keyboard_modifiers (GDK_MACOS_DISPLAY (display))
| _gdk_macos_display_get_current_mouse_modifiers (GDK_MACOS_DISPLAY (display));
*x = x_tmp;
*y = x_tmp;
*x = point.x;
*y = point.y - surface->height;
return TRUE;
return *x >= 0 && *y >= 0 && *x < surface->width && *y < surface->height;
}
static void
@@ -713,7 +713,10 @@ _gdk_macos_surface_thaw (GdkMacosSurface *self,
timings = gdk_frame_clock_get_timings (frame_clock, self->pending_frame_counter);
if (timings != NULL)
timings->presentation_time = presentation_time - refresh_interval;
{
timings->presentation_time = presentation_time - refresh_interval;
timings->complete = TRUE;
}
self->pending_frame_counter = 0;
}
@@ -820,7 +823,6 @@ _gdk_macos_surface_synthesize_null_key (GdkMacosSurface *self)
event = gdk_key_event_new (GDK_KEY_PRESS,
GDK_SURFACE (self),
gdk_seat_get_keyboard (seat),
NULL,
GDK_CURRENT_TIME,
0,
0,
+4 -1
View File
@@ -25,6 +25,7 @@
#include "gdktoplevelprivate.h"
#include "gdkmacosdisplay-private.h"
#include "gdkmacosmonitor-private.h"
#include "gdkmacostoplevelsurface-private.h"
#include "gdkmacosutils-private.h"
@@ -95,6 +96,7 @@ static gboolean
_gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
GdkToplevelLayout *layout)
{
GdkSurface *surface = GDK_SURFACE (toplevel);
GdkMacosToplevelSurface *self = (GdkMacosToplevelSurface *)toplevel;
NSWindow *nswindow = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self));
GdkDisplay *display = gdk_surface_get_display (surface);
@@ -190,10 +192,11 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
(GDK_MACOS_SURFACE (self)->shadow_left ||
GDK_MACOS_SURFACE (self)->shadow_top))
{
GdkMonitor *monitor = _gdk_macos_surface_get_best_monitor (GDK_MACOS_SURFACE (self));
int x = GDK_SURFACE (self)->x;
int y = GDK_SURFACE (self)->y;
monitor = _gdk_macos_surface_get_best_monitor (GDK_MACOS_SURFACE (self));
if (monitor != NULL)
{
GdkRectangle visible;
+1
View File
@@ -43,6 +43,7 @@ gdk_macos_frameworks = [
'Carbon',
'CoreVideo',
'CoreServices',
'Foundation',
'OpenGL',
'QuartzCore',
]
+1 -1
View File
@@ -227,7 +227,7 @@ libgdk_c_args = [
gdk_backends = []
gdk_backends_gen_headers = [] # non-public generated headers
foreach backend : ['broadway', 'quartz', 'wayland', 'win32', 'x11', 'macos']
foreach backend : ['broadway', 'wayland', 'win32', 'x11', 'macos']
if get_variable('@0@_enabled'.format(backend))
subdir(backend)
gdk_deps += get_variable('gdk_@0@_deps'.format(backend))
+10 -6
View File
@@ -3,11 +3,15 @@
#include "gdkwaylanddevice.h"
void
gdk_wayland_device_query_state (GdkDevice *device,
GdkSurface *surface,
double *win_x,
double *win_y,
GdkModifierType *mask);
void gdk_wayland_device_query_state (GdkDevice *device,
GdkSurface *surface,
double *win_x,
double *win_y,
GdkModifierType *mask);
void gdk_wayland_device_pad_set_feedback (GdkDevice *device,
GdkDevicePadFeature feature,
guint feature_idx,
const char *label);
#endif
+26 -12
View File
@@ -942,7 +942,7 @@ gdk_wayland_device_pad_init (GdkWaylandDevicePad *pad)
}
/**
* gdk_wayland_device_get_wl_seat:
* gdk_wayland_device_get_wl_seat: (skip)
* @device: (type GdkWaylandDevice): a #GdkDevice
*
* Returns the Wayland wl_seat of a #GdkDevice.
@@ -961,7 +961,7 @@ gdk_wayland_device_get_wl_seat (GdkDevice *device)
}
/**
* gdk_wayland_device_get_wl_pointer:
* gdk_wayland_device_get_wl_pointer: (skip)
* @device: (type GdkWaylandDevice): a #GdkDevice
*
* Returns the Wayland wl_pointer of a #GdkDevice.
@@ -980,7 +980,7 @@ gdk_wayland_device_get_wl_pointer (GdkDevice *device)
}
/**
* gdk_wayland_device_get_wl_keyboard:
* gdk_wayland_device_get_wl_keyboard: (skip)
* @device: (type GdkWaylandDevice): a #GdkDevice
*
* Returns the Wayland wl_keyboard of a #GdkDevice.
@@ -4971,6 +4971,12 @@ gdk_wayland_seat_set_drag (GdkSeat *seat,
g_set_object (&wayland_seat->drag, drag);
}
/**
* gdk_wayland_device_get_data_device: (skip)
* @gdk_device: (type GdkWaylandDevice): a #GdkDevice
*
* ...
*/
struct wl_data_device *
gdk_wayland_device_get_data_device (GdkDevice *gdk_device)
{
@@ -4982,6 +4988,13 @@ gdk_wayland_device_get_data_device (GdkDevice *gdk_device)
return seat->data_device;
}
/**
* gdk_wayland_device_set_selection: (skip)
* @gdk_device: (type GdkWaylandDevice): a #GdkDevice
* @source: the data source for the selection
*
* ...
*/
void
gdk_wayland_device_set_selection (GdkDevice *gdk_device,
struct wl_data_source *source)
@@ -4999,12 +5012,12 @@ gdk_wayland_device_set_selection (GdkDevice *gdk_device,
}
/**
* gdk_wayland_seat_get_wl_seat:
* gdk_wayland_seat_get_wl_seat: (skip)
* @seat: (type GdkWaylandSeat): a #GdkSeat
*
* Returns the Wayland wl_seat of a #GdkSeat.
* Returns the Wayland `wl_seat` of a #GdkSeat.
*
* Returns: (transfer none): a Wayland wl_seat
* Returns: (transfer none): a Wayland `wl_seat`
*/
struct wl_seat *
gdk_wayland_seat_get_wl_seat (GdkSeat *seat)
@@ -5016,9 +5029,10 @@ gdk_wayland_seat_get_wl_seat (GdkSeat *seat)
/**
* gdk_wayland_device_get_node_path:
* @device: a #GdkDevice
* @device: (type GdkWaylandDevice): a #GdkDevice
*
* Returns the `/dev/input/event*` path of this device.
*
* Returns the /dev/input/event* path of this device.
* For #GdkDevices that possibly coalesce multiple hardware
* devices (eg. mouse, keyboard, touch,...), this function
* will return %NULL.
@@ -5026,8 +5040,8 @@ gdk_wayland_seat_get_wl_seat (GdkSeat *seat)
* This is most notably implemented for devices of type
* %GDK_SOURCE_PEN, %GDK_SOURCE_TABLET_PAD.
*
* Returns: the /dev/input/event* path of this device
**/
* Returns: (nullable) (transfer none): the `/dev/input/event*` path of this device
*/
const char *
gdk_wayland_device_get_node_path (GdkDevice *device)
{
@@ -5050,9 +5064,9 @@ gdk_wayland_device_get_node_path (GdkDevice *device)
return NULL;
}
/**
/*<private>
* gdk_wayland_device_pad_set_feedback:
* @device: a %GDK_SOURCE_TABLET_PAD device
* @device: (type GdkWaylandDevice): a %GDK_SOURCE_TABLET_PAD device
* @feature: Feature to set the feedback label for
* @feature_idx: 0-indexed index of the feature to set the feedback label for
* @label: Feedback label
+23 -8
View File
@@ -384,6 +384,15 @@ static const struct org_kde_kwin_server_decoration_manager_listener server_decor
.default_mode = server_decoration_manager_default_mode
};
/*
* gdk_wayland_display_prefers_ssd:
* @display: (type GdkWaylandDisplay): a #GdkDisplay
*
* Checks whether the Wayland compositor prefers to draw the window
* decorations or if it leaves decorations to the application.
*
* Returns: %TRUE if the compositor prefers server-side decorations
*/
gboolean
gdk_wayland_display_prefers_ssd (GdkDisplay *display)
{
@@ -859,12 +868,12 @@ gdk_wayland_display_get_next_serial (GdkDisplay *display)
/**
* gdk_wayland_display_get_startup_notification_id:
* @display: (type GdkX11Display): a #GdkDisplay
* @display: (type GdkWaylandDisplay): a #GdkDisplay
*
* Gets the startup notification ID for a Wayland display, or %NULL
* if no ID has been defined.
*
* Returns: the startup notification ID for @display, or %NULL
* Returns: (nullable): the startup notification ID for @display, or %NULL
*/
const char *
gdk_wayland_display_get_startup_notification_id (GdkDisplay *display)
@@ -1064,10 +1073,16 @@ get_cursor_theme (GdkWaylandDisplay *display_wayland,
return wl_cursor_theme_create ("/usr/share/icons/default/cursors", size, display_wayland->shm);
}
/**
* gdk_wayland_display_set_cursor_theme:
* @display: (type GdkWaylandDisplay): a #GdkDisplay
*
* Sets the cursor theme for the given @display.
*/
void
gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
const char *name,
int size)
int size)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY(display);
struct wl_cursor_theme *theme;
@@ -1154,7 +1169,7 @@ _gdk_wayland_display_update_serial (GdkWaylandDisplay *display_wayland,
}
/**
* gdk_wayland_display_get_wl_display:
* gdk_wayland_display_get_wl_display: (skip)
* @display: (type GdkWaylandDisplay): a #GdkDisplay
*
* Returns the Wayland wl_display of a #GdkDisplay.
@@ -1170,7 +1185,7 @@ gdk_wayland_display_get_wl_display (GdkDisplay *display)
}
/**
* gdk_wayland_display_get_wl_compositor:
* gdk_wayland_display_get_wl_compositor: (skip)
* @display: (type GdkWaylandDisplay): a #GdkDisplay
*
* Returns the Wayland global singleton compositor of a #GdkDisplay.
@@ -2617,11 +2632,11 @@ gdk_wayland_display_get_output_scale (GdkWaylandDisplay *display_wayland,
/**
* gdk_wayland_display_query_registry:
* @display: a wayland #GdkDisplay
* @display: (type GdkWaylandDisplay): a #GdkDisplay
* @global: global interface to query in the registry
*
* Returns %TRUE if the the interface was found in the display
* wl_registry.global handler.
* `wl_registry.global` handler.
*
* Returns: %TRUE if the global is offered by the compositor
**/
+2
View File
@@ -165,6 +165,8 @@ struct _GdkWaylandDisplayClass
GdkDisplayClass parent_class;
};
gboolean gdk_wayland_display_prefers_ssd (GdkDisplay *display);
G_END_DECLS
#endif /* __GDK_WAYLAND_DISPLAY__ */
+1 -1
View File
@@ -49,7 +49,7 @@ gdk_wayland_monitor_class_init (GdkWaylandMonitorClass *class)
}
/**
* gdk_wayland_monitor_get_wl_output:
* gdk_wayland_monitor_get_wl_output: (skip)
* @monitor: (type GdkWaylandMonitor): a #GdkMonitor
*
* Returns the Wayland wl_output of a #GdkMonitor.
+2 -9
View File
@@ -22,25 +22,18 @@
#include "config.h"
#include <gdk/gdkseatprivate.h>
#include "gdkwaylandseat.h"
#include "gdk/gdkseatprivate.h"
#define GDK_TYPE_WAYLAND_SEAT (gdk_wayland_seat_get_type ())
#define GDK_WAYLAND_SEAT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_WAYLAND_SEAT, GdkWaylandSeat))
#define GDK_WAYLAND_SEAT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_WAYLAND_SEAT, GdkWaylandSeatClass))
#define GDK_IS_WAYLAND_SEAT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_WAYLAND_SEAT))
#define GDK_IS_WAYLAND_SEAT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_WAYLAND_SEAT))
#define GDK_WAYLAND_SEAT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_WAYLAND_SEAT, GdkWaylandSeatClass))
typedef struct _GdkWaylandSeat GdkWaylandSeat;
typedef struct _GdkWaylandSeatClass GdkWaylandSeatClass;
struct _GdkWaylandSeatClass
{
GdkSeatClass parent_class;
};
GType gdk_wayland_seat_get_type (void) G_GNUC_CONST;
void gdk_wayland_seat_update_cursor_scale (GdkWaylandSeat *seat);
void gdk_wayland_seat_clear_touchpoints (GdkWaylandSeat *seat,
+73 -40
View File
@@ -17,12 +17,7 @@
#include "config.h"
#include <netinet/in.h>
#include <unistd.h>
#include "gdk.h"
#include "gdkwayland.h"
#include "gdkwaylandsurface.h"
#include "gdksurface-wayland.h"
#include "gdkdeviceprivate.h"
#include "gdkdisplay-wayland.h"
@@ -45,6 +40,9 @@
#include <string.h>
#include <errno.h>
#include <netinet/in.h>
#include <unistd.h>
#define SURFACE_IS_TOPLEVEL(surface) TRUE
#define MAX_WL_BUFFER_SIZE (4083) /* 4096 minus header, string argument length and NUL byte */
@@ -333,7 +331,9 @@ _gdk_wayland_surface_save_size (GdkSurface *surface)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
if (surface->state & (GDK_TOPLEVEL_STATE_FULLSCREEN | GDK_TOPLEVEL_STATE_MAXIMIZED))
if (surface->state & (GDK_TOPLEVEL_STATE_FULLSCREEN |
GDK_TOPLEVEL_STATE_MAXIMIZED |
GDK_TOPLEVEL_STATE_TILED))
return;
impl->saved_width = surface->width - impl->margin_left - impl->margin_right;
@@ -881,24 +881,6 @@ gdk_wayland_surface_finalize (GObject *object)
G_OBJECT_CLASS (gdk_wayland_surface_parent_class)->finalize (object);
}
static void
gdk_wayland_surface_resize (GdkSurface *surface,
int width,
int height,
int scale)
{
GdkDisplay *display;
GdkEvent *event;
event = gdk_configure_event_new (surface, width, height);
gdk_wayland_surface_update_size (surface, width, height, scale);
_gdk_surface_update_size (surface);
display = gdk_surface_get_display (surface);
_gdk_wayland_display_deliver_event (display, event);
}
static gboolean
is_realized_shell_surface (GdkWaylandSurface *impl)
{
@@ -920,6 +902,26 @@ is_realized_popup (GdkWaylandSurface *impl)
impl->display_server.zxdg_popup_v6);
}
static void
gdk_wayland_surface_resize (GdkSurface *surface,
int width,
int height,
int scale)
{
gdk_wayland_surface_update_size (surface, width, height, scale);
_gdk_surface_update_size (surface);
if (is_realized_shell_surface (GDK_WAYLAND_SURFACE (surface)))
{
GdkDisplay *display;
GdkEvent *event;
event = gdk_configure_event_new (surface, width, height);
display = gdk_surface_get_display (surface);
_gdk_wayland_display_deliver_event (display, event);
}
}
static void gdk_wayland_surface_show (GdkSurface *surface,
gboolean already_mapped);
static void gdk_wayland_surface_hide (GdkSurface *surface);
@@ -1350,6 +1352,11 @@ gdk_wayland_surface_configure_toplevel (GdkSurface *surface)
/* Save size for next time we get 0x0 */
_gdk_wayland_surface_save_size (surface);
}
else
{
width += impl->margin_left + impl->margin_right;
height += impl->margin_top + impl->margin_bottom;
}
gdk_wayland_surface_resize (surface, width, height, impl->scale);
}
@@ -1685,6 +1692,13 @@ create_zxdg_toplevel_v6_resources (GdkSurface *surface)
surface);
}
/**
* gdk_wayland_toplevel_set_application_id:
* @toplevel: (type GdkWaylandToplevel): a #GdkToplevel
* @application_id: the application id for the @toplevel
*
* Sets the application id on a #GdkToplevel.
*/
void
gdk_wayland_toplevel_set_application_id (GdkToplevel *toplevel,
const char *application_id)
@@ -2783,6 +2797,8 @@ gdk_wayland_surface_hide_surface (GdkSurface *surface)
g_clear_pointer (&impl->popup.layout, gdk_popup_layout_unref);
}
impl->has_uncommitted_ack_configure = FALSE;
unset_transient_for_exported (surface);
_gdk_wayland_surface_clear_saved_size (surface);
@@ -4024,7 +4040,7 @@ _gdk_wayland_surface_set_grab_seat (GdkSurface *surface,
}
/**
* gdk_wayland_surface_get_wl_surface:
* gdk_wayland_surface_get_wl_surface: (skip)
* @surface: (type GdkWaylandSurface): a #GdkSurface
*
* Returns the Wayland surface of a #GdkSurface.
@@ -4154,13 +4170,13 @@ maybe_set_gtk_surface_dbus_properties (GdkWaylandSurface *impl)
}
void
gdk_wayland_toplevel_set_dbus_properties_libgtk_only (GdkToplevel *toplevel,
const char *application_id,
const char *app_menu_path,
const char *menubar_path,
const char *window_object_path,
const char *application_object_path,
const char *unique_bus_name)
gdk_wayland_toplevel_set_dbus_properties (GdkToplevel *toplevel,
const char *application_id,
const char *app_menu_path,
const char *menubar_path,
const char *window_object_path,
const char *application_object_path,
const char *unique_bus_name)
{
GdkWaylandSurface *impl;
@@ -4216,12 +4232,12 @@ static const struct zxdg_exported_v1_listener xdg_exported_listener = {
/**
* GdkWaylandToplevelExported:
* @toplevel: the #GdkToplevel that is exported
* @toplevel: (type GdkWaylandToplevel): the #GdkToplevel that is exported
* @handle: the handle
* @user_data: user data that was passed to gdk_wayland_toplevel_export_handle()
*
* Callback that gets called when the handle for a surface has been
* obtained from the Wayland compositor. The handle can be passed
* obtained from the Wayland compositor. The @handle can be passed
* to other processes, for the purpose of marking surfaces as transient
* for out-of-process surfaces.
*/
@@ -4234,7 +4250,7 @@ gdk_wayland_surface_is_exported (GdkWaylandSurface *impl)
/**
* gdk_wayland_toplevel_export_handle:
* @toplevel: the #GdkToplevel to obtain a handle for
* @toplevel: (type GdkWaylandToplevel): the #GdkToplevel to obtain a handle for
* @callback: callback to call with the handle
* @user_data: (closure): user data for @callback
* @destroy_func: destroy notify for @user_data
@@ -4298,7 +4314,7 @@ gdk_wayland_toplevel_export_handle (GdkToplevel *toplevel,
/**
* gdk_wayland_toplevel_unexport_handle:
* @toplevel: the #GdkToplevel to unexport
* @toplevel: (type GdkWaylandToplevel): the #GdkToplevel to unexport
*
* Destroys the handle that was obtained with
* gdk_wayland_toplevel_export_handle().
@@ -4352,7 +4368,7 @@ static const struct zxdg_imported_v1_listener xdg_imported_listener = {
/**
* gdk_wayland_toplevel_set_transient_for_exported:
* @toplevel: the #GdkToplevel to make as transient
* @toplevel: (type GdkWaylandToplevel): the #GdkToplevel to make as transient
* @parent_handle_str: an exported handle for a surface
*
* Marks @toplevel as transient for the surface to which the given
@@ -4405,6 +4421,13 @@ gdk_wayland_surface_get_inhibitor (GdkWaylandSurface *impl,
return g_hash_table_lookup (impl->shortcuts_inhibitors, gdk_seat);
}
/*
* gdk_wayland_surface_inhibit_shortcuts:
* @surface: (type GdkWaylandSurface): a #GdkSurface
* @seat: the seat to inhibit
*
* Inhibits the shortcuts coming from the given @seat.
*/
void
gdk_wayland_surface_inhibit_shortcuts (GdkSurface *surface,
GdkSeat *gdk_seat)
@@ -4428,6 +4451,14 @@ gdk_wayland_surface_inhibit_shortcuts (GdkSurface *surface,
g_hash_table_insert (impl->shortcuts_inhibitors, gdk_seat, inhibitor);
}
/*
* gdk_wayland_surface_restore_shortcuts:
* @surface: (type GdkWaylandSurface): a #GdkSurface
* @seat: the seat to inhibit
*
* Restores the shortcuts on the given @seat inhibited by calling
* gdk_wayland_surface_inhibit_shortcuts().
*/
void
gdk_wayland_surface_restore_shortcuts (GdkSurface *surface,
GdkSeat *gdk_seat)
@@ -4448,8 +4479,10 @@ create_dnd_surface (GdkDisplay *display)
{
GdkSurface *surface;
surface = gdk_surface_new_temp (display, &(GdkRectangle){ 0, 0, 100, 100 });
surface = _gdk_wayland_display_create_surface (display,
GDK_SURFACE_TEMP,
NULL,
0, 0, 100, 100);
GDK_WAYLAND_SURFACE (surface)->is_drag_surface = TRUE;
return surface;
+40
View File
@@ -0,0 +1,40 @@
/* gdksurface-wayland.h: Private header for GdkWaylandSurface
*
* Copyright 2020 GNOME Foundation
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* 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.1 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/>.
*/
#pragma once
#include "gdkwaylandsurface.h"
G_BEGIN_DECLS
void gdk_wayland_toplevel_set_dbus_properties (GdkToplevel *toplevel,
const char *application_id,
const char *app_menu_path,
const char *menubar_path,
const char *window_object_path,
const char *application_object_path,
const char *unique_bus_name);
void gdk_wayland_toplevel_announce_csd (GdkToplevel *toplevel);
gboolean gdk_wayland_toplevel_inhibit_idle (GdkToplevel *toplevel);
void gdk_wayland_toplevel_uninhibit_idle (GdkToplevel *toplevel);
G_END_DECLS
+1
View File
@@ -32,6 +32,7 @@
#include <gdk/wayland/gdkwaylanddevice.h>
#include <gdk/wayland/gdkwaylanddisplay.h>
#include <gdk/wayland/gdkwaylandmonitor.h>
#include <gdk/wayland/gdkwaylandseat.h>
#include <gdk/wayland/gdkwaylandsurface.h>
#include <gdk/wayland/gdkwaylandglcontext.h>
+1 -9
View File
@@ -33,6 +33,7 @@ typedef struct _GdkWaylandDevice GdkWaylandDevice;
#else
typedef GdkDevice GdkWaylandDevice;
#endif
typedef struct _GdkWaylandDeviceClass GdkWaylandDeviceClass;
#define GDK_TYPE_WAYLAND_DEVICE (gdk_wayland_device_get_type ())
@@ -52,18 +53,9 @@ struct wl_pointer *gdk_wayland_device_get_wl_pointer (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
struct wl_keyboard *gdk_wayland_device_get_wl_keyboard (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
struct wl_seat *gdk_wayland_seat_get_wl_seat (GdkSeat *seat);
GDK_AVAILABLE_IN_ALL
const char *gdk_wayland_device_get_node_path (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
void gdk_wayland_device_pad_set_feedback (GdkDevice *device,
GdkDevicePadFeature element,
guint idx,
const char *label);
G_END_DECLS
#endif /* __GDK_WAYLAND_DEVICE_H__ */
-2
View File
@@ -59,8 +59,6 @@ GDK_AVAILABLE_IN_ALL
void gdk_wayland_display_set_startup_notification_id (GdkDisplay *display,
const char *startup_id);
gboolean gdk_wayland_display_prefers_ssd (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
gboolean gdk_wayland_display_query_registry (GdkDisplay *display,
const char *global);
+49
View File
@@ -0,0 +1,49 @@
/* gdkwaylandseat.h: Wayland GdkSeat
*
* Copyright 2020 GNOME Foundation
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* 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.1 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/>.
*/
#pragma once
#if !defined (__GDKWAYLAND_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/wayland/gdkwayland.h> can be included directly."
#endif
#include <gdk/gdk.h>
#include <wayland-client.h>
G_BEGIN_DECLS
#ifdef GTK_COMPILATION
typedef struct _GdkWaylandSeat GdkWaylandSeat;
#else
typedef GdkSeat GdkWaylandSeat;
#endif
typedef struct _GdkWaylandSeatClass GdkWaylandSeatClass;
#define GDK_TYPE_WAYLAND_SEAT (gdk_wayland_seat_get_type ())
#define GDK_WAYLAND_SEAT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_WAYLAND_SEAT, GdkWaylandSeat))
#define GDK_IS_WAYLAND_SEAT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_WAYLAND_SEAT))
GDK_AVAILABLE_IN_ALL
GType gdk_wayland_seat_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
struct wl_seat * gdk_wayland_seat_get_wl_seat (GdkSeat *seat);
G_END_DECLS
-14
View File
@@ -62,15 +62,6 @@ GType gdk_wayland_popup_get_type (void);
GDK_AVAILABLE_IN_ALL
struct wl_surface *gdk_wayland_surface_get_wl_surface (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_wayland_toplevel_set_dbus_properties_libgtk_only (GdkToplevel *toplevel,
const char *application_id,
const char *app_menu_path,
const char *menubar_path,
const char *window_object_path,
const char *application_object_path,
const char *unique_bus_name);
typedef void (*GdkWaylandToplevelExported) (GdkToplevel *toplevel,
const char *handle,
gpointer user_data);
@@ -92,11 +83,6 @@ GDK_AVAILABLE_IN_ALL
void gdk_wayland_toplevel_set_application_id (GdkToplevel *toplevel,
const char *application_id);
void gdk_wayland_toplevel_announce_csd (GdkToplevel *toplevel);
gboolean gdk_wayland_toplevel_inhibit_idle (GdkToplevel *toplevel);
void gdk_wayland_toplevel_uninhibit_idle (GdkToplevel *toplevel);
G_END_DECLS
#endif /* __GDK_WAYLAND_SURFACE_H__ */
+2 -1
View File
@@ -24,7 +24,8 @@ gdk_wayland_public_headers = files([
'gdkwaylanddisplay.h',
'gdkwaylandglcontext.h',
'gdkwaylandmonitor.h',
'gdkwaylandsurface.h'
'gdkwaylandseat.h',
'gdkwaylandsurface.h',
])
install_headers(gdk_wayland_public_headers, 'gdkwayland.h', subdir: 'gtk-4.0/gdk/wayland/')
+6 -1
View File
@@ -427,7 +427,12 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
ndevices, ncursors));
#endif
/* Create a dummy window to receive wintab events */
wintab_window = gdk_surface_new_temp (display, &(GdkRectangle) { -100, -100, 2, 2 });
wintab_window =
_gdk_win32_display_create_surface (display,
GDK_SURFACE_TEMP,
NULL,
-100, -100, 2, 2);
g_object_ref (wintab_window);
for (devix = 0; devix < ndevices; devix++)
+4 -1
View File
@@ -1700,7 +1700,10 @@ create_drag_surface (GdkDisplay *display)
{
GdkSurface *surface;
surface = gdk_surface_new_temp (display, &(GdkRectangle) { 0, 0, 100, 100 });
surface = _gdk_win32_display_create_surface (display,
GDK_SURFACE_TEMP,
NULL,
0, 0, 100, 100);
return surface;
}
+4 -237
View File
@@ -1578,225 +1578,6 @@ generate_button_event (GdkEventType type,
_gdk_win32_append_event (event);
}
/*
* Used by the stacking functions to see if a window
* should be always on top.
* Restacking is only done if both windows are either ontop
* or not ontop.
*/
static gboolean
should_window_be_always_on_top (GdkSurface *window)
{
DWORD exstyle;
if (GDK_IS_DRAG_SURFACE (window) ||
(window->state & GDK_TOPLEVEL_STATE_ABOVE))
return TRUE;
exstyle = GetWindowLong (GDK_SURFACE_HWND (window), GWL_EXSTYLE);
if (exstyle & WS_EX_TOPMOST)
return TRUE;
return FALSE;
}
static void
restack_children (GdkSurface *window)
{
GList *popup;
for (popup = window->children; popup; popup = popup->next)
{
GdkSurface *child = GDK_SURFACE (popup->data);
/* Windows doesn't have a function to put window A *above* window B.
* Instead we put window A immediately *below* window B,
* then put window B immediately below window A.
* SWP_NOSENDCHANGING prevents our own handler from triggering.
*/
SetWindowPos (GDK_SURFACE_HWND (child), GDK_SURFACE_HWND (window), 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING);
g_print ("Put popup %p (%p) above %p (%p)\n", child, GDK_SURFACE_HWND (child), window, GDK_SURFACE_HWND (window));
SetWindowPos (GDK_SURFACE_HWND (window), GDK_SURFACE_HWND (child), 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER);
}
}
static void
ensure_stacking_on_unminimize (MSG *msg)
{
HWND rover;
HWND lowest_transient = NULL;
GdkSurface *msg_window;
gboolean window_ontop = FALSE;
msg_window = gdk_win32_handle_table_lookup (msg->hwnd);
if (msg_window)
window_ontop = should_window_be_always_on_top (msg_window);
for (rover = GetNextWindow (msg->hwnd, GW_HWNDNEXT);
rover;
rover = GetNextWindow (rover, GW_HWNDNEXT))
{
GdkSurface *rover_gdkw = gdk_win32_handle_table_lookup (rover);
GdkWin32Surface *rover_impl;
gboolean rover_ontop;
/* Checking window group not implemented yet */
if (rover_gdkw == NULL)
continue;
rover_ontop = should_window_be_always_on_top (rover_gdkw);
rover_impl = GDK_WIN32_SURFACE (rover_gdkw);
if (GDK_SURFACE_IS_MAPPED (rover_gdkw) &&
rover_impl->transient_owner != NULL &&
((window_ontop && rover_ontop) || (!window_ontop && !rover_ontop)))
{
lowest_transient = rover;
}
}
if (lowest_transient != NULL)
{
GDK_NOTE (EVENTS,
g_print (" restacking %p below %p",
msg->hwnd, lowest_transient));
SetWindowPos (msg->hwnd, lowest_transient, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER);
}
}
static gboolean
ensure_stacking_on_window_pos_changing (MSG *msg,
GdkSurface *window)
{
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
WINDOWPOS *windowpos = (WINDOWPOS *) msg->lParam;
HWND rover;
gboolean restacking;
gboolean window_ontop;
if (GetActiveWindow () != msg->hwnd ||
impl->transient_owner != NULL)
return FALSE;
/* Make sure the window stays behind any transient-type windows
* of the same window group.
*
* If the window is not active and being activated, we let
* Windows bring it to the top and rely on the WM_ACTIVATEAPP
* handling to bring any utility windows on top of it.
*/
window_ontop = should_window_be_always_on_top (window);
for (rover = windowpos->hwndInsertAfter, restacking = FALSE;
rover;
rover = GetNextWindow (rover, GW_HWNDNEXT))
{
GdkSurface *rover_gdkw = gdk_win32_handle_table_lookup (rover);
GdkWin32Surface *rover_impl;
gboolean rover_ontop;
/* Checking window group not implemented yet */
if (rover_gdkw == NULL)
continue;
rover_ontop = should_window_be_always_on_top (rover_gdkw);
rover_impl = GDK_WIN32_SURFACE (rover_gdkw);
if (GDK_SURFACE_IS_MAPPED (rover_gdkw) &&
rover_impl->transient_owner != NULL &&
((window_ontop && rover_ontop) || (!window_ontop && !rover_ontop)))
{
restacking = TRUE;
windowpos->hwndInsertAfter = rover;
}
}
if (restacking)
{
GDK_NOTE (EVENTS,
g_print (" letting Windows restack %p above %p",
msg->hwnd, windowpos->hwndInsertAfter));
return TRUE;
}
return FALSE;
}
static void
ensure_stacking_on_activate_app (MSG *msg,
GdkSurface *window)
{
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
HWND rover;
gboolean window_ontop;
if (impl->transient_owner != NULL)
{
GdkSurface *child = window;
GdkSurface *owner = impl->transient_owner;
SetWindowPos (msg->hwnd, HWND_TOP, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER);
/* Bing the whole hierarchy of transients back up */
while (owner != NULL)
{
SetWindowPos (GDK_SURFACE_HWND (owner), GDK_SURFACE_HWND (child), 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER);
restack_children (owner);
child = owner;
owner = GDK_WIN32_SURFACE (owner)->transient_owner;
}
return;
}
if (!IsWindowVisible (msg->hwnd) ||
msg->hwnd != GetActiveWindow ())
return;
/* This window is not a transient-type window and it is the
* activated window. Make sure this window is as visible as
* possible, just below the lowest transient-type window of this
* app.
*/
window_ontop = should_window_be_always_on_top (window);
for (rover = GetNextWindow (msg->hwnd, GW_HWNDPREV);
rover;
rover = GetNextWindow (rover, GW_HWNDPREV))
{
GdkSurface *rover_gdkw = gdk_win32_handle_table_lookup (rover);
GdkWin32Surface *rover_impl;
gboolean rover_ontop;
/* Checking window group not implemented yet */
if (rover_gdkw == NULL)
continue;
rover_ontop = should_window_be_always_on_top (rover_gdkw);
rover_impl = GDK_WIN32_SURFACE (rover_gdkw);
if (GDK_SURFACE_IS_MAPPED (rover_gdkw) &&
rover_impl->transient_owner != NULL &&
((window_ontop && rover_ontop) || (!window_ontop && !rover_ontop)))
{
GDK_NOTE (EVENTS,
g_print (" restacking %p below %p",
msg->hwnd, rover));
SetWindowPos (msg->hwnd, rover, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER);
break;
}
}
}
static gboolean
handle_wm_sysmenu (GdkSurface *window, MSG *msg, int *ret_valp)
{
@@ -3021,7 +2802,6 @@ gdk_event_translate (MSG *msg,
if (GDK_SURFACE_IS_MAPPED (window))
{
return_val = ensure_stacking_on_window_pos_changing (msg, window);
impl = GDK_WIN32_SURFACE (window);
@@ -3101,17 +2881,6 @@ gdk_event_translate (MSG *msg,
if ((old_state & GDK_TOPLEVEL_STATE_MINIMIZED) !=
(new_state & GDK_TOPLEVEL_STATE_MINIMIZED))
do_show_window (window, (new_state & GDK_TOPLEVEL_STATE_MINIMIZED));
/* When un-minimizing, make sure we're stacked under any
transient-type windows. */
if (!(old_state & GDK_TOPLEVEL_STATE_MINIMIZED) &&
(new_state & GDK_TOPLEVEL_STATE_MINIMIZED))
{
ensure_stacking_on_unminimize (msg);
restack_children (window);
}
}
/* Show, New size or position => configure event */
@@ -3132,7 +2901,10 @@ gdk_event_translate (MSG *msg,
if (impl->transient_owner &&
GetForegroundWindow () == GDK_SURFACE_HWND (window))
SetForegroundWindow (GDK_SURFACE_HWND (impl->transient_owner));
{
SetForegroundWindow (GDK_SURFACE_HWND (impl->transient_owner));
SetCapture (GDK_SURFACE_HWND (impl->transient_owner));
}
}
if (!(windowpos->flags & SWP_NOCLIENTSIZE))
@@ -3314,11 +3086,6 @@ gdk_event_translate (MSG *msg,
GDK_NOTE (EVENTS, g_print (" %s thread: %" G_GINT64_FORMAT,
msg->wParam ? "YES" : "NO",
(gint64) msg->lParam));
if (msg->wParam && GDK_SURFACE_IS_MAPPED (window))
{
ensure_stacking_on_activate_app (msg, window);
restack_children (window);
}
break;
case WM_NCHITTEST:
/* TODO: pass all messages to DwmDefWindowProc() first! */
+17 -5
View File
@@ -1001,7 +1001,7 @@ show_window_internal (GdkSurface *window,
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window),
(window->state & GDK_TOPLEVEL_STATE_ABOVE)?HWND_TOPMOST:HWND_NOTOPMOST,
0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOOWNERZORDER));
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE));
}
}
@@ -1327,6 +1327,9 @@ gdk_win32_surface_raise (GdkSurface *window)
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window), HWND_TOPMOST,
0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER));
else if (GDK_IS_POPUP (window))
ShowWindow (GDK_SURFACE_HWND (window), SW_SHOWNOACTIVATE);
else
/* Do not wrap this in an API_CALL macro as SetForegroundWindow might
* fail when for example dragging a window belonging to a different
@@ -1924,7 +1927,7 @@ _gdk_win32_surface_update_style_bits (GdkSurface *window)
rect.right += after.right - before.right;
rect.bottom += after.bottom - before.bottom;
flags = SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOREPOSITION | SWP_NOOWNERZORDER;
flags = SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOREPOSITION;
if (will_be_topmost && !was_topmost)
{
@@ -4257,7 +4260,7 @@ gdk_win32_surface_fullscreen (GdkSurface *window)
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window), HWND_TOP,
x, y, width, height,
SWP_NOCOPYBITS | SWP_SHOWWINDOW | SWP_NOOWNERZORDER));
SWP_NOCOPYBITS | SWP_SHOWWINDOW));
}
}
@@ -4281,7 +4284,7 @@ gdk_win32_surface_unfullscreen (GdkSurface *window)
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window), HWND_NOTOPMOST,
fi->r.left, fi->r.top,
fi->r.right - fi->r.left, fi->r.bottom - fi->r.top,
SWP_NOCOPYBITS | SWP_SHOWWINDOW | SWP_NOOWNERZORDER));
SWP_NOCOPYBITS | SWP_SHOWWINDOW));
g_object_set_data (G_OBJECT (window), "fullscreen-info", NULL);
g_free (fi);
@@ -4822,7 +4825,15 @@ gdk_win32_toplevel_set_property (GObject *object,
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_MODAL:
_gdk_push_modal_window (surface);
GDK_SURFACE (surface)->modal_hint = g_value_get_boolean (value);
if (GDK_SURFACE (surface)->modal_hint)
{
SetCapture (GDK_SURFACE_HWND (surface));
_gdk_push_modal_window (surface);
}
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_ICON_LIST:
@@ -4876,6 +4887,7 @@ gdk_win32_toplevel_get_property (GObject *object,
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_MODAL:
g_value_set_boolean (value, GDK_SURFACE (surface)->modal_hint);
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_ICON_LIST:
+5 -4
View File
@@ -1441,10 +1441,11 @@ gdk_x11_display_open (const char *display_name)
gdk_event_init (display);
{
GdkRectangle rect = { -100, -100, 1, 1 };
display_x11->leader_gdk_surface = gdk_surface_new_temp (display, &rect);
}
display_x11->leader_gdk_surface =
_gdk_x11_display_create_surface (display,
GDK_SURFACE_TEMP,
NULL,
-100, -100, 1, 1);
(_gdk_x11_surface_get_toplevel (display_x11->leader_gdk_surface))->is_leader = TRUE;
+8 -2
View File
@@ -1269,7 +1269,10 @@ create_drag_surface (GdkDisplay *display)
{
GdkSurface *surface;
surface = gdk_surface_new_temp (display, &(GdkRectangle) { 0, 0, 100, 100 });
surface = _gdk_x11_display_create_surface (display,
GDK_SURFACE_TEMP,
NULL,
0, 0, 100, 100);
return surface;
}
@@ -1999,7 +2002,10 @@ _gdk_x11_surface_drag_begin (GdkSurface *surface,
display = gdk_surface_get_display (surface);
ipc_surface = gdk_surface_new_temp (display, &(GdkRectangle) { -99, -99, 1, 1 });
ipc_surface = _gdk_x11_display_create_surface (display,
GDK_SURFACE_TEMP,
NULL,
-99, -99, 1, 1);
drag = (GdkDrag *) g_object_new (GDK_TYPE_X11_DRAG,
"surface", ipc_surface,
+6 -2
View File
@@ -4114,11 +4114,15 @@ create_moveresize_surface (MoveResizeData *mv_resize,
guint32 timestamp)
{
GdkGrabStatus status;
GdkRectangle rect = { -100, -100, 1, 1 };
g_assert (mv_resize->moveresize_emulation_surface == NULL);
mv_resize->moveresize_emulation_surface = gdk_surface_new_temp (mv_resize->display, &rect);
mv_resize->moveresize_emulation_surface =
_gdk_x11_display_create_surface (mv_resize->display,
GDK_SURFACE_TEMP,
NULL,
-100, -100, 1, 1);
gdk_x11_surface_show (mv_resize->moveresize_emulation_surface, FALSE);
status = gdk_seat_grab (gdk_device_get_seat (mv_resize->device),
+6
View File
@@ -258,9 +258,12 @@ collect_reused_child_nodes (GskRenderer *renderer,
case GSK_LINEAR_GRADIENT_NODE:
/* Fallbacks (=> leaf for now */
case GSK_GL_SHADER_NODE:
case GSK_COLOR_MATRIX_NODE:
case GSK_TEXT_NODE:
case GSK_RADIAL_GRADIENT_NODE:
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
case GSK_REPEAT_NODE:
case GSK_BLEND_NODE:
case GSK_CROSS_FADE_NODE:
@@ -842,11 +845,14 @@ gsk_broadway_renderer_add_node (GskRenderer *renderer,
break; /* Fallback */
case GSK_TEXT_NODE:
case GSK_RADIAL_GRADIENT_NODE:
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
case GSK_REPEAT_NODE:
case GSK_BLEND_NODE:
case GSK_CROSS_FADE_NODE:
case GSK_BLUR_NODE:
case GSK_GL_SHADER_NODE:
default:
break; /* Fallback */
}
+5 -2
View File
@@ -587,7 +587,8 @@ texture_key_hash (gconstpointer v)
return GPOINTER_TO_UINT (k->pointer)
+ (guint)(k->scale*100)
+ (guint)k->filter;
+ (guint)k->filter * 2 +
+ (guint)k->pointer_is_child;
}
static gboolean
@@ -598,7 +599,9 @@ texture_key_equal (gconstpointer v1, gconstpointer v2)
return k1->pointer == k2->pointer &&
k1->scale == k2->scale &&
k1->filter == k2->filter;
k1->filter == k2->filter &&
k1->pointer_is_child == k2->pointer_is_child &&
(!k1->pointer_is_child || graphene_rect_equal (&k1->parent_rect, &k2->parent_rect));
}
int

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