Compare commits
399 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e5d0f32d8c | |||
| e825fd901f | |||
| e3543f37d3 | |||
| e9bf0322ac | |||
| 6d5cb0a083 | |||
| 8b5aab459a | |||
| 8da3cc10fd | |||
| f48a4e84af | |||
| 09c76208a2 | |||
| 62b1d21556 | |||
| 8fba58eaa9 | |||
| b4890edd64 | |||
| 93b9388180 | |||
| 76b2609ad5 | |||
| a37a0711ad | |||
| 23dbb7122c | |||
| e04ab263f9 | |||
| 5e6e808a55 | |||
| 6eaf6e2f7d | |||
| e4a4a0f6dd | |||
| f301ea7936 | |||
| a3e9ecd199 | |||
| cda1733fc7 | |||
| 0ee851c8c7 | |||
| ed3b73871f | |||
| e570eb4f86 | |||
| cfaf619620 | |||
| de5b6764bc | |||
| bc17dfa83d | |||
| 84a98f74c1 | |||
| 50facedc47 | |||
| 200cacc3ad | |||
| eed3cab29f | |||
| 76b0687467 | |||
| 5039dc40f8 | |||
| 7c3de4a2da | |||
| b486e9b760 | |||
| ce2fd8a0d0 | |||
| 99b1b26fdb | |||
| b7e4bbaf74 | |||
| f579b171a9 | |||
| f9929d15eb | |||
| c45a6ad52d | |||
| 7233e38aa8 | |||
| 73ba97acd9 | |||
| 7d2ad604d2 | |||
| 45e64b915c | |||
| ebaef9f18b | |||
| c73fe8ac4a | |||
| 8ed8f883d1 | |||
| 032a5afc20 | |||
| 0064500146 | |||
| 4582ddcad9 | |||
| 8bb2720494 | |||
| 3b8218a99e | |||
| 9a8fa8dd82 | |||
| d6892c85dc | |||
| d3c20c3269 | |||
| 9904259661 | |||
| a8fcde11de | |||
| d2d4cd64cd | |||
| 2c7e68d98f | |||
| 6f42f8ef2c | |||
| 152dd70cde | |||
| 8ec1045c87 | |||
| 46866b8a66 | |||
| 9df6f802f2 | |||
| ad8613876c | |||
| 1bbca0cd25 | |||
| 83784c17a3 | |||
| 3f46d0f2fa | |||
| ef1ff8313f | |||
| 119a07e055 | |||
| abfd94d2d9 | |||
| 6022fbcdf8 | |||
| 744016e768 | |||
| d39f50a4ee | |||
| c23d3c4406 | |||
| 1e2eae4ddf | |||
| 77eb3df7c0 | |||
| e540022869 | |||
| e6700405c9 | |||
| 5bbd8e12fa | |||
| 8b59771cd1 | |||
| 8a0a08e4ce | |||
| bef6352401 | |||
| 60a43ddce0 | |||
| 90c9e88ee9 | |||
| d860bf95ab | |||
| a3bd0a3e17 | |||
| d274c7df06 | |||
| 9a5f482e1a | |||
| 2f6140c066 | |||
| 9ce4471527 | |||
| cda4ec48b2 | |||
| d9582c123e | |||
| 4d30aacb0c | |||
| 4862c3f779 | |||
| 08d1353cde | |||
| 585dadf575 | |||
| d069eb173a | |||
| 6015560b63 | |||
| 5a776389d7 | |||
| 6c2dfed5a5 | |||
| 7dec24c2cc | |||
| c20e7a0c5d | |||
| 719021e1f4 | |||
| 4856e115a9 | |||
| bfb5bbe862 | |||
| b98c86fb7b | |||
| e01c3f581e | |||
| c45199e388 | |||
| 27fb9917d8 | |||
| b5d6613a3f | |||
| 5dc77edbe3 | |||
| a3d63b3579 | |||
| 57c12a8661 | |||
| f1ccb9b81a | |||
| 2711cb8dcd | |||
| c79925bd4a | |||
| 05d5860dc0 | |||
| a1fdf06d80 | |||
| 36d7ca058e | |||
| 2e08db91ca | |||
| 2c9b47ff3c | |||
| 62ad1a61dc | |||
| 3fc9de7539 | |||
| 1c9a55d185 | |||
| 492940205e | |||
| 985e4906c8 | |||
| e9dcf8167c | |||
| 3aa6c27c26 | |||
| f537a55b71 | |||
| 7075e6be89 | |||
| 016354b6dd | |||
| 1dfc6d65df | |||
| b7d0295481 | |||
| a2854af325 | |||
| 320496b039 | |||
| b0450d4b1b | |||
| 91ff8bf336 | |||
| 7b145f72dc | |||
| 0dcc21b605 | |||
| bd43a9e868 | |||
| 9bf23d80a1 | |||
| 38fd66dc04 | |||
| f004f14b89 | |||
| 8f15f6959c | |||
| f26efd9adf | |||
| 3f342d75b2 | |||
| 3ab189404e | |||
| 48fc8d6606 | |||
| 2e0f411de9 | |||
| f08e36e225 | |||
| 9f358ac655 | |||
| 33d1349e53 | |||
| 6b2b6ceb74 | |||
| 76421847a5 | |||
| 840cd6e44c | |||
| f81038e99a | |||
| 007e7c68dc | |||
| e5e147ad53 | |||
| 58e00040e0 | |||
| 5d1b8399fb | |||
| deec2b6c6c | |||
| 246eb8ea25 | |||
| 815df9a76a | |||
| f896dddadc | |||
| d733e94a8b | |||
| 59db0ca328 | |||
| 3bd97590a1 | |||
| 722a0fa36d | |||
| b21708c5e4 | |||
| b5fb584316 | |||
| fd1e1b9b7c | |||
| c0caae0ff0 | |||
| 5c972e4786 | |||
| 1a3c5cf420 | |||
| eb7affd911 | |||
| a05dbff2c9 | |||
| 4b0d17b332 | |||
| 2d8f677e63 | |||
| b5c9b6aa25 | |||
| 86924c2f9a | |||
| af0f5e3f30 | |||
| 9e6c72210d | |||
| ce0b2d6953 | |||
| d1bb3f66ac | |||
| 70cd0e28ab | |||
| 2e00bcc580 | |||
| db68c1f2c6 | |||
| e3fa60a070 | |||
| c9c29d8bde | |||
| cd59d62947 | |||
| 4f4fe4ef44 | |||
| 06f83847c6 | |||
| 941b5c2aeb | |||
| d661b7f258 | |||
| f86d996d58 | |||
| fe3031fb99 | |||
| 4b001a24db | |||
| 4727fea631 | |||
| 7ff4cba624 | |||
| 0363cc83b9 | |||
| c1327e2c1b | |||
| 9971707544 | |||
| 02115912aa | |||
| e29571e6a6 | |||
| 582ad79088 | |||
| 3fac42fd3c | |||
| 8f0b38b462 | |||
| 6c5a106d7e | |||
| 5f7cab4632 | |||
| 558db5a3a7 | |||
| bc94b4f235 | |||
| 4c809281b2 | |||
| 81faf7caa3 | |||
| 7477e8626d | |||
| 47f30d208c | |||
| 74a1c0916a | |||
| ee67edbe3a | |||
| ec9cdb74ef | |||
| ad0f9144ec | |||
| 3e8215a971 | |||
| 8df7487e2a | |||
| 633692b53e | |||
| e0a5c65003 | |||
| e4753791c0 | |||
| a57f7e3935 | |||
| 8de5a94eb7 | |||
| 88872d1986 | |||
| ab33b56ec9 | |||
| c37e88d561 | |||
| 2638700435 | |||
| 0a5a720fe1 | |||
| 0e5f7601e4 | |||
| e583e823b5 | |||
| a96358046f | |||
| 40f26ea09b | |||
| 71a7f0771b | |||
| 00739718ab | |||
| 19881c8c06 | |||
| 8b0aae8536 | |||
| fbe000734a | |||
| 0c67b367ac | |||
| f75b4aac1d | |||
| d563d158c0 | |||
| 5c892fa4ea | |||
| 4aac64edf0 | |||
| c97bbfdfb1 | |||
| a44598772d | |||
| 933a0e5a98 | |||
| e33e9c506d | |||
| 0108a5f56d | |||
| c995473407 | |||
| 3f9bdaa4c8 | |||
| a70998aa50 | |||
| 0fb1f44eec | |||
| 26cc96bb7f | |||
| 1c8b22cf05 | |||
| abbbd08931 | |||
| 587cf28dd3 | |||
| 53231a137c | |||
| 104a264d8b | |||
| 75fd582b97 | |||
| 89977412e9 | |||
| ce030b1b36 | |||
| 6c5dc8cd1f | |||
| fb4b38e5ea | |||
| fc405f8882 | |||
| afe61e28e0 | |||
| 4f3f3c9ae2 | |||
| e699685003 | |||
| 9583195e96 | |||
| a526f0770e | |||
| 707e492f0d | |||
| 680dba6524 | |||
| d1bb1d091c | |||
| 6510b876d1 | |||
| e376941e49 | |||
| 4889199b14 | |||
| 2e15225446 | |||
| 9dad71513c | |||
| ed072b4b5d | |||
| 7ffc4e0a21 | |||
| b9403f4f5b | |||
| 9f1aa3141b | |||
| 06e905f87d | |||
| 2ba8dcebff | |||
| 95a8def7c2 | |||
| 777799070d | |||
| 0f83a9550b | |||
| 17f2443350 | |||
| 6bfc995097 | |||
| 8068111c6e | |||
| 6e1c47b021 | |||
| aed4ced032 | |||
| 96160ea5dc | |||
| c76c07ddfe | |||
| 7b82dc7ac5 | |||
| a63e9d38fb | |||
| cc8db1805d | |||
| 948532f3c9 | |||
| 8f39f8d827 | |||
| 5e28c05121 | |||
| 32d15a5858 | |||
| 460eaac1f4 | |||
| 02d7817632 | |||
| 3080e2974d | |||
| be9d98ed38 | |||
| 944274bc58 | |||
| b555e909c4 | |||
| c0b813940e | |||
| 9fe9ea34fd | |||
| d90dc7f75e | |||
| f36f1b9829 | |||
| 2b09f5ea1e | |||
| f51c82a2aa | |||
| 11d3be278d | |||
| cc98282caa | |||
| 85f2e1ccd8 | |||
| 91b98bc9e2 | |||
| 704ee6a9d0 | |||
| 72e9f30937 | |||
| aadaf4adf2 | |||
| d83ad6b505 | |||
| b647d1a58c | |||
| 3c94e91e5e | |||
| 8a1bee1d79 | |||
| 9297439de4 | |||
| 68cff3b108 | |||
| 84846aace7 | |||
| 7bd93730d1 | |||
| c5d05fdc88 | |||
| f6ff2cd1cb | |||
| 9b0060e84d | |||
| 8d5633cb88 | |||
| f74b1d48b6 | |||
| 27ebf756fe | |||
| 631da2e723 | |||
| b5531d3d6f | |||
| 5e6bc41fdd | |||
| d0581af2af | |||
| cec746804d | |||
| ade1aaa8be | |||
| 345d23898d | |||
| 415717276a | |||
| cebe640bce | |||
| 73084b761f | |||
| eb13ecfbe7 | |||
| 85c4507609 | |||
| fcb6c8e447 | |||
| 0b27f39c2b | |||
| 2101f880af | |||
| 2cc241732d | |||
| c01782b0a9 | |||
| a62831562f | |||
| 40dd81e1a4 | |||
| a9f3a52c18 | |||
| 0978912922 | |||
| 3c9923d395 | |||
| 0296f49eb0 | |||
| 4b7a550366 | |||
| 37e18b784e | |||
| 1275a2cb8d | |||
| 67a6f343a0 | |||
| a98e6bff85 | |||
| d0f5644771 | |||
| b1a3ac8330 | |||
| 80811069ac | |||
| 6e3dc1e669 | |||
| d1aa0a74e4 | |||
| 7a6fb09179 | |||
| 5732c5e3d0 | |||
| 79fb3d9b0c | |||
| 17455054f1 | |||
| 763f51cb98 | |||
| 9fb78603ec | |||
| f802be88e9 | |||
| b9d2049991 | |||
| cfe3558610 | |||
| 35d15de3b6 | |||
| 23a336df0e | |||
| bacdc735a4 | |||
| 19a168446e | |||
| 47ec7bc66d | |||
| b4178870dd | |||
| 03ef792802 | |||
| 7955efef6c | |||
| 3134003376 | |||
| a508860d1f | |||
| c835ca41e0 | |||
| 2d5eafd014 | |||
| 9b34878208 | |||
| 4b1b956d27 | |||
| 0dd58c4d1b | |||
| 02cdb36421 | |||
| b3d4d70bc1 | |||
| 715c0bfc0a |
+1
-2
@@ -445,9 +445,8 @@ reference:
|
||||
--force-fallback-for=gdk-pixbuf,pango
|
||||
-Dintrospection=enabled
|
||||
-Ddocumentation=true
|
||||
-Dgtk_doc=true
|
||||
-Dgdk-pixbuf:gtk_doc=true
|
||||
-Dpango:gtk_doc=true
|
||||
-Dpango:documentation=true
|
||||
-Dbuild-demos=false
|
||||
-Dbuild-examples=false
|
||||
-Dbuild-tests=false
|
||||
|
||||
@@ -24,7 +24,7 @@ flatpak build ${builddir} meson \
|
||||
-Dbuild-examples=false \
|
||||
-Dintrospection=disabled \
|
||||
-Dbuild-demos=true \
|
||||
-Ddemo-profile=devel \
|
||||
-Dprofile=devel \
|
||||
_flatpak_build
|
||||
|
||||
flatpak build --env=CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA ${builddir} ninja -C _flatpak_build install
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
Overview of Changes in 4.14.4, 02-05-2024
|
||||
Overview of Changes in 4.15.1, xx-xx-xxxx
|
||||
=========================================
|
||||
|
||||
* GtkGraphicsOffload:
|
||||
- Don't crash without a child
|
||||
|
||||
* CSS:
|
||||
- Support the :root selector
|
||||
|
||||
* Icontheme:
|
||||
- Make symbolic svg loading more efficient
|
||||
- Handle color-free symbolics more efficiently
|
||||
@@ -14,56 +17,141 @@ Overview of Changes in 4.14.4, 02-05-2024
|
||||
|
||||
* GDK:
|
||||
- Support XDG_ACTIVATION_TOKEN
|
||||
- dmabuf: Be more defensive when importing unknown formats to G
|
||||
- dmabuf: Be more defensive when importing unknown formats to GL
|
||||
- dmabuf: Use narrow range for YUV
|
||||
|
||||
* GSK:
|
||||
- gpu: Handle tiny offscreens correctl
|
||||
- Improve logging for GDK_DEBUG=offload
|
||||
- Improve logging for GSK_DEBUG=renderer
|
||||
- gpu: Warn about inefficient texture import
|
||||
- gpu: Handle tiny offscreens correctly
|
||||
- vulkan: Add profiler marks in various places
|
||||
- vulkan: Fix a problem with imported dmabufs showing up black
|
||||
|
||||
* Wayland:
|
||||
- Use wl_compositor version 6
|
||||
|
||||
* X11:
|
||||
- Implement a missing method
|
||||
|
||||
* Build:
|
||||
- Fix many ubsan warning
|
||||
- Fix many ubsan warnings
|
||||
|
||||
* macOS
|
||||
* Debugging:
|
||||
- Show more texture details in the recorder
|
||||
|
||||
* macOS:
|
||||
- Fix problems with events handed back to the OS
|
||||
- Respect GDK_DEBUG=default-settings
|
||||
|
||||
* Translation updates:
|
||||
German
|
||||
Indonesian
|
||||
Kabyle
|
||||
Korean
|
||||
Lithuanian
|
||||
Russian
|
||||
Turkish
|
||||
|
||||
|
||||
Overview of Changes in 4.14.3, 18-04-2024
|
||||
Overview of Changes in 4.15.0, 21-04-2024
|
||||
=========================================
|
||||
|
||||
This release changes the default GSK renderer to be Vulkan, on
|
||||
Wayland. Other platforms still use ngl.
|
||||
|
||||
The intent of this change is to get wider testing and verify that
|
||||
Vulkan drivers are good enough for us to rely on. If significant
|
||||
problems show up, we will revert this change for 4.16.
|
||||
|
||||
You can still override the renderer choice using the GSK_RENDERER
|
||||
environment variable.
|
||||
|
||||
---
|
||||
|
||||
This release also changes font rendering settings by introducing
|
||||
a new high-level gtk-font-rendering settings which gives GTK more
|
||||
freedom to decide on font rendering.
|
||||
|
||||
You can still use the low-level font-related settings by changing
|
||||
the new property to 'manual'.
|
||||
|
||||
---
|
||||
|
||||
* GtkColumnView:
|
||||
- Fix infinite loops in dispose
|
||||
- Fix problems with weak ref cycles in GtkExpression
|
||||
|
||||
* GtkListView:
|
||||
* GtkShortcutManager:
|
||||
- Track the propagation phase of added controllers
|
||||
|
||||
* GtkGLArea:
|
||||
- Produce dmabuf textures, so graphics offload is possible
|
||||
|
||||
* GtkTextView:
|
||||
- Support text shadows
|
||||
|
||||
* GtkGraphicsOffload:
|
||||
- Add a black-background property
|
||||
|
||||
* Settings:
|
||||
- Add a new gtk-font-rendering setting
|
||||
|
||||
* Accessibility:
|
||||
- Add support for GetRangeExtents to GtkAccessibleText
|
||||
- Add support for GetOffsetAtPoint to GtkAccessibleText
|
||||
- Implement GtkAccessibleRange for scrollbars
|
||||
|
||||
* GDK:
|
||||
- Add a callback-based cursor API
|
||||
|
||||
* GSK:
|
||||
- Use the Vulkan renderer by default
|
||||
- Avoid an infinite recursion with offscreens in some cases
|
||||
- Optimize graphics offload to make it more likely that compositors
|
||||
can use direct scanout
|
||||
|
||||
* X11:
|
||||
- Fix some confusing debug messages
|
||||
- Drop a no-longer-relevant optimization that was interfering with
|
||||
getting the current window manager capabilities
|
||||
|
||||
* macOS:
|
||||
- Implement the color picker for macOS 10.15+
|
||||
|
||||
* Debugging:
|
||||
- Snow monitor resolution in the inspector
|
||||
|
||||
* Demos:
|
||||
- Use graphics offload in the shadertoy demo
|
||||
- Show more reliable fps numbers in the fishbowl demo
|
||||
|
||||
* Tools:
|
||||
- Support generating pdf in gtk4-rendernode-tool
|
||||
|
||||
* Build:
|
||||
- Require pango 1.52
|
||||
- Require cairo 1.18
|
||||
- Add a missing dependency that was causing build failures
|
||||
- Drop deprecated build options:
|
||||
gtk_doc -> documentation
|
||||
update_screenshots -> screenshots
|
||||
demo-profile -> profile
|
||||
demos -> build-demos
|
||||
|
||||
* Deprecations:
|
||||
- gdk_widget_set/get_font_options
|
||||
- gdk_wayland/x11_display_set_cursor_theme
|
||||
|
||||
* Translation updates:
|
||||
Basque
|
||||
Brazilian Portuguese
|
||||
Georgian
|
||||
British English
|
||||
Chinese (China)
|
||||
Hebrew
|
||||
Kabyle
|
||||
Persian
|
||||
Polish
|
||||
Russian
|
||||
Slovenian
|
||||
Swedish
|
||||
Ukrainian
|
||||
Turkish
|
||||
|
||||
|
||||
Overview of Changes in 4.14.2, 03-04-2024
|
||||
|
||||
@@ -186,7 +186,7 @@
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Ddemo-profile=devel"
|
||||
"-Dprofile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Ddemo-profile=devel"
|
||||
"-Dprofile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Ddemo-profile=devel"
|
||||
"-Dprofile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Ddemo-profile=devel"
|
||||
"-Dprofile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
||||
@@ -15,12 +15,54 @@ on_destroy (gpointer data)
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
static GdkTexture *
|
||||
cursor_callback (GdkCursor *cursor,
|
||||
int cursor_size,
|
||||
double scale,
|
||||
int *width,
|
||||
int *height,
|
||||
int *hotspot_x,
|
||||
int *hotspot_y,
|
||||
gpointer data)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture;
|
||||
GError *error = NULL;
|
||||
int scaled_size;
|
||||
|
||||
scaled_size = ceil (cursor_size * scale);
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_resource_at_scale ("/cursors/images/gtk-logo.svg",
|
||||
scaled_size, scaled_size,
|
||||
TRUE,
|
||||
&error);
|
||||
if (!pixbuf)
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
*width = cursor_size;
|
||||
*height = cursor_size;
|
||||
*hotspot_x = 18 * cursor_size / 32.0;
|
||||
*hotspot_y = 2 * cursor_size / 32.0;
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_cursors (GtkWidget *do_widget)
|
||||
{
|
||||
if (!window)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GtkWidget *logo_callback;
|
||||
GdkCursor *cursor;
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/cursors/cursors.ui");
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||
@@ -29,6 +71,10 @@ do_cursors (GtkWidget *do_widget)
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (on_destroy), NULL);
|
||||
logo_callback = GTK_WIDGET (gtk_builder_get_object (builder, "logo_callback"));
|
||||
cursor = gdk_cursor_new_from_callback (cursor_callback, NULL, NULL, NULL);
|
||||
gtk_widget_set_cursor (logo_callback, cursor);
|
||||
g_object_unref (cursor);
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
|
||||
+145
-150
File diff suppressed because it is too large
Load Diff
@@ -116,6 +116,7 @@
|
||||
<file>w_resize_cursor.png</file>
|
||||
<file>zoom_in_cursor.png</file>
|
||||
<file>zoom_out_cursor.png</file>
|
||||
<file>gtk-logo.svg</file>
|
||||
</gresource>
|
||||
<gresource prefix="/dnd">
|
||||
<file>dnd.css</file>
|
||||
|
||||
@@ -363,7 +363,9 @@ insert_markup_idle (gpointer data)
|
||||
|
||||
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
|
||||
{
|
||||
g_idle_add (insert_markup_idle, data);
|
||||
guint id;
|
||||
id = g_idle_add (insert_markup_idle, data);
|
||||
g_source_set_name_by_id (id, "[gtk-demo] insert_markup_idle");
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
@@ -398,7 +400,9 @@ parse_markup_idle (gpointer data)
|
||||
do {
|
||||
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
|
||||
{
|
||||
g_idle_add (parse_markup_idle, data);
|
||||
guint id;
|
||||
id = g_idle_add (parse_markup_idle, data);
|
||||
g_source_set_name_by_id (id, "[gtk-demo] parse_markup_idle");
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="128"
|
||||
height="128"
|
||||
id="svg6843"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.92.4 5da689c313, 2019-01-14"
|
||||
version="1.0"
|
||||
sodipodi:docname="gtk-logo.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
||||
inkscape:export-filename="/home/ebassi/Pictures/gtk-logo-256.png"
|
||||
inkscape:export-xdpi="192"
|
||||
inkscape:export-ydpi="192">
|
||||
<defs
|
||||
id="defs6845">
|
||||
<inkscape:perspective
|
||||
sodipodi:type="inkscape:persp3d"
|
||||
inkscape:vp_x="-50 : 600 : 1"
|
||||
inkscape:vp_y="0 : 1000 : 0"
|
||||
inkscape:vp_z="700 : 600 : 1"
|
||||
inkscape:persp3d-origin="300 : 400 : 1"
|
||||
id="perspective13" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="2.8284271"
|
||||
inkscape:cx="69.874353"
|
||||
inkscape:cy="64.313526"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:document-units="px"
|
||||
inkscape:grid-bbox="true"
|
||||
width="128px"
|
||||
height="128px"
|
||||
showguides="true"
|
||||
inkscape:guide-bbox="true"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1016"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="27"
|
||||
inkscape:window-maximized="1">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid7947" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata6848">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
<dc:date />
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title />
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
<dc:rights>
|
||||
<cc:Agent>
|
||||
<dc:title />
|
||||
</cc:Agent>
|
||||
</dc:rights>
|
||||
<dc:publisher>
|
||||
<cc:Agent>
|
||||
<dc:title />
|
||||
</cc:Agent>
|
||||
</dc:publisher>
|
||||
<dc:identifier />
|
||||
<dc:source />
|
||||
<dc:relation />
|
||||
<dc:language />
|
||||
<dc:subject>
|
||||
<rdf:Bag />
|
||||
</dc:subject>
|
||||
<dc:coverage />
|
||||
<dc:description />
|
||||
<dc:contributor>
|
||||
<cc:Agent>
|
||||
<dc:title />
|
||||
</cc:Agent>
|
||||
</dc:contributor>
|
||||
<cc:license
|
||||
rdf:resource="" />
|
||||
</cc:Work>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
id="layer1"
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer">
|
||||
<path
|
||||
sodipodi:nodetypes="ccccc"
|
||||
id="path6976"
|
||||
d="M 20.88413,30.82696 L 53.816977,55.527708 L 107.33282,39.060543 L 70.587303,17.177763 L 20.88413,30.82696 z"
|
||||
style="fill:#729fcf;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.12364459;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" />
|
||||
<path
|
||||
id="path6978"
|
||||
d="M 22.94243,82.287118 L 20.88413,30.82696 L 53.816977,55.527708 L 53.816977,111.10486 L 22.94243,82.287118 z"
|
||||
style="fill:#e40000;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.12364459;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" />
|
||||
<path
|
||||
id="path6980"
|
||||
d="M 53.816977,111.10486 L 103.21619,90.5207 L 107.33282,39.060543 L 53.816977,55.527708 L 53.816977,111.10486 z"
|
||||
style="fill:#7fe719;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.12364459;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" />
|
||||
<path
|
||||
sodipodi:nodetypes="ccc"
|
||||
id="path6982"
|
||||
d="M 23.216626,81.319479 L 70.48573,67.361442 L 103.38422,90.444516"
|
||||
style="opacity:1;fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.25;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
id="path6984"
|
||||
d="M 70.434539,17.875593 L 70.434539,66.984877"
|
||||
style="opacity:1;fill:#babdb6;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.25;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
@@ -40,7 +40,7 @@ get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
|
||||
{
|
||||
wchar_t *langname_w = NULL;
|
||||
wchar_t locale_abbrev_w[9];
|
||||
gchar *langname, *locale_abbrev, *locale, *p;
|
||||
gchar *langname, *locale_abbrev, *locale;
|
||||
gint i;
|
||||
const LCTYPE iso639_lctypes[] = { LOCALE_SISO639LANGNAME, LOCALE_SISO639LANGNAME2 };
|
||||
GHashTable *ht_scripts_langs = (GHashTable *) param;
|
||||
@@ -59,7 +59,6 @@ get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
|
||||
GetLocaleInfoEx (locale_w, LOCALE_SLOCALIZEDDISPLAYNAME, langname_w, langname_size);
|
||||
langname = g_utf16_to_utf8 (langname_w, -1, NULL, NULL, NULL);
|
||||
locale = g_utf16_to_utf8 (locale_w, -1, NULL, NULL, NULL);
|
||||
p = strchr (locale, '-');
|
||||
lang = pango_language_from_string (locale);
|
||||
if (g_hash_table_lookup (ht_scripts_langs, lang) == NULL)
|
||||
g_hash_table_insert (ht_scripts_langs, lang, langname);
|
||||
|
||||
@@ -120,7 +120,7 @@ create_shadertoy_window (GtkWidget *do_widget)
|
||||
gtk_box_append (GTK_BOX (box), aspect);
|
||||
|
||||
shadertoy = new_shadertoy ("/shadertoy/alienplanet.glsl");
|
||||
gtk_aspect_frame_set_child (GTK_ASPECT_FRAME (aspect), shadertoy);
|
||||
gtk_aspect_frame_set_child (GTK_ASPECT_FRAME (aspect), gtk_graphics_offload_new (shadertoy));
|
||||
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 250);
|
||||
|
||||
@@ -330,6 +330,7 @@ stroke bounds of the path.
|
||||
| offset | `<point>` | 0 0 | non-default |
|
||||
| hint-style | `<hint style>` | slight | non-default |
|
||||
| antialias | `<antialias>` | gray | non-default |
|
||||
| hint-metrics | `<hint metrics>` | off | non-default |
|
||||
|
||||
Creates a node like `gsk_text_node_new()` with the given properties.
|
||||
|
||||
@@ -346,6 +347,7 @@ font, an error node will be returned.
|
||||
|
||||
Possible values for hint-style are none, slight or full.
|
||||
Possible value for antialias are none or gray.
|
||||
Possible value for hint-metrics are on or off.
|
||||
|
||||
### texture
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ in a selector, widget names must be prefixed with a # character.
|
||||
| E:not(selector) | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#negation) | |
|
||||
| E:dir(ltr), E:dir(rtl) | [CSS Selector Level 4](https://drafts.csswg.org/selectors/#the-dir-pseudo) | |
|
||||
| E:drop(active) | [CSS Selector Level 4](https://drafts.csswg.org/selectors/#drag-pseudos) | |
|
||||
| E:root | [CSS Selector Level 3](https://www.w3.org/TR/selectors-3/#root-pseudo) | |
|
||||
| E F | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#descendent-combinators) | |
|
||||
| E > F | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#child-combinators) | |
|
||||
| E ~ F | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#general-sibling-combinators) | |
|
||||
|
||||
@@ -56,6 +56,30 @@ follows:
|
||||
1 value:
|
||||
: all
|
||||
|
||||
## Custom Properties
|
||||
|
||||
GTK supports custom properties as defined in the
|
||||
[CSS Custom Properties for Cascading Variables](https://www.w3.org/TR/css-variables-1)
|
||||
spec.
|
||||
|
||||
Custom properties are defined as follows:
|
||||
|
||||
```css
|
||||
--prop: red;
|
||||
```
|
||||
|
||||
and used via the `var` keyword:
|
||||
|
||||
```css
|
||||
color: var(--prop);
|
||||
```
|
||||
|
||||
Custom properties can have a fallback for when the referred property is invalid:
|
||||
|
||||
```css
|
||||
color: var(--prop, green);
|
||||
```
|
||||
|
||||
## Colors
|
||||
|
||||
GTK extends the CSS syntax with several additional ways to specify colors.
|
||||
|
||||
@@ -8,6 +8,10 @@ gtk4-broadwayd
|
||||
The Broadway display server
|
||||
---------------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
| **gtk4-broadwayd** [OPTIONS...] <DISPLAY>
|
||||
|
||||
@@ -8,6 +8,10 @@ gtk4-builder-tool
|
||||
GtkBuilder File Utility
|
||||
-----------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
| **gtk4-builder-tool** <COMMAND> [OPTIONS...] <FILE>
|
||||
|
||||
@@ -8,6 +8,9 @@ gtk4-demo-application
|
||||
Demonstrate GtkApplication
|
||||
--------------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
@@ -8,6 +8,10 @@ gtk4-demo
|
||||
Demonstrate GTK widgets
|
||||
-----------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@ gtk4-encode-symbolic-svg
|
||||
Symbolic icon conversion utility
|
||||
--------------------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@ gtk4-icon-browser
|
||||
List themed icons
|
||||
-----------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@ gtk4-launch
|
||||
Launch an application
|
||||
---------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@ gtk4-node-editor
|
||||
Editor render nodes
|
||||
-----------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@ gtk4-path-tool
|
||||
GskPath Utility
|
||||
-----------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
| **gtk4-path-tool** <COMMAND> [OPTIONS...] <PATH>
|
||||
|
||||
@@ -8,6 +8,10 @@ gtk4-query-settings
|
||||
Print name and value of GTK settings
|
||||
------------------------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@ gtk4-rendernode-tool
|
||||
GskRenderNode Utility
|
||||
-----------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
| **gtk4-rendernode-tool** <COMMAND> [OPTIONS...] <FILE>
|
||||
@@ -45,13 +49,14 @@ without any titlebar.
|
||||
Rendering
|
||||
^^^^^^^^^
|
||||
|
||||
The ``render`` command saves a rendering of the rendernode as a png or tiff image.
|
||||
The name of the file to write can be specified as a second FILE argument.
|
||||
The ``render`` command saves a rendering of the rendernode as a png, tiff or svg
|
||||
image or as pdf document. The name of the file to write can be specified as a second
|
||||
FILE argument.
|
||||
|
||||
``--renderer=RENDERER``
|
||||
|
||||
Use the given renderer. Use ``--renderer=help`` to get a information
|
||||
about poassible values for the ``RENDERER``.
|
||||
about possible values for the ``RENDERER``.
|
||||
|
||||
Benchmark
|
||||
^^^^^^^^^
|
||||
@@ -93,4 +98,4 @@ exit code is 1. If the images are identical, it is 0.
|
||||
|
||||
``--quiet``
|
||||
|
||||
Don't write results to stdout.`
|
||||
Don't write results to stdout.
|
||||
|
||||
@@ -8,6 +8,10 @@ gtk4-update-icon-cache
|
||||
Icon theme caching utility
|
||||
--------------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@ gtk4-widget-factory
|
||||
Showcase GTK widgets and styles
|
||||
-------------------------------
|
||||
|
||||
:Version: GTK
|
||||
:Manual section: 1
|
||||
:Manual group: GTK commands
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ if get_option('man-pages') and rst2man.found()
|
||||
[ 'gtk4-path-tool', '1', ],
|
||||
]
|
||||
|
||||
if get_option('demos')
|
||||
if get_option('build-demos')
|
||||
rst_files += [
|
||||
[ 'gtk4-demo', '1', ],
|
||||
[ 'gtk4-demo-application', '1', ],
|
||||
|
||||
@@ -217,6 +217,10 @@ A number of options affect behavior instead of logging:
|
||||
`no-portals`
|
||||
: Disable use of [portals](https://docs.flatpak.org/en/latest/portals.html)
|
||||
|
||||
`force-offload`
|
||||
: Force graphics offload for all textures, even when slower. This allows
|
||||
to debug offloading in the absence of dmabufs.
|
||||
|
||||
`gl-disable`
|
||||
: Disable OpenGL support
|
||||
|
||||
|
||||
@@ -155,6 +155,7 @@ Each property name is part of the `GtkAccessibleProperty` enumeration.
|
||||
| %GTK_ACCESSIBLE_PROPERTY_VALUE_MIN | “aria-valuemin” | double |
|
||||
| %GTK_ACCESSIBLE_PROPERTY_VALUE_NOW | “aria-valuenow” | double |
|
||||
| %GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT | “aria-valuetext” | translatable string |
|
||||
| %GTK_ACCESSIBLE_PROPERTY_HELP_TEXT | N/A | translatable string |
|
||||
|
||||
#### List of accessible relations
|
||||
|
||||
@@ -216,6 +217,10 @@ are accessible as part of the development process. The GTK Inspector shows
|
||||
the accessible attributes of each widget, and also provides an overlay that
|
||||
can highlight accessibility issues.
|
||||
|
||||
If you support some non-standard keyboard interactions for a widget, you
|
||||
**should** set an appropriate `GTK_ACCESSIBLE_PROPERTY_HELP_TEXT` to help
|
||||
discoverability of the behavior.
|
||||
|
||||
It is possible to set accessible attributes in UI files as well:
|
||||
```xml
|
||||
<object class="GtkButton" id="button1">
|
||||
|
||||
+132
-17
@@ -91,6 +91,31 @@ const GDK_META_MASK = 1 << 28;
|
||||
|
||||
var useDataUrls = window.location.search.includes("datauri");
|
||||
|
||||
/* check if we are on Android and using Chrome */
|
||||
var isAndroidChrome = false;
|
||||
{
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
if (ua.indexOf("android") > -1 && ua.indexOf("chrom") > -1) {
|
||||
isAndroidChrome = true;
|
||||
}
|
||||
}
|
||||
/* check for the passive option for Event listener */
|
||||
let passiveSupported = false;
|
||||
try {
|
||||
const options = {
|
||||
get passive() { // This function will be called when the browser
|
||||
// attempts to access the passive property.
|
||||
passiveSupported = true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("test", null, options);
|
||||
window.removeEventListener("test", null, options);
|
||||
} catch(err) {
|
||||
passiveSupported = false;
|
||||
}
|
||||
|
||||
/* This base64code is based on https://github.com/beatgammit/base64-js/blob/master/index.js which is MIT licensed */
|
||||
|
||||
var b64_lookup = [];
|
||||
@@ -215,11 +240,32 @@ function logStackTrace(len) {
|
||||
log(callstack[i]);
|
||||
}
|
||||
|
||||
/* Helper functions for touch identifier to make it unique on Android */
|
||||
var globalTouchIdentifier = Math.round(Date.now() / 1000);
|
||||
function touchIdentifierStart(tId)
|
||||
{
|
||||
if (isAndroidChrome) {
|
||||
if (tId == 0) {
|
||||
return ++globalTouchIdentifier;
|
||||
}
|
||||
return globalTouchIdentifier + tId;
|
||||
}
|
||||
return tId;
|
||||
}
|
||||
function touchIdentifier(tId)
|
||||
{
|
||||
if (isAndroidChrome) {
|
||||
return globalTouchIdentifier + tId;
|
||||
}
|
||||
return tId;
|
||||
}
|
||||
|
||||
var grab = new Object();
|
||||
grab.surface = null;
|
||||
grab.ownerEvents = false;
|
||||
grab.implicit = false;
|
||||
var keyDownList = [];
|
||||
var inputList = [];
|
||||
var lastSerial = 0;
|
||||
var lastX = 0;
|
||||
var lastY = 0;
|
||||
@@ -987,7 +1033,14 @@ function handleDisplayCommands(display_commands)
|
||||
break;
|
||||
case DISPLAY_OP_DELETE_SURFACE:
|
||||
var id = cmd[1];
|
||||
delete surfaces[id];
|
||||
if (id == surfaceWithMouse) {
|
||||
surfaceWithMouse = 0;
|
||||
}
|
||||
if (id == realSurfaceWithMouse) {
|
||||
realSurfaceWithMouse = 0;
|
||||
firstTouchDownId = null;
|
||||
}
|
||||
delete surfaces[id];
|
||||
break;
|
||||
case DISPLAY_OP_CHANGE_TEXTURE:
|
||||
var image = cmd[1];
|
||||
@@ -1371,8 +1424,14 @@ function getEffectiveEventTarget (id) {
|
||||
function updateKeyboardStatus() {
|
||||
if (fakeInput != null && showKeyboardChanged) {
|
||||
showKeyboardChanged = false;
|
||||
if (showKeyboard)
|
||||
if (showKeyboard) {
|
||||
if (isAndroidChrome) {
|
||||
fakeInput.blur();
|
||||
fakeInput.value = ' '.repeat(80); // TODO: Should be exchange with broadway server
|
||||
// to bring real value here.
|
||||
}
|
||||
fakeInput.focus();
|
||||
}
|
||||
else
|
||||
fakeInput.blur();
|
||||
}
|
||||
@@ -2924,6 +2983,19 @@ function pushKeyEvent(fev) {
|
||||
keyDownList.push(fev);
|
||||
}
|
||||
|
||||
function copyInputEvent(ev) {
|
||||
var members = ['inputType', 'data'], i, obj = {};
|
||||
for (i = 0; i < members.length; i++) {
|
||||
if (typeof ev[members[i]] !== "undefined")
|
||||
obj[members[i]] = ev[members[i]];
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
function pushInputEvent(fev) {
|
||||
inputList.push(fev);
|
||||
}
|
||||
|
||||
function getKeyEvent(keyCode, pop) {
|
||||
var i, fev = null;
|
||||
for (i = keyDownList.length-1; i >= 0; i--) {
|
||||
@@ -3022,6 +3094,29 @@ function handleKeyUp(e) {
|
||||
keysym = fev.keysym;
|
||||
else {
|
||||
//log("Key event (keyCode = " + ev.keyCode + ") not found on keyDownList");
|
||||
if (isAndroidChrome && (ev.keyCode == 229)) {
|
||||
var i, fev = null, len = inputList.length, str;
|
||||
for (i = 0; i < len; i++) {
|
||||
fev = inputList[i];
|
||||
switch(fev.inputType) {
|
||||
case "deleteContentBackward":
|
||||
sendInput(BROADWAY_EVENT_KEY_PRESS, [65288, lastState]);
|
||||
sendInput(BROADWAY_EVENT_KEY_RELEASE, [65288, lastState]);
|
||||
break;
|
||||
case "insertText":
|
||||
if (fev.data !== undefined) {
|
||||
for (let sym of fev.data) {
|
||||
sendInput(BROADWAY_EVENT_KEY_PRESS, [sym.codePointAt(0), lastState]);
|
||||
sendInput(BROADWAY_EVENT_KEY_RELEASE, [sym.codePointAt(0), lastState]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
inputList.splice(0, len);
|
||||
}
|
||||
keysym = 0;
|
||||
}
|
||||
|
||||
@@ -3030,6 +3125,16 @@ function handleKeyUp(e) {
|
||||
return cancelEvent(ev);
|
||||
}
|
||||
|
||||
function handleInput (e) {
|
||||
var fev = null, ev = (e ? e : window.event), keysym = null, suppress = false;
|
||||
|
||||
fev = copyInputEvent(ev);
|
||||
pushInputEvent(fev);
|
||||
|
||||
// Stop keypress events just in case
|
||||
return cancelEvent(ev);
|
||||
}
|
||||
|
||||
function onKeyDown (ev) {
|
||||
updateForEvent(ev);
|
||||
return handleKeyDown(ev);
|
||||
@@ -3045,6 +3150,11 @@ function onKeyUp (ev) {
|
||||
return handleKeyUp(ev);
|
||||
}
|
||||
|
||||
function onInput (ev) {
|
||||
updateForEvent(ev);
|
||||
return handleInput(ev);
|
||||
}
|
||||
|
||||
function cancelEvent(ev)
|
||||
{
|
||||
ev = ev ? ev : window.event;
|
||||
@@ -3076,13 +3186,14 @@ function onMouseWheel(ev)
|
||||
}
|
||||
|
||||
function onTouchStart(ev) {
|
||||
event.preventDefault();
|
||||
ev.preventDefault();
|
||||
|
||||
updateKeyboardStatus();
|
||||
updateForEvent(ev);
|
||||
|
||||
for (var i = 0; i < ev.changedTouches.length; i++) {
|
||||
var touch = ev.changedTouches.item(i);
|
||||
var touchId = touchIdentifierStart(touch.identifier);
|
||||
|
||||
var origId = getSurfaceId(touch);
|
||||
var id = getEffectiveEventTarget (origId);
|
||||
@@ -3090,7 +3201,7 @@ function onTouchStart(ev) {
|
||||
var isEmulated = 0;
|
||||
|
||||
if (firstTouchDownId == null) {
|
||||
firstTouchDownId = touch.identifier;
|
||||
firstTouchDownId = touchId;
|
||||
isEmulated = 1;
|
||||
|
||||
if (realSurfaceWithMouse != origId || id != surfaceWithMouse) {
|
||||
@@ -3105,52 +3216,54 @@ function onTouchStart(ev) {
|
||||
}
|
||||
}
|
||||
|
||||
sendInput (BROADWAY_EVENT_TOUCH, [0, id, touch.identifier, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
|
||||
sendInput (BROADWAY_EVENT_TOUCH, [0, id, touchId, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
|
||||
}
|
||||
}
|
||||
|
||||
function onTouchMove(ev) {
|
||||
event.preventDefault();
|
||||
ev.preventDefault();
|
||||
|
||||
updateKeyboardStatus();
|
||||
updateForEvent(ev);
|
||||
|
||||
for (var i = 0; i < ev.changedTouches.length; i++) {
|
||||
var touch = ev.changedTouches.item(i);
|
||||
var touchId = touchIdentifier(touch.identifier);
|
||||
|
||||
var origId = getSurfaceId(touch);
|
||||
var id = getEffectiveEventTarget (origId);
|
||||
var pos = getPositionsFromEvent(touch, id);
|
||||
|
||||
var isEmulated = 0;
|
||||
if (firstTouchDownId == touch.identifier) {
|
||||
if (firstTouchDownId == touchId) {
|
||||
isEmulated = 1;
|
||||
}
|
||||
|
||||
sendInput (BROADWAY_EVENT_TOUCH, [1, id, touch.identifier, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
|
||||
sendInput (BROADWAY_EVENT_TOUCH, [1, id, touchId, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
|
||||
}
|
||||
}
|
||||
|
||||
function onTouchEnd(ev) {
|
||||
event.preventDefault();
|
||||
ev.preventDefault();
|
||||
|
||||
updateKeyboardStatus();
|
||||
updateForEvent(ev);
|
||||
|
||||
for (var i = 0; i < ev.changedTouches.length; i++) {
|
||||
var touch = ev.changedTouches.item(i);
|
||||
var touchId = touchIdentifier(touch.identifier);
|
||||
|
||||
var origId = getSurfaceId(touch);
|
||||
var id = getEffectiveEventTarget (origId);
|
||||
var pos = getPositionsFromEvent(touch, id);
|
||||
|
||||
var isEmulated = 0;
|
||||
if (firstTouchDownId == touch.identifier) {
|
||||
if (firstTouchDownId == touchId) {
|
||||
isEmulated = 1;
|
||||
firstTouchDownId = null;
|
||||
}
|
||||
|
||||
sendInput (BROADWAY_EVENT_TOUCH, [2, id, touch.identifier, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
|
||||
sendInput (BROADWAY_EVENT_TOUCH, [2, id, touchId, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3167,11 +3280,11 @@ function setupDocument(document)
|
||||
document.onkeyup = onKeyUp;
|
||||
|
||||
if (document.addEventListener) {
|
||||
document.addEventListener('DOMMouseScroll', onMouseWheel, false);
|
||||
document.addEventListener('mousewheel', onMouseWheel, false);
|
||||
document.addEventListener('touchstart', onTouchStart, false);
|
||||
document.addEventListener('touchmove', onTouchMove, false);
|
||||
document.addEventListener('touchend', onTouchEnd, false);
|
||||
document.addEventListener('DOMMouseScroll', onMouseWheel, passiveSupported ? { passive: false, capture: false } : false);
|
||||
document.addEventListener('mousewheel', onMouseWheel, passiveSupported ? { passive: false, capture: false } : false);
|
||||
document.addEventListener('touchstart', onTouchStart, passiveSupported ? { passive: false, capture: false } : false);
|
||||
document.addEventListener('touchmove', onTouchMove, passiveSupported ? { passive: false, capture: false } : false);
|
||||
document.addEventListener('touchend', onTouchEnd, passiveSupported ? { passive: false, capture: false } : false);
|
||||
} else if (document.attachEvent) {
|
||||
element.attachEvent("onmousewheel", onMouseWheel);
|
||||
}
|
||||
@@ -3237,12 +3350,14 @@ function connect()
|
||||
};
|
||||
|
||||
var iOS = /(iPad|iPhone|iPod)/g.test( navigator.userAgent );
|
||||
if (iOS) {
|
||||
if (iOS || isAndroidChrome) {
|
||||
fakeInput = document.createElement("input");
|
||||
fakeInput.type = "text";
|
||||
fakeInput.style.position = "absolute";
|
||||
fakeInput.style.left = "-1000px";
|
||||
fakeInput.style.top = "-1000px";
|
||||
document.body.appendChild(fakeInput);
|
||||
if (isAndroidChrome)
|
||||
fakeInput.addEventListener('input', onInput, passiveSupported ? { passive: false, capture: false } : false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ static const GdkDebugKey gdk_debug_keys[] = {
|
||||
|
||||
{ "portals", GDK_DEBUG_PORTALS, "Force use of portals" },
|
||||
{ "no-portals", GDK_DEBUG_NO_PORTALS, "Disable use of portals" },
|
||||
{ "force-offload", GDK_DEBUG_FORCE_OFFLOAD, "Force graphics offload for all textures" },
|
||||
{ "gl-disable", GDK_DEBUG_GL_DISABLE, "Disable OpenGL support" },
|
||||
{ "gl-no-fractional", GDK_DEBUG_GL_NO_FRACTIONAL, "Disable fractional scaling for OpenGL" },
|
||||
{ "gl-debug", GDK_DEBUG_GL_DEBUG, "Insert debugging information in OpenGL" },
|
||||
|
||||
@@ -156,6 +156,9 @@ gdk_cursor_finalize (GObject *object)
|
||||
g_clear_object (&cursor->texture);
|
||||
g_clear_object (&cursor->fallback);
|
||||
|
||||
if (cursor->destroy)
|
||||
cursor->destroy (cursor->data);
|
||||
|
||||
G_OBJECT_CLASS (gdk_cursor_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
@@ -253,6 +256,11 @@ gdk_cursor_hash (gconstpointer pointer)
|
||||
hash ^= g_str_hash (cursor->name);
|
||||
else if (cursor->texture)
|
||||
hash ^= g_direct_hash (cursor->texture);
|
||||
else if (cursor->callback)
|
||||
{
|
||||
hash ^= g_direct_hash (cursor->callback);
|
||||
hash ^= g_direct_hash (cursor->data);
|
||||
}
|
||||
|
||||
hash ^= (cursor->hotspot_x << 8) | cursor->hotspot_y;
|
||||
|
||||
@@ -281,6 +289,10 @@ gdk_cursor_equal (gconstpointer a,
|
||||
ca->hotspot_y != cb->hotspot_y)
|
||||
return FALSE;
|
||||
|
||||
if (ca->callback != cb->callback ||
|
||||
ca->data != cb->data)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -355,6 +367,45 @@ gdk_cursor_new_from_texture (GdkTexture *texture,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cursor_new_from_callback:
|
||||
* @callback: the `GdkCursorGetTextureCallback`
|
||||
* @data: data to pass to @callback
|
||||
* @destroy: destroy notify for @data
|
||||
* @fallback: (nullable): the `GdkCursor` to fall back to when
|
||||
* this one cannot be supported
|
||||
*
|
||||
* Creates a new callback-based cursor object.
|
||||
*
|
||||
* Cursors of this kind produce textures for the cursor
|
||||
* image on demand, when the @callback is called.
|
||||
*
|
||||
* Returns: (nullable): a new `GdkCursor`
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
GdkCursor *
|
||||
gdk_cursor_new_from_callback (GdkCursorGetTextureCallback callback,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy,
|
||||
GdkCursor *fallback)
|
||||
{
|
||||
GdkCursor *cursor;
|
||||
|
||||
g_return_val_if_fail (callback != NULL, NULL);
|
||||
g_return_val_if_fail (fallback == NULL || GDK_IS_CURSOR (fallback), NULL);
|
||||
|
||||
cursor = g_object_new (GDK_TYPE_CURSOR,
|
||||
"fallback", fallback,
|
||||
NULL);
|
||||
|
||||
cursor->callback = callback;
|
||||
cursor->data = data;
|
||||
cursor->destroy = destroy;
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cursor_get_fallback: (attributes org.gtk.Method.get_property=fallback)
|
||||
* @cursor: a `GdkCursor`
|
||||
@@ -459,3 +510,22 @@ gdk_cursor_get_hotspot_y (GdkCursor *cursor)
|
||||
|
||||
return cursor->hotspot_y;
|
||||
}
|
||||
|
||||
GdkTexture *
|
||||
gdk_cursor_get_texture_for_size (GdkCursor *cursor,
|
||||
int cursor_size,
|
||||
double scale,
|
||||
int *width,
|
||||
int *height,
|
||||
int *hotspot_x,
|
||||
int *hotspot_y)
|
||||
{
|
||||
if (cursor->callback == NULL)
|
||||
return NULL;
|
||||
|
||||
return cursor->callback (cursor,
|
||||
cursor_size, scale,
|
||||
width, height,
|
||||
hotspot_x, hotspot_y,
|
||||
cursor->data);
|
||||
}
|
||||
|
||||
@@ -51,6 +51,52 @@ GDK_AVAILABLE_IN_ALL
|
||||
GdkCursor* gdk_cursor_new_from_name (const char *name,
|
||||
GdkCursor *fallback);
|
||||
|
||||
/**
|
||||
* GdkCursorGetTestureCallback:
|
||||
* @cursor: the `GdkCursor`
|
||||
* @cursor_size: the nominal cursor size, in application pixels
|
||||
* @scale: the device scale
|
||||
* @width: (out): return location for the actual cursor width,
|
||||
* in application pixels
|
||||
* @height: (out): return location for the actual cursor height,
|
||||
* in application pixels
|
||||
* @hotspot_x: (out): return location for the hotspot X position,
|
||||
* in application pixels
|
||||
* @hotspot_y: (out): return location for the hotspot Y position,
|
||||
* in application pixels
|
||||
* @data: User data for the callback
|
||||
*
|
||||
* The type of callback used by a dynamic `GdkCursor` to generate
|
||||
* a texture for the cursor image at the given @cursor_size
|
||||
* and @scale.
|
||||
*
|
||||
* The actual cursor size in application pixels may be different
|
||||
* from @cursor_size x @cursor_size, and will be returned in
|
||||
* @width, @height. The returned texture should have a size that
|
||||
* corresponds to the actual cursor size, in device pixels (i.e.
|
||||
* application pixels, multiplied by @scale).
|
||||
*
|
||||
* This function may fail and return `NULL`, in which case
|
||||
* the fallback cursor will be used.
|
||||
*
|
||||
* Returns: (nullable) (transfer full): the cursor image, or
|
||||
* `NULL` if none could be produced.
|
||||
*/
|
||||
typedef GdkTexture * (* GdkCursorGetTextureCallback) (GdkCursor *cursor,
|
||||
int cursor_size,
|
||||
double scale,
|
||||
int *width,
|
||||
int *height,
|
||||
int *hotspot_x,
|
||||
int *hotspot_y,
|
||||
gpointer data);
|
||||
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GdkCursor * gdk_cursor_new_from_callback (GdkCursorGetTextureCallback callback,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy,
|
||||
GdkCursor *fallback);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkCursor * gdk_cursor_get_fallback (GdkCursor *cursor);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
||||
@@ -44,6 +44,10 @@ struct _GdkCursor
|
||||
GdkTexture *texture;
|
||||
int hotspot_x;
|
||||
int hotspot_y;
|
||||
|
||||
GdkCursorGetTextureCallback callback;
|
||||
gpointer data;
|
||||
GDestroyNotify destroy;
|
||||
};
|
||||
|
||||
struct _GdkCursorClass
|
||||
@@ -55,5 +59,13 @@ guint gdk_cursor_hash (gconstpointer
|
||||
gboolean gdk_cursor_equal (gconstpointer a,
|
||||
gconstpointer b);
|
||||
|
||||
GdkTexture * gdk_cursor_get_texture_for_size (GdkCursor *cursor,
|
||||
int cursor_size,
|
||||
double scale,
|
||||
int *width,
|
||||
int *height,
|
||||
int *hotspot_x,
|
||||
int *hotspot_y);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ typedef enum {
|
||||
GDK_DEBUG_NO_PORTALS = 1 << 15,
|
||||
GDK_DEBUG_GL_DISABLE = 1 << 16,
|
||||
GDK_DEBUG_GL_NO_FRACTIONAL= 1 << 17,
|
||||
|
||||
GDK_DEBUG_FORCE_OFFLOAD = 1 << 18,
|
||||
GDK_DEBUG_GL_DISABLE_GL = 1 << 19,
|
||||
GDK_DEBUG_GL_DISABLE_GLES = 1 << 20,
|
||||
GDK_DEBUG_GL_PREFER_GL = 1 << 21,
|
||||
|
||||
+6
-1
@@ -163,6 +163,8 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
|
||||
return NULL;
|
||||
|
||||
previous = gdk_gl_context_get_current ();
|
||||
if (previous)
|
||||
g_object_ref (previous);
|
||||
formats = gdk_dmabuf_formats_builder_new ();
|
||||
external = gdk_dmabuf_formats_builder_new ();
|
||||
|
||||
@@ -194,7 +196,10 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
|
||||
}
|
||||
|
||||
if (previous)
|
||||
gdk_gl_context_make_current (previous);
|
||||
{
|
||||
gdk_gl_context_make_current (previous);
|
||||
g_object_unref (previous);
|
||||
}
|
||||
|
||||
return GDK_DMABUF_DOWNLOADER (renderer);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "gdkdmabufformatsbuilderprivate.h"
|
||||
#include "gdkdmabuffourccprivate.h"
|
||||
#include "gdkdmabufprivate.h"
|
||||
#include "gdkdmabuftexturebuilderprivate.h"
|
||||
#include "gdktextureprivate.h"
|
||||
#include <gdk/gdkglcontext.h>
|
||||
#include <gdk/gdkgltexturebuilder.h>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "gdkdisplay.h"
|
||||
#include "gdkenumtypes.h"
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
#include "gdkdmabuftexturebuilderprivate.h"
|
||||
|
||||
#include <cairo-gobject.h>
|
||||
|
||||
@@ -948,22 +949,20 @@ gdk_dmabuf_texture_builder_set_update_region (GdkDmabufTextureBuilder *self,
|
||||
*
|
||||
* Builds a new `GdkTexture` with the values set up in the builder.
|
||||
*
|
||||
* It is a programming error to call this function if any mandatory
|
||||
* property has not been set.
|
||||
* It is a programming error to call this function if any mandatory property has not been set.
|
||||
*
|
||||
* If the dmabuf is not supported by GTK, %NULL will be returned and @error will be set.
|
||||
* Not all formats defined in the `drm_fourcc.h` header are supported. You can use
|
||||
* [method@Gdk.Display.get_dmabuf_formats] to get a list of supported formats. If the
|
||||
* format is not supported by GTK, %NULL will be returned and @error will be set.
|
||||
*
|
||||
* The `destroy` function gets called when the returned texture gets released.
|
||||
*
|
||||
* It is possible to call this function multiple times to create multiple textures,
|
||||
* possibly with changing properties in between.
|
||||
*
|
||||
* It is the responsibility of the caller to keep the file descriptors for the planes
|
||||
* open until the created texture is no longer used, and close them afterwards (possibly
|
||||
* using the @destroy notify).
|
||||
*
|
||||
* Not all formats defined in the `drm_fourcc.h` header are supported. You can use
|
||||
* [method@Gdk.Display.get_dmabuf_formats] to get a list of supported formats.
|
||||
* It is possible to call this function multiple times to create multiple textures,
|
||||
* possibly with changing properties in between.
|
||||
*
|
||||
* Returns: (transfer full) (nullable): a newly built `GdkTexture` or `NULL`
|
||||
* if the format is not supported
|
||||
@@ -1004,3 +1003,19 @@ gdk_dmabuf_texture_builder_get_dmabuf (GdkDmabufTextureBuilder *self)
|
||||
{
|
||||
return &self->dmabuf;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_dmabuf_texture_builder_set_dmabuf (GdkDmabufTextureBuilder *self,
|
||||
const GdkDmabuf *dmabuf)
|
||||
{
|
||||
gdk_dmabuf_texture_builder_set_fourcc (self, dmabuf->fourcc);
|
||||
gdk_dmabuf_texture_builder_set_modifier (self, dmabuf->modifier);
|
||||
gdk_dmabuf_texture_builder_set_n_planes (self, dmabuf->n_planes);
|
||||
|
||||
for (unsigned int i = 0; i < dmabuf->n_planes; i++)
|
||||
{
|
||||
gdk_dmabuf_texture_builder_set_fd (self, i, dmabuf->planes[i].fd);
|
||||
gdk_dmabuf_texture_builder_set_stride (self, i, dmabuf->planes[i].stride);
|
||||
gdk_dmabuf_texture_builder_set_offset (self, i, dmabuf->planes[i].offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "gdkdmabuftexturebuilder.h"
|
||||
#include "gdkdmabufprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
const GdkDmabuf * gdk_dmabuf_texture_builder_get_dmabuf (GdkDmabufTextureBuilder *builder);
|
||||
|
||||
void gdk_dmabuf_texture_builder_set_dmabuf (GdkDmabufTextureBuilder *builder,
|
||||
const GdkDmabuf *dmabuf);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
const GdkDmabuf * gdk_dmabuf_texture_builder_get_dmabuf (GdkDmabufTextureBuilder *builder);
|
||||
|
||||
GdkTexture * gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
|
||||
GDestroyNotify destroy,
|
||||
gpointer data,
|
||||
|
||||
@@ -1956,8 +1956,6 @@ gdk_gl_context_get_glsl_version_string (GdkGLContext *self)
|
||||
return "#version 310 es";
|
||||
else if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
|
||||
return "#version 300 es";
|
||||
else if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
|
||||
return "#version 300 es";
|
||||
else
|
||||
return "#version 100";
|
||||
}
|
||||
|
||||
@@ -744,3 +744,11 @@ gdk_monitor_set_description (GdkMonitor *monitor,
|
||||
g_object_notify_by_pspec (G_OBJECT (monitor), props[PROP_DESCRIPTION]);
|
||||
}
|
||||
|
||||
#define MM_PER_INCH 25.4
|
||||
|
||||
double
|
||||
gdk_monitor_get_dpi (GdkMonitor *monitor)
|
||||
{
|
||||
return MAX ((monitor->geometry.width * monitor->scale) / (monitor->width_mm / MM_PER_INCH),
|
||||
(monitor->geometry.height * monitor->scale) / (monitor->height_mm / MM_PER_INCH));
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ void gdk_monitor_set_subpixel_layout (GdkMonitor *monitor,
|
||||
void gdk_monitor_invalidate (GdkMonitor *monitor);
|
||||
void gdk_monitor_set_description (GdkMonitor *monitor,
|
||||
const char *description);
|
||||
double gdk_monitor_get_dpi (GdkMonitor *monitor);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+7
-18
@@ -98,9 +98,9 @@ gdk_rgba_free (GdkRGBA *rgba)
|
||||
* Returns: %TRUE if the @rgba is clear
|
||||
*/
|
||||
gboolean
|
||||
gdk_rgba_is_clear (const GdkRGBA *rgba)
|
||||
(gdk_rgba_is_clear) (const GdkRGBA *rgba)
|
||||
{
|
||||
return rgba->alpha < ((float) 0x00ff / (float) 0xffff);
|
||||
return _gdk_rgba_is_clear (rgba);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,9 +115,9 @@ gdk_rgba_is_clear (const GdkRGBA *rgba)
|
||||
* Returns: %TRUE if the @rgba is opaque
|
||||
*/
|
||||
gboolean
|
||||
gdk_rgba_is_opaque (const GdkRGBA *rgba)
|
||||
(gdk_rgba_is_opaque) (const GdkRGBA *rgba)
|
||||
{
|
||||
return rgba->alpha > ((float)0xff00 / (float)0xffff);
|
||||
return _gdk_rgba_is_opaque (rgba);
|
||||
}
|
||||
|
||||
#define SKIP_WHITESPACES(s) while (*(s) == ' ') (s)++;
|
||||
@@ -368,21 +368,10 @@ gdk_rgba_hash (gconstpointer p)
|
||||
* Returns: %TRUE if the two colors compare equal
|
||||
*/
|
||||
gboolean
|
||||
gdk_rgba_equal (gconstpointer p1,
|
||||
gconstpointer p2)
|
||||
(gdk_rgba_equal) (gconstpointer p1,
|
||||
gconstpointer p2)
|
||||
{
|
||||
const GdkRGBA *rgba1, *rgba2;
|
||||
|
||||
rgba1 = p1;
|
||||
rgba2 = p2;
|
||||
|
||||
if (rgba1->red == rgba2->red &&
|
||||
rgba1->green == rgba2->green &&
|
||||
rgba1->blue == rgba2->blue &&
|
||||
rgba1->alpha == rgba2->alpha)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
return _gdk_rgba_equal (p1, p2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,5 +43,34 @@
|
||||
gboolean gdk_rgba_parser_parse (GtkCssParser *parser,
|
||||
GdkRGBA *rgba);
|
||||
|
||||
#define gdk_rgba_is_clear(rgba) _gdk_rgba_is_clear (rgba)
|
||||
#define gdk_rgba_is_opaque(rgba) _gdk_rgba_is_opaque (rgba)
|
||||
#define gdk_rgba_equal(p1, p2) _gdk_rgba_equal (p1, p2)
|
||||
|
||||
static inline gboolean
|
||||
_gdk_rgba_is_clear (const GdkRGBA *rgba)
|
||||
{
|
||||
return rgba->alpha < ((float) 0x00ff / (float) 0xffff);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_gdk_rgba_is_opaque (const GdkRGBA *rgba)
|
||||
{
|
||||
return rgba->alpha > ((float)0xff00 / (float)0xffff);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
_gdk_rgba_equal (gconstpointer p1,
|
||||
gconstpointer p2)
|
||||
{
|
||||
const GdkRGBA *rgba1 = p1;
|
||||
const GdkRGBA *rgba2 = p2;
|
||||
|
||||
return rgba1->red == rgba2->red &&
|
||||
rgba1->green == rgba2->green &&
|
||||
rgba1->blue == rgba2->blue &&
|
||||
rgba1->alpha == rgba2->alpha;
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+177
-10
@@ -48,6 +48,14 @@ gdk_subsurface_class_init (GdkSubsurfaceClass *class)
|
||||
object_class->finalize = gdk_subsurface_finalize;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_subsurface_get_parent:
|
||||
* @subsurface: a `GdkSubsurface`
|
||||
*
|
||||
* Returns the parent surface of @subsurface.
|
||||
*
|
||||
* Returns: the parent surface
|
||||
*/
|
||||
GdkSurface *
|
||||
gdk_subsurface_get_parent (GdkSubsurface *subsurface)
|
||||
{
|
||||
@@ -108,15 +116,41 @@ insert_subsurface (GdkSubsurface *subsurface,
|
||||
}
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_subsurface_attach:
|
||||
* @subsurface: the `GdkSubsurface`
|
||||
* @texture: the texture to attach. This typically has to be a `GdkDmabufTexture`
|
||||
* @source: the source rectangle (i.e. the subset of the texture) to display
|
||||
* @dest: the dest rectangle, in application pixels, relative to the parent surface.
|
||||
* It must be integral in application and device pixels, or attaching will fail
|
||||
* @transform: the transform to apply to the texture contents before displaying
|
||||
* @background: (nullable): the background rectangle, in application pixels relative
|
||||
* to the parent surface. This tells GDK to put a black background of this
|
||||
* size below the subsurface. It must be integral in application and device pixels,
|
||||
* or attaching will fail
|
||||
* @above: whether the subsurface should be above its sibling
|
||||
* @sibling: (nullable): the sibling subsurface to stack relative to, or `NULL` to
|
||||
* stack relative to the parent surface
|
||||
*
|
||||
* Attaches content to a subsurface.
|
||||
*
|
||||
* This function takes all the necessary arguments to determine the subsurface
|
||||
* configuration, including its position, size, content, background and stacking.
|
||||
*
|
||||
* Returns: `TRUE` if the attaching succeeded
|
||||
*/
|
||||
gboolean
|
||||
gdk_subsurface_attach (GdkSubsurface *subsurface,
|
||||
GdkTexture *texture,
|
||||
const graphene_rect_t *source,
|
||||
const graphene_rect_t *dest,
|
||||
GdkTextureTransform transform,
|
||||
const graphene_rect_t *background,
|
||||
gboolean above,
|
||||
GdkSubsurface *sibling)
|
||||
{
|
||||
GdkSurface *parent = subsurface->parent;
|
||||
gboolean result;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), FALSE);
|
||||
g_return_val_if_fail (GDK_IS_TEXTURE (texture), FALSE);
|
||||
@@ -130,6 +164,15 @@ gdk_subsurface_attach (GdkSubsurface *subsurface,
|
||||
g_return_val_if_fail (sibling == NULL || GDK_IS_SUBSURFACE (sibling), FALSE);
|
||||
g_return_val_if_fail (sibling == NULL || sibling->parent == subsurface->parent, FALSE);
|
||||
|
||||
result = GDK_SUBSURFACE_GET_CLASS (subsurface)->attach (subsurface,
|
||||
texture,
|
||||
source,
|
||||
dest,
|
||||
transform,
|
||||
background,
|
||||
above,
|
||||
sibling);
|
||||
|
||||
remove_subsurface (subsurface);
|
||||
|
||||
if (sibling)
|
||||
@@ -155,9 +198,17 @@ gdk_subsurface_attach (GdkSubsurface *subsurface,
|
||||
}
|
||||
}
|
||||
|
||||
return GDK_SUBSURFACE_GET_CLASS (subsurface)->attach (subsurface, texture, source, dest, above, sibling);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_subsurface_detach:
|
||||
* @subsurface: a `GdkSubsurface`
|
||||
*
|
||||
* Hides the subsurface.
|
||||
*
|
||||
* To show it again, you need to call gdk_subsurface_attach().
|
||||
*/
|
||||
void
|
||||
gdk_subsurface_detach (GdkSubsurface *subsurface)
|
||||
{
|
||||
@@ -168,6 +219,14 @@ gdk_subsurface_detach (GdkSubsurface *subsurface)
|
||||
GDK_SUBSURFACE_GET_CLASS (subsurface)->detach (subsurface);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_subsurface_get_texture:
|
||||
* @subsurface: a `GdkSubsurface`
|
||||
*
|
||||
* Gets the texture that is currently displayed by the subsurface.
|
||||
*
|
||||
* Returns: (nullable): the texture that is displayed
|
||||
*/
|
||||
GdkTexture *
|
||||
gdk_subsurface_get_texture (GdkSubsurface *subsurface)
|
||||
{
|
||||
@@ -176,30 +235,138 @@ gdk_subsurface_get_texture (GdkSubsurface *subsurface)
|
||||
return GDK_SUBSURFACE_GET_CLASS (subsurface)->get_texture (subsurface);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_subsurface_get_source_rect:
|
||||
* @subsurface: a `GdkSubsurface`
|
||||
* @rect: (out caller-allocates): return location for the rectangle
|
||||
*
|
||||
* Returns the source rect that was specified in the most recent
|
||||
* gdk_subsurface_attach() call for @subsurface.
|
||||
*/
|
||||
void
|
||||
gdk_subsurface_get_source (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *source)
|
||||
gdk_subsurface_get_source_rect (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *rect)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_SUBSURFACE (subsurface));
|
||||
g_return_if_fail (source != NULL);
|
||||
g_return_if_fail (rect != NULL);
|
||||
|
||||
GDK_SUBSURFACE_GET_CLASS (subsurface)->get_source (subsurface, source);
|
||||
GDK_SUBSURFACE_GET_CLASS (subsurface)->get_source_rect (subsurface, rect);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_subsurface_get_texture_rect:
|
||||
* @subsurface: a `GdkSubsurface`
|
||||
* @rect: (out caller-allocates): return location for the rectangle
|
||||
*
|
||||
* Returns the texture rect that was specified in the most recent
|
||||
* gdk_subsurface_attach() call for @subsurface.
|
||||
*/
|
||||
void
|
||||
gdk_subsurface_get_dest (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *dest)
|
||||
gdk_subsurface_get_texture_rect (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *rect)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_SUBSURFACE (subsurface));
|
||||
g_return_if_fail (dest != NULL);
|
||||
g_return_if_fail (rect != NULL);
|
||||
|
||||
GDK_SUBSURFACE_GET_CLASS (subsurface)->get_dest (subsurface, dest);
|
||||
GDK_SUBSURFACE_GET_CLASS (subsurface)->get_texture_rect (subsurface, rect);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_subsurface_is_above_parent:
|
||||
* @subsurface: a `GdkSubsurface`
|
||||
*
|
||||
* Returns whether the subsurface is above the parent surface
|
||||
* or below. Note that a subsurface can be above its parent
|
||||
* surface, and still be covered by sibling subsurfaces.
|
||||
*
|
||||
* Returns: `TRUE` if @subsurface is above its parent
|
||||
*/
|
||||
gboolean
|
||||
gdk_subsurface_is_above_parent (GdkSubsurface *subsurface)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), TRUE);
|
||||
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), FALSE);
|
||||
|
||||
return subsurface->above_parent;
|
||||
}
|
||||
|
||||
/*< private>
|
||||
* gdk_subsurface_get_sibling:
|
||||
* @subsurface: the `GdkSubsurface`
|
||||
* @above: whether to get the subsurface above
|
||||
*
|
||||
* Returns the subsurface above (or below) @subsurface in
|
||||
* the stacking order.
|
||||
*
|
||||
* Returns: the sibling, or `NULL` if there is none.
|
||||
*/
|
||||
GdkSubsurface *
|
||||
gdk_subsurface_get_sibling (GdkSubsurface *subsurface,
|
||||
gboolean above)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), NULL);
|
||||
|
||||
if (above)
|
||||
return subsurface->sibling_above;
|
||||
else
|
||||
return subsurface->sibling_below;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_subsurface_get_transform:
|
||||
* @subsurface: a `GdkSubsurface`
|
||||
*
|
||||
* Returns the transform that was specified in the most recent call to
|
||||
* gdk_subsurface_attach() call for @subsurface.
|
||||
*
|
||||
* Returns: the transform
|
||||
*/
|
||||
GdkTextureTransform
|
||||
gdk_subsurface_get_transform (GdkSubsurface *subsurface)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), GDK_TEXTURE_TRANSFORM_NORMAL);
|
||||
|
||||
return GDK_SUBSURFACE_GET_CLASS (subsurface)->get_transform (subsurface);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_subsurface_get_background_rect:
|
||||
* @subsurface: a `GdkSubsurface`
|
||||
* @rect: (out caller-allocates): return location for the rectangle
|
||||
*
|
||||
* Obtains the background rect that was specified in the most recent
|
||||
* gdk_subsurface_attach() call for @subsurface.
|
||||
*
|
||||
* Returns: `TRUE` if @subsurface has a background
|
||||
*/
|
||||
gboolean
|
||||
gdk_subsurface_get_background_rect (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *rect)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), FALSE);
|
||||
g_return_val_if_fail (rect != NULL, FALSE);
|
||||
|
||||
return GDK_SUBSURFACE_GET_CLASS (subsurface)->get_background_rect (subsurface, rect);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gdk_subsurface_get_bounds:
|
||||
* @subsurface: a `GdkSubsurface`
|
||||
* @bounds: (out caller-allocates): return location for the bounds
|
||||
*
|
||||
* Returns the bounds of the subsurface.
|
||||
*
|
||||
* The bounds are the union of the texture and background rects.
|
||||
*/
|
||||
void
|
||||
gdk_subsurface_get_bounds (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *bounds)
|
||||
{
|
||||
graphene_rect_t background;
|
||||
|
||||
g_return_if_fail (GDK_IS_SUBSURFACE (subsurface));
|
||||
g_return_if_fail (bounds != NULL);
|
||||
|
||||
gdk_subsurface_get_texture_rect (subsurface, bounds);
|
||||
if (gdk_subsurface_get_background_rect (subsurface, &background))
|
||||
graphene_rect_union (bounds, &background, bounds);
|
||||
}
|
||||
|
||||
+53
-27
@@ -47,42 +47,68 @@ struct _GdkSubsurface
|
||||
GdkSubsurface *sibling_below;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
GDK_TEXTURE_TRANSFORM_NORMAL,
|
||||
GDK_TEXTURE_TRANSFORM_90,
|
||||
GDK_TEXTURE_TRANSFORM_180,
|
||||
GDK_TEXTURE_TRANSFORM_270,
|
||||
GDK_TEXTURE_TRANSFORM_FLIPPED,
|
||||
GDK_TEXTURE_TRANSFORM_FLIPPED_90,
|
||||
GDK_TEXTURE_TRANSFORM_FLIPPED_180,
|
||||
GDK_TEXTURE_TRANSFORM_FLIPPED_270,
|
||||
} GdkTextureTransform;
|
||||
|
||||
struct _GdkSubsurfaceClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
gboolean (* attach) (GdkSubsurface *subsurface,
|
||||
GdkTexture *texture,
|
||||
const graphene_rect_t *source,
|
||||
const graphene_rect_t *dest,
|
||||
gboolean above,
|
||||
GdkSubsurface *sibling);
|
||||
void (* detach) (GdkSubsurface *subsurface);
|
||||
GdkTexture * (* get_texture) (GdkSubsurface *subsurface);
|
||||
void (* get_source) (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *source);
|
||||
void (* get_dest) (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *dest);
|
||||
gboolean (* attach) (GdkSubsurface *subsurface,
|
||||
GdkTexture *texture,
|
||||
const graphene_rect_t *source,
|
||||
const graphene_rect_t *dest,
|
||||
GdkTextureTransform transform,
|
||||
const graphene_rect_t *bg,
|
||||
gboolean above,
|
||||
GdkSubsurface *sibling);
|
||||
void (* detach) (GdkSubsurface *subsurface);
|
||||
GdkTexture * (* get_texture) (GdkSubsurface *subsurface);
|
||||
void (* get_source_rect) (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *rect);
|
||||
void (* get_texture_rect) (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *rect);
|
||||
GdkTextureTransform
|
||||
(* get_transform) (GdkSubsurface *subsurface);
|
||||
gboolean (* get_background_rect) (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *rect);
|
||||
};
|
||||
|
||||
GType gdk_subsurface_get_type (void) G_GNUC_CONST;
|
||||
GType gdk_subsurface_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GdkSurface * gdk_subsurface_get_parent (GdkSubsurface *subsurface);
|
||||
gboolean gdk_subsurface_attach (GdkSubsurface *subsurface,
|
||||
GdkTexture *texture,
|
||||
const graphene_rect_t *source,
|
||||
const graphene_rect_t *dest,
|
||||
gboolean above,
|
||||
GdkSubsurface *sibling);
|
||||
void gdk_subsurface_detach (GdkSubsurface *subsurface);
|
||||
GdkTexture * gdk_subsurface_get_texture (GdkSubsurface *subsurface);
|
||||
void gdk_subsurface_get_source (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *source);
|
||||
void gdk_subsurface_get_dest (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *dest);
|
||||
gboolean gdk_subsurface_is_above_parent (GdkSubsurface *subsurface);
|
||||
GdkSurface * gdk_subsurface_get_parent (GdkSubsurface *subsurface);
|
||||
|
||||
gboolean gdk_subsurface_attach (GdkSubsurface *subsurface,
|
||||
GdkTexture *texture,
|
||||
const graphene_rect_t *source,
|
||||
const graphene_rect_t *dest,
|
||||
GdkTextureTransform transform,
|
||||
const graphene_rect_t *background,
|
||||
gboolean above,
|
||||
GdkSubsurface *sibling);
|
||||
void gdk_subsurface_detach (GdkSubsurface *subsurface);
|
||||
GdkTexture * gdk_subsurface_get_texture (GdkSubsurface *subsurface);
|
||||
void gdk_subsurface_get_source_rect (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *rect);
|
||||
void gdk_subsurface_get_texture_rect (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *rect);
|
||||
gboolean gdk_subsurface_is_above_parent (GdkSubsurface *subsurface);
|
||||
GdkSubsurface * gdk_subsurface_get_sibling (GdkSubsurface *subsurface,
|
||||
gboolean above);
|
||||
GdkTextureTransform
|
||||
gdk_subsurface_get_transform (GdkSubsurface *subsurface);
|
||||
gboolean gdk_subsurface_get_background_rect (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *rect);
|
||||
void gdk_subsurface_get_bounds (GdkSubsurface *subsurface,
|
||||
graphene_rect_t *bounds);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+47
-10
@@ -29,6 +29,7 @@
|
||||
#include "gdkdmabuffourccprivate.h"
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkprofilerprivate.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <math.h>
|
||||
|
||||
@@ -57,6 +58,9 @@ static const GdkDebugKey gsk_vulkan_feature_keys[] = {
|
||||
*
|
||||
* Support for `GdkVulkanContext` is platform-specific and context creation
|
||||
* can fail, returning %NULL context.
|
||||
*
|
||||
* Deprecated: 4.14: GTK does not expose any Vulkan internals. This
|
||||
* struct is a leftover that was accidentally exposed.
|
||||
*/
|
||||
|
||||
typedef struct _GdkVulkanContextPrivate GdkVulkanContextPrivate;
|
||||
@@ -628,6 +632,7 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
|
||||
{
|
||||
GdkVulkanContext *context = GDK_VULKAN_CONTEXT (draw_context);
|
||||
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
|
||||
VkResult acquire_result;
|
||||
guint i;
|
||||
|
||||
if (depth != priv->current_format)
|
||||
@@ -649,12 +654,29 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
|
||||
cairo_region_union (priv->regions[i], region);
|
||||
}
|
||||
|
||||
GDK_VK_CHECK (vkAcquireNextImageKHR, gdk_vulkan_context_get_device (context),
|
||||
priv->swapchain,
|
||||
UINT64_MAX,
|
||||
priv->draw_semaphore,
|
||||
VK_NULL_HANDLE,
|
||||
&priv->draw_index);
|
||||
acquire_next_image:
|
||||
acquire_result = GDK_VK_CHECK (vkAcquireNextImageKHR, gdk_vulkan_context_get_device (context),
|
||||
priv->swapchain,
|
||||
UINT64_MAX,
|
||||
priv->draw_semaphore,
|
||||
VK_NULL_HANDLE,
|
||||
&priv->draw_index);
|
||||
if ((acquire_result == VK_ERROR_OUT_OF_DATE_KHR) ||
|
||||
(acquire_result == VK_SUBOPTIMAL_KHR))
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
GDK_DEBUG (VULKAN, "Recreating the swapchain");
|
||||
|
||||
if (!gdk_vulkan_context_check_swapchain (context, &error))
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
goto acquire_next_image;
|
||||
}
|
||||
|
||||
cairo_region_union (region, priv->regions[priv->draw_index]);
|
||||
}
|
||||
@@ -1107,6 +1129,7 @@ gdk_display_load_pipeline_cache (GdkDisplay *display)
|
||||
static gboolean
|
||||
gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
||||
{
|
||||
G_GNUC_UNUSED gint64 begin_time = GDK_PROFILER_CURRENT_TIME;
|
||||
GError *error = NULL;
|
||||
VkDevice device;
|
||||
VkPipelineCache cache;
|
||||
@@ -1121,14 +1144,13 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
||||
GDK_VK_CHECK (vkGetPipelineCacheData, device, cache, &size, NULL);
|
||||
if (size == 0)
|
||||
return TRUE;
|
||||
|
||||
|
||||
if (size == display->vk_pipeline_cache_size)
|
||||
{
|
||||
GDK_DEBUG (VULKAN, "pipeline cache size (%zu bytes) unchanged, skipping save", size);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
data = g_malloc (size);
|
||||
if (GDK_VK_CHECK (vkGetPipelineCacheData, device, cache, &size, data) != VK_SUCCESS)
|
||||
{
|
||||
@@ -1148,7 +1170,7 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
||||
|
||||
file = gdk_vulkan_get_pipeline_cache_file (display);
|
||||
|
||||
GDK_DEBUG (VULKAN, "Saving pipeline cache to %s", g_file_peek_path (file));
|
||||
GDK_DEBUG (VULKAN, "Saving pipeline cache of size %lu to %s", size, g_file_peek_path (file));
|
||||
|
||||
if (!g_file_replace_contents (file,
|
||||
data,
|
||||
@@ -1163,7 +1185,7 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WRONG_ETAG))
|
||||
{
|
||||
VkPipelineCache new_cache;
|
||||
|
||||
|
||||
GDK_DEBUG (VULKAN, "Pipeline cache file modified, merging into current");
|
||||
new_cache = gdk_display_load_pipeline_cache (display);
|
||||
if (new_cache)
|
||||
@@ -1190,6 +1212,10 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gdk_profiler_end_markf (begin_time,
|
||||
"Save Vulkan pipeline cache", "%s size %lu",
|
||||
g_file_peek_path (file), size);
|
||||
|
||||
g_object_unref (file);
|
||||
g_free (data);
|
||||
g_free (display->vk_pipeline_cache_etag);
|
||||
@@ -1234,6 +1260,11 @@ gdk_display_create_pipeline_cache (GdkDisplay *display)
|
||||
},
|
||||
NULL,
|
||||
&display->vk_pipeline_cache);
|
||||
GDK_DEBUG (VULKAN, "Creating empty pipeline cache");
|
||||
}
|
||||
else
|
||||
{
|
||||
GDK_DEBUG (VULKAN, "Loading pipeline cache (%lu bytes)", display->vk_pipeline_cache_size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1343,6 +1374,7 @@ static gboolean
|
||||
gdk_display_create_vulkan_device (GdkDisplay *display,
|
||||
GError **error)
|
||||
{
|
||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||
uint32_t i, j, k;
|
||||
const char *override;
|
||||
gboolean list_devices;
|
||||
@@ -1551,6 +1583,8 @@ gdk_display_create_vulkan_device (GdkDisplay *display,
|
||||
"Hum, what? This should not happen.")));
|
||||
}
|
||||
|
||||
gdk_profiler_end_mark (start_time, "Create Vulkan device", NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1589,6 +1623,7 @@ static gboolean
|
||||
gdk_display_create_vulkan_instance (GdkDisplay *display,
|
||||
GError **error)
|
||||
{
|
||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||
uint32_t i;
|
||||
GPtrArray *used_extensions;
|
||||
GPtrArray *used_layers;
|
||||
@@ -1750,6 +1785,8 @@ gdk_display_create_vulkan_instance (GdkDisplay *display,
|
||||
|
||||
display->vk_shader_modules = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
gdk_profiler_end_mark (start_time, "Create Vulkan instance", NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "gdkmacoscursor-private.h"
|
||||
#include "gdkcursorprivate.h"
|
||||
|
||||
@interface NSCursor()
|
||||
-(long long)_coreCursorType;
|
||||
@@ -217,9 +218,25 @@ _gdk_macos_cursor_get_ns_cursor (GdkCursor *cursor)
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
nscursor = create_cursor_from_texture (gdk_cursor_get_texture (cursor),
|
||||
gdk_cursor_get_hotspot_x (cursor),
|
||||
gdk_cursor_get_hotspot_y (cursor));
|
||||
GdkTexture *texture;
|
||||
int hotspot_x, hotspot_y;
|
||||
|
||||
texture = gdk_cursor_get_texture (cursor);
|
||||
hotspot_x = gdk_cursor_get_hotspot_x (cursor);
|
||||
hotspot_y = gdk_cursor_get_hotspot_y (cursor);
|
||||
|
||||
if (texture == NULL)
|
||||
{
|
||||
int size = 32; // FIXME
|
||||
int width, height;
|
||||
|
||||
texture = gdk_cursor_get_texture_for_size (cursor, size, 1,
|
||||
&width, &height,
|
||||
&hotspot_x, &hotspot_y);
|
||||
}
|
||||
|
||||
nscursor = create_cursor_from_texture (texture, hotspot_x, hotspot_y);
|
||||
|
||||
return nscursor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,17 +198,8 @@ static void
|
||||
gdk_wayland_cairo_context_empty_frame (GdkDrawContext *draw_context)
|
||||
{
|
||||
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
|
||||
if (!impl->has_pending_subsurface_commits)
|
||||
return;
|
||||
|
||||
gdk_wayland_surface_sync (surface);
|
||||
gdk_wayland_surface_request_frame (surface);
|
||||
|
||||
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "Wayland surface commit", NULL);
|
||||
gdk_wayland_surface_commit (surface);
|
||||
gdk_wayland_surface_notify_committed (surface);
|
||||
gdk_wayland_surface_handle_empty_frame (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -155,15 +155,19 @@ static const struct wl_buffer_listener buffer_listener = {
|
||||
struct wl_buffer *
|
||||
_gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
||||
GdkCursor *cursor,
|
||||
guint desired_scale,
|
||||
double desired_scale,
|
||||
gboolean use_viewporter,
|
||||
guint image_index,
|
||||
int *hotspot_x,
|
||||
int *hotspot_y,
|
||||
int *width,
|
||||
int *height,
|
||||
int *scale)
|
||||
double *scale)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
int desired_scale_factor;
|
||||
|
||||
desired_scale_factor = (int) ceil (desired_scale);
|
||||
|
||||
if (gdk_cursor_get_name (cursor))
|
||||
{
|
||||
@@ -174,7 +178,7 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
||||
|
||||
c = gdk_wayland_cursor_load_for_name (display,
|
||||
_gdk_wayland_display_get_cursor_theme (display),
|
||||
desired_scale,
|
||||
desired_scale_factor,
|
||||
gdk_cursor_get_name (cursor));
|
||||
if (c && c->image_count > 0)
|
||||
{
|
||||
@@ -191,7 +195,7 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
||||
|
||||
image = c->images[image_index];
|
||||
|
||||
cursor_scale = desired_scale;
|
||||
cursor_scale = desired_scale_factor;
|
||||
if ((image->width % cursor_scale != 0) ||
|
||||
(image->height % cursor_scale != 0))
|
||||
{
|
||||
@@ -211,7 +215,7 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
||||
return wl_cursor_image_get_buffer (image);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (gdk_cursor_get_texture (cursor))
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
struct wl_buffer *buffer;
|
||||
@@ -226,7 +230,7 @@ from_texture:
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
&GDK_FRACTIONAL_SCALE_INIT_INT (1));
|
||||
|
||||
|
||||
gdk_texture_download (texture,
|
||||
cairo_image_surface_get_data (surface),
|
||||
cairo_image_surface_get_stride (surface));
|
||||
@@ -250,11 +254,50 @@ from_texture:
|
||||
|
||||
return buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!use_viewporter)
|
||||
*scale = desired_scale_factor;
|
||||
else
|
||||
*scale = desired_scale;
|
||||
|
||||
texture = gdk_cursor_get_texture_for_size (cursor,
|
||||
display->cursor_theme_size,
|
||||
*scale,
|
||||
width,
|
||||
height,
|
||||
hotspot_x,
|
||||
hotspot_y);
|
||||
|
||||
if (texture)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
struct wl_buffer *buffer;
|
||||
|
||||
surface = gdk_wayland_display_create_shm_surface (display,
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
&GDK_FRACTIONAL_SCALE_INIT_INT (1));
|
||||
|
||||
gdk_texture_download (texture,
|
||||
cairo_image_surface_get_data (surface),
|
||||
cairo_image_surface_get_stride (surface));
|
||||
cairo_surface_mark_dirty (surface);
|
||||
|
||||
buffer = _gdk_wayland_shm_surface_get_wl_buffer (surface);
|
||||
wl_buffer_add_listener (buffer, &buffer_listener, surface);
|
||||
|
||||
g_object_unref (texture);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
if (gdk_cursor_get_fallback (cursor))
|
||||
return _gdk_wayland_cursor_get_buffer (display,
|
||||
gdk_cursor_get_fallback (cursor),
|
||||
gdk_cursor_get_fallback (cursor),
|
||||
desired_scale,
|
||||
use_viewporter,
|
||||
image_index,
|
||||
hotspot_x, hotspot_y,
|
||||
width, height,
|
||||
|
||||
@@ -62,6 +62,7 @@ struct _GdkWaylandPointerData {
|
||||
uint32_t grab_time;
|
||||
|
||||
struct wl_surface *pointer_surface;
|
||||
struct wp_viewport *pointer_surface_viewport;
|
||||
guint cursor_is_default: 1;
|
||||
GdkCursor *cursor;
|
||||
guint cursor_timeout_id;
|
||||
@@ -69,7 +70,7 @@ struct _GdkWaylandPointerData {
|
||||
guint cursor_image_delay;
|
||||
guint touchpad_event_sequence;
|
||||
|
||||
guint current_output_scale;
|
||||
double current_output_scale;
|
||||
GSList *pointer_surface_outputs;
|
||||
|
||||
/* Accumulated event data for a pointer frame */
|
||||
|
||||
@@ -260,18 +260,25 @@ gdk_wayland_device_update_surface_cursor (GdkDevice *device)
|
||||
GdkWaylandPointerData *pointer =
|
||||
gdk_wayland_device_get_pointer (wayland_device);
|
||||
struct wl_buffer *buffer;
|
||||
int x, y, w, h, scale;
|
||||
int x, y, w, h;
|
||||
double scale;
|
||||
guint next_image_index, next_image_delay;
|
||||
gboolean retval = G_SOURCE_REMOVE;
|
||||
GdkWaylandTabletData *tablet;
|
||||
gboolean use_viewport;
|
||||
|
||||
tablet = gdk_wayland_seat_find_tablet (seat, device);
|
||||
|
||||
use_viewport = pointer->pointer_surface_viewport != NULL;
|
||||
if (g_getenv ("NO_POINTER_VIEWPORT"))
|
||||
use_viewport = FALSE;
|
||||
|
||||
if (pointer->cursor)
|
||||
{
|
||||
buffer = _gdk_wayland_cursor_get_buffer (GDK_WAYLAND_DISPLAY (seat->display),
|
||||
pointer->cursor,
|
||||
pointer->current_output_scale,
|
||||
use_viewport,
|
||||
pointer->cursor_image_index,
|
||||
&x, &y, &w, &h, &scale);
|
||||
}
|
||||
@@ -310,7 +317,16 @@ gdk_wayland_device_update_surface_cursor (GdkDevice *device)
|
||||
if (buffer)
|
||||
{
|
||||
wl_surface_attach (pointer->pointer_surface, buffer, 0, 0);
|
||||
if (wl_surface_get_version (pointer->pointer_surface) >= WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
|
||||
if (use_viewport)
|
||||
{
|
||||
wp_viewport_set_source (pointer->pointer_surface_viewport,
|
||||
wl_fixed_from_int (0),
|
||||
wl_fixed_from_int (0),
|
||||
wl_fixed_from_double (w * scale),
|
||||
wl_fixed_from_double (h * scale));
|
||||
wp_viewport_set_destination (pointer->pointer_surface_viewport, w, h);
|
||||
}
|
||||
else if (wl_surface_get_version (pointer->pointer_surface) >= WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
|
||||
wl_surface_set_buffer_scale (pointer->pointer_surface, scale);
|
||||
wl_surface_damage (pointer->pointer_surface, 0, 0, w, h);
|
||||
wl_surface_commit (pointer->pointer_surface);
|
||||
|
||||
@@ -105,6 +105,9 @@
|
||||
#endif
|
||||
|
||||
static void _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland);
|
||||
static void _gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
|
||||
const char *name,
|
||||
int size);
|
||||
|
||||
G_DEFINE_TYPE (GdkWaylandDisplay, gdk_wayland_display, GDK_TYPE_DISPLAY)
|
||||
|
||||
@@ -284,97 +287,6 @@ static const struct wl_shm_listener wl_shm_listener = {
|
||||
wl_shm_format
|
||||
};
|
||||
|
||||
static void
|
||||
linux_dmabuf_done (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1)
|
||||
{
|
||||
GDK_DEBUG (MISC, "dmabuf feedback done");
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_format_table (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
int32_t fd,
|
||||
uint32_t size)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = data;
|
||||
|
||||
display_wayland->linux_dmabuf_n_formats = size / 16;
|
||||
display_wayland->linux_dmabuf_formats = mmap (NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
|
||||
GDK_DEBUG (MISC, "got dmabuf format table (%lu entries)", display_wayland->linux_dmabuf_n_formats);
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_main_device (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
struct wl_array *device)
|
||||
{
|
||||
dev_t dev G_GNUC_UNUSED;
|
||||
|
||||
memcpy (&dev, device->data, sizeof (dev_t));
|
||||
|
||||
GDK_DEBUG (MISC, "got dmabuf main device: %u %u", major (dev), minor (dev));
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_done (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1)
|
||||
{
|
||||
GDK_DEBUG (MISC, "dmabuf feedback tranche done");
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_target_device (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
struct wl_array *device)
|
||||
{
|
||||
dev_t dev G_GNUC_UNUSED;
|
||||
|
||||
memcpy (&dev, device->data, sizeof (dev_t));
|
||||
|
||||
GDK_DEBUG (MISC, "got dmabuf tranche target device: %u %u", major (dev), minor (dev));
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_formats (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
struct wl_array *indices)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = data;
|
||||
|
||||
GDK_DEBUG (MISC, "got dmabuf tranche formats (%lu entries):", indices->size / sizeof (guint16));
|
||||
guint16 *pos;
|
||||
|
||||
wl_array_for_each (pos, indices)
|
||||
{
|
||||
LinuxDmabufFormat *fmt G_GNUC_UNUSED = &display_wayland->linux_dmabuf_formats[*pos];
|
||||
uint32_t f G_GNUC_UNUSED = fmt->fourcc;
|
||||
uint64_t m G_GNUC_UNUSED = fmt->modifier;
|
||||
GDK_DEBUG (MISC, " %.4s:%#" G_GINT64_MODIFIER "x", (char *) &f, m);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_flags (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
uint32_t flags)
|
||||
{
|
||||
GDK_DEBUG (MISC,
|
||||
"got dmabuf tranche flags: %s",
|
||||
flags & ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT ? "scanout" : "");
|
||||
}
|
||||
|
||||
static const struct zwp_linux_dmabuf_feedback_v1_listener linux_dmabuf_feedback_listener = {
|
||||
linux_dmabuf_done,
|
||||
linux_dmabuf_format_table,
|
||||
linux_dmabuf_main_device,
|
||||
linux_dmabuf_tranche_done,
|
||||
linux_dmabuf_tranche_target_device,
|
||||
linux_dmabuf_tranche_formats,
|
||||
linux_dmabuf_tranche_flags,
|
||||
};
|
||||
|
||||
static void
|
||||
server_decoration_manager_default_mode (void *data,
|
||||
struct org_kde_kwin_server_decoration_manager *manager,
|
||||
@@ -441,7 +353,7 @@ gdk_registry_handle_global (void *data,
|
||||
{
|
||||
display_wayland->compositor =
|
||||
wl_registry_bind (display_wayland->wl_registry, id,
|
||||
&wl_compositor_interface, MIN (version, 5));
|
||||
&wl_compositor_interface, MIN (version, 6));
|
||||
}
|
||||
else if (strcmp (interface, "wl_shm") == 0)
|
||||
{
|
||||
@@ -451,12 +363,14 @@ gdk_registry_handle_global (void *data,
|
||||
}
|
||||
else if (strcmp (interface, "zwp_linux_dmabuf_v1") == 0 && version >= 4)
|
||||
{
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback;
|
||||
|
||||
display_wayland->linux_dmabuf =
|
||||
wl_registry_bind (display_wayland->wl_registry, id, &zwp_linux_dmabuf_v1_interface, version);
|
||||
display_wayland->linux_dmabuf_feedback =
|
||||
zwp_linux_dmabuf_v1_get_default_feedback (display_wayland->linux_dmabuf);
|
||||
zwp_linux_dmabuf_feedback_v1_add_listener (display_wayland->linux_dmabuf_feedback,
|
||||
&linux_dmabuf_feedback_listener, display_wayland);
|
||||
feedback = zwp_linux_dmabuf_v1_get_default_feedback (display_wayland->linux_dmabuf);
|
||||
display_wayland->dmabuf_formats_info = dmabuf_formats_info_new (GDK_DISPLAY (display_wayland),
|
||||
"default",
|
||||
feedback);
|
||||
_gdk_wayland_display_async_roundtrip (display_wayland);
|
||||
}
|
||||
else if (strcmp (interface, "xdg_wm_base") == 0)
|
||||
@@ -610,7 +524,13 @@ gdk_registry_handle_global (void *data,
|
||||
&wp_presentation_interface,
|
||||
MIN (version, 1));
|
||||
}
|
||||
|
||||
else if (strcmp (interface, wp_single_pixel_buffer_manager_v1_interface.name) == 0)
|
||||
{
|
||||
display_wayland->single_pixel_buffer =
|
||||
wl_registry_bind (display_wayland->wl_registry, id,
|
||||
&wp_single_pixel_buffer_manager_v1_interface,
|
||||
MIN (version, 1));
|
||||
}
|
||||
|
||||
g_hash_table_insert (display_wayland->known_globals,
|
||||
GUINT_TO_POINTER (id), g_strdup (interface));
|
||||
@@ -821,10 +741,9 @@ gdk_wayland_display_dispose (GObject *object)
|
||||
g_clear_pointer (&display_wayland->fractional_scale, wp_fractional_scale_manager_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->viewporter, wp_viewporter_destroy);
|
||||
g_clear_pointer (&display_wayland->presentation, wp_presentation_destroy);
|
||||
g_clear_pointer (&display_wayland->single_pixel_buffer, wp_single_pixel_buffer_manager_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->linux_dmabuf, zwp_linux_dmabuf_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->linux_dmabuf_feedback, zwp_linux_dmabuf_feedback_v1_destroy);
|
||||
if (display_wayland->linux_dmabuf_formats)
|
||||
munmap (display_wayland->linux_dmabuf_formats, display_wayland->linux_dmabuf_n_formats * 16);
|
||||
g_clear_pointer (&display_wayland->dmabuf_formats_info, dmabuf_formats_info_free);
|
||||
|
||||
g_clear_pointer (&display_wayland->shm, wl_shm_destroy);
|
||||
g_clear_pointer (&display_wayland->wl_registry, wl_registry_destroy);
|
||||
@@ -1126,7 +1045,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
display_class->get_monitors = gdk_wayland_display_get_monitors;
|
||||
display_class->get_monitor_at_surface = gdk_wayland_display_get_monitor_at_surface;
|
||||
display_class->get_setting = gdk_wayland_display_get_setting;
|
||||
display_class->set_cursor_theme = gdk_wayland_display_set_cursor_theme;
|
||||
display_class->set_cursor_theme = _gdk_wayland_display_set_cursor_theme;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1199,11 +1118,22 @@ get_cursor_theme (GdkWaylandDisplay *display_wayland,
|
||||
* @size: the size to use for cursors
|
||||
*
|
||||
* Sets the cursor theme for the given @display.
|
||||
*
|
||||
* Deprecated: 4.16: Use the cursor-related properties of
|
||||
* [GtkSettings](../gtk4/class.Settings.html) to set the cursor theme
|
||||
*/
|
||||
void
|
||||
gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
|
||||
const char *name,
|
||||
int size)
|
||||
{
|
||||
_gdk_wayland_display_set_cursor_theme (display, name, size);
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
|
||||
const char *name,
|
||||
int size)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY(display);
|
||||
struct wl_cursor_theme *theme;
|
||||
@@ -1272,7 +1202,7 @@ _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland)
|
||||
else
|
||||
name = "default";
|
||||
|
||||
gdk_wayland_display_set_cursor_theme (GDK_DISPLAY (display_wayland), name, size);
|
||||
_gdk_wayland_display_set_cursor_theme (GDK_DISPLAY (display_wayland), name, size);
|
||||
g_value_unset (&v);
|
||||
|
||||
gdk_profiler_end_mark (before, "Wayland cursor theme load", NULL);
|
||||
@@ -1808,6 +1738,7 @@ static TranslationEntry translations[] = {
|
||||
{ FALSE, "org.gnome.desktop.interface", "font-hinting", "gtk-xft-hinting", G_TYPE_NONE, { .i = 1 } },
|
||||
{ FALSE, "org.gnome.desktop.interface", "font-hinting", "gtk-xft-hintstyle", G_TYPE_NONE, { .i = 1 } },
|
||||
{ FALSE, "org.gnome.desktop.interface", "font-rgba-order", "gtk-xft-rgba", G_TYPE_NONE, { .i = 0 } },
|
||||
{ FALSE, "org.gnome.desktop.interface", "font-rendering", "gtk-font-rendering", G_TYPE_ENUM, { .i = 0 } },
|
||||
{ FALSE, "org.gnome.settings-daemon.plugins.xsettings", "antialiasing", "gtk-xft-antialias", G_TYPE_NONE, { .i = 1 } },
|
||||
{ FALSE, "org.gnome.settings-daemon.plugins.xsettings", "hinting", "gtk-xft-hinting", G_TYPE_NONE, { .i = 1 } },
|
||||
{ FALSE, "org.gnome.settings-daemon.plugins.xsettings", "hinting", "gtk-xft-hintstyle", G_TYPE_NONE, { .i = 1 } },
|
||||
@@ -1899,6 +1830,7 @@ apply_portal_setting (TranslationEntry *entry,
|
||||
entry->fallback.s = g_intern_string (g_variant_get_string (value, NULL));
|
||||
break;
|
||||
case G_TYPE_INT:
|
||||
case G_TYPE_ENUM:
|
||||
entry->fallback.i = g_variant_get_int32 (value);
|
||||
break;
|
||||
case G_TYPE_BOOLEAN:
|
||||
@@ -2148,6 +2080,9 @@ set_value_from_entry (GdkDisplay *display,
|
||||
case G_TYPE_BOOLEAN:
|
||||
g_value_set_boolean (value, entry->fallback.b);
|
||||
break;
|
||||
case G_TYPE_ENUM:
|
||||
g_value_set_enum (value, entry->fallback.i);
|
||||
break;
|
||||
case G_TYPE_NONE:
|
||||
if (g_str_equal (entry->setting, "gtk-fontconfig-timestamp"))
|
||||
g_value_set_uint (value, (guint)entry->fallback.i);
|
||||
@@ -2198,6 +2133,11 @@ set_value_from_entry (GdkDisplay *display,
|
||||
? g_settings_get_boolean (settings, entry->key)
|
||||
: entry->fallback.b);
|
||||
break;
|
||||
case G_TYPE_ENUM:
|
||||
g_value_set_enum (value, settings && entry->valid
|
||||
? g_settings_get_enum (settings, entry->key)
|
||||
: entry->fallback.i);
|
||||
break;
|
||||
case G_TYPE_NONE:
|
||||
if (g_str_equal (entry->setting, "gtk-fontconfig-timestamp"))
|
||||
g_value_set_uint (value, (guint)entry->fallback.i);
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <gdk/wayland/fractional-scale-v1-client-protocol.h>
|
||||
#include <gdk/wayland/viewporter-client-protocol.h>
|
||||
#include <gdk/wayland/presentation-time-client-protocol.h>
|
||||
#include <gdk/wayland/single-pixel-buffer-v1-client-protocol.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <gdk/gdkkeys.h>
|
||||
@@ -48,6 +49,7 @@
|
||||
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkwaylanddevice.h"
|
||||
#include "gdkdmabuf-wayland-private.h"
|
||||
#include "cursor/wayland-cursor.h"
|
||||
|
||||
#include <epoxy/egl.h>
|
||||
@@ -72,13 +74,6 @@ typedef enum _GdkWaylandShellVariant
|
||||
GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6
|
||||
} GdkWaylandShellVariant;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t fourcc;
|
||||
uint32_t padding;
|
||||
uint64_t modifier;
|
||||
} LinuxDmabufFormat;
|
||||
|
||||
struct _GdkWaylandDisplay
|
||||
{
|
||||
GdkDisplay parent_instance;
|
||||
@@ -104,9 +99,7 @@ struct _GdkWaylandDisplay
|
||||
struct wl_compositor *compositor;
|
||||
struct wl_shm *shm;
|
||||
struct zwp_linux_dmabuf_v1 *linux_dmabuf;
|
||||
struct zwp_linux_dmabuf_feedback_v1 *linux_dmabuf_feedback;
|
||||
gsize linux_dmabuf_n_formats;
|
||||
LinuxDmabufFormat *linux_dmabuf_formats;
|
||||
DmabufFormatsInfo *dmabuf_formats_info;
|
||||
struct xdg_wm_base *xdg_wm_base;
|
||||
struct zxdg_shell_v6 *zxdg_shell_v6;
|
||||
struct gtk_shell1 *gtk_shell;
|
||||
@@ -127,6 +120,7 @@ struct _GdkWaylandDisplay
|
||||
struct wp_fractional_scale_manager_v1 *fractional_scale;
|
||||
struct wp_viewporter *viewporter;
|
||||
struct wp_presentation *presentation;
|
||||
struct wp_single_pixel_buffer_manager_v1 *single_pixel_buffer;
|
||||
|
||||
GList *async_roundtrips;
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* gdkdmabuf-wayland.h
|
||||
*
|
||||
* Copyright 2023 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <wayland-client.h>
|
||||
#include <wayland-egl.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <gdk/gdkkeys.h>
|
||||
#include <gdk/gdksurface.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t fourcc;
|
||||
uint32_t padding;
|
||||
uint64_t modifier;
|
||||
} DmabufFormat;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
dev_t target_device;
|
||||
guint32 flags;
|
||||
gsize n_formats;
|
||||
DmabufFormat *formats;
|
||||
} DmabufTranche;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
dev_t main_device;
|
||||
GPtrArray *tranches;
|
||||
} DmabufFormats;
|
||||
|
||||
typedef struct DmabufFormatsInfo DmabufFormatsInfo;
|
||||
|
||||
struct DmabufFormatsInfo
|
||||
{
|
||||
GdkDisplay *display;
|
||||
char *name;
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback;
|
||||
|
||||
gsize n_dmabuf_formats;
|
||||
DmabufFormat *dmabuf_format_table;
|
||||
|
||||
DmabufFormats *dmabuf_formats;
|
||||
DmabufFormats *pending_dmabuf_formats;
|
||||
DmabufTranche *pending_tranche;
|
||||
};
|
||||
|
||||
DmabufFormatsInfo * dmabuf_formats_info_new (GdkDisplay *display,
|
||||
const char *name,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback);
|
||||
|
||||
void dmabuf_formats_info_free (DmabufFormatsInfo *info);
|
||||
|
||||
G_END_DECLS
|
||||
@@ -0,0 +1,241 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkdmabuf-wayland-private.h"
|
||||
|
||||
#include "gdkdebugprivate.h"
|
||||
#include "gdkdmabufformatsprivate.h"
|
||||
#include "gdkdmabufformatsbuilderprivate.h"
|
||||
#include "gdkdmabufformatsprivate.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/sysmacros.h>
|
||||
|
||||
#include "linux-dmabuf-unstable-v1-client-protocol.h"
|
||||
|
||||
|
||||
static DmabufTranche *
|
||||
dmabuf_tranche_new (void)
|
||||
{
|
||||
return g_new0 (DmabufTranche, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
dmabuf_tranche_free (DmabufTranche *tranche)
|
||||
{
|
||||
g_free (tranche->formats);
|
||||
g_free (tranche);
|
||||
}
|
||||
|
||||
static DmabufFormats *
|
||||
dmabuf_formats_new (void)
|
||||
{
|
||||
DmabufFormats *formats;
|
||||
|
||||
formats = g_new0 (DmabufFormats, 1);
|
||||
formats->tranches = g_ptr_array_new_with_free_func ((GDestroyNotify) dmabuf_tranche_free);
|
||||
|
||||
return formats;
|
||||
}
|
||||
|
||||
static void
|
||||
dmabuf_formats_free (DmabufFormats *formats)
|
||||
{
|
||||
g_ptr_array_unref (formats->tranches);
|
||||
g_free (formats);
|
||||
}
|
||||
|
||||
static void
|
||||
update_dmabuf_formats (DmabufFormatsInfo *info)
|
||||
{
|
||||
DmabufFormats *formats = info->dmabuf_formats;
|
||||
|
||||
GDK_DISPLAY_DEBUG (info->display, MISC,
|
||||
"dmabuf format table (%lu entries)", info->n_dmabuf_formats);
|
||||
GDK_DISPLAY_DEBUG (info->display, MISC,
|
||||
"dmabuf main device: %u %u",
|
||||
major (formats->main_device),
|
||||
minor (formats->main_device));
|
||||
|
||||
for (gsize i = 0; i < formats->tranches->len; i++)
|
||||
{
|
||||
DmabufTranche *tranche = g_ptr_array_index (formats->tranches, i);
|
||||
|
||||
GDK_DISPLAY_DEBUG (info->display, MISC,
|
||||
"dmabuf tranche target device: %u %u",
|
||||
major (tranche->target_device),
|
||||
minor (tranche->target_device));
|
||||
|
||||
GDK_DISPLAY_DEBUG (info->display, MISC,
|
||||
"dmabuf%s tranche (%lu entries):",
|
||||
tranche->flags & ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT ? " scanout" : "",
|
||||
tranche->n_formats);
|
||||
|
||||
for (gsize j = 0; j < tranche->n_formats; j++)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (info->display, MISC,
|
||||
" %.4s:%#" G_GINT64_MODIFIER "x",
|
||||
(char *) &(tranche->formats[j].fourcc),
|
||||
tranche->formats[j].modifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_done (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback)
|
||||
{
|
||||
DmabufFormatsInfo *info = data;
|
||||
|
||||
g_clear_pointer (&info->dmabuf_formats, dmabuf_formats_free);
|
||||
|
||||
info->dmabuf_formats = info->pending_dmabuf_formats;
|
||||
info->pending_dmabuf_formats = NULL;
|
||||
|
||||
update_dmabuf_formats (info);
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_format_table (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback,
|
||||
int32_t fd,
|
||||
uint32_t size)
|
||||
{
|
||||
DmabufFormatsInfo *info = data;
|
||||
|
||||
if (info->dmabuf_formats)
|
||||
munmap (info->dmabuf_formats, sizeof (DmabufFormat) * info->n_dmabuf_formats);
|
||||
|
||||
info->n_dmabuf_formats = size / 16;
|
||||
info->dmabuf_format_table = mmap (NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_main_device (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback,
|
||||
struct wl_array *device)
|
||||
{
|
||||
DmabufFormatsInfo *info = data;
|
||||
dev_t dev;
|
||||
|
||||
memcpy (&dev, device->data, sizeof (dev_t));
|
||||
|
||||
g_assert (info->pending_dmabuf_formats == NULL);
|
||||
|
||||
info->pending_dmabuf_formats = dmabuf_formats_new ();
|
||||
info->pending_dmabuf_formats->main_device = dev;
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_done (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback)
|
||||
{
|
||||
DmabufFormatsInfo *info = data;
|
||||
|
||||
g_ptr_array_add (info->pending_dmabuf_formats->tranches,
|
||||
info->pending_tranche);
|
||||
|
||||
info->pending_tranche = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_target_device (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback,
|
||||
struct wl_array *device)
|
||||
{
|
||||
DmabufFormatsInfo *info = data;
|
||||
dev_t dev;
|
||||
DmabufTranche *tranche;
|
||||
|
||||
memcpy (&dev, device->data, sizeof (dev_t));
|
||||
|
||||
g_assert (info->pending_tranche == NULL);
|
||||
|
||||
tranche = dmabuf_tranche_new ();
|
||||
tranche->target_device = dev;
|
||||
|
||||
info->pending_tranche = tranche;
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_formats (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback,
|
||||
struct wl_array *indices)
|
||||
{
|
||||
DmabufFormatsInfo *info = data;
|
||||
DmabufTranche *tranche;
|
||||
int i;
|
||||
guint16 *pos;
|
||||
|
||||
g_assert (info->pending_tranche != NULL);
|
||||
tranche = info->pending_tranche;
|
||||
|
||||
tranche->n_formats = indices->size / sizeof (guint16);
|
||||
tranche->formats = g_new (DmabufFormat, tranche->n_formats);
|
||||
|
||||
i = 0;
|
||||
wl_array_for_each (pos, indices)
|
||||
{
|
||||
tranche->formats[i++] = info->dmabuf_format_table[*pos];
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_flags (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback,
|
||||
uint32_t flags)
|
||||
{
|
||||
DmabufFormatsInfo *info = data;
|
||||
DmabufTranche *tranche;
|
||||
|
||||
g_assert (info->pending_tranche != NULL);
|
||||
tranche = info->pending_tranche;
|
||||
tranche->flags = flags;
|
||||
}
|
||||
|
||||
static const struct zwp_linux_dmabuf_feedback_v1_listener feedback_listener = {
|
||||
linux_dmabuf_done,
|
||||
linux_dmabuf_format_table,
|
||||
linux_dmabuf_main_device,
|
||||
linux_dmabuf_tranche_done,
|
||||
linux_dmabuf_tranche_target_device,
|
||||
linux_dmabuf_tranche_formats,
|
||||
linux_dmabuf_tranche_flags,
|
||||
};
|
||||
|
||||
DmabufFormatsInfo *
|
||||
dmabuf_formats_info_new (GdkDisplay *display,
|
||||
const char *name,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback)
|
||||
{
|
||||
DmabufFormatsInfo *info;
|
||||
|
||||
info = g_new0 (DmabufFormatsInfo, 1);
|
||||
|
||||
info->display = display;
|
||||
info->name = g_strdup (name);
|
||||
info->feedback = feedback;
|
||||
|
||||
if (info->feedback)
|
||||
zwp_linux_dmabuf_feedback_v1_add_listener (info->feedback,
|
||||
&feedback_listener, info);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
void
|
||||
dmabuf_formats_info_free (DmabufFormatsInfo *info)
|
||||
{
|
||||
g_free (info->name);
|
||||
g_clear_pointer (&info->feedback, zwp_linux_dmabuf_feedback_v1_destroy);
|
||||
if (info->dmabuf_format_table)
|
||||
{
|
||||
munmap (info->dmabuf_format_table, info->n_dmabuf_formats * 16);
|
||||
info->dmabuf_format_table = NULL;
|
||||
}
|
||||
g_clear_pointer (&info->dmabuf_formats, dmabuf_formats_free);
|
||||
g_clear_pointer (&info->pending_dmabuf_formats, dmabuf_formats_free);
|
||||
g_clear_pointer (&info->pending_tranche, dmabuf_tranche_free);
|
||||
|
||||
g_free (info);
|
||||
}
|
||||
@@ -88,14 +88,7 @@ gdk_wayland_gl_context_empty_frame (GdkDrawContext *draw_context)
|
||||
{
|
||||
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
|
||||
|
||||
if (gdk_wayland_surface_needs_commit (surface))
|
||||
{
|
||||
gdk_wayland_surface_sync (surface);
|
||||
gdk_wayland_surface_request_frame (surface);
|
||||
|
||||
gdk_wayland_surface_commit (surface);
|
||||
gdk_wayland_surface_notify_committed (surface);
|
||||
}
|
||||
gdk_wayland_surface_handle_empty_frame (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -116,13 +116,14 @@ void gdk_wayland_display_system_bell (GdkDisplay *display,
|
||||
|
||||
struct wl_buffer *_gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
||||
GdkCursor *cursor,
|
||||
guint desired_scale,
|
||||
double desired_scale,
|
||||
gboolean use_viewporter,
|
||||
guint image_index,
|
||||
int *hotspot_x,
|
||||
int *hotspot_y,
|
||||
int *w,
|
||||
int *h,
|
||||
int *scale);
|
||||
double *scale);
|
||||
guint _gdk_wayland_cursor_get_next_image_index (GdkWaylandDisplay *display,
|
||||
GdkCursor *cursor,
|
||||
guint scale,
|
||||
@@ -130,7 +131,7 @@ guint _gdk_wayland_cursor_get_next_image_index (GdkWaylandDisplay *display,
|
||||
guint *next_image_delay);
|
||||
|
||||
void gdk_wayland_surface_sync (GdkSurface *surface);
|
||||
gboolean gdk_wayland_surface_needs_commit (GdkSurface *surface);
|
||||
void gdk_wayland_surface_handle_empty_frame (GdkSurface *surface);
|
||||
void gdk_wayland_surface_commit (GdkSurface *surface);
|
||||
void gdk_wayland_surface_notify_committed (GdkSurface *surface);
|
||||
void gdk_wayland_surface_request_frame (GdkSurface *surface);
|
||||
|
||||
@@ -781,8 +781,8 @@ pointer_handle_motion (void *data,
|
||||
{
|
||||
double x, y;
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
g_message ("motion %f %f, seat %p state %d",
|
||||
x, y, seat, gdk_event_get_modifier_state (event));
|
||||
gdk_debug_message ("motion %f %f, seat %p state %d",
|
||||
x, y, seat, gdk_event_get_modifier_state (event));
|
||||
}
|
||||
|
||||
if (wl_seat_get_version (seat->wl_seat) < WL_POINTER_HAS_FRAME)
|
||||
@@ -1664,7 +1664,7 @@ touch_handle_down (void *data,
|
||||
{
|
||||
double xx, yy;
|
||||
gdk_event_get_position (event, &xx, &yy);
|
||||
g_message ("touch begin %f %f", xx, yy);
|
||||
gdk_debug_message ("touch begin %f %f", xx, yy);
|
||||
}
|
||||
|
||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||
@@ -1699,7 +1699,7 @@ touch_handle_up (void *data,
|
||||
{
|
||||
double x, y;
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
g_message ("touch end %f %f", x, y);
|
||||
gdk_debug_message ("touch end %f %f", x, y);
|
||||
}
|
||||
|
||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||
@@ -1747,7 +1747,7 @@ touch_handle_motion (void *data,
|
||||
{
|
||||
double xx, yy;
|
||||
gdk_event_get_position (event, &xx, &yy);
|
||||
g_message ("touch update %f %f", xx, yy);
|
||||
gdk_debug_message ("touch update %f %f", xx, yy);
|
||||
}
|
||||
|
||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||
@@ -1841,9 +1841,9 @@ emit_gesture_swipe_event (GdkWaylandSeat *seat,
|
||||
{
|
||||
double x, y;
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
g_message ("swipe event %d, coords: %f %f, seat %p state %d",
|
||||
gdk_event_get_event_type (event), x, y, seat,
|
||||
gdk_event_get_modifier_state (event));
|
||||
gdk_debug_message ("swipe event %d, coords: %f %f, seat %p state %d",
|
||||
gdk_event_get_event_type (event), x, y, seat,
|
||||
gdk_event_get_modifier_state (event));
|
||||
}
|
||||
|
||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||
@@ -1936,10 +1936,10 @@ emit_gesture_pinch_event (GdkWaylandSeat *seat,
|
||||
{
|
||||
double x, y;
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
g_message ("pinch event %d, coords: %f %f, seat %p state %d",
|
||||
gdk_event_get_event_type (event),
|
||||
x, y, seat,
|
||||
gdk_event_get_modifier_state (event));
|
||||
gdk_debug_message ("pinch event %d, coords: %f %f, seat %p state %d",
|
||||
gdk_event_get_event_type (event),
|
||||
x, y, seat,
|
||||
gdk_event_get_modifier_state (event));
|
||||
}
|
||||
|
||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||
@@ -2030,10 +2030,10 @@ emit_gesture_hold_event (GdkWaylandSeat *seat,
|
||||
{
|
||||
double x, y;
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
g_message ("hold event %d, coords: %f %f, seat %p state %d",
|
||||
gdk_event_get_event_type (event),
|
||||
x, y, seat,
|
||||
gdk_event_get_modifier_state (event));
|
||||
gdk_debug_message ("hold event %d, coords: %f %f, seat %p state %d",
|
||||
gdk_event_get_event_type (event),
|
||||
x, y, seat,
|
||||
gdk_event_get_modifier_state (event));
|
||||
}
|
||||
|
||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||
@@ -3767,8 +3767,7 @@ pointer_surface_update_scale (GdkDevice *device)
|
||||
GdkWaylandDevice *wayland_device = GDK_WAYLAND_DEVICE (device);
|
||||
GdkWaylandPointerData *pointer =
|
||||
gdk_wayland_device_get_pointer (wayland_device);
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
|
||||
guint32 scale;
|
||||
double scale;
|
||||
GSList *l;
|
||||
|
||||
if (wl_surface_get_version (pointer->pointer_surface) < WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
|
||||
@@ -3783,8 +3782,8 @@ pointer_surface_update_scale (GdkDevice *device)
|
||||
scale = 1;
|
||||
for (l = pointer->pointer_surface_outputs; l != NULL; l = l->next)
|
||||
{
|
||||
guint32 output_scale = gdk_wayland_display_get_output_scale (display_wayland, l->data);
|
||||
scale = MAX (scale, output_scale);
|
||||
GdkMonitor *monitor = gdk_wayland_display_get_monitor_for_output (seat->display, l->data);
|
||||
scale = MAX (scale, gdk_monitor_get_scale (monitor));
|
||||
}
|
||||
|
||||
if (pointer->current_output_scale == scale)
|
||||
@@ -3879,6 +3878,7 @@ gdk_wayland_pointer_data_finalize (GdkWaylandPointerData *pointer)
|
||||
g_clear_object (&pointer->cursor);
|
||||
wl_surface_destroy (pointer->pointer_surface);
|
||||
g_slist_free (pointer->pointer_surface_outputs);
|
||||
g_clear_pointer (&pointer->pointer_surface_viewport, wp_viewport_destroy);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -4242,6 +4242,9 @@ init_pointer_data (GdkWaylandPointerData *pointer_data,
|
||||
wl_surface_add_listener (pointer_data->pointer_surface,
|
||||
&pointer_surface_listener,
|
||||
logical_device);
|
||||
|
||||
if (display_wayland->viewporter)
|
||||
pointer_data->pointer_surface_viewport = wp_viewporter_get_viewport (display_wayland->viewporter, pointer_data->pointer_surface);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "gdksubsurfaceprivate.h"
|
||||
|
||||
#include "wayland-client-protocol.h"
|
||||
|
||||
typedef struct _GdkWaylandSubsurface GdkWaylandSubsurface;
|
||||
typedef struct _GdkWaylandSubsurfaceClass GdkWaylandSubsurfaceClass;
|
||||
@@ -23,10 +24,17 @@ struct _GdkWaylandSubsurface
|
||||
GdkTexture *texture;
|
||||
cairo_rectangle_int_t dest;
|
||||
graphene_rect_t source;
|
||||
enum wl_output_transform transform;
|
||||
|
||||
struct wl_region *opaque_region;
|
||||
|
||||
struct wl_callback *frame_callback;
|
||||
|
||||
struct wl_surface *bg_surface;
|
||||
struct wl_subsurface *bg_subsurface;
|
||||
struct wp_viewport *bg_viewport;
|
||||
cairo_rectangle_int_t bg_rect;
|
||||
gboolean bg_attached;
|
||||
};
|
||||
|
||||
struct _GdkWaylandSubsurfaceClass
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
#include "gdksurface-wayland-private.h"
|
||||
#include "gdksubsurfaceprivate.h"
|
||||
#include "gdkdebugprivate.h"
|
||||
#include "gsk/gskrectprivate.h"
|
||||
|
||||
#include "linux-dmabuf-unstable-v1-client-protocol.h"
|
||||
|
||||
@@ -46,10 +48,55 @@ gdk_wayland_subsurface_finalize (GObject *object)
|
||||
g_clear_pointer (&self->viewport, wp_viewport_destroy);
|
||||
g_clear_pointer (&self->subsurface, wl_subsurface_destroy);
|
||||
g_clear_pointer (&self->surface, wl_surface_destroy);
|
||||
g_clear_pointer (&self->bg_viewport, wp_viewport_destroy);
|
||||
g_clear_pointer (&self->bg_subsurface, wl_subsurface_destroy);
|
||||
g_clear_pointer (&self->bg_surface, wl_surface_destroy);
|
||||
|
||||
G_OBJECT_CLASS (gdk_wayland_subsurface_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
shm_buffer_release (void *data,
|
||||
struct wl_buffer *buffer)
|
||||
{
|
||||
cairo_surface_t *surface = data;
|
||||
|
||||
/* Note: the wl_buffer is destroyed as cairo user data */
|
||||
cairo_surface_destroy (surface);
|
||||
}
|
||||
|
||||
static const struct wl_buffer_listener shm_buffer_listener = {
|
||||
shm_buffer_release,
|
||||
};
|
||||
|
||||
static struct wl_buffer *
|
||||
get_shm_wl_buffer (GdkWaylandSubsurface *self,
|
||||
GdkTexture *texture)
|
||||
{
|
||||
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SUBSURFACE (self)->parent));
|
||||
int width, height;
|
||||
cairo_surface_t *surface;
|
||||
GdkTextureDownloader *downloader;
|
||||
struct wl_buffer *buffer;
|
||||
|
||||
width = gdk_texture_get_width (texture);
|
||||
height = gdk_texture_get_height (texture);
|
||||
surface = gdk_wayland_display_create_shm_surface (display, width, height, &GDK_FRACTIONAL_SCALE_INIT_INT (1));
|
||||
|
||||
downloader = gdk_texture_downloader_new (texture);
|
||||
|
||||
gdk_texture_downloader_download_into (downloader,
|
||||
cairo_image_surface_get_data (surface),
|
||||
cairo_image_surface_get_stride (surface));
|
||||
|
||||
gdk_texture_downloader_free (downloader);
|
||||
|
||||
buffer = _gdk_wayland_shm_surface_get_wl_buffer (surface);
|
||||
wl_buffer_add_listener (buffer, &shm_buffer_listener, surface);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
dmabuf_buffer_release (void *data,
|
||||
struct wl_buffer *buffer)
|
||||
@@ -96,8 +143,8 @@ static const struct zwp_linux_buffer_params_v1_listener params_listener = {
|
||||
};
|
||||
|
||||
static struct wl_buffer *
|
||||
get_wl_buffer (GdkWaylandSubsurface *self,
|
||||
GdkTexture *texture)
|
||||
get_dmabuf_wl_buffer (GdkWaylandSubsurface *self,
|
||||
GdkTexture *texture)
|
||||
{
|
||||
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SUBSURFACE (self)->parent));
|
||||
const GdkDmabuf *dmabuf;
|
||||
@@ -148,23 +195,138 @@ get_wl_buffer (GdkWaylandSubsurface *self,
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static struct wl_buffer *
|
||||
get_wl_buffer (GdkWaylandSubsurface *self,
|
||||
GdkTexture *texture)
|
||||
{
|
||||
GdkDisplay *display = gdk_surface_get_display (GDK_SUBSURFACE (self)->parent);
|
||||
struct wl_buffer *buffer = NULL;
|
||||
|
||||
if (GDK_IS_DMABUF_TEXTURE (texture))
|
||||
buffer = get_dmabuf_wl_buffer (self, texture);
|
||||
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (display, FORCE_OFFLOAD))
|
||||
{
|
||||
if (!buffer)
|
||||
buffer = get_shm_wl_buffer (self, texture);
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
sp_buffer_release (void *data,
|
||||
struct wl_buffer *buffer)
|
||||
{
|
||||
wl_buffer_destroy (buffer);
|
||||
}
|
||||
|
||||
static const struct wl_buffer_listener sp_buffer_listener = {
|
||||
sp_buffer_release,
|
||||
};
|
||||
|
||||
static struct wl_buffer *
|
||||
get_sp_buffer (GdkWaylandSubsurface *self)
|
||||
{
|
||||
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SUBSURFACE (self)->parent));
|
||||
struct wl_buffer *buffer = NULL;
|
||||
|
||||
if (display->single_pixel_buffer)
|
||||
buffer = wp_single_pixel_buffer_manager_v1_create_u32_rgba_buffer (display->single_pixel_buffer,
|
||||
0, 0, 0, 0xffffffffU);
|
||||
|
||||
if (buffer)
|
||||
wl_buffer_add_listener (buffer, &sp_buffer_listener, self);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static inline enum wl_output_transform
|
||||
gdk_texture_transform_to_wl (GdkTextureTransform transform)
|
||||
{
|
||||
return (enum wl_output_transform) transform;
|
||||
}
|
||||
|
||||
static inline GdkTextureTransform
|
||||
wl_output_transform_to_gdk (enum wl_output_transform transform)
|
||||
{
|
||||
return (GdkTextureTransform) transform;
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_bg_surface (GdkWaylandSubsurface *self)
|
||||
{
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (GDK_SUBSURFACE (self)->parent);
|
||||
GdkDisplay *display = gdk_surface_get_display (GDK_SUBSURFACE (self)->parent);
|
||||
GdkWaylandDisplay *disp = GDK_WAYLAND_DISPLAY (display);
|
||||
struct wl_region *region;
|
||||
|
||||
if (self->bg_surface)
|
||||
return;
|
||||
|
||||
self->bg_surface = wl_compositor_create_surface (disp->compositor);
|
||||
self->bg_subsurface = wl_subcompositor_get_subsurface (disp->subcompositor,
|
||||
self->bg_surface,
|
||||
impl->display_server.wl_surface);
|
||||
self->bg_viewport = wp_viewporter_get_viewport (disp->viewporter, self->bg_surface);
|
||||
|
||||
/* We are opaque */
|
||||
wl_surface_set_opaque_region (self->bg_surface, self->opaque_region);
|
||||
|
||||
/* No input, please */
|
||||
region = wl_compositor_create_region (disp->compositor);
|
||||
wl_surface_set_input_region (self->bg_surface, region);
|
||||
wl_region_destroy (region);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
scaled_rect_is_integral (const graphene_rect_t *rect,
|
||||
float scale,
|
||||
graphene_rect_t *device_rect)
|
||||
{
|
||||
cairo_rectangle_int_t device_int;
|
||||
|
||||
gsk_rect_scale (rect, scale, scale, device_rect);
|
||||
|
||||
device_int.x = device_rect->origin.x;
|
||||
device_int.y = device_rect->origin.y;
|
||||
device_int.width = device_rect->size.width;
|
||||
device_int.height = device_rect->size.height;
|
||||
|
||||
return device_int.x == device_rect->origin.x &&
|
||||
device_int.y == device_rect->origin.y &&
|
||||
device_int.width == device_rect->size.width &&
|
||||
device_int.height == device_rect->size.height;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_wayland_subsurface_attach (GdkSubsurface *sub,
|
||||
GdkTexture *texture,
|
||||
const graphene_rect_t *source,
|
||||
const graphene_rect_t *dest,
|
||||
GdkTextureTransform transform,
|
||||
const graphene_rect_t *background,
|
||||
gboolean above,
|
||||
GdkSubsurface *sibling)
|
||||
{
|
||||
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
|
||||
GdkWaylandSurface *parent = GDK_WAYLAND_SURFACE (sub->parent);
|
||||
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (sub->parent));
|
||||
struct wl_buffer *buffer = NULL;
|
||||
gboolean result = FALSE;
|
||||
GdkWaylandSubsurface *sib = sibling ? GDK_WAYLAND_SUBSURFACE (sibling) : NULL;
|
||||
gboolean will_be_above;
|
||||
double scale;
|
||||
graphene_rect_t device_rect;
|
||||
cairo_rectangle_int_t device_dest;
|
||||
gboolean has_background;
|
||||
enum wl_output_transform tf;
|
||||
gboolean dest_changed = FALSE;
|
||||
gboolean source_changed = FALSE;
|
||||
gboolean transform_changed = FALSE;
|
||||
gboolean stacking_changed = FALSE;
|
||||
gboolean needs_commit = FALSE;
|
||||
gboolean background_changed = FALSE;
|
||||
gboolean needs_bg_commit = FALSE;
|
||||
|
||||
if (sibling)
|
||||
will_be_above = sibling->above_parent;
|
||||
@@ -177,69 +339,133 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self->dest.x = dest->origin.x;
|
||||
self->dest.y = dest->origin.y;
|
||||
self->dest.width = dest->size.width;
|
||||
self->dest.height = dest->size.height;
|
||||
|
||||
self->source.origin.x = source->origin.x;
|
||||
self->source.origin.y = source->origin.y;
|
||||
self->source.size.width = source->size.width;
|
||||
self->source.size.height = source->size.height;
|
||||
|
||||
scale = gdk_fractional_scale_to_double (&parent->scale);
|
||||
|
||||
device_rect.origin.x = dest->origin.x * scale;
|
||||
device_rect.origin.y = dest->origin.y * scale;
|
||||
device_rect.size.width = dest->size.width * scale;
|
||||
device_rect.size.height = dest->size.height * scale;
|
||||
|
||||
device_dest.x = device_rect.origin.x;
|
||||
device_dest.y = device_rect.origin.y;
|
||||
device_dest.width = device_rect.size.width;
|
||||
device_dest.height = device_rect.size.height;
|
||||
|
||||
if (self->dest.x != dest->origin.x ||
|
||||
self->dest.y != dest->origin.y ||
|
||||
self->dest.width != dest->size.width ||
|
||||
self->dest.height != dest->size.height)
|
||||
{
|
||||
self->dest.x = dest->origin.x;
|
||||
self->dest.y = dest->origin.y;
|
||||
self->dest.width = dest->size.width;
|
||||
self->dest.height = dest->size.height;
|
||||
dest_changed = TRUE;
|
||||
}
|
||||
|
||||
if (!gsk_rect_equal (&self->source, source))
|
||||
{
|
||||
self->source.origin.x = source->origin.x;
|
||||
self->source.origin.y = source->origin.y;
|
||||
self->source.size.width = source->size.width;
|
||||
self->source.size.height = source->size.height;
|
||||
source_changed = TRUE;
|
||||
}
|
||||
|
||||
tf = gdk_texture_transform_to_wl (transform);
|
||||
if (self->transform != tf)
|
||||
{
|
||||
self->transform = tf;
|
||||
transform_changed = TRUE;
|
||||
}
|
||||
|
||||
if (sibling != gdk_subsurface_get_sibling (sub, above) ||
|
||||
will_be_above != gdk_subsurface_is_above_parent (sub))
|
||||
stacking_changed = TRUE;
|
||||
|
||||
if (self->texture == NULL)
|
||||
{
|
||||
dest_changed = TRUE;
|
||||
source_changed = TRUE;
|
||||
transform_changed = TRUE;
|
||||
stacking_changed = TRUE;
|
||||
}
|
||||
|
||||
scale = gdk_fractional_scale_to_double (&parent->scale);
|
||||
|
||||
if (background)
|
||||
{
|
||||
background_changed =
|
||||
!self->bg_attached ||
|
||||
self->bg_rect.x != background->origin.x ||
|
||||
self->bg_rect.y != background->origin.y ||
|
||||
self->bg_rect.width != background->size.width ||
|
||||
self->bg_rect.height != background->size.height;
|
||||
self->bg_rect.x = background->origin.x;
|
||||
self->bg_rect.y = background->origin.y;
|
||||
self->bg_rect.width = background->size.width;
|
||||
self->bg_rect.height = background->size.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
background_changed = self->bg_attached;
|
||||
self->bg_rect.x = 0;
|
||||
self->bg_rect.y = 0;
|
||||
self->bg_rect.width = 0;
|
||||
self->bg_rect.height = 0;
|
||||
}
|
||||
|
||||
has_background = self->bg_rect.width > 0 && self->bg_rect.height > 0;
|
||||
|
||||
if (has_background)
|
||||
ensure_bg_surface (self);
|
||||
|
||||
if (!scaled_rect_is_integral (dest, 1, &device_rect))
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"Non-integer coordinates %g %g %g %g for %dx%d texture, hiding subsurface %p",
|
||||
"[%p] 🗙 Non-integral coordinates %g %g %g %g",
|
||||
self,
|
||||
dest->origin.x, dest->origin.y,
|
||||
dest->size.width, dest->size.height,
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
self);
|
||||
dest->size.width, dest->size.height);
|
||||
}
|
||||
else if (device_dest.x != device_rect.origin.x ||
|
||||
device_dest.y != device_rect.origin.y ||
|
||||
device_dest.width != device_rect.size.width ||
|
||||
device_dest.height != device_rect.size.height)
|
||||
else if (!scaled_rect_is_integral (dest, scale, &device_rect))
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"Non-integral device coordinates %g %g %g %g (fractional scale %.2f), hiding subsurface %p",
|
||||
"[%p] 🗙 Non-integral device coordinates %g %g %g %g (scale %.2f)",
|
||||
self,
|
||||
device_rect.origin.x, device_rect.origin.y,
|
||||
device_rect.size.width, device_rect.size.width,
|
||||
scale,
|
||||
self);
|
||||
device_rect.size.width, device_rect.size.height,
|
||||
scale);
|
||||
}
|
||||
else if (!GDK_IS_DMABUF_TEXTURE (texture))
|
||||
else if (background && !scaled_rect_is_integral (background, 1, &device_rect))
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"%dx%d %s is not a GdkDmabufTexture, hiding subsurface %p",
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
"[%p] 🗙 Non-integral background coordinates %g %g %g %g",
|
||||
self,
|
||||
background->origin.x, background->origin.y,
|
||||
background->size.width, background->size.height);
|
||||
}
|
||||
else if (background && !scaled_rect_is_integral (background, scale, &device_rect))
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"[%p] 🗙 Non-integral background device coordinates %g %g %g %g (scale %.2f)",
|
||||
self,
|
||||
device_rect.origin.x, device_rect.origin.y,
|
||||
device_rect.size.width, device_rect.size.height,
|
||||
scale);
|
||||
}
|
||||
else if (!GDK_IS_DMABUF_TEXTURE (texture) &&
|
||||
!GDK_DISPLAY_DEBUG_CHECK (gdk_surface_get_display (sub->parent), FORCE_OFFLOAD))
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"[%p] 🗙 %s (%dx%d) is not a GdkDmabufTexture",
|
||||
self,
|
||||
G_OBJECT_TYPE_NAME (texture),
|
||||
self);
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture));
|
||||
}
|
||||
else if (!will_be_above &&
|
||||
gdk_memory_format_alpha (gdk_texture_get_format (texture)) != GDK_MEMORY_ALPHA_OPAQUE)
|
||||
gdk_memory_format_alpha (gdk_texture_get_format (texture)) != GDK_MEMORY_ALPHA_OPAQUE &&
|
||||
!has_background)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"Cannot offload non-opaque %dx%d texture below, hiding subsurface %p",
|
||||
"[%p] 🗙 Non-opaque texture (%dx%d) below",
|
||||
self,
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
gdk_texture_get_height (texture));
|
||||
}
|
||||
else if (has_background && !display->single_pixel_buffer)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"[%p] 🗙 Texture has background, but no single-pixel buffer support",
|
||||
self);
|
||||
}
|
||||
else
|
||||
@@ -268,10 +494,13 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
|
||||
}
|
||||
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"Attached %dx%d texture to subsurface %p at %d %d %d %d",
|
||||
"[%p] %s Attaching texture (%dx%d) at %d %d %d %d",
|
||||
self,
|
||||
will_be_above
|
||||
? (has_background ? "▲" : "△")
|
||||
: (has_background ? "▼" : "▽"),
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
self,
|
||||
self->dest.x, self->dest.y,
|
||||
self->dest.width, self->dest.height);
|
||||
result = TRUE;
|
||||
@@ -279,35 +508,53 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
|
||||
else
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"Compositor failed to create wl_buffer for %dx%d texture, hiding subsurface %p",
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
"[%p] 🗙 Failed to create wl_buffer",
|
||||
self);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dest_changed)
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"[%p] %s Moving texture (%dx%d) to %d %d %d %d",
|
||||
self,
|
||||
will_be_above
|
||||
? (has_background ? "▲" : "△")
|
||||
: (has_background ? "▼" : "▽"),
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
self->dest.x, self->dest.y,
|
||||
self->dest.width, self->dest.height);
|
||||
|
||||
buffer = NULL;
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||
"Moved %dx%d texture in subsurface %p to %d %d %d %d",
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
self,
|
||||
self->dest.x, self->dest.y,
|
||||
self->dest.width, self->dest.height);
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
wl_subsurface_set_position (self->subsurface, self->dest.x, self->dest.y);
|
||||
wp_viewport_set_destination (self->viewport, self->dest.width, self->dest.height);
|
||||
wp_viewport_set_source (self->viewport,
|
||||
wl_fixed_from_double (self->source.origin.x),
|
||||
wl_fixed_from_double (self->source.origin.y),
|
||||
wl_fixed_from_double (self->source.size.width),
|
||||
wl_fixed_from_double (self->source.size.height));
|
||||
if (transform_changed)
|
||||
{
|
||||
wl_surface_set_buffer_transform (self->surface, self->transform);
|
||||
needs_commit = TRUE;
|
||||
}
|
||||
|
||||
if (dest_changed)
|
||||
{
|
||||
wl_subsurface_set_position (self->subsurface, self->dest.x, self->dest.y);
|
||||
wp_viewport_set_destination (self->viewport, self->dest.width, self->dest.height);
|
||||
needs_commit = TRUE;
|
||||
}
|
||||
|
||||
if (source_changed)
|
||||
{
|
||||
wp_viewport_set_source (self->viewport,
|
||||
wl_fixed_from_double (self->source.origin.x),
|
||||
wl_fixed_from_double (self->source.origin.y),
|
||||
wl_fixed_from_double (self->source.size.width),
|
||||
wl_fixed_from_double (self->source.size.height));
|
||||
needs_commit = TRUE;
|
||||
}
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
@@ -316,39 +563,95 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
|
||||
0, 0,
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture));
|
||||
needs_commit = TRUE;
|
||||
}
|
||||
|
||||
if (has_background)
|
||||
{
|
||||
if (background_changed)
|
||||
{
|
||||
wl_subsurface_set_position (self->bg_subsurface, self->bg_rect.x, self->bg_rect.y);
|
||||
wp_viewport_set_destination (self->bg_viewport, self->bg_rect.width, self->bg_rect.height);
|
||||
needs_bg_commit = TRUE;
|
||||
}
|
||||
|
||||
if (!self->bg_attached)
|
||||
{
|
||||
self->bg_attached = TRUE;
|
||||
|
||||
wp_viewport_set_source (self->bg_viewport,
|
||||
wl_fixed_from_int (0),
|
||||
wl_fixed_from_int (0),
|
||||
wl_fixed_from_int (1),
|
||||
wl_fixed_from_int (1));
|
||||
wl_surface_attach (self->bg_surface, get_sp_buffer (self), 0, 0);
|
||||
wl_surface_damage_buffer (self->bg_surface, 0, 0, 1, 1);
|
||||
needs_bg_commit = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (self->bg_attached)
|
||||
{
|
||||
self->bg_attached = FALSE;
|
||||
wl_surface_attach (self->bg_surface, NULL, 0, 0);
|
||||
needs_bg_commit = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
result = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_set_object (&self->texture, NULL);
|
||||
if (g_set_object (&self->texture, NULL))
|
||||
{
|
||||
wl_surface_attach (self->surface, NULL, 0, 0);
|
||||
needs_commit = TRUE;
|
||||
}
|
||||
|
||||
wl_surface_attach (self->surface, NULL, 0, 0);
|
||||
if (self->bg_attached)
|
||||
{
|
||||
self->bg_attached = FALSE;
|
||||
wl_surface_attach (self->bg_surface, NULL, 0, 0);
|
||||
needs_bg_commit = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (sib)
|
||||
if (stacking_changed)
|
||||
{
|
||||
if (above)
|
||||
wl_subsurface_place_above (self->subsurface, sib->surface);
|
||||
if (sib)
|
||||
{
|
||||
if (above)
|
||||
wl_subsurface_place_above (self->subsurface, sib->surface);
|
||||
else
|
||||
wl_subsurface_place_below (self->subsurface, sib->surface);
|
||||
}
|
||||
else
|
||||
wl_subsurface_place_below (self->subsurface, sib->surface);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (above)
|
||||
wl_subsurface_place_above (self->subsurface,
|
||||
GDK_WAYLAND_SURFACE (sub->parent)->display_server.wl_surface);
|
||||
else
|
||||
wl_subsurface_place_below (self->subsurface,
|
||||
GDK_WAYLAND_SURFACE (sub->parent)->display_server.wl_surface);
|
||||
{
|
||||
if (above)
|
||||
wl_subsurface_place_above (self->subsurface,
|
||||
GDK_WAYLAND_SURFACE (sub->parent)->display_server.wl_surface);
|
||||
else
|
||||
wl_subsurface_place_below (self->subsurface,
|
||||
GDK_WAYLAND_SURFACE (sub->parent)->display_server.wl_surface);
|
||||
}
|
||||
needs_commit = TRUE;
|
||||
|
||||
if (self->bg_attached)
|
||||
{
|
||||
wl_subsurface_place_below (self->bg_subsurface, self->surface);
|
||||
needs_bg_commit = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
wl_surface_commit (self->surface);
|
||||
if (needs_commit)
|
||||
wl_surface_commit (self->surface);
|
||||
|
||||
((GdkWaylandSurface *)sub->parent)->has_pending_subsurface_commits = TRUE;
|
||||
GDK_WAYLAND_SURFACE (sub->parent)->opaque_region_dirty = TRUE;
|
||||
if (needs_bg_commit)
|
||||
wl_surface_commit (self->bg_surface);
|
||||
|
||||
((GdkWaylandSurface *)sub->parent)->has_pending_subsurface_commits = needs_commit || needs_bg_commit;
|
||||
GDK_WAYLAND_SURFACE (sub->parent)->opaque_region_dirty = stacking_changed || dest_changed || background_changed;
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -360,7 +663,7 @@ gdk_wayland_subsurface_detach (GdkSubsurface *sub)
|
||||
|
||||
if (sub->parent == NULL)
|
||||
{
|
||||
g_warning ("Can't draw to destroyed subsurface %p", self);
|
||||
g_warning ("Can't detach from destroyed subsurface %p", self);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -369,6 +672,13 @@ gdk_wayland_subsurface_detach (GdkSubsurface *sub)
|
||||
wl_surface_set_opaque_region (self->surface, self->opaque_region);
|
||||
wl_surface_commit (self->surface);
|
||||
|
||||
if (self->bg_attached)
|
||||
{
|
||||
wl_surface_attach (self->bg_surface, NULL, 0, 0);
|
||||
wl_surface_commit (self->bg_surface);
|
||||
self->bg_attached = FALSE;
|
||||
}
|
||||
|
||||
((GdkWaylandSurface *)sub->parent)->has_pending_subsurface_commits = TRUE;
|
||||
GDK_WAYLAND_SURFACE (sub->parent)->opaque_region_dirty = TRUE;
|
||||
}
|
||||
@@ -382,27 +692,49 @@ gdk_wayland_subsurface_get_texture (GdkSubsurface *sub)
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_subsurface_get_dest (GdkSubsurface *sub,
|
||||
graphene_rect_t *dest)
|
||||
gdk_wayland_subsurface_get_texture_rect (GdkSubsurface *sub,
|
||||
graphene_rect_t *rect)
|
||||
{
|
||||
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
|
||||
|
||||
dest->origin.x = self->dest.x;
|
||||
dest->origin.y = self->dest.y;
|
||||
dest->size.width = self->dest.width;
|
||||
dest->size.height = self->dest.height;
|
||||
rect->origin.x = self->dest.x;
|
||||
rect->origin.y = self->dest.y;
|
||||
rect->size.width = self->dest.width;
|
||||
rect->size.height = self->dest.height;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_subsurface_get_source (GdkSubsurface *sub,
|
||||
graphene_rect_t *source)
|
||||
gdk_wayland_subsurface_get_source_rect (GdkSubsurface *sub,
|
||||
graphene_rect_t *rect)
|
||||
{
|
||||
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
|
||||
|
||||
source->origin.x = self->source.origin.x;
|
||||
source->origin.y = self->source.origin.y;
|
||||
source->size.width = self->source.size.width;
|
||||
source->size.height = self->source.size.height;
|
||||
rect->origin.x = self->source.origin.x;
|
||||
rect->origin.y = self->source.origin.y;
|
||||
rect->size.width = self->source.size.width;
|
||||
rect->size.height = self->source.size.height;
|
||||
}
|
||||
|
||||
static GdkTextureTransform
|
||||
gdk_wayland_subsurface_get_transform (GdkSubsurface *sub)
|
||||
{
|
||||
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
|
||||
|
||||
return wl_output_transform_to_gdk (self->transform);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_wayland_subsurface_get_background_rect (GdkSubsurface *sub,
|
||||
graphene_rect_t *rect)
|
||||
{
|
||||
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
|
||||
|
||||
rect->origin.x = self->bg_rect.x;
|
||||
rect->origin.y = self->bg_rect.y;
|
||||
rect->size.width = self->bg_rect.width;
|
||||
rect->size.height = self->bg_rect.height;
|
||||
|
||||
return rect->size.width > 0 && rect->size.height > 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -416,8 +748,10 @@ gdk_wayland_subsurface_class_init (GdkWaylandSubsurfaceClass *class)
|
||||
subsurface_class->attach = gdk_wayland_subsurface_attach;
|
||||
subsurface_class->detach = gdk_wayland_subsurface_detach;
|
||||
subsurface_class->get_texture = gdk_wayland_subsurface_get_texture;
|
||||
subsurface_class->get_source = gdk_wayland_subsurface_get_source;
|
||||
subsurface_class->get_dest = gdk_wayland_subsurface_get_dest;
|
||||
subsurface_class->get_source_rect = gdk_wayland_subsurface_get_source_rect;
|
||||
subsurface_class->get_texture_rect = gdk_wayland_subsurface_get_texture_rect;
|
||||
subsurface_class->get_transform = gdk_wayland_subsurface_get_transform;
|
||||
subsurface_class->get_background_rect = gdk_wayland_subsurface_get_background_rect;
|
||||
};
|
||||
|
||||
static void
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
#include "linux-dmabuf-unstable-v1-client-protocol.h"
|
||||
#include "presentation-time-client-protocol.h"
|
||||
|
||||
#include "gsk/gskrectprivate.h"
|
||||
|
||||
|
||||
/**
|
||||
* GdkWaylandSurface:
|
||||
@@ -657,6 +659,7 @@ static void
|
||||
gdk_wayland_surface_sync_opaque_region (GdkSurface *surface)
|
||||
{
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
||||
struct wl_region *wl_region = NULL;
|
||||
|
||||
if (!impl->display_server.wl_surface)
|
||||
@@ -679,16 +682,21 @@ gdk_wayland_surface_sync_opaque_region (GdkSurface *surface)
|
||||
continue;
|
||||
|
||||
if (sub->texture != NULL)
|
||||
cairo_region_subtract_rectangle (region, &sub->dest);
|
||||
{
|
||||
graphene_rect_t bounds;
|
||||
cairo_rectangle_int_t rect;
|
||||
|
||||
gdk_subsurface_get_bounds (subsurface, &bounds);
|
||||
gsk_rect_to_cairo_grow (&bounds, &rect);
|
||||
cairo_region_subtract_rectangle (region, &rect);
|
||||
}
|
||||
}
|
||||
|
||||
wl_region = wl_region_from_cairo_region (GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface)),
|
||||
region);
|
||||
wl_region = wl_region_from_cairo_region (display, region);
|
||||
cairo_region_destroy (region);
|
||||
}
|
||||
else
|
||||
wl_region = wl_region_from_cairo_region (GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface)),
|
||||
impl->opaque_region);
|
||||
wl_region = wl_region_from_cairo_region (display, impl->opaque_region);
|
||||
}
|
||||
|
||||
wl_surface_set_opaque_region (impl->display_server.wl_surface, wl_region);
|
||||
@@ -775,7 +783,7 @@ gdk_wayland_surface_sync (GdkSurface *surface)
|
||||
gdk_wayland_surface_sync_viewport (surface);
|
||||
}
|
||||
|
||||
gboolean
|
||||
static gboolean
|
||||
gdk_wayland_surface_needs_commit (GdkSurface *surface)
|
||||
{
|
||||
GdkWaylandSurface *self = GDK_WAYLAND_SURFACE (surface);
|
||||
@@ -787,6 +795,20 @@ gdk_wayland_surface_needs_commit (GdkSurface *surface)
|
||||
self->viewport_dirty;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_wayland_surface_handle_empty_frame (GdkSurface *surface)
|
||||
{
|
||||
if (!gdk_wayland_surface_needs_commit (surface))
|
||||
return;
|
||||
|
||||
gdk_wayland_surface_sync (surface);
|
||||
gdk_wayland_surface_request_frame (surface);
|
||||
|
||||
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "Wayland surface commit", NULL);
|
||||
gdk_wayland_surface_commit (surface);
|
||||
gdk_wayland_surface_notify_committed (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_surface_fractional_scale_preferred_scale_cb (void *data,
|
||||
struct wp_fractional_scale_v1 *fractional_scale,
|
||||
@@ -799,6 +821,11 @@ gdk_wayland_surface_fractional_scale_preferred_scale_cb (void *data,
|
||||
gdk_wayland_surface_update_size (surface,
|
||||
surface->width, surface->height,
|
||||
&GDK_FRACTIONAL_SCALE_INIT (scale));
|
||||
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (surface), EVENTS,
|
||||
"preferred fractional scale, surface %p scale %f",
|
||||
surface,
|
||||
gdk_fractional_scale_to_double (&GDK_FRACTIONAL_SCALE_INIT (scale)));
|
||||
}
|
||||
|
||||
static const struct wp_fractional_scale_v1_listener fractional_scale_listener = {
|
||||
@@ -815,8 +842,8 @@ surface_enter (void *data,
|
||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||
GdkMonitor *monitor;
|
||||
|
||||
GDK_DISPLAY_DEBUG(gdk_surface_get_display (surface), EVENTS,
|
||||
"surface enter, surface %p output %p", surface, output);
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (surface), EVENTS,
|
||||
"surface enter, surface %p output %p", surface, output);
|
||||
|
||||
impl->display_server.outputs = g_slist_prepend (impl->display_server.outputs, output);
|
||||
|
||||
@@ -848,9 +875,38 @@ surface_leave (void *data,
|
||||
gdk_surface_leave_monitor (surface, monitor);
|
||||
}
|
||||
|
||||
static void
|
||||
surface_preferred_buffer_scale (void *data,
|
||||
struct wl_surface *wl_surface,
|
||||
int32_t factor)
|
||||
{
|
||||
GdkSurface *surface = GDK_SURFACE (data);
|
||||
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (surface), EVENTS,
|
||||
"preferred buffer scale, surface %p scale %d",
|
||||
surface, factor);
|
||||
}
|
||||
|
||||
static void
|
||||
surface_preferred_buffer_transform (void *data,
|
||||
struct wl_surface *wl_surface,
|
||||
uint32_t transform)
|
||||
{
|
||||
GdkSurface *surface = GDK_SURFACE (data);
|
||||
const char *transform_name[] = {
|
||||
"normal", "90", "180", "270", "flipped", "flipped-90", "flipped-180", "flipped-270"
|
||||
};
|
||||
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (surface), EVENTS,
|
||||
"preferred buffer transform, surface %p transform %s",
|
||||
surface, transform_name[transform]);
|
||||
}
|
||||
|
||||
static const struct wl_surface_listener surface_listener = {
|
||||
surface_enter,
|
||||
surface_leave
|
||||
surface_leave,
|
||||
surface_preferred_buffer_scale,
|
||||
surface_preferred_buffer_transform,
|
||||
};
|
||||
|
||||
static void
|
||||
|
||||
@@ -77,16 +77,8 @@ static void
|
||||
gdk_vulkan_context_wayland_empty_frame (GdkDrawContext *context)
|
||||
{
|
||||
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
|
||||
if (!impl->has_pending_subsurface_commits)
|
||||
return;
|
||||
|
||||
gdk_wayland_surface_sync (surface);
|
||||
gdk_wayland_surface_request_frame (surface);
|
||||
|
||||
gdk_wayland_surface_commit (surface);
|
||||
gdk_wayland_surface_notify_committed (surface);
|
||||
gdk_wayland_surface_handle_empty_frame (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -48,7 +48,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
struct wl_display *gdk_wayland_display_get_wl_display (GdkDisplay *display);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
struct wl_compositor *gdk_wayland_display_get_wl_compositor (GdkDisplay *display);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_16
|
||||
void gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
|
||||
const char *name,
|
||||
int size);
|
||||
@@ -60,7 +60,7 @@ void gdk_wayland_display_set_startup_notification_id (GdkDisp
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_wayland_display_query_registry (GdkDisplay *display,
|
||||
const char *global);
|
||||
const char *global);
|
||||
|
||||
GDK_AVAILABLE_IN_4_4
|
||||
gpointer gdk_wayland_display_get_egl_display (GdkDisplay *display);
|
||||
|
||||
+25
-61
@@ -8,6 +8,7 @@ gdk_wayland_sources = files([
|
||||
'gdkdevice-wayland.c',
|
||||
'gdkdevicepad-wayland.c',
|
||||
'gdkdisplay-wayland.c',
|
||||
'gdkdmabuf-wayland.c',
|
||||
'gdkdrag-wayland.c',
|
||||
'gdkdragsurface-wayland.c',
|
||||
'gdkdrop-wayland.c',
|
||||
@@ -47,73 +48,36 @@ gdk_wayland_deps = [
|
||||
wlegldep,
|
||||
]
|
||||
|
||||
wayland_scanner = find_program('wayland-scanner')
|
||||
|
||||
# Format:
|
||||
# - protocol name
|
||||
# - protocol stability ('private', 'stable' or 'unstable')
|
||||
# - protocol version (if stability is 'unstable')
|
||||
wlmod = import('unstable-wayland')
|
||||
proto_sources = [
|
||||
['gtk-shell', 'private', ],
|
||||
['primary-selection', 'unstable', 'v1', ],
|
||||
['pointer-gestures', 'unstable', 'v1', ],
|
||||
['viewporter', 'stable', ],
|
||||
['xdg-shell', 'unstable', 'v6', ],
|
||||
['xdg-shell', 'stable', ],
|
||||
['xdg-foreign', 'unstable', 'v1', ],
|
||||
['xdg-foreign', 'unstable', 'v2', ],
|
||||
['tablet', 'unstable', 'v2', ],
|
||||
['keyboard-shortcuts-inhibit', 'unstable', 'v1', ],
|
||||
['server-decoration', 'private' ],
|
||||
['xdg-output', 'unstable', 'v1', ],
|
||||
['idle-inhibit', 'unstable', 'v1', ],
|
||||
['xdg-activation', 'staging', 'v1', ],
|
||||
['fractional-scale', 'staging', 'v1', ],
|
||||
['linux-dmabuf', 'unstable', 'v1', ],
|
||||
['presentation-time', 'stable', 'v1', ],
|
||||
'protocol/gtk-shell.xml',
|
||||
'protocol/server-decoration.xml',
|
||||
wlmod.find_protocol('primary-selection', state: 'unstable', version: 1),
|
||||
wlmod.find_protocol('pointer-gestures', state: 'unstable', version: 1),
|
||||
wlmod.find_protocol('viewporter', state: 'stable'),
|
||||
wlmod.find_protocol('xdg-shell', state: 'unstable', version: 6),
|
||||
wlmod.find_protocol('xdg-shell', state: 'stable'),
|
||||
wlmod.find_protocol('xdg-foreign', state: 'unstable', version: 1),
|
||||
wlmod.find_protocol('xdg-foreign', state: 'unstable', version: 2),
|
||||
wlmod.find_protocol('tablet', state: 'unstable', version: 2),
|
||||
wlmod.find_protocol('keyboard-shortcuts-inhibit', state: 'unstable', version: 1),
|
||||
wlmod.find_protocol('xdg-output', state: 'unstable', version: 1),
|
||||
wlmod.find_protocol('idle-inhibit', state: 'unstable', version: 1),
|
||||
wlmod.find_protocol('xdg-activation', state: 'staging', version: 1),
|
||||
wlmod.find_protocol('fractional-scale', state: 'staging', version: 1),
|
||||
wlmod.find_protocol('linux-dmabuf', state: 'unstable', version: 1),
|
||||
wlmod.find_protocol('presentation-time', state: 'stable'),
|
||||
wlmod.find_protocol('single-pixel-buffer', state: 'staging', version: 1),
|
||||
]
|
||||
|
||||
gdk_wayland_gen_headers = []
|
||||
|
||||
foreach p: proto_sources
|
||||
proto_name = p.get(0)
|
||||
proto_stability = p.get(1)
|
||||
|
||||
if proto_stability == 'stable'
|
||||
output_base = proto_name
|
||||
input = files(join_paths(wlproto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base)))
|
||||
elif proto_stability == 'staging'
|
||||
proto_version = p.get(2)
|
||||
output_base = '@0@-@1@'.format(proto_name, proto_version)
|
||||
input = files(join_paths(wlproto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base)))
|
||||
elif proto_stability == 'private'
|
||||
output_base = proto_name
|
||||
input = files('protocol/@0@.xml'.format(proto_name))
|
||||
else
|
||||
proto_version = p.get(2)
|
||||
output_base = '@0@-@1@-@2@'.format(proto_name, proto_stability, proto_version)
|
||||
input = files(join_paths(wlproto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base)))
|
||||
endif
|
||||
|
||||
gdk_wayland_gen_headers += custom_target('@0@ client header'.format(output_base),
|
||||
input: input,
|
||||
output: '@0@-client-protocol.h'.format(output_base),
|
||||
command: [
|
||||
wayland_scanner,
|
||||
'client-header',
|
||||
'@INPUT@', '@OUTPUT@',
|
||||
],
|
||||
)
|
||||
|
||||
gdk_wayland_sources += custom_target('@0@ source'.format(output_base),
|
||||
input: input,
|
||||
output: '@0@-protocol.c'.format(output_base),
|
||||
command: [
|
||||
wayland_scanner,
|
||||
'private-code',
|
||||
'@INPUT@', '@OUTPUT@',
|
||||
],
|
||||
)
|
||||
# Returns a list [.c, .h]
|
||||
gen = wlmod.scan_xml(p)
|
||||
assert(gen.length() == 2)
|
||||
gdk_wayland_sources += gen[0]
|
||||
gdk_wayland_gen_headers += gen[1]
|
||||
endforeach
|
||||
|
||||
libgdk_wayland = static_library('gdk-wayland',
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "gdkcursor.h"
|
||||
#include "gdkwin32.h"
|
||||
#include "gdktextureprivate.h"
|
||||
#include "gdkcursorprivate.h"
|
||||
|
||||
#include "gdkdisplay-win32.h"
|
||||
|
||||
@@ -907,7 +908,9 @@ _gdk_win32_create_hicon_for_texture (GdkTexture *texture,
|
||||
width = cairo_image_surface_get_width (surface);
|
||||
height = cairo_image_surface_get_height (surface);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
icon = pixbuf_to_hicon (pixbuf, is_icon, x, y);
|
||||
|
||||
@@ -1481,6 +1484,7 @@ gdk_win32_display_get_win32hcursor (GdkWin32Display *display,
|
||||
GdkWin32Display *win32_display = GDK_WIN32_DISPLAY (display);
|
||||
GdkWin32HCursor *win32hcursor;
|
||||
const char *cursor_name;
|
||||
GdkTexture *texture;
|
||||
GdkCursor *fallback;
|
||||
|
||||
g_return_val_if_fail (cursor != NULL, NULL);
|
||||
@@ -1494,14 +1498,32 @@ gdk_win32_display_get_win32hcursor (GdkWin32Display *display,
|
||||
return win32hcursor;
|
||||
|
||||
cursor_name = gdk_cursor_get_name (cursor);
|
||||
texture = gdk_cursor_get_texture (cursor);
|
||||
|
||||
if (cursor_name)
|
||||
win32hcursor = gdk_win32hcursor_create_for_name (display, cursor_name);
|
||||
else
|
||||
else if (texture)
|
||||
win32hcursor = gdk_win32hcursor_create_for_texture (display,
|
||||
gdk_cursor_get_texture (cursor),
|
||||
texture,
|
||||
gdk_cursor_get_hotspot_x (cursor),
|
||||
gdk_cursor_get_hotspot_y (cursor));
|
||||
else
|
||||
{
|
||||
int size = display->cursor_theme_size;
|
||||
int width, height, hotspot_x, hotspot_y;
|
||||
|
||||
texture = gdk_cursor_get_texture_for_size (cursor, size, 1,
|
||||
&width, &height,
|
||||
&hotspot_x, &hotspot_y);
|
||||
if (texture)
|
||||
{
|
||||
win32hcursor = gdk_win32hcursor_create_for_texture (display,
|
||||
texture,
|
||||
hotspot_x,
|
||||
hotspot_y);
|
||||
g_object_unref (texture);
|
||||
}
|
||||
}
|
||||
|
||||
if (win32hcursor != NULL)
|
||||
{
|
||||
|
||||
@@ -267,7 +267,7 @@ create_dummy_gl_window (void)
|
||||
{
|
||||
WNDCLASS wclass = { 0, };
|
||||
ATOM klass;
|
||||
HWND hwnd;
|
||||
HWND hwnd = NULL;
|
||||
|
||||
wclass.lpszClassName = "GdkGLDummyWindow";
|
||||
wclass.lpfnWndProc = DefWindowProc;
|
||||
|
||||
@@ -38,7 +38,6 @@ gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context,
|
||||
{
|
||||
GdkSurface *window = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
|
||||
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
|
||||
GdkWin32Surface *win32_surface = GDK_WIN32_SURFACE (window);
|
||||
VkWin32SurfaceCreateInfoKHR info;
|
||||
VkResult result;
|
||||
|
||||
|
||||
+34
-1
@@ -274,11 +274,22 @@ gdk_x11_cursor_create_for_name (GdkDisplay *display,
|
||||
* will have to be handled by the application (GTK applications can learn
|
||||
* about cursor theme changes by listening for change notification
|
||||
* for the corresponding `GtkSetting`).
|
||||
*
|
||||
* Deprecated: 4.16: Use the cursor-related properties of
|
||||
* [GtkSettings](../gtk4/class.Settings.html) to set the cursor theme
|
||||
*/
|
||||
void
|
||||
gdk_x11_display_set_cursor_theme (GdkDisplay *display,
|
||||
const char *theme,
|
||||
const int size)
|
||||
{
|
||||
_gdk_x11_display_set_cursor_theme (display, theme, size);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_x11_display_set_cursor_theme (GdkDisplay *display,
|
||||
const char *theme,
|
||||
const int size)
|
||||
{
|
||||
#if defined(HAVE_XCURSOR) && defined(HAVE_XFIXES) && XFIXES_MAJOR >= 2
|
||||
GdkX11Screen *x11_screen;
|
||||
@@ -370,11 +381,33 @@ gdk_x11_display_get_xcursor (GdkDisplay *display,
|
||||
|
||||
if (gdk_cursor_get_name (cursor))
|
||||
xcursor = gdk_x11_cursor_create_for_name (display, gdk_cursor_get_name (cursor));
|
||||
else
|
||||
else if (gdk_cursor_get_texture (cursor))
|
||||
xcursor = gdk_x11_cursor_create_for_texture (display,
|
||||
gdk_cursor_get_texture (cursor),
|
||||
gdk_cursor_get_hotspot_x (cursor),
|
||||
gdk_cursor_get_hotspot_y (cursor));
|
||||
else
|
||||
{
|
||||
int size;
|
||||
GdkTexture *texture;
|
||||
int width, height;
|
||||
int hotspot_x, hotspot_y;
|
||||
|
||||
size = XcursorGetDefaultSize (GDK_DISPLAY_XDISPLAY (display));
|
||||
|
||||
texture = gdk_cursor_get_texture_for_size (cursor, size, 1,
|
||||
&width, &height,
|
||||
&hotspot_x, &hotspot_y);
|
||||
|
||||
if (texture)
|
||||
{
|
||||
xcursor = gdk_x11_cursor_create_for_texture (display,
|
||||
texture,
|
||||
hotspot_x,
|
||||
hotspot_y);
|
||||
g_object_unref (texture);
|
||||
}
|
||||
}
|
||||
|
||||
if (xcursor != None)
|
||||
{
|
||||
|
||||
@@ -3078,7 +3078,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
display_class->get_monitors = gdk_x11_display_get_monitors;
|
||||
display_class->get_setting = gdk_x11_display_get_setting;
|
||||
display_class->set_cursor_theme = gdk_x11_display_set_cursor_theme;
|
||||
display_class->set_cursor_theme = _gdk_x11_display_set_cursor_theme;
|
||||
|
||||
class->xevent = gdk_event_source_xevent;
|
||||
|
||||
|
||||
@@ -206,6 +206,10 @@ GdkFilterReturn
|
||||
gdk_surface_cache_shape_filter (const XEvent *xevent,
|
||||
gpointer data);
|
||||
|
||||
void _gdk_x11_display_set_cursor_theme (GdkDisplay *display,
|
||||
const char *theme,
|
||||
const int size);
|
||||
|
||||
void _gdk_x11_cursor_display_finalize (GdkDisplay *display);
|
||||
|
||||
void _gdk_x11_surface_register_dnd (GdkSurface *window);
|
||||
|
||||
@@ -88,7 +88,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gdk_x11_display_set_program_class (GdkDisplay *display,
|
||||
const char *program_class);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_16
|
||||
void gdk_x11_display_set_cursor_theme (GdkDisplay *display,
|
||||
const char *theme,
|
||||
const int size);
|
||||
|
||||
@@ -4013,7 +4013,7 @@ gsk_gl_render_job_visit_subsurface_node (GskGLRenderJob *job,
|
||||
/* Clear the area so we can see through */
|
||||
GskGLCommandBatch *batch;
|
||||
guint16 color[4];
|
||||
rgba_to_half (&(GdkRGBA){0,0,0,0}, color);
|
||||
rgba_to_half (&GDK_RGBA_TRANSPARENT, color);
|
||||
|
||||
batch = gsk_gl_command_queue_get_batch (job->command_queue);
|
||||
batch->draw.blend = 0;
|
||||
|
||||
@@ -19,7 +19,7 @@ static gint64 profiler_buffer_uploads;
|
||||
static void
|
||||
gsk_gpu_buffer_class_init (GskGpuBufferClass *klass)
|
||||
{
|
||||
profiler_buffer_uploads_id = gdk_profiler_define_int_counter ("ngl-buffer-uploads", "Number of bytes uploaded to GPU");
|
||||
profiler_buffer_uploads_id = gdk_profiler_define_int_counter ("buffer-uploads", "Number of bytes uploaded to GPU");
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+11
-2
@@ -546,7 +546,7 @@ gsk_gpu_device_maybe_gc (GskGpuDevice *self)
|
||||
|
||||
if (priv->cache_timeout == 0 || dead_texture_pixels > 1000000)
|
||||
{
|
||||
GSK_DEBUG (GLYPH_CACHE, "Pre-frame GC (%lu dead pixels)", dead_texture_pixels);
|
||||
GSK_DEBUG (GLYPH_CACHE, "Pre-frame GC (%" G_GSIZE_FORMAT " dead pixels)", dead_texture_pixels);
|
||||
gsk_gpu_device_gc (self, g_get_monotonic_time ());
|
||||
}
|
||||
}
|
||||
@@ -907,6 +907,7 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self,
|
||||
gsize atlas_x, atlas_y, padding;
|
||||
float subpixel_x, subpixel_y;
|
||||
PangoFont *scaled_font;
|
||||
cairo_hint_metrics_t hint_metrics;
|
||||
|
||||
cache = g_hash_table_lookup (priv->glyph_cache, &lookup);
|
||||
if (cache)
|
||||
@@ -918,7 +919,15 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self,
|
||||
return cache->image;
|
||||
}
|
||||
|
||||
scaled_font = gsk_reload_font (font, scale, CAIRO_HINT_METRICS_DEFAULT, CAIRO_HINT_STYLE_DEFAULT, CAIRO_ANTIALIAS_DEFAULT);
|
||||
/* The combination of hint-style != none and hint-metrics == off
|
||||
* leads to broken rendering with some fonts.
|
||||
*/
|
||||
if (gsk_font_get_hint_style (font) != CAIRO_HINT_STYLE_NONE)
|
||||
hint_metrics = CAIRO_HINT_METRICS_ON;
|
||||
else
|
||||
hint_metrics = CAIRO_HINT_METRICS_DEFAULT;
|
||||
|
||||
scaled_font = gsk_reload_font (font, scale, hint_metrics, CAIRO_HINT_STYLE_DEFAULT, CAIRO_ANTIALIAS_DEFAULT);
|
||||
|
||||
subpixel_x = (flags & 3) / 4.f;
|
||||
subpixel_y = ((flags >> 2) & 3) / 4.f;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "gdk/gdkdisplayprivate.h"
|
||||
#include "gdk/gdkvulkancontextprivate.h"
|
||||
#include "gdk/gdkprofilerprivate.h"
|
||||
|
||||
struct _GskVulkanDevice
|
||||
{
|
||||
@@ -949,6 +950,9 @@ gsk_vulkan_device_get_vk_pipeline (GskVulkanDevice *self,
|
||||
GdkDisplay *display;
|
||||
const char *version_string;
|
||||
char *vertex_shader_name, *fragment_shader_name;
|
||||
G_GNUC_UNUSED gint64 begin_time = GDK_PROFILER_CURRENT_TIME;
|
||||
const char *clip_name[] = { "NONE", "RECT", "ROUNDED" };
|
||||
const char *blend_name[] = { "OVER", "ADD", "CLEAR" };
|
||||
|
||||
cache_key = (PipelineCacheKey) {
|
||||
.op_class = op_class,
|
||||
@@ -1125,6 +1129,27 @@ gsk_vulkan_device_get_vk_pipeline (GskVulkanDevice *self,
|
||||
NULL,
|
||||
&pipeline);
|
||||
|
||||
gdk_profiler_end_markf (begin_time,
|
||||
"Create Vulkan pipeline", "%s version=%s variation=%u clip=%s blend=%s format=%u",
|
||||
op_class->shader_name,
|
||||
version_string + 1,
|
||||
variation,
|
||||
clip_name[clip],
|
||||
blend_name[blend],
|
||||
format);
|
||||
|
||||
GSK_DEBUG (SHADERS,
|
||||
"Create Vulkan pipeline (%s %s, %u/%s/%s/%u) for layout (%" G_GSIZE_FORMAT "/%" G_GSIZE_FORMAT "/%" G_GSIZE_FORMAT ")",
|
||||
op_class->shader_name,
|
||||
version_string + 1,
|
||||
variation,
|
||||
clip_name[clip],
|
||||
blend_name[blend],
|
||||
format,
|
||||
layout->setup.n_buffers,
|
||||
layout->setup.n_samplers,
|
||||
layout->setup.n_immutable_samplers);
|
||||
|
||||
g_free (fragment_shader_name);
|
||||
g_free (vertex_shader_name);
|
||||
|
||||
|
||||
+141
-65
@@ -29,6 +29,7 @@
|
||||
#include "gskdebugprivate.h"
|
||||
#include "gskrendernodeprivate.h"
|
||||
#include "gdksurfaceprivate.h"
|
||||
#include "gdkrgbaprivate.h"
|
||||
|
||||
#include <graphene.h>
|
||||
|
||||
@@ -55,34 +56,91 @@ struct _GskOffload
|
||||
GskOffloadInfo *last_info;
|
||||
};
|
||||
|
||||
static GdkTexture *
|
||||
find_texture_to_attach (GskOffload *self,
|
||||
GdkSubsurface *subsurface,
|
||||
const GskRenderNode *node,
|
||||
graphene_rect_t *out_clip)
|
||||
static GdkTextureTransform
|
||||
find_texture_transform (GskTransform *transform)
|
||||
{
|
||||
float sx, sy, dx, dy;
|
||||
|
||||
g_assert (gsk_transform_get_category (transform) >= GSK_TRANSFORM_CATEGORY_2D_AFFINE);
|
||||
|
||||
gsk_transform_to_affine (transform, &sx, &sy, &dx, &dy);
|
||||
|
||||
if (sx > 0)
|
||||
{
|
||||
if (sy > 0)
|
||||
return GDK_TEXTURE_TRANSFORM_NORMAL;
|
||||
else
|
||||
return GDK_TEXTURE_TRANSFORM_FLIPPED_180;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sy > 0)
|
||||
return GDK_TEXTURE_TRANSFORM_FLIPPED;
|
||||
else
|
||||
return GDK_TEXTURE_TRANSFORM_180;
|
||||
}
|
||||
}
|
||||
|
||||
static GdkTexture *
|
||||
find_texture_to_attach (GskOffload *self,
|
||||
const GskRenderNode *subsurface_node,
|
||||
graphene_rect_t *out_texture_rect,
|
||||
graphene_rect_t *out_source_rect,
|
||||
gboolean *has_background,
|
||||
GdkTextureTransform *out_texture_transform)
|
||||
{
|
||||
GdkSubsurface *subsurface;
|
||||
const GskRenderNode *node;
|
||||
gboolean has_clip = FALSE;
|
||||
graphene_rect_t clip;
|
||||
GskTransform *transform = NULL;
|
||||
GdkTexture *ret = NULL;
|
||||
|
||||
*has_background = FALSE;
|
||||
*out_texture_transform = GDK_TEXTURE_TRANSFORM_NORMAL;
|
||||
|
||||
subsurface = gsk_subsurface_node_get_subsurface (subsurface_node);
|
||||
node = subsurface_node;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
switch ((int)GSK_RENDER_NODE_TYPE (node))
|
||||
switch ((int) GSK_RENDER_NODE_TYPE (node))
|
||||
{
|
||||
case GSK_DEBUG_NODE:
|
||||
node = gsk_debug_node_get_child (node);
|
||||
break;
|
||||
|
||||
case GSK_CONTAINER_NODE:
|
||||
if (gsk_container_node_get_n_children (node) != 1)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
||||
"Can't offload subsurface %p: too much content, container with %d children",
|
||||
subsurface, gsk_container_node_get_n_children (node));
|
||||
return NULL;
|
||||
}
|
||||
node = gsk_container_node_get_child (node, 0);
|
||||
case GSK_SUBSURFACE_NODE:
|
||||
node = gsk_subsurface_node_get_child (node);
|
||||
break;
|
||||
|
||||
case GSK_CONTAINER_NODE:
|
||||
if (gsk_container_node_get_n_children (node) == 1)
|
||||
{
|
||||
node = gsk_container_node_get_child (node, 0);
|
||||
break;
|
||||
}
|
||||
else if (gsk_container_node_get_n_children (node) == 2)
|
||||
{
|
||||
GskRenderNode *child = gsk_container_node_get_child (node, 0);
|
||||
graphene_rect_t bounds;
|
||||
|
||||
gsk_transform_transform_bounds (transform, &child->bounds, &bounds);
|
||||
if (GSK_RENDER_NODE_TYPE (child) == GSK_COLOR_NODE &&
|
||||
gsk_rect_equal (&bounds, &subsurface_node->bounds) &&
|
||||
gdk_rgba_equal (gsk_color_node_get_color (child), &GDK_RGBA_BLACK))
|
||||
{
|
||||
*has_background = TRUE;
|
||||
node = gsk_container_node_get_child (node, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
||||
"[%p] 🗙 Too much content, container with %d children",
|
||||
subsurface, gsk_container_node_get_n_children (node));
|
||||
goto out;
|
||||
|
||||
case GSK_TRANSFORM_NODE:
|
||||
{
|
||||
GskTransform *t = gsk_transform_node_get_transform (node);
|
||||
@@ -91,10 +149,10 @@ find_texture_to_attach (GskOffload *self,
|
||||
{
|
||||
char *s = gsk_transform_to_string (t);
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
||||
"Can't offload subsurface %p: transform %s is not just scale/translate",
|
||||
"[%p] 🗙 Transform %s is not just scale/translate",
|
||||
subsurface, s);
|
||||
g_free (s);
|
||||
return NULL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (has_clip)
|
||||
@@ -104,6 +162,8 @@ find_texture_to_attach (GskOffload *self,
|
||||
gsk_transform_unref (inv);
|
||||
}
|
||||
|
||||
transform = gsk_transform_transform (transform, gsk_transform_ref (t));
|
||||
|
||||
node = gsk_transform_node_get_child (node);
|
||||
}
|
||||
break;
|
||||
@@ -117,12 +177,13 @@ find_texture_to_attach (GskOffload *self,
|
||||
if (!gsk_rect_intersection (c, &clip, &clip))
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
||||
"Can't offload subsurface %p: empty clip", subsurface);
|
||||
return NULL;
|
||||
"[%p] 🗙 Empty clip", subsurface);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gsk_transform_transform_bounds (transform, &node->bounds, out_texture_rect);
|
||||
clip = *c;
|
||||
has_clip = TRUE;
|
||||
}
|
||||
@@ -135,6 +196,8 @@ find_texture_to_attach (GskOffload *self,
|
||||
{
|
||||
GdkTexture *texture = gsk_texture_node_get_texture (node);
|
||||
|
||||
*out_texture_transform = find_texture_transform (transform);
|
||||
|
||||
if (has_clip)
|
||||
{
|
||||
float dx = node->bounds.origin.x;
|
||||
@@ -144,29 +207,36 @@ find_texture_to_attach (GskOffload *self,
|
||||
|
||||
gsk_rect_intersection (&node->bounds, &clip, &clip);
|
||||
|
||||
out_clip->origin.x = (clip.origin.x - dx) * sx;
|
||||
out_clip->origin.y = (clip.origin.y - dy) * sy;
|
||||
out_clip->size.width = clip.size.width * sx;
|
||||
out_clip->size.height = clip.size.height * sy;
|
||||
out_source_rect->origin.x = (clip.origin.x - dx) * sx;
|
||||
out_source_rect->origin.y = (clip.origin.y - dy) * sy;
|
||||
out_source_rect->size.width = clip.size.width * sx;
|
||||
out_source_rect->size.height = clip.size.height * sy;
|
||||
}
|
||||
else
|
||||
{
|
||||
out_clip->origin.x = 0;
|
||||
out_clip->origin.y = 0;
|
||||
out_clip->size.width = gdk_texture_get_width (texture);
|
||||
out_clip->size.height = gdk_texture_get_height (texture);
|
||||
gsk_transform_transform_bounds (transform, &node->bounds, out_texture_rect);
|
||||
out_source_rect->origin.x = 0;
|
||||
out_source_rect->origin.y = 0;
|
||||
out_source_rect->size.width = gdk_texture_get_width (texture);
|
||||
out_source_rect->size.height = gdk_texture_get_height (texture);
|
||||
}
|
||||
|
||||
return texture;
|
||||
ret = texture;
|
||||
goto out;
|
||||
}
|
||||
|
||||
default:
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
||||
"Can't offload subsurface %p: Only textures supported but found %s",
|
||||
"[%p] 🗙 Only textures supported (found %s)",
|
||||
subsurface, g_type_name_from_instance ((GTypeInstance *) node));
|
||||
return NULL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
g_clear_pointer (&transform, gsk_transform_unref);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -406,7 +476,8 @@ visit_node (GskOffload *self,
|
||||
|
||||
if (info->can_raise)
|
||||
{
|
||||
if (gsk_rect_intersects (&transformed_bounds, &info->dest))
|
||||
if (gsk_rect_intersects (&transformed_bounds, &info->texture_rect) ||
|
||||
gsk_rect_intersects (&transformed_bounds, &info->background_rect))
|
||||
{
|
||||
GskRenderNodeType type = GSK_RENDER_NODE_TYPE (node);
|
||||
|
||||
@@ -417,7 +488,7 @@ visit_node (GskOffload *self,
|
||||
type != GSK_DEBUG_NODE)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
||||
"Can't raise subsurface %p because a %s overlaps",
|
||||
"[%p] Lowering because a %s overlaps",
|
||||
info->subsurface,
|
||||
g_type_name_from_instance ((GTypeInstance *) node));
|
||||
info->can_raise = FALSE;
|
||||
@@ -431,7 +502,6 @@ visit_node (GskOffload *self,
|
||||
switch (GSK_RENDER_NODE_TYPE (node))
|
||||
{
|
||||
case GSK_BORDER_NODE:
|
||||
case GSK_COLOR_NODE:
|
||||
case GSK_CONIC_GRADIENT_NODE:
|
||||
case GSK_LINEAR_GRADIENT_NODE:
|
||||
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
||||
@@ -441,6 +511,7 @@ visit_node (GskOffload *self,
|
||||
case GSK_TEXTURE_NODE:
|
||||
case GSK_TEXTURE_SCALE_NODE:
|
||||
case GSK_CAIRO_NODE:
|
||||
case GSK_COLOR_NODE:
|
||||
case GSK_INSET_SHADOW_NODE:
|
||||
case GSK_OUTSET_SHADOW_NODE:
|
||||
case GSK_GL_SHADER_NODE:
|
||||
@@ -454,7 +525,7 @@ visit_node (GskOffload *self,
|
||||
case GSK_MASK_NODE:
|
||||
case GSK_FILL_NODE:
|
||||
case GSK_STROKE_NODE:
|
||||
break;
|
||||
break;
|
||||
|
||||
case GSK_CLIP_NODE:
|
||||
{
|
||||
@@ -551,39 +622,42 @@ complex_clip:
|
||||
case GSK_SUBSURFACE_NODE:
|
||||
{
|
||||
GdkSubsurface *subsurface = gsk_subsurface_node_get_subsurface (node);
|
||||
GskTransform *transform;
|
||||
|
||||
GskOffloadInfo *info = find_subsurface_info (self, subsurface);
|
||||
|
||||
transform = self->transforms ? (GskTransform *) self->transforms->data : NULL;
|
||||
|
||||
if (info == NULL)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
||||
"Can't offload: unknown subsurface %p",
|
||||
"[%p] 🗙 Unknown subsurface",
|
||||
subsurface);
|
||||
}
|
||||
else if (!self->current_clip->is_fully_contained)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
||||
"Can't offload subsurface %p: clipped",
|
||||
"[%p] 🗙 Clipped",
|
||||
subsurface);
|
||||
}
|
||||
else if (self->transforms &&
|
||||
gsk_transform_get_category ((GskTransform *)self->transforms->data) < GSK_TRANSFORM_CATEGORY_2D_AFFINE)
|
||||
else if (gsk_transform_get_category (transform) < GSK_TRANSFORM_CATEGORY_2D_AFFINE)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
||||
"Can't offload subsurface %p: non-affine transform",
|
||||
"[%p] 🗙 Non-affine transform",
|
||||
subsurface);
|
||||
}
|
||||
else
|
||||
{
|
||||
graphene_rect_t clip;
|
||||
gboolean has_background;
|
||||
|
||||
info->texture = find_texture_to_attach (self, subsurface, gsk_subsurface_node_get_child (node), &clip);
|
||||
info->texture = find_texture_to_attach (self, node, &info->texture_rect, &info->source_rect, &has_background, &info->transform);
|
||||
if (info->texture)
|
||||
{
|
||||
info->can_offload = TRUE;
|
||||
info->can_raise = TRUE;
|
||||
info->source = clip;
|
||||
transform_bounds (self, &node->bounds, &info->dest);
|
||||
transform_bounds (self, &info->texture_rect, &info->texture_rect);
|
||||
info->has_background = has_background;
|
||||
transform_bounds (self, &node->bounds, &info->background_rect);
|
||||
info->place_above = self->last_info ? self->last_info->subsurface : NULL;
|
||||
self->last_info = info;
|
||||
}
|
||||
@@ -606,7 +680,6 @@ gsk_offload_new (GdkSurface *surface,
|
||||
GskRenderNode *root,
|
||||
cairo_region_t *diff)
|
||||
{
|
||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||
GskOffload *self;
|
||||
|
||||
self = g_new0 (GskOffload, 1);
|
||||
@@ -623,9 +696,12 @@ gsk_offload_new (GdkSurface *surface,
|
||||
for (gsize i = 0; i < self->n_subsurfaces; i++)
|
||||
{
|
||||
GskOffloadInfo *info = &self->subsurfaces[i];
|
||||
graphene_rect_t rect;
|
||||
|
||||
info->subsurface = gdk_surface_get_subsurface (self->surface, i);
|
||||
info->was_offloaded = gdk_subsurface_get_texture (info->subsurface) != NULL;
|
||||
info->was_above = gdk_subsurface_is_above_parent (info->subsurface);
|
||||
info->had_background = gdk_subsurface_get_background_rect (info->subsurface, &rect);
|
||||
}
|
||||
|
||||
if (self->n_subsurfaces > 0)
|
||||
@@ -642,23 +718,28 @@ gsk_offload_new (GdkSurface *surface,
|
||||
for (gsize i = 0; i < self->n_subsurfaces; i++)
|
||||
{
|
||||
GskOffloadInfo *info = &self->subsurfaces[i];
|
||||
graphene_rect_t old_dest;
|
||||
graphene_rect_t old_bounds;
|
||||
graphene_rect_t bounds;
|
||||
|
||||
gdk_subsurface_get_dest (info->subsurface, &old_dest);
|
||||
gdk_subsurface_get_bounds (info->subsurface, &old_bounds);
|
||||
|
||||
if (info->can_offload)
|
||||
{
|
||||
if (info->can_raise)
|
||||
info->is_offloaded = gdk_subsurface_attach (info->subsurface,
|
||||
info->texture,
|
||||
&info->source,
|
||||
&info->dest,
|
||||
&info->source_rect,
|
||||
&info->texture_rect,
|
||||
info->transform,
|
||||
info->has_background ? &info->background_rect : NULL,
|
||||
TRUE, NULL);
|
||||
else
|
||||
info->is_offloaded = gdk_subsurface_attach (info->subsurface,
|
||||
info->texture,
|
||||
&info->source,
|
||||
&info->dest,
|
||||
&info->source_rect,
|
||||
&info->texture_rect,
|
||||
info->transform,
|
||||
info->has_background ? &info->background_rect : NULL,
|
||||
info->place_above != NULL,
|
||||
info->place_above);
|
||||
}
|
||||
@@ -666,34 +747,29 @@ gsk_offload_new (GdkSurface *surface,
|
||||
{
|
||||
info->is_offloaded = FALSE;
|
||||
if (info->was_offloaded)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (display, OFFLOAD, "Hiding subsurface %p", info->subsurface);
|
||||
gdk_subsurface_detach (info->subsurface);
|
||||
}
|
||||
gdk_subsurface_detach (info->subsurface);
|
||||
}
|
||||
|
||||
if (info->is_offloaded && gdk_subsurface_is_above_parent (info->subsurface))
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (display, OFFLOAD, "Raising subsurface %p", info->subsurface);
|
||||
info->is_above = TRUE;
|
||||
}
|
||||
info->is_above = info->is_offloaded && gdk_subsurface_is_above_parent (info->subsurface);
|
||||
|
||||
gdk_subsurface_get_bounds (info->subsurface, &bounds);
|
||||
|
||||
if (info->is_offloaded != info->was_offloaded ||
|
||||
info->is_above != info->was_above ||
|
||||
(info->is_offloaded && !gsk_rect_equal (&info->dest, &old_dest)))
|
||||
(info->is_offloaded && !gsk_rect_equal (&bounds, &old_bounds)))
|
||||
{
|
||||
/* We changed things, need to invalidate everything */
|
||||
cairo_rectangle_int_t int_dest;
|
||||
cairo_rectangle_int_t rect;
|
||||
|
||||
if (info->is_offloaded)
|
||||
{
|
||||
gsk_rect_to_cairo_grow (&info->dest, &int_dest);
|
||||
cairo_region_union_rectangle (diff, &int_dest);
|
||||
gsk_rect_to_cairo_grow (&bounds, &rect);
|
||||
cairo_region_union_rectangle (diff, &rect);
|
||||
}
|
||||
if (info->was_offloaded)
|
||||
{
|
||||
gsk_rect_to_cairo_grow (&old_dest, &int_dest);
|
||||
cairo_region_union_rectangle (diff, &int_dest);
|
||||
gsk_rect_to_cairo_grow (&old_bounds, &rect);
|
||||
cairo_region_union_rectangle (diff, &rect);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,10 @@ typedef struct
|
||||
GdkSubsurface *subsurface;
|
||||
GdkTexture *texture;
|
||||
GdkSubsurface *place_above;
|
||||
graphene_rect_t dest;
|
||||
graphene_rect_t source;
|
||||
graphene_rect_t texture_rect;
|
||||
graphene_rect_t source_rect;
|
||||
GdkTextureTransform transform;
|
||||
graphene_rect_t background_rect;
|
||||
|
||||
guint was_offloaded : 1;
|
||||
guint can_offload : 1;
|
||||
@@ -41,6 +43,9 @@ typedef struct
|
||||
guint was_above : 1;
|
||||
guint can_raise : 1;
|
||||
guint is_above : 1;
|
||||
|
||||
guint had_background : 1;
|
||||
guint has_background : 1;
|
||||
} GskOffloadInfo;
|
||||
|
||||
GskOffload * gsk_offload_new (GdkSurface *surface,
|
||||
|
||||
+10
-35
@@ -48,15 +48,9 @@ gsk_reload_font (PangoFont *font,
|
||||
cairo_hint_style_t hint_style,
|
||||
cairo_antialias_t antialias)
|
||||
{
|
||||
cairo_font_options_t *options;
|
||||
cairo_scaled_font_t *sf;
|
||||
static cairo_font_options_t *options = NULL;
|
||||
static PangoContext *context = NULL;
|
||||
#if !PANGO_VERSION_CHECK (1, 52, 0)
|
||||
PangoFontDescription *desc;
|
||||
FcPattern *pattern;
|
||||
double dpi;
|
||||
int size;
|
||||
#endif
|
||||
cairo_scaled_font_t *sf;
|
||||
|
||||
/* These requests often come in sequentially so keep the result
|
||||
* around and re-use it if everything matches.
|
||||
@@ -84,7 +78,9 @@ gsk_reload_font (PangoFont *font,
|
||||
g_set_object (&last_font, font);
|
||||
g_clear_object (&last_result);
|
||||
|
||||
options = cairo_font_options_create ();
|
||||
if (G_UNLIKELY (options == NULL))
|
||||
options = cairo_font_options_create ();
|
||||
|
||||
sf = pango_cairo_font_get_scaled_font (PANGO_CAIRO_FONT (font));
|
||||
cairo_scaled_font_get_font_options (sf, options);
|
||||
|
||||
@@ -104,7 +100,6 @@ gsk_reload_font (PangoFont *font,
|
||||
cairo_font_options_get_subpixel_order (options) == CAIRO_SUBPIXEL_ORDER_DEFAULT)
|
||||
{
|
||||
last_result = g_object_ref (font);
|
||||
cairo_font_options_destroy (options);
|
||||
return g_object_ref (font);
|
||||
}
|
||||
|
||||
@@ -113,33 +108,12 @@ gsk_reload_font (PangoFont *font,
|
||||
cairo_font_options_set_antialias (options, antialias);
|
||||
cairo_font_options_set_subpixel_order (options, CAIRO_SUBPIXEL_ORDER_DEFAULT);
|
||||
|
||||
if (!context)
|
||||
if (G_UNLIKELY (context == NULL))
|
||||
context = pango_context_new ();
|
||||
|
||||
pango_cairo_context_set_font_options (context, options);
|
||||
cairo_font_options_destroy (options);
|
||||
|
||||
#if PANGO_VERSION_CHECK (1, 52, 0)
|
||||
last_result = pango_font_map_reload_font (pango_font_get_font_map (font), font, scale, context, NULL);
|
||||
#else
|
||||
|
||||
#ifdef HAVE_PANGOFT
|
||||
pattern = pango_fc_font_get_pattern (PANGO_FC_FONT (font));
|
||||
if (FcPatternGetDouble (pattern, FC_DPI, 0, &dpi) == FcResultMatch)
|
||||
pango_cairo_context_set_resolution (context, dpi);
|
||||
#endif
|
||||
|
||||
desc = pango_font_describe (font);
|
||||
size = pango_font_description_get_size (desc);
|
||||
|
||||
if (pango_font_description_get_size_is_absolute (desc))
|
||||
pango_font_description_set_absolute_size (desc, size * scale);
|
||||
else
|
||||
pango_font_description_set_size (desc, (int) floor (size * scale + .5));
|
||||
|
||||
last_result = pango_font_map_load_font (pango_font_get_font_map (font), context, desc);
|
||||
pango_font_description_free (desc);
|
||||
#endif
|
||||
|
||||
return g_object_ref (last_result);
|
||||
}
|
||||
@@ -155,15 +129,16 @@ gsk_reload_font (PangoFont *font,
|
||||
cairo_hint_style_t
|
||||
gsk_font_get_hint_style (PangoFont *font)
|
||||
{
|
||||
static cairo_font_options_t *options = NULL;
|
||||
cairo_scaled_font_t *sf;
|
||||
cairo_font_options_t *options;
|
||||
cairo_hint_style_t style;
|
||||
|
||||
if (G_UNLIKELY (options == NULL))
|
||||
options = cairo_font_options_create ();
|
||||
|
||||
sf = pango_cairo_font_get_scaled_font (PANGO_CAIRO_FONT (font));
|
||||
options = cairo_font_options_create ();
|
||||
cairo_scaled_font_get_font_options (sf, options);
|
||||
style = cairo_font_options_get_hint_style (options);
|
||||
cairo_font_options_destroy (options);
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
+90
-57
@@ -1,5 +1,4 @@
|
||||
/* GSK - The GTK Scene Kit
|
||||
*
|
||||
* Copyright 2016 Endless
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@@ -429,21 +428,6 @@ gsk_renderer_render_texture (GskRenderer *renderer,
|
||||
|
||||
texture = GSK_RENDERER_GET_CLASS (renderer)->render_texture (renderer, root, viewport);
|
||||
|
||||
if (GSK_RENDERER_DEBUG_CHECK (renderer, RENDERER))
|
||||
{
|
||||
GString *buf = g_string_new ("*** Texture stats ***\n\n");
|
||||
|
||||
gsk_profiler_append_counters (priv->profiler, buf);
|
||||
g_string_append_c (buf, '\n');
|
||||
|
||||
gsk_profiler_append_timers (priv->profiler, buf);
|
||||
g_string_append_c (buf, '\n');
|
||||
|
||||
g_print ("%s\n***\n\n", buf->str);
|
||||
|
||||
g_string_free (buf, TRUE);
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
@@ -510,21 +494,6 @@ gsk_renderer_render (GskRenderer *renderer,
|
||||
|
||||
renderer_class->render (renderer, root, clip);
|
||||
|
||||
if (GSK_RENDERER_DEBUG_CHECK (renderer, RENDERER))
|
||||
{
|
||||
GString *buf = g_string_new ("*** Frame stats ***\n\n");
|
||||
|
||||
gsk_profiler_append_counters (priv->profiler, buf);
|
||||
g_string_append_c (buf, '\n');
|
||||
|
||||
gsk_profiler_append_timers (priv->profiler, buf);
|
||||
g_string_append_c (buf, '\n');
|
||||
|
||||
g_print ("%s\n***\n\n", buf->str);
|
||||
|
||||
g_string_free (buf, TRUE);
|
||||
}
|
||||
|
||||
g_clear_pointer (&priv->prev_node, gsk_render_node_unref);
|
||||
cairo_region_destroy (clip);
|
||||
g_clear_pointer (&offload, gsk_offload_free);
|
||||
@@ -610,12 +579,17 @@ get_renderer_for_display (GdkSurface *surface)
|
||||
static GType
|
||||
get_renderer_for_env_var (GdkSurface *surface)
|
||||
{
|
||||
static GType env_var_type = G_TYPE_NONE;
|
||||
static GType env_var_type = G_TYPE_INVALID;
|
||||
|
||||
if (env_var_type == G_TYPE_NONE)
|
||||
if (env_var_type == G_TYPE_INVALID)
|
||||
{
|
||||
const char *renderer_name = g_getenv ("GSK_RENDERER");
|
||||
env_var_type = get_renderer_for_name (renderer_name);
|
||||
if (env_var_type != G_TYPE_INVALID)
|
||||
GSK_DEBUG (RENDERER,
|
||||
"Environment variable GSK_RENDERER=%s set, trying %s",
|
||||
renderer_name,
|
||||
g_type_name (env_var_type));
|
||||
}
|
||||
|
||||
return env_var_type;
|
||||
@@ -633,63 +607,115 @@ get_renderer_for_backend (GdkSurface *surface)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gl_software_rendering (GdkSurface *surface)
|
||||
gl_supported_platform (GdkSurface *surface,
|
||||
GType renderer_type,
|
||||
gboolean as_fallback)
|
||||
{
|
||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||
GdkGLContext *context;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!gdk_display_prepare_gl (display, NULL))
|
||||
return G_TYPE_INVALID;
|
||||
if (!gdk_display_prepare_gl (display, &error))
|
||||
{
|
||||
if (!as_fallback)
|
||||
GSK_DEBUG (RENDERER, "Not using GL: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (as_fallback)
|
||||
return TRUE;
|
||||
|
||||
context = gdk_display_get_gl_context (display);
|
||||
gdk_gl_context_make_current (context);
|
||||
|
||||
return strstr ((const char *) glGetString (GL_RENDERER), "llvmpipe") != NULL;
|
||||
if (strstr ((const char *) glGetString (GL_RENDERER), "llvmpipe") != NULL)
|
||||
{
|
||||
GSK_DEBUG (RENDERER, "Not using '%s': renderer is llvmpipe", g_type_name (renderer_type));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GType
|
||||
get_renderer_for_gl (GdkSurface *surface)
|
||||
{
|
||||
if (gl_software_rendering (surface))
|
||||
if (!gl_supported_platform (surface, gsk_ngl_renderer_get_type (), FALSE))
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
return gsk_ngl_renderer_get_type ();
|
||||
}
|
||||
|
||||
static GType
|
||||
get_renderer_for_gl_fallback (GdkSurface *surface)
|
||||
{
|
||||
if (!gl_supported_platform (surface, GSK_TYPE_GL_RENDERER, TRUE))
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
return GSK_TYPE_GL_RENDERER;
|
||||
}
|
||||
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
static gboolean
|
||||
vulkan_software_rendering (GdkSurface *surface)
|
||||
vulkan_supported_platform (GdkSurface *surface,
|
||||
GType renderer_type,
|
||||
gboolean as_fallback)
|
||||
{
|
||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||
VkPhysicalDeviceProperties props;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!gdk_display_init_vulkan (display, NULL))
|
||||
return G_TYPE_INVALID;
|
||||
if (!gdk_display_init_vulkan (display, &error))
|
||||
{
|
||||
if (!as_fallback)
|
||||
GSK_DEBUG (RENDERER, "Not using Vulkan: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
vkGetPhysicalDeviceProperties (display->vk_physical_device, &props);
|
||||
|
||||
return props.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU;
|
||||
}
|
||||
if (props.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU)
|
||||
{
|
||||
if (!as_fallback)
|
||||
GSK_DEBUG (RENDERER,
|
||||
"Not using '%s': device is CPU",
|
||||
g_type_name (renderer_type));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (as_fallback)
|
||||
return TRUE;
|
||||
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
if (GDK_IS_WAYLAND_DISPLAY (gdk_surface_get_display (surface)))
|
||||
return TRUE;
|
||||
#endif
|
||||
|
||||
GSK_DEBUG (RENDERER, "Not using '%s': platform is not Wayland", g_type_name (renderer_type));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GType
|
||||
get_renderer_for_vulkan (GdkSurface *surface)
|
||||
{
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
if (vulkan_software_rendering (surface))
|
||||
if (!vulkan_supported_platform (surface, GSK_TYPE_VULKAN_RENDERER, FALSE))
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
return GSK_TYPE_VULKAN_RENDERER;
|
||||
#else
|
||||
return G_TYPE_INVALID;
|
||||
#endif
|
||||
}
|
||||
|
||||
static GType
|
||||
get_renderer_for_gles2 (GdkSurface *surface)
|
||||
get_renderer_for_vulkan_fallback (GdkSurface *surface)
|
||||
{
|
||||
return GSK_TYPE_GL_RENDERER;
|
||||
if (!vulkan_supported_platform (surface, GSK_TYPE_VULKAN_RENDERER, TRUE))
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
return GSK_TYPE_VULKAN_RENDERER;
|
||||
}
|
||||
#endif
|
||||
|
||||
static GType
|
||||
get_renderer_fallback (GdkSurface *surface)
|
||||
@@ -703,9 +729,14 @@ static struct {
|
||||
{ get_renderer_for_display },
|
||||
{ get_renderer_for_env_var },
|
||||
{ get_renderer_for_backend },
|
||||
{ get_renderer_for_gl },
|
||||
{ get_renderer_for_gles2 },
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
{ get_renderer_for_vulkan },
|
||||
#endif
|
||||
{ get_renderer_for_gl },
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
{ get_renderer_for_vulkan_fallback },
|
||||
#endif
|
||||
{ get_renderer_for_gl_fallback },
|
||||
{ get_renderer_fallback },
|
||||
};
|
||||
|
||||
@@ -743,17 +774,19 @@ gsk_renderer_new_for_surface (GdkSurface *surface)
|
||||
|
||||
if (gsk_renderer_realize (renderer, surface, &error))
|
||||
{
|
||||
GSK_RENDERER_DEBUG (renderer, RENDERER,
|
||||
"Using renderer of type '%s' for surface '%s'",
|
||||
G_OBJECT_TYPE_NAME (renderer),
|
||||
G_OBJECT_TYPE_NAME (surface));
|
||||
GSK_DEBUG (RENDERER,
|
||||
"Using renderer '%s' for surface '%s'",
|
||||
G_OBJECT_TYPE_NAME (renderer),
|
||||
G_OBJECT_TYPE_NAME (surface));
|
||||
return renderer;
|
||||
}
|
||||
|
||||
g_message ("Failed to realize renderer of type '%s' for surface '%s': %s\n",
|
||||
GSK_DEBUG (RENDERER,
|
||||
"Failed to realize renderer '%s' for surface '%s': %s",
|
||||
G_OBJECT_TYPE_NAME (renderer),
|
||||
G_OBJECT_TYPE_NAME (surface),
|
||||
error->message);
|
||||
|
||||
g_object_unref (renderer);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "gdk/gdksubsurfaceprivate.h"
|
||||
#include "gdk/gdktextureprivate.h"
|
||||
#include "gdk/gdktexturedownloaderprivate.h"
|
||||
#include "gdk/gdkrgbaprivate.h"
|
||||
|
||||
#include <cairo.h>
|
||||
#ifdef CAIRO_HAS_SVG_SURFACE
|
||||
|
||||
+36
-11
@@ -962,16 +962,12 @@ create_ascii_glyphs (PangoFont *font)
|
||||
for (i = MIN_ASCII_GLYPH; i < MAX_ASCII_GLYPH; i++)
|
||||
{
|
||||
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,
|
||||
¬_a_hack,
|
||||
glyph_string,
|
||||
flags);
|
||||
PANGO_SHAPE_NONE);
|
||||
|
||||
if (glyph_string->num_glyphs != 1)
|
||||
{
|
||||
@@ -2316,6 +2312,25 @@ parse_antialias (GtkCssParser *parser,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_hint_metrics (GtkCssParser *parser,
|
||||
Context *context,
|
||||
gpointer out)
|
||||
{
|
||||
if (!parse_enum (parser, CAIRO_GOBJECT_TYPE_HINT_METRICS, out))
|
||||
return FALSE;
|
||||
|
||||
if (*(cairo_hint_metrics_t *) out != CAIRO_HINT_METRICS_OFF &&
|
||||
*(cairo_hint_metrics_t *) out != CAIRO_HINT_METRICS_ON)
|
||||
{
|
||||
gtk_css_parser_error_value (parser, "Unsupported value for enum \"%s\"",
|
||||
g_type_name (CAIRO_GOBJECT_TYPE_HINT_METRICS));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
parse_text_node (GtkCssParser *parser,
|
||||
Context *context)
|
||||
@@ -2326,6 +2341,7 @@ parse_text_node (GtkCssParser *parser,
|
||||
PangoGlyphString *glyphs = NULL;
|
||||
cairo_hint_style_t hint_style = CAIRO_HINT_STYLE_SLIGHT;
|
||||
cairo_antialias_t antialias = CAIRO_ANTIALIAS_GRAY;
|
||||
cairo_hint_metrics_t hint_metrics = CAIRO_HINT_METRICS_OFF;
|
||||
PangoFont *hinted;
|
||||
const Declaration declarations[] = {
|
||||
{ "font", parse_font, clear_font, &font },
|
||||
@@ -2334,6 +2350,7 @@ parse_text_node (GtkCssParser *parser,
|
||||
{ "glyphs", parse_glyphs, clear_glyphs, &glyphs },
|
||||
{ "hint-style", parse_hint_style, NULL, &hint_style },
|
||||
{ "antialias", parse_antialias, NULL, &antialias },
|
||||
{ "hint-metrics", parse_hint_metrics, NULL, &hint_metrics },
|
||||
};
|
||||
GskRenderNode *result;
|
||||
|
||||
@@ -2345,7 +2362,7 @@ parse_text_node (GtkCssParser *parser,
|
||||
g_assert (font);
|
||||
}
|
||||
|
||||
hinted = gsk_reload_font (font, 1.0, CAIRO_HINT_METRICS_OFF, hint_style, antialias);
|
||||
hinted = gsk_reload_font (font, 1.0, hint_metrics, hint_style, antialias);
|
||||
g_object_unref (font);
|
||||
font = hinted;
|
||||
|
||||
@@ -3543,13 +3560,13 @@ append_texture_param (Printer *p,
|
||||
case GDK_MEMORY_U8:
|
||||
case GDK_MEMORY_U16:
|
||||
bytes = gdk_texture_save_to_png_bytes (texture);
|
||||
g_string_append (p->str, "url(\"data:image/png;base64,");
|
||||
g_string_append (p->str, "url(\"data:image/png;base64,\\\n");
|
||||
break;
|
||||
|
||||
case GDK_MEMORY_FLOAT16:
|
||||
case GDK_MEMORY_FLOAT32:
|
||||
bytes = gdk_texture_save_to_tiff_bytes (texture);
|
||||
g_string_append (p->str, "url(\"data:image/tiff;base64,");
|
||||
g_string_append (p->str, "url(\"data:image/tiff;base64,\\\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -3608,7 +3625,7 @@ gsk_text_node_serialize_font (GskRenderNode *node,
|
||||
|
||||
b64 = base64_encode_with_linebreaks ((const guchar *) data, len);
|
||||
|
||||
g_string_append (p->str, " url(\"data:font/ttf;base64,");
|
||||
g_string_append (p->str, " url(\"data:font/ttf;base64,\\\n");
|
||||
append_escaping_newlines (p->str, b64);
|
||||
g_string_append (p->str, "\")");
|
||||
|
||||
@@ -3627,11 +3644,13 @@ gsk_text_node_serialize_font_options (GskRenderNode *node,
|
||||
cairo_font_options_t *options;
|
||||
cairo_hint_style_t hint_style;
|
||||
cairo_antialias_t antialias;
|
||||
cairo_hint_metrics_t hint_metrics;
|
||||
|
||||
options = cairo_font_options_create ();
|
||||
cairo_scaled_font_get_font_options (sf, options);
|
||||
hint_style = cairo_font_options_get_hint_style (options);
|
||||
antialias = cairo_font_options_get_antialias (options);
|
||||
hint_metrics = cairo_font_options_get_hint_metrics (options);
|
||||
cairo_font_options_destroy (options);
|
||||
|
||||
/* medium and full are identical in the absence of subpixel modes */
|
||||
@@ -3647,6 +3666,12 @@ gsk_text_node_serialize_font_options (GskRenderNode *node,
|
||||
*/
|
||||
if (antialias == CAIRO_ANTIALIAS_NONE)
|
||||
append_enum_param (p, "antialias", CAIRO_GOBJECT_TYPE_ANTIALIAS, antialias);
|
||||
|
||||
/* CAIRO_HINT_METRICS_ON is the only value we ever emit here, since off is the default,
|
||||
* and we don't accept any other values.
|
||||
*/
|
||||
if (hint_metrics == CAIRO_HINT_METRICS_ON)
|
||||
append_enum_param (p, "hint-metrics", CAIRO_GOBJECT_TYPE_HINT_METRICS, CAIRO_HINT_METRICS_ON);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -4418,7 +4443,7 @@ render_node_print (Printer *p,
|
||||
cairo_surface_write_to_png_stream (surface, cairo_write_array, array);
|
||||
|
||||
_indent (p);
|
||||
g_string_append (p->str, "pixels: url(\"data:image/png;base64,");
|
||||
g_string_append (p->str, "pixels: url(\"data:image/png;base64,\\\n");
|
||||
b64 = base64_encode_with_linebreaks (array->data, array->len);
|
||||
append_escaping_newlines (p->str, b64);
|
||||
g_free (b64);
|
||||
@@ -4438,7 +4463,7 @@ render_node_print (Printer *p,
|
||||
if (cairo_script_from_recording_surface (script, surface) == CAIRO_STATUS_SUCCESS)
|
||||
{
|
||||
_indent (p);
|
||||
g_string_append (p->str, "script: url(\"data:;base64,");
|
||||
g_string_append (p->str, "script: url(\"data:;base64,\\\n");
|
||||
b64 = base64_encode_with_linebreaks (array->data, array->len);
|
||||
append_escaping_newlines (p->str, b64);
|
||||
g_free (b64);
|
||||
|
||||
@@ -48,114 +48,6 @@ find_first_accessible_non_socket (GtkAccessible *accessible)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
translate_coordinates_to_accessible (GtkAccessible *accessible,
|
||||
AtspiCoordType coordtype,
|
||||
int xi,
|
||||
int yi,
|
||||
int *xo,
|
||||
int *yo)
|
||||
{
|
||||
GtkAccessible *parent;
|
||||
int x, y, width, height;
|
||||
|
||||
if (coordtype == ATSPI_COORD_TYPE_SCREEN)
|
||||
{
|
||||
*xo = 0;
|
||||
*yo = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gtk_accessible_get_bounds (accessible, &x, &y, &width, &height))
|
||||
{
|
||||
*xo = xi;
|
||||
*yo = yi;
|
||||
return;
|
||||
}
|
||||
|
||||
// Transform coords to our parent, we will need that in any case
|
||||
*xo = xi - x;
|
||||
*yo = yi - y;
|
||||
|
||||
// If that's what the caller requested, we're done
|
||||
if (coordtype == ATSPI_COORD_TYPE_PARENT)
|
||||
return;
|
||||
|
||||
if (coordtype == ATSPI_COORD_TYPE_WINDOW)
|
||||
{
|
||||
parent = gtk_accessible_get_accessible_parent (accessible);
|
||||
while (parent != NULL)
|
||||
{
|
||||
g_object_unref (parent);
|
||||
|
||||
if (gtk_accessible_get_bounds (parent, &x, &y, &width, &height))
|
||||
{
|
||||
*xo = *xo - x;
|
||||
*yo = *yo - y;
|
||||
parent = gtk_accessible_get_accessible_parent (parent);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
static void
|
||||
translate_coordinates_from_accessible (GtkAccessible *accessible,
|
||||
AtspiCoordType coordtype,
|
||||
int xi,
|
||||
int yi,
|
||||
int *xo,
|
||||
int *yo)
|
||||
{
|
||||
GtkAccessible *parent;
|
||||
int x, y, width, height;
|
||||
|
||||
if (coordtype == ATSPI_COORD_TYPE_SCREEN)
|
||||
{
|
||||
*xo = 0;
|
||||
*yo = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gtk_accessible_get_bounds (accessible, &x, &y, &width, &height))
|
||||
{
|
||||
*xo = xi;
|
||||
*yo = yi;
|
||||
return;
|
||||
}
|
||||
|
||||
// Transform coords to our parent, we will need that in any case
|
||||
*xo = xi + x;
|
||||
*yo = yi + y;
|
||||
|
||||
// If that's what the caller requested, we're done
|
||||
if (coordtype == ATSPI_COORD_TYPE_PARENT)
|
||||
return;
|
||||
|
||||
if (coordtype == ATSPI_COORD_TYPE_WINDOW)
|
||||
{
|
||||
parent = gtk_accessible_get_accessible_parent (accessible);
|
||||
while (parent != NULL)
|
||||
{
|
||||
g_object_unref (parent);
|
||||
|
||||
if (gtk_accessible_get_bounds (parent, &x, &y, &width, &height))
|
||||
{
|
||||
*xo = *xo + x;
|
||||
*yo = *yo + y;
|
||||
parent = gtk_accessible_get_accessible_parent (parent);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
static GtkAccessible *
|
||||
accessible_at_point (GtkAccessible *parent,
|
||||
int x,
|
||||
@@ -209,7 +101,7 @@ component_handle_method (GDBusConnection *connection,
|
||||
|
||||
g_variant_get (parameters, "(iiu)", &x, &y, &coordtype);
|
||||
|
||||
translate_coordinates_to_accessible (accessible, coordtype, x, y, &x, &y);
|
||||
gtk_at_spi_translate_coordinates_to_accessible (accessible, coordtype, x, y, &x, &y);
|
||||
|
||||
if (gtk_accessible_get_bounds (accessible, &bounds_x, &bounds_y, &width, &height))
|
||||
ret = x >= 0 && x <= bounds_x && y >= 0 && y <= bounds_y;
|
||||
@@ -225,8 +117,7 @@ component_handle_method (GDBusConnection *connection,
|
||||
GtkAccessible *child;
|
||||
|
||||
g_variant_get (parameters, "(iiu)", &x, &y, &coordtype);
|
||||
|
||||
translate_coordinates_to_accessible (accessible, coordtype, x, y, &x, &y);
|
||||
gtk_at_spi_translate_coordinates_to_accessible (accessible, coordtype, x, y, &x, &y);
|
||||
|
||||
child = accessible_at_point (accessible, x, y, TRUE);
|
||||
if (!child)
|
||||
@@ -255,7 +146,7 @@ component_handle_method (GDBusConnection *connection,
|
||||
|
||||
g_variant_get (parameters, "(u)", &coordtype);
|
||||
|
||||
translate_coordinates_from_accessible (accessible, coordtype, 0, 0, &x, &y);
|
||||
gtk_at_spi_translate_coordinates_from_accessible (accessible, coordtype, 0, 0, &x, &y);
|
||||
|
||||
g_dbus_method_invocation_return_value (invocation, g_variant_new ("((iiii))", x, y, width, height));
|
||||
}
|
||||
@@ -266,7 +157,7 @@ component_handle_method (GDBusConnection *connection,
|
||||
|
||||
g_variant_get (parameters, "(u)", &coordtype);
|
||||
|
||||
translate_coordinates_from_accessible (accessible, coordtype, 0, 0, &x, &y);
|
||||
gtk_at_spi_translate_coordinates_from_accessible (accessible, coordtype, 0, 0, &x, &y);
|
||||
|
||||
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(ii)", x, y));
|
||||
}
|
||||
|
||||
@@ -720,6 +720,16 @@ handle_accessible_get_property (GDBusConnection *connection,
|
||||
res = get_parent_context_ref (accessible);
|
||||
else if (g_strcmp0 (property_name, "ChildCount") == 0)
|
||||
res = g_variant_new_int32 (gtk_at_spi_context_get_child_count (self));
|
||||
else if (g_strcmp0 (property_name, "HelpText"))
|
||||
{
|
||||
if (gtk_at_context_has_accessible_property (GTK_AT_CONTEXT (self), GTK_ACCESSIBLE_PROPERTY_HELP_TEXT))
|
||||
{
|
||||
GtkAccessibleValue *value = gtk_at_context_get_accessible_property (GTK_AT_CONTEXT (self), GTK_ACCESSIBLE_PROPERTY_HELP_TEXT);
|
||||
res = g_variant_new_string (gtk_string_accessible_value_get (value));
|
||||
}
|
||||
else
|
||||
res = g_variant_new_string ("");
|
||||
}
|
||||
else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"Unknown property '%s'", property_name);
|
||||
@@ -1136,7 +1146,7 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
|
||||
}
|
||||
|
||||
if (changed_properties & GTK_ACCESSIBLE_PROPERTY_CHANGE_DESCRIPTION)
|
||||
{
|
||||
{
|
||||
char *label = gtk_at_context_get_description (GTK_AT_CONTEXT (self));
|
||||
GVariant *v = g_variant_new_take_string (label);
|
||||
emit_property_changed (self, "accessible-description", v);
|
||||
@@ -1149,6 +1159,14 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
|
||||
"accessible-value",
|
||||
g_variant_new_double (gtk_number_accessible_value_get (value)));
|
||||
}
|
||||
|
||||
if (changed_properties & GTK_ACCESSIBLE_PROPERTY_CHANGE_HELP_TEXT)
|
||||
{
|
||||
value = gtk_accessible_attribute_set_get_value (properties, GTK_ACCESSIBLE_PROPERTY_HELP_TEXT);
|
||||
emit_property_changed (self,
|
||||
"accessible-help-text",
|
||||
g_variant_new_string (gtk_string_accessible_value_get (value)));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+115
-1415
File diff suppressed because it is too large
Load Diff
+111
-2
@@ -97,7 +97,7 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
|
||||
return ATSPI_ROLE_FORM;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_GENERIC:
|
||||
return ATSPI_ROLE_FILLER;
|
||||
return ATSPI_ROLE_PANEL;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_GRID:
|
||||
return ATSPI_ROLE_TABLE;
|
||||
@@ -106,7 +106,7 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
|
||||
return ATSPI_ROLE_TABLE_CELL;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_GROUP:
|
||||
return ATSPI_ROLE_PANEL;
|
||||
return ATSPI_ROLE_GROUPING;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_HEADING:
|
||||
return ATSPI_ROLE_HEADING;
|
||||
@@ -367,3 +367,112 @@ gtk_at_spi_emit_children_changed (GDBusConnection *connection,
|
||||
g_variant_new ("(siiv@(so))", change, idx, 0, child_ref, sender_ref),
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gtk_at_spi_translate_coordinates_to_accessible (GtkAccessible *accessible,
|
||||
AtspiCoordType coordtype,
|
||||
int xi,
|
||||
int yi,
|
||||
int *xo,
|
||||
int *yo)
|
||||
{
|
||||
GtkAccessible *parent;
|
||||
int x, y, width, height;
|
||||
|
||||
if (coordtype == ATSPI_COORD_TYPE_SCREEN)
|
||||
{
|
||||
*xo = 0;
|
||||
*yo = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gtk_accessible_get_bounds (accessible, &x, &y, &width, &height))
|
||||
{
|
||||
*xo = xi;
|
||||
*yo = yi;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Transform coords to our parent, we will need that in any case */
|
||||
*xo = xi - x;
|
||||
*yo = yi - y;
|
||||
|
||||
/* If that's what the caller requested, we're done */
|
||||
if (coordtype == ATSPI_COORD_TYPE_PARENT)
|
||||
return;
|
||||
|
||||
if (coordtype == ATSPI_COORD_TYPE_WINDOW)
|
||||
{
|
||||
parent = gtk_accessible_get_accessible_parent (accessible);
|
||||
while (parent != NULL)
|
||||
{
|
||||
g_object_unref (parent);
|
||||
|
||||
if (gtk_accessible_get_bounds (parent, &x, &y, &width, &height))
|
||||
{
|
||||
*xo = *xo - x;
|
||||
*yo = *yo - y;
|
||||
parent = gtk_accessible_get_accessible_parent (parent);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
void
|
||||
gtk_at_spi_translate_coordinates_from_accessible (GtkAccessible *accessible,
|
||||
AtspiCoordType coordtype,
|
||||
int xi,
|
||||
int yi,
|
||||
int *xo,
|
||||
int *yo)
|
||||
{
|
||||
GtkAccessible *parent;
|
||||
int x, y, width, height;
|
||||
|
||||
if (coordtype == ATSPI_COORD_TYPE_SCREEN)
|
||||
{
|
||||
*xo = 0;
|
||||
*yo = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gtk_accessible_get_bounds (accessible, &x, &y, &width, &height))
|
||||
{
|
||||
*xo = xi;
|
||||
*yo = yi;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Transform coords to our parent, we will need that in any case */
|
||||
*xo = xi + x;
|
||||
*yo = yi + y;
|
||||
|
||||
/* If that's what the caller requested, we're done */
|
||||
if (coordtype == ATSPI_COORD_TYPE_PARENT)
|
||||
return;
|
||||
|
||||
if (coordtype == ATSPI_COORD_TYPE_WINDOW)
|
||||
{
|
||||
parent = gtk_accessible_get_accessible_parent (accessible);
|
||||
while (parent != NULL)
|
||||
{
|
||||
g_object_unref (parent);
|
||||
|
||||
if (gtk_accessible_get_bounds (parent, &x, &y, &width, &height))
|
||||
{
|
||||
*xo = *xo + x;
|
||||
*yo = *yo + y;
|
||||
parent = gtk_accessible_get_accessible_parent (parent);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
@@ -39,4 +39,21 @@ gtk_at_spi_emit_children_changed (GDBusConnection *connection,
|
||||
GVariant *child_ref,
|
||||
GVariant *sender_ref);
|
||||
|
||||
void
|
||||
gtk_at_spi_translate_coordinates_to_accessible (GtkAccessible *accessible,
|
||||
AtspiCoordType coordtype,
|
||||
int xi,
|
||||
int yi,
|
||||
int *xo,
|
||||
int *yo);
|
||||
|
||||
|
||||
void
|
||||
gtk_at_spi_translate_coordinates_from_accessible (GtkAccessible *accessible,
|
||||
AtspiCoordType coordtype,
|
||||
int xi,
|
||||
int yi,
|
||||
int *xo,
|
||||
int *yo);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
+543
-47
@@ -26,24 +26,18 @@
|
||||
#include "gtkcsserror.h"
|
||||
#include "gtkcsslocationprivate.h"
|
||||
|
||||
static void clear_ref (GtkCssVariableValueReference *ref);
|
||||
|
||||
#define GDK_ARRAY_NAME gtk_css_parser_references
|
||||
#define GDK_ARRAY_TYPE_NAME GtkCssParserReferences
|
||||
#define GDK_ARRAY_ELEMENT_TYPE GtkCssVariableValueReference
|
||||
#define GDK_ARRAY_BY_VALUE 1
|
||||
#define GDK_ARRAY_NO_MEMSET 1
|
||||
#define GDK_ARRAY_FREE_FUNC clear_ref
|
||||
#include "gdk/gdkarrayimpl.c"
|
||||
|
||||
typedef struct _GtkCssParserBlock GtkCssParserBlock;
|
||||
|
||||
struct _GtkCssParser
|
||||
{
|
||||
volatile int ref_count;
|
||||
|
||||
GtkCssTokenizer *tokenizer;
|
||||
GFile *file;
|
||||
GFile *directory;
|
||||
GtkCssParserErrorFunc error_func;
|
||||
gpointer user_data;
|
||||
GDestroyNotify user_destroy;
|
||||
|
||||
GArray *blocks;
|
||||
GtkCssLocation location;
|
||||
GtkCssToken token;
|
||||
};
|
||||
|
||||
struct _GtkCssParserBlock
|
||||
{
|
||||
GtkCssLocation start_location;
|
||||
@@ -52,8 +46,97 @@ struct _GtkCssParserBlock
|
||||
GtkCssTokenType alternative_token;
|
||||
};
|
||||
|
||||
#define GDK_ARRAY_NAME gtk_css_parser_blocks
|
||||
#define GDK_ARRAY_TYPE_NAME GtkCssParserBlocks
|
||||
#define GDK_ARRAY_ELEMENT_TYPE GtkCssParserBlock
|
||||
#define GDK_ARRAY_PREALLOC 32
|
||||
#define GDK_ARRAY_NO_MEMSET 1
|
||||
#include "gdk/gdkarrayimpl.c"
|
||||
|
||||
static inline GtkCssParserBlock *
|
||||
gtk_css_parser_blocks_get_last (GtkCssParserBlocks *blocks)
|
||||
{
|
||||
return gtk_css_parser_blocks_index (blocks, gtk_css_parser_blocks_get_size (blocks) - 1);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gtk_css_parser_blocks_drop_last (GtkCssParserBlocks *blocks)
|
||||
{
|
||||
gtk_css_parser_blocks_set_size (blocks, gtk_css_parser_blocks_get_size (blocks) - 1);
|
||||
}
|
||||
|
||||
typedef struct _GtkCssTokenizerData GtkCssTokenizerData;
|
||||
|
||||
struct _GtkCssTokenizerData
|
||||
{
|
||||
GtkCssTokenizer *tokenizer;
|
||||
char *var_name;
|
||||
GtkCssVariableValue *variable;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_tokenizer_data_clear (gpointer data)
|
||||
{
|
||||
GtkCssTokenizerData *td = data;
|
||||
|
||||
gtk_css_tokenizer_unref (td->tokenizer);
|
||||
if (td->var_name)
|
||||
g_free (td->var_name);
|
||||
if (td->variable)
|
||||
gtk_css_variable_value_unref (td->variable);
|
||||
}
|
||||
|
||||
#define GDK_ARRAY_NAME gtk_css_tokenizers
|
||||
#define GDK_ARRAY_TYPE_NAME GtkCssTokenizers
|
||||
#define GDK_ARRAY_ELEMENT_TYPE GtkCssTokenizerData
|
||||
#define GDK_ARRAY_FREE_FUNC gtk_css_tokenizer_data_clear
|
||||
#define GDK_ARRAY_BY_VALUE 1
|
||||
#define GDK_ARRAY_PREALLOC 16
|
||||
#define GDK_ARRAY_NO_MEMSET 1
|
||||
#include "gdk/gdkarrayimpl.c"
|
||||
|
||||
static inline GtkCssTokenizerData *
|
||||
gtk_css_tokenizers_get_last (GtkCssTokenizers *tokenizers)
|
||||
{
|
||||
return gtk_css_tokenizers_index (tokenizers, gtk_css_tokenizers_get_size (tokenizers) - 1);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gtk_css_tokenizers_drop_last (GtkCssTokenizers *tokenizers)
|
||||
{
|
||||
gtk_css_tokenizers_set_size (tokenizers, gtk_css_tokenizers_get_size (tokenizers) - 1);
|
||||
}
|
||||
|
||||
struct _GtkCssParser
|
||||
{
|
||||
volatile int ref_count;
|
||||
|
||||
GtkCssTokenizers tokenizers;
|
||||
GFile *file;
|
||||
GFile *directory;
|
||||
GtkCssParserErrorFunc error_func;
|
||||
gpointer user_data;
|
||||
GDestroyNotify user_destroy;
|
||||
|
||||
GtkCssParserBlocks blocks;
|
||||
GtkCssLocation location;
|
||||
GtkCssToken token;
|
||||
|
||||
GtkCssVariableValue **refs;
|
||||
gsize n_refs;
|
||||
gsize next_ref;
|
||||
gboolean var_fallback;
|
||||
};
|
||||
|
||||
static inline GtkCssTokenizer *
|
||||
get_tokenizer (GtkCssParser *self)
|
||||
{
|
||||
return gtk_css_tokenizers_get_last (&self->tokenizers)->tokenizer;
|
||||
}
|
||||
|
||||
static GtkCssParser *
|
||||
gtk_css_parser_new (GtkCssTokenizer *tokenizer,
|
||||
GtkCssVariableValue *value,
|
||||
GFile *file,
|
||||
GtkCssParserErrorFunc error_func,
|
||||
gpointer user_data,
|
||||
@@ -64,17 +147,21 @@ gtk_css_parser_new (GtkCssTokenizer *tokenizer,
|
||||
self = g_new0 (GtkCssParser, 1);
|
||||
|
||||
self->ref_count = 1;
|
||||
self->tokenizer = gtk_css_tokenizer_ref (tokenizer);
|
||||
|
||||
gtk_css_tokenizers_init (&self->tokenizers);
|
||||
gtk_css_tokenizers_append (&self->tokenizers,
|
||||
&(GtkCssTokenizerData) {
|
||||
gtk_css_tokenizer_ref (tokenizer),
|
||||
NULL,
|
||||
value ? gtk_css_variable_value_ref (value) : NULL });
|
||||
|
||||
if (file)
|
||||
{
|
||||
self->file = g_object_ref (file);
|
||||
self->directory = g_file_get_parent (file);
|
||||
}
|
||||
self->file = g_object_ref (file);
|
||||
|
||||
self->error_func = error_func;
|
||||
self->user_data = user_data;
|
||||
self->user_destroy = user_destroy;
|
||||
self->blocks = g_array_new (FALSE, FALSE, sizeof (GtkCssParserBlock));
|
||||
gtk_css_parser_blocks_init (&self->blocks);
|
||||
|
||||
return self;
|
||||
}
|
||||
@@ -109,26 +196,50 @@ gtk_css_parser_new_for_bytes (GBytes *bytes,
|
||||
{
|
||||
GtkCssTokenizer *tokenizer;
|
||||
GtkCssParser *result;
|
||||
|
||||
|
||||
tokenizer = gtk_css_tokenizer_new (bytes);
|
||||
result = gtk_css_parser_new (tokenizer, file, error_func, user_data, user_destroy);
|
||||
result = gtk_css_parser_new (tokenizer, NULL, file, error_func, user_data, user_destroy);
|
||||
gtk_css_tokenizer_unref (tokenizer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkCssParser *
|
||||
gtk_css_parser_new_for_token_stream (GtkCssVariableValue *value,
|
||||
GFile *file,
|
||||
GtkCssVariableValue **refs,
|
||||
gsize n_refs,
|
||||
GtkCssParserErrorFunc error_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy)
|
||||
{
|
||||
GtkCssTokenizer *tokenizer;
|
||||
GtkCssParser *result;
|
||||
|
||||
tokenizer = gtk_css_tokenizer_new_for_range (value->bytes, value->offset,
|
||||
value->end_offset - value->offset);
|
||||
result = gtk_css_parser_new (tokenizer, value, file, error_func, user_data, user_destroy);
|
||||
gtk_css_tokenizer_unref (tokenizer);
|
||||
|
||||
result->refs = refs;
|
||||
result->n_refs = n_refs;
|
||||
result->next_ref = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_parser_finalize (GtkCssParser *self)
|
||||
{
|
||||
if (self->user_destroy)
|
||||
self->user_destroy (self->user_data);
|
||||
|
||||
g_clear_pointer (&self->tokenizer, gtk_css_tokenizer_unref);
|
||||
gtk_css_tokenizers_clear (&self->tokenizers);
|
||||
g_clear_object (&self->file);
|
||||
g_clear_object (&self->directory);
|
||||
if (self->blocks->len)
|
||||
g_critical ("Finalizing CSS parser with %u remaining blocks", self->blocks->len);
|
||||
g_array_free (self->blocks, TRUE);
|
||||
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
|
||||
g_critical ("Finalizing CSS parser with %lu remaining blocks", gtk_css_parser_blocks_get_size (&self->blocks));
|
||||
gtk_css_parser_blocks_clear (&self->blocks);
|
||||
|
||||
g_free (self);
|
||||
}
|
||||
@@ -163,6 +274,12 @@ gtk_css_parser_get_file (GtkCssParser *self)
|
||||
return self->file;
|
||||
}
|
||||
|
||||
GBytes *
|
||||
gtk_css_parser_get_bytes (GtkCssParser *self)
|
||||
{
|
||||
return gtk_css_tokenizer_get_bytes (gtk_css_tokenizers_get (&self->tokenizers, 0)->tokenizer);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_css_parser_resolve_url:
|
||||
* @self: a `GtkCssParser`
|
||||
@@ -188,7 +305,12 @@ gtk_css_parser_resolve_url (GtkCssParser *self,
|
||||
}
|
||||
|
||||
if (self->directory == NULL)
|
||||
return NULL;
|
||||
{
|
||||
if (self->file)
|
||||
self->directory = g_file_get_parent (self->file);
|
||||
if (self->directory == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_file_resolve_relative_path (self->directory, url);
|
||||
}
|
||||
@@ -239,7 +361,7 @@ gtk_css_parser_get_start_location (GtkCssParser *self)
|
||||
const GtkCssLocation *
|
||||
gtk_css_parser_get_end_location (GtkCssParser *self)
|
||||
{
|
||||
return gtk_css_tokenizer_get_location (self->tokenizer);
|
||||
return gtk_css_tokenizer_get_location (get_tokenizer (self));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,13 +381,13 @@ gtk_css_parser_get_block_location (GtkCssParser *self)
|
||||
{
|
||||
const GtkCssParserBlock *block;
|
||||
|
||||
if (self->blocks->len == 0)
|
||||
if (gtk_css_parser_blocks_get_size (&self->blocks) == 0)
|
||||
{
|
||||
static const GtkCssLocation start_of_document = { 0, };
|
||||
return &start_of_document;
|
||||
}
|
||||
|
||||
block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
|
||||
block = gtk_css_parser_blocks_get_last (&self->blocks);
|
||||
return &block->start_location;
|
||||
}
|
||||
|
||||
@@ -273,12 +395,14 @@ static void
|
||||
gtk_css_parser_ensure_token (GtkCssParser *self)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GtkCssTokenizer *tokenizer;
|
||||
|
||||
if (!gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
|
||||
return;
|
||||
|
||||
self->location = *gtk_css_tokenizer_get_location (self->tokenizer);
|
||||
if (!gtk_css_tokenizer_read_token (self->tokenizer, &self->token, &error))
|
||||
tokenizer = get_tokenizer (self);
|
||||
self->location = *gtk_css_tokenizer_get_location (tokenizer);
|
||||
if (!gtk_css_tokenizer_read_token (tokenizer, &self->token, &error))
|
||||
{
|
||||
/* We ignore the error here, because the resulting token will
|
||||
* likely already trigger an error in the parsing code and
|
||||
@@ -286,6 +410,49 @@ gtk_css_parser_ensure_token (GtkCssParser *self)
|
||||
*/
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
if (gtk_css_tokenizers_get_size (&self->tokenizers) > 1 && gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
gtk_css_tokenizers_drop_last (&self->tokenizers);
|
||||
gtk_css_parser_ensure_token (self);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Resolve var(--name): skip it and insert the resolved reference instead */
|
||||
if (self->n_refs > 0 && gtk_css_token_is_function (&self->token, "var") && self->var_fallback == 0)
|
||||
{
|
||||
GtkCssVariableValue *ref;
|
||||
GtkCssTokenizer *ref_tokenizer;
|
||||
|
||||
gtk_css_parser_start_block (self);
|
||||
|
||||
g_assert (gtk_css_parser_has_token (self, GTK_CSS_TOKEN_IDENT));
|
||||
|
||||
char *var_name = gtk_css_parser_consume_ident (self);
|
||||
g_assert (var_name[0] == '-' && var_name[1] == '-');
|
||||
|
||||
/* If we encounter var() in a fallback when we can already resolve the
|
||||
* actual variable, skip it */
|
||||
self->var_fallback++;
|
||||
gtk_css_parser_skip (self);
|
||||
gtk_css_parser_end_block (self);
|
||||
self->var_fallback--;
|
||||
|
||||
g_assert (self->next_ref < self->n_refs);
|
||||
|
||||
ref = self->refs[self->next_ref++];
|
||||
ref_tokenizer = gtk_css_tokenizer_new_for_range (ref->bytes, ref->offset,
|
||||
ref->end_offset - ref->offset);
|
||||
gtk_css_tokenizers_append (&self->tokenizers,
|
||||
&(GtkCssTokenizerData) {
|
||||
ref_tokenizer,
|
||||
g_strdup (var_name),
|
||||
gtk_css_variable_value_ref (ref)
|
||||
});
|
||||
|
||||
gtk_css_parser_ensure_token (self);
|
||||
g_free (var_name);
|
||||
}
|
||||
}
|
||||
|
||||
const GtkCssToken *
|
||||
@@ -295,9 +462,9 @@ gtk_css_parser_peek_token (GtkCssParser *self)
|
||||
|
||||
gtk_css_parser_ensure_token (self);
|
||||
|
||||
if (self->blocks->len)
|
||||
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
|
||||
{
|
||||
const GtkCssParserBlock *block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
|
||||
const GtkCssParserBlock *block = gtk_css_parser_blocks_get_last (&self->blocks);
|
||||
if (gtk_css_token_is (&self->token, block->end_token) ||
|
||||
gtk_css_token_is (&self->token, block->inherited_end_token) ||
|
||||
gtk_css_token_is (&self->token, block->alternative_token))
|
||||
@@ -352,7 +519,7 @@ gtk_css_parser_start_block (GtkCssParser *self)
|
||||
block.inherited_end_token = GTK_CSS_TOKEN_EOF;
|
||||
block.alternative_token = GTK_CSS_TOKEN_EOF;
|
||||
block.start_location = self->location;
|
||||
g_array_append_val (self->blocks, block);
|
||||
gtk_css_parser_blocks_append (&self->blocks, block);
|
||||
|
||||
gtk_css_token_clear (&self->token);
|
||||
}
|
||||
@@ -364,13 +531,13 @@ gtk_css_parser_start_semicolon_block (GtkCssParser *self,
|
||||
GtkCssParserBlock block;
|
||||
|
||||
block.end_token = GTK_CSS_TOKEN_SEMICOLON;
|
||||
if (self->blocks->len)
|
||||
block.inherited_end_token = g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1).end_token;
|
||||
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
|
||||
block.inherited_end_token = gtk_css_parser_blocks_get_last (&self->blocks)->end_token;
|
||||
else
|
||||
block.inherited_end_token = GTK_CSS_TOKEN_EOF;
|
||||
block.alternative_token = alternative_token;
|
||||
block.start_location = self->location;
|
||||
g_array_append_val (self->blocks, block);
|
||||
gtk_css_parser_blocks_append (&self->blocks, block);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -378,9 +545,9 @@ gtk_css_parser_end_block_prelude (GtkCssParser *self)
|
||||
{
|
||||
GtkCssParserBlock *block;
|
||||
|
||||
g_return_if_fail (self->blocks->len > 0);
|
||||
g_return_if_fail (gtk_css_parser_blocks_get_size (&self->blocks) > 0);
|
||||
|
||||
block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
|
||||
block = gtk_css_parser_blocks_get_last (&self->blocks);
|
||||
|
||||
if (block->alternative_token == GTK_CSS_TOKEN_EOF)
|
||||
return;
|
||||
@@ -405,11 +572,11 @@ gtk_css_parser_end_block (GtkCssParser *self)
|
||||
{
|
||||
GtkCssParserBlock *block;
|
||||
|
||||
g_return_if_fail (self->blocks->len > 0);
|
||||
g_return_if_fail (gtk_css_parser_blocks_get_size (&self->blocks) > 0);
|
||||
|
||||
gtk_css_parser_skip_until (self, GTK_CSS_TOKEN_EOF);
|
||||
|
||||
block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
|
||||
block = gtk_css_parser_blocks_get_last (&self->blocks);
|
||||
|
||||
if (gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
@@ -418,7 +585,7 @@ gtk_css_parser_end_block (GtkCssParser *self)
|
||||
gtk_css_parser_get_block_location (self),
|
||||
gtk_css_parser_get_start_location (self),
|
||||
"Unterminated block at end of document");
|
||||
g_array_set_size (self->blocks, self->blocks->len - 1);
|
||||
gtk_css_parser_blocks_drop_last (&self->blocks);
|
||||
}
|
||||
else if (gtk_css_token_is (&self->token, block->inherited_end_token))
|
||||
{
|
||||
@@ -428,11 +595,11 @@ gtk_css_parser_end_block (GtkCssParser *self)
|
||||
gtk_css_parser_get_block_location (self),
|
||||
gtk_css_parser_get_start_location (self),
|
||||
"Expected ';' at end of block");
|
||||
g_array_set_size (self->blocks, self->blocks->len - 1);
|
||||
gtk_css_parser_blocks_drop_last (&self->blocks);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_array_set_size (self->blocks, self->blocks->len - 1);
|
||||
gtk_css_parser_blocks_drop_last (&self->blocks);
|
||||
if (gtk_css_token_is_preserved (&self->token, NULL))
|
||||
{
|
||||
gtk_css_token_clear (&self->token);
|
||||
@@ -502,6 +669,19 @@ gtk_css_parser_skip_until (GtkCssParser *self,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_parser_skip_whitespace (GtkCssParser *self)
|
||||
{
|
||||
const GtkCssToken *token;
|
||||
|
||||
for (token = gtk_css_parser_peek_token (self);
|
||||
gtk_css_token_is (token, GTK_CSS_TOKEN_WHITESPACE);
|
||||
token = gtk_css_parser_peek_token (self))
|
||||
{
|
||||
gtk_css_parser_consume_token (self);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_parser_emit_error (GtkCssParser *self,
|
||||
const GtkCssLocation *start,
|
||||
@@ -1112,3 +1292,319 @@ gtk_css_parser_consume_any (GtkCssParser *parser,
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_css_parser_has_references (GtkCssParser *self)
|
||||
{
|
||||
GtkCssTokenizer *tokenizer = get_tokenizer (self);
|
||||
gboolean ret = FALSE;
|
||||
int inner_blocks = 0, i;
|
||||
|
||||
gtk_css_tokenizer_save (tokenizer);
|
||||
|
||||
do {
|
||||
const GtkCssToken *token;
|
||||
|
||||
token = gtk_css_parser_get_token (self);
|
||||
|
||||
if (inner_blocks == 0)
|
||||
{
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
|
||||
break;
|
||||
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_PARENS) ||
|
||||
gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_SQUARE))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (gtk_css_token_is_preserved (token, NULL))
|
||||
{
|
||||
if (inner_blocks > 0 && gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
gtk_css_parser_end_block (self);
|
||||
inner_blocks--;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_css_parser_consume_token (self);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gboolean is_var = gtk_css_token_is_function (token, "var");
|
||||
|
||||
inner_blocks++;
|
||||
gtk_css_parser_start_block (self);
|
||||
|
||||
if (!ret && is_var)
|
||||
{
|
||||
token = gtk_css_parser_get_token (self);
|
||||
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
|
||||
{
|
||||
const char *var_name = gtk_css_token_get_string (token);
|
||||
|
||||
if (var_name[0] != '-' || var_name[1] != '-')
|
||||
goto error;
|
||||
|
||||
gtk_css_parser_consume_token (self);
|
||||
|
||||
if (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_EOF) &&
|
||||
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_COMMA))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_SEMICOLON) &&
|
||||
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_CLOSE_CURLY));
|
||||
|
||||
if (inner_blocks > 0)
|
||||
goto error;
|
||||
|
||||
g_assert (tokenizer == get_tokenizer (self));
|
||||
|
||||
gtk_css_tokenizer_restore (tokenizer);
|
||||
self->location = *gtk_css_tokenizer_get_location (tokenizer);
|
||||
gtk_css_tokenizer_read_token (tokenizer, &self->token, NULL);
|
||||
|
||||
return ret;
|
||||
|
||||
error:
|
||||
for (i = 0; i < inner_blocks; i++)
|
||||
gtk_css_parser_end_block (self);
|
||||
|
||||
g_assert (tokenizer == get_tokenizer (self));
|
||||
|
||||
gtk_css_tokenizer_restore (tokenizer);
|
||||
self->location = *gtk_css_tokenizer_get_location (tokenizer);
|
||||
gtk_css_tokenizer_read_token (tokenizer, &self->token, NULL);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
clear_ref (GtkCssVariableValueReference *ref)
|
||||
{
|
||||
g_free (ref->name);
|
||||
if (ref->fallback)
|
||||
gtk_css_variable_value_unref (ref->fallback);
|
||||
}
|
||||
|
||||
#define GDK_ARRAY_NAME gtk_css_parser_references
|
||||
#define GDK_ARRAY_TYPE_NAME GtkCssParserReferences
|
||||
#define GDK_ARRAY_ELEMENT_TYPE GtkCssVariableValueReference
|
||||
|
||||
GtkCssVariableValue *
|
||||
gtk_css_parser_parse_value_into_token_stream (GtkCssParser *self)
|
||||
{
|
||||
GBytes *bytes = gtk_css_tokenizer_get_bytes (get_tokenizer (self));
|
||||
const GtkCssToken *token;
|
||||
gsize offset;
|
||||
gsize length = 0;
|
||||
GtkCssParserReferences refs;
|
||||
int inner_blocks = 0, i;
|
||||
gboolean is_initial = FALSE;
|
||||
|
||||
for (token = gtk_css_parser_peek_token (self);
|
||||
gtk_css_token_is (token, GTK_CSS_TOKEN_WHITESPACE);
|
||||
token = gtk_css_parser_peek_token (self))
|
||||
{
|
||||
gtk_css_parser_consume_token (self);
|
||||
}
|
||||
|
||||
gtk_css_parser_references_init (&refs);
|
||||
|
||||
offset = self->location.bytes;
|
||||
|
||||
do {
|
||||
token = gtk_css_parser_get_token (self);
|
||||
|
||||
if (length == 0 && gtk_css_token_is_ident (token, "initial"))
|
||||
is_initial = TRUE;
|
||||
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_BAD_STRING) ||
|
||||
gtk_css_token_is (token, GTK_CSS_TOKEN_BAD_URL))
|
||||
{
|
||||
gtk_css_parser_error_syntax (self, "Invalid property value");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (inner_blocks == 0)
|
||||
{
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
|
||||
break;
|
||||
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_PARENS) ||
|
||||
gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_SQUARE))
|
||||
{
|
||||
gtk_css_parser_error_syntax (self, "Invalid property value");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (gtk_css_token_is_preserved (token, NULL))
|
||||
{
|
||||
if (inner_blocks > 0 && gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
length++;
|
||||
gtk_css_parser_end_block (self);
|
||||
|
||||
inner_blocks--;
|
||||
}
|
||||
else
|
||||
{
|
||||
length++;
|
||||
gtk_css_parser_consume_token (self);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gboolean is_var = gtk_css_token_is_function (token, "var");
|
||||
|
||||
length++;
|
||||
inner_blocks++;
|
||||
|
||||
gtk_css_parser_start_block (self);
|
||||
|
||||
if (is_var)
|
||||
{
|
||||
token = gtk_css_parser_get_token (self);
|
||||
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
|
||||
{
|
||||
GtkCssVariableValueReference ref;
|
||||
char *var_name = g_strdup (gtk_css_token_get_string (token));
|
||||
|
||||
if (var_name[0] != '-' || var_name[1] != '-')
|
||||
{
|
||||
gtk_css_parser_error_value (self, "Invalid variable name: %s", var_name);
|
||||
g_free (var_name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
length++;
|
||||
gtk_css_parser_consume_token (self);
|
||||
|
||||
if (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_EOF) &&
|
||||
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_COMMA))
|
||||
{
|
||||
gtk_css_parser_error_syntax (self, "Invalid property value");
|
||||
g_free (var_name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
ref.name = var_name;
|
||||
|
||||
if (gtk_css_parser_has_token (self, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
ref.length = 3;
|
||||
ref.fallback = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
length++;
|
||||
gtk_css_parser_consume_token (self);
|
||||
|
||||
ref.fallback = gtk_css_parser_parse_value_into_token_stream (self);
|
||||
|
||||
if (ref.fallback == NULL)
|
||||
{
|
||||
gtk_css_parser_error_value (self, "Invalid fallback for: %s", var_name);
|
||||
g_free (var_name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
ref.length = 4 + ref.fallback->length;
|
||||
length += ref.fallback->length;
|
||||
}
|
||||
|
||||
gtk_css_parser_references_append (&refs, &ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_SEMICOLON) &&
|
||||
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_CLOSE_CURLY));
|
||||
|
||||
if (inner_blocks > 0)
|
||||
{
|
||||
gtk_css_parser_error_syntax (self, "Invalid property value");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (is_initial && length == 1)
|
||||
{
|
||||
gtk_css_parser_references_clear (&refs);
|
||||
|
||||
return gtk_css_variable_value_new_initial (bytes,
|
||||
offset,
|
||||
self->location.bytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkCssVariableValueReference *out_refs;
|
||||
gsize n_refs;
|
||||
|
||||
n_refs = gtk_css_parser_references_get_size (&refs);
|
||||
out_refs = gtk_css_parser_references_steal (&refs);
|
||||
|
||||
return gtk_css_variable_value_new (bytes,
|
||||
offset,
|
||||
self->location.bytes,
|
||||
length,
|
||||
out_refs,
|
||||
n_refs);
|
||||
}
|
||||
|
||||
error:
|
||||
for (i = 0; i < inner_blocks; i++)
|
||||
gtk_css_parser_end_block (self);
|
||||
|
||||
gtk_css_parser_references_clear (&refs);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_parser_get_expanding_variables (GtkCssParser *self,
|
||||
GtkCssVariableValue ***variables,
|
||||
char ***variable_names,
|
||||
gsize *n_variables)
|
||||
{
|
||||
gsize len = gtk_css_tokenizers_get_size (&self->tokenizers);
|
||||
GtkCssVariableValue **vars = NULL;
|
||||
char **names = NULL;
|
||||
gsize n;
|
||||
|
||||
if (variables)
|
||||
vars = g_new0 (GtkCssVariableValue *, len + 1);
|
||||
if (variable_names)
|
||||
names = g_new0 (char *, len + 1);
|
||||
|
||||
n = 0;
|
||||
for (gsize i = 0; i < gtk_css_tokenizers_get_size (&self->tokenizers); i++)
|
||||
{
|
||||
GtkCssTokenizerData *data = gtk_css_tokenizers_index (&self->tokenizers, i);
|
||||
if (variables && data->variable)
|
||||
vars[n] = gtk_css_variable_value_ref (data->variable);
|
||||
if (variable_names)
|
||||
names[n] = g_strdup (data->var_name);
|
||||
n++;
|
||||
}
|
||||
|
||||
if (variables)
|
||||
*variables = vars;
|
||||
|
||||
if (variable_names)
|
||||
*variable_names = names;
|
||||
|
||||
if (n_variables)
|
||||
*n_variables = n;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "gtkcssenums.h"
|
||||
#include "gtkcsstokenizerprivate.h"
|
||||
#include "gtkcssvariablevalueprivate.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
@@ -58,10 +59,18 @@ GtkCssParser * gtk_css_parser_new_for_bytes (GBytes
|
||||
GtkCssParserErrorFunc error_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy);
|
||||
GtkCssParser * gtk_css_parser_new_for_token_stream (GtkCssVariableValue *value,
|
||||
GFile *file,
|
||||
GtkCssVariableValue **refs,
|
||||
gsize n_refs,
|
||||
GtkCssParserErrorFunc error_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy);
|
||||
GtkCssParser * gtk_css_parser_ref (GtkCssParser *self);
|
||||
void gtk_css_parser_unref (GtkCssParser *self);
|
||||
|
||||
GFile * gtk_css_parser_get_file (GtkCssParser *self) G_GNUC_PURE;
|
||||
GBytes * gtk_css_parser_get_bytes (GtkCssParser *self) G_GNUC_PURE;
|
||||
GFile * gtk_css_parser_resolve_url (GtkCssParser *self,
|
||||
const char *url);
|
||||
|
||||
@@ -81,6 +90,7 @@ void gtk_css_parser_end_block (GtkCssParser
|
||||
void gtk_css_parser_skip (GtkCssParser *self);
|
||||
void gtk_css_parser_skip_until (GtkCssParser *self,
|
||||
GtkCssTokenType token_type);
|
||||
void gtk_css_parser_skip_whitespace (GtkCssParser *self);
|
||||
|
||||
void gtk_css_parser_emit_error (GtkCssParser *self,
|
||||
const GtkCssLocation *start,
|
||||
@@ -150,5 +160,14 @@ gsize gtk_css_parser_consume_any (GtkCssParser
|
||||
gsize n_options,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean gtk_css_parser_has_references (GtkCssParser *parser);
|
||||
|
||||
GtkCssVariableValue * gtk_css_parser_parse_value_into_token_stream (GtkCssParser *parser);
|
||||
|
||||
void gtk_css_parser_get_expanding_variables (GtkCssParser *parser,
|
||||
GtkCssVariableValue ***variables,
|
||||
char ***names,
|
||||
gsize *n_variables);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ struct _GtkCssSection
|
||||
int ref_count;
|
||||
GtkCssSection *parent;
|
||||
GFile *file;
|
||||
GBytes *bytes;
|
||||
GtkCssLocation start_location;
|
||||
GtkCssLocation end_location; /* end location if parser is %NULL */
|
||||
};
|
||||
@@ -48,6 +49,15 @@ GtkCssSection *
|
||||
gtk_css_section_new (GFile *file,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end)
|
||||
{
|
||||
return gtk_css_section_new_with_bytes (file, NULL,start, end);
|
||||
}
|
||||
|
||||
GtkCssSection *
|
||||
gtk_css_section_new_with_bytes (GFile *file,
|
||||
GBytes *bytes,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end)
|
||||
{
|
||||
GtkCssSection *result;
|
||||
|
||||
@@ -60,6 +70,8 @@ gtk_css_section_new (GFile *file,
|
||||
result->ref_count = 1;
|
||||
if (file)
|
||||
result->file = g_object_ref (file);
|
||||
if (bytes)
|
||||
result->bytes = g_bytes_ref (bytes);
|
||||
result->start_location = *start;
|
||||
result->end_location = *end;
|
||||
|
||||
@@ -104,6 +116,8 @@ gtk_css_section_unref (GtkCssSection *section)
|
||||
gtk_css_section_unref (section->parent);
|
||||
if (section->file)
|
||||
g_object_unref (section->file);
|
||||
if (section->bytes)
|
||||
g_bytes_unref (section->bytes);
|
||||
|
||||
g_free (section);
|
||||
}
|
||||
@@ -151,6 +165,14 @@ gtk_css_section_get_file (const GtkCssSection *section)
|
||||
return section->file;
|
||||
}
|
||||
|
||||
GBytes *
|
||||
gtk_css_section_get_bytes (const GtkCssSection *section)
|
||||
{
|
||||
g_return_val_if_fail (section != NULL, NULL);
|
||||
|
||||
return section->bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_css_section_get_start_location:
|
||||
* @section: the section
|
||||
|
||||
@@ -46,6 +46,11 @@ GDK_AVAILABLE_IN_ALL
|
||||
GtkCssSection * gtk_css_section_new (GFile *file,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end);
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GtkCssSection * gtk_css_section_new_with_bytes (GFile *file,
|
||||
GBytes *bytes,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkCssSection * gtk_css_section_ref (GtkCssSection *section);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
@@ -61,6 +66,8 @@ GDK_AVAILABLE_IN_ALL
|
||||
GtkCssSection * gtk_css_section_get_parent (const GtkCssSection *section);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GFile * gtk_css_section_get_file (const GtkCssSection *section);
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GBytes * gtk_css_section_get_bytes (const GtkCssSection *section);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GtkCssLocation *
|
||||
gtk_css_section_get_start_location (const GtkCssSection *section);
|
||||
|
||||
@@ -36,6 +36,9 @@ struct _GtkCssTokenizer
|
||||
const char *end;
|
||||
|
||||
GtkCssLocation position;
|
||||
|
||||
GtkCssLocation saved_position;
|
||||
const char *saved_data;
|
||||
};
|
||||
|
||||
void
|
||||
@@ -568,6 +571,14 @@ gtk_css_token_init_dimension (GtkCssToken *token,
|
||||
|
||||
GtkCssTokenizer *
|
||||
gtk_css_tokenizer_new (GBytes *bytes)
|
||||
{
|
||||
return gtk_css_tokenizer_new_for_range (bytes, 0, g_bytes_get_size (bytes));
|
||||
}
|
||||
|
||||
GtkCssTokenizer *
|
||||
gtk_css_tokenizer_new_for_range (GBytes *bytes,
|
||||
gsize offset,
|
||||
gsize length)
|
||||
{
|
||||
GtkCssTokenizer *tokenizer;
|
||||
|
||||
@@ -576,8 +587,8 @@ gtk_css_tokenizer_new (GBytes *bytes)
|
||||
tokenizer->bytes = g_bytes_ref (bytes);
|
||||
tokenizer->name_buffer = g_string_new (NULL);
|
||||
|
||||
tokenizer->data = g_bytes_get_data (bytes, NULL);
|
||||
tokenizer->end = tokenizer->data + g_bytes_get_size (bytes);
|
||||
tokenizer->data = g_bytes_get_region (bytes, 1, offset, length);
|
||||
tokenizer->end = tokenizer->data + length;
|
||||
|
||||
gtk_css_location_init (&tokenizer->position);
|
||||
|
||||
@@ -604,6 +615,12 @@ gtk_css_tokenizer_unref (GtkCssTokenizer *tokenizer)
|
||||
g_free (tokenizer);
|
||||
}
|
||||
|
||||
GBytes *
|
||||
gtk_css_tokenizer_get_bytes (GtkCssTokenizer *tokenizer)
|
||||
{
|
||||
return tokenizer->bytes;
|
||||
}
|
||||
|
||||
const GtkCssLocation *
|
||||
gtk_css_tokenizer_get_location (GtkCssTokenizer *tokenizer)
|
||||
{
|
||||
@@ -1484,3 +1501,23 @@ gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_tokenizer_save (GtkCssTokenizer *tokenizer)
|
||||
{
|
||||
g_assert (!tokenizer->saved_data);
|
||||
|
||||
tokenizer->saved_position = tokenizer->position;
|
||||
tokenizer->saved_data = tokenizer->data;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_tokenizer_restore (GtkCssTokenizer *tokenizer)
|
||||
{
|
||||
g_assert (tokenizer->saved_data);
|
||||
|
||||
tokenizer->position = tokenizer->saved_position;
|
||||
tokenizer->data = tokenizer->saved_data;
|
||||
|
||||
gtk_css_location_init (&tokenizer->saved_position);
|
||||
tokenizer->saved_data = NULL;
|
||||
}
|
||||
|
||||
@@ -138,15 +138,22 @@ void gtk_css_token_print (const GtkCssTok
|
||||
char * gtk_css_token_to_string (const GtkCssToken *token);
|
||||
|
||||
GtkCssTokenizer * gtk_css_tokenizer_new (GBytes *bytes);
|
||||
GtkCssTokenizer * gtk_css_tokenizer_new_for_range (GBytes *bytes,
|
||||
gsize offset,
|
||||
gsize length);
|
||||
|
||||
GtkCssTokenizer * gtk_css_tokenizer_ref (GtkCssTokenizer *tokenizer);
|
||||
void gtk_css_tokenizer_unref (GtkCssTokenizer *tokenizer);
|
||||
|
||||
GBytes * gtk_css_tokenizer_get_bytes (GtkCssTokenizer *tokenizer);
|
||||
const GtkCssLocation * gtk_css_tokenizer_get_location (GtkCssTokenizer *tokenizer) G_GNUC_CONST;
|
||||
|
||||
gboolean gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer,
|
||||
GtkCssToken *token,
|
||||
GError **error);
|
||||
|
||||
void gtk_css_tokenizer_save (GtkCssTokenizer *tokenizer);
|
||||
void gtk_css_tokenizer_restore (GtkCssTokenizer *tokenizer);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (C) 2023 GNOME Foundation Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alice Mikhaylenko <alicem@gnome.org>
|
||||
*/
|
||||
|
||||
#include "gtkcssvariablevalueprivate.h"
|
||||
|
||||
GtkCssVariableValue *
|
||||
gtk_css_variable_value_new (GBytes *bytes,
|
||||
gsize offset,
|
||||
gsize end_offset,
|
||||
gsize length,
|
||||
GtkCssVariableValueReference *references,
|
||||
gsize n_references)
|
||||
{
|
||||
GtkCssVariableValue *self = g_new0 (GtkCssVariableValue, 1);
|
||||
|
||||
self->ref_count = 1;
|
||||
|
||||
self->bytes = g_bytes_ref (bytes);
|
||||
self->offset = offset;
|
||||
self->end_offset = end_offset;
|
||||
self->length = length;
|
||||
|
||||
self->references = references;
|
||||
self->n_references = n_references;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
GtkCssVariableValue *
|
||||
gtk_css_variable_value_new_initial (GBytes *bytes,
|
||||
gsize offset,
|
||||
gsize end_offset)
|
||||
{
|
||||
GtkCssVariableValue *self = gtk_css_variable_value_new (bytes, offset, end_offset, 1, NULL, 0);
|
||||
|
||||
self->is_invalid = TRUE;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
GtkCssVariableValue *
|
||||
gtk_css_variable_value_ref (GtkCssVariableValue *self)
|
||||
{
|
||||
self->ref_count++;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_variable_value_unref (GtkCssVariableValue *self)
|
||||
{
|
||||
gsize i;
|
||||
|
||||
self->ref_count--;
|
||||
if (self->ref_count > 0)
|
||||
return;
|
||||
|
||||
g_bytes_unref (self->bytes);
|
||||
|
||||
for (i = 0; i < self->n_references; i++)
|
||||
{
|
||||
GtkCssVariableValueReference *ref = &self->references[i];
|
||||
|
||||
g_free (ref->name);
|
||||
if (ref->fallback)
|
||||
gtk_css_variable_value_unref (ref->fallback);
|
||||
}
|
||||
|
||||
if (self->section)
|
||||
gtk_css_section_unref (self->section);
|
||||
|
||||
g_free (self->references);
|
||||
g_free (self);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_variable_value_print (GtkCssVariableValue *self,
|
||||
GString *string)
|
||||
{
|
||||
gsize len = self->end_offset - self->offset;
|
||||
gconstpointer data = g_bytes_get_region (self->bytes, 1, self->offset, len);
|
||||
|
||||
g_assert (data != NULL);
|
||||
|
||||
g_string_append_len (string, (const char *) data, len);
|
||||
}
|
||||
|
||||
char *
|
||||
gtk_css_variable_value_to_string (GtkCssVariableValue *self)
|
||||
{
|
||||
GString *string = g_string_new (NULL);
|
||||
gtk_css_variable_value_print (self, string);
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_css_variable_value_equal (const GtkCssVariableValue *value1,
|
||||
const GtkCssVariableValue *value2)
|
||||
{
|
||||
if (value1 == value2)
|
||||
return TRUE;
|
||||
|
||||
if (value1 == NULL || value2 == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (value1->bytes != value2->bytes)
|
||||
return FALSE;
|
||||
|
||||
if (value1->offset != value2->offset)
|
||||
return FALSE;
|
||||
|
||||
if (value1->end_offset != value2->end_offset)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GtkCssVariableValue *
|
||||
gtk_css_variable_value_transition (GtkCssVariableValue *start,
|
||||
GtkCssVariableValue *end,
|
||||
double progress)
|
||||
{
|
||||
GtkCssVariableValue *ret = progress < 0.5 ? start : end;
|
||||
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
|
||||
return gtk_css_variable_value_ref (ret);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_variable_value_set_section (GtkCssVariableValue *self,
|
||||
GtkCssSection *section)
|
||||
{
|
||||
self->section = gtk_css_section_ref (section);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_variable_value_taint (GtkCssVariableValue *self)
|
||||
{
|
||||
self->is_animation_tainted = TRUE;
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2023 GNOME Foundation Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alice Mikhaylenko <alicem@gnome.org>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gtkcss.h"
|
||||
#include "gtkcsstokenizerprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkCssVariableValueReference GtkCssVariableValueReference;
|
||||
typedef struct _GtkCssVariableValue GtkCssVariableValue;
|
||||
|
||||
struct _GtkCssVariableValueReference
|
||||
{
|
||||
char *name;
|
||||
gsize length;
|
||||
GtkCssVariableValue *fallback;
|
||||
};
|
||||
|
||||
struct _GtkCssVariableValue
|
||||
{
|
||||
int ref_count;
|
||||
|
||||
GBytes *bytes;
|
||||
gsize offset;
|
||||
gsize end_offset;
|
||||
gsize length;
|
||||
|
||||
GtkCssVariableValueReference *references;
|
||||
gsize n_references;
|
||||
|
||||
GtkCssSection *section;
|
||||
gboolean is_invalid;
|
||||
gboolean is_animation_tainted;
|
||||
};
|
||||
|
||||
GtkCssVariableValue *gtk_css_variable_value_new (GBytes *bytes,
|
||||
gsize offset,
|
||||
gsize end_offset,
|
||||
gsize length,
|
||||
GtkCssVariableValueReference *references,
|
||||
gsize n_references);
|
||||
GtkCssVariableValue *gtk_css_variable_value_new_initial (GBytes *bytes,
|
||||
gsize offset,
|
||||
gsize end_offset);
|
||||
GtkCssVariableValue *gtk_css_variable_value_ref (GtkCssVariableValue *self);
|
||||
void gtk_css_variable_value_unref (GtkCssVariableValue *self);
|
||||
void gtk_css_variable_value_print (GtkCssVariableValue *self,
|
||||
GString *string);
|
||||
char * gtk_css_variable_value_to_string (GtkCssVariableValue *self);
|
||||
gboolean gtk_css_variable_value_equal (const GtkCssVariableValue *value1,
|
||||
const GtkCssVariableValue *value2) G_GNUC_PURE;
|
||||
GtkCssVariableValue *gtk_css_variable_value_transition (GtkCssVariableValue *start,
|
||||
GtkCssVariableValue *end,
|
||||
double progress);
|
||||
void gtk_css_variable_value_set_section (GtkCssVariableValue *self,
|
||||
GtkCssSection *section);
|
||||
void gtk_css_variable_value_taint (GtkCssVariableValue *self);
|
||||
|
||||
G_END_DECLS
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user