Compare commits

...

552 Commits

Author SHA1 Message Date
Matthias Clasen 8609cd5686 Try to fix cairo node serialization
Place the saved png at the right offset.

This depends on
https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/118
to make the cairo recording surface produce a proper png.
2021-01-30 19:47:45 -05:00
Piotr Drąg cc5edbbbb2 Update POTFILES.in 2021-01-30 14:21:32 +01:00
Matthias Clasen 94d9e34dd3 Merge branch 'fix-unfocus-on-unmap' into 'master'
Fix unsetting focus

Closes #3623

See merge request GNOME/gtk!3136
2021-01-30 03:25:19 +00:00
Matthias Clasen 3dbf5038fa Fix unsetting focus
Make _gtk_window_unset_focus_and_default queue the changes
for after the next draw. This achieves two things: first,
it avoids invalidating css at the wrong time (e.g. when
setting child-visible during size-allocation), and second,
it defers the focus change until after the widget is
hidden, so that moving the focus has the desired effect
of picking a different, visible widget.

Fixes: #3623
2021-01-29 21:41:16 -05:00
Matthias Clasen 456a2f3bcf Merge branch 'msvc.nounistd' into 'master'
testsuite/testutils.c: Fix build on Visual Studio

See merge request GNOME/gtk!3131
2021-01-29 20:16:13 +00:00
Matthias Clasen 8e1fa52d14 Merge branch 'gst-vaapi-fix' into 'master'
gtkgstsink: Sync texture before handing it to GDK

See merge request GNOME/gtk!3114
2021-01-29 19:06:03 +00:00
Matthias Clasen cbf2feb633 Merge branch 'ci-gstreamer-deps' into 'master'
Ci gstreamer deps

See merge request GNOME/gtk!3133
2021-01-29 19:05:47 +00:00
Matthias Clasen afe8ee501c Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!3134
2021-01-29 18:47:31 +00:00
Jan Alexander Steffens (heftig) 4644dab081 gtkgstsink: Sync texture before handing it to GDK
We need to synchronize when moving the texture between contexts, or we
get glitches with VA-API decoding.
2021-01-29 18:58:17 +01:00
Matthias Clasen b37a69d76c ci: Add mesa-libGLES-devel
Try again, since libglvnd-devel is not the right choice.
2021-01-29 12:55:46 -05:00
Emmanuele Bassi 51bc6ce2e4 build: Disable subproject Cairo tests
There's really no point in running them.
2021-01-29 16:31:10 +00:00
Emmanuele Bassi 988ebc2248 docs: Annotate XML fragments as such
This way we can get syntax highlighting.
2021-01-29 16:31:10 +00:00
Emmanuele Bassi 9f31e95420 docs: Escape bare tags
Otherwise tools processing the description of GtkWidget will be *very*
confused.
2021-01-29 16:31:10 +00:00
Emmanuele Bassi 3a076e26f7 docs: Use the appropriate syntax for code block language 2021-01-29 16:31:09 +00:00
Emmanuele Bassi e3e85fc6f3 docs: Remove stray code block end marker 2021-01-29 16:31:09 +00:00
Jonas Ådahl ad3a35b4c5 Merge branch 'gtk-surface-release-4' into 'master'
wayland: Signal gtk-shell surface destruction to the server

See merge request GNOME/gtk!3129
2021-01-29 16:21:05 +00:00
Matthias Clasen 454caa3eec ci: Use v26 of the Fedora image
This includes libglvnd-devel and should fix using the
gstreamer gl support.
2021-01-29 11:14:54 -05:00
Matthias Clasen 0ffe67ffed ci: Add libglvnd-devel to images
gstreamers gl support included headers from this
package without depending on it. Work around this
packaging error by explicitly adding the needed
dependencies.
2021-01-29 11:07:11 -05:00
Matthias Clasen 8eb46bbfb2 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3615

See merge request GNOME/gtk!3132
2021-01-29 15:15:43 +00:00
Chun-wei Fan d8e8b3c235 testsuite/testutils.c: Fix build on Visual Studio
Visual Studio does not come with unistd.h, but Windows do have write() and
close() in io.h, so include io.h instead of unistd.h on Windows.

For MinGW, unistd.h in turn includes io.h.
2021-01-29 17:59:10 +08:00
Timm Bäder 79f273348d gl renderer: Fix viewport computation when rendering offscreen
Fixes #3615
2021-01-29 10:37:48 +01:00
Timm Bäder fc99081658 showrendernode: Monitor input file 2021-01-29 09:45:25 +01:00
Timm Bäder aba14e6a43 node editor: Show some default node data
Show case the icon and the render node format this way.
2021-01-29 09:45:25 +01:00
Timm Bäder 8ebcef97ff shader builder: Improve error output 2021-01-29 09:45:25 +01:00
Timm Bäder 00956a3770 node editor: Make help textview monospace
Otherwise the nice markdown tables don't line up.
2021-01-29 08:07:39 +01:00
Matthias Clasen 1635d9fb78 Merge branch 'pango-glyph-positions' into 'master'
Tell pango not to round glyph positions

See merge request GNOME/gtk!2058
2021-01-29 01:41:56 +00:00
Matthias Clasen 20fb155e8c gsk: Fix render node serialization
When looking for ascii glyphs, we must match
the pango shape flags that GTK is using.
2021-01-28 18:19:42 -05:00
Matthias Clasen da59c77ae2 widget: Use subpixel positioning
Before turning off pangos rounding of glyph positions,
we must check if the cairo we are using is new enough
to have working subpixel positioning (the relevant
cairo commit is 52a7c79fd4ff96bb5fac175f0199819b0f8c18fc).
2021-01-28 18:17:22 -05:00
Matthias Clasen 0d0bdaa02e gsk: Fix a thinko
With subpixel positioning, we need to offset the
cached glyphs by their phase.
2021-01-28 18:16:16 -05:00
Sebastian Keller 04cf5044da wayland: Signal gtk-shell surface destruction to the server
This adds a "release" destructor for the gtk_surface1 interface which
signals to the server that a surface has been destroyed on the client
side, which the current "destroy" does not do.

Ideally the protocol would have specified a destroy request marked as
destructor to handle this automatically, however this is no longer
possible due to the destroy method being implicitly generated in the
absence of an explicit request in the protocol. Adding a destroy request
marked as destructor now would generate a new destroy method that
unconditionally would send the request to the server, which would break
clients running on servers not supporting that request.
2021-01-28 22:31:03 +01:00
Anders Jonsson b005cd0bbd Update Swedish translation
(cherry picked from commit 5a5bb9099e)
2021-01-28 20:39:25 +00:00
Matthias Clasen f5379d2047 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!3127
2021-01-28 19:12:18 +00:00
Matthias Clasen 98c247ec29 label: Drop some unused includes 2021-01-28 12:27:07 -05:00
Matthias Clasen 38e2f9138d Remove vestigial glade support
These files have not been kept up to date, and
glade doesn't work with GTK4 currently.
2021-01-28 12:27:07 -05:00
Matthias Clasen 3cc7d9b8c0 Move the gesture icons in the right place
Put these images into gtk/icons, where they belong.
2021-01-28 12:27:07 -05:00
Matthias Clasen 1ac9400712 Drop unused logo resource
The inspector no longer sets a window icon.
2021-01-28 12:27:07 -05:00
Matthias Clasen 10d5705b70 Reduce use of GtkStyleContext
Remove some unnecessary uses of GtkStyleContext where
we can directly go to the GtkCssStyle, and and drop
unnnecessary includes.
2021-01-28 12:27:07 -05:00
Matthias Clasen 2d0d579735 Unify border-spacing handling
Avoid using GtkStyleContext unnecessarily, just go
to the css node directly.
2021-01-28 12:27:07 -05:00
Matthias Clasen ac0f524722 build: Redo the tools build
Move the tools directory to be toplevel, and instead of
recompiling sources twice, link them with the our new
static libgtk.a.
2021-01-28 12:27:07 -05:00
Matthias Clasen 2cd0e5f60b Merge branch 'wip/fl/gl-renderer-fixes' into 'master'
gskglshaderbuilder: bind correct uv location

See merge request GNOME/gtk!3128
2021-01-28 17:15:43 +00:00
Fabio Lagalla d83502d054 gskglshaderbuilder: bind correct uv location 2021-01-28 17:08:46 +01:00
Matthias Clasen 9e539a7f59 Merge branch 'matthiasc/for-master' into 'master'
builder-tool: Translate GtkImage:pixbuf

See merge request GNOME/gtk!3126
2021-01-28 02:04:48 +00:00
Matthias Clasen c60247f51f Merge branch 'wip/fl/gl-gradients' into 'master'
OpenGL gradient rendering improvements and additions

See merge request GNOME/gtk!3105
2021-01-28 01:43:57 +00:00
Matthias Clasen 06321511ad builder-tool: Translate GtkImage:pixbuf
The pixbuf property doesn't exist anymore. It is
commonly set to a path in ui files, so translate it
to the file property.
2021-01-27 17:01:51 -05:00
Matthias Clasen 2e7923cad0 Merge branch 'matthiasc/for-master' into 'master'
docs: Add gtk_widget_grab_default to migration guide

See merge request GNOME/gtk!3125
2021-01-27 21:53:02 +00:00
Matthias Clasen 3c66c27caa docs: Add gtk_widget_grab_default to migration guide
Point out the replacement for this api.
2021-01-27 13:50:05 -05:00
Timm Bäder 7f4bd6917e Merge branch 'sophie-h-master-patch-47269' into 'master'
widget: get_name() is not nullable

See merge request GNOME/gtk!3124
2021-01-27 18:34:10 +00:00
Sophie Herold b89376da55 widget: get_name() is not nullable
Partial revert of !2905
2021-01-27 17:49:17 +00:00
Fabio Lagalla a1dd6521e8 gskglrenderer: Remove switch fallthrough comments 2021-01-27 12:52:11 +01:00
Fabio Lagalla 0088f840fe gskrendernode: Cache angle in conic gradients 2021-01-27 12:44:10 +01:00
Fabio Lagalla 1b698c896e gskglrenderer: Use gboolean instead of bool 2021-01-27 12:44:10 +01:00
Fabio Lagalla 04000f28e7 gskglrenderer: First class support of repeating-radial-gradient 2021-01-27 12:44:10 +01:00
Fabio Lagalla 976a05f6eb gskglrenderer: First class support of repeating-linear-gradient 2021-01-27 12:44:10 +01:00
Fabio Lagalla b15902bf44 gskglrenderer: Optimize conic-gradient shader 2021-01-27 12:44:10 +01:00
Fabio Lagalla 5ac7529771 gskglrenderer: Optimize radial-gradient shader 2021-01-27 12:44:10 +01:00
Fabio Lagalla bbf68c0d9d gskglrenderer: Optimize linear-gradient shader 2021-01-27 12:44:10 +01:00
Matthias Clasen eeb3dd3511 Merge branch 'fix-can-focus' into 'master'
widget: Fix can-focus

Closes #3610

See merge request GNOME/gtk!3123
2021-01-27 05:34:21 +00:00
Matthias Clasen 7b0ce11e46 Merge branch 'search-entry-capture' into 'master'
Search entry capture

Closes #3098

See merge request GNOME/gtk!3115
2021-01-27 05:14:30 +00:00
Matthias Clasen 8ef1d6a49c widget: Fix can-focus
Setting can-focus to FALSE on a widget is supposed
to prevent focus from entering the entire subtree.
So when we grab focus directly to a widget, we need
to check the can-focus flag not just of the widget
itself, but all its ancestors.

Fixes: #3610
2021-01-26 23:45:06 -05:00
Matthias Clasen 7db60f958d searchentry: Capture events in the bubble phase
This is an unfortunate naming clash, but it avoids
an event handling clash between the capture widget
and its children.

Fixes: #3098
2021-01-26 22:17:57 -05:00
Matthias Clasen 30043e072e Merge branch 'css-crossfade-color' into 'master'
Css crossfade color

See merge request GNOME/gtk!3122
2021-01-27 03:11:17 +00:00
Matthias Clasen 5ee7606779 css: Support colors in cross fades
The CSS Image Spec (Level 4) allows colors in
cross-fade expressions to specify solid-color images.

Support this.
2021-01-26 21:14:09 -05:00
Matthias Clasen 25409c5a5a css: Add a constructor for GtkCssImageFallback
Add a way to create a solid color image.
2021-01-26 21:10:11 -05:00
Matthias Clasen 51122dd287 docs: Cosmetics
Tweak the css docs slightly.
2021-01-26 20:33:16 -05:00
Matthias Clasen ec9159f983 Merge branch 'gst-vaapi-fix-pre' into 'master'
Minor fixes to gtkgstsink

See merge request GNOME/gtk!3120
2021-01-27 01:11:54 +00:00
Matthias Clasen f3d77d1c21 Merge branch 'css-text-decoration' into 'master'
css: Fix text-decoration-line support

Closes #3621

See merge request GNOME/gtk!3121
2021-01-27 00:42:40 +00:00
Matthias Clasen 1258fcaaf4 css: Fix text-decoration-line support
This property needs to be treated as flags, not as
enum, since it should be possible to specify more
than one value, e.g.

text-decoration-line: underline overline;

Tests included.

Fixes: #3621
2021-01-26 17:53:14 -05:00
Jan Alexander Steffens (heftig) 00fd60aaa8 gtkgstsink: Use video_frame_free also for the GL path
The video frame needs to stay mapped while the texture is in use.

Avoid using g_memdup because the structure is not supposed to be moved.
2021-01-26 20:30:47 +01:00
Jan Alexander Steffens (heftig) c7a7d0582a gtkgstsink: Report allocation size even if no pool requested
We can do that so we should.
2021-01-26 20:30:47 +01:00
Matthias Clasen b6e7acfb90 Merge branch 'matthiasc/for-master' into 'master'
docs: Update border-size docs

See merge request GNOME/gtk!3119
2021-01-26 16:25:24 +00:00
Matthias Clasen 40eae298d5 docs: Update border-size docs
GtkCenterLayout respected border-size as well.
2021-01-26 10:40:22 -05:00
Marek Černocký 09a9131a10 Updated Czech translation 2021-01-26 16:21:18 +01:00
Marek Černocký c93c9f5c2a Updated Czech translation 2021-01-26 16:12:36 +01:00
Matthias Clasen 7f08adc23e Merge branch 'ebassi/for-master' into 'master'
Fixes for gdk_surface_translate_coordinates()

See merge request GNOME/gtk!3118
2021-01-26 13:57:50 +00:00
Emmanuele Bassi f41012080f Validate arguments
We're just assuming everything is not NULL or with a valid type.
2021-01-26 12:56:32 +00:00
Emmanuele Bassi 786e9d351c Make the inout argument logic clearer
It's easy to misread a `+=`.
2021-01-26 12:54:53 +00:00
Emmanuele Bassi 3d2cf97fbf Fix annotations
The arguments are really (inout), not (out).
2021-01-26 12:54:00 +00:00
Matthias Clasen 1fe6fb6739 Merge branch 'circular-menubutton' into 'master'
Allow circular menubuttons

Closes #3423 and #3523

See merge request GNOME/gtk!3117
2021-01-26 12:47:38 +00:00
Emmanuele Bassi 6710eb5eb3 Merge branch 'ricotz/for-master' into 'master'
gdk: Add missing g-i annotations for gdk_surface_translate_coordinates

See merge request GNOME/gtk!3112
2021-01-26 12:28:55 +00:00
Matthias Clasen 80b1d55683 Merge branch 'css-overline' into 'master'
css: Support overline

See merge request GNOME/gtk!3116
2021-01-26 05:44:14 +00:00
Matthias Clasen 1cebc4316b Allow circular menubuttons
Fixes #3523
2021-01-26 00:20:23 -05:00
Matthias Clasen 20895d6f3f Merge branch 'adaptive-emojichooser' into 'master'
Adaptive emojichooser

Closes #3307

See merge request GNOME/gtk!2989
2021-01-26 05:07:46 +00:00
Matthias Clasen 65a4118d50 css: Support overline
We can support text-decoration-line: overline,
since pango supports it now.
2021-01-26 00:04:04 -05:00
Matthias Clasen 4857829aaa popover: Try to not exceed monitor bounds
When the natural size of the popover exceeds
the monitor width, clamp it to fit on screen.

This gives the Emoji chooser a chance to
work on phone screens.

Fixes: #3307
2021-01-25 23:33:04 -05:00
Matthias Clasen 2ea4574caf emojichooser: Allow the section buttons to wrap
Use a flowbox instead of a horizontal box for
the section buttons at the bottom, so they can
wrap and allow for narrow layout.

We also need to stop giving the scrolledwindow
a content height, so it can shrink to make room
for more rows of section buttons.
2021-01-25 23:32:15 -05:00
Matthias Clasen 102b74f9eb emojichooser: Make keynav work with != 7 columns
The number of 7 columns was hardcoded in a few places
related to keynav across sections. The flowbox does
not have an api for it, but we can find out anyway
how many columns there are.
2021-01-25 23:32:08 -05:00
Matthias Clasen 8a0d4dfa94 searchbar: Capture events in the bubble phase
This is an unfortunate naming clash, but it avoids
an event handling clash between the capture widget
and its children.

Fixes: #3098
2021-01-25 22:16:29 -05:00
Matthias Clasen b4e645862a searchbar: Fix documentation mishap
The css section was inserted between the example
and the sentence referring to it.
2021-01-25 22:15:56 -05:00
Matthias Clasen ea48506a32 Merge branch 'simplify-get-module-path' into 'master'
modules: Simplify _gtk_get_module_path

See merge request GNOME/gtk!3113
2021-01-26 02:53:38 +00:00
Jan Alexander Steffens (heftig) 23f0a29260 modules: Simplify _gtk_get_module_path
Remove the bizarre loops.
2021-01-25 22:47:16 +01:00
Rico Tzschichholz 9249717cf4 gdk: Add missing g-i annotations for gdk_surface_translate_coordinates 2021-01-25 20:18:33 +01:00
Matthias Clasen 4196dfc374 Merge branch 'wip/jimmac/larger-scrollbars-gtk4' into 'master'
Adwaita: make scrollbars larger

Closes #1886

See merge request GNOME/gtk!3109
2021-01-25 13:35:47 +00:00
Jakub Steiner 23af707b41 Adwaita: make scrollbars larger
When using scrollbars as active controls, rather than their primary role as indicators,
increase their size as click targets.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1886
2021-01-25 14:15:22 +01:00
Matthias Clasen 421088c3a0 Merge branch 'transform-origin' into 'master'
Transform origin

See merge request GNOME/gtk!3108
2021-01-25 12:58:36 +00:00
Matthias Clasen 749f1a7c00 Add a reftest for transform-origin 2021-01-24 23:47:10 -05:00
Matthias Clasen 344f9fcf05 css: Implement transform-origin
Implement most of transform-origin. We only
handle the xy components currently, which lets
us reuse the position value implementation that
is used for background-position.
2021-01-24 22:49:08 -05:00
Matthias Clasen 4c971cd4da docs: Fix reference for css transform
Refer to the canonical location for the css
transform spec.
2021-01-24 22:48:00 -05:00
A S Alam 43d553dcfb Update Punjabi translation
(cherry picked from commit 64519d73bb)
2021-01-24 22:52:47 +00:00
A S Alam 66264f9a3d Update Punjabi translation
(cherry picked from commit 518331812e)
2021-01-24 22:42:39 +00:00
Efstathios Iosifidis 269f369541 Update Greek translation
(cherry picked from commit 281c17c400)
2021-01-24 10:17:36 +00:00
Matthias Clasen 1973019962 Merge branch 'static-lib-for-tests' into 'master'
Static lib for tests

See merge request GNOME/gtk!3107
2021-01-23 16:15:23 +00:00
Matthias Clasen fe515c4c1c testsuite: Link some tests statically
Link tests for private apis statically.
2021-01-23 10:34:57 -05:00
Matthias Clasen 14f0a0addb Create a static library
Rearrange our build to create a libgtk.a for the the contents of gtk/,
and build libgtk-4.so from our per-subdirectory static libraries.
This will let us link tests statically for testing internal apis.
2021-01-23 10:31:23 -05:00
Matthias Clasen 64a2d0221c Merge branch 'lsan-leaks-2' into 'master'
Lsan leaks 2

See merge request GNOME/gtk!3106
2021-01-22 20:08:54 +00:00
Matthias Clasen 0ef91c3ba8 Avoid a buffer overrun
We were putting the '\0' behind the end. Oops.
2021-01-22 13:56:04 -05:00
Matthias Clasen 2adcb7be71 Tweak lsan suppressions
We don't use atk-bridge anymore, and we don't want
to see gio leaks.
2021-01-22 13:32:41 -05:00
Matthias Clasen a332f2402a ci: Don't print lsan suppressions
Printing these out breaks TAP output, and we really
aren't interested in them.
2021-01-22 13:01:09 -05:00
Matthias Clasen 131a61c51b testsuite: Fix a leak
asan pointed out that the array tests leak.
2021-01-22 11:50:04 -05:00
Matthias Clasen 39d5dd89c5 Avoid a heap-use-after-free
_gtk_gesture_cancel_sequence frees the struct pointed to by data,
so don't write to it afterwards. Found by asan.
2021-01-22 11:39:04 -05:00
Danial Behzadi 341efe9a40 Update Persian translation 2021-01-22 14:57:52 +00:00
Matthias Clasen 5ed6f89b4a Merge branch 'lsan-leaks' into 'master'
Lsan leaks

See merge request GNOME/gtk!3104
2021-01-22 12:30:22 +00:00
Matthias Clasen 4d609149d2 Merge branch 'tests-without-diff' into 'master'
testsuite: Stop requiring diff

See merge request GNOME/gtk!3103
2021-01-22 05:16:08 +00:00
Matthias Clasen 0d790505aa Force malloc of g_slices in asan build
Otherwise leaks could be missed.
2021-01-22 00:13:13 -05:00
Matthias Clasen a486536925 Remove libc from leak suppression list
Every program starts in __libc_start_main, so this would suppress
everything. This doesn't happen in practice because asan by default
is unable to unwind the stack. Setting
ASAN_OPTIONS=fast_unwind_on_malloc=0,malloc_context_size=15 can unwind
the stack, and if malloc_context_size is large enough it will indeed
suppress everything.
2021-01-22 00:12:46 -05:00
Matthias Clasen e808fb424a testsuite: Stop requiring diff
Unify the many copies of diff_with_file in one source
file, and patch it to detect diff at runtime and fall
back to a simple strcmp if we don't have it. Make all
tests use this new testutils.c, and stop requiring
diff for building the tests.

This should let us allow to build on Windows with the
default value for -Dbuild-tests.
2021-01-21 23:57:24 -05:00
Matthias Clasen 6c54abeca7 wayland: Explicitly announce ssd for kwin
Without this, kwin correctly assumes that we are
using client-side decorations. This is a port
of 32ae97f1 from GTK 3.24.

Fixes: #3609
2021-01-21 22:45:47 -05:00
Daniel Șerbănescu d24b8a094c Update Romanian translation 2021-01-21 19:27:47 +00:00
Emmanuele Bassi c46391420f Merge branch 'ebassi/lazier-a11y' into 'master'
Lazier accessibility

See merge request GNOME/gtk!3102
2021-01-21 18:57:34 +00:00
Yuri Chornoivan 68df7527f7 Update Ukrainian translation 2021-01-21 18:23:25 +00:00
Matthias Clasen 5a3c3d8210 Merge branch 'inspector-controllers' into 'master'
Inspector controllers

See merge request GNOME/gtk!3101
2021-01-21 18:15:57 +00:00
Emmanuele Bassi 95ceb49770 a11y: Make GtkATContext realization lazier
We only realize the ATContext on the top level, which will create an
GtkAtSpiRoot object and the corresponding GtkAtSpiCache object. Whenever
an AT connects to the accessibility bus, and asks for the various
objects, all the ATContext will be realized on demand.
2021-01-21 16:40:57 +00:00
Emmanuele Bassi 0bde58ffd7 a11y: Avoid signal emission during cache population
If we're responding to a request to get all the cached items, there's no
need to emit signals when adding an ATContext to the cache.
2021-01-21 16:40:57 +00:00
Matthias Clasen ccd9827b63 inspector: Redo the actions page
Don't create widgets in bind, instead just set
the new action on the action-editor, and let it
recreate the parts that need to be recreated.
2021-01-21 10:25:13 -05:00
Matthias Clasen db189cfb9f inspector: Reshuffle action editor
Prepare the action editor for being able to change its
actions after creation.
2021-01-21 10:24:31 -05:00
Matthias Clasen 7527f181d5 inspector: Simplify action editor
We are not using the size group anymore, so drop it.
2021-01-21 10:20:21 -05:00
Matthias Clasen c05b418512 inspector: Split out variant editor 2021-01-21 10:19:18 -05:00
Matthias Clasen e97d996fe4 inspector: Redo the shortcuts page
Use a column view here.
2021-01-21 10:19:18 -05:00
Matthias Clasen 0537b167ca inspector: Redo the controllers page
Use a column view, and only show the widgets own
controllers.
2021-01-21 10:19:18 -05:00
Matthias Clasen 40446201ff Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

Closes #3607

See merge request GNOME/gtk!3100
2021-01-21 04:22:13 +00:00
Matthias Clasen fff6b35821 inspector: Redo the controllers page
Use a column view, and only show the widgets own
controllers.
2021-01-20 18:51:01 -05:00
Emmanuele Bassi 75f2d7583f Abort if the shared memory pool cannot be created
If we cannot allocate memory, we cannot create any windowing system
surface. There's no coming back from that.

Fixes: #3607
2021-01-20 19:10:54 +00:00
Matthias Clasen 1fd8d3b487 Merge branch 'matthiasc/for-master' into 'master'
docs: Update getting started section

Closes #3601

See merge request GNOME/gtk!3099
2021-01-20 15:54:37 +00:00
Emmanuele Bassi a1216599ff Add rename-to annotation for GtkListStore.insert_valuesv()
The vector-based variant should shadow the variadic arguments function
in bindings.
2021-01-20 14:10:17 +00:00
Emmanuele Bassi 8fff0e0fdf docs: Reformat GtkListStore.insert_values() 2021-01-20 14:10:17 +00:00
Emmanuele Bassi 439727a84a Add more directions to the issue templates
Let's hope people read them.
2021-01-20 14:10:17 +00:00
Matthias Clasen 3a18a6dddf docs: Update getting started section
We were still talking about draw signals here,
which don't exist anymore.

Fixes: #3601
2021-01-20 08:01:54 -05:00
Matthias Clasen d7050c63ae Merge branch 'treeview-sort-arrows' into 'master'
Redo arrow icons in various widgets

Closes #3577

See merge request GNOME/gtk!3097
2021-01-19 21:24:04 +00:00
Balázs Meskó b7c88ec87d Update Hungarian translation 2021-01-19 20:47:20 +00:00
Matthias Clasen 5985b62f60 columnview: Redo indicator arrows
Use the same approach as GtkTreeViewColumn for sort
indicators. Luckily, the same css works for both.
2021-01-19 14:24:19 -05:00
Matthias Clasen e7c29b989c menbutton: Redo indicator arrows
Instead of hardcoding icon names in the widget, use
arrow.none, arrow.up, arrow.down, arrow.left, arrow.right
styles and set the icon to use with -gtk-icon-source. This
lets themes change the icons that are used here, without
forcing all uses of pan-up/down/start/end-symbolic to be
treated the same.

Document this in the menubutton CSS docs.
2021-01-19 14:02:23 -05:00
Matthias Clasen 2100e427d9 treeviewcolumn: Redo sort arrows
Instead of hardcoding icon names in the widget, use
sort-indicator.ascending and sort-indicator.descending styles
and set the icon to use with -gtk-icon-source. This lets themes
change the icon that is used here, without forcing all uses of
pan-up/down-symbolic to be treated the same.

Document this in the treeview CSS docs.

Fixes: #3577
2021-01-19 14:02:16 -05:00
Matthias Clasen 2550d6dc63 Merge branch 'wip/kalev/dist-HighContrast-dark' into 'master'
dist: Fix css theme disting after HighContrast-dark changes

See merge request GNOME/gtk!3095
2021-01-19 12:08:21 +00:00
Matthias Clasen ca72fae884 Merge branch 'issue-2436-gtk4' into 'master'
macOS: fix #2436 raise transient window on focus

Closes #2436

See merge request GNOME/gtk!3094
2021-01-19 11:56:54 +00:00
Matthias Clasen 4fc1af14a7 Merge branch 'wip/kalev/NEWS.pre-4.0' into 'master'
Split NEWS for pre-4.0 changes

See merge request GNOME/gtk!3096
2021-01-19 11:43:58 +00:00
Kalev Lember 1a30ec6da6 dist: Fix css theme disting after HighContrast-dark changes
Commit f60d245e32 renamed it from
HighContrast-inverse.css to HighContrast-dark.css.
2021-01-19 10:50:30 +01:00
Kalev Lember e77d519482 Split NEWS for pre-4.0 changes
Similar to commit 87e9f0895b that did the
same for older releases, this commit splits out pre-4.0 changes to
separate NEWS.pre-4.0 file.
2021-01-19 10:40:09 +01:00
Thomas Holder 59806eee38 macOS: fix #2436 raise transient window on focus
Ported from gtk-3-24 e278f38905

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/2436
2021-01-19 09:31:00 +01:00
Matthias Clasen e6f0103940 Merge branch 'version-bump' into 'master'
Version bump

See merge request GNOME/gtk!3093
2021-01-19 04:48:26 +00:00
Matthias Clasen cbaad3dbd9 Add version macros for 4.2
These will be needed for adding new API.
2021-01-18 23:10:18 -05:00
Matthias Clasen ee43a6a603 Bump version to 4.1
master is now open for 4.2 API additions.

Includes an update for the one test we have that
has the version number in its expected output.
2021-01-18 23:09:44 -05:00
Matthias Clasen 1ac1147ecb Merge branch 'check_button_activate' into 'master'
Add activate signal to GtkCheckButton

Closes #3525 and #3550

See merge request GNOME/gtk!3012
2021-01-19 04:06:01 +00:00
Matthias Clasen 1edbc1f1f9 Merge branch 'wip/jtojnar/fix-pc-vulcan' into 'master'
build: Use Meson’s module for building .pc files

Closes #3517

See merge request GNOME/gtk!3005
2021-01-19 04:04:34 +00:00
Matthias Clasen 146b4c93ba 4.0.2 2021-01-18 22:23:57 -05:00
Matthias Clasen 94f90f457a Merge branch 'fix-cell-renderer-toggle' into 'master'
cellrenderertoggle: Fix css node handling

Closes #3599

See merge request GNOME/gtk!3092
2021-01-19 02:09:10 +00:00
Matthias Clasen 6b7d56ac49 cellrenderertoggle: Fix css node handling
Commit cbbbf44dd4 tried to replace
gtk_style_context_save_named with an explicit
css node to save to, but it failed, and the failure
was showing up as crashes in the inspector.

Fix by Benjamin Otte.

Fixes: #3599
2021-01-18 20:52:59 -05:00
Emmanuele Bassi 1635d7be8c Merge branch 'cherry-pick-gtk_file_chooser_set_current_name-fix-type' into 'master'
gtk_file_chooser_set_current_name: fix type of name argument

See merge request GNOME/gtk!3091
2021-01-18 23:19:00 +00:00
Thomas Holder 992cd088cf gtk_file_chooser_set_current_name: fix type of name argument
The description says UTF-8 string, but the annotation said filename.

Cherry-picked from gtk-3-24 1573ff6803
2021-01-18 22:14:03 +01:00
Matthias Clasen f6010b2a59 Merge branch 'doap-update' into 'master'
Update the gtk.doap file

See merge request GNOME/gtk!3088
2021-01-18 14:40:02 +00:00
Matthias Clasen 9222a5fd6d Update the gtk.doap file
Add relevant people as maintainers.
2021-01-18 09:14:50 -05:00
Florentina Mușat 6f7fb6ba5a Update Romanian translation 2021-01-18 13:06:18 +00:00
Chun-wei Fan a57a144f8e Merge branch 'win32-remove-layered-windows' into 'master'
GDK/Win32: Remove layered windows usage

See merge request GNOME/gtk!2782
2021-01-18 10:42:37 +00:00
Chun-wei Fan 7b47e3225b GDK/Win32: Remove layered windows usage
In GTK4, we are now defaulting to the OpenGL renderer with the Cairo renderer
only used as a fallback, so there is no point keeping the code paths that use
layered windows as layered windows do not work well with OpenGL nor Vulkan.
2021-01-18 12:48:16 +08:00
Matthias Clasen 6aa893e091 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3437

See merge request GNOME/gtk!3087
2021-01-17 17:51:15 +00:00
Matthias Clasen 5aa03bcb0d aboutdialog: Fix initial focus
When GtkAboutDialog was changed to derive from
GtkWindow, it lost the initial focus handling that
GtkDialog has. Reinstate some of it.

Fixes: #3437
2021-01-17 11:53:53 -05:00
Matthias Clasen d7060025e0 inspector: Avoid a critical
Avoid a critical when closing the inspector with the
recorder page open.
2021-01-17 10:55:53 -05:00
Matthias Clasen 00883016af Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

Closes #3593

See merge request GNOME/gtk!3086
2021-01-17 14:20:13 +00:00
Fabio Tomat f0d8b614d0 Update Friulian translation 2021-01-17 13:11:25 +00:00
Piotr Drąg ddbd574643 Update Polish translation 2021-01-17 12:38:17 +01:00
Timm Bäder 5ea3777599 widget: Fix gtk_widget_class_add_binding() argument name 2021-01-17 08:12:14 +01:00
Timm Bäder a3949763f2 Add nullable annotations to GtkShortcutFunc
Fixes #3593
2021-01-17 08:11:42 +01:00
Matthias Clasen 1b961a9ae2 Merge branch 'surface-scale' into 'master'
Surface scale

Closes #3578

See merge request GNOME/gtk!3085
2021-01-17 05:23:22 +00:00
Timm Bäder d9f6b268d3 gl renderer: Use rect_contains_rect() copy
And this way the contains_rect() inside
rounded_inner_rect_contains_rect() goes from 3.3% to 0.79% in the
fishbowl when rendering the levelbars.
2021-01-17 04:39:26 +01:00
Timm Bäder 934b91f65f label: Remove unneeded NULL guards
The pointers passed to GtkWidgetClass::measure cannot be NULL
2021-01-17 04:39:26 +01:00
Timm Bäder c3050231d1 label: Refactor get_layout_location
Make this function shorter, the parameters non-nullable and the simple
cases more explicit.
2021-01-17 04:39:26 +01:00
Timm Bäder 4d7a01562e gl renderer: Don't reset offset when drawing offscreen 2021-01-17 04:39:26 +01:00
Timm Bäder 650eed7f72 gl renderer: Properly y-flip non-offscreen children of rounded clips 2021-01-17 04:39:26 +01:00
Timm Bäder ec8614e8e4 label: Fix a potential memory leak
This only happens in error cases so not very interesting. Anyway, try to
make scan-build happy.
2021-01-17 04:39:26 +01:00
Timm Bäder cb41b96a9e builderparser: Save finalizers in a GPtrArray
We get up to 370 of these when starting the widget-factory.
2021-01-17 04:39:26 +01:00
Timm Bäder 872b46a527 widget: Shorten get_halign() a bit 2021-01-17 04:39:26 +01:00
Timm Bäder b1c8613dbe accessible: Fix memory leak if context is unset
Unref the acessible values
2021-01-17 04:39:26 +01:00
Timm Bäder de6cd4f0d2 builder: Use a GPtrArray when parsing signals 2021-01-17 04:39:26 +01:00
Timm Bäder aec2fb939f builderparser: Keep properties in a GPtrArray 2021-01-17 04:39:26 +01:00
Timm Bäder 69293db804 builderparser: Only allocate subparser stack when needed
Out of the 3.3k possibly_finish_subparser calls when opening the
widget-factory, only 300 need one.
2021-01-17 04:39:26 +01:00
Matthias Clasen 61a7ebf980 Merge branch 'matthiasc/for-master' into 'master'
docs: Add details

See merge request GNOME/gtk!3084
2021-01-16 20:36:44 +00:00
Matthias Clasen f14762b026 x11: Notify on surface scale changes
Emit property notification when the surface scale
changes.
2021-01-16 15:22:46 -05:00
Matthias Clasen 187d261400 wayland: Notify on surface changes
When the width, height or scale of a surface changes,
emit property change notification.
2021-01-16 15:22:46 -05:00
Matthias Clasen e905f7ff7c native: Listen for scale changes
Connect to change notification for the surface
scale-factor property, and update the widgets
when it changes.

Fixes: #3578
2021-01-16 15:22:46 -05:00
Matthias Clasen aefc630d29 surface: Add a scale-factor property
This will allow us to notify when the scale changes.
2021-01-16 15:22:46 -05:00
Matthias Clasen a5e929ce36 docs: Add details
Explain the difference between GtkPicture and GtkImage,
and when you might want to use which.
2021-01-16 14:45:20 -05:00
Yuri Chornoivan 1641d365f5 Update Ukrainian translation 2021-01-16 18:44:30 +00:00
Matthias Clasen 07d9cd8efe Merge branch 'matthiasc/for-master' into 'master'
inspector: Add a legend for the layout overlay

See merge request GNOME/gtk!3083
2021-01-16 18:37:58 +00:00
Matthias Clasen 29868b2a05 docs: Remove a reference to configure events
Those don't exist anymore.
2021-01-16 12:52:06 -05:00
Matthias Clasen 691b6b88ea inspector: Add a legend for the layout overlay
Colors are more useful if you know what they represent.
2021-01-16 12:38:24 -05:00
Matthias Clasen 2ee1a00177 Merge branch 'matthiasc/for-master' into 'master'
overlaylayout: Set the child type in the class

See merge request GNOME/gtk!3082
2021-01-16 03:55:22 +00:00
Matthias Clasen 144cf2d040 overlaylayout: Set the child type in the class
We don't need to override create_layout_child here,
and setting the child type has the advantage that
the layout properties are showing up in the inspector.
2021-01-15 22:35:11 -05:00
Matthias Clasen e1a308d151 Merge branch 'rtl-margins' into 'master'
Flip margin-start and -end in RTL

Closes #3583

See merge request GNOME/gtk!3081
2021-01-16 00:19:41 +00:00
Matthias Clasen bbfaacb598 Add a reftest for box flipping
Test that a horizontal box changes the order of its
children in RTL, and that widget margins flip start
and end.

This tests the fix in d89ff71819.
2021-01-15 18:43:31 -05:00
Matthias Clasen d89ff71819 Flip margin-start and -end in RTL
We lost this at some point, but the widget margins
are still meant to be relative to the text direction.

Fixes: #3583
2021-01-15 14:58:21 -05:00
Matthias Clasen 141c725489 Merge branch 'macos-ci-cairo' into 'master'
Revert "Fix the cairo build on OS X"

See merge request GNOME/gtk!3080
2021-01-15 15:56:37 +00:00
Matthias Clasen bbc3aa4ff9 Revert "Fix the cairo build on OS X"
This reverts commit 710ef00dfe.

The cairo change has been merged.
2021-01-15 09:07:02 -05:00
Marek Černocký f7856f29fd Updated Czech translation 2021-01-15 14:10:17 +01:00
Matthias Clasen 7b69c58deb Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!3078
2021-01-15 05:48:00 +00:00
Matthias Clasen f60d245e32 Make HighContrastInverse a dark variant
Make HighContrastInverse available as the dark variant of HighContrast,
in addition to being a standalone theme. This regularizes our theme
variants, and doesn't hurt.
2021-01-14 22:55:52 -05:00
Matthias Clasen f04e5bd590 Make Adwaita-dark available as a theme
This makes Adwaita-dark available as a standalone
theme.
2021-01-14 22:42:50 -05:00
Matthias Clasen 90c428b4a7 Merge branch 'wip/carlosg/mark-valid-portal-settings' into 'master'
gdk/wayland: Mark matched settings from the portal as valid

See merge request GNOME/gtk!3076
2021-01-14 18:33:45 +00:00
Carlos Garnacho 97b5fad131 gdk/wayland: Mark matched settings from the portal as valid
Commit e6209de962 added some checks on TranslationEntry.valid in
order to figure out whether using the new font settings or the
old g-s-d ones. However that's only set in the non-sandboxed case.

This makes sandboxed applications fallback to the old (and also
non-existing with modern g-s-d) settings, possibly resulting in
ugly defaults being picked.

Fix this by also marking TranslationEntry elements as valid when
using the settings portal, precisely those entries that we are able
to read and match with our own table.
2021-01-14 15:57:29 +01:00
Matthias Clasen 285a91715d Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!3075
2021-01-14 13:38:18 +00:00
Matthias Clasen 880468f5a3 docs: Fix a heading gotcha
One of the many migration guide sections was too
prominent.
2021-01-14 08:13:34 -05:00
Matthias Clasen 6ddbb2a402 doc: Clarify some migration hints
Don't mention GdkSurface::layout as replacement for
GtkWindow::configure-event. Instead, explain how to
save window state.
2021-01-14 07:52:36 -05:00
Daniel Mustieles 7eab565225 Updated Spanish translation 2021-01-14 10:35:43 +01:00
Daniel Mustieles b34101d45d Updated Spanish translation 2021-01-14 10:35:35 +01:00
Christian Hergert 6c21a7be0b Merge branch 'nacho/macos-stylus' into 'master'
Support stylus devices on macos

See merge request GNOME/gtk!3058
2021-01-13 16:13:14 +00:00
Anders Jonsson a6f2bcb220 Update Swedish translation 2021-01-12 21:55:52 +00:00
Anders Jonsson ef0db01d5c Update Swedish translation 2021-01-12 21:51:53 +00:00
Emmanuele Bassi ef33ec639c Merge branch 'ebassi/aspect-frame-doc' into 'master'
Ebassi/aspect frame doc

See merge request GNOME/gtk!3073
2021-01-12 16:50:31 +00:00
Matthias Clasen 27ca4434e2 Remove a misleading comment 2021-01-12 10:50:41 -05:00
Matthias Clasen 9861c7d25c Merge branch 'dist-css' into 'master'
dist: Add a dist script to generate css

See merge request GNOME/gtk!3074
2021-01-12 14:04:51 +00:00
Matthias Clasen 13ef82fc4d dist: Add a dist script to generate css
When I added the sassc option, I failed to ensure that
the theme css is included in the tarballs. This is required
to make tarball builds with -Dsassc=disabled work.
2021-01-12 08:42:18 -05:00
Emmanuele Bassi b33ca43e14 Merge branch 'ebassi/atspi-path-sanitize' into 'master'
a11y: Fix leak

See merge request GNOME/gtk!3072
2021-01-12 12:37:31 +00:00
Emmanuele Bassi 39e07a8d56 Document limits of gtk_aspect_frame_get_ratio()
The GtkAspectFrame:ratio getter will return the value set, not the
actual ratio computed in case GtkAspectFrame:obey-child is TRUE.
2021-01-12 12:28:18 +00:00
Emmanuele Bassi 5286743cbe Document GtkAspectFrame properties 2021-01-12 12:28:00 +00:00
Emmanuele Bassi 58bb998ef0 docs: GtkAspectFrame is not a GtkFrame any more 2021-01-12 12:23:14 +00:00
Emmanuele Bassi a56b2900dd a11y: Fix leak
Introduced by me in commit 03b60a2d5e.
2021-01-12 12:01:29 +00:00
Emmanuele Bassi ff34124394 Merge branch 'ebassi/atspi-path-sanitize' into 'master'
a11y: Sanitize the AT-SPI object path further

See merge request GNOME/gtk!3071
2021-01-12 11:36:52 +00:00
Emmanuele Bassi 03b60a2d5e a11y: Sanitize the AT-SPI object path further
When falling back to g_get_prgname(), we need to take into account that
the program name may be the full argv[0] path, which will end up messing
the DBus object path.
2021-01-12 11:15:28 +00:00
Benjamin Otte d939d04885 Merge branch 'about-dialog-icon-size' into 'master'
About dialog icon size

See merge request GNOME/gtk!3070
2021-01-11 23:13:21 +00:00
Matthias Clasen 73fb28a058 iconhelper: Recreate the texture when needed
When the icon size changes, we want to reload themed
icons.

This was showing up as the GtkImage in about dialogs
getting a big size with the same small icon upon
changing -gtk-icon-size in the inspector.
2021-01-11 17:50:05 -05:00
Matthias Clasen 65eaf8e8c4 Adwaita: Make about dialog icons big
Use 128 as the icon size for the image widget
in about dialogs.
2021-01-11 17:50:05 -05:00
Matthias Clasen beeedb5141 aboutdialog: Set icon-size for the logo
Make it explicit that we want large icons here.
2021-01-11 17:50:05 -05:00
Matthias Clasen 1d40750a60 aboutdialog: Set a style class
Add the .aboutdialog style class to toplevel
widget of about dialogs, similar to what we
do for e.g. GtkAssistant.
2021-01-11 17:46:55 -05:00
Matthias Clasen 96baf9769a about dialog: Remove manual icon sizing
We have icon theme code to do that for us.
2021-01-11 17:46:55 -05:00
Matthias Clasen 5044031b53 Merge branch 'wip/kalev/gcc-11' into 'master'
Avoid diagnostics for gcc-11 false positive out of bounds accesses

See merge request GNOME/gtk!3064
2021-01-11 22:04:52 +00:00
Emmanuele Bassi 9f7119ee58 Merge branch 'wip/fl/glrenderer-fixes' into 'master'
gl renderer: print fragment shader info

See merge request GNOME/gtk!3069
2021-01-11 16:44:00 +00:00
Kalev Lember c514c41d0e Avoid diagnostics for gcc-11 false positive out of bounds accesses
This is a patch by Jeff Law <law@redhat.com> done in downstream Fedora
to fix the build with gcc 11.
2021-01-11 17:19:36 +01:00
Jakub Steiner 45848c5298 Merge branch 'wip/jimmac/adjust-for-contemporary-trends' into 'master'
Wip/jimmac/adjust for contemporary trends

Closes #3568 and #3560

See merge request GNOME/gtk!3060
2021-01-11 16:09:08 +00:00
Fabio Lagalla 8c61038b9f gl renderer: print fragment shader info
It was logged twice the vertex shader info, instead
2021-01-11 17:06:03 +01:00
Jakub Steiner b5cb2f7e41 Adwaita: update image assets
- reflect button styling
- ignore backdrop for non buttons
2021-01-11 16:24:22 +01:00
Matthias Clasen 8af0d4b51f Merge branch 'otte/for-master2' into 'master'
Remove guarantees we do not intend to hold

See merge request GNOME/gtk!3066
2021-01-11 15:07:40 +00:00
Jakub Steiner 378ad75d48 Adwaita: scales border
- remove -alt specialcasing for a straight forward border like
  everything else and avoid broken :dark and HC
2021-01-11 16:00:32 +01:00
Matthias Clasen 01d19e2aa4 Merge branch 'fix-tablet-4' into 'master'
Wayland: ignore touch/tablet events on destroyed surfaces [GTK4]

See merge request GNOME/gtk!3065
2021-01-11 14:44:27 +00:00
Jakub Steiner 64e16ecaf1 Merge branch 'wip/jimmac/undercorated-active' into 'master'
Adwaita: less dramatic :active for undecorated buttons

Closes #3575

See merge request GNOME/gtk!3068
2021-01-11 14:37:58 +00:00
Jakub Steiner 6a047e53a8 Adwaita: less dramatic :active for undecorated buttons
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3575
2021-01-11 15:00:38 +01:00
Jakub Steiner 31a7bc70c9 Adwaita: fix button border logic
- tint borders dark on non default / blue / red buttons
- just use plain $borders_color otherwise
- fixes HC/HCi
- ditch -alt buttons
2021-01-11 14:08:57 +01:00
Jakub Steiner 874cae1dab Adwaita: flatter, lighter buttons
- lighten up for contrast, less of an oldschool gradient

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3568
2021-01-11 13:50:32 +01:00
Jakub Steiner 7a3dd41dba Adwaita: round progress and levelbars 2021-01-11 13:50:32 +01:00
Jakub Steiner 149962670a Adwaita: :checked:active and checked:hover states
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3560
2021-01-11 13:50:32 +01:00
Jakub Steiner 849e3c8b4b Adwaita: flat scales, progressbars and level bars 2021-01-11 13:50:32 +01:00
Jakub Steiner c9807f5afe Adwaita: remove edge highlights
- flat is the name of the game
  - kids scream make it flat
  - simplify mixins
2021-01-11 13:50:32 +01:00
Carlos Garnacho 9a9899597c Merge branch 'avoid-pointer-reset-gtk4' into 'master'
wayland: avoid set_cursor() when unchanged or invisible

Closes #3350

See merge request GNOME/gtk!3062
2021-01-11 12:07:01 +00:00
Matthias Clasen fecb7af66e Merge branch 'surface.compute.win32' into 'master'
Fix surface and geometry computation for Windows (Win32)

Closes #3480

See merge request GNOME/gtk!3067
2021-01-11 11:56:42 +00:00
Ignacio Casal Quinteiro f5efb15cba Support stylus devices on macos 2021-01-11 11:41:00 +01:00
Chun-wei Fan d7d4fed0f3 gdk/win32: Fix window display and resizing
Have an implementation of ->request_layout() and ->compute_size() for the Win32
surface backend so that we can properly display and move and resize the
windows, as we request from the Win32 APIs.

Hxndling Aerosnap properly is mostly done except for snap_up(), which needs to
to be looked at later.
2021-01-11 17:55:25 +08:00
Chun-wei Fan c2c2635763 gdk/win32: Rename 'margins' to 'shadow'
This improves consistency for the code.
2021-01-11 17:53:56 +08:00
Chun-wei Fan fb33e83c96 gdkwin32-surface.c: Fix return type
gdk_win32_toplevel_present() should now be returning nothing, not a gboolean.
2021-01-11 17:53:47 +08:00
Chun-wei Fan 291ad17a22 gdksurface-win32.c: Decouple mapped state from surface creation
In line with what is done with the Wayland backend, enable the mapped state
independently as needed from the toplevel surface presentation, and also enable
the mapped state if necessary when presenting the popup surface.
2021-01-11 17:53:38 +08:00
Benjamin Otte 0f052d46b2 Remove guarantees we do not intend to hold
The fact that we are using gdk-pixbuf for loading files currrently does not mean we will use it going forward.
Also, "anything gdk-pixbuf can load" does not mean anything, because what gdk-pixbuf can load is a compile-time option.

As new_from_resource() will assert() if it cannot load a resource, we must be very sure that people do not use anything but PNG and JPEG for resources and the docs were not clear on that.
2021-01-10 21:37:03 +00:00
Asier Sarasua Garmendia 506423cf23 Update Basque translation 2021-01-10 18:00:26 +00:00
Asier Sarasua Garmendia 946a496a2e Update Basque translation 2021-01-10 17:59:56 +00:00
Piotr Drąg d20526570b Update Polish translation 2021-01-10 18:27:55 +01:00
wisp3rwind 8312b9d9ca Wayland: ignore touch/tablet events on destroyed surfaces
When destroying a wl_surface (e.g. when a window or menu is closed), the
surface may continue to exist in the compositor slightly longer than on
the client side. In that case, the surface can still receive input
events, which need to be ignored gracefully.
In particular, this prevents segfaulting on wl_surface_get_user_data()
in that situation.

Reported in
https://gitlab.gnome.org/GNOME/gtk/-/issues/3296

The same issue for pointers/keyboards was reported in
https://bugzilla.gnome.org/show_bug.cgi?id=693338

and fixed with in
bfd7137ffb
3625f17857
a8fc099a72
2021-01-10 12:31:37 +01:00
wisp3rwind 992f092968 wayland: avoid set_cursor() when unchanged or invisible
In pointer_surface_update_scale(), only rescale the cursor surface when
the scale has actually changed and the cursor is on at least one output.

fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3350

Right now, this issue is not completely understood, so it might also
involve some questionable handling of cursor surface by sway/wlroots.

However, irrespective of that issue, this patch avoids unnecessary calls to the
compositor, and there should be no drawback: Whenever the pointer enters
a new output, pointer_surface_update_scale() will be called again, such
that correct scaling of the cursor is still ensured.

There is a slight difference: When the cursor leaves the last output,
previously the image was reset to scale factor 1. Now, it keeps whatever
was last. That might be more sensible than the previous behaviour,
assuming that it's likely that when the cursor enter an output again, it
has the same scaling. Alternatively, if one cares about resource usage
at this level, it might make more sense to destroy the surface than
rescaling to 1.
2021-01-09 11:42:59 +01:00
Matthias Clasen 60835227a1 4.0.1 2021-01-09 01:30:13 -05:00
Matthias Clasen 2b6b35d91f build: Add a sassc feature
Add an option to disable css rebuilds. This allows
to build GTK from release tarballs (Which are including
the css) without a sassc dependency.
2021-01-09 01:30:13 -05:00
Matthias Clasen 897164c66c Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3565

See merge request GNOME/gtk!3061
2021-01-09 03:56:59 +00:00
Matthias Clasen 441d944c08 droptarget: Some docs cleanups
Fixes #3565, among other things.
2021-01-08 22:24:42 -05:00
Chun-wei Fan 2b8ad6c4b5 gtkffmediafile.c: Use g_snprintf()
Visual Studio 2013 is just shy of being sufficiently C99-compliant to
build GTK master, as it did not support snprintf() in its CRT
implementation.

Use g_snprintf() to cover for this.
2021-01-08 22:24:42 -05:00
Chun-wei Fan 99b2da4c47 gtk/gtksecurememoryprivate.h: Include glib.h
Some compilers somehow do not have `inline` defined, so include glib.h
to ensure that keyword is defined.`
2021-01-08 22:24:42 -05:00
Matthias Clasen 8243b5493b a11y: Avoid __ prefixes for variable names
Seems that msvc does not like that.
2021-01-08 22:24:42 -05:00
Matthias Clasen d5ef906cff Merge branch 'nacho/seatdefault' into 'master'
Clean ups in seat default

See merge request GNOME/gtk!3057
2021-01-09 01:04:22 +00:00
Ignacio Casal Quinteiro a720d8bc79 seatdefault: use g_clear_pointer to unref the tools 2021-01-08 13:11:56 +01:00
Ignacio Casal Quinteiro 57691eacc5 seatdefault: rename dispose method 2021-01-08 13:10:56 +01:00
Matthias Clasen 526e24f5b1 Merge branch 'wip/nacho/associated-device' into 'master'
gdkdevice: use g_set_object to set the associated device

See merge request GNOME/gtk!3049
2021-01-07 21:08:46 +00:00
Matthias Clasen 2a79152762 Merge branch 'mcatanzaro/company-unparent-warning' into 'master'
Add critical if widget has a parent during dispose

See merge request GNOME/gtk!3053
2021-01-07 18:37:28 +00:00
Matthias Clasen f03acaf7ab Merge branch 'mcatanzaro/unparent' into 'master'
Remove incorrect unparenting guidance from migration guide

See merge request GNOME/gtk!3050
2021-01-07 18:35:37 +00:00
Matthias Clasen 4e7ce9edcf Merge branch 'mcatanzaro/gtkbuilder-docs' into 'master'
Improve GtkBuilder documentation

See merge request GNOME/gtk!3055
2021-01-07 18:00:19 +00:00
Matthias Clasen ff72619333 Merge branch 'mcatanzaro/event-controller-porting-guide' into 'master'
Expand event controller API changes section of GTK 4 porting guide

See merge request GNOME/gtk!3054
2021-01-07 17:55:38 +00:00
Michael Catanzaro 59692599ea Remove incorrect unparenting guidance from migration guide
This rule is almost always wrong, and we're having some trouble agreeing
on replacement text. Let's remove the whole paragraph for now, to avoid
confusion.
2021-01-07 11:39:53 -06:00
Benjamin Otte 4761641098 Add critical if widget has a parent during dispose
This is a refcounting bug. Be very verbose about it instead of trying to
call a function that releases a reference to the widget without
references.
2021-01-07 11:39:32 -06:00
Michael Catanzaro afaa275dc8 gtkbuilder: fix recommendations that no longer make sense in GTK 4
In GTK 3, it was pretty much always better to use
gtk_builder_new_from_whatever() rather than
gtk_builder_add_from_whatever(). But in GTK 4, this is no longer
generally true. Let's add some context on when you want to use one or
the other.
2021-01-07 11:34:42 -06:00
Michael Catanzaro c736deb83b Add section on GtkBuilder API changes to GTK 4 migration guide
Thanks to Benjamin for helping with the language.
2021-01-07 11:34:42 -06:00
Emmanuele Bassi e930a20522 Merge branch 'ebassi/ci-only' into 'master'
ci: Specify `only` for other jobs

See merge request GNOME/gtk!3052
2021-01-07 17:17:44 +00:00
Michael Catanzaro 137f32f9ef Expand event controller API changes section of GTK 4 porting guide
There is more to say about changes to GtkEventController.
2021-01-07 10:53:09 -06:00
Emmanuele Bassi 195b98f19a ci: Only run macOS job on upstream branches
Don't run CI on macOS for forks.
2021-01-07 16:14:04 +00:00
Emmanuele Bassi 87e0a28482 ci: Specify only for other jobs
Otherwise MRs will only run macOS jobs.
2021-01-07 16:13:59 +00:00
Ignacio Casal Quinteiro 3ca3d7efef gdkdevice: use g_set_object to set the associated device 2021-01-07 16:13:39 +01:00
Matthias Clasen d8d8322912 Merge branch 'wip/jimmac/flat-buttons' into 'master'
Adwaita: fine tune flat button styling

Closes #3481

See merge request GNOME/gtk!3046
2021-01-07 13:42:42 +00:00
Matthias Clasen 1ea1a70fd2 Merge branch 'wip/jimmac/hc-switch-border' into 'master'
HC: switch border color

Closes #3460

See merge request GNOME/gtk!3048
2021-01-07 13:41:40 +00:00
Matthias Clasen 1d5bc2838b Merge branch 'wip/nacho/tool-api' into 'master'
seat: improve api to take into account the tool type

See merge request GNOME/gtk!3047
2021-01-07 13:25:11 +00:00
Ignacio Casal Quinteiro 45ec3fc389 seat: improve api to take into account the tool type
Otherwise if we have several tools with the same serial
and hardware id we might match the wrong tool.
2021-01-07 12:50:48 +01:00
Jakub Steiner 3a5eee7dbe HC: switch border color
- lighten inverted HC borders while darkening the regular/light variant

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3460
2021-01-07 12:44:53 +01:00
Jakub Steiner 0cda6f42b8 Adwaita: fine tune flat button styling
- enough contrast for hover and active, while noticably different in
  normal nad headerbar context (and both light and dark variants).

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3481
2021-01-07 12:12:55 +01:00
Matthias Clasen 0d99ef7cee Merge branch 'X11-surface' into 'master'
x11: fix crash on idle compute size without layout

See merge request GNOME/gtk!3031
2021-01-06 22:13:02 +00:00
Matthias Clasen 7583810c90 Merge branch 'wip/exalm/headerbar' into 'master'
headerbar: Prepend start window controls instead of appending

See merge request GNOME/gtk!3044
2021-01-06 22:10:25 +00:00
Jordi Mas 1341bc0b19 Update Catalan translation 2021-01-06 22:42:44 +01:00
Alexander Mikhaylenko fd073deea9 headerbar: Prepend start window controls instead of appending
Make sure they are always in the correct position.
2021-01-06 22:04:55 +05:00
Matthias Clasen 5652ab0a61 Merge branch 'macos-ci' into 'master'
Macos ci

See merge request GNOME/gtk!3032
2021-01-06 14:52:11 +00:00
Matthias Clasen 2ff23b08be Merge branch 'wip/jimmac/headerbar-specialcasing' into 'master'
Adwaita: specialcase switches and scales for headerbars

Closes #3504

See merge request GNOME/gtk!3043
2021-01-06 14:40:36 +00:00
Matthias Clasen 0336af06f1 ci: Limit macos runs
We are building the full stack here, which is pretty expensive,
so only do it for merge requests and master.
2021-01-06 09:36:54 -05:00
Matthias Clasen 2af9f1ad62 Merge branch 'wip/jimmac/hc-dim-label' into 'master'
HC: special case .dim-label

Closes #3507

See merge request GNOME/gtk!3042
2021-01-06 13:04:24 +00:00
Jakub Steiner e657da6658 Adwaita: specialcase switches and scales for headerbars
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3504
2021-01-06 13:02:21 +01:00
Jakub Steiner fd00aa98ea HC: special case .dim-label
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3507
2021-01-06 12:46:35 +01:00
Timm Bäder de8a8d7bde Merge branch 'dlech-master-patch-65287' into 'master'
doc: fix annotation for GtkCssLocation

See merge request GNOME/gtk!3041
2021-01-06 08:55:57 +00:00
David Lechner eb6fbf907f doc: fix annotation for GtkCssLocation
GtkCssLocation is a type so it should be prefixed with # rather than @.
2021-01-06 04:32:09 +00:00
Christian Hergert 4035f86b6d macos: use deprecated NSOnState for older systems 2021-01-05 16:37:30 -08:00
Christian Hergert 855b44f2ed macos: keep array of pasteboard types
To support Sierra, we need to have access to pasteboard types as a
NSString. Constants are provided in later versions of macOS, but we
can emulate that with an array which is initialized on first access.
2021-01-05 16:21:05 -08:00
Christian Hergert f2e0097cac gtk: fix brace initialization for bloom filter
This was breaking CI for macOS and it is a simple enough change to ensure
that just works for the internal buckets.
2021-01-05 16:21:05 -08:00
Christian Hergert 7c9bc7a204 macos: supply NSPasteboardType when necessary
On older macOS systems, we might need to provide our own typedef
for the NSPasteboardType. It is just a NSString pointer anyway.
2021-01-05 13:54:07 -08:00
Christian Hergert f4f104c9f9 macos: fix typedef on older macOS
On older systems, we don't have a typedef for gravity. They are a NSString
pointer and we can provide that manually just fine.
2021-01-05 13:53:22 -08:00
Christian Hergert 28a6f0df05 macos: handle point conversion on older macOS
On older systems, the availability of some methods seem to be incorrect
based on Apple documentation. This works around the issue by using
the rect conversion on older systems.
2021-01-05 13:52:11 -08:00
Matthias Clasen 0eab4deab0 Merge branch 'media-caps' into 'master'
media: Be more specific in our caps

See merge request GNOME/gtk!3037
2021-01-05 21:34:27 +00:00
Matthias Clasen 6e8e467cc9 Merge branch 'simplify-toolbar' into 'master'
3to4: Remove GtkToolbar::toolbar_style

See merge request GNOME/gtk!3040
2021-01-05 19:35:46 +00:00
Matthias Clasen ca9801f5fb 3to4: Remove GtkToolbar::toolbar_style
The property was removed (with the rest of the widget),
so keeping it around in the ui file makes no sense.

Testcase included.
2021-01-05 13:58:58 -05:00
Matthias Clasen 6b6fc1e5d8 Merge branch 'ebassi/migrating-clipboard' into 'master'
Ebassi/migrating clipboard

See merge request GNOME/gtk!3039
2021-01-05 18:41:27 +00:00
Emmanuele Bassi e3641d0568 Merge branch 'dlech-master-patch-06007' into 'master'
docs: fix parameter reference in gtk_bitset_contains()

See merge request GNOME/gtk!3035
2021-01-05 18:10:59 +00:00
David Lechner a5b88a53c2 docs: fix parameter reference in gtk_bitset_contains()
This fixes an error in the doc comments where the first parameter was
referred to as @bitset instead of @self.
2021-01-05 11:39:43 -06:00
Emmanuele Bassi e4d0114e0d docs: Add migration section for GtkClipboard
A simple copy/paste text example, plus directing people towards the
appropriate GType to replace the old convenience API.
2021-01-05 16:51:14 +00:00
Matthias Clasen f974c5343e Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!3038
2021-01-05 16:49:53 +00:00
Daniel Șerbănescu bc39da0619 Updated the Romanian Translation 2021-01-05 17:38:02 +01:00
Emmanuele Bassi 1995b7f34b docs: Preformat some symbols 2021-01-05 16:19:21 +00:00
Matthias Clasen 36eb7c40d0 gtk-demo: Small a11y fix
Label the entry in the assistant demo.
2021-01-05 11:16:10 -05:00
Matthias Clasen 56af472cfc a11y: Only spew help once
Make GTK_A11Y=help only spew once, and avoid a warning
when we do.
2021-01-05 11:15:33 -05:00
Matthias Clasen d1fcfa58b9 popup: Mention the popover arrow in the docs
Suggested by Jonas.
2021-01-05 10:59:59 -05:00
Matthias Clasen cf23324749 Merge branch 'no-gl-context' into 'master'
Disable GL support in gstreamer media backend on Windows

See merge request GNOME/gtk!3034
2021-01-05 15:22:09 +00:00
Matthias Clasen b79c26b39e Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

See merge request GNOME/gtk!3029
2021-01-05 15:20:25 +00:00
Matthias Clasen 532b8c71a8 media: Be more specific in our caps
We can only handle 2D textures, so tell gstreamer
about that.
2021-01-05 09:28:04 -05:00
Matthias Clasen 7c5b8911d8 Merge branch 'matthiasc/for-master' into 'master'
some docs tweaks

See merge request GNOME/gtk!3036
2021-01-05 14:26:38 +00:00
Matthias Clasen e141d61593 docs: Cosmetics 2021-01-05 08:37:23 -05:00
Matthias Clasen 9595d440cf docs: Flesh out Popup layout docs
We have nice illustrations for this, lets use them.
2021-01-05 08:37:23 -05:00
Yuri Chornoivan 1063924bd0 Update Ukrainian translation 2021-01-05 08:08:44 +00:00
Timm Bäder 42fedfc870 csstokenizer: Keep a GString for name parsing around
We only every parse one of those at a time, so keep a GString around for
it. This way we don't have to create a new GString every time we parse
an identifier. Doesn't spare us the strdup though.
2021-01-05 08:53:13 +01:00
Timm Bäder 24836c0351 csstokenizer: Add separate init functions for token types
Using a variadic function is just awkward there. Use different init
functions and use them as appropriate; we already know which one to call
everywhere.
2021-01-05 08:53:13 +01:00
Timm Bäder 21b6c8b5d8 builder: Remove unused typedef 2021-01-05 08:53:13 +01:00
Timm Bäder 41fb6f6a8e builder: Remove unused function prototype 2021-01-05 08:53:13 +01:00
Timm Bäder 071ea6b559 builderparser: Use GPtrArray for stack 2021-01-05 08:53:11 +01:00
Chun-wei Fan 397a71ca8b gstreamer media backend: Disable OpenGL on Windows
...for at least WGL, since we are not allowed to use wglMakeCurrent(),
which is eventually called by gdk_gl_context_make_current() to share WGL
contexts across different threads, which will cause a crash.

This means, we cannot enable WGL in the gstreamer media backend on
Windows.
2021-01-05 14:34:06 +08:00
Matthias Clasen 40c10f83e2 Merge branch 'matthiasc/gl-media-stream' into 'master'
Use GL in the gstreamer media backend

See merge request GNOME/gtk!3027
2021-01-05 00:54:37 +00:00
Matthias Clasen fb31581bb4 gtk-demo: Use GtkVideo in the fishbowl
The demo is called 'Video', so we should actually
use a GtkVideo widget. Doing things this way has
the advantage that we get GL support, which wasn't
working with GtkPicture.
2021-01-04 18:26:29 -05:00
Matthias Clasen 536a67ec96 media: Only force GL if we're using a GL renderer
When we are not using a GL renderer, getting GL textures
is no advantage to us, so don't make gstreamer send its
frames as GL memory in this case.
2021-01-04 15:01:19 -05:00
Matthias Clasen 53fe751371 media: Convince gstreamer to deliver GL memory
Use a glsinkbin to make gstreamer deliver GL memory.
2021-01-04 15:00:36 -05:00
Benjamin Otte 7901ab857b media: Add support for OpenGL to GtkGstMediaFile 2021-01-04 15:00:36 -05:00
Matthias Clasen 8f585f7a53 video: Realize the media stream before setting a file
This makes it so that we obtain a GL context before
creating the GstSink, so we at least advertise our
ability to handle GL buffer.

Gstreamer still won't send us any.
2021-01-04 15:00:36 -05:00
Matthias Clasen 874b19b27e Merge branch 'wip/jimmac/popover-separators' into 'master'
Adwaita: increase cotrast of popover separators

Closes #3535

See merge request GNOME/gtk!3033
2021-01-04 18:14:00 +00:00
Jakub Steiner fe7b11b4e9 Adwaita: increase contrast of popover separators
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3535
2021-01-04 17:55:44 +01:00
Yetizone 601dfeeff9 checkbutton: Add activate signal to work with gtk_widget_activate()
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3525
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3550
2021-01-04 17:25:53 +02:00
Matthias Clasen cf623ce774 Merge branch 'window-geometry-info' into 'master'
gtk/window: remove GtkWindowGeometryInfo from public header file

See merge request GNOME/gtk!3028
2021-01-04 13:55:08 +00:00
Aurimas Černius 36b49950e8 Updated Lithuanian translation 2021-01-04 14:10:23 +02:00
Matthias Clasen 77feb51b9c Pass coretext=enabled to harfbuzz
When we use harfbuzz as a subproject on OS X,
we (or rather, pango) need coretext support.
2021-01-03 21:34:04 -05:00
Matthias Clasen 710ef00dfe Fix the cairo build on OS X
Change the subproject to point to a branch that includes
an OS X build fix. Once
https://gitlab.freedesktop.org/cairo/cairo/-/issues/441
is fixed, we should switch back to master.
2021-01-03 21:34:04 -05:00
Matthias Clasen 0c8124828f ci: Disable pixman tests on MacOS
The pixman tests fail to build, and I don't have
the stamina to fix all sub-sub-projects, so just
disable the tests.
2021-01-03 21:34:04 -05:00
Matthias Clasen 0605c3c167 ci: Fix the harfbuzz build on MacOS
We need to force c++11 at the toplevel here, since
meson can't deal with per-project compiler choice.
2021-01-03 21:34:04 -05:00
Matthias Clasen 93d795e7c0 printing: Remove cairo header checks
cc.has_header doesn't work with subprojects, and all this
check does is to make the build fail, so we can just...
let the build fail instead.
2021-01-03 21:34:04 -05:00
Matthias Clasen d55f938f7c printing: cairo-pdf is needed
The print backends need cairos pdf support, which is
contingent on zlib, so enable that when using cairo
as a subproject, as we do in ci for MacOS.
2021-01-03 21:34:04 -05:00
Matthias Clasen 45bb4dc80c ci: Add a macos build
Most of this is cribbed from glib.

We don't use COMMON_MESON_FLAGS here, since disabling
-Werror one subproject at a time is too painful for
all the promoted sub-sub-projects. This needs a better
solution in meson.

Since this is a full rebuild of the entire stack, limit
this to master and merge requests.
2021-01-03 21:34:04 -05:00
Rafostar 53af35d256 x11: fix crash on idle compute size without layout
On x11 toplevel layout is not created before toplevel
is presented, but GTK tries to update it on idle
which leads to a crash due to accessing property
of undefined object. Treat soon to be created layout
as a layout with default values upon creation (resizable).
2021-01-03 18:02:31 +01:00
Philipp Kiemle 51a6b29e01 Update German translation 2021-01-03 13:41:25 +00:00
Philipp Kiemle e3835476ba Update German translation 2021-01-03 13:40:13 +00:00
Timm Bäder 256b094b13 messagedialog: Modernize source file
Move vfunc implementations above class_init, remove unneeded prototypes,
properly indent everything and remove trailing whitespace
2021-01-03 11:01:29 +01:00
Timm Bäder 699adb0b10 widget: Refactor gtk_widget_class_set_template()
Don't call gbytes_get_data/get_size so often and exit early if the given
bytes is already precompiled.
2021-01-03 11:01:29 +01:00
Timm Bäder c91b5eaa41 widget: Inline setup_template_child() into only caller
This is a pretty short and self-contained function.
2021-01-03 11:01:29 +01:00
Timm Bäder 7e1f20bf4c icontheme: Make a parameter const 2021-01-03 11:01:29 +01:00
Timm Bäder f9fe640905 settings: Overallocate property_values
Instead of walking the pspecs twice and checking for the owner_type,
just allocate n_pspecs entries. They are the same value right now
anyway, but even if they aren't it doesn't hurt to have a few extra ones
allocated.
2021-01-03 11:01:29 +01:00
Timm Bäder 34ea99006f settings: Load keyfiles ourselves
This does not change anything in the case where the .init file does not
exist. We still hit the disk once. Otherwise, we now only hit it once
instead of twice and avoid a potential race-condition.
2021-01-03 11:01:29 +01:00
Timm Bäder 06cce81a97 widget: Use gtk_widget_get_native() in get_surface_allocation() 2021-01-03 11:01:29 +01:00
Timm Bäder 4a1a7940d5 gtksettings: Remove unused defines 2021-01-03 11:01:29 +01:00
Timm Bäder 1108d00014 render: Inline function into only caller 2021-01-03 11:01:29 +01:00
Timm Bäder 034672e84e frame: Remove unnecessary function
Just call the vfunc directly in the only place we used to call the old
wrapper
2021-01-03 11:01:29 +01:00
Timm Bäder 00c885c93c gesture: Replace tabs 2021-01-03 11:01:29 +01:00
Timm Bäder 114f0bd8d6 box: Replace tabs with spaces 2021-01-03 11:01:29 +01:00
Timm Bäder 24c67efdfd scrolledwindow: Use g_clear_handle_id 2021-01-03 11:01:29 +01:00
Timm Bäder 6a3748146d viewport: Small cleanup
No need to check for visibility before calling gtk_widget_measure().
2021-01-03 11:01:29 +01:00
Timm Bäder 92ec754737 widget: Move quark_builder_set_id declaration to other GQuarks 2021-01-03 11:01:29 +01:00
Timm Bäder d11fbbc478 widget: Re-arrange some more functions 2021-01-03 11:01:29 +01:00
Timm Bäder f11f0da11c wiget: Fix whitespace issues
Switch from tabs to spaces everywhere consistently and remove all
trailing whitespace.
2021-01-03 11:01:29 +01:00
Timm Bäder ebdf2989f8 widget: Move a few vfunc implementations above class_init
And save us the prototypes at the top of the file this way.
2021-01-03 11:01:29 +01:00
Timm Bäder bc35c5d494 nevertrigger: Remove unused instance members 2021-01-03 11:01:29 +01:00
Timm Bäder 70a3e5e8ce shortcutmanager: Use g_list_store_find()
We require glib 2.66 these days, so we can unconditionally use
g_list_store_find().
2021-01-03 11:01:29 +01:00
Timm Bäder 74ff61a937 gesturelongpress: Remove a useless cast
We already get a GtkGestureLongPress here.
2021-01-03 11:01:29 +01:00
Timm Bäder 280d7e57bd gesturelongpress: Keep the pspec around
So we can use it to notify(), like we do everywhere else.
2021-01-03 11:01:29 +01:00
Timm Bäder 03f5a368ec label: Remove unused private functions 2021-01-03 11:01:29 +01:00
Timm Bäder 0b15aba82a label: Remove mnemonics_visible_apply_recursively from private header
This is only used in gtklabel.c
2021-01-03 11:01:28 +01:00
Timm Bäder d8fa9de93a label: Modernize source file
Try to sort toplevel functions to minimize unnecessary function
prototypes at the beginning of the file, get rid of all tabs and
trailing whitespace.
2021-01-03 11:01:28 +01:00
Timm Bäder afabbc4957 gtk4-demo: Remove unused size group 2021-01-03 11:01:28 +01:00
Timm Bäder d978ba31d6 glcontext-wayland: Whitespace 2021-01-03 11:01:28 +01:00
Timm Bäder 71efa96ef2 gesturestylus: Only add histroy element if translation succeeded
Instead of always doing it and then undoing it if the translation does
not succeed.
2021-01-03 11:01:28 +01:00
Timm Bäder e336fe2bf8 gesturestylus: Retrieve event and controller widget only once
Make it clear that these are not gonna chance while iterating the loop.
2021-01-03 11:01:28 +01:00
Timm Bäder d7f15c15e9 glcontext-wayland: Avoid heap-alloacting small arrays...
every frame.
2021-01-03 11:01:28 +01:00
Timm Bäder fff570538c glcontext-wayland: Only allocate configs we use
We only use the first one, so don't allocate space for more than that.
2021-01-03 11:01:28 +01:00
Matthias Clasen 38166a67c7 NEWS: Updates 2021-01-02 20:17:19 -05:00
Matthias Clasen 01b94db73d Merge branch 'matthiasc/for-master' into 'master'
video: Tweak the docs

See merge request GNOME/gtk!3026
2021-01-02 19:04:26 +00:00
Matthias Clasen c804645382 video: Tweak the docs
Point out the limitations and use cases of GtkVideo
and mention that GtkPicture can display video just fine.
2021-01-02 12:21:03 -05:00
Matthias Clasen 384081ce0a Merge branch 'matthiasc/for-master' into 'master'
video: Pause on unset too

See merge request GNOME/gtk!3025
2021-01-02 15:49:46 +00:00
Florentina Mușat afccb86f7e Update Romanian translation 2021-01-02 11:21:43 +00:00
Matthias Clasen 0ba5631100 video: Pause on unset too
When new media stream is set on the GtkVideo
widget and we're autoplaying, pause the old one.

Otherwise, the music keeps playing unexpectedly.
2021-01-02 01:33:48 -05:00
Matthias Clasen c72589f0ee Merge branch 'wip/chergert/fix-macos-compute-size' into 'master'
macos: fix compute_size and request_layout

Closes #3532

See merge request GNOME/gtk!3023
2021-01-01 23:33:01 +00:00
Matthias Clasen f2e5775380 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3506 and #3530

See merge request GNOME/gtk!3024
2021-01-01 22:48:11 +00:00
Benjamin Otte a7164208d3 Merge branch 'video-stop' into 'master'
video: Stop playing when appropriate

See merge request GNOME/gtk!3022
2021-01-01 21:54:22 +00:00
Matthias Clasen 20f3d1608d video: Be consistent about play/pause
Always check that the stream is prepared, and the
widget is mapped, before calling gtk_media_stream_play().
2021-01-01 16:25:54 -05:00
Christian Hergert 9320148d71 macos: implement compute_size and request_layout
These functions were not implemented when the sizing changes
landed before GTK 4 was released. This fixes an issue with non-
resizeable windows not reacting to layout changes.

Fixes #3532
2021-01-01 13:17:47 -08:00
Christian Hergert ad617a0e06 macos: avoid setHasShadow unless shadow changes 2021-01-01 13:17:47 -08:00
Christian Hergert 62af8365f6 macos: fix toplevel present function prototype
No need to return anything here.
2021-01-01 13:17:47 -08:00
Matthias Clasen 29afe5a688 video: Stop playing when appropriate
When the widget gets unrealized or hidden, pause
the mediastream. Otherwise, audio might keep playing
unexpectedly.
2021-01-01 15:17:59 -05:00
Matthias Clasen 2d3885a44a center layout: Fix handling of expanding center child
We were not taking spacing into account when adjusting
the size of an expanding center child, causing it to slip
under the end child at times.

Fixes: #3506
2021-01-01 11:02:57 -05:00
Matthias Clasen 75a297632e Merge branch 'wip/chergert/fix-macos-window-check' into 'master'
macos: ensure GdkMacosWindow in surface discovery

Closes #3533

See merge request GNOME/gtk!3021
2021-01-01 15:39:08 +00:00
Matthias Clasen 572649740e docs: Flesh out the gtk4-builder-tool man page
Add some details about the --3to4 conversion, and
set expectations.
2021-01-01 10:14:01 -05:00
Yuri Chornoivan b5938faa06 Update Ukrainian translation 2021-01-01 14:50:35 +00:00
Matthias Clasen a4baac7193 docs: Complete a sentence
Fixes: #3530
2021-01-01 09:40:40 -05:00
Matthias Clasen bdde41e290 Merge branch 'encode-symbolic-debug' into 'master'
gtk4-encode-symbolic: Add debug output

See merge request GNOME/gtk!3017
2021-01-01 14:23:08 +00:00
Christian Hergert d888402bf9 macos: ensure GdkMacosWindow in surface discovery
We want to ignore windows that are not related to those controlled
by the GDK backend.

Fixes #3533
2020-12-31 10:55:50 -08:00
Christian Hergert 378bd9fab2 Merge branch 'macos-mojave' into 'master'
macos: do not crash in mojave

See merge request GNOME/gtk!3020
2020-12-31 18:13:46 +00:00
Ignacio Casal Quinteiro 4ad5e77907 macos: do not crash in mojave
The localizedName property is not available in Mojave
so just ifdef in that case the code out.
2020-12-31 11:35:04 +01:00
David Lechner 4fb70c5e4d gtk/window: remove GtkWindowGeometryInfo from public header file
GtkWindowGeometryInfo is only used by static methods in gtkwindow.c
so it doesn't need to be in the public header file.
2020-12-30 01:32:27 -06:00
Matthias Clasen d5963ad109 Merge branch 'revert-224c2674' into 'master'
Revert "Merge branch 'gtk_egl_wayland' into 'master'"

See merge request GNOME/gtk!3018
2020-12-30 03:34:51 +00:00
Matthias Clasen b5fe434fea Revert "Merge branch 'gtk_egl_wayland' into 'master'"
This reverts merge request !3011
2020-12-30 03:32:18 +00:00
Matthias Clasen 224c2674ab Merge branch 'gtk_egl_wayland' into 'master'
Expose gdk_wayland_surface_get_wl_egl_window()

See merge request GNOME/gtk!3011
2020-12-30 03:32:05 +00:00
Matthias Clasen 878b34fae3 gtk4-encode-symbolic: Add debug output
Add a --debug option that makes this tool produce
some debug output that can be helpful in tracking
down why symbolic svgs are broken.
2020-12-29 21:30:52 -05:00
Matthias Clasen 5fe433418d Merge branch 'mcatanzaro/#3509' into 'master'
message dialog: use title style only if there is secondary text

Closes #3509

See merge request GNOME/gtk!3015
2020-12-29 17:47:01 +00:00
Matthias Clasen 02ba9bc1da Merge branch 'fix-menu-alignment' into 'master'
Fix menu item alignment with submenus

See merge request GNOME/gtk!3016
2020-12-29 17:41:49 +00:00
Michael Catanzaro 2336120010 message dialog: use title style only if there is secondary text
If there is no secondary text, then the primary text is just a message,
not a title, and should not use title style.

This partially reverts 1e3ec7c1f9. The
message dialog nown looks like it used to in GTK 3. However, it's still
styled only using a style class rather than using pango markup, as in
GTK 3.

Fixes #3509
2020-12-29 11:15:14 -06:00
Matthias Clasen 0d54d73a51 Fix menu item alignment with submenus
We were not aligning model button labels with nesting
submenus with indicators in their containing menu.

This was visible in the application demo of gtk4-demo.
2020-12-29 12:10:35 -05:00
Timm Bäder 6c09832b9b Merge branch 'xndcn/fix-shader' into 'master'
gl: Fix implicit leaking of shader object

See merge request GNOME/gtk!3013
2020-12-29 16:58:55 +00:00
Matthias Clasen 1758f88492 Merge branch 'ebassi/issue-3522' into 'master'
Fix the Vulkan header check for VK_RESULT_RANGE_SIZE

Closes #3522

See merge request GNOME/gtk!3009
2020-12-29 16:36:09 +00:00
xndcn 34ffdc6e3f gl: Fix implicit leaking of shader object
According to OpenGL spec, a shader object will only be flagged
for deletion unless it has been detached; when a program object
is deleted, those shader objects attached to it will be detached
but not deleted unless they have already been flagged for deletion.

So we shall detach a shader object before it is deleted, and delete
it before the program object is deleted best.
2020-12-29 23:50:45 +08:00
Timm Bäder 108933b655 Merge branch 'wip/chergert/volatile-fixes' into 'master'
types: fix various use of volatile in type registration

See merge request GNOME/gtk!2865
2020-12-29 07:49:12 +00:00
Vivek Kasireddy 3344bcaf92 gdk/wayland/surface: Expose gdk_wayland_surface_get_wl_egl_window()
Some GTK based applications such as Qemu UI create and manage
EGLSurfaces associated with the relevant GdkSurfaces. In order to create
an EGLSurface, there needs to be a way to pass the native window
object to eglCreateWindowSurface(). While running in an X environment,
the native window object can be obtained by calling
gdk_x11_surface_get_xid(). Likewise, the native window object can be
obtained by calling gdk_wayland_surface_get_wl_egl_window() while
running in a Wayland environment. Therefore, this API needs to be
exposed to apps.

Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
2020-12-28 18:20:04 -08:00
Emmanuele Bassi f22ec063a1 Fix the Vulkan header check for VK_RESULT_RANGE_SIZE
The VK_RESULT_RANGE_SIZE enumeration value was removed in 1.2.140, not
1.2.142.

Fixes: #3522
2020-12-28 18:41:18 +00:00
Benjamin Otte 0fcf01ddd5 Merge branch 'gtkmediafile-pixel-aspect-ratio' into 'master'
gtkmediafile: Consider pixel-aspect-ratio for rendering video with the correct aspect ratio

Closes #3516

See merge request GNOME/gtk!3007
2020-12-28 14:54:30 +00:00
Asier Sarasua Garmendia 1119a74ff0 Update Basque translation 2020-12-27 17:56:02 +00:00
Sebastian Dröge 18ea60e235 gtkmediafile: Consider pixel-aspect-ratio for rendering video with the correct aspect ratio
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3516
2020-12-27 19:33:55 +02:00
Matthias Clasen d752828977 Merge branch 'wip/jtojnar/trivial-fix-pc-vulcan' into 'master'
build: Fix vulkan reference in pc file

Closes #3517

See merge request GNOME/gtk!3006
2020-12-27 17:06:52 +00:00
Fran Dieguez 1034271d9a Update Galician translation 2020-12-27 16:56:56 +00:00
Fran Dieguez f013d3b5d6 Update Galician translation 2020-12-27 16:51:38 +00:00
Benjamin Otte 5f41d26abc Merge branch 'gtkgstsink-unmap-only-when-done' into 'master'
gtkmediafile: Only unmap the GstVideoFrame in the GBytes destroy notify

See merge request GNOME/gtk!3003
2020-12-27 06:17:36 +00:00
Jan Tojnar 7d5826ccf7 build: Fix vulkan reference in pc file
A mistake in string concatenation caused the vulcan dependency to be omitted.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3517
2020-12-27 06:42:29 +01:00
Jan Tojnar 2c9f2325e2 build: Use Meson’s module for building .pc files
Using the module will prevent trivial bugs caused by incorrect string concatenation.

This is just a literal translation. In the future we might rely on Meson auto-detecting fields from library declaration.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3517
2020-12-27 06:27:59 +01:00
Matthias Clasen daded2bc86 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!3004
2020-12-27 05:21:26 +00:00
Matthias Clasen bc7619abaf Merge branch 'gtkclip' into 'master'
gtk: remove GtkClipboard leftovers

See merge request GNOME/gtk!2991
2020-12-27 04:32:26 +00:00
Matthias Clasen 459d6e1349 Merge branch 'wip/carlosg/for-master' into 'master'
gtk/gesturestylus: Convert motion history from surface coordinates

Closes #3491

See merge request GNOME/gtk!2999
2020-12-27 04:30:38 +00:00
Sebastian Dröge 6e108d310a gtkmediafile: Only unmap the GstVideoFrame in the GBytes destroy notify
The memory pointed to by GstVideoFrame::plane_data becomes invalid after
unmapping causing the GBytes to point at some random memory if the
unmapping is not deferred until its destroy notify.

When the GStreamer buffer is backed by normal system memory this is not
a problem but if it is backed by e.g. an OpenGL texture, dmabuf or some
other hardware-specific memory this will otherwise cause interesting
problems.
2020-12-26 14:26:23 +02:00
Benjamin Otte 9c84fa127a Merge branch 'unused-static-inline' into 'master'
Remove unused static inline function

See merge request GNOME/gtk!3002
2020-12-25 18:05:11 +00:00
Emmanuel Gil Peyrot 84c6708366 Remove unused static inline function
This was causing a warning on AArch64 since __LITTLE_ENDIAN__ and
__BIG_ENDIAN__ weren’t set, but the functions were actually completely
unused.
2020-12-25 16:16:43 +01:00
Benjamin Otte f7e3016949 Merge branch 'gles-gears' into 'master'
Fix gtk4-demo’s gears demo on OpenGL ES

See merge request GNOME/gtk!3000
2020-12-25 01:36:34 +00:00
Emmanuel Gil Peyrot dd1110ca5c Fix some of gtk4-demo’s transitions example on OpenGL ES
Same issue as the previous commit, int+float is error, and pow() only
works on floats.
2020-12-25 01:36:21 +01:00
Emmanuel Gil Peyrot 28c4adac24 Fix gtk4-demo’s gears demo on OpenGL ES
Here is a command to reproduce this testcase:
GDK_DEBUG=gl-gles gtk4-demo --run gears

Without this patch, Mesa throws this compile error:
0:130(13): error: no matching function for call to `mod(error, float)'; candidates are:

This is caused by `u_rotation - 90` being of type error since
`u_rotation` is a float and it’s illegal to subtract it with an integer.
2020-12-25 01:21:08 +01:00
Carlos Garnacho cf20cfd31e gtk/gesturestylus: Convert motion history from surface coordinates
Motion history coordinates are based on GdkSurface coordinates. Transform
the coordinates from the GtkNative they are received on, accounting for the
possible transforms (e.g. due to window borders and shadows).

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3491
2020-12-24 19:59:51 +01:00
Matthias Clasen 7e579bb59a Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!2997
2020-12-24 07:13:22 +00:00
Benjamin Otte 96e1b85c2c gdkarray: Add a "stolen" boolean to splice()
If set to TRUE, does not call the free func for the removed items.

This can be used to move items between arrays without having to do the
refcounting dance.
2020-12-24 06:38:45 +01:00
Benjamin Otte 71e616d17e listview: Use the correct scroll policy
Use the horizontal policy for horizontal decisions, not the vertical
one.

This broke in 0011ce949c.
2020-12-24 06:38:45 +01:00
Benjamin Otte f85d939e5e docs: Put render nodes in their own sections 2020-12-24 06:38:45 +01:00
Benjamin Otte 8d014d6cb0 roundedbox: Remove unused API 2020-12-24 06:38:45 +01:00
Benjamin Otte f7f8990f7a picture: Fix copy/paste error in docs 2020-12-24 06:38:45 +01:00
Benjamin Otte d6f288427a video: When autoplaying, start playing once the video is prepared
This fixe video sources with longer loading times not automatically
playing.
2020-12-24 06:38:45 +01:00
Benjamin Otte 2a8f371643 gtk-demo: Don't put the search bar in the scroll area
1. That's a bad idea UI wise as you can't see the search after you
   scrolled.

2. That's a bad idea code-wise because Listviews need to be put into
   a ScrolledWindow or they won't scroll.
2020-12-24 06:38:45 +01:00
Benjamin Otte dee863dbb2 rendernode: Bail if matrix is invalid
Invalid matrices are okay in GSK (and GL), but not in Cairo.

Testcase included.
2020-12-24 06:38:45 +01:00
A S Alam 7d6877ec80 Update Punjabi translation 2020-12-23 19:48:28 +00:00
Danial Behzadi f426d23690 Update Persian translation 2020-12-23 15:53:07 +00:00
Matthias Clasen 6bd0dc3e78 colorbutton: Correct the css docs
Mention the wrapper colorbutton node.
2020-12-23 09:03:07 -05:00
Matthias Clasen 4f0c920a8e fontbutton: Correct the css docs
Mention the wrapper fontbutton node.
2020-12-23 08:59:58 -05:00
Matthias Clasen b0b793dd94 menubutton: Correct the css docs
We are using menubutton instead of button.popup now.
2020-12-23 08:56:18 -05:00
Matthias Clasen efbb649eee modelbutton: Center titles
The centering of titles was broken in b5b81dea7f.
Make it mostly work again by adding an empty end indicator.

Related: #3405
2020-12-23 00:51:51 -05:00
Matthias Clasen e128a77eed Merge branch 'matthiasc/for-master' into 'master'
window: Release application in destroy

See merge request GNOME/gtk!2994
2020-12-23 03:01:55 +00:00
Matthias Clasen 5cd2ee927a window: Release application in destroy
We used to do this; it was lost in some life-cycle
reshuffling.
2020-12-22 20:34:13 -05:00
Marc-André Lureau 90dfb5e138 gtk: remove GtkClipboard leftovers
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-12-22 16:39:54 +04:00
Matthias Clasen e854b90293 Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

See merge request GNOME/gtk!2990
2020-12-22 04:53:31 +00:00
Matthias Clasen 6d042d9e61 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2988
2020-12-22 02:29:03 +00:00
Matthias Clasen 4310f24a4e Fix warnings with Vulkan < 162
Tiring to watch the Vulkan people stumble through
ABI and API compat, but what can you do.
2020-12-21 20:00:16 -05:00
Matthias Clasen aebf8e3c29 Merge branch 'mcatanzaro/fix-gtk-builder-tool' into 'master'
Fix buffer overruns in 'gtk-builder-tool simplify'

See merge request GNOME/gtk!2987
2020-12-21 22:49:42 +00:00
Matthias Clasen fcd449f0d4 modelbutton: Remove an unused field
We're not using the centered field anymore.
2020-12-21 17:45:01 -05:00
Michael Catanzaro ab1b117d91 Fix buffer overruns in 'gtk-builder-tool simplify'
Oops, here we allocate only one byte for each pointer we want to store.
We need to multiply by the size of a pointer.
2020-12-21 15:39:34 -06:00
Emmanuele Bassi 1253296387 Merge branch 'fix-printbackends' into 'master'
Fix the value for the print-backends setting

Closes #3486

See merge request GNOME/gtk!2986
2020-12-21 20:04:26 +00:00
Matthias Clasen 466484176f Merge branch 'ebassi/docs-for-master' into 'master'
Ebassi/docs for master

See merge request GNOME/gtk!2983
2020-12-21 19:22:38 +00:00
Matthias Clasen 20289ad8e1 Fix the value for the print-backends setting
This was broken in the meson conversion, causing
us to default to "" instead of the built print
backends.

Fixes: #3486
2020-12-21 14:10:03 -05:00
Matthias Clasen 0abb8c6862 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2984
2020-12-21 19:00:10 +00:00
Matthias Clasen 147386189f inspector: Show glyphs as in node files
Reuse the glyph serialization code from gsk to
show glyphs in the same way here.
2020-12-21 13:11:46 -05:00
Matthias Clasen 9cec9e4ce2 gsk: Export the glyph serialization privately
We want to use the same serialization in the inspector,
so export this function.
2020-12-21 13:11:08 -05:00
Matthias Clasen 26119af7a6 gsk: Improve glyph serialization
The special case for ASCII glyphs is unfortunately not
working very well, because of an oversight in pango:
When I added subpixel positioning, I made pango_shape()
default to not rounding, and make PangoLayout call
pango_shape_with_flags() and pass the rounding information
down. The upshot is that we need to use the _with_flags
variant here and tell it to round position, so it matches
what the text node contains.
2020-12-21 13:08:34 -05:00
Timm Bäder 478d1f71e3 Merge branch 'fix-node-glyphs' into 'master'
gsk: Fix serialization of glyphs

Closes #3496

See merge request GNOME/gtk!2982
2020-12-21 17:16:38 +00:00
Emmanuele Bassi b1d952b8a2 docs: Add examples for GtkDropTarget
Like we did for GtkDragSource.
2020-12-21 17:11:42 +00:00
Emmanuele Bassi b9bcdbbfdc docs: Add examples of GtkDragSource use
The description is a bit terse; we should help out application
developers some more.
2020-12-21 17:03:59 +00:00
Emmanuele Bassi 6c31ed53f4 docs: Fix typo and whitespace 2020-12-21 17:03:42 +00:00
Matthias Clasen aa95ae774f gsk: Fix serialization of glyphs
We were forgetting to put a space between two numbers
in some cases, confusing the parser.

Test included.

Fixes: #3496
2020-12-21 10:49:56 -05:00
Emmanuele Bassi 65adfd9243 Merge branch 'box_docs' into 'master'
box: improve documentation

Closes #3499

See merge request GNOME/gtk!2981
2020-12-21 15:40:07 +00:00
Yetizone c4a8c0893b box: improve documentation
Rephrase a function parameter description and remove "." from all function parameters descriptions

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3499
2020-12-21 17:26:23 +02:00
Timm Bäder e90f5e8a20 gskpango: Don't copy fg color
No need to do that here, we copy it in to the individual render nodes
anyway.
2020-12-21 15:23:25 +01:00
Timm Bäder 526c76181e gl renderer: Check for pointer equality in rounded_rect_equal 2020-12-21 15:22:08 +01:00
Timm Bäder cf352374ae gskpango: Correct a comment
Not all other draw calls will use cairo.
2020-12-21 13:23:28 +01:00
Timm Bäder 98b99201b0 gskpango: Remove bounds rect
We only need this to render shapes and trapezoids, i.e. only when
falling back to cairo. Remove code to measure the layout and convert the
ink_rect to a graphene_rect_t from gtk_snapshot_append_layout() and do
it when drawing shapes and trapezoids instead.
2020-12-21 12:56:38 +01:00
Timm Bäder bce4d669ee gskpango: Fix a potential cairo_t leak
The previous early return did not cairo_destroy() it.
2020-12-21 12:49:06 +01:00
Timm Bäder e7a326e230 label: Refactor get_layout_location()
Rename a few local variables to be clearer about whether they belong to
the widget or to the layout.

Remove a workaround for an old bug that is no longer valid. We don't
underallocate the layout anymore. Aways center vertically, with respect
to the yalign.
2020-12-21 12:44:01 +01:00
Timm Bäder 9eaeaa8452 label: Refactor snapshot()
Use two early-out style if statements to reduce indentation in this
entire function.
2020-12-21 12:32:32 +01:00
Timm Bäder 2031c5bf90 textlayout: Remove dead offset_y code 2020-12-21 10:26:03 +01:00
Timm Bäder 9fefa7b44c rendernode: Different uniformity in border nodes
Means they are different and a diff is impossible.
2020-12-21 10:26:03 +01:00
Timm Bäder a2a70c3b65 rendernode: Sort diff() requirements by complexity 2020-12-21 10:26:03 +01:00
Timm Bäder 0b4ed8d791 renderborder: Avoid 0 width outline color nodes 2020-12-21 10:26:03 +01:00
Timm Bäder c34f98931e layoutoverlay: Avoid adding transparent color nodes
We have a region for the border here, but the color is defined as
transparent black because we don't want to render anything for it.

This way, the generated .node file for the listbox demo in gtk4-demo
with enabled layout borders is 3.5MB instead of 3.8MB.
2020-12-21 10:26:03 +01:00
Timm Bäder 2feac2772f layoutoverlay: Avoid adding 0 sized color nodes
This way, the output node file of the listbox demo in gtk4-demo with
enabled layout borders is only 3.8MB instead of 12MB.
2020-12-21 10:26:03 +01:00
Timm Bäder fdda4e4e99 GskTransform: Add nullable annotations to _equals()
Both can be NULL here.
2020-12-21 10:26:03 +01:00
Timm Bäder e1cf0cff26 gl renderer: Proper state tracking for color matrix ops 2020-12-21 10:26:03 +01:00
Timm Bäder 634fa772c9 gl renderer: Add missing debug output for repeat ops 2020-12-21 10:26:03 +01:00
Timm Bäder 4b3bbe0ecd gl renderer: Create shader-global uniform ops on draw()
This way we can render the first frame of tests/testoutsetshadowdrawing
in 153 ops instead of 183.

And the first frame of gtk4-demo in 260 instead of 300.
2020-12-21 10:26:03 +01:00
Timm Bäder cde43541d0 gl renderer: Unify new clip/viewport rects in blur_texture() 2020-12-21 10:26:03 +01:00
Timm Bäder 186287ecfb GskTransform: Fix identity transform class name 2020-12-21 10:26:02 +01:00
Timm Bäder bd5d1615ac GskTransform: Avoid a ref+unref pair
If gsk_transform_is_identity() returned FALSE for the next transform,
the previous code did a ref + unref pair, even though it was unneeded.
2020-12-21 10:26:02 +01:00
Timm Bäder 21299cc7e4 icontheme: Make some constant values const 2020-12-21 10:26:02 +01:00
Timm Bäder e747ea7dfd pixbufutils: Only convert icon size to string once 2020-12-21 10:26:02 +01:00
Timm Bäder 810cd7881e icontheme: Make icon_paintable_ensure_texture() return an unowned value
It's private, has only one caller and that one doesn't need the extra
ref.
2020-12-21 10:26:02 +01:00
Timm Bäder a8213d7f45 gl renderer: Avoid setting modelview to identical values
The previous comment here was incorrect. We can save the op itself, we
just can't save us the entry in the modelview stack.
2020-12-21 10:26:02 +01:00
Timm Bäder e6f6d1e478 main: Add & use gdk_event_dup_axes()
The way this code is written trips up scan-build. Add
gdk_event_dup_axes() and use it in gtkmain.c.
2020-12-21 10:26:02 +01:00
Rafael Fontenelle 933d241bba Update Brazilian Portuguese translation 2020-12-21 07:02:13 +00:00
Matthias Clasen 7249c3a09b Merge branch 'ebassi/issue-3495' into 'master'
Use full path when calling gtk4-update-icon-cache

Closes #3495

See merge request GNOME/gtk!2979
2020-12-20 22:40:48 +00:00
Emmanuele Bassi d13f8ac3a9 Call the newly installed gtk4-update-icon-cache
Otherwise we rely on whatever it's inside the PATH.
2020-12-20 16:33:41 +00:00
Emmanuele Bassi fa35e3b874 Pass the bindir to the post-install script 2020-12-20 16:33:25 +00:00
Rafael Fontenelle 853883c6e5 Update Brazilian Portuguese translation 2020-12-20 14:06:52 +00:00
sicklylife b467279c7d Update Japanese translation 2020-12-20 08:03:00 +00:00
sicklylife c6a5ac1d16 Update Japanese translation 2020-12-20 07:58:09 +00:00
A S Alam e41288de4f Update Punjabi translation 2020-12-20 06:14:42 +00:00
Jordi Mas i Hernandez b886988a54 Update Catalan translation 2020-12-19 18:29:08 +00:00
Matthias Clasen bb8a459fe2 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2978
2020-12-19 17:20:39 +00:00
Matthias Clasen d5143a1bf0 Revert "gl renderer: Render too big textures to the clipped area"
This reverts commit 7f6608cbed.
2020-12-19 11:43:56 -05:00
Matthias Clasen 12611fa142 Revert "gl renderer: Take a out graphene_rect in blur_node()"
This reverts commit 7eece7e769.
2020-12-19 11:43:43 -05:00
Matthias Clasen 3e319b409b Merge branch 'ebassi/issue-3492' into 'master'
3to4: Remove GtkCheckButton:draw-indicator

Closes #3492

See merge request GNOME/gtk!2976
2020-12-19 16:41:14 +00:00
Emmanuele Bassi f2b16836c2 3to4: Add test for GtkCheckButton:draw-indicator removal 2020-12-19 15:52:22 +00:00
Emmanuele Bassi 14bf45a0d5 3to4: Remove GtkCheckButton:draw-indicator
The property was removed from the widget, so we need to remove it from
UI files too.

Fixes: #3492
2020-12-18 23:14:24 +00:00
Timm Bäder 0c6a6b3370 Merge branch 'doc_backticks' into 'master'
docs: backtick fixes

See merge request GNOME/gtk!2975
2020-12-18 15:57:30 +00:00
wisp3rwind 9521f609d8 docs: backtick fixes
- in the gettext() examples, at least the _() triggers italics
- add missing closing backtick
2020-12-18 16:31:41 +01:00
Matthias Clasen 7533369695 Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

See merge request GNOME/gtk!2973
2020-12-18 05:06:35 +00:00
Matthias Clasen f31765d5dd Merge branch 'ebassi/mnemonic-label-remove' into 'master'
a11y: Fix removing mnemonic widgets

See merge request GNOME/gtk!2970
2020-12-18 00:00:48 +00:00
Matthias Clasen d33062795c Merge branch 'ebassi/docs-for-master' into 'master'
Ebassi/docs for master

See merge request GNOME/gtk!2971
2020-12-17 23:59:41 +00:00
Emmanuele Bassi 2da8d9b0ac Do not build gdk-pixbuf's man page
When using it as a sub-project. We don't really need them.
2020-12-17 20:50:16 +00:00
Matthias Clasen 3f56e8191f Merge branch 'shortcuts' into 'master'
docs: Add separation between kinds of shortcuts in Keyboard input

See merge request GNOME/gtk!2964
2020-12-17 19:43:38 +00:00
Chris Mayo bf4c3dc2c5 docs: Fix list of kinds of shortcuts in Keyboard input
Formatting in HTML was mangled.
2020-12-17 19:18:10 +00:00
Emmanuele Bassi a5365ec8cb docs: Add missing GTK types
If we don't specify the get_type() function, gtk-doc will not collect
properties and signals, and will use a different URL for the page.
2020-12-17 18:30:19 +00:00
Emmanuele Bassi ec94ec0286 Merge branch 'ebassi/password-entry-notify' into 'master'
Notify properties on deletion in PasswordEntryBuffer

Closes #3484

See merge request GNOME/gtk!2969
2020-12-17 15:51:04 +00:00
Emmanuele Bassi af0973c847 a11y: Fix removing mnemonic widgets
We must not use the variadic arguments version with GList, as it expects
a pointer to a GtkAccessible.
2020-12-17 15:49:00 +00:00
Emmanuele Bassi e71f6b0bc0 docs: Note the caveat on GtkEditable signals with delegates
We cannot bubble up ::insert-text and ::delete-text signals from the
delegate to the wrapper editable without causing an infinite recursion,
due to how the signals are designed; ideally, we would have decoupled
signal emission from virtual functions *before* releasing GTK4, but now
that we have, we can't break the contract.
2020-12-17 15:13:43 +00:00
Emmanuele Bassi 1738724e4a Notify properties on deletion in PasswordEntryBuffer
The GtkEntryBufferClass.deleted_text() behaviour changed between GTK3
and GTK4, which means any subclass of GtkEntryBuffer is now responsible
for emitting the "notify" signal for the "text" and "length" properties.

Without this, the GtkText delegate widget used by GtkPasswordEntry would
not be able to communicate changes in the contents of its buffer.

Fixes: #3484
2020-12-17 15:01:35 +00:00
Emmanuele Bassi e9e09be37e Merge branch 'issue-3483' into 'master'
Fix URLs for the download.gnome.org locations

Closes #3483

See merge request GNOME/gtk!2968
2020-12-17 13:47:01 +00:00
Matthias Clasen 8a923e02a1 Merge branch 'wip/jimmac/flat-button-tweaks' into 'master'
Adwaita: flat button adjustments

See merge request GNOME/gtk!2967
2020-12-17 12:52:22 +00:00
Emmanuele Bassi 4f12e2f711 Fix URLs for the download.gnome.org locations
Use a trailing slash, otherwise we end up on an out of date mirror.

Fixes: #3483
2020-12-17 12:46:12 +00:00
Jakub Steiner addcf57b4d Adwaita: flat button adjustments
- normally lighter (on bg_color)
- darker for headerbar
- undecorated checked buttons were never style properly (even gtk3)
  see page2 volume buttons

Finetunes https://gitlab.gnome.org/GNOME/gtk/-/issues/3427
2020-12-17 12:20:29 +01:00
Matthias Clasen db08bccb11 Merge branch 'cursor-aspect-ratio' into 'master'
Cursor aspect ratio fixes for gtk 4

Closes #3441

See merge request GNOME/gtk!2966
2020-12-16 23:40:26 +00:00
Sebastian Keller 02f0681344 settings: Change gtk-cursor-aspect-ratio from float to double
Float properties can not be read from keyfiles. This was causing changes
to this property in settings.ini to be ignored. Fix this by changing it
to a double.

Technically this change could be considered an API break, but there are
no users of this property as float yet and it is early enough to expect
there to never be any.

Also document this change in the 3 to 4 migration guide since in gtk 3
this setting will be kept a float.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3441
2020-12-16 22:35:36 +01:00
Emmanuele Bassi 62dbadd536 Merge branch 'fix-macos-compilation' into 'master'
macos: fix typo that breaks compilation

See merge request GNOME/gtk!2962
2020-12-16 20:18:27 +00:00
Matthias Clasen 0588db8a69 Merge branch 'wip/carlosg/for-master' into 'master'
gdk/x11: Transform XI_Motion based scroll into discrete

Closes #3459

See merge request GNOME/gtk!2959
2020-12-16 19:56:16 +00:00
Emmanuele Bassi 58b1a13453 Merge branch 'ricotz/for-master' into 'master'
gdk: Use correct parameter name to fix g-ir-scanner warning

See merge request GNOME/gtk!2963
2020-12-16 19:46:51 +00:00
Rico Tzschichholz df70dbbae4 gdk: Use correct parameter name to fix g-ir-scanner warning
../gdk/gdktoplevellayout.c:217: Warning: Gdk: gdk_toplevel_layout_get_maximized:
  unknown parameter 'maximized' in documentation comment, should be 'maximize'
2020-12-16 20:19:05 +01:00
Tom Schoonjans 81c55b06d2 macos: fix typo that breaks compilation 2020-12-16 19:16:19 +00:00
Carlos Garnacho c95a32def8 gdk/x11: Transform XI_Motion based scroll into discrete
Depending on the input driver, we will get XI_Motion based scroll
events for regular mouse wheels. These are intended to be handled
as discrete scroll, so detect smooth scroll events that move by
exactly 1.0 in either direction.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3459
2020-12-16 14:26:44 +01:00
Timm Bäder 7eece7e769 gl renderer: Take a out graphene_rect in blur_node() 2020-12-16 09:13:12 +01:00
Timm Bäder 7f6608cbed gl renderer: Render too big textures to the clipped area 2020-12-16 08:26:46 +01:00
Timm Bäder f816a8fb82 gl renderer: Unify viewport setting in add_offscreen_ops()
We use the same rect here a few times.
2020-12-16 08:26:46 +01:00
Timm Bäder 3c2484142d vulkancontext: Remove usage of VK_ERROR_INCOMPATIBLE_VERSION_KHR
According to
https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/html/chap46.html
this has been removed. It also breaks the build on my system
2020-12-16 08:26:46 +01:00
Christian Hergert 0d2ea14ac1 types: fix various use of volatile in type registration
The use of volatile was incorrect in GLib and has been that way for
a long time. Recently however that has changed, and this makes GTK
follow suit to avoid using volatile in the type registration.

See also: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719

Combined with the above merge request for GLib, this fixes a large
number of compilation warnings when using Clang.
2020-11-18 20:21:33 -08:00
635 changed files with 62681 additions and 51110 deletions
+28 -1
View File
@@ -24,7 +24,7 @@ variables:
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:v25"
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v27"
FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"
DOCS_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora-docs:v25"
@@ -43,6 +43,7 @@ style-check-diff:
- .gitlab-ci/run-style-check-diff.sh
.build-fedora-default:
extends: .only-default
image: $FEDORA_IMAGE
artifacts:
when: always
@@ -121,6 +122,7 @@ installed-tests:
.mingw-defaults:
extends: .only-default
stage: build
tags:
- win32-ps
@@ -144,6 +146,31 @@ msys2-mingw64:
MSYSTEM: "MINGW64"
CHERE_INVOKING: "yes"
macos:
extends: .only-default
only:
- branches@GNOME/gtk
stage: build
tags:
- macos
needs: []
before_script:
- bash .gitlab-ci/show-execution-environment.sh
- pip3 install --user meson==0.56
- pip3 install --user ninja
- export PATH=/Users/gitlabrunner/Library/Python/3.7/bin:$PATH
script:
- meson -Dx11-backend=false
-Dintrospection=disabled
-Dcpp_std=c++11
-Dpixman:tests=disabled
_build
- ninja -C _build
artifacts:
when: always
paths:
- "${CI_PROJECT_DIR}/_build/meson-logs"
.flatpak-defaults:
image: $FLATPAK_IMAGE
stage: flatpak
+1
View File
@@ -65,6 +65,7 @@ RUN dnf -y install \
libxslt \
mesa-dri-drivers \
mesa-libEGL-devel \
mesa-libGLES-devel \
mesa-libwayland-egl-devel \
ninja-build \
pango-devel \
+1 -1
View File
@@ -1,4 +1,4 @@
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v25
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v27
# Enable sudo for wheel users
RUN sed -i -e 's/# %wheel/%wheel/' -e '0,/%wheel/{s/%wheel/# %wheel/}' /etc/sudoers
+2 -1
View File
@@ -8,7 +8,8 @@ builddir=$1
backend=$2
# Ignore memory leaks lower in dependencies
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0
export G_SLICE=always-malloc
case "${backend}" in
x11)
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
set -eux -o pipefail
xcodebuild -version || :
xcodebuild -showsdks || :
system_profiler SPSoftwareDataType || :
+12
View File
@@ -1,4 +1,13 @@
<!--
Please, read the CONTRIBUTING.md guide on how to file a new issue.
https://gitlab.gnome.org/GNOME/gtk/-/blob/master/CONTRIBUTING.md
-->
## Steps to reproduce
<!--
Please, explain the sequence of actions necessary to reproduce the
bug
-->
1. ...
2. ...
@@ -32,5 +41,8 @@
## Additional information
<!--
- Screenshots or screen recordings are useful for visual errors
- Attaching a screenshot or a video without explaining the current
behavior and the actions necessary to reproduce the bug will lead
to the bug being closed
- Please report any warning or message printed on the terminal
-->
+10
View File
@@ -1,4 +1,14 @@
<!--
Please, read the CONTRIBUTING.md guide on how to file a new issue.
https://gitlab.gnome.org/GNOME/gtk/-/blob/master/CONTRIBUTING.md
-->
## Steps to reproduce
<!--
Please, explain the sequence of actions necessary to reproduce the
crash
-->
1. ...
2. ...
+97 -9148
View File
File diff suppressed because it is too large Load Diff
+9178
View File
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -17,7 +17,7 @@ license fees or royalties.
The official download location
- https://download.gnome.org/sources/gtk+
- https://download.gnome.org/sources/gtk/
The official web site
@@ -49,11 +49,11 @@ In order to build GTK you will need:
You will also need various dependencies, based on the platform you are
building for:
- [GLib](https://download.gnome.org/sources/glib)
- [GdkPixbuf](https://download.gnome.org/sources/gdk-pixbuf)
- [GObject-Introspection](https://download.gnome.org/sources/gobject-introspection)
- [Cairo](https://www.cairographics.org)
- [Pango](https://download.gnome.org/sources/pango)
- [GLib](https://download.gnome.org/sources/glib/)
- [GdkPixbuf](https://download.gnome.org/sources/gdk-pixbuf/)
- [GObject-Introspection](https://download.gnome.org/sources/gobject-introspection/)
- [Cairo](https://www.cairographics.org/)
- [Pango](https://download.gnome.org/sources/pango/)
- [Epoxy](https://github.com/anholt/libepoxy)
- [Graphene](https://github.com/ebassi/graphene)
- [Xkb-common](https://github.com/xkbcommon/libxkbcommon)
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env python3
import os
from pathlib import PurePath
import subprocess
stylesheets = [ 'gtk/theme/Adwaita/Adwaita.css',
'gtk/theme/Adwaita/Adwaita-dark.css',
'gtk/theme/HighContrast/HighContrast.css',
'gtk/theme/HighContrast/HighContrast-dark.css' ]
sourceroot = os.environ.get('MESON_SOURCE_ROOT')
distroot = os.environ.get('MESON_DIST_ROOT')
for stylesheet in stylesheets:
stylesheet_path = PurePath(stylesheet)
src = PurePath(sourceroot, stylesheet_path.with_suffix('.scss'))
dst = PurePath(distroot, stylesheet_path)
subprocess.call(['sassc', '-a', '-M', '-t', 'compact', src, dst])
+25 -23
View File
@@ -1,20 +1,21 @@
#!/usr/bin/env python3
import os
import sys
import subprocess
if 'DESTDIR' not in os.environ:
gtk_api_version = sys.argv[1]
gtk_abi_version = sys.argv[2]
import os
import sys
import subprocess
if 'DESTDIR' not in os.environ:
gtk_api_version = sys.argv[1]
gtk_abi_version = sys.argv[2]
gtk_libdir = sys.argv[3]
gtk_datadir = sys.argv[4]
gtk_moduledir = os.path.join(gtk_libdir, 'gtk-' + gtk_api_version, gtk_abi_version)
gtk_printmodule_dir = os.path.join(gtk_moduledir, 'printbackends')
gtk_immodule_dir = os.path.join(gtk_moduledir, 'immodules')
print('Compiling GSettings schemas...')
gtk_bindir = sys.argv[5]
gtk_moduledir = os.path.join(gtk_libdir, 'gtk-' + gtk_api_version, gtk_abi_version)
gtk_printmodule_dir = os.path.join(gtk_moduledir, 'printbackends')
gtk_immodule_dir = os.path.join(gtk_moduledir, 'immodules')
print('Compiling GSettings schemas...')
glib_compile_schemas = subprocess.check_output(['pkg-config',
'--variable=glib_compile_schemas',
'gio-2.0']).strip()
@@ -22,13 +23,14 @@ if 'DESTDIR' not in os.environ:
# pkg-config variables only available since GLib 2.62.0.
glib_compile_schemas = 'glib-compile-schemas'
subprocess.call([glib_compile_schemas,
os.path.join(gtk_datadir, 'glib-2.0', 'schemas')])
print('Updating icon cache...')
subprocess.call(['gtk4-update-icon-cache', '-q', '-t' ,'-f',
os.path.join(gtk_datadir, 'icons', 'hicolor')])
print('Updating module cache for print backends...')
os.path.join(gtk_datadir, 'glib-2.0', 'schemas')])
print('Updating icon cache...')
update_icon_cache = os.path.join(gtk_bindir, 'gtk4-update-icon-cache')
subprocess.call([update_icon_cache, '-q', '-t' ,'-f',
os.path.join(gtk_datadir, 'icons', 'hicolor')])
print('Updating module cache for print backends...')
os.makedirs(gtk_printmodule_dir, exist_ok=True)
gio_querymodules = subprocess.check_output(['pkg-config',
'--variable=gio_querymodules',
@@ -37,7 +39,7 @@ if 'DESTDIR' not in os.environ:
# pkg-config variables only available since GLib 2.62.0.
gio_querymodules = 'gio-querymodules'
subprocess.call([gio_querymodules, gtk_printmodule_dir])
print('Updating module cache for input methods...')
print('Updating module cache for input methods...')
os.makedirs(gtk_immodule_dir, exist_ok=True)
subprocess.call([gio_querymodules, gtk_immodule_dir])
+3
View File
@@ -98,6 +98,9 @@ create_page1 (GtkWidget *assistant)
gtk_box_append (GTK_BOX (box), label);
entry = gtk_entry_new ();
gtk_accessible_update_relation (GTK_ACCESSIBLE (entry),
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
-1);
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
gtk_widget_set_valign (entry, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (box), entry);
+1 -1
View File
@@ -20,7 +20,7 @@ mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv)
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);
float alpha = 1.0 - pow (1.0/(sum), 40.0)*pow (10.0, 40.0*0.7);
fragColor = vec4 (r*0.5, g*0.5, b*0.5, 1.0) * alpha;
}
+1 -1
View File
@@ -177,7 +177,7 @@ float ccell2(vec2 p, float r) {
float df(vec2 p, float scale, inout vec2 nn) {
p /= scale;
nn = hextile(p);
nn = round(nn);
nn = floor(nn + 0.5);
float r = hash(nn);
float d;;
+1 -1
View File
@@ -179,7 +179,7 @@ float ccell2(vec2 p, float r) {
float df(vec2 p, float scale, inout vec2 nn) {
p /= scale;
nn = hextile(p);
nn = round(nn);
nn = floor(nn + 0.5);
float r = hash(nn);
float d;;
+4 -5
View File
@@ -119,13 +119,12 @@ create_label (void)
static GtkWidget *
create_video (void)
{
GtkMediaStream *stream = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
GtkWidget *w = gtk_picture_new_for_paintable (GDK_PAINTABLE (stream));
GtkWidget *w = gtk_video_new ();
gtk_widget_set_size_request (w, 64, 64);
gtk_media_stream_set_loop (stream, TRUE);
gtk_media_stream_play (stream);
g_object_unref (stream);
gtk_video_set_loop (GTK_VIDEO (w), TRUE);
gtk_video_set_autoplay (GTK_VIDEO (w), TRUE);
gtk_video_set_resource (GTK_VIDEO (w), "/images/gtk-logo.webm");
return w;
}
+2
View File
@@ -787,6 +787,8 @@ gtk_gears_realize (GtkWidget *widget)
glLinkProgram(program);
glGetProgramInfoLog(program, sizeof msg, NULL, msg);
g_debug ("program info: %s\n", msg);
glDetachShader (program, v);
glDetachShader (program, f);
glDeleteShader (v);
glDeleteShader (f);
+20 -22
View File
@@ -53,31 +53,30 @@
<child>
<object class="GtkBox">
<child>
<object class="GtkScrolledWindow">
<style>
<class name="sidebar"/>
</style>
<property name="width-request">120</property>
<property name="hscrollbar-policy">never</property>
<property name="min-content-width">150</property>
<object class="GtkBox">
<property name="width-request">220</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="width-request">220</property>
<property name="orientation">vertical</property>
<object class="GtkSearchBar" id="searchbar">
<property name="key-capture-widget">window</property>
<child>
<object class="GtkSearchBar" id="searchbar">
<property name="key-capture-widget">window</property>
<child>
<object class="GtkSearchEntry" id="search-entry">
<accessibility>
<relation name="controls">listview</relation>
</accessibility>
</object>
</child>
<object class="GtkSearchEntry" id="search-entry">
<accessibility>
<relation name="controls">listview</relation>
</accessibility>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<style>
<class name="sidebar"/>
</style>
<property name="width-request">120</property>
<property name="hscrollbar-policy">never</property>
<property name="min-content-width">150</property>
<property name="vexpand">1</property>
<child>
<object class="GtkListView" id="listview">
<style>
@@ -94,7 +93,6 @@
</accessibility>
</object>
</child>
</object>
</child>
</object>
+1 -1
View File
@@ -31,7 +31,7 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec
float propagation_length = time * wave_speed;
float t = (propagation_length - distance_from_center) / wave_length;
float offset_magnitude = 0;
float offset_magnitude = 0.0;
if (t > 0.0)
offset_magnitude = decay(wave_height * sin(t * 2.0 * PI), t);
+1
View File
@@ -13,6 +13,7 @@
<property name="right-margin">20</property>
<property name="top-margin">20</property>
<property name="bottom-margin">20</property>
<property name="monospace">1</property>
<property name="buffer">
<object class="GtkTextBuffer" id="buffer"/>
</property>
+20
View File
@@ -910,6 +910,26 @@ node_editor_window_init (NodeEditorWindow *self)
self->text_buffer = gtk_text_buffer_new (self->tag_table);
g_signal_connect (self->text_buffer, "changed", G_CALLBACK (text_changed), self);
gtk_text_view_set_buffer (GTK_TEXT_VIEW (self->text_view), self->text_buffer);
/* Default */
gtk_text_buffer_set_text (self->text_buffer,
"shadow {\n"
" child: texture {\n"
" bounds: 0 0 128 128;\n"
" texture: url(\"resource:///org/gtk/gtk4/node-editor/icons/apps/org.gtk.gtk4.NodeEditor.Devel.svg\");\n"
" }\n"
" shadows: rgba(0,0,0,0.5) 0 1 12;\n"
"}\n"
"\n"
"transform {\n"
" child: text {\n"
" color: rgb(46,52,54);\n"
" font: \"Cantarell Bold 11\";\n"
" glyphs: \"GTK Node Editor\";\n"
" offset: 8 14.418;\n"
" }\n"
" transform: translate(0, 140);\n"
"}", -1);
}
NodeEditorWindow *
-1
View File
@@ -3298,7 +3298,6 @@ bad things might happen.</property>
</object>
</child>
</object>
<object class="GtkSizeGroup" id="basement-indicators"/>
<menu id="new_style_menu_model">
<section>
<attribute name="display-hint">circular-buttons</attribute>

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 45 KiB

+3
View File
@@ -146,6 +146,9 @@ images = [
'images/nwse_resize_cursor.png',
'images/zoom_in_cursor.png',
'images/zoom_out_cursor.png',
'images/popup-anchors.png',
'images/popup-flip.png',
'images/popup-slide.png',
]
src_dir = [ gdkinc ]

Before

Width:  |  Height:  |  Size: 126 KiB

After

Width:  |  Height:  |  Size: 126 KiB

+24 -3
View File
@@ -98,19 +98,22 @@ gsk_render_node_write_to_file
GskScalingFilter
gsk_render_node_get_bounds
<SUBSECTION Nodes>
<SUBSECTION>
gsk_color_node_new
gsk_color_node_get_color
gsk_texture_node_new
gsk_texture_node_get_texture
<SUBSECTION>
GskColorStop
gsk_linear_gradient_node_new
gsk_repeating_linear_gradient_node_new
gsk_linear_gradient_node_get_start
gsk_linear_gradient_node_get_end
gsk_linear_gradient_node_get_n_color_stops
gsk_linear_gradient_node_get_color_stops
gsk_repeating_linear_gradient_node_new
<SUBSECTION>
gsk_radial_gradient_node_new
gsk_repeating_radial_gradient_node_new
gsk_radial_gradient_node_get_n_color_stops
gsk_radial_gradient_node_get_color_stops
gsk_radial_gradient_node_get_start
@@ -118,16 +121,18 @@ gsk_radial_gradient_node_get_end
gsk_radial_gradient_node_get_hradius
gsk_radial_gradient_node_get_vradius
gsk_radial_gradient_node_get_center
gsk_repeating_radial_gradient_node_new
<SUBSECTION>
gsk_conic_gradient_node_new
gsk_conic_gradient_node_get_n_color_stops
gsk_conic_gradient_node_get_color_stops
gsk_conic_gradient_node_get_center
gsk_conic_gradient_node_get_rotation
<SUBSECTION>
gsk_border_node_new
gsk_border_node_get_outline
gsk_border_node_get_widths
gsk_border_node_get_colors
<SUBSECTION>
gsk_inset_shadow_node_new
gsk_inset_shadow_node_get_outline
gsk_inset_shadow_node_get_color
@@ -135,6 +140,7 @@ gsk_inset_shadow_node_get_dx
gsk_inset_shadow_node_get_dy
gsk_inset_shadow_node_get_spread
gsk_inset_shadow_node_get_blur_radius
<SUBSECTION>
gsk_outset_shadow_node_new
gsk_outset_shadow_node_get_outline
gsk_outset_shadow_node_get_color
@@ -142,45 +148,57 @@ gsk_outset_shadow_node_get_dx
gsk_outset_shadow_node_get_dy
gsk_outset_shadow_node_get_spread
gsk_outset_shadow_node_get_blur_radius
<SUBSECTION>
gsk_cairo_node_new
gsk_cairo_node_get_draw_context
gsk_cairo_node_get_surface
<SUBSECTION>
gsk_container_node_new
gsk_container_node_get_n_children
gsk_container_node_get_child
<SUBSECTION>
gsk_transform_node_new
gsk_transform_node_get_child
gsk_transform_node_get_transform
<SUBSECTION>
gsk_opacity_node_new
gsk_opacity_node_get_child
gsk_opacity_node_get_opacity
<SUBSECTION>
gsk_color_matrix_node_new
gsk_color_matrix_node_get_child
gsk_color_matrix_node_get_color_matrix
gsk_color_matrix_node_get_color_offset
<SUBSECTION>
gsk_repeat_node_new
gsk_repeat_node_get_child
gsk_repeat_node_get_child_bounds
<SUBSECTION>
gsk_clip_node_new
gsk_clip_node_get_child
gsk_clip_node_get_clip
<SUBSECTION>
gsk_rounded_clip_node_new
gsk_rounded_clip_node_get_child
gsk_rounded_clip_node_get_clip
<SUBSECTION>
GskShadow
gsk_shadow_node_new
gsk_shadow_node_get_shadow
gsk_shadow_node_get_n_shadows
gsk_shadow_node_get_child
<SUBSECTION>
GskBlendMode
gsk_blend_node_new
gsk_blend_node_get_bottom_child
gsk_blend_node_get_top_child
gsk_blend_node_get_blend_mode
<SUBSECTION>
gsk_cross_fade_node_new
gsk_cross_fade_node_get_start_child
gsk_cross_fade_node_get_end_child
gsk_cross_fade_node_get_progress
<SUBSECTION>
gsk_text_node_new
gsk_text_node_get_font
gsk_text_node_get_glyphs
@@ -188,12 +206,15 @@ gsk_text_node_get_color
gsk_text_node_has_color_glyphs
gsk_text_node_get_num_glyphs
gsk_text_node_get_offset
<SUBSECTION>
gsk_blur_node_new
gsk_blur_node_get_child
gsk_blur_node_get_radius
<SUBSECTION>
gsk_debug_node_new
gsk_debug_node_get_child
gsk_debug_node_get_message
<SUBSECTION>
gsk_gl_shader_node_new
gsk_gl_shader_node_get_n_children
gsk_gl_shader_node_get_child
+9 -8
View File
@@ -18,9 +18,9 @@ Length
Percentage
: %, calc()
Angle
: deg | grad | turn, calc()
: deg, grad, turn, calc()
Time
: s | ms, calc()
: s, ms, calc()
Length values with the em or ex units are resolved using the font
size value, unless they occur in setting the font-size itself, in
@@ -32,7 +32,7 @@ not quite the same as the CSS definition of rem.
The calc() notation adds considerable expressive power. There are limits
on what types can be combined in such an expression (e.g. it does not make
sense to add a number and a time). For the full details, see the
[CSS3 VAlues and Units](https://www.w3.org/TR/css3-values/#calc-notation)
[CSS3 Values and Units](https://www.w3.org/TR/css3-values/#calc-notation)
spec.
A common pattern among shorthand properties (called 'four sides') is one
@@ -151,7 +151,7 @@ done with
|caret-color|[CSS Basic User Interface Level 3](https://www.w3.org/TR/css3-ui/#caret-color) | CSS allows an auto value |
|-gtk-secondary-caret-color|[Color](https://www.w3.org/TR/css-color-3/#valuea-def-color) | used for the secondary caret in bidirectional text |
|letter-spacing| [CSS Text Level 3](https://www.w3.org/TR/css3-text/#letter-spacing) | |
|text-decoration-line| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-line-property) | CSS allows overline |
|text-decoration-line| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-line-property) | |
|text-decoration-color| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-color-property) | |
|text-decoration-style| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-style-property) | CSS allows dashed and dotted |
|text-shadow| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-shadow-property) | |
@@ -159,11 +159,12 @@ done with
|-gtk-icon-source| [Image](https://www.w3.org/TR/css-backgrounds-3/#typedef-image), `builtin` or `none` | used for builtin icons in buttons and expanders |
|-gtk-icon-size| [Length](https://www.w3.org/TR/css3-values/#length-value) | size used for builtin icons in buttons and expanders |
|-gtk-icon-style| `requested`, `regular` or `symbolic` | preferred style for application-loaded icons |
|-gtk-icon-transform| [Transform list](https://drafts.csswg.org/css-transforms-1/#typedef-transform-list) or `none` | applied to builtin and application-loaded icons |
|-gtk-icon-transform| [Transform list](https://www.w3.org/TR/css-transforms-1/#typedef-transform-list) or `none` | applied to builtin and application-loaded icons |
|-gtk-icon-palette| Color palette, as explained above | used to recolor symbolic icons |
|-gtk-icon-shadow| [Shadow](https://www.w3.org/TR/css-backgrounds-3/#typedef-shadow) or `none` | applied to builtin and application-loaded icons |
|-gtk-icon-filter| [Filter value list](https://www.w3.org/TR/filter-effects-1/#typedef-filter-value-list) or `none` | applied to builtin and application-loaded icons |
|transform| [CSS Transforms Level 2](https://drafts.csswg.org/css-transforms-2/) | |
|transform| [CSS Transforms Level 1](https://www.w3.org/TR/css-transforms-1/#transform-property) | |
|transform-origin| [CSS Transforms Level 1](https://www.w3.org/TR/css-transforms-1/#transform-origin-property) | CSS allows specifying a z component|
|min-width| [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#min-width) | CSS allows percentages |
|min-height| [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#min-height) | CSS allows percentages |
|margin-top| [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#margin-top) | CSS allows percentages or auto |
@@ -217,7 +218,7 @@ done with
|background-size| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-size) | |
|background-position| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-position) | |
|background-repeat| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-repeat) | |
|background-image| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-image) | not supported: urls without quotes, colors in crossfades |
|background-image| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-image) | not supported: urls without quotes |
|box-shadow| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#box-shadow) | |
|background-blend-mode| [CSS Compositing and Blending Level 1](https://www.w3.org/TR/compositing-1/#propdef-background-blend-mode) | only affects multiple backgrounds |
|background| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background) | |
@@ -235,4 +236,4 @@ done with
|animation-delay| [CSS Animations Level 1](https://www.w3.org/TR/css3-animations/#animation-delay) | |
|animation-fill-mode| [CSS Animations Level 1](https://www.w3.org/TR/css3-animations/#animation-fill-mode) | |
|animation| [CSS Animations Level 1](https://www.w3.org/TR/css3-animations/#animation) | |
|border-spacing| [CSS Table Level 3](https://www.w3.org/TR/css-tables-3/#border-spacing-property) | respected by GtkBox and GtkGrid |
|border-spacing| [CSS Table Level 3](https://www.w3.org/TR/css-tables-3/#border-spacing-property) | respected by GtkBoxLayout, GtkGridLayout, GtkCenterLayout |
+8 -9
View File
@@ -343,20 +343,19 @@ Many widgets, like buttons, do all their drawing themselves. You just tell
them the label you want to see, and they figure out what font to use, draw
the button outline and focus rectangle, etc. Sometimes, it is necessary to
do some custom drawing. In that case, a GtkDrawingArea might be the right
widget to use. It offers a canvas on which you can draw by connecting to
the ::draw signal.
widget to use. It offers a canvas on which you can draw by setting its
draw function.
The contents of a widget often need to be partially or fully redrawn,
e.g. when another window is moved and uncovers part of the widget, or
when the window containing it is resized. It is also possible to explicitly
cause part or all of the widget to be redrawn, by calling
gtk_widget_queue_draw() or its variants. GTK takes care of most of the
details by providing a ready-to-use cairo context to the ::draw signal
handler.
cause a widget to be redrawn, by calling gtk_widget_queue_draw(). GTK takes
care of most of the details by providing a ready-to-use cairo context to the
draw function.
The following example shows a ::draw signal handler. It is a bit more
complicated than the previous examples, since it also demonstrates
input event handling by means of event controllers.
The following example shows how to use a draw function with GtkDrawingArea.
It is a bit more complicated than the previous examples, since it also
demonstrates input event handling with event controllers.
![Drawing](drawing.png)
+31 -25
View File
@@ -41,35 +41,41 @@
<command>gtk4-builder-tool</command> can perform various operations
on GtkBuilder .ui files.
</para>
<para>
The <option>validate</option> command validates the .ui file and reports
errors to stderr.
</para>
<para>
The <option>enumerate</option> command lists all the named objects that
are created in the .ui file.
</para>
<para>
The <option>preview</option> command displays the .ui file. This command
accepts options to specify the ID of the toplevel object and a .css file
to use.
</para>
<para>
The <option>simplify</option> command simplifies the .ui file by removing
properties that are set to their default values and writes the resulting XML
to stdout, or back to the input file.
</para>
<para>
When the <option>--3to4</option> is specified, <option>simplify</option>
interprets the input as a GTK 3 ui file and attempts to convert it to GTK 4
equivalents. It performs various conversions, such as renaming properties,
translating child properties to layout properties, rewriting the setup for
GtkNotebook, GtkStack, GtkAssistant or changing toolbars into boxes.
</para>
<para>
You should always test the modified .ui files produced by gtk4-builder-tool
before using them in production.
</para>
</refsect1>
<refsect1><title>Commands</title>
<para>The following commands are understood:</para>
<variablelist>
<varlistentry>
<term><option>validate</option></term>
<listitem><para>Validates the .ui file and report errors to stderr.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>simplify</option></term>
<listitem><para>Simplifies the .ui file by removing properties that
are set to their default values and write the resulting XML to stdout,
or back to the input file.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>enumerate</option></term>
<listitem><para>Lists all the named objects that are created in the .ui file.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>preview</option></term>
<listitem><para>Preview the .ui file. This command accepts options
to specify the ID of an object and a .css file to use.</para></listitem>
</varlistentry>
</variablelist>
<para>
Note in particular that the conversion
done with <option>--3to4</option> is meant as a starting point for a port
from GTK 3 to GTK 4. It is expected that you will have to do manual fixups
after the initial conversion.
</para>
</refsect1>
<refsect1><title>Simplify Options</title>
@@ -61,6 +61,13 @@
<listitem><para>Write png files to <replaceable>DIRECTORY</replaceable>
instead of the current working directory.</para></listitem>
</varlistentry>
<varlistentry>
<term>--debug</term>
<listitem><para>Generate png files of the various channels during
the conversion. If these files are not monochrome green, they
are often helpful in pinpointing the problematic parts of
the source svg.</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
-1
View File
@@ -4668,7 +4668,6 @@ GTK_WINDOW_GET_CLASS
<SUBSECTION Private>
GtkWindowPrivate
gtk_window_get_type
GtkWindowGeometryInfo
gtk_window_remove_embedded_xid
gtk_window_add_embedded_xid
GtkWindowKeysForeachFunc
+8 -3
View File
@@ -19,8 +19,8 @@ gtk_assistant_page_get_type
gtk_at_context_get_type
gtk_bin_layout_get_type
gtk_bitset_get_type
gtk_expression_get_type
gtk_bookmark_list_get_type
gtk_bool_filter_get_type
gtk_box_get_type
gtk_box_layout_get_type
gtk_buildable_get_type
@@ -46,6 +46,7 @@ gtk_cell_renderer_spinner_get_type
gtk_cell_renderer_text_get_type
gtk_cell_renderer_toggle_get_type
gtk_cell_view_get_type
gtk_center_box_get_type
gtk_center_layout_get_type
gtk_check_button_get_type
gtk_closure_expression_get_type
@@ -65,14 +66,16 @@ gtk_constraint_target_get_type
gtk_css_provider_get_type
gtk_custom_filter_get_type
gtk_custom_sorter_get_type
gtk_custom_layout_get_type
gtk_dialog_get_type
gtk_directory_list_get_type
gtk_drag_icon_get_type
gtk_drag_source_get_type
gtk_drawing_area_get_type
gtk_drop_target_get_type
gtk_drop_target_async_get_type
gtk_drop_controller_motion_get_type
gtk_drop_down_get_type
gtk_drop_target_async_get_type
gtk_drop_target_get_type
gtk_editable_get_type
gtk_editable_label_get_type
gtk_emoji_chooser_get_type
@@ -87,6 +90,7 @@ gtk_event_controller_motion_get_type
gtk_event_controller_scroll_get_type
gtk_every_filter_get_type
gtk_expander_get_type
gtk_expression_get_type
gtk_file_chooser_dialog_get_type
gtk_file_chooser_get_type
gtk_file_chooser_native_get_type
@@ -250,6 +254,7 @@ gtk_video_get_type
gtk_viewport_get_type
gtk_volume_button_get_type
gtk_widget_get_type
gtk_widget_paintable_get_type
gtk_window_get_type
gtk_window_controls_get_type
gtk_window_group_get_type
+12 -15
View File
@@ -119,21 +119,18 @@ around or to activate a widget that does not currently have the focus.
GTK has traditionally supported different kinds of shortcuts:
Accelerators
: Accelerators are any other shortcuts that can be activated regardless
of where the focus is, and typically trigger global actions, such as
Ctrl-Q to quit an application.
Mnmemonics
: Mnemonics are usually triggered using Alt as a modifier for a letter.
They are used in places where a label is associated with a control,
and are indicated by underlining the letter in the label. As a special
case, inside menus (i.e. inside #GtkPopoverMenu), mnemonics can be
triggered without the modifier.
Key bindings
: Key bindings are specific to individual widgets, such as Ctrl-C or
Ctrl-V in an entry copy to or paste from the clipboard. They are only
triggered when the widget has focus.
- Accelerators are any other shortcuts that can be activated regardless
of where the focus is, and typically trigger global actions, such as
Ctrl-Q to quit an application.
- Mnemonics are usually triggered using Alt as a modifier for a letter.
They are used in places where a label is associated with a control,
and are indicated by underlining the letter in the label. As a special
case, inside menus (i.e. inside #GtkPopoverMenu), mnemonics can be
triggered without the modifier.
- Key bindings are specific to individual widgets, such as Ctrl-C or
Ctrl-V in an entry copy to or paste from the clipboard. They are only
triggered when the widget has focus.
GTK handles accelerators and mnemonics in a global scope, during the
capture phase, and key bindings locally, during the target phase.
-4
View File
@@ -413,10 +413,6 @@ images = [
'images/password-entry.png',
'images/picture.png',
'images/popover.png',
'images/popup-anchors.png',
'images/popup-at.svg',
'images/popup-flip.png',
'images/popup-slide.png',
'images/printdialog.png',
'images/progressbar.png',
'images/right-center.png',
+138 -17
View File
@@ -165,11 +165,11 @@ for this change.
| ::key-release-event | #GtkEventControllerKey |
| ::enter-notify-event | #GtkEventControllerMotion |
| ::leave-notify-event | #GtkEventControllerMotion |
| ::configure-event | replaced by #GdkSurface::layout |
| ::configure-event | - |
| ::focus-in-event | #GtkEventControllerFocus |
| ::focus-out-event | #GtkEventControllerFocus |
| ::map-event | replaced by #GdkSurface:mapped |
| ::unmap-event | replaced by #GdkSurface:mapped |
| ::map-event | - |
| ::unmap-event | - |
| ::property-notify-event | replaced by #GdkClipboard |
| ::selection-clear-event | replaced by #GdkClipboard |
| ::selection-request-event | replaced by #GdkClipboard |
@@ -178,10 +178,17 @@ for this change.
| ::proximity-in-event | #GtkGestureStylus |
| ::proximity-out-event | #GtkGestureStylus |
| ::visibility-notify-event | - |
| ::window-state-event | replaced by #GdkToplevel:state |
| ::window-state-event | - |
| ::damage-event | - |
| ::grab-broken-event | - |
Event signals which are not directly related to input have to be dealt
with on a one-by-one basis. If you were using ::configure-event and
::window-state-event to save window state, you should use property
notification for corresponding GtkWindow properties, such as
#GtkWindow:default-width, #GtkWindow:default-height, #GtkWindow:maximized
or #GtkWindow:fullscreened.
### Set a proper application ID
In GTK 4 we want the application's #GApplication 'application-id'
@@ -264,14 +271,6 @@ therefore can no longer be used to break reference cycles. A typical sign
of a reference cycle involving a toplevel window is when closing the window
does not make the application quit.
A good rule to follow is: If you set a widget pointer with
gtk_widget_class_bind_template_child() in class_init(), you need to
unparent it in dispose(). The slight complication here is that you need
to respect the widget hierarchy while doing so. Ie if you set both `field1`
and `field2`, but `field1` is an ancestor of `field2`, then you only need
to unparent `field1` — doing so will remove the the entire subtree below
`field1`, including `field2`.
### Stop using GdkScreen
The GdkScreen object has been removed in GTK 4. Most of its APIs already
@@ -407,7 +406,7 @@ and gdk_keymap_get_entries_for_keyval().
GTK 3 has the idea that use of modifiers may differ between different
platforms, and has a #GdkModifierIntent api to let platforms provide
hint about how modifiers are expected to be used. It also promoted
the use of <Primary> instead of <Control> to specify accelerators that
the use of `<Primary>` instead of `<Control>` to specify accelerators that
adapt to platform conventions.
In GTK 4, the meaning of modifiers has been fixed, and backends are
@@ -426,13 +425,88 @@ GDK_CONTROL_MASK|GDK_ALT_MASK
: Prevent text input
Consequently, #GdkModifierIntent and related APIs have been removed,
and <Control> is preferred over <Primary> in accelerators.
and `<Control>` is preferred over `<Primary>` in accelerators.
A related change is that GTK 4 no longer supports the use of archaic
X11 'real' modifiers with the names Mod1,..., Mod5, and %GDK_MOD1_MASK
has been renamed to %GDK_ALT_MASK.
### Stop using gtk_get_current_... APIs
### Replace GtkClipboard with GdkClipboard
The `GtkClipboard` API has been removed, and replaced by #GdkClipboard.
There is not direct 1:1 mapping between the old an the new API, so it cannot
be a mechanical replacement; the new API is based on object types and #GValue
like object properties, instead of opaque identifiers, so it should be easier
to use.
For instance, the example below copies the contents of an entry into the
clipboard:
```
static void
copy_text (GtkWidget *widget)
{
GtkEditable *editable = GTK_EDITABLE (widget);
// Initialize a GValue with the contents of the widget
GValue value = G_VALUE_INIT;
g_value_init (&value, G_TYPE_STRING);
g_value_set_string (&value, gtk_editable_get_text (editable));
// Store the value in the clipboard object
GdkClipboard *clipboard = gtk_widget_get_clipboard (widget);
gdk_clipboard_set_value (clipboard, &value);
g_value_unset (&value);
}
```
whereas the example below pastes the contents into the entry:
```
static void
paste_text (GtkWidget *widget)
{
GtkEditable *editable = GTK_EDITABLE (widget);
// Initialize a GValue to receive text
GValue value = G_VALUE_INIT;
g_value_init (&value, G_TYPE_STRING);
// Get the content provider for the clipboard, and ask it for text
GdkClipboard *clipboard = gtk_widget_get_clipboard (widget);
GdkContentProvider *provider = gdk_clipboard_get_content (clipboard);
// If the content provider does not contain text, we are not interested
if (!gdk_content_provider_get_value (provider, &value, NULL))
return;
const char *str = g_value_get_string (&value);
gtk_editable_set_text (editable, str);
g_value_unset (&value);
}
```
The convenience API for specific target types in `GtkClipboard` has been
replaced by their corresponding GType:
| GtkClipboard | GType |
| ----------------------------------- | ---------------------- |
| `gtk_clipboard_request_text()` | `G_TYPE_STRING` |
| `gtk_clipboard_request_rich_text()` | `GTK_TYPE_TEXT_BUFFER` |
| `gtk_clipboard_request_image()` | `GDK_TYPE_PIXBUF` |
| `gtk_clipboard_request_uris()` |` GDK_TYPE_FILE_LIST` |
**Note**: Support for rich text serialization across different processes
for #GtkTextBuffer is not available any more.
If you are copying the contents of an image, it is recommended to use
GDK_TYPE_PAINTABLE instead of GDK_TYPE_PIXBUF, to minimize the amount of
potential copies.
### Stop using `gtk_get_current_...` APIs
The function gtk_get_current_event() and its variants have been
replaced by equivalent event controller APIs:
@@ -448,6 +522,25 @@ option. You should always review the resulting changes.
The <requires> tag now supports for the 'lib' attribute the
'gtk' value only, instead of the 'gtk+' one previously.
### Adapt to GtkBuilder API changes
gtk_builder_connect_signals() no longer exists. Instead, signals are
always connected automatically. If you need to add user data to your
signals, gtk_builder_set_current_object() must be called. An important
caveat is that you have to do this before loading any XML. This means if
you need to use gtk_builder_set_current_object(), you can no longer use
gtk_builder_new_from_file(), gtk_builder_new_from_resource(), or
gtk_builder_new_from_string(). Instead, you must use vanilla gtk_builder_new(),
then call gtk_builder_set_current_object(), then load the XML using
gtk_builder_add_from_file(), gtk_builder_add_from_resource(), or
gtk_builder_add_from_string(). You must check the return value for
failure and manually abort with g_error() if something went wrong.
You only have to worry about this if you were previously using
gtk_builder_connect_signals(). If you are using templates, then
gtk_widget_init_template() will call gtk_builder_set_current_object()
for you, so templates work like before.
### Adapt to event controller API changes
A few changes to the event controller and #GtkGesture APIs
@@ -458,6 +551,23 @@ Another is that #GtkGestureMultiPress has been renamed to #GtkGestureClick,
and has lost its area property. A #GtkEventControllerFocus has been
split off from #GtkEventcontrollerKey.
In GTK 3, #GtkEventController:widget was a construct-only property, so
a #GtkWidget was provided whenever constructing a #GtkEventController.
In GTK 4, #GtkEventController:widget is now read-only. Use
gtk_widget_add_controller() to add an event controller to a widget.
In GTK 3, widgets did not own their event controllers, and event
controllers did not own their widgets, so developers were responsible
for manually keeping event controllers alive for the lifetime of their
associated widgets. In GTK 4, widgets own their event controllers.
gtk_widget_add_controller() takes ownership of the event controller, so
there is no longer any need to store a reference to the event controller
after it has been added to a widget.
Although not normally needed, an event controller could be removed from
a widget in GTK 3 by destroying the event controller with g_object_unref().
In GTK 4, you must use gtk_widget_remove_controller().
### Focus handling changes
The semantics of the #GtkWidget:can-focus property have changed.
@@ -751,7 +861,8 @@ to get it.
The ::size-allocate signal has been removed, since it is easy
to misuse. If you need to learn about sizing changes of custom
drawing widgets, use the #GtkDrawingArea::resize or #GtkGLArea::resize
signals.
signals. If you want to track the size of toplevel windows, use
property notification for #GtkWindow:default-width and #GtkWindow:default-height.
### Switch to GtkWidget's children APIs
@@ -968,6 +1079,11 @@ that wants to override the default handling, you can provide an
implementation of the default.activate action in your widgets' action
groups.
### Stop using gtk_widget_grab_default()
The function gtk_widget_grab_default() has been removed. If you need
to mark a widget as default, use gtk_window_set_default_widget() directly.
### Stop setting ::has-default and ::has-focus in .ui files
The special handling for the ::has-default and ::has-focus properties
@@ -1062,7 +1178,7 @@ to start a drag manually, call gdk_drag_begin().
The ::drag-data-get signal has been replaced by the #GtkDragSource::prepare
signal, which returns a #GdkContentProvider for the drag operation.
The destination-side Drag-and-Drop apis in GTK 4 have also been changed
The destination-side Drag-and-Drop API in GTK 4 have also been changed
to use an event controller, #GtkDropTarget. Instead of calling
gtk_drag_dest_set() and connecting to #GtkWidget signals, you create
a #GtkDropTarget object, attach it to the widget with
@@ -1157,6 +1273,11 @@ shows a #GtkFileChooserNative dialog when clicked; once the file selection
has completed, you can update the label of the #GtkButton with the selected
file.
### Adapt to changed GtkSettings properties
In GTK 3 the #GtkSettings:gtk-cursor-aspect-ratio property of #GtkSettings was
a float. In GTK 4 this has been changed to a double.
## Changes to consider after the switch
GTK 4 has a number of new features that you may want to take
+4 -4
View File
@@ -97,11 +97,11 @@ the question you have, this list is a good place to start.
#define N_(x) x
#define C_(ctx,x) pgettext (ctx, x)
You use N_() (N stands for no-op) to mark a string for translation in
You use `N_()` (N stands for no-op) to mark a string for translation in
a location where a function call to gettext() is not allowed, such as
in an array initializer. You eventually have to call gettext() on the
string to actually fetch the translation. _() both marks the string for
translation and actually translates it. The C_() macro (C stands for
string to actually fetch the translation. `_()` both marks the string for
translation and actually translates it. The `C_()` macro (C stands for
context) adds an additional context to the string that is marked for
translation, which can help to disambiguate short strings that might
need different translations in different parts of your program.
@@ -190,7 +190,7 @@ the question you have, this list is a good place to start.
encode string literals in UTF-8 by using octal or hexadecimal escapes
like `\212` or `\xa8` to encode each byte. This is portable, but
modifying the escaped strings is not very convenient. Be careful when
mixing hexadecimal escapes with ordinary text; `"\xa8abcd" is a string
mixing hexadecimal escapes with ordinary text; `"\xa8abcd"` is a string
of length 1 !
- Runtime conversion
+7 -4
View File
@@ -182,6 +182,7 @@ G_GNUC_UNUSED static inline void
gdk_array(splice) (GdkArray *self,
gsize pos,
gsize removed,
gboolean stolen,
_T_ *additions,
gsize added)
{
@@ -192,8 +193,9 @@ gdk_array(splice) (GdkArray *self,
g_assert (pos + removed <= size);
remaining = size - pos - removed;
gdk_array(free_elements) (gdk_array(index) (self, pos),
gdk_array(index) (self, pos + removed));
if (!stolen)
gdk_array(free_elements) (gdk_array(index) (self, pos),
gdk_array(index) (self, pos + removed));
gdk_array(reserve) (self, size - removed + added);
@@ -225,9 +227,9 @@ gdk_array(set_size) (GdkArray *self,
{
gsize old_size = gdk_array(get_size) (self);
if (new_size > old_size)
gdk_array(splice) (self, old_size, 0, NULL, new_size - old_size);
gdk_array(splice) (self, old_size, 0, FALSE, NULL, new_size - old_size);
else
gdk_array(splice) (self, new_size, old_size - new_size, NULL, 0);
gdk_array(splice) (self, new_size, old_size - new_size, FALSE, NULL, 0);
}
G_GNUC_UNUSED static void
@@ -241,6 +243,7 @@ gdk_array(append) (GdkArray *self,
gdk_array(splice) (self,
gdk_array(get_size) (self),
0,
FALSE,
#ifdef GDK_ARRAY_BY_VALUE
value,
#else
+1 -11
View File
@@ -611,17 +611,7 @@ _gdk_device_set_associated_device (GdkDevice *device,
g_return_if_fail (GDK_IS_DEVICE (device));
g_return_if_fail (associated == NULL || GDK_IS_DEVICE (associated));
if (device->associated == associated)
return;
if (device->associated)
{
g_object_unref (device->associated);
device->associated = NULL;
}
if (associated)
device->associated = g_object_ref (associated);
g_set_object (&device->associated, associated);
}
/*
+1 -1
View File
@@ -280,7 +280,7 @@ gdk_draw_context_get_surface (GdkDrawContext *context)
* implementation must use gdk_draw_context_get_frame_region() to query the
* region that must be drawn.
*
* When using GTK+, the widget system automatically places calls to
* When using GTK, the widget system automatically places calls to
* gdk_draw_context_begin_frame() and gdk_draw_context_end_frame() via the
* use of #GskRenderers, so application code does not need to call these
* functions explicitly.
+1 -1
View File
@@ -12,7 +12,7 @@
GType
@enum_name@_get_type (void)
{
static volatile gsize g_define_type_id__volatile = 0;
static gsize g_define_type_id__volatile = 0;
if (g_once_init_enter (&g_define_type_id__volatile))
{
+19 -3
View File
@@ -210,7 +210,7 @@ gdk_event_init (GdkEvent *self)
GType
gdk_event_get_type (void)
{
static volatile gsize event_type__volatile;
static gsize event_type__volatile;
if (g_once_init_enter (&event_type__volatile))
{
@@ -374,7 +374,7 @@ static GType gdk_event_types[GDK_EVENT_LAST];
GType \
type_name ## _get_type (void) \
{ \
static volatile gsize gdk_define_event_type_id__volatile; \
static gsize gdk_define_event_type_id__volatile; \
if (g_once_init_enter (&gdk_define_event_type_id__volatile)) \
{ \
GType gdk_define_event_type_id = \
@@ -452,7 +452,7 @@ gdk_event_init_types_once (void)
void
gdk_event_init_types (void)
{
static volatile gsize event_types__volatile;
static gsize event_types__volatile;
if (g_once_init_enter (&event_types__volatile))
{
@@ -1138,6 +1138,22 @@ gdk_event_get_axes (GdkEvent *event,
return GDK_EVENT_GET_CLASS (event)->get_axes (event, axes, n_axes);
}
double *
gdk_event_dup_axes (GdkEvent *event)
{
double *axes;
guint n_axes;
if (gdk_event_get_axes (event, &axes, &n_axes))
{
double *axes_copy = g_memdup (axes, n_axes * sizeof (double));
return axes_copy;
}
return NULL;
}
/**
* gdk_event_get_event_type:
* @event: a #GdkEvent
+2
View File
@@ -603,6 +603,8 @@ void _gdk_event_queue_handle_motion_compression (GdkDisplay *display);
void gdk_event_queue_handle_scroll_compression (GdkDisplay *display);
void _gdk_event_queue_flush (GdkDisplay *display);
double * gdk_event_dup_axes (GdkEvent *event);
G_END_DECLS
+3
View File
@@ -107,6 +107,9 @@ make_program (GdkGLContextProgram *program,
glLinkProgram (program->program);
glDetachShader (program->program, vertex_shader);
glDetachShader (program->program, fragment_shader);
glDeleteShader (vertex_shader);
glDeleteShader (fragment_shader);
+31
View File
@@ -30,6 +30,37 @@
* Popups are positioned relative to their parent surface.
* The GdkPopupLayout struct contains information that is
* necessary to do so.
*
* The positioning requires a negotiation with the windowing system,
* since it depends on external constraints, such as the position of
* the parent surface, and the screen dimensions.
*
* The basic ingredients are a rectangle on the parent surface,
* and the anchor on both that rectangle and the popup. The anchors
* specify a side or corner to place next to each other.
*
* ![Popup anchors](popup-anchors.png)
*
* For cases where placing the anchors next to each other would make
* the popup extend offscreen, the layout includes some hints for how
* to resolve this problem. The hints may suggest to flip the anchor
* position to the other side, or to 'slide' the popup along a side,
* or to resize it.
*
* ![Flipping popups](popup-flip.png)
*
* ![Sliding popups](popup-slide.png)
*
* These hints may be combined.
*
* Ultimatively, it is up to the windowing system to determine the position
* and size of the popup. You can learn about the result by calling
* gdk_popup_get_position_x(), gdk_popup_get_position_y(),
* gdk_popup_get_rect_anchor() and gdk_popup_get_surface_anchor() after the
* popup has been presented. This can be used to adjust the rendering. For
* example, GtkPopover changes its arrow position accordingly. But you have
* to be careful avoid changing the size of the popover, or it has to be
* presented again.
*/
struct _GdkPopupLayout
+5 -4
View File
@@ -436,9 +436,10 @@ gdk_seat_tool_removed (GdkSeat *seat,
}
GdkDeviceTool *
gdk_seat_get_tool (GdkSeat *seat,
guint64 serial,
guint64 hw_id)
gdk_seat_get_tool (GdkSeat *seat,
guint64 serial,
guint64 hw_id,
GdkDeviceToolType type)
{
GdkDeviceTool *match = NULL;
GList *tools, *l;
@@ -449,7 +450,7 @@ gdk_seat_get_tool (GdkSeat *seat,
{
GdkDeviceTool *tool = l->data;
if (tool->serial == serial && tool->hw_id == hw_id)
if (tool->serial == serial && tool->hw_id == hw_id && tool->type == type)
{
match = tool;
break;
+4 -8
View File
@@ -49,7 +49,7 @@ struct _GdkSeatDefaultPrivate
G_DEFINE_TYPE_WITH_PRIVATE (GdkSeatDefault, gdk_seat_default, GDK_TYPE_SEAT)
static void
gdk_seat_dispose (GObject *object)
gdk_seat_default_dispose (GObject *object)
{
GdkSeatDefault *seat = GDK_SEAT_DEFAULT (object);
GdkSeatDefaultPrivate *priv = gdk_seat_default_get_instance_private (seat);
@@ -79,11 +79,7 @@ gdk_seat_dispose (GObject *object)
g_object_unref (l->data);
}
if (priv->tools)
{
g_ptr_array_unref (priv->tools);
priv->tools = NULL;
}
g_clear_pointer (&priv->tools, g_ptr_array_unref);
g_list_free (priv->physical_pointers);
g_list_free (priv->physical_keyboards);
@@ -307,7 +303,7 @@ gdk_seat_default_class_init (GdkSeatDefaultClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkSeatClass *seat_class = GDK_SEAT_CLASS (klass);
object_class->dispose = gdk_seat_dispose;
object_class->dispose = gdk_seat_default_dispose;
seat_class->get_capabilities = gdk_seat_default_get_capabilities;
@@ -442,7 +438,7 @@ gdk_seat_default_remove_tool (GdkSeatDefault *seat,
priv = gdk_seat_default_get_instance_private (seat);
if (tool != gdk_seat_get_tool (GDK_SEAT (seat), tool->serial, tool->hw_id))
if (tool != gdk_seat_get_tool (GDK_SEAT (seat), tool->serial, tool->hw_id, tool->type))
return;
g_signal_emit_by_name (seat, "tool-removed", tool);
+4 -3
View File
@@ -75,9 +75,10 @@ void gdk_seat_tool_removed (GdkSeat *seat,
GdkDeviceTool *tool);
GdkDeviceTool *
gdk_seat_get_tool (GdkSeat *seat,
guint64 serial,
guint64 hw_id);
gdk_seat_get_tool (GdkSeat *seat,
guint64 serial,
guint64 hw_id,
GdkDeviceToolType type);
GdkGrabStatus gdk_seat_grab (GdkSeat *seat,
GdkSurface *surface,
+29 -6
View File
@@ -92,6 +92,7 @@ enum {
PROP_MAPPED,
PROP_WIDTH,
PROP_HEIGHT,
PROP_SCALE_FACTOR,
LAST_PROP
};
@@ -551,6 +552,13 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
0, G_MAXINT, 0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
properties[PROP_SCALE_FACTOR] =
g_param_spec_int ("scale-factor",
P_("Scale factor"),
P_("Scale factor"),
1, G_MAXINT, 1,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, LAST_PROP, properties);
/**
@@ -782,6 +790,10 @@ gdk_surface_get_property (GObject *object,
g_value_set_int (value, surface->height);
break;
case PROP_SCALE_FACTOR:
g_value_set_int (value, gdk_surface_get_scale_factor (surface));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -2545,8 +2557,7 @@ gdk_surface_get_frame_clock (GdkSurface *surface)
* value can be used to determine whether to use a pixel resource
* with higher resolution data.
*
* The scale of a surface may change during runtime, if this happens
* a configure event will be sent to the toplevel surface.
* The scale of a surface may change during runtime.
*
* Returns: the scale factor
*/
@@ -2949,8 +2960,8 @@ gdk_surface_request_motion (GdkSurface *surface)
* gdk_surface_translate_coordinates:
* @from: the origin surface
* @to: the target surface
* @x: coordinates to translate
* @y: coordinates to translate
* @x: (inout): coordinates to translate
* @y: (inout): coordinates to translate
*
* Translates the given coordinates from being
* relative to the @from surface to being relative
@@ -2969,9 +2980,18 @@ gdk_surface_translate_coordinates (GdkSurface *from,
double *x,
double *y)
{
double in_x, in_y, out_x, out_y;
int x1, y1, x2, y2;
GdkSurface *f, *t;
g_return_val_if_fail (GDK_IS_SURFACE (from), FALSE);
g_return_val_if_fail (GDK_IS_SURFACE (to), FALSE);
g_return_val_if_fail (x != NULL, FALSE);
g_return_val_if_fail (y != NULL, FALSE);
in_x = *x;
in_y = *y;
x1 = 0;
y1 = 0;
f = from;
@@ -2995,8 +3015,11 @@ gdk_surface_translate_coordinates (GdkSurface *from,
if (f != t)
return FALSE;
*x += x1 - x2;
*y += y1 - y2;
out_x = in_x + (x1 - x2);
out_y = in_y + (y1 - y2);
*x = out_x;
*y = out_y;
return TRUE;
}
+6 -6
View File
@@ -316,9 +316,9 @@ gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf)
* @resource_path: the path of the resource file
*
* Creates a new texture by loading an image from a resource.
* The file format is detected automatically, and can be any
* format that is supported by the gdk-pixbuf library, such as
* JPEG or PNG.
* The file format is detected automatically.
* The supported formats are PNG and JPEG, though more formats might be
* available.
*
* It is a fatal error if @resource_path does not specify a valid
* image resource and the program will abort if that happens.
@@ -352,9 +352,9 @@ gdk_texture_new_from_resource (const char *resource_path)
* @error: Return location for an error
*
* Creates a new texture by loading an image from a file.
* The file format is detected automatically, and can be any
* format that is supported by the gdk-pixbuf library, such as
* JPEG or PNG.
* The file format is detected automatically.
* The supported formats are PNG and JPEG, though more formats might be
* available.
*
* If %NULL is returned, then @error will be set.
*
+1 -1
View File
@@ -67,7 +67,7 @@ void gdk_toplevel_layout_set_fullscreen (GdkToplevelLayout *l
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_layout_get_maximized (GdkToplevelLayout *layout,
gboolean *maximize);
gboolean *maximized);
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_layout_get_fullscreen (GdkToplevelLayout *layout,
+23
View File
@@ -78,6 +78,14 @@
*/
#define GDK_VERSION_4_0 (G_ENCODE_VERSION (4, 0))
/**
* GDK_VERSION_4_2:
*
* A macro that evaluates to the 4.2 version of GDK, in a format
* that can be used by the C pre-processor.
*/
#define GDK_VERSION_4_2 (G_ENCODE_VERSION (4, 2))
/* evaluates to the current stable version; for development cycles,
* this means the next stable target, with a hard backstop to the
@@ -175,4 +183,19 @@
# define GDK_DEPRECATED_IN_4_0_FOR(f) _GDK_EXTERN
#endif
#if GDK_VERSION_MAX_ALLOWED < GDK_VERSION_4_2
# define GDK_AVAILABLE_IN_4_2 GDK_UNAVAILABLE(4, 2)
#else
# define GDK_AVAILABLE_IN_4_2 _GDK_EXTERN
#endif
#if GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_4_2
# define GDK_DEPRECATED_IN_4_2 GDK_DEPRECATED
# define GDK_DEPRECATED_IN_4_2_FOR(f) GDK_DEPRECATED_FOR(f)
#else
# define GDK_DEPRECATED_IN_4_2 _GDK_EXTERN
# define GDK_DEPRECATED_IN_4_2_FOR(f) _GDK_EXTERN
#endif
#endif /* __GDK_VERSION_MACROS_H__ */
+3 -1
View File
@@ -210,8 +210,10 @@ gdk_vulkan_strerror (VkResult result)
return "An unknown error has occurred; either the application has provided invalid input, or an implementation failure has occurred.";
#endif
#if VK_HEADER_VERSION >= 135
#if VK_HEADER_VERSION < 162
case VK_ERROR_INCOMPATIBLE_VERSION_KHR:
return "Acceleration structure serialized with version as the version information is not compatible with device.";
return "This error was removed by the Vulkan gods.";
#endif
case VK_THREAD_IDLE_KHR:
return "A deferred operation is not complete but there is currently no work for this thread to do at the time of this call.";
case VK_THREAD_DONE_KHR:
+6 -2
View File
@@ -38,6 +38,10 @@
#include "gdkmonitorprivate.h"
#include "gdksurfaceprivate.h"
#ifndef AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER
typedef NSString *CALayerContentsGravity;
#endif
@implementation GdkMacosWindow
-(BOOL)windowShouldClose:(id)sender
@@ -466,7 +470,7 @@
inTrackManualResize = YES;
mouse_location = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]];
mouse_location = convert_nspoint_to_screen (self, [self mouseLocationOutsideOfEventStream]);
mdx = initialResizeLocation.x - mouse_location.x;
mdy = initialResizeLocation.y - mouse_location.y;
@@ -588,7 +592,7 @@
}
initialResizeFrame = [self frame];
initialResizeLocation = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]];
initialResizeLocation = convert_nspoint_to_screen (self, [self mouseLocationOutsideOfEventStream]);
}
-(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
+4
View File
@@ -27,6 +27,10 @@
G_BEGIN_DECLS
#ifndef AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER
typedef NSString *NSPasteboardType;
#endif
#define GDK_TYPE_MACOS_CLIPBOARD (_gdk_macos_clipboard_get_type())
G_DECLARE_FINAL_TYPE (GdkMacosClipboard, _gdk_macos_clipboard, GDK, MACOS_CLIPBOARD, GdkClipboard)
+64 -16
View File
@@ -40,8 +40,56 @@ typedef struct
guint done : 1;
} WriteRequest;
enum {
TYPE_STRING,
TYPE_PBOARD,
TYPE_URL,
TYPE_FILE_URL,
TYPE_COLOR,
TYPE_TIFF,
TYPE_PNG,
TYPE_LAST
};
#define PTYPE(k) (get_pasteboard_type(TYPE_##k))
static NSPasteboardType pasteboard_types[TYPE_LAST];
G_DEFINE_TYPE (GdkMacosClipboard, _gdk_macos_clipboard, GDK_TYPE_CLIPBOARD)
static NSPasteboardType
get_pasteboard_type (int type)
{
static gsize initialized = FALSE;
g_assert (type >= 0);
g_assert (type < TYPE_LAST);
if (g_once_init_enter (&initialized))
{
pasteboard_types[TYPE_PNG] = NSPasteboardTypePNG;
pasteboard_types[TYPE_STRING] = NSPasteboardTypeString;
pasteboard_types[TYPE_TIFF] = NSPasteboardTypeTIFF;
pasteboard_types[TYPE_COLOR] = NSPasteboardTypeColor;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
pasteboard_types[TYPE_PBOARD] = NSStringPboardType;
G_GNUC_END_IGNORE_DEPRECATIONS
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER
pasteboard_types[TYPE_URL] = NSPasteboardTypeURL;
pasteboard_types[TYPE_FILE_URL] = NSPasteboardTypeFileURL;
#else
pasteboard_types[TYPE_URL] = [[NSString alloc] initWithUTF8String:"public.url"];
pasteboard_types[TYPE_FILE_URL] = [[NSString alloc] initWithUTF8String:"public.file-url"];
#endif
g_once_init_leave (&initialized, TRUE);
}
return pasteboard_types[type];
}
static void
write_request_free (WriteRequest *wr)
{
@@ -56,17 +104,17 @@ _gdk_macos_clipboard_from_ns_type (NSPasteboardType type)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if ([type isEqualToString:NSPasteboardTypeString] ||
[type isEqualToString:NSStringPboardType])
if ([type isEqualToString:PTYPE(STRING)] ||
[type isEqualToString:PTYPE(PBOARD)])
return g_intern_string ("text/plain;charset=utf-8");
else if ([type isEqualToString:NSPasteboardTypeURL] ||
[type isEqualToString:NSPasteboardTypeFileURL])
else if ([type isEqualToString:PTYPE(URL)] ||
[type isEqualToString:PTYPE(FILE_URL)])
return g_intern_string ("text/uri-list");
else if ([type isEqualToString:NSPasteboardTypeColor])
else if ([type isEqualToString:PTYPE(COLOR)])
return g_intern_string ("application/x-color");
else if ([type isEqualToString:NSPasteboardTypeTIFF])
else if ([type isEqualToString:PTYPE(TIFF)])
return g_intern_string ("image/tiff");
else if ([type isEqualToString:NSPasteboardTypePNG])
else if ([type isEqualToString:PTYPE(PNG)])
return g_intern_string ("image/png");
G_GNUC_END_IGNORE_DEPRECATIONS;
@@ -83,25 +131,25 @@ _gdk_macos_clipboard_to_ns_type (const char *mime_type,
if (g_strcmp0 (mime_type, "text/plain;charset=utf-8") == 0)
{
return NSPasteboardTypeString;
return PTYPE(STRING);
}
else if (g_strcmp0 (mime_type, "text/uri-list") == 0)
{
if (alternate)
*alternate = NSPasteboardTypeURL;
return NSPasteboardTypeFileURL;
*alternate = PTYPE(URL);
return PTYPE(FILE_URL);
}
else if (g_strcmp0 (mime_type, "application/x-color") == 0)
{
return NSPasteboardTypeColor;
return PTYPE(COLOR);
}
else if (g_strcmp0 (mime_type, "image/tiff") == 0)
{
return NSPasteboardTypeTIFF;
return PTYPE(TIFF);
}
else if (g_strcmp0 (mime_type, "image/png") == 0)
{
return NSPasteboardTypePNG;
return PTYPE(PNG);
}
return nil;
@@ -220,7 +268,7 @@ _gdk_macos_clipboard_read_async (GdkClipboard *clipboard,
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if ([[self->pasteboard types] containsObject:NSPasteboardTypeFileURL])
if ([[self->pasteboard types] containsObject:PTYPE(FILE_URL)])
{
GString *str = g_string_new (NULL);
NSArray *files = [self->pasteboard propertyListForType:NSFilenamesPboardType];
@@ -267,12 +315,12 @@ _gdk_macos_clipboard_read_async (GdkClipboard *clipboard,
}
else if (strcmp (mime_type, "image/tiff") == 0)
{
NSData *data = [self->pasteboard dataForType:NSPasteboardTypeTIFF];
NSData *data = [self->pasteboard dataForType:PTYPE(TIFF)];
stream = create_stream_from_nsdata (data);
}
else if (strcmp (mime_type, "image/png") == 0)
{
NSData *data = [self->pasteboard dataForType:NSPasteboardTypePNG];
NSData *data = [self->pasteboard dataForType:PTYPE(PNG)];
stream = create_stream_from_nsdata (data);
}
+47 -11
View File
@@ -28,6 +28,7 @@
#include "gdkmacosdisplay-private.h"
#include "gdkmacoskeymap-private.h"
#include "gdkmacossurface-private.h"
#include "gdkmacosseat-private.h"
#define GDK_MOD2_MASK (1 << 4)
#define GRIP_WIDTH 15
@@ -205,6 +206,9 @@ fill_button_event (GdkMacosDisplay *display,
GdkSeat *seat;
GdkEventType type;
GdkModifierType state;
GdkDevice *pointer = NULL;
GdkDeviceTool *tool = NULL;
double *axes = NULL;
g_assert (GDK_IS_MACOS_DISPLAY (display));
g_assert (GDK_IS_MACOS_SURFACE (surface));
@@ -241,16 +245,22 @@ fill_button_event (GdkMacosDisplay *display,
y < 0 || y > GDK_SURFACE (surface)->height))
return NULL;
if (([nsevent subtype] == NSEventSubtypeTabletPoint) &&
_gdk_macos_seat_get_tablet (GDK_MACOS_SEAT (seat), &pointer, &tool))
axes = _gdk_macos_seat_get_tablet_axes_from_nsevent (GDK_MACOS_SEAT (seat), nsevent);
else
pointer = gdk_seat_get_pointer (seat);
return gdk_button_event_new (type,
GDK_SURFACE (surface),
gdk_seat_get_pointer (seat),
NULL,
pointer,
tool,
get_time_from_ns_event (nsevent),
state,
get_mouse_button_from_ns_event (nsevent),
x,
y,
NULL);
axes);
}
static GdkEvent *
@@ -557,6 +567,9 @@ fill_motion_event (GdkMacosDisplay *display,
{
GdkSeat *seat;
GdkModifierType state;
GdkDevice *pointer = NULL;
GdkDeviceTool *tool = NULL;
double *axes = NULL;
g_assert (GDK_IS_MACOS_SURFACE (surface));
g_assert (nsevent != NULL);
@@ -566,14 +579,20 @@ fill_motion_event (GdkMacosDisplay *display,
state = get_keyboard_modifiers_from_ns_event (nsevent) |
_gdk_macos_display_get_current_mouse_modifiers (display);
if (([nsevent subtype] == NSEventSubtypeTabletPoint) &&
_gdk_macos_seat_get_tablet (GDK_MACOS_SEAT (seat), &pointer, &tool))
axes = _gdk_macos_seat_get_tablet_axes_from_nsevent (GDK_MACOS_SEAT (seat), nsevent);
else
pointer = gdk_seat_get_pointer (seat);
return gdk_motion_event_new (GDK_SURFACE (surface),
gdk_seat_get_pointer (seat),
NULL,
pointer,
tool,
get_time_from_ns_event (nsevent),
state,
x,
y,
NULL);
axes);
}
static GdkEvent *
@@ -700,7 +719,7 @@ get_surface_point_from_screen_point (GdkSurface *surface,
NSPoint point;
nswindow = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (surface));
point = [nswindow convertPointFromScreen:screen_point];
point = convert_nspoint_from_screen (nswindow, screen_point);
*x = point.x;
*y = surface->height - point.y;
@@ -762,7 +781,7 @@ get_surface_from_ns_event (GdkMacosDisplay *self,
GdkSurface *surface = NULL;
NSWindow *nswindow = [nsevent window];
if (nswindow)
if (GDK_IS_MACOS_WINDOW (nswindow))
{
GdkMacosBaseView *view;
NSPoint point, view_point;
@@ -821,7 +840,7 @@ get_surface_from_ns_event (GdkMacosDisplay *self,
}
else
{
*screen_point = [(GdkMacosWindow *)[nsevent window] convertPointToScreen:point];
*screen_point = convert_nspoint_to_screen ([nsevent window], point);
*x = point.x;
*y = surface->height - point.y;
}
@@ -974,11 +993,11 @@ find_surface_for_ns_event (GdkMacosDisplay *self,
g_assert (x != NULL);
g_assert (y != NULL);
view = (GdkMacosBaseView *)[[nsevent window] contentView];
if (!(surface = get_surface_from_ns_event (self, nsevent, &point, x, y)))
return NULL;
view = (GdkMacosBaseView *)[GDK_MACOS_SURFACE (surface)->window contentView];
_gdk_macos_display_from_display_coords (self, point.x, point.y, &x_tmp, &y_tmp);
switch ((int)[nsevent type])
@@ -1051,6 +1070,23 @@ _gdk_macos_display_translate (GdkMacosDisplay *self,
return NULL;
}
/* We need to register the proximity event from any point on the screen
* to properly register the devices
* FIXME: is there a better way to detect if a tablet has been plugged?
*/
if (event_type == NSEventTypeTabletProximity)
{
GdkSeat *seat = gdk_display_get_default_seat (GDK_DISPLAY (self));
_gdk_macos_seat_handle_tablet_tool_event (GDK_MACOS_SEAT (seat), nsevent);
/* FIXME: we might want to cache this proximity event and propagate it
* but proximity events in gdk work at a window level while on macos
* works at a screen level. For now we just skip them.
*/
return NULL;
}
if (!(surface = find_surface_for_ns_event (self, nsevent, &x, &y)))
return NULL;
+17
View File
@@ -547,6 +547,20 @@ _gdk_macos_display_surface_resigned_key (GdkMacosDisplay *self,
_gdk_macos_display_clear_sorting (self);
}
/* Raises a transient window.
*/
static void
raise_transient (GdkMacosSurface *surface)
{
GdkMacosSurface *parent_surface = GDK_MACOS_SURFACE (GDK_SURFACE (surface)->transient_for);
NSWindow *parent = _gdk_macos_surface_get_native (parent_surface);
NSWindow *window = _gdk_macos_surface_get_native (surface);
[parent removeChildWindow:window];
[parent addChildWindow:window ordered:NSWindowAbove];
}
void
_gdk_macos_display_surface_became_main (GdkMacosDisplay *self,
GdkMacosSurface *surface)
@@ -559,6 +573,9 @@ _gdk_macos_display_surface_became_main (GdkMacosDisplay *self,
g_queue_push_head_link (&self->main_surfaces, &surface->main);
if (GDK_SURFACE (surface)->transient_for)
raise_transient (surface);
_gdk_macos_display_clear_sorting (self);
}
+4
View File
@@ -145,6 +145,7 @@ GetSubpixelLayout (CGDirectDisplayID screen_id)
static char *
GetLocalizedName (NSScreen *screen)
{
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER
GDK_BEGIN_MACOS_ALLOC_POOL;
NSString *str;
@@ -158,6 +159,9 @@ GetLocalizedName (NSScreen *screen)
GDK_END_MACOS_ALLOC_POOL;
return g_steal_pointer (&name);
#else
return NULL;
#endif
}
static char *
+11
View File
@@ -23,6 +23,7 @@
#include <AppKit/AppKit.h>
#include "gdkmacosdisplay.h"
#include "gdkmacosseat.h"
#include "gdkseatprivate.h"
@@ -30,6 +31,16 @@ G_BEGIN_DECLS
GdkSeat *_gdk_macos_seat_new (GdkMacosDisplay *display);
void _gdk_macos_seat_handle_tablet_tool_event (GdkMacosSeat *seat,
NSEvent *nsevent);
gboolean _gdk_macos_seat_get_tablet (GdkMacosSeat *seat,
GdkDevice **device,
GdkDeviceTool **tool);
double *_gdk_macos_seat_get_tablet_axes_from_nsevent (GdkMacosSeat *seat,
NSEvent *nsevent);
G_END_DECLS
#endif /* __GDK_MACOS_SEAT_PRIVATE_H__ */
+585 -21
View File
@@ -1,5 +1,6 @@
/*
* Copyright © 2020 Red Hat, Inc.
* Copyright © 2021 Amazon.com, Inc. and its affiliates. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -22,42 +23,605 @@
#include <gdk/gdk.h>
#include "gdkdeviceprivate.h"
#include "gdkseatdefaultprivate.h"
#include "gdkdevicetoolprivate.h"
#include "gdkmacosdevice.h"
#include "gdkmacosseat-private.h"
typedef struct
{
NSUInteger device_id;
char *name;
GdkDevice *logical_device;
GdkDevice *stylus_device;
GdkSeat *seat;
GdkDeviceTool *current_tool;
int axis_indices[GDK_AXIS_LAST];
double axes[GDK_AXIS_LAST];
} GdkMacosTabletData;
struct _GdkMacosSeat
{
GdkSeat parent_instance;
GdkMacosDisplay *display;
GdkDevice *logical_pointer;
GdkDevice *logical_keyboard;
GdkMacosTabletData *current_tablet;
GPtrArray *tablets;
GPtrArray *tools;
};
struct _GdkMacosSeatClass
{
GdkSeatClass parent_class;
};
G_DEFINE_TYPE (GdkMacosSeat, gdk_macos_seat, GDK_TYPE_SEAT)
#define KEYBOARD_EVENTS (GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | \
GDK_FOCUS_CHANGE_MASK)
#define TOUCH_EVENTS (GDK_TOUCH_MASK)
#define POINTER_EVENTS (GDK_POINTER_MOTION_MASK | \
GDK_BUTTON_PRESS_MASK | \
GDK_BUTTON_RELEASE_MASK | \
GDK_SCROLL_MASK | GDK_SMOOTH_SCROLL_MASK | \
GDK_ENTER_NOTIFY_MASK | \
GDK_LEAVE_NOTIFY_MASK | \
GDK_PROXIMITY_IN_MASK | \
GDK_PROXIMITY_OUT_MASK)
static void
gdk_macos_tablet_data_free (gpointer user_data)
{
GdkMacosTabletData *tablet = user_data;
gdk_seat_device_removed (GDK_SEAT (tablet->seat), tablet->stylus_device);
gdk_seat_device_removed (GDK_SEAT (tablet->seat), tablet->logical_device);
_gdk_device_set_associated_device (tablet->logical_device, NULL);
_gdk_device_set_associated_device (tablet->stylus_device, NULL);
g_object_unref (tablet->logical_device);
g_object_unref (tablet->stylus_device);
g_free (tablet->name);
g_free (tablet);
}
static void
gdk_macos_seat_dispose (GObject *object)
{
GdkMacosSeat *self = GDK_MACOS_SEAT (object);
if (self->logical_pointer)
{
gdk_seat_device_removed (GDK_SEAT (self), self->logical_pointer);
g_clear_object (&self->logical_pointer);
}
if (self->logical_keyboard)
{
gdk_seat_device_removed (GDK_SEAT (self), self->logical_keyboard);
g_clear_object (&self->logical_pointer);
}
g_clear_pointer (&self->tablets, g_ptr_array_unref);
g_clear_pointer (&self->tools, g_ptr_array_unref);
G_OBJECT_CLASS (gdk_macos_seat_parent_class)->dispose (object);
}
static GdkSeatCapabilities
gdk_macos_seat_get_capabilities (GdkSeat *seat)
{
GdkMacosSeat *self = GDK_MACOS_SEAT (seat);
GdkSeatCapabilities caps = 0;
if (self->logical_pointer)
caps |= GDK_SEAT_CAPABILITY_POINTER;
if (self->logical_keyboard)
caps |= GDK_SEAT_CAPABILITY_KEYBOARD;
return caps;
}
static GdkGrabStatus
gdk_macos_seat_grab (GdkSeat *seat,
GdkSurface *surface,
GdkSeatCapabilities capabilities,
gboolean owner_events,
GdkCursor *cursor,
GdkEvent *event,
GdkSeatGrabPrepareFunc prepare_func,
gpointer prepare_func_data)
{
GdkMacosSeat *self = GDK_MACOS_SEAT (seat);
guint32 evtime = event ? gdk_event_get_time (event) : GDK_CURRENT_TIME;
GdkGrabStatus status = GDK_GRAB_SUCCESS;
gboolean was_visible;
was_visible = gdk_surface_get_mapped (surface);
if (prepare_func)
(prepare_func) (seat, surface, prepare_func_data);
if (!gdk_surface_get_mapped (surface))
{
g_critical ("Surface %p has not been mapped in GdkSeatGrabPrepareFunc",
surface);
return GDK_GRAB_NOT_VIEWABLE;
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if (capabilities & GDK_SEAT_CAPABILITY_ALL_POINTING)
{
/* ALL_POINTING spans 3 capabilities; get the mask for the ones we have */
GdkEventMask pointer_evmask = 0;
/* We let tablet styli take over the pointer cursor */
if (capabilities & (GDK_SEAT_CAPABILITY_POINTER |
GDK_SEAT_CAPABILITY_TABLET_STYLUS))
{
pointer_evmask |= POINTER_EVENTS;
}
if (capabilities & GDK_SEAT_CAPABILITY_TOUCH)
pointer_evmask |= TOUCH_EVENTS;
status = gdk_device_grab (self->logical_pointer, surface,
owner_events,
pointer_evmask, cursor,
evtime);
}
if (status == GDK_GRAB_SUCCESS &&
capabilities & GDK_SEAT_CAPABILITY_KEYBOARD)
{
status = gdk_device_grab (self->logical_keyboard, surface,
owner_events,
KEYBOARD_EVENTS, cursor,
evtime);
if (status != GDK_GRAB_SUCCESS)
{
if (capabilities & ~GDK_SEAT_CAPABILITY_KEYBOARD)
gdk_device_ungrab (self->logical_pointer, evtime);
}
}
if (status != GDK_GRAB_SUCCESS && !was_visible)
gdk_surface_hide (surface);
G_GNUC_END_IGNORE_DEPRECATIONS;
return status;
}
static void
gdk_macos_seat_ungrab (GdkSeat *seat)
{
GdkMacosSeat *self = GDK_MACOS_SEAT (seat);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gdk_device_ungrab (self->logical_pointer, GDK_CURRENT_TIME);
gdk_device_ungrab (self->logical_keyboard, GDK_CURRENT_TIME);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
static GdkDevice *
gdk_macos_seat_get_logical_device (GdkSeat *seat,
GdkSeatCapabilities capability)
{
GdkMacosSeat *self = GDK_MACOS_SEAT (seat);
/* There must be only one flag set */
switch ((guint) capability)
{
case GDK_SEAT_CAPABILITY_POINTER:
case GDK_SEAT_CAPABILITY_TOUCH:
return self->logical_pointer;
case GDK_SEAT_CAPABILITY_KEYBOARD:
return self->logical_keyboard;
default:
g_warning ("Unhandled capability %x", capability);
break;
}
return NULL;
}
static GList *
gdk_macos_seat_get_devices (GdkSeat *seat,
GdkSeatCapabilities capabilities)
{
GdkMacosSeat *self = GDK_MACOS_SEAT (seat);
GList *physical_devices = NULL;
if (self->logical_pointer && (capabilities & GDK_SEAT_CAPABILITY_POINTER))
physical_devices = g_list_prepend (physical_devices, self->logical_pointer);
if (self->logical_keyboard && (capabilities & GDK_SEAT_CAPABILITY_KEYBOARD))
physical_devices = g_list_prepend (physical_devices, self->logical_keyboard);
if (capabilities & GDK_SEAT_CAPABILITY_TABLET_STYLUS)
{
for (guint i = 0; i < self->tablets->len; i++)
{
GdkMacosTabletData *tablet = g_ptr_array_index (self->tablets, i);
physical_devices = g_list_prepend (physical_devices, tablet->stylus_device);
}
}
return physical_devices;
}
static GList *
gdk_macos_seat_get_tools (GdkSeat *seat)
{
GdkMacosSeat *self = GDK_MACOS_SEAT (seat);
GdkDeviceTool *tool;
GList *tools = NULL;
for (guint i = 0; i < self->tools->len; i++)
{
tool = g_ptr_array_index (self->tools, i);
tools = g_list_prepend (tools, tool);
}
return tools;
}
static void
gdk_macos_seat_class_init (GdkMacosSeatClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkSeatClass *seat_class = GDK_SEAT_CLASS (klass);
object_class->dispose = gdk_macos_seat_dispose;
seat_class->get_capabilities = gdk_macos_seat_get_capabilities;
seat_class->grab = gdk_macos_seat_grab;
seat_class->ungrab = gdk_macos_seat_ungrab;
seat_class->get_logical_device = gdk_macos_seat_get_logical_device;
seat_class->get_devices = gdk_macos_seat_get_devices;
seat_class->get_tools = gdk_macos_seat_get_tools;
}
static void
gdk_macos_seat_init (GdkMacosSeat *self)
{
self->tablets = g_ptr_array_new_with_free_func (gdk_macos_tablet_data_free);
self->tools = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
}
static void
init_devices (GdkMacosSeat *self)
{
/* pointer */
self->logical_pointer = g_object_new (GDK_TYPE_MACOS_DEVICE,
"name", "Core Pointer",
"source", GDK_SOURCE_MOUSE,
"has-cursor", TRUE,
"display", self->display,
"seat", self,
NULL);
/* keyboard */
self->logical_keyboard = g_object_new (GDK_TYPE_MACOS_DEVICE,
"name", "Core Keyboard",
"source", GDK_SOURCE_KEYBOARD,
"has-cursor", FALSE,
"display", self->display,
"seat", self,
NULL);
/* link both */
_gdk_device_set_associated_device (self->logical_pointer, self->logical_keyboard);
_gdk_device_set_associated_device (self->logical_keyboard, self->logical_pointer);
gdk_seat_device_added (GDK_SEAT (self), self->logical_pointer);
gdk_seat_device_added (GDK_SEAT (self), self->logical_keyboard);
}
GdkSeat *
_gdk_macos_seat_new (GdkMacosDisplay *display)
{
GdkDevice *core_keyboard;
GdkDevice *core_pointer;
GdkSeat *seat;
GdkMacosSeat *self;
g_return_val_if_fail (GDK_IS_MACOS_DISPLAY (display), NULL);
core_pointer = g_object_new (GDK_TYPE_MACOS_DEVICE,
"name", "Core Pointer",
"source", GDK_SOURCE_MOUSE,
"has-cursor", TRUE,
"display", display,
NULL);
core_keyboard = g_object_new (GDK_TYPE_MACOS_DEVICE,
"name", "Core Keyboard",
"source", GDK_SOURCE_KEYBOARD,
self = g_object_new (GDK_TYPE_MACOS_SEAT,
"display", display,
NULL);
self->display = display;
init_devices (self);
return g_steal_pointer (&self);
}
static GdkDeviceToolType
get_device_tool_type_from_nsevent (NSEvent *nsevent)
{
GdkDeviceToolType tool_type;
switch ([nsevent pointingDeviceType])
{
case NSPointingDeviceTypePen:
tool_type = GDK_DEVICE_TOOL_TYPE_PEN;
break;
case NSPointingDeviceTypeEraser:
tool_type = GDK_DEVICE_TOOL_TYPE_ERASER;
break;
case NSPointingDeviceTypeCursor:
tool_type = GDK_DEVICE_TOOL_TYPE_MOUSE;
break;
case NSPointingDeviceTypeUnknown:
default:
tool_type = GDK_DEVICE_TOOL_TYPE_UNKNOWN;
}
return tool_type;
}
static GdkAxisFlags
get_device_tool_axes_from_nsevent (NSEvent *nsevent)
{
/* TODO: do we need to be smarter about the capabilities? */
return GDK_AXIS_FLAG_XTILT | GDK_AXIS_FLAG_YTILT | GDK_AXIS_FLAG_PRESSURE |
GDK_AXIS_FLAG_ROTATION;
}
static GdkMacosTabletData *
create_tablet_data_from_nsevent (GdkMacosSeat *self,
NSEvent *nsevent)
{
GdkMacosTabletData *tablet;
GdkDisplay *display = gdk_seat_get_display (GDK_SEAT (self));
GdkDevice *logical_device, *stylus_device;
char *logical_name;
char *vid, *pid;
tablet = g_new0 (GdkMacosTabletData, 1);
tablet->seat = GDK_SEAT (self);
tablet->device_id = [nsevent deviceID];
/* FIXME: find a better name */
tablet->name = g_strdup_printf ("Tablet %lu", [nsevent deviceID]);
vid = g_strdup_printf ("%.4lx", [nsevent vendorID]);
pid = g_strdup_printf ("%.4lx", [nsevent tabletID]);
logical_name = g_strdup_printf ("Logical pointer for %s", tablet->name);
logical_device = g_object_new (GDK_TYPE_MACOS_DEVICE,
"name", logical_name,
"source", GDK_SOURCE_MOUSE,
"has-cursor", TRUE,
"display", display,
"seat", self,
NULL);
stylus_device = g_object_new (GDK_TYPE_MACOS_DEVICE,
"name", tablet->name,
"source", GDK_SOURCE_PEN,
"has-cursor", FALSE,
"display", display,
"seat", self,
"vendor-id", vid,
"product-id", pid,
NULL);
_gdk_device_set_associated_device (GDK_DEVICE (core_pointer),
GDK_DEVICE (core_keyboard));
_gdk_device_set_associated_device (GDK_DEVICE (core_keyboard),
GDK_DEVICE (core_pointer));
tablet->logical_device = logical_device;
tablet->stylus_device = stylus_device;
seat = gdk_seat_default_new_for_logical_pair (core_pointer, core_keyboard);
_gdk_device_set_associated_device (logical_device, self->logical_keyboard);
_gdk_device_set_associated_device (stylus_device, logical_device);
g_object_unref (core_pointer);
g_object_unref (core_keyboard);
gdk_seat_device_added (GDK_SEAT (self), logical_device);
gdk_seat_device_added (GDK_SEAT (self), stylus_device);
return g_steal_pointer (&seat);
g_free (logical_name);
g_free (vid);
g_free (pid);
return tablet;
}
static GdkMacosTabletData *
get_tablet_data_from_nsevent (GdkMacosSeat *self,
NSEvent *nsevent)
{
GdkMacosTabletData *tablet = NULL;
for (guint i = 0; i < self->tablets->len; i++)
{
GdkMacosTabletData *t = g_ptr_array_index (self->tablets, i);
if (t->device_id == [nsevent deviceID])
{
tablet = t;
break;
}
}
if (!tablet)
tablet = create_tablet_data_from_nsevent (self, nsevent);
return tablet;
}
static void
device_tablet_clone_tool_axes (GdkMacosTabletData *tablet,
GdkDeviceTool *tool)
{
int axis_pos;
g_object_freeze_notify (G_OBJECT (tablet->stylus_device));
_gdk_device_reset_axes (tablet->stylus_device);
_gdk_device_add_axis (tablet->stylus_device, GDK_AXIS_X, 0, 0, 0);
_gdk_device_add_axis (tablet->stylus_device, GDK_AXIS_Y, 0, 0, 0);
if (tool->tool_axes & (GDK_AXIS_FLAG_XTILT | GDK_AXIS_FLAG_YTILT))
{
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
GDK_AXIS_XTILT, -1.0, 1.0, 0);
tablet->axis_indices[GDK_AXIS_XTILT] = axis_pos;
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
GDK_AXIS_YTILT, -1.0, 1.0, 0);
tablet->axis_indices[GDK_AXIS_YTILT] = axis_pos;
}
if (tool->tool_axes & GDK_AXIS_FLAG_PRESSURE)
{
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
GDK_AXIS_PRESSURE, 0.0, 1.0, 0);
tablet->axis_indices[GDK_AXIS_PRESSURE] = axis_pos;
}
if (tool->tool_axes & GDK_AXIS_FLAG_ROTATION)
{
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
GDK_AXIS_ROTATION, 0.0, 1.0, 0);
tablet->axis_indices[GDK_AXIS_ROTATION] = axis_pos;
}
g_object_thaw_notify (G_OBJECT (tablet->stylus_device));
}
static void
mimic_device_axes (GdkDevice *logical,
GdkDevice *physical)
{
double axis_min, axis_max, axis_resolution;
GdkAxisUse axis_use;
int axis_count;
g_object_freeze_notify (G_OBJECT (logical));
_gdk_device_reset_axes (logical);
axis_count = gdk_device_get_n_axes (physical);
for (int i = 0; i < axis_count; i++)
{
_gdk_device_get_axis_info (physical, i, &axis_use, &axis_min,
&axis_max, &axis_resolution);
_gdk_device_add_axis (logical, axis_use, axis_min,
axis_max, axis_resolution);
}
g_object_thaw_notify (G_OBJECT (logical));
}
void
_gdk_macos_seat_handle_tablet_tool_event (GdkMacosSeat *seat,
NSEvent *nsevent)
{
GdkDeviceToolType tool_type;
GdkMacosTabletData *tablet;
GdkDeviceTool *tool;
g_return_if_fail (GDK_IS_MACOS_SEAT (seat));
g_return_if_fail (nsevent != NULL);
tablet = get_tablet_data_from_nsevent (seat, nsevent);
tool_type = get_device_tool_type_from_nsevent (nsevent);
if (tool_type == GDK_DEVICE_TOOL_TYPE_UNKNOWN)
{
g_warning ("Unknown device tool detected");
return;
}
tool = gdk_seat_get_tool (GDK_SEAT (seat), [nsevent tabletID], [nsevent deviceID], tool_type);
if ([nsevent isEnteringProximity])
{
if (!tool)
{
tool = gdk_device_tool_new ([nsevent tabletID], [nsevent vendorID], tool_type,
get_device_tool_axes_from_nsevent (nsevent));
g_ptr_array_add (seat->tools, tool);
}
gdk_device_update_tool (tablet->stylus_device, tool);
tablet->current_tool = tool;
device_tablet_clone_tool_axes (tablet, tool);
mimic_device_axes (tablet->logical_device, tablet->stylus_device);
seat->current_tablet = tablet;
}
else
{
gdk_device_update_tool (tablet->stylus_device, NULL);
tablet->current_tool = NULL;
seat->current_tablet = NULL;
}
}
gboolean
_gdk_macos_seat_get_tablet (GdkMacosSeat *seat,
GdkDevice **logical_device,
GdkDeviceTool **tool)
{
g_return_val_if_fail (GDK_IS_MACOS_SEAT (seat), FALSE);
if (!seat->current_tablet)
return FALSE;
*logical_device = seat->current_tablet->logical_device;
*tool = seat->current_tablet->current_tool;
return TRUE;
}
double *
_gdk_macos_seat_get_tablet_axes_from_nsevent (GdkMacosSeat *seat,
NSEvent *nsevent)
{
GdkMacosTabletData *tablet;
int axis_index;
g_return_val_if_fail (GDK_IS_MACOS_SEAT (seat), NULL);
g_return_val_if_fail (nsevent != NULL, NULL);
tablet = seat->current_tablet;
if (!tablet || !tablet->current_tool)
return NULL;
if (tablet->current_tool->tool_axes & (GDK_AXIS_FLAG_XTILT | GDK_AXIS_FLAG_YTILT))
{
axis_index = tablet->axis_indices[GDK_AXIS_XTILT];
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
[nsevent tilt].x, &tablet->axes[GDK_AXIS_XTILT]);
axis_index = tablet->axis_indices[GDK_AXIS_YTILT];
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
[nsevent tilt].y, &tablet->axes[GDK_AXIS_YTILT]);
}
if (tablet->current_tool->tool_axes & GDK_AXIS_FLAG_PRESSURE)
{
axis_index = tablet->axis_indices[GDK_AXIS_PRESSURE];
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
[nsevent pressure], &tablet->axes[GDK_AXIS_PRESSURE]);
}
if (tablet->current_tool->tool_axes & GDK_AXIS_FLAG_ROTATION)
{
axis_index = tablet->axis_indices[GDK_AXIS_ROTATION];
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
[nsevent rotation], &tablet->axes[GDK_AXIS_ROTATION]);
}
return g_memdup (tablet->axes,
sizeof (double) * GDK_AXIS_LAST);
}
+40
View File
@@ -0,0 +1,40 @@
/*
* Copyright © 2021 Amazon.com, Inc. and its affiliates. All Rights Reserved.
*
* 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/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#pragma once
#if !defined (__GDKMACOS_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/macos/gdkmacos.h> can be included directly."
#endif
#include <gdk/gdk.h>
G_BEGIN_DECLS
#define GDK_TYPE_MACOS_SEAT (gdk_macos_seat_get_type ())
#define GDK_MACOS_SEAT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_MACOS_SEAT, GdkMacosSeat))
#define GDK_IS_MACOS_SEAT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_MACOS_SEAT))
typedef struct _GdkMacosSeat GdkMacosSeat;
typedef struct _GdkMacosSeatClass GdkMacosSeatClass;
GDK_AVAILABLE_IN_ALL
GType gdk_macos_seat_get_type (void) G_GNUC_CONST;
G_END_DECLS
+1
View File
@@ -61,6 +61,7 @@ struct _GdkMacosSurface
gint64 pending_frame_counter;
guint did_initial_present : 1;
guint geometry_dirty : 1;
};
struct _GdkMacosSurfaceClass
+6
View File
@@ -150,6 +150,12 @@ _gdk_macos_surface_set_shadow (GdkMacosSurface *surface,
g_assert (GDK_IS_MACOS_SURFACE (self));
if (self->shadow_top == top &&
self->shadow_right == right &&
self->shadow_bottom == bottom &&
self->shadow_left == left)
return;
self->shadow_top = top;
self->shadow_right = right;
self->shadow_bottom = bottom;
+91 -11
View File
@@ -81,7 +81,7 @@ _gdk_macos_toplevel_surface_unmaximize (GdkMacosToplevelSurface *self)
[window zoom:window];
}
static gboolean
static void
_gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
GdkToplevelLayout *layout)
{
@@ -97,7 +97,7 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
GdkSurfaceHints mask;
NSWindowStyleMask style_mask;
gboolean maximize;
gboolean fullscreen
gboolean fullscreen;
g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (self));
g_assert (GDK_IS_MACOS_WINDOW (nswindow));
@@ -107,6 +107,7 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
style_mask = [nswindow styleMask];
monitor = gdk_display_get_monitor_at_surface (display, surface);
if (monitor)
{
GdkRectangle workarea;
@@ -158,13 +159,11 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
[nswindow setStyleMask:style_mask];
if (size.shadow.is_valid)
{
_gdk_macos_surface_set_shadow (GDK_MACOS_SURFACE (surface),
size.shadow.top,
size.shadow.right,
size.shadow.bottom,
size.shadow.left);
}
_gdk_macos_surface_set_shadow (GDK_MACOS_SURFACE (surface),
size.shadow.top,
size.shadow.right,
size.shadow.bottom,
size.shadow.left);
_gdk_macos_surface_set_geometry_hints (GDK_MACOS_SURFACE (self), &geometry, mask);
gdk_surface_constrain_size (&geometry, mask, width, height, &width, &height);
@@ -230,8 +229,6 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
_gdk_macos_surface_show (GDK_MACOS_SURFACE (self));
GDK_MACOS_SURFACE (self)->did_initial_present = TRUE;
return TRUE;
}
static gboolean
@@ -373,6 +370,87 @@ _gdk_macos_toplevel_surface_hide (GdkSurface *surface)
GDK_SURFACE_CLASS (_gdk_macos_toplevel_surface_parent_class)->hide (surface);
}
static gboolean
_gdk_macos_toplevel_surface_compute_size (GdkSurface *surface)
{
GdkMacosToplevelSurface *self = (GdkMacosToplevelSurface *)surface;
NSWindow *nswindow = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self));
GdkToplevelSize size;
GdkDisplay *display;
GdkMonitor *monitor;
int bounds_width, bounds_height;
int width, height;
GdkGeometry geometry;
GdkSurfaceHints mask;
NSWindowStyleMask style_mask;
g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (self));
if (!GDK_MACOS_SURFACE (surface)->geometry_dirty)
return FALSE;
GDK_MACOS_SURFACE (surface)->geometry_dirty = FALSE;
display = gdk_surface_get_display (surface);
monitor = gdk_display_get_monitor_at_surface (display, surface);
style_mask = [nswindow styleMask];
if (monitor)
{
GdkRectangle workarea;
gdk_macos_monitor_get_workarea (monitor, &workarea);
bounds_width = workarea.width;
bounds_height = workarea.height;
}
else
{
bounds_width = G_MAXINT;
bounds_height = G_MAXINT;
}
gdk_toplevel_size_init (&size, bounds_width, bounds_height);
gdk_toplevel_notify_compute_size (GDK_TOPLEVEL (surface), &size);
g_warn_if_fail (size.width > 0);
g_warn_if_fail (size.height > 0);
width = size.width;
height = size.height;
if (style_mask & NSWindowStyleMaskResizable)
{
geometry.min_width = size.min_width;
geometry.min_height = size.min_height;
mask = GDK_HINT_MIN_SIZE;
}
else
{
geometry.max_width = geometry.min_width = width;
geometry.max_height = geometry.min_height = height;
mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE;
}
if (size.shadow.is_valid)
_gdk_macos_surface_set_shadow (GDK_MACOS_SURFACE (surface),
size.shadow.top,
size.shadow.right,
size.shadow.bottom,
size.shadow.left);
_gdk_macos_surface_set_geometry_hints (GDK_MACOS_SURFACE (self), &geometry, mask);
gdk_surface_constrain_size (&geometry, mask, width, height, &width, &height);
_gdk_macos_surface_resize (GDK_MACOS_SURFACE (self), width, height);
return FALSE;
}
static void
_gdk_macos_toplevel_surface_request_layout (GdkSurface *surface)
{
GDK_MACOS_SURFACE (surface)->geometry_dirty = TRUE;
}
static void
_gdk_macos_toplevel_surface_destroy (GdkSurface *surface,
gboolean foreign_destroy)
@@ -506,6 +584,8 @@ _gdk_macos_toplevel_surface_class_init (GdkMacosToplevelSurfaceClass *klass)
surface_class->destroy = _gdk_macos_toplevel_surface_destroy;
surface_class->hide = _gdk_macos_toplevel_surface_hide;
surface_class->compute_size = _gdk_macos_toplevel_surface_compute_size;
surface_class->request_layout = _gdk_macos_toplevel_surface_request_layout;
gdk_toplevel_install_properties (object_class, LAST_PROP);
}
+31
View File
@@ -40,5 +40,36 @@ struct _GdkPoint
};
typedef struct _GdkPoint GdkPoint;
static inline NSPoint
convert_nspoint_from_screen (NSWindow *window,
NSPoint point)
{
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER
return [window convertPointFromScreen:point];
#else
/* Apple documentation claims that convertPointFromScreen is available
* on 10.12+. However, that doesn't seem to be the case when using it.
* Instead, we'll just use it on modern 10.15 systems and fallback to
* converting using rects on older systems.
*/
return [window convertRectFromScreen:NSMakeRect (point.x, point.y, 0, 0)].origin;
#endif
}
static inline NSPoint
convert_nspoint_to_screen (NSWindow *window,
NSPoint point)
{
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER
return [window convertPointToScreen:point];
#else
/* Apple documentation claims that convertPointToScreen is available
* on 10.12+. However, that doesn't seem to be the case when using it.
* Instead, we'll just use it on modern 10.15 systems and fallback to
* converting using rects on older systems.
*/
return [window convertRectToScreen:NSMakeRect (point.x, point.y, 0, 0)].origin;
#endif
}
#endif /* __GDK_MACOS_UTILS_PRIVATE_H__ */
+1
View File
@@ -33,6 +33,7 @@ gdk_macos_public_headers = files([
'gdkmacosglcontext.h',
'gdkmacoskeymap.h',
'gdkmacosmonitor.h',
'gdkmacosseat.h',
'gdkmacossurface.h',
])
+70 -11
View File
@@ -2357,6 +2357,9 @@ touch_handle_down (void *data,
_gdk_wayland_display_update_serial (display, serial);
if (!wl_surface)
return;
touch = gdk_wayland_seat_add_touch (seat, id, wl_surface);
touch->x = wl_fixed_to_double (x);
touch->y = wl_fixed_to_double (y);
@@ -2404,6 +2407,9 @@ touch_handle_up (void *data,
_gdk_wayland_display_update_serial (display, serial);
touch = gdk_wayland_seat_get_touch (seat, id);
if (!touch)
return;
event = gdk_touch_event_new (GDK_TOUCH_END,
GDK_SLOT_TO_EVENT_SEQUENCE (touch->id),
touch->surface,
@@ -2442,6 +2448,9 @@ touch_handle_motion (void *data,
GdkEvent *event;
touch = gdk_wayland_seat_get_touch (seat, id);
if (!touch)
return;
touch->x = wl_fixed_to_double (x);
touch->y = wl_fixed_to_double (y);
@@ -3381,9 +3390,14 @@ tablet_tool_handle_proximity_in (void *data,
GdkWaylandTabletData *tablet = zwp_tablet_v2_get_user_data (wp_tablet);
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
GdkSurface *surface = wl_surface_get_user_data (wsurface);
GdkSurface *surface;
GdkEvent *event;
if (!wsurface)
return;
surface = wl_surface_get_user_data (wsurface);
if (!surface)
return;
if (!GDK_IS_SURFACE (surface))
@@ -3427,6 +3441,9 @@ tablet_tool_handle_proximity_out (void *data,
GdkWaylandTabletData *tablet = tool->current_tablet;
GdkEvent *event;
if (!tablet)
return;
GDK_SEAT_NOTE (tool->seat, EVENTS,
g_message ("proximity out, seat %p, tool %d", tool->seat,
gdk_device_tool_get_tool_type (tool->tool)));
@@ -3490,7 +3507,7 @@ tablet_tool_handle_down (void *data,
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tool->seat);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
if (!tablet->pointer_info.focus)
if (!tablet || !tablet->pointer_info.focus)
return;
_gdk_wayland_display_update_serial (display_wayland, serial);
@@ -3507,7 +3524,7 @@ tablet_tool_handle_up (void *data,
GdkWaylandTabletToolData *tool = data;
GdkWaylandTabletData *tablet = tool->current_tablet;
if (!tablet->pointer_info.focus)
if (!tablet || !tablet->pointer_info.focus)
return;
tablet_create_button_event_frame (tablet, GDK_BUTTON_RELEASE, GDK_BUTTON_PRIMARY);
@@ -3524,6 +3541,9 @@ tablet_tool_handle_motion (void *data,
GdkWaylandTabletData *tablet = tool->current_tablet;
GdkEvent *event;
if (!tablet)
return;
tablet->pointer_info.surface_x = wl_fixed_to_double (sx);
tablet->pointer_info.surface_y = wl_fixed_to_double (sy);
@@ -3551,7 +3571,12 @@ tablet_tool_handle_pressure (void *data,
{
GdkWaylandTabletToolData *tool = data;
GdkWaylandTabletData *tablet = tool->current_tablet;
int axis_index = tablet->axis_indices[GDK_AXIS_PRESSURE];
int axis_index;
if (!tablet)
return;
axis_index = tablet->axis_indices[GDK_AXIS_PRESSURE];
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
pressure, &tablet->axes[GDK_AXIS_PRESSURE]);
@@ -3568,7 +3593,12 @@ tablet_tool_handle_distance (void *data,
{
GdkWaylandTabletToolData *tool = data;
GdkWaylandTabletData *tablet = tool->current_tablet;
int axis_index = tablet->axis_indices[GDK_AXIS_DISTANCE];
int axis_index;
if (!tablet)
return;
axis_index = tablet->axis_indices[GDK_AXIS_DISTANCE];
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
distance, &tablet->axes[GDK_AXIS_DISTANCE]);
@@ -3586,8 +3616,14 @@ tablet_tool_handle_tilt (void *data,
{
GdkWaylandTabletToolData *tool = data;
GdkWaylandTabletData *tablet = tool->current_tablet;
int xtilt_axis_index = tablet->axis_indices[GDK_AXIS_XTILT];
int ytilt_axis_index = tablet->axis_indices[GDK_AXIS_YTILT];
int xtilt_axis_index;
int ytilt_axis_index;
if (!tablet)
return;
xtilt_axis_index = tablet->axis_indices[GDK_AXIS_XTILT];
ytilt_axis_index = tablet->axis_indices[GDK_AXIS_YTILT];
_gdk_device_translate_axis (tablet->stylus_device, xtilt_axis_index,
wl_fixed_to_double (xtilt),
@@ -3614,7 +3650,7 @@ tablet_tool_handle_button (void *data,
GdkEventType evtype;
guint n_button;
if (!tablet->pointer_info.focus)
if (!tablet || !tablet->pointer_info.focus)
return;
tablet->pointer_info.press_serial = serial;
@@ -3645,7 +3681,12 @@ tablet_tool_handle_rotation (void *data,
{
GdkWaylandTabletToolData *tool = data;
GdkWaylandTabletData *tablet = tool->current_tablet;
int axis_index = tablet->axis_indices[GDK_AXIS_ROTATION];
int axis_index;
if (!tablet)
return;
axis_index = tablet->axis_indices[GDK_AXIS_ROTATION];
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
wl_fixed_to_double (degrees),
@@ -3664,7 +3705,12 @@ tablet_tool_handle_slider (void *data,
{
GdkWaylandTabletToolData *tool = data;
GdkWaylandTabletData *tablet = tool->current_tablet;
int axis_index = tablet->axis_indices[GDK_AXIS_SLIDER];
int axis_index;
if (!tablet)
return;
axis_index = tablet->axis_indices[GDK_AXIS_SLIDER];
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
position, &tablet->axes[GDK_AXIS_SLIDER]);
@@ -3682,9 +3728,14 @@ tablet_tool_handle_wheel (void *data,
{
GdkWaylandTabletToolData *tool = data;
GdkWaylandTabletData *tablet = tool->current_tablet;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
GdkWaylandSeat *seat;
GdkEvent *event;
if (!tablet)
return;
seat = GDK_WAYLAND_SEAT (tablet->seat);
GDK_SEAT_NOTE (seat, EVENTS,
g_message ("tablet tool %d wheel %d/%d",
gdk_device_tool_get_tool_type (tool->tool), degrees, clicks));
@@ -3724,6 +3775,9 @@ tablet_tool_handle_frame (void *data,
GdkWaylandTabletData *tablet = tool->current_tablet;
GdkEvent *frame_event;
if (!tablet)
return;
GDK_SEAT_NOTE (tablet->seat, EVENTS,
g_message ("tablet frame, time %d", time));
@@ -4312,6 +4366,9 @@ pointer_surface_update_scale (GdkDevice *device)
return;
}
if (!pointer->pointer_surface_outputs)
return;
scale = 1;
for (l = pointer->pointer_surface_outputs; l != NULL; l = l->next)
{
@@ -4319,6 +4376,8 @@ pointer_surface_update_scale (GdkDevice *device)
scale = MAX (scale, output_scale);
}
if (pointer->current_output_scale == scale)
return;
pointer->current_output_scale = scale;
gdk_wayland_device_update_surface_cursor (device);
+9 -6
View File
@@ -94,7 +94,7 @@
#define MIN_SYSTEM_BELL_DELAY_MS 20
#define GTK_SHELL1_VERSION 3
#define GTK_SHELL1_VERSION 4
#define OUTPUT_VERSION_WITH_DONE 2
#define NO_XDG_OUTPUT_DONE_SINCE_VERSION 3
@@ -1350,21 +1350,23 @@ _gdk_wayland_display_create_shm_surface (GdkWaylandDisplay *display,
data->buffer = NULL;
data->scale = scale;
stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width*scale);
stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width * scale);
data->pool = create_shm_pool (display->shm,
height*scale*stride,
height * scale * stride,
&data->buf_length,
&data->buf);
if (G_UNLIKELY (data->pool == NULL))
g_error ("Unable to create shared memory pool");
surface = cairo_image_surface_create_for_data (data->buf,
CAIRO_FORMAT_ARGB32,
width*scale,
height*scale,
width * scale,
height * scale,
stride);
data->buffer = wl_shm_pool_create_buffer (data->pool, 0,
width*scale, height*scale,
width * scale, height * scale,
stride, WL_SHM_FORMAT_ARGB8888);
cairo_surface_set_user_data (surface, &gdk_wayland_shm_surface_cairo_key,
@@ -1836,6 +1838,7 @@ settings_portal_changed (GDBusProxy *proxy,
char *a = g_variant_print (value, FALSE);
g_debug ("Using changed portal setting %s %s: %s", namespace, name, a);
g_free (a);
entry->valid = TRUE;
apply_portal_setting (entry, value, display);
gdk_display_setting_changed (display, entry->setting);
}
+37 -42
View File
@@ -242,14 +242,22 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "swap buffers");
if (display_wayland->have_egl_swap_buffers_with_damage)
{
EGLint stack_rects[4 * 4]; /* 4 rects */
EGLint *heap_rects = NULL;
int i, j, n_rects = cairo_region_num_rectangles (painted);
EGLint *rects = g_new (EGLint, n_rects * 4);
cairo_rectangle_int_t rect;
int surface_height = gdk_surface_get_height (surface);
int scale = gdk_surface_get_scale_factor (surface);
EGLint *rects;
if (n_rects < G_N_ELEMENTS (stack_rects) / 4)
rects = (EGLint *)&stack_rects;
else
heap_rects = rects = g_new (EGLint, n_rects * 4);
for (i = 0, j = 0; i < n_rects; i++)
{
cairo_rectangle_int_t rect;
cairo_region_get_rectangle (painted, i, &rect);
rects[j++] = rect.x * scale;
rects[j++] = (surface_height - rect.height - rect.y) * scale;
@@ -257,7 +265,7 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
rects[j++] = rect.height * scale;
}
eglSwapBuffersWithDamageEXT (display_wayland->egl_display, egl_surface, rects, n_rects);
g_free (rects);
g_free (heap_rects);
}
else
eglSwapBuffers (display_wayland->egl_display, egl_surface);
@@ -293,27 +301,27 @@ gdk_wayland_get_display (GdkWaylandDisplay *display_wayland)
if (epoxy_has_egl_extension (NULL, "EGL_KHR_platform_base"))
{
PFNEGLGETPLATFORMDISPLAYPROC getPlatformDisplay =
(void *) eglGetProcAddress ("eglGetPlatformDisplay");
(void *) eglGetProcAddress ("eglGetPlatformDisplay");
if (getPlatformDisplay)
dpy = getPlatformDisplay (EGL_PLATFORM_WAYLAND_EXT,
display_wayland->wl_display,
NULL);
dpy = getPlatformDisplay (EGL_PLATFORM_WAYLAND_EXT,
display_wayland->wl_display,
NULL);
if (dpy)
return dpy;
return dpy;
}
if (epoxy_has_egl_extension (NULL, "EGL_EXT_platform_base"))
{
PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay =
(void *) eglGetProcAddress ("eglGetPlatformDisplayEXT");
(void *) eglGetProcAddress ("eglGetPlatformDisplayEXT");
if (getPlatformDisplay)
dpy = getPlatformDisplay (EGL_PLATFORM_WAYLAND_EXT,
display_wayland->wl_display,
NULL);
dpy = getPlatformDisplay (EGL_PLATFORM_WAYLAND_EXT,
display_wayland->wl_display,
NULL);
if (dpy)
return dpy;
return dpy;
}
return eglGetDisplay ((EGLNativeDisplayType) display_wayland->wl_display);
@@ -386,7 +394,7 @@ find_eglconfig_for_surface (GdkSurface *surface,
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
EGLint attrs[MAX_EGL_ATTRS];
EGLint count;
EGLConfig *configs;
EGLConfig config;
int i = 0;
attrs[i++] = EGL_SURFACE_TYPE;
@@ -407,39 +415,26 @@ find_eglconfig_for_surface (GdkSurface *surface,
attrs[i++] = EGL_NONE;
g_assert (i < MAX_EGL_ATTRS);
if (!eglChooseConfig (display_wayland->egl_display, attrs, NULL, 0, &count) || count < 1)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
_("No available configurations for the given pixel format"));
return FALSE;
}
configs = g_new (EGLConfig, count);
if (!eglChooseConfig (display_wayland->egl_display, attrs, configs, count, &count) || count < 1)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
_("No available configurations for the given pixel format"));
return FALSE;
}
/* Pick first valid configuration i guess? */
if (!eglChooseConfig (display_wayland->egl_display, attrs, &config, 1, &count) || count < 1)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
_("No available configurations for the given pixel format"));
return FALSE;
}
if (egl_config_out != NULL)
*egl_config_out = configs[0];
g_free (configs);
g_assert (egl_config_out);
*egl_config_out = config;
return TRUE;
}
GdkGLContext *
gdk_wayland_surface_create_gl_context (GdkSurface *surface,
gboolean attached,
GdkGLContext *share,
GError **error)
gboolean attached,
GdkGLContext *share,
GError **error)
{
GdkDisplay *display = gdk_surface_get_display (surface);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
@@ -526,10 +521,10 @@ gdk_wayland_display_make_gl_context_current (GdkDisplay *display,
else
{
if (display_wayland->have_egl_surfaceless_context)
egl_surface = EGL_NO_SURFACE;
egl_surface = EGL_NO_SURFACE;
else
egl_surface = gdk_wayland_surface_get_dummy_egl_surface (surface,
context_wayland->egl_config);
egl_surface = gdk_wayland_surface_get_dummy_egl_surface (surface,
context_wayland->egl_config);
}
if (!eglMakeCurrent (display_wayland->egl_display, egl_surface,
+36 -4
View File
@@ -389,10 +389,13 @@ gdk_wayland_surface_update_size (GdkSurface *surface,
int scale)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
gboolean width_changed, height_changed, scale_changed;
if ((surface->width == width) &&
(surface->height == height) &&
(impl->scale == scale))
width_changed = surface->width != width;
height_changed = surface->height != height;
scale_changed = impl->scale != scale;
if (!width_changed && !height_changed && !scale_changed)
return;
surface->width = width;
@@ -405,6 +408,13 @@ gdk_wayland_surface_update_size (GdkSurface *surface,
wl_surface_set_buffer_scale (impl->display_server.wl_surface, scale);
gdk_surface_invalidate_rect (surface, NULL);
if (width_changed)
g_object_notify (G_OBJECT (surface), "width");
if (height_changed)
g_object_notify (G_OBJECT (surface), "height");
if (scale_changed)
g_object_notify (G_OBJECT (surface), "scale-factor");
}
static const char *
@@ -2213,6 +2223,24 @@ gdk_wayland_toplevel_announce_csd (GdkToplevel *toplevel)
ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT);
}
void
gdk_wayland_toplevel_announce_ssd (GdkToplevel *toplevel)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SURFACE (toplevel)));
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (toplevel);
g_return_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel));
if (!display_wayland->server_decoration_manager)
return;
impl->display_server.server_decoration =
org_kde_kwin_server_decoration_manager_create (display_wayland->server_decoration_manager,
impl->display_server.wl_surface);
if (impl->display_server.server_decoration)
org_kde_kwin_server_decoration_request_mode (impl->display_server.server_decoration,
ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER);
}
gboolean
gdk_wayland_toplevel_inhibit_idle (GdkToplevel *toplevel)
{
@@ -2939,7 +2967,11 @@ gdk_wayland_surface_hide_surface (GdkSurface *surface)
if (impl->display_server.gtk_surface)
{
gtk_surface1_destroy (impl->display_server.gtk_surface);
if (display_wayland->gtk_shell_version >=
GTK_SURFACE1_RELEASE_SINCE_VERSION)
gtk_surface1_release (impl->display_server.gtk_surface);
else
gtk_surface1_destroy (impl->display_server.gtk_surface);
impl->display_server.gtk_surface = NULL;
impl->application.was_set = FALSE;
}
+1
View File
@@ -33,6 +33,7 @@ void gdk_wayland_toplevel_set_dbus_properties (GdkTopl
const char *unique_bus_name);
void gdk_wayland_toplevel_announce_csd (GdkToplevel *toplevel);
void gdk_wayland_toplevel_announce_ssd (GdkToplevel *toplevel);
gboolean gdk_wayland_toplevel_inhibit_idle (GdkToplevel *toplevel);
void gdk_wayland_toplevel_uninhibit_idle (GdkToplevel *toplevel);
+5 -2
View File
@@ -1,6 +1,6 @@
<protocol name="gtk">
<interface name="gtk_shell1" version="3">
<interface name="gtk_shell1" version="4">
<description summary="gtk specific extensions">
gtk_shell is a protocol extension providing additional features for
clients implementing it.
@@ -35,7 +35,7 @@
</request>
</interface>
<interface name="gtk_surface1" version="3">
<interface name="gtk_surface1" version="4">
<request name="set_dbus_properties">
<arg name="application_id" type="string" allow-null="true"/>
<arg name="app_menu_path" type="string" allow-null="true"/>
@@ -82,6 +82,9 @@
<request name="request_focus" since="3">
<arg name="startup_id" type="string" allow-null="true"/>
</request>
<!-- Version 4 additions -->
<request name="release" type="destructor" since="4"/>
</interface>
</protocol>
+10 -76
View File
@@ -31,46 +31,6 @@
G_DEFINE_TYPE (GdkWin32CairoContext, gdk_win32_cairo_context, GDK_TYPE_CAIRO_CONTEXT)
static cairo_surface_t *
create_cairo_surface_for_layered_window (GdkWin32Surface *impl,
int width,
int height,
int scale)
{
if (width > impl->dib_width ||
height > impl->dib_height)
{
cairo_surface_t *new_cache;
impl->dib_width = MAX (impl->dib_width, MAX (width, 1));
impl->dib_height = MAX (impl->dib_height, MAX (height, 1));
/* Create larger cache surface, copy old cache surface over it */
new_cache = cairo_win32_surface_create_with_dib (CAIRO_FORMAT_ARGB32,
impl->dib_width,
impl->dib_height);
if (impl->cache_surface)
{
cairo_t *cr = cairo_create (new_cache);
cairo_set_source_surface (cr, impl->cache_surface, 0, 0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
cairo_destroy (cr);
cairo_surface_flush (new_cache);
cairo_surface_destroy (impl->cache_surface);
}
impl->cache_surface = new_cache;
cairo_surface_set_device_scale (impl->cache_surface,
scale,
scale);
}
return cairo_surface_reference (impl->cache_surface);
}
static cairo_surface_t *
create_cairo_surface_for_surface (GdkSurface *surface,
int scale)
@@ -114,22 +74,11 @@ gdk_win32_cairo_context_begin_frame (GdkDrawContext *draw_context,
width = MAX (width, 1);
height = MAX (height, 1);
if (self->layered)
self->window_surface = create_cairo_surface_for_layered_window (impl, width, height, scale);
else
self->window_surface = create_cairo_surface_for_surface (surface, scale);
self->window_surface = create_cairo_surface_for_surface (surface, scale);
if (self->layered ||
!self->double_buffered)
{
/* Layered windows paint on the window_surface (which is itself
* an in-memory cache that the window maintains, since layered windows
* do not support incremental redraws.
* Non-double-buffered windows paint on the window surface directly
* as well.
*/
self->paint_surface = cairo_surface_reference (self->window_surface);
}
if (!self->double_buffered)
/* Non-double-buffered windows paint on the window surface directly */
self->paint_surface = cairo_surface_reference (self->window_surface);
else
{
if (width > self->db_width ||
@@ -153,11 +102,10 @@ gdk_win32_cairo_context_begin_frame (GdkDrawContext *draw_context,
}
/* Clear the paint region.
* For non-double-buffered and for layered rendering we must
* clear it, otherwise semi-transparent pixels will "add up"
* with each repaint.
* For double-buffered rendering we must clear the old pixels
* from the DB cache surface that we're going to use as a buffer.
* For non-double-buffered rendering we must clear it, otherwise
* semi-transparent pixels will "add up" with each repaint.
* We must also clear the old pixels from the DB cache surface
* that we're going to use as a buffer.
*/
cr = cairo_create (self->paint_surface);
cairo_set_source_rgba (cr, 0, 0, 0, 00);
@@ -184,12 +132,10 @@ gdk_win32_cairo_context_end_frame (GdkDrawContext *draw_context,
* to be here.
*/
/* Layered windows have their own, special copying section
* further down. For double-buffered windows we need to blit
/* For double-buffered windows we need to blit
* the DB buffer contents into the window itself.
*/
if (!self->layered &&
self->double_buffered)
if (self->double_buffered)
{
cairo_t *cr;
@@ -207,18 +153,6 @@ gdk_win32_cairo_context_end_frame (GdkDrawContext *draw_context,
cairo_surface_flush (self->window_surface);
/* Update layered window, updating its contents, size and position
* in one call.
*/
if (self->layered)
{
RECT client_rect;
/* Get the position/size of the window that GDK wants. */
_gdk_win32_get_window_client_area_rect (surface, scale, &client_rect);
_gdk_win32_update_layered_window_from_cache (surface, &client_rect, TRUE, TRUE, TRUE);
}
g_clear_pointer (&self->paint_surface, cairo_surface_destroy);
g_clear_pointer (&self->window_surface, cairo_surface_destroy);
}
+3 -8
View File
@@ -44,10 +44,6 @@ struct _GdkWin32CairoContext
* code that is unaffected by this flag.
*/
guint double_buffered : 1;
/* Re-set to the same value as GdkSurfaceImplWin32->layered
* every frame (since layeredness can change at runtime).
*/
guint layered : 1;
/* The a surface for double-buffering. We keep it
* around between repaints, and only re-allocate it
@@ -56,12 +52,11 @@ struct _GdkWin32CairoContext
int db_width;
int db_height;
/* Surface for the window DC (in non-layered mode).
* A reference of the cache surface (in layered mode). */
/* Surface for the window DC */
cairo_surface_t *window_surface;
/* A reference to db_surface (when double-buffering).
* When not using double-buffering or in layered mode
* this is a reference to window_surface.
* When not using double-buffering this is a reference
* to window_surface.
*/
cairo_surface_t *paint_surface;
};
-1
View File
@@ -2113,7 +2113,6 @@ gdk_drag_anim_timeout (gpointer data)
(drag->start_y - drag->util_data.last_y) * t -
drag->hot_y);
gdk_win32_surface_move (drag->drag_surface, x, y);
gdk_win32_surface_set_opacity (drag->drag_surface, 1.0 - f);
return G_SOURCE_CONTINUE;
}
+13 -14
View File
@@ -1495,15 +1495,6 @@ handle_dpi_changed (GdkSurface *window,
monitor = gdk_display_get_monitor_at_surface (display, window);
gdk_monitor_set_scale_factor (monitor, impl->surface_scale);
if (impl->layered)
{
/* We only need to set the cairo surface device scale here ourselves for layered windows */
if (impl->cache_surface != NULL)
cairo_surface_set_device_scale (impl->cache_surface,
impl->surface_scale,
impl->surface_scale);
}
}
_gdk_win32_adjust_client_rect (window, rect);
@@ -1721,8 +1712,8 @@ _gdk_win32_surface_fill_min_max_info (GdkSurface *window,
mmi->ptMaxSize.y = nearest_info.rcWork.bottom - nearest_info.rcWork.top;
}
mmi->ptMaxTrackSize.x = GetSystemMetrics (SM_CXVIRTUALSCREEN) + impl->margins_x * impl->surface_scale;
mmi->ptMaxTrackSize.y = GetSystemMetrics (SM_CYVIRTUALSCREEN) + impl->margins_y * impl->surface_scale;
mmi->ptMaxTrackSize.x = GetSystemMetrics (SM_CXVIRTUALSCREEN) + impl->shadow_x * impl->surface_scale;
mmi->ptMaxTrackSize.y = GetSystemMetrics (SM_CYVIRTUALSCREEN) + impl->shadow_y * impl->surface_scale;
}
return TRUE;
@@ -2354,9 +2345,7 @@ gdk_event_translate (MSG *msg,
if (impl->drag_move_resize_context.op != GDK_WIN32_DRAGOP_NONE)
{
gdk_win32_surface_do_move_resize_drag (window, current_root_x, current_root_y);
}
gdk_win32_surface_do_move_resize_drag (window, current_root_x, current_root_y);
else if (_gdk_input_ignore_core == 0)
{
current_x = (gint16) GET_X_LPARAM (msg->lParam) / impl->surface_scale;
@@ -2835,6 +2824,16 @@ gdk_event_translate (MSG *msg,
else
unset_bits |= GDK_TOPLEVEL_STATE_MAXIMIZED;
/*
* If we are minizing, pause all surface layout computations, and re-start the
* computation once we are coming out of a minimized state
*/
if (!(old_state & GDK_TOPLEVEL_STATE_MINIMIZED) && set_bits & GDK_TOPLEVEL_STATE_MINIMIZED)
gdk_surface_freeze_updates (window);
if (old_state & GDK_TOPLEVEL_STATE_MINIMIZED && unset_bits & GDK_TOPLEVEL_STATE_MINIMIZED)
gdk_surface_thaw_updates (window);
gdk_surface_set_is_mapped (window, !!IsWindowVisible (msg->hwnd));
gdk_synthesize_surface_state (window, unset_bits, set_bits);
-24
View File
@@ -88,19 +88,6 @@ _gdk_win32_gl_context_dispose (GObject *gobject)
#endif
}
if (surface != NULL)
{
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
if (impl->suppress_layered > 0)
impl->suppress_layered--;
/* If we don't have any surface that forces layered windows off,
* trigger update_style_bits() to enable layered windows again
*/
if (impl->suppress_layered == 0)
_gdk_win32_surface_update_style_bits (surface);
}
G_OBJECT_CLASS (gdk_win32_gl_context_parent_class)->dispose (gobject);
}
@@ -1001,17 +988,6 @@ gdk_win32_gl_context_realize (GdkGLContext *context,
/* set whether we are using GLES */
gdk_gl_context_set_use_es (context, use_es);
/* OpenGL does not work with WS_EX_LAYERED enabled, so we need to
* disable WS_EX_LAYERED when we acquire a valid HGLRC
*/
impl->suppress_layered++;
/* if this is the first time a GL context is acquired for the surface,
* disable layered windows by triggering update_style_bits()
*/
if (impl->suppress_layered == 1)
_gdk_win32_surface_update_style_bits (surface);
/* Ensure that any other context is created with a legacy bit set */
gdk_gl_context_set_is_legacy (context, legacy_bit);
-1
View File
@@ -351,7 +351,6 @@ _gdk_win32_surface_exstyle_to_string (LONG style)
BIT (CONTEXTHELP);
BIT (CONTROLPARENT);
BIT (DLGMODALFRAME);
BIT (LAYERED);
BIT (LAYOUTRTL);
BIT (LEFTSCROLLBAR);
BIT (MDICHILD);
+224 -304
View File
@@ -53,6 +53,10 @@
#include <math.h>
static void gdk_surface_win32_finalize (GObject *object);
static void compute_toplevel_size (GdkSurface *surface,
gboolean update_geometry,
int *width,
int *height);
static gpointer parent_class = NULL;
static GSList *modal_window_stack = NULL;
@@ -271,7 +275,6 @@ _gdk_win32_adjust_client_rect (GdkSurface *window,
gboolean
_gdk_win32_surface_enable_transparency (GdkSurface *window)
{
GdkWin32Surface *impl;
DWM_BLURBEHIND blur_behind;
HRGN empty_region;
HRESULT call_result;
@@ -280,12 +283,6 @@ _gdk_win32_surface_enable_transparency (GdkSurface *window)
if (window == NULL || GDK_SURFACE_HWND (window) == NULL)
return FALSE;
impl = GDK_WIN32_SURFACE (window);
/* layered windows don't need blurbehind for transparency */
if (impl->layered)
return TRUE;
if (!gdk_display_is_composited (gdk_surface_get_display (window)))
return FALSE;
@@ -522,9 +519,6 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
surface->width = width;
surface->height = height;
impl->layered = FALSE;
impl->layered_opacity = 1.0;
impl->surface_scale = _gdk_win32_display_get_monitor_scale_factor (display_win32, NULL, NULL, NULL);
impl->unscaled_width = width * impl->surface_scale;
impl->unscaled_height = height * impl->surface_scale;
@@ -1100,6 +1094,8 @@ gdk_win32_surface_resize (GdkSurface *window,
outer_rect.bottom - outer_rect.top,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER));
window->resize_count += 1;
gdk_surface_request_layout (window);
}
static void
@@ -1160,8 +1156,6 @@ gdk_win32_surface_move_resize_internal (GdkSurface *window,
{
GdkWin32Surface *surface = GDK_WIN32_SURFACE (window);
surface->inhibit_configure = TRUE;
/* We ignore changes to the window being moved or resized by the
user, as we don't want to fight the user */
if (GDK_SURFACE_HWND (window) == _modal_move_resize_window)
@@ -1186,8 +1180,6 @@ gdk_win32_surface_move_resize_internal (GdkSurface *window,
}
out:
surface->inhibit_configure = FALSE;
gdk_surface_request_layout (window);
}
@@ -1228,10 +1220,10 @@ gdk_win32_surface_layout_popup (GdkSurface *surface,
gdk_surface_layout_popup_helper (surface,
width,
height,
impl->margins.left,
impl->margins.right,
impl->margins.top,
impl->margins.bottom,
impl->shadow.left,
impl->shadow.right,
impl->shadow.top,
impl->shadow.bottom,
monitor,
&bounds,
layout,
@@ -1256,11 +1248,24 @@ gdk_win32_surface_layout_popup (GdkSurface *surface,
}
}
static void
maybe_notify_mapped (GdkSurface *surface)
{
if (surface->destroyed)
return;
if (!GDK_SURFACE_IS_MAPPED (surface))
{
gdk_surface_set_is_mapped (surface, TRUE);
gdk_surface_invalidate_rect (surface, NULL);
}
}
static void
show_popup (GdkSurface *surface)
{
gdk_win32_surface_raise (surface);
gdk_surface_set_is_mapped (surface, TRUE);
maybe_notify_mapped (surface);
show_window_internal (surface, FALSE, FALSE);
gdk_surface_invalidate_rect (surface, NULL);
}
@@ -1746,11 +1751,6 @@ update_single_bit (LONG *style,
* Returns TRUE if window has no decorations.
* Usually it means CSD windows, because GTK
* calls gdk_surface_set_decorations (window, 0);
* This is used to decide whether a toplevel should
* be made layered, thus it
* only returns TRUE for toplevels (until GTK minimal
* system requirements are lifted to Windows 8 or newer,
* because only toplevels can be layered).
*/
gboolean
_gdk_win32_surface_lacks_wm_decorations (GdkSurface *window)
@@ -1844,27 +1844,6 @@ _gdk_win32_surface_update_style_bits (GdkSurface *window)
new_exstyle &= ~WS_EX_TOOLWINDOW;
}
/* We can get away with using layered windows
* only when no decorations are needed. It can mean
* CSD or borderless non-CSD windows (tooltips?).
*
* If this window cannot use layered windows, disable it always.
* This currently applies to windows using OpenGL, which
* does not work with layered windows.
*/
if (impl->suppress_layered == 0)
{
if (_gdk_win32_surface_lacks_wm_decorations (window))
impl->layered = g_strcmp0 (g_getenv ("GDK_WIN32_LAYERED"), "0") != 0;
}
else
impl->layered = FALSE;
if (impl->layered)
new_exstyle |= WS_EX_LAYERED;
else
new_exstyle &= ~WS_EX_LAYERED;
if (get_effective_window_decorations (window, &decorations))
{
all = (decorations & GDK_DECOR_ALL);
@@ -2294,6 +2273,7 @@ snap_up (GdkSurface *window)
impl = GDK_WIN32_SURFACE (window);
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_FULLUP;
impl->resized = FALSE;
stash_window (window, impl);
@@ -2304,10 +2284,18 @@ snap_up (GdkSurface *window)
y = 0;
height = maxysize;
x = x - impl->margins.left;
y = y - impl->margins.top;
width += impl->margins_x;
height += impl->margins_y;
x = x - impl->shadow.left;
y = y - impl->shadow.top;
width += impl->shadow_x;
height += impl->shadow_y;
/* XXX: FIXME, AeroSnap snap_up() not really working well,
*
* * The snap_up() puts the window at the top left corner.
* * Without the following call, the height maximizes but we see a spew of
* "GdkToplevelSize: geometry size (x,y) exceeds bounds" warnings
*/
compute_toplevel_size (window, TRUE, &width, &height);
gdk_win32_surface_move_resize (window, x, y, width, height);
}
@@ -2323,6 +2311,7 @@ snap_left (GdkSurface *window,
impl = GDK_WIN32_SURFACE (window);
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_HALFLEFT;
impl->resized = FALSE;
gdk_win32_monitor_get_workarea (snap_monitor, &rect);
@@ -2330,10 +2319,10 @@ snap_left (GdkSurface *window,
rect.width = rect.width / 2;
rect.x = rect.x - impl->margins.left;
rect.y = rect.y - impl->margins.top;
rect.width = rect.width + impl->margins_x;
rect.height = rect.height + impl->margins_y;
rect.x = rect.x - impl->shadow.left;
rect.y = rect.y - impl->shadow.top;
rect.width = rect.width + impl->shadow_x;
rect.height = rect.height + impl->shadow_y;
gdk_win32_surface_move_resize (window,
rect.x, rect.y,
@@ -2351,6 +2340,7 @@ snap_right (GdkSurface *window,
impl = GDK_WIN32_SURFACE (window);
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_HALFRIGHT;
impl->resized = FALSE;
gdk_win32_monitor_get_workarea (snap_monitor, &rect);
@@ -2359,10 +2349,10 @@ snap_right (GdkSurface *window,
rect.width = rect.width / 2;
rect.x += rect.width;
rect.x = rect.x - impl->margins.left;
rect.y = rect.y - impl->margins.top;
rect.width = rect.width + impl->margins_x;
rect.height = rect.height + impl->margins_y;
rect.x = rect.x - impl->shadow.left;
rect.y = rect.y - impl->shadow.top;
rect.width = rect.width + impl->shadow_x;
rect.height = rect.height + impl->shadow_y;
gdk_win32_surface_move_resize (window,
rect.x, rect.y,
@@ -3502,10 +3492,10 @@ setup_drag_move_resize_context (GdkSurface *window,
*/
if (op == GDK_WIN32_DRAGOP_MOVE && !maximized)
{
swx += impl->margins.left / impl->surface_scale;
swy += impl->margins.top / impl->surface_scale;
swwidth -= impl->margins_x;
swheight -= impl->margins_y;
swx += impl->shadow.left / impl->surface_scale;
swy += impl->shadow.top / impl->surface_scale;
swwidth -= impl->shadow_x;
swheight -= impl->shadow_y;
}
pointer_outside_of_window = root_x < swx || root_x > swx + swwidth ||
@@ -3555,23 +3545,23 @@ setup_drag_move_resize_context (GdkSurface *window,
unmax_width = placement.rcNormalPosition.right - placement.rcNormalPosition.left;
unmax_height = placement.rcNormalPosition.bottom - placement.rcNormalPosition.top;
shadow_unmax_width = unmax_width - impl->margins_x * impl->surface_scale;
shadow_unmax_height = unmax_height - impl->margins_y * impl->surface_scale;
shadow_unmax_width = unmax_width - impl->shadow_x * impl->surface_scale;
shadow_unmax_height = unmax_height - impl->shadow_y * impl->surface_scale;
if (offsetx * impl->surface_scale < (shadow_unmax_width / 2) &&
offsety * impl->surface_scale < (shadow_unmax_height / 2))
{
placement.rcNormalPosition.top = (root_y - offsety + impl->margins.top - _gdk_offset_y) * impl->surface_scale;
placement.rcNormalPosition.top = (root_y - offsety + impl->shadow.top - _gdk_offset_y) * impl->surface_scale;
placement.rcNormalPosition.bottom = placement.rcNormalPosition.top + unmax_height;
if (left_half)
{
placement.rcNormalPosition.left = (root_x - offsetx + impl->margins.left - _gdk_offset_x) * impl->surface_scale;
placement.rcNormalPosition.left = (root_x - offsetx + impl->shadow.left - _gdk_offset_x) * impl->surface_scale;
placement.rcNormalPosition.right = placement.rcNormalPosition.left + unmax_width;
}
else
{
placement.rcNormalPosition.right = (root_x + offsetx + impl->margins.right - _gdk_offset_x) * impl->surface_scale;
placement.rcNormalPosition.right = (root_x + offsetx + impl->shadow.right - _gdk_offset_x) * impl->surface_scale;
placement.rcNormalPosition.left = placement.rcNormalPosition.right - unmax_width;
}
}
@@ -3582,7 +3572,7 @@ setup_drag_move_resize_context (GdkSurface *window,
(_gdk_offset_x * impl->surface_scale);
if (offsety * impl->surface_scale < shadow_unmax_height / 2)
placement.rcNormalPosition.top = (root_y - offsety + impl->margins.top - _gdk_offset_y) * impl->surface_scale;
placement.rcNormalPosition.top = (root_y - offsety + impl->shadow.top - _gdk_offset_y) * impl->surface_scale;
else
placement.rcNormalPosition.top = (root_y * impl->surface_scale) -
(unmax_height / 2) -
@@ -3609,18 +3599,18 @@ setup_drag_move_resize_context (GdkSurface *window,
if (op == GDK_WIN32_DRAGOP_MOVE)
{
snew_pos.width -= impl->margins_x;
snew_pos.height -= impl->margins_y;
snew_pos.width -= impl->shadow_x;
snew_pos.height -= impl->shadow_y;
}
if (offsetx < snew_pos.width / 2 && offsety < snew_pos.height / 2)
{
new_pos.y = root_y - offsety + impl->margins.top / impl->surface_scale;
new_pos.y = root_y - offsety + impl->shadow.top / impl->surface_scale;
if (left_half)
new_pos.x = root_x - offsetx + impl->margins.left / impl->surface_scale;
new_pos.x = root_x - offsetx + impl->shadow.left / impl->surface_scale;
else
new_pos.x = root_x + offsetx + impl->margins.left / impl->surface_scale - new_pos.width;
new_pos.x = root_x + offsetx + impl->shadow.left / impl->surface_scale - new_pos.width;
}
else
{
@@ -3785,67 +3775,6 @@ gdk_win32_get_window_size_and_position_from_client_rect (GdkSurface *window,
window_size->cy = window_rect->bottom - window_rect->top;
}
void
_gdk_win32_update_layered_window_from_cache (GdkSurface *surface,
RECT *client_rect,
gboolean do_move,
gboolean do_resize,
gboolean do_paint)
{
POINT window_position;
SIZE window_size;
BLENDFUNCTION blender;
HDC hdc;
SIZE *window_size_ptr;
POINT source_point = { 0, 0 };
POINT *source_point_ptr;
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
gdk_win32_get_window_size_and_position_from_client_rect (surface,
client_rect,
&window_size,
&window_position);
blender.BlendOp = AC_SRC_OVER;
blender.BlendFlags = 0;
blender.AlphaFormat = AC_SRC_ALPHA;
blender.SourceConstantAlpha = impl->layered_opacity * 255;
/* Strictly speaking, we don't need to supply hdc, source_point and
* window_size to just move the window. However, without these arguments
* the window moves but does not update its contents on Windows 7 when
* desktop composition is off. This forces us to provide hdc and
* source_point. window_size is here to avoid the function
* inexplicably failing with error 317.
*/
hdc = cairo_win32_surface_get_dc (impl->cache_surface);
window_size_ptr = &window_size;
source_point_ptr = &source_point;
if (gdk_display_is_composited (gdk_surface_get_display (surface)))
{
if (!do_paint)
hdc = NULL;
if (!do_resize)
window_size_ptr = NULL;
if (!do_move)
source_point_ptr = NULL;
}
/* Don't use UpdateLayeredWindow on minimized windows */
if (IsIconic (GDK_SURFACE_HWND (surface)))
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (surface),
SWP_NOZORDER_SPECIFIED,
window_position.x, window_position.y,
window_size.cx, window_size.cy,
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOREDRAW));
else
API_CALL (UpdateLayeredWindow, (GDK_SURFACE_HWND (surface), NULL,
&window_position, window_size_ptr,
hdc, source_point_ptr,
0, &blender, ULW_ALPHA));
}
void
gdk_win32_surface_do_move_resize_drag (GdkSurface *window,
int x,
@@ -4015,42 +3944,47 @@ gdk_win32_surface_do_move_resize_drag (GdkSurface *window,
rect.top != new_rect.top ||
rect.bottom != new_rect.bottom))
{
if (GDK_IS_TOPLEVEL (window))
{
int scale = impl->surface_scale;
impl->unscaled_width = new_rect.right - new_rect.left;
impl->unscaled_height = new_rect.bottom - new_rect.top;
impl->next_layout.configured_width = (impl->unscaled_width + scale - 1) / scale;
impl->next_layout.configured_height = (impl->unscaled_height + scale - 1) / scale;
impl->resized = TRUE;
}
context->native_move_resize_pending = TRUE;
gdk_surface_request_layout (window);
}
else if (context->op == GDK_WIN32_DRAGOP_MOVE &&
(rect.left != new_rect.left ||
rect.top != new_rect.top))
{
SIZE window_size;
POINT window_position;
context->native_move_resize_pending = FALSE;
gdk_surface_request_layout (window);
if (impl->layered)
{
_gdk_win32_update_layered_window_from_cache (window, &new_rect, TRUE, FALSE, FALSE);
}
else
{
SIZE window_size;
POINT window_position;
gdk_win32_get_window_size_and_position_from_client_rect (window,
&new_rect,
&window_size,
&window_position);
gdk_win32_get_window_size_and_position_from_client_rect (window,
&new_rect,
&window_size,
&window_position);
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window),
SWP_NOZORDER_SPECIFIED,
window_position.x, window_position.y,
0, 0,
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE));
}
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window),
SWP_NOZORDER_SPECIFIED,
window_position.x, window_position.y,
0, 0,
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE));
}
if (context->op == GDK_WIN32_DRAGOP_RESIZE ||
context->op == GDK_WIN32_DRAGOP_MOVE)
handle_aerosnap_move_resize (window, context, x, y);
gdk_surface_request_layout (window);
}
static void
@@ -4159,6 +4093,7 @@ gdk_win32_surface_minimize (GdkSurface *window)
static void
gdk_win32_surface_maximize (GdkSurface *window)
{
GdkWin32Surface *impl;
g_return_if_fail (GDK_IS_SURFACE (window));
@@ -4169,6 +4104,9 @@ gdk_win32_surface_maximize (GdkSurface *window)
GDK_SURFACE_HWND (window),
_gdk_win32_surface_state_to_string (window->state)));
impl = GDK_WIN32_SURFACE (window);
impl->resized = FALSE;
if (GDK_SURFACE_IS_MAPPED (window))
GtkShowWindow (window, SW_MAXIMIZE);
else
@@ -4313,61 +4251,6 @@ gdk_win32_surface_lookup_for_display (GdkDisplay *display,
return (GdkSurface*) gdk_win32_handle_table_lookup (anid);
}
void
gdk_win32_surface_set_opacity (GdkSurface *window,
double opacity)
{
LONG exstyle;
typedef BOOL (WINAPI *PFN_SetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
PFN_SetLayeredWindowAttributes setLayeredWindowAttributes = NULL;
GdkWin32Surface *impl;
g_return_if_fail (GDK_IS_SURFACE (window));
if (GDK_SURFACE_DESTROYED (window))
return;
if (opacity < 0)
opacity = 0;
else if (opacity > 1)
opacity = 1;
impl = GDK_WIN32_SURFACE (window);
if (impl->layered)
{
if (impl->layered_opacity != opacity)
{
RECT window_rect;
impl->layered_opacity = opacity;
_gdk_win32_get_window_client_area_rect (window, impl->surface_scale, &window_rect);
_gdk_win32_update_layered_window_from_cache (window, &window_rect, TRUE, TRUE, TRUE);
}
return;
}
exstyle = GetWindowLong (GDK_SURFACE_HWND (window), GWL_EXSTYLE);
if (!(exstyle & WS_EX_LAYERED))
SetWindowLong (GDK_SURFACE_HWND (window),
GWL_EXSTYLE,
exstyle | WS_EX_LAYERED);
setLayeredWindowAttributes =
(PFN_SetLayeredWindowAttributes)GetProcAddress (GetModuleHandle ("user32.dll"), "SetLayeredWindowAttributes");
if (setLayeredWindowAttributes)
{
API_CALL (setLayeredWindowAttributes, (GDK_SURFACE_HWND (window),
0,
opacity * 0xff,
LWA_ALPHA));
}
}
gboolean
gdk_win32_surface_is_win32 (GdkSurface *window)
{
@@ -4447,9 +4330,6 @@ GtkShowWindow (GdkSurface *window,
if (IsWindowVisible (hwnd))
break;
if ((WS_EX_LAYERED & GetWindowLongPtr (hwnd, GWL_EXSTYLE)) != WS_EX_LAYERED)
break;
/* Window was hidden, will be shown. Erase it, GDK will repaint soon,
* but not soon enough, so it's possible to see old content before
* the next redraw, unless we erase the window first.
@@ -4514,17 +4394,17 @@ gdk_win32_surface_set_shadow_width (GdkSurface *window,
"left %d, top %d, right %d, bottom %d\n",
window, left, top, right, bottom));
impl->zero_margins = left == 0 && right == 0 && top == 0 && bottom == 0;
impl->zero_shadow = left == 0 && right == 0 && top == 0 && bottom == 0;
if (impl->zero_margins)
if (impl->zero_shadow)
return;
impl->margins.left = left;
impl->margins.right = right * impl->surface_scale;
impl->margins.top = top;
impl->margins.bottom = bottom * impl->surface_scale;
impl->margins_x = left + right;
impl->margins_y = top + bottom;
impl->shadow.left = left;
impl->shadow.right = right * impl->surface_scale;
impl->shadow.top = top;
impl->shadow.bottom = bottom * impl->surface_scale;
impl->shadow_x = left + right;
impl->shadow_y = top + bottom;
}
@@ -4597,6 +4477,118 @@ gdk_win32_surface_set_input_region (GdkSurface *window,
*/
}
static void
compute_toplevel_size (GdkSurface *surface,
gboolean update_geometry,
int *width,
int *height)
{
GdkDisplay *display = gdk_surface_get_display (surface);
GdkMonitor *monitor;
GdkToplevelSize size;
int bounds_width, bounds_height;
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
monitor = gdk_display_get_monitor_at_surface (display, surface);
if (monitor)
{
GdkRectangle workarea;
gdk_win32_monitor_get_workarea (monitor, &workarea);
bounds_width = workarea.width;
bounds_height = workarea.height;
}
else
{
bounds_width = G_MAXINT;
bounds_height = G_MAXINT;
}
gdk_toplevel_size_init (&size, bounds_width, bounds_height);
gdk_toplevel_notify_compute_size (GDK_TOPLEVEL (surface), &size);
g_warn_if_fail (size.width > 0);
g_warn_if_fail (size.height > 0);
*width = size.width;
*height = size.height;
if (size.shadow.is_valid)
{
gdk_win32_surface_set_shadow_width (surface,
size.shadow.left,
size.shadow.right,
size.shadow.top,
size.shadow.bottom);
}
if (update_geometry)
{
GdkGeometry geometry;
GdkSurfaceHints mask;
GdkToplevelLayout *layout = impl->toplevel_layout;
if (gdk_toplevel_layout_get_resizable (layout))
{
geometry.min_width = size.min_width;
geometry.min_height = size.min_height;
mask = GDK_HINT_MIN_SIZE;
}
else
{
geometry.max_width = geometry.min_width = *width;
geometry.max_height = geometry.min_height = *height;
mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE;
}
gdk_win32_surface_set_geometry_hints (surface, &geometry, mask);
gdk_surface_constrain_size (&geometry, mask, *width, *height, width, height);
}
}
static void
_gdk_win32_surface_request_layout (GdkSurface *surface)
{
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
int scale = impl->surface_scale;
RECT rect;
if (GDK_IS_TOPLEVEL (surface) && impl->resized)
{
surface->width = impl->next_layout.configured_width;
surface->height = impl->next_layout.configured_height;
}
else
{
_gdk_win32_get_window_rect (surface, &rect);
impl->unscaled_width = rect.right - rect.left;
impl->unscaled_height = rect.bottom - rect.top;
impl->next_layout.configured_width = (impl->unscaled_width + scale - 1) / scale;
impl->next_layout.configured_height = (impl->unscaled_height + scale - 1) / scale;
surface->x = rect.left / scale;
surface->y = rect.top / scale;
}
}
static gboolean
_gdk_win32_surface_compute_size (GdkSurface *surface)
{
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
int width, height;
if (GDK_IS_TOPLEVEL (surface))
compute_toplevel_size (surface, TRUE, &width, &height);
if (!impl->resized)
{
surface->width = impl->next_layout.configured_width;
surface->height = impl->next_layout.configured_height;
_gdk_surface_update_size (surface);
}
return FALSE;
}
static void
gdk_win32_surface_class_init (GdkWin32SurfaceClass *klass)
{
@@ -4623,6 +4615,8 @@ gdk_win32_surface_class_init (GdkWin32SurfaceClass *klass)
impl_class->create_gl_context = _gdk_win32_surface_create_gl_context;
impl_class->get_scale_factor = _gdk_win32_surface_get_scale_factor;
impl_class->get_unscaled_size = _gdk_win32_surface_get_unscaled_size;
impl_class->request_layout = _gdk_win32_surface_request_layout;
impl_class->compute_size = _gdk_win32_surface_compute_size;
}
HGDIOBJ
@@ -4912,75 +4906,18 @@ gdk_win32_toplevel_class_init (GdkWin32ToplevelClass *class)
}
static void
show_surface (GdkSurface *surface)
{
gboolean was_mapped;
if (surface->destroyed)
return;
was_mapped = GDK_SURFACE_IS_MAPPED (surface);
if (!was_mapped)
gdk_surface_set_is_mapped (surface, TRUE);
gdk_win32_surface_show (surface, FALSE);
if (!was_mapped)
gdk_surface_invalidate_rect (surface, NULL);
}
static gboolean
gdk_win32_toplevel_present (GdkToplevel *toplevel,
GdkToplevelLayout *layout)
{
GdkSurface *surface = GDK_SURFACE (toplevel);
GdkDisplay *display = gdk_surface_get_display (surface);
GdkMonitor *monitor;
GdkToplevelSize size;
int bounds_width, bounds_height;
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
int width, height;
GdkGeometry geometry;
GdkSurfaceHints mask;
gboolean maximize;
gboolean fullscreen;
monitor = gdk_display_get_monitor_at_surface (display, surface);
if (monitor)
{
GdkRectangle workarea;
gdk_win32_monitor_get_workarea (monitor, &workarea);
bounds_width = workarea.width;
bounds_height = workarea.height;
}
else
{
bounds_width = G_MAXINT;
bounds_height = G_MAXINT;
}
gdk_toplevel_size_init (&size, bounds_width, bounds_height);
gdk_toplevel_notify_compute_size (toplevel, &size);
g_warn_if_fail (size.width > 0);
g_warn_if_fail (size.height > 0);
width = size.width;
height = size.height;
if (gdk_toplevel_layout_get_resizable (layout))
{
geometry.min_width = size.min_width;
geometry.min_height = size.min_height;
mask = GDK_HINT_MIN_SIZE;
}
else
{
geometry.max_width = geometry.min_width = width;
geometry.max_height = geometry.min_height = height;
mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE;
}
gdk_win32_surface_set_geometry_hints (surface, &geometry, mask);
gdk_surface_constrain_size (&geometry, mask, width, height, &width, &height);
g_clear_pointer (&impl->toplevel_layout, gdk_toplevel_layout_unref);
impl->toplevel_layout = gdk_toplevel_layout_copy (layout);
compute_toplevel_size (surface, FALSE, &width, &height);
gdk_win32_surface_resize (surface, width, height);
if (gdk_toplevel_layout_get_maximized (layout, &maximize))
@@ -4999,18 +4936,8 @@ gdk_win32_toplevel_present (GdkToplevel *toplevel,
gdk_win32_surface_unfullscreen (surface);
}
show_surface (surface);
if (size.shadow.is_valid)
{
gdk_win32_surface_set_shadow_width (surface,
size.shadow.left,
size.shadow.right,
size.shadow.top,
size.shadow.bottom);
}
return TRUE;
gdk_win32_surface_show (surface, FALSE);
maybe_notify_mapped (surface);
}
static gboolean
@@ -5093,8 +5020,9 @@ gdk_win32_drag_surface_present (GdkDragSurface *drag_surface,
{
GdkSurface *surface = GDK_SURFACE (drag_surface);
gdk_win32_surface_resize (surface, width, height);
show_surface (surface);
gdk_win32_surface_resize (surface, width, height);
gdk_win32_surface_show (surface, FALSE);
maybe_notify_mapped (surface);
return TRUE;
}
@@ -5185,7 +5113,6 @@ gdk_win32_surface_apply_queued_move_resize (GdkSurface *surface,
RECT
gdk_win32_surface_handle_queued_move_resize (GdkDrawContext *draw_context)
{
GdkWin32CairoContext *cairo_ctx = NULL;
GdkSurface *surface;
GdkWin32Surface *impl;
int scale;
@@ -5195,23 +5122,16 @@ gdk_win32_surface_handle_queued_move_resize (GdkDrawContext *draw_context)
impl = GDK_WIN32_SURFACE (surface);
scale = gdk_surface_get_scale_factor (surface);
if (GDK_IS_WIN32_CAIRO_CONTEXT (draw_context))
{
cairo_ctx = GDK_WIN32_CAIRO_CONTEXT (draw_context);
cairo_ctx->layered = impl->layered;
}
gdk_win32_surface_get_queued_window_rect (surface, scale, &queued_window_rect);
/* Apply queued resizes for non-double-buffered and non-layered windows
/* Apply queued resizes for non-double-buffered windows
* before painting them (we paint on the window DC directly,
* it must have the right size).
* Due to some poorly-undetstood issue delayed
* resizing of double-buffered windows can produce weird
* artefacts, so these are also resized before we paint.
*/
if (impl->drag_move_resize_context.native_move_resize_pending &&
(cairo_ctx == NULL || !cairo_ctx->layered))
if (impl->drag_move_resize_context.native_move_resize_pending)
{
impl->drag_move_resize_context.native_move_resize_pending = FALSE;
gdk_win32_surface_apply_queued_move_resize (surface, queued_window_rect);
+14 -28
View File
@@ -265,25 +265,18 @@ struct _GdkWin32Surface
int initial_y;
/* left/right/top/bottom width of the shadow/resize-grip around the window */
RECT margins;
RECT shadow;
/* left+right and top+bottom from @margins */
int margins_x;
int margins_y;
/* left+right and top+bottom from @shadow */
int shadow_x;
int shadow_y;
/* Set to TRUE when GTK tells us that margins are 0 everywhere.
* We don't actually set margins to 0, we just set this bit.
/* Set to TRUE when GTK tells us that shadow are 0 everywhere.
* We don't actually set shadow to 0, we just set this bit.
*/
guint zero_margins : 1;
guint zero_shadow : 1;
guint inhibit_configure : 1;
/* Set to TRUE if window is using true layered mode adjustments
* via UpdateLayeredWindow().
* Layered windows that get SetLayeredWindowAttributes() called
* on them are not true layered windows.
*/
guint layered : 1;
/* If TRUE, the @temp_styles is set to the styles that were temporarily
* added to this window.
*/
@@ -309,12 +302,6 @@ struct _GdkWin32Surface
int dib_width;
int dib_height;
/* If the client wants uniformly-transparent window,
* we remember the opacity value here and apply it
* during UpdateLayredWindow() call, for layered windows.
*/
double layered_opacity;
HDC hdc;
int hdc_count;
HBITMAP saved_dc_bitmap; /* Original bitmap for dc */
@@ -340,9 +327,6 @@ struct _GdkWin32Surface
/* Enable all decorations? */
gboolean decorate_all;
/* No. of windows to force layered windows off */
guint suppress_layered;
/* Temporary styles that this window got for the purpose of
* handling WM_SYSMENU.
* They are removed at the first opportunity (usually WM_INITMENU).
@@ -354,6 +338,13 @@ struct _GdkWin32Surface
int unscaled_width;
int unscaled_height;
GdkToplevelLayout *toplevel_layout;
struct {
int configured_width;
int configured_height;
} next_layout;
gboolean resized;
#ifdef GDK_WIN32_ENABLE_EGL
EGLSurface egl_surface;
EGLSurface egl_dummy_surface;
@@ -375,11 +366,6 @@ int _gdk_win32_surface_get_scale_factor (GdkSurface *window);
void _gdk_win32_get_window_client_area_rect (GdkSurface *window,
int scale,
RECT *rect);
void _gdk_win32_update_layered_window_from_cache (GdkSurface *window,
RECT *client_rect,
gboolean do_move,
gboolean do_resize,
gboolean do_paint);
void gdk_win32_surface_move (GdkSurface *surface,
int x,
-6
View File
@@ -63,12 +63,6 @@ gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context,
NULL,
surface);
if (result == VK_SUCCESS)
win32_surface->suppress_layered ++;
if (win32_surface->suppress_layered == 1)
_gdk_win32_surface_update_style_bits (window);
return result;
}
+44 -13
View File
@@ -1097,15 +1097,16 @@ handle_property_change (GdkX11DeviceManagerXI2 *device_manager,
if (ev->what != XIPropertyDeleted &&
device_get_tool_serial_and_id (device, &serial_id, &tool_id))
{
GdkDeviceToolType tool_type;
seat = gdk_device_get_seat (device);
tool = gdk_seat_get_tool (seat, serial_id, tool_id);
tool_type = device_get_tool_type (device);
if (!tool && serial_id > 0)
if (tool_type != GDK_DEVICE_TOOL_TYPE_UNKNOWN)
{
GdkDeviceToolType tool_type;
tool = gdk_seat_get_tool (seat, serial_id, tool_id, tool_type);
tool_type = device_get_tool_type (device);
if (tool_type != GDK_DEVICE_TOOL_TYPE_UNKNOWN)
if (!tool && serial_id > 0)
{
tool = gdk_device_tool_new (serial_id, tool_id, tool_type, 0);
gdk_seat_default_add_tool (GDK_SEAT_DEFAULT (seat), tool);
@@ -1716,19 +1717,49 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
scroll_valuators_changed (GDK_X11_DEVICE_XI2 (source_device),
&xev->valuators, &delta_x, &delta_y))
{
GdkModifierType state;
GDK_DISPLAY_NOTE (display, EVENTS,
g_message ("smooth scroll: \n\tdevice: %u\n\tsource device: %u\n\twindow %ld\n\tdeltas: %f %f",
xev->deviceid, xev->sourceid,
xev->event, delta_x, delta_y));
event = gdk_scroll_event_new (surface,
device,
NULL,
xev->time,
_gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group),
delta_x,
delta_y,
delta_x == 0.0 && delta_y == 0.0);
state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
if (gdk_device_get_source (source_device) != GDK_SOURCE_TOUCHPAD &&
((delta_x == 0.0 && ABS (delta_y) == 1.0) ||
(ABS (delta_x) == 1.0 && delta_y == 0.0)))
{
GdkScrollDirection direction;
if (delta_x > 0)
direction = GDK_SCROLL_RIGHT;
else if (delta_x < 0)
direction = GDK_SCROLL_LEFT;
else if (delta_y > 0)
direction = GDK_SCROLL_DOWN;
else
direction = GDK_SCROLL_UP;
event = gdk_scroll_event_new_discrete (surface,
device,
NULL,
xev->time,
state,
direction,
FALSE);
}
else
{
event = gdk_scroll_event_new (surface,
device,
NULL,
xev->time,
state,
delta_x,
delta_y,
delta_x == 0.0 && delta_y == 0.0);
}
break;
}
+3 -1
View File
@@ -291,7 +291,7 @@ compute_toplevel_size (GdkSurface *surface,
GdkGeometry geometry;
GdkSurfaceHints mask;
if (gdk_toplevel_layout_get_resizable (impl->toplevel_layout))
if (!impl->toplevel_layout || gdk_toplevel_layout_get_resizable (impl->toplevel_layout))
{
geometry.min_width = size.min_width;
geometry.min_height = size.min_height;
@@ -2013,6 +2013,8 @@ _gdk_x11_surface_set_surface_scale (GdkSurface *surface,
surface->height * impl->surface_scale);
gdk_surface_invalidate_rect (surface, NULL);
g_object_notify (G_OBJECT (surface), "scale-factor");
}
void
+3 -3
View File
@@ -149,10 +149,10 @@ render_glyph (GlyphCacheKey *key,
glyph_info.glyph = key->data.glyph;
glyph_info.geometry.width = value->draw_width * 1024;
if (glyph_info.glyph & PANGO_GLYPH_UNKNOWN_FLAG)
glyph_info.geometry.x_offset = 0;
glyph_info.geometry.x_offset = 250 * key->data.xshift;
else
glyph_info.geometry.x_offset = - value->draw_x * 1024;
glyph_info.geometry.y_offset = - value->draw_y * 1024;
glyph_info.geometry.x_offset = 250 * key->data.xshift - value->draw_x * 1024;
glyph_info.geometry.y_offset = 250 * key->data.yshift - value->draw_y * 1024;
glyph_string.num_glyphs = 1;
glyph_string.glyphs = &glyph_info;
+78 -78
View File
@@ -1452,6 +1452,7 @@ render_linear_gradient_node (GskGLRenderer *self,
ops_set_linear_gradient (builder,
n_color_stops,
stops,
gsk_render_node_get_node_type (node) == GSK_REPEATING_LINEAR_GRADIENT_NODE,
builder->dx + start->x,
builder->dy + start->y,
builder->dx + end->x,
@@ -1485,6 +1486,7 @@ render_radial_gradient_node (GskGLRenderer *self,
ops_set_radial_gradient (builder,
n_color_stops,
stops,
gsk_render_node_get_node_type (node) == GSK_REPEATING_RADIAL_GRADIENT_NODE,
builder->dx + center->x,
builder->dy + center->y,
start, end,
@@ -1510,7 +1512,7 @@ render_conic_gradient_node (GskGLRenderer *self,
{
const GskColorStop *stops = gsk_conic_gradient_node_get_color_stops (node, NULL);
const graphene_point_t *center = gsk_conic_gradient_node_get_center (node);
const float rotation = gsk_conic_gradient_node_get_rotation (node);
const float angle = gsk_conic_gradient_node_get_angle (node);
ops_set_program (builder, &self->programs->conic_gradient_program);
ops_set_conic_gradient (builder,
@@ -1518,7 +1520,7 @@ render_conic_gradient_node (GskGLRenderer *self,
stops,
builder->dx + center->x,
builder->dy + center->y,
rotation);
angle);
load_vertex_data (ops_draw (builder, NULL), &node->bounds, builder);
}
@@ -1554,7 +1556,7 @@ rounded_inner_rect_contains_rect (const GskRoundedRect *rounded,
MAX (rounded->corner[GSK_CORNER_BOTTOM_LEFT].height,
rounded->corner[GSK_CORNER_BOTTOM_RIGHT].height);
return graphene_rect_contains_rect (&inner, rect);
return _graphene_rect_contains_rect (&inner, rect);
}
/* Current clip is NOT rounded but new one is definitely! */
@@ -1644,8 +1646,8 @@ render_clipped_child (GskGLRenderer *self,
/* well fuck */
const float scale_x = builder->scale_x;
const float scale_y = builder->scale_y;
const GskRoundedRect scaled_clip = GSK_ROUNDED_RECT_INIT (clip->origin.x * scale_x,
clip->origin.y * scale_y,
const GskRoundedRect scaled_clip = GSK_ROUNDED_RECT_INIT ((builder->dx + clip->origin.x) * scale_x,
(builder->dy + clip->origin.y) * scale_y,
clip->size.width * scale_x,
clip->size.height * scale_y);
gboolean is_offscreen;
@@ -1746,7 +1748,6 @@ render_rounded_clip_node (GskGLRenderer *self,
}
else
{
GskRoundedRect scaled_clip;
gboolean is_offscreen;
TextureRegion region;
/* NOTE: We are *not* transforming the clip by the current modelview here.
@@ -1755,19 +1756,7 @@ render_rounded_clip_node (GskGLRenderer *self,
*
* We do, however, apply the scale factor to the child clip of course.
*/
scaled_clip.bounds.origin.x = clip->bounds.origin.x * scale_x;
scaled_clip.bounds.origin.y = clip->bounds.origin.y * scale_y;
scaled_clip.bounds.size.width = clip->bounds.size.width * scale_x;
scaled_clip.bounds.size.height = clip->bounds.size.height * scale_y;
/* Increase corner radius size by scale factor */
for (i = 0; i < 4; i ++)
{
scaled_clip.corner[i].width = clip->corner[i].width * scale_x;
scaled_clip.corner[i].height = clip->corner[i].height * scale_y;
}
ops_push_clip (builder, &scaled_clip);
ops_push_clip (builder, &transformed_clip);
if (!add_offscreen_ops (self, builder, &node->bounds,
child,
&region, &is_offscreen,
@@ -1779,7 +1768,8 @@ render_rounded_clip_node (GskGLRenderer *self,
ops_set_program (builder, &self->programs->blit_program);
ops_set_texture (builder, region.texture_id);
load_offscreen_vertex_data (ops_draw (builder, NULL), node, builder);
load_vertex_data_with_region (ops_draw (builder, NULL), &node->bounds, builder,
&region, is_offscreen);
}
}
@@ -1824,6 +1814,7 @@ blur_texture (GskGLRenderer *self,
float blur_radius_x,
float blur_radius_y)
{
const GskRoundedRect new_clip = GSK_ROUNDED_RECT_INIT (0, 0, texture_to_blur_width, texture_to_blur_height);
int pass1_texture_id, pass1_render_target;
int pass2_texture_id, pass2_render_target;
int prev_render_target;
@@ -1850,17 +1841,16 @@ blur_texture (GskGLRenderer *self,
GL_NEAREST, GL_NEAREST,
&pass2_texture_id, &pass2_render_target);
init_projection_matrix (&item_proj,
&GRAPHENE_RECT_INIT (0, 0, texture_to_blur_width, texture_to_blur_height));
init_projection_matrix (&item_proj, &new_clip.bounds);
ops_set_program (builder, &self->programs->blur_program);
prev_projection = ops_set_projection (builder, &item_proj);
ops_set_modelview (builder, NULL);
prev_viewport = ops_set_viewport (builder, &GRAPHENE_RECT_INIT (0, 0, texture_to_blur_width, texture_to_blur_height));
ops_push_clip (builder, &GSK_ROUNDED_RECT_INIT (0, 0, texture_to_blur_width, texture_to_blur_height));
prev_viewport = ops_set_viewport (builder, &new_clip.bounds);
ops_push_clip (builder, &new_clip);
prev_render_target = ops_set_render_target (builder, pass1_render_target);
ops_begin (builder, OP_CLEAR);
ops_set_program (builder, &self->programs->blur_program);
op = ops_begin (builder, OP_CHANGE_BLUR);
op->size.width = texture_to_blur_width;
@@ -1871,7 +1861,7 @@ blur_texture (GskGLRenderer *self,
ops_set_texture (builder, region->texture_id);
load_vertex_data_with_region (ops_draw (builder, NULL),
&GRAPHENE_RECT_INIT (0, 0, texture_to_blur_width, texture_to_blur_height),
&new_clip.bounds,
builder, region,
FALSE);
#if 0
@@ -1893,7 +1883,7 @@ blur_texture (GskGLRenderer *self,
ops_set_render_target (builder, pass2_render_target);
ops_begin (builder, OP_CLEAR);
load_vertex_data_with_region (ops_draw (builder, NULL), /* render pass 2 */
&GRAPHENE_RECT_INIT (0, 0, texture_to_blur_width, texture_to_blur_height),
&new_clip.bounds,
builder, region,
FALSE);
@@ -2940,10 +2930,15 @@ static inline void
apply_color_matrix_op (const Program *program,
const OpColorMatrix *op)
{
float mat[16];
OP_PRINT (" -> Color Matrix");
graphene_matrix_to_float (op->matrix, mat);
glUniformMatrix4fv (program->color_matrix.color_matrix_location, 1, GL_FALSE, mat);
OP_PRINT (" -> Color matrix. Send matrix: %d. Send offset: %d.",
op->matrix.send, op->offset.send);
if (op->matrix.send)
{
float mat[16];
graphene_matrix_to_float (op->matrix.value, mat);
glUniformMatrix4fv (program->color_matrix.color_matrix_location, 1, GL_FALSE, mat);
}
if (op->offset.send)
{
@@ -3048,14 +3043,19 @@ apply_linear_gradient_op (const Program *program,
op->n_color_stops.value * 5,
(float *)op->color_stops.value);
glUniform2f (program->linear_gradient.start_point_location, op->start_point[0], op->start_point[1]);
glUniform2f (program->linear_gradient.end_point_location, op->end_point[0], op->end_point[1]);
glUniform4f (program->linear_gradient.points_location,
op->start_point[0], op->start_point[1],
op->end_point[0] - op->start_point[0], op->end_point[1] - op->start_point[1]);
glUniform1i (program->linear_gradient.repeat_location, op->repeat);
}
static inline void
apply_radial_gradient_op (const Program *program,
const OpRadialGradient *op)
{
float scale;
float bias;
OP_PRINT (" -> Radial gradient");
if (op->n_color_stops.send)
glUniform1i (program->radial_gradient.num_color_stops_location, op->n_color_stops.value);
@@ -3065,16 +3065,23 @@ apply_radial_gradient_op (const Program *program,
op->n_color_stops.value * 5,
(float *)op->color_stops.value);
glUniform1f (program->radial_gradient.start_location, op->start);
glUniform1f (program->radial_gradient.end_location, op->end);
glUniform2f (program->radial_gradient.radius_location, op->radius[0], op->radius[1]);
glUniform2f (program->radial_gradient.center_location, op->center[0], op->center[1]);
scale = 1.0f / (op->end - op->start);
bias = -op->start * scale;
glUniform1i (program->radial_gradient.repeat_location, op->repeat);
glUniform2f (program->radial_gradient.range_location, scale, bias);
glUniform4f (program->radial_gradient.geometry_location,
op->center[0], op->center[1],
1.0f / op->radius[0], 1.0f / op->radius[1]);
}
static inline void
apply_conic_gradient_op (const Program *program,
const OpConicGradient *op)
{
float bias;
float scale;
OP_PRINT (" -> Conic gradient");
if (op->n_color_stops.send)
glUniform1i (program->conic_gradient.num_color_stops_location, op->n_color_stops.value);
@@ -3084,8 +3091,9 @@ apply_conic_gradient_op (const Program *program,
op->n_color_stops.value * 5,
(float *)op->color_stops.value);
glUniform1f (program->conic_gradient.rotation_location, op->rotation);
glUniform2f (program->conic_gradient.center_location, op->center[0], op->center[1]);
scale = 0.5f * M_1_PI;
bias = op->angle * scale + 2.0f;
glUniform4f (program->conic_gradient.geometry_location, op->center[0], op->center[1], scale, bias);
}
static inline void
@@ -3199,6 +3207,7 @@ static inline void
apply_repeat_op (const Program *program,
const OpRepeat *op)
{
OP_PRINT (" -> Repeat");
glUniform4fv (program->repeat.child_bounds_location, 1, op->child_bounds);
glUniform4fv (program->repeat.texture_rect_location, 1, op->texture_rect);
}
@@ -3374,22 +3383,20 @@ gsk_gl_renderer_create_programs (GskGLRenderer *self,
/* linear gradient */
INIT_PROGRAM_UNIFORM_LOCATION (linear_gradient, color_stops);
INIT_PROGRAM_UNIFORM_LOCATION (linear_gradient, num_color_stops);
INIT_PROGRAM_UNIFORM_LOCATION (linear_gradient, start_point);
INIT_PROGRAM_UNIFORM_LOCATION (linear_gradient, end_point);
INIT_PROGRAM_UNIFORM_LOCATION (linear_gradient, repeat);
INIT_PROGRAM_UNIFORM_LOCATION (linear_gradient, points);
/* radial gradient */
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, color_stops);
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, num_color_stops);
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, center);
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, start);
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, end);
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, radius);
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, repeat);
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, geometry);
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, range);
/* conic gradient */
INIT_PROGRAM_UNIFORM_LOCATION (conic_gradient, color_stops);
INIT_PROGRAM_UNIFORM_LOCATION (conic_gradient, num_color_stops);
INIT_PROGRAM_UNIFORM_LOCATION (conic_gradient, center);
INIT_PROGRAM_UNIFORM_LOCATION (conic_gradient, rotation);
INIT_PROGRAM_UNIFORM_LOCATION (conic_gradient, geometry);
/* blur */
INIT_PROGRAM_UNIFORM_LOCATION (blur, blur_radius);
@@ -3735,10 +3742,12 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
break;
case GSK_LINEAR_GRADIENT_NODE:
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
render_linear_gradient_node (self, node, builder);
break;
case GSK_RADIAL_GRADIENT_NODE:
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
render_radial_gradient_node (self, node, builder);
break;
@@ -3805,8 +3814,6 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
render_gl_shader_node (self, node, builder);
break;
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
case GSK_CAIRO_NODE:
default:
{
@@ -3824,9 +3831,9 @@ add_offscreen_ops (GskGLRenderer *self,
gboolean *is_offscreen,
guint flags)
{
float width, height;
const float dx = builder->dx;
const float dy = builder->dy;
float scaled_width, scaled_height;
float scale_x;
float scale_y;
int render_target;
@@ -3839,6 +3846,7 @@ add_offscreen_ops (GskGLRenderer *self,
int filter;
GskTextureKey key;
int cached_id;
graphene_rect_t viewport;
if (node_is_invisible (child_node))
{
@@ -3881,8 +3889,6 @@ add_offscreen_ops (GskGLRenderer *self,
return TRUE;
}
width = bounds->size.width;
height = bounds->size.height;
scale_x = builder->scale_x;
scale_y = builder->scale_y;
@@ -3893,23 +3899,23 @@ add_offscreen_ops (GskGLRenderer *self,
{
const int max_texture_size = gsk_gl_driver_get_max_texture_size (self->gl_driver);
width = ceilf (width * scale_x);
if (width > max_texture_size)
scaled_width = ceilf (bounds->size.width * scale_x);
if (scaled_width > max_texture_size)
{
scale_x *= (float)max_texture_size / width;
width = max_texture_size;
scale_x *= (float)max_texture_size / scaled_width;
scaled_width = max_texture_size;
}
height = ceilf (height * scale_y);
if (height > max_texture_size)
scaled_height = ceilf (bounds->size.height * scale_y);
if (scaled_height > max_texture_size)
{
scale_y *= (float)max_texture_size / height;
height = max_texture_size;
scale_y *= (float)max_texture_size / scaled_height;
scaled_height = max_texture_size;
}
}
gsk_gl_driver_create_render_target (self->gl_driver,
width, height,
scaled_width, scaled_height,
filter, filter,
&texture_id, &render_target);
if (gdk_gl_context_has_debug (self->gl_context))
@@ -3924,30 +3930,24 @@ add_offscreen_ops (GskGLRenderer *self,
render_target);
}
init_projection_matrix (&item_proj,
&GRAPHENE_RECT_INIT (
bounds->origin.x * scale_x,
bounds->origin.y * scale_y,
width, height
));
ops_transform_bounds_modelview (builder, bounds, &viewport);
/* Code above will scale the size with the scale we use in the render ops,
* but for the viewport size, we need our own size limited by the texture size */
viewport.size.width = scaled_width;
viewport.size.height = scaled_height;
init_projection_matrix (&item_proj, &viewport);
prev_render_target = ops_set_render_target (builder, render_target);
/* Clear since we use this rendertarget for the first time */
ops_begin (builder, OP_CLEAR);
prev_projection = ops_set_projection (builder, &item_proj);
ops_set_modelview (builder, gsk_transform_scale (NULL, scale_x, scale_y));
prev_viewport = ops_set_viewport (builder,
&GRAPHENE_RECT_INIT (bounds->origin.x * scale_x,
bounds->origin.y * scale_y,
width, height));
prev_viewport = ops_set_viewport (builder, &viewport);
if (flags & RESET_CLIP)
ops_push_clip (builder,
&GSK_ROUNDED_RECT_INIT (bounds->origin.x * scale_x,
bounds->origin.y * scale_y,
width, height));
ops_push_clip (builder, &GSK_ROUNDED_RECT_INIT_FROM_RECT (viewport));
builder->dx = 0;
builder->dy = 0;
builder->dx = dx;
builder->dy = dy;
prev_opacity = ops_set_opacity (builder, 1.0);
@@ -3962,7 +3962,7 @@ add_offscreen_ops (GskGLRenderer *self,
g_type_name_from_instance ((GTypeInstance *) child_node),
child_node,
k ++),
width, height);
scaled_width, scaled_height);
}
#endif
+81 -159
View File
@@ -14,27 +14,28 @@ rect_equal (const graphene_rect_t *a,
return memcmp (a, b, sizeof (graphene_rect_t)) == 0;
}
static inline gboolean G_GNUC_PURE
static inline bool G_GNUC_PURE
rounded_rect_equal (const GskRoundedRect *r1,
const GskRoundedRect *r2)
{
int i;
if (r1 == r2)
return true;
if (!r1)
return FALSE;
return false;
if (r1->bounds.origin.x != r2->bounds.origin.x ||
r1->bounds.origin.y != r2->bounds.origin.y ||
r1->bounds.size.width != r2->bounds.size.width ||
r1->bounds.size.height != r2->bounds.size.height)
return FALSE;
return false;
for (i = 0; i < 4; i ++)
for (int i = 0; i < 4; i ++)
if (r1->corner[i].width != r2->corner[i].width ||
r1->corner[i].height != r2->corner[i].height)
return FALSE;
return false;
return TRUE;
return true;
}
static inline gboolean G_GNUC_PURE
@@ -208,10 +209,9 @@ ops_free (RenderOpBuilder *builder)
void
ops_set_program (RenderOpBuilder *builder,
Program *program)
Program *program)
{
OpProgram *op;
ProgramState *program_state = NULL;
if (builder->current_program == program)
return;
@@ -220,86 +220,6 @@ ops_set_program (RenderOpBuilder *builder,
op->program = program;
builder->current_program = program;
program_state = &program->state;
if (memcmp (&builder->current_projection, &program_state->projection, sizeof (graphene_matrix_t)) != 0)
{
OpMatrix *opm;
opm = ops_begin (builder, OP_CHANGE_PROJECTION);
opm->matrix = builder->current_projection;
program_state->projection = builder->current_projection;
}
if (program_state->modelview == NULL ||
!gsk_transform_equal (builder->current_modelview, program_state->modelview))
{
OpMatrix *opm;
opm = ops_begin (builder, OP_CHANGE_MODELVIEW);
gsk_transform_to_matrix (builder->current_modelview, &opm->matrix);
gsk_transform_unref (program_state->modelview);
program_state->modelview = gsk_transform_ref (builder->current_modelview);
}
if (!rect_equal (&builder->current_viewport, &program_state->viewport))
{
OpViewport *opv;
opv = ops_begin (builder, OP_CHANGE_VIEWPORT);
opv->viewport = builder->current_viewport;
program_state->viewport = builder->current_viewport;
}
if (!rounded_rect_equal (builder->current_clip, &program_state->clip))
{
OpClip *opc;
opc = ops_begin (builder, OP_CHANGE_CLIP);
opc->clip = *builder->current_clip;
opc->send_corners = !rounded_rect_corners_equal (builder->current_clip, &program_state->clip);
program_state->clip = *builder->current_clip;
}
if (program_state->opacity != builder->current_opacity)
{
OpOpacity *opo;
opo = ops_begin (builder, OP_CHANGE_OPACITY);
opo->opacity = builder->current_opacity;
program_state->opacity = builder->current_opacity;
}
}
static void
ops_set_clip (RenderOpBuilder *builder,
const GskRoundedRect *clip)
{
ProgramState *current_program_state = get_current_program_state (builder);
OpClip *op;
if (current_program_state &&
rounded_rect_equal (&current_program_state->clip, clip))
return;
if (!(op = op_buffer_peek_tail_checked (&builder->render_ops, OP_CHANGE_CLIP)))
{
op = op_buffer_add (&builder->render_ops, OP_CHANGE_CLIP);
op->send_corners = !current_program_state ||
!rounded_rect_corners_equal (&current_program_state->clip, clip);
}
else
{
/* If the op before sent the corners, this one needs, too */
op->send_corners |= !current_program_state ||
!rounded_rect_corners_equal (&current_program_state->clip, clip);
}
op->clip = *clip;
if (current_program_state)
current_program_state->clip = *clip;
}
void
@@ -318,7 +238,6 @@ ops_push_clip (RenderOpBuilder *self,
g_array_append_val (self->clip_stack, entry);
self->current_clip = &g_array_index (self->clip_stack, ClipStackEntry, self->clip_stack->len - 1).rect;
self->clip_is_rectilinear = entry.is_rectilinear;
ops_set_clip (self, clip);
}
void
@@ -336,7 +255,6 @@ ops_pop_clip (RenderOpBuilder *self)
{
self->current_clip = &head->rect;
self->clip_is_rectilinear = head->is_rectilinear;
ops_set_clip (self, &head->rect);
}
else
{
@@ -352,32 +270,6 @@ ops_has_clip (RenderOpBuilder *self)
self->clip_stack->len > 1;
}
static void
ops_set_modelview_internal (RenderOpBuilder *builder,
GskTransform *transform)
{
ProgramState *current_program_state = get_current_program_state (builder);
OpMatrix *op;
#if 0
XXX This is not possible if we want pop() to work.
if (builder->current_program &&
gsk_transform_equal (builder->current_program_state->modelview, transform))
return;
#endif
if (!(op = op_buffer_peek_tail_checked (&builder->render_ops, OP_CHANGE_MODELVIEW)))
op = op_buffer_add (&builder->render_ops, OP_CHANGE_MODELVIEW);
gsk_transform_to_matrix (transform, &op->matrix);
if (builder->current_program != NULL)
{
gsk_transform_unref (current_program_state->modelview);
current_program_state->modelview = gsk_transform_ref (transform);
}
}
/**
* ops_set_modelview:
* @builder
@@ -410,7 +302,6 @@ ops_set_modelview (RenderOpBuilder *builder,
builder->current_modelview = entry->transform;
builder->scale_x = entry->metadata.scale_x;
builder->scale_y = entry->metadata.scale_y;
ops_set_modelview_internal (builder, entry->transform);
}
/* This sets the given modelview to the one we get when multiplying
@@ -456,7 +347,6 @@ ops_push_modelview (RenderOpBuilder *builder,
builder->scale_x = entry->metadata.scale_x;
builder->scale_y = entry->metadata.scale_y;
builder->current_modelview = entry->transform;
ops_set_modelview_internal (builder, entry->transform);
}
void
@@ -480,7 +370,6 @@ ops_pop_modelview (RenderOpBuilder *builder)
builder->scale_x = head->metadata.scale_x;
builder->scale_y = head->metadata.scale_y;
builder->current_modelview = head->transform;
ops_set_modelview_internal (builder, head->transform);
}
else
{
@@ -492,17 +381,7 @@ graphene_matrix_t
ops_set_projection (RenderOpBuilder *builder,
const graphene_matrix_t *projection)
{
ProgramState *current_program_state = get_current_program_state (builder);
graphene_matrix_t prev_mv;
OpMatrix *op;
if (!(op = op_buffer_peek_tail_checked (&builder->render_ops, OP_CHANGE_PROJECTION)))
op = op_buffer_add (&builder->render_ops, OP_CHANGE_PROJECTION);
op->matrix = *projection;
if (builder->current_program != NULL)
current_program_state->projection = *projection;
prev_mv = builder->current_projection;
builder->current_projection = *projection;
@@ -518,9 +397,8 @@ ops_set_viewport (RenderOpBuilder *builder,
OpViewport *op;
graphene_rect_t prev_viewport;
if (current_program_state != NULL &&
rect_equal (&current_program_state->viewport, viewport))
return current_program_state->viewport;
if (rect_equal (&builder->current_viewport, viewport))
return *viewport;
op = ops_begin (builder, OP_CHANGE_VIEWPORT);
op->viewport = *viewport;
@@ -586,24 +464,14 @@ float
ops_set_opacity (RenderOpBuilder *builder,
float opacity)
{
ProgramState *current_program_state = get_current_program_state (builder);
OpOpacity *op;
float prev_opacity;
if (builder->current_opacity == opacity)
return opacity;
if (!(op = op_buffer_peek_tail_checked (&builder->render_ops, OP_CHANGE_OPACITY)))
op = op_buffer_add (&builder->render_ops, OP_CHANGE_OPACITY);
op->opacity = opacity;
prev_opacity = builder->current_opacity;
builder->current_opacity = opacity;
if (builder->current_program != NULL)
current_program_state->opacity = opacity;
return prev_opacity;
}
@@ -666,30 +534,30 @@ ops_set_color_matrix (RenderOpBuilder *builder,
const graphene_vec4_t *offset)
{
ProgramState *current_program_state = get_current_program_state (builder);
const bool offset_equal = graphene_vec4_equal (offset, &current_program_state->color_matrix.offset);
const bool matrix_equal = graphene_matrix_equal_fast (matrix,
&current_program_state->color_matrix.matrix);
OpColorMatrix *op;
bool offset_equal;
offset_equal = memcmp (offset,
&current_program_state->color_matrix.offset,
sizeof (graphene_vec4_t)) == 0;
if (memcmp (matrix,
&current_program_state->color_matrix.matrix,
sizeof (graphene_matrix_t)) == 0 &&
offset_equal)
if (offset_equal && matrix_equal)
return;
current_program_state->color_matrix.matrix = *matrix;
op = ops_begin (builder, OP_CHANGE_COLOR_MATRIX);
op->matrix = matrix;
if (!matrix_equal)
{
current_program_state->color_matrix.matrix = *matrix;
op->matrix.value = matrix;
op->matrix.send = TRUE;
}
else
op->matrix.send = FALSE;
if (!offset_equal)
{
current_program_state->color_matrix.offset = *offset;
op->offset.value = offset;
op->offset.send = TRUE;
current_program_state->color_matrix.offset = *offset;
}
else
op->offset.send = FALSE;
@@ -755,8 +623,58 @@ GskQuadVertex *
ops_draw (RenderOpBuilder *builder,
const GskQuadVertex vertex_data[GL_N_VERTICES])
{
ProgramState *program_state = get_current_program_state (builder);
OpDraw *op;
if (memcmp (&builder->current_projection, &program_state->projection, sizeof (graphene_matrix_t)) != 0)
{
OpMatrix *opm;
opm = ops_begin (builder, OP_CHANGE_PROJECTION);
opm->matrix = builder->current_projection;
program_state->projection = builder->current_projection;
}
if (program_state->modelview == NULL ||
!gsk_transform_equal (builder->current_modelview, program_state->modelview))
{
OpMatrix *opm;
opm = ops_begin (builder, OP_CHANGE_MODELVIEW);
gsk_transform_to_matrix (builder->current_modelview, &opm->matrix);
gsk_transform_unref (program_state->modelview);
program_state->modelview = gsk_transform_ref (builder->current_modelview);
}
if (!rect_equal (&builder->current_viewport, &program_state->viewport))
{
OpViewport *opv;
opv = ops_begin (builder, OP_CHANGE_VIEWPORT);
opv->viewport = builder->current_viewport;
program_state->viewport = builder->current_viewport;
}
if (!rounded_rect_equal (builder->current_clip, &program_state->clip))
{
OpClip *opc;
opc = ops_begin (builder, OP_CHANGE_CLIP);
opc->clip = *builder->current_clip;
opc->send_corners = !rounded_rect_corners_equal (builder->current_clip, &program_state->clip);
program_state->clip = *builder->current_clip;
}
if (program_state->opacity != builder->current_opacity)
{
OpOpacity *opo;
opo = ops_begin (builder, OP_CHANGE_OPACITY);
opo->opacity = builder->current_opacity;
program_state->opacity = builder->current_opacity;
}
/* TODO: Did the additions above break the following optimization? */
if ((op = op_buffer_peek_tail_checked (&builder->render_ops, OP_DRAW)))
{
op->vao_size += GL_N_VERTICES;
@@ -941,6 +859,7 @@ void
ops_set_linear_gradient (RenderOpBuilder *self,
guint n_color_stops,
const GskColorStop *color_stops,
gboolean repeat,
float start_x,
float start_y,
float end_x,
@@ -994,6 +913,7 @@ ops_set_linear_gradient (RenderOpBuilder *self,
sizeof (GskColorStop) * real_n_color_stops);
}
op->repeat = repeat;
op->start_point[0] = start_x;
op->start_point[1] = start_y;
op->end_point[0] = end_x;
@@ -1004,6 +924,7 @@ void
ops_set_radial_gradient (RenderOpBuilder *self,
guint n_color_stops,
const GskColorStop *color_stops,
gboolean repeat,
float center_x,
float center_y,
float start,
@@ -1027,6 +948,7 @@ ops_set_radial_gradient (RenderOpBuilder *self,
op->radius[1] = vradius;
op->start = start;
op->end = end;
op->repeat = repeat;
}
void
@@ -1035,7 +957,7 @@ ops_set_conic_gradient (RenderOpBuilder *self,
const GskColorStop *color_stops,
float center_x,
float center_y,
float rotation)
float angle)
{
const guint real_n_color_stops = MIN (GL_MAX_GRADIENT_STOPS, n_color_stops);
OpConicGradient *op;
@@ -1049,6 +971,6 @@ ops_set_conic_gradient (RenderOpBuilder *self,
op->color_stops.send = true;
op->center[0] = center_x;
op->center[1] = center_y;
op->rotation = rotation;
op->angle = angle;
}
+9 -9
View File
@@ -118,22 +118,20 @@ struct _Program
struct {
int num_color_stops_location;
int color_stops_location;
int start_point_location;
int end_point_location;
int points_location;
int repeat_location;
} linear_gradient;
struct {
int num_color_stops_location;
int color_stops_location;
int center_location;
int start_location;
int end_location;
int radius_location;
int geometry_location;
int range_location;
int repeat_location;
} radial_gradient;
struct {
int num_color_stops_location;
int color_stops_location;
int center_location;
int rotation_location;
int geometry_location;
} conic_gradient;
struct {
int blur_radius_location;
@@ -319,6 +317,7 @@ void ops_set_unblurred_outset_shadow (RenderOpBuilder *se
void ops_set_linear_gradient (RenderOpBuilder *self,
guint n_color_stops,
const GskColorStop *color_stops,
gboolean repeat,
float start_x,
float start_y,
float end_x,
@@ -326,6 +325,7 @@ void ops_set_linear_gradient (RenderOpBuilder *self,
void ops_set_radial_gradient (RenderOpBuilder *self,
guint n_color_stops,
const GskColorStop *color_stops,
gboolean repeat,
float center_x,
float center_y,
float start,
@@ -337,7 +337,7 @@ void ops_set_conic_gradient (RenderOpBuilder *self,
const GskColorStop *color_stops,
float center_x,
float center_y,
float rotation);
float angle);
GskQuadVertex * ops_draw (RenderOpBuilder *builder,
const GskQuadVertex vertex_data[GL_N_VERTICES]);
+13 -12
View File
@@ -64,8 +64,10 @@ prepend_line_numbers (char *code,
}
static gboolean
check_shader_error (int shader_id,
GError **error)
check_shader_error (int shader_id,
int shader_type,
const char *resource_path,
GError **error)
{
int status;
int log_len;
@@ -91,7 +93,9 @@ check_shader_error (int shader_id,
prepend_line_numbers (code, s);
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_COMPILATION_FAILED,
"Compilation failure in shader.\nSource Code: %s\n\nError Message:\n%s\n\n",
"Compilation failure in %s shader %s.\nSource Code:\n%s\n\nError Message:\n%s\n\n",
(shader_type == GL_FRAGMENT_SHADER ? "fragment" : "vertex"),
resource_path,
s->str,
buffer);
@@ -184,7 +188,7 @@ gsk_gl_shader_builder_create_program (GskGLShaderBuilder *self,
});
glCompileShader (vertex_id);
if (!check_shader_error (vertex_id, error))
if (!check_shader_error (vertex_id, GL_VERTEX_SHADER, resource_path, error))
{
glDeleteShader (vertex_id);
goto out;
@@ -218,20 +222,22 @@ gsk_gl_shader_builder_create_program (GskGLShaderBuilder *self,
});
glCompileShader (fragment_id);
if (!check_shader_error (fragment_id, error))
if (!check_shader_error (fragment_id, GL_FRAGMENT_SHADER, resource_path, error))
{
glDeleteShader (fragment_id);
goto out;
}
print_shader_info ("Fragment shader", vertex_id, resource_path);
print_shader_info ("Fragment shader", fragment_id, resource_path);
program_id = glCreateProgram ();
glAttachShader (program_id, vertex_id);
glAttachShader (program_id, fragment_id);
glBindAttribLocation (program_id, 0, "aPosition");
glBindAttribLocation (program_id, 1, "vUv");
glBindAttribLocation (program_id, 1, "aUv");
glLinkProgram (program_id);
glDetachShader (program_id, vertex_id);
glDetachShader (program_id, fragment_id);
glGetProgramiv (program_id, GL_LINK_STATUS, &status);
if (status == GL_FALSE)
@@ -252,14 +258,9 @@ gsk_gl_shader_builder_create_program (GskGLShaderBuilder *self,
glDeleteProgram (program_id);
program_id = -1;
goto out;
}
glDetachShader (program_id, vertex_id);
glDeleteShader (vertex_id);
glDetachShader (program_id, fragment_id);
glDeleteShader (fragment_id);
out:
+5 -2
View File
@@ -53,6 +53,7 @@ typedef struct { GskRoundedRect value; guint send: 1; guint send_corners: 1; } R
typedef struct { const GdkRGBA *value; guint send: 1; } RGBAUniformValue;
typedef struct { const graphene_vec4_t *value; guint send: 1; } Vec4UniformValue;
typedef struct { const GskColorStop *value; guint send: 1; } ColorStopUniformValue;
typedef struct { const graphene_matrix_t *value; guint send: 1; } MatrixUniformValue;
/* OpNode are allocated within OpBuffer.pos, but we keep
* a secondary index into the locations of that buffer
@@ -145,6 +146,7 @@ typedef struct
IntUniformValue n_color_stops;
float start_point[2];
float end_point[2];
gboolean repeat;
} OpLinearGradient;
typedef struct
@@ -155,6 +157,7 @@ typedef struct
float end;
float radius[2];
float center[2];
gboolean repeat;
} OpRadialGradient;
typedef struct
@@ -162,12 +165,12 @@ typedef struct
ColorStopUniformValue color_stops;
IntUniformValue n_color_stops;
float center[2];
float rotation;
float angle;
} OpConicGradient;
typedef struct
{
const graphene_matrix_t *matrix;
MatrixUniformValue matrix;
Vec4UniformValue offset;
} OpColorMatrix;
+1 -1
View File
@@ -22,7 +22,7 @@ static guint gsk_debug_flags;
static void
init_debug_flags (void)
{
static volatile gsize gsk_debug_flags__set;
static gsize gsk_debug_flags__set;
if (g_once_init_enter (&gsk_debug_flags__set))
{
+1 -1
View File
@@ -13,7 +13,7 @@
GType
@enum_name@_get_type (void)
{
static volatile gsize g_define_type_id__volatile = 0;
static gsize g_define_type_id__volatile = 0;
if (g_once_init_enter (&g_define_type_id__volatile))
{
+1 -1
View File
@@ -184,7 +184,7 @@ gsk_render_node_init (GskRenderNode *self)
GType
gsk_render_node_get_type (void)
{
static volatile gsize render_node_type__volatile;
static gsize render_node_type__volatile;
if (g_once_init_enter (&render_node_type__volatile))
{
+2
View File
@@ -257,6 +257,8 @@ const graphene_point_t * gsk_conic_gradient_node_get_center (GskRenderNo
GDK_AVAILABLE_IN_ALL
float gsk_conic_gradient_node_get_rotation (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
float gsk_conic_gradient_node_get_angle (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
gsize gsk_conic_gradient_node_get_n_color_stops (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
const GskColorStop * gsk_conic_gradient_node_get_color_stops (GskRenderNode *node,
+50 -6
View File
@@ -782,6 +782,7 @@ struct _GskConicGradientNode
graphene_point_t center;
float rotation;
float angle;
gsize n_stops;
GskColorStop *stops;
@@ -1023,6 +1024,12 @@ gsk_conic_gradient_node_new (const graphene_rect_t *bounds,
self->stops = g_malloc_n (n_color_stops, sizeof (GskColorStop));
memcpy (self->stops, color_stops, n_color_stops * sizeof (GskColorStop));
self->angle = 90.f - self->rotation;
self->angle = G_PI * self->angle / 180.f;
self->angle = fmodf (self->angle, 2.f * G_PI);
if (self->angle < 0.f)
self->angle += 2.f * G_PI;
return node;
}
@@ -1095,6 +1102,26 @@ gsk_conic_gradient_node_get_rotation (GskRenderNode *node)
return self->rotation;
}
/**
* gsk_conic_gradient_node_get_angle:
* @node: (type GskConicGradientNode): a #GskRenderNode for a conic gradient
*
* Retrieves the angle for the gradient in radians, normalized in [0, 2 * PI]
*
* The angle is starting at the top and going clockwise, as expressed
* in the css specification:
* angle = 90 - gsk_conic_gradient_node_get_rotation()
*
* Returns: the angle for the gradient
*/
float
gsk_conic_gradient_node_get_angle (GskRenderNode *node)
{
GskConicGradientNode *self = (GskConicGradientNode *) node;
return self->angle;
}
/*** GSK_BORDER_NODE ***/
/**
@@ -1263,15 +1290,22 @@ gsk_border_node_diff (GskRenderNode *node1,
gdk_rgba_equal (&self1->border_color[0], &self2->border_color[0]))
return;
if (gsk_rounded_rect_equal (&self1->outline, &self2->outline) &&
/* Different uniformity -> diff impossible */
if (self1->uniform ^ self2->uniform)
{
gsk_render_node_diff_impossible (node1, node2, region);
return;
}
if (self1->border_width[0] == self2->border_width[0] &&
self1->border_width[1] == self2->border_width[1] &&
self1->border_width[2] == self2->border_width[2] &&
self1->border_width[3] == self2->border_width[3] &&
gdk_rgba_equal (&self1->border_color[0], &self2->border_color[0]) &&
gdk_rgba_equal (&self1->border_color[1], &self2->border_color[1]) &&
gdk_rgba_equal (&self1->border_color[2], &self2->border_color[2]) &&
gdk_rgba_equal (&self1->border_color[3], &self2->border_color[3]) &&
self1->border_width[0] == self2->border_width[0] &&
self1->border_width[1] == self2->border_width[1] &&
self1->border_width[2] == self2->border_width[2] &&
self1->border_width[3] == self2->border_width[3])
gsk_rounded_rect_equal (&self1->outline, &self2->outline))
return;
gsk_render_node_diff_impossible (node1, node2, region);
@@ -2755,6 +2789,16 @@ gsk_transform_node_draw (GskRenderNode *node,
ctm.xx, ctm.yx,
ctm.xy, ctm.yy,
ctm.x0, ctm.y0));
if (xx * yy == xy * yx)
{
/* broken matrix here. This can happen during transitions
* (like when flipping an axis at the point where scale == 0)
* and just means that nothing should be drawn.
* But Cairo thows lots of ugly errors instead of silently
* going on. So We silently go on.
*/
return;
}
cairo_transform (cr, &ctm);
gsk_render_node_draw (self->child, cr);
@@ -5632,7 +5676,7 @@ gsk_render_node_init_types_once (void)
void
gsk_render_node_init_types (void)
{
static volatile gsize register_types__volatile;
static gsize register_types__volatile;
if (g_once_init_enter (&register_types__volatile))
{
+92 -62
View File
@@ -688,10 +688,18 @@ create_ascii_glyphs (PangoFont *font)
glyph_string = pango_glyph_string_new ();
for (i = MIN_ASCII_GLYPH; i < MAX_ASCII_GLYPH; i++)
{
pango_shape ((char[2]) { i, 0 },
1,
&not_a_hack,
glyph_string);
const char text[2] = { i, 0 };
PangoShapeFlags flags = 0;
if (cairo_version () < CAIRO_VERSION_ENCODE (1, 17, 4))
flags = PANGO_SHAPE_ROUND_POSITIONS;
pango_shape_with_flags (text, 1,
text, 1,
&not_a_hack,
glyph_string,
flags);
if (glyph_string->num_glyphs != 1)
{
pango_glyph_string_free (glyph_string);
@@ -1386,7 +1394,7 @@ parse_cairo_node (GtkCssParser *parser)
if (surface != NULL)
{
cairo_t *cr = gsk_cairo_node_get_draw_context (node);
cairo_set_source_surface (cr, surface, 0, 0);
cairo_set_source_surface (cr, surface, bounds.origin.x, bounds.origin.y);
cairo_paint (cr);
cairo_destroy (cr);
}
@@ -2304,6 +2312,84 @@ base64_encode_with_linebreaks (const guchar *data,
return out;
}
void
gsk_text_node_serialize_glyphs (GskRenderNode *node,
GString *p)
{
const guint n_glyphs = gsk_text_node_get_num_glyphs (node);
const PangoGlyphInfo *glyphs = gsk_text_node_get_glyphs (node, NULL);
PangoFont *font = gsk_text_node_get_font (node);
GString *str;
guint i, j;
PangoGlyphString *ascii;
ascii = create_ascii_glyphs (font);
str = g_string_new ("");
for (i = 0; i < n_glyphs; i++)
{
if (ascii)
{
for (j = 0; j < ascii->num_glyphs; j++)
{
if (glyphs[i].glyph == ascii->glyphs[j].glyph &&
glyphs[i].geometry.width == ascii->glyphs[j].geometry.width &&
glyphs[i].geometry.x_offset == 0 &&
glyphs[i].geometry.y_offset == 0 &&
glyphs[i].attr.is_cluster_start)
{
g_string_append_c (str, j + MIN_ASCII_GLYPH);
break;
}
else if (glyphs[i].glyph == ascii->glyphs[j].glyph)
{
if (glyphs[i].geometry.width != ascii->glyphs[j].geometry.width)
g_print ("not ascii because of width (%d != %d)\n",
glyphs[i].geometry.width,
ascii->glyphs[j].geometry.width);
if (glyphs[i].geometry.x_offset != 0 ||
glyphs[i].geometry.y_offset != 0)
g_print ("not ascii because of offset\n");
if (!glyphs[i].attr.is_cluster_start)
g_print ("not ascii because of cluster\n");
}
}
if (j != ascii->num_glyphs)
continue;
}
if (str->len)
{
g_string_append_printf (p, "\"%s\", ", str->str);
g_string_set_size (str, 0);
}
g_string_append_printf (p, "%u %g",
glyphs[i].glyph,
(double) glyphs[i].geometry.width / PANGO_SCALE);
if (!glyphs[i].attr.is_cluster_start ||
glyphs[i].geometry.x_offset != 0 ||
glyphs[i].geometry.y_offset != 0)
{
g_string_append_printf (p, " %g %g",
(double) glyphs[i].geometry.x_offset / PANGO_SCALE,
(double) glyphs[i].geometry.y_offset / PANGO_SCALE);
if (!glyphs[i].attr.is_cluster_start)
g_string_append (p, " same-cluster");
}
if (i + 1 < n_glyphs)
g_string_append (p, ", ");
}
if (str->len)
g_string_append_printf (p, "\"%s\"", str->str);
g_string_free (str, TRUE);
if (ascii)
pango_glyph_string_free (ascii);
}
static void
render_node_print (Printer *p,
GskRenderNode *node)
@@ -2631,16 +2717,11 @@ render_node_print (Printer *p,
case GSK_TEXT_NODE:
{
const guint n_glyphs = gsk_text_node_get_num_glyphs (node);
const PangoGlyphInfo *glyphs = gsk_text_node_get_glyphs (node, NULL);
const graphene_point_t *offset = gsk_text_node_get_offset (node);
const GdkRGBA *color = gsk_text_node_get_color (node);
PangoFont *font = gsk_text_node_get_font (node);
PangoFontDescription *desc;
char *font_name;
GString *str;
guint i, j;
PangoGlyphString *ascii = create_ascii_glyphs (font);
start_node (p, "text");
@@ -2650,61 +2731,14 @@ render_node_print (Printer *p,
_indent (p);
desc = pango_font_describe (font);
font_name = pango_font_description_to_string (desc);
if (ascii == NULL)
g_print ("\"%s\" has no ascii table\n", font_name);
g_string_append_printf (p->str, "font: \"%s\";\n", font_name);
g_free (font_name);
pango_font_description_free (desc);
_indent (p);
str = g_string_new (NULL);
g_string_append (p->str, "glyphs: ");
for (i = 0; i < n_glyphs; i++)
{
if (ascii)
{
for (j = 0; j < ascii->num_glyphs; j++)
{
if (glyphs[i].glyph == ascii->glyphs[j].glyph &&
glyphs[i].geometry.width == ascii->glyphs[j].geometry.width &&
glyphs[i].geometry.x_offset == 0 &&
glyphs[i].geometry.y_offset == 0 &&
glyphs[i].attr.is_cluster_start)
{
g_string_append_c (str, j + MIN_ASCII_GLYPH);
break;
}
}
if (j != ascii->num_glyphs)
continue;
}
if (str->len)
{
g_string_append_printf (p->str, "\"%s\", ", str->str);
g_string_set_size (str, 0);
}
g_string_append_printf (p->str, "%u %g",
glyphs[i].glyph,
(double) glyphs[i].geometry.width / PANGO_SCALE);
if (!glyphs[i].attr.is_cluster_start ||
glyphs[i].geometry.x_offset != 0 ||
glyphs[i].geometry.y_offset != 0)
{
g_string_append_printf (p->str, "%g %g",
(double) glyphs[i].geometry.x_offset / PANGO_SCALE,
(double) glyphs[i].geometry.y_offset / PANGO_SCALE);
if (!glyphs[i].attr.is_cluster_start)
g_string_append (p->str, " same-cluster");
}
if (i + 1 < n_glyphs)
g_string_append (p->str, ", ");
}
if (str->len)
g_string_append_printf (p->str, "\"%s\"", str->str);
gsk_text_node_serialize_glyphs (node, p->str);
g_string_append_c (p->str, ';');
g_string_append_c (p->str, '\n');
@@ -2713,10 +2747,6 @@ render_node_print (Printer *p,
append_point_param (p, "offset", offset);
end_node (p);
g_string_free (str, TRUE);
if (ascii)
pango_glyph_string_free (ascii);
}
break;
+3
View File
@@ -96,6 +96,9 @@ void gsk_render_node_diff_impossible (GskRenderNode
bool gsk_border_node_get_uniform (GskRenderNode *self);
void gsk_text_node_serialize_glyphs (GskRenderNode *self,
GString *str);
G_END_DECLS
#endif /* __GSK_RENDER_NODE_PRIVATE_H__ */
+10
View File
@@ -7,6 +7,16 @@
G_BEGIN_DECLS
#define GSK_ROUNDED_RECT_INIT_FROM_RECT(_r) \
(GskRoundedRect) { .bounds = _r, \
.corner = { \
GRAPHENE_SIZE_INIT(0, 0),\
GRAPHENE_SIZE_INIT(0, 0),\
GRAPHENE_SIZE_INIT(0, 0),\
GRAPHENE_SIZE_INIT(0, 0),\
}}
gboolean gsk_rounded_rect_is_circular (const GskRoundedRect *self);
void gsk_rounded_rect_path (const GskRoundedRect *self,

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