Compare commits
209 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 |
+1
-2
@@ -445,9 +445,8 @@ reference:
|
|||||||
--force-fallback-for=gdk-pixbuf,pango
|
--force-fallback-for=gdk-pixbuf,pango
|
||||||
-Dintrospection=enabled
|
-Dintrospection=enabled
|
||||||
-Ddocumentation=true
|
-Ddocumentation=true
|
||||||
-Dgtk_doc=true
|
|
||||||
-Dgdk-pixbuf:gtk_doc=true
|
-Dgdk-pixbuf:gtk_doc=true
|
||||||
-Dpango:gtk_doc=true
|
-Dpango:documentation=true
|
||||||
-Dbuild-demos=false
|
-Dbuild-demos=false
|
||||||
-Dbuild-examples=false
|
-Dbuild-examples=false
|
||||||
-Dbuild-tests=false
|
-Dbuild-tests=false
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ flatpak build ${builddir} meson \
|
|||||||
-Dbuild-examples=false \
|
-Dbuild-examples=false \
|
||||||
-Dintrospection=disabled \
|
-Dintrospection=disabled \
|
||||||
-Dbuild-demos=true \
|
-Dbuild-demos=true \
|
||||||
-Ddemo-profile=devel \
|
-Dprofile=devel \
|
||||||
_flatpak_build
|
_flatpak_build
|
||||||
|
|
||||||
flatpak build --env=CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA ${builddir} ninja -C _flatpak_build install
|
flatpak build --env=CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA ${builddir} ninja -C _flatpak_build install
|
||||||
|
|||||||
@@ -1,15 +1,98 @@
|
|||||||
Overview of Changes in 4.15.0, xx-xx-xxxx
|
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
|
||||||
|
|
||||||
|
* Accessibility:
|
||||||
|
- Make the gtk-demo sidebar search more accessible
|
||||||
|
- Stop emitting focus events
|
||||||
|
|
||||||
|
* GDK:
|
||||||
|
- Support XDG_ACTIVATION_TOKEN
|
||||||
|
- dmabuf: Be more defensive when importing unknown formats to GL
|
||||||
|
- dmabuf: Use narrow range for YUV
|
||||||
|
|
||||||
|
* GSK:
|
||||||
|
- 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 warnings
|
||||||
|
|
||||||
|
* 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:
|
||||||
|
Korean
|
||||||
|
Turkish
|
||||||
|
|
||||||
|
|
||||||
|
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:
|
* GtkShortcutManager:
|
||||||
- Track the propagation phase of added controllers
|
- Track the propagation phase of added controllers
|
||||||
|
|
||||||
* GtkGLArea:
|
* GtkGLArea:
|
||||||
- Produce dmabuf textures, so graphics offload is possible
|
- Produce dmabuf textures, so graphics offload is possible
|
||||||
|
|
||||||
|
* GtkTextView:
|
||||||
|
- Support text shadows
|
||||||
|
|
||||||
* GtkGraphicsOffload:
|
* GtkGraphicsOffload:
|
||||||
- Add a black-background property
|
- Add a black-background property
|
||||||
|
|
||||||
|
* Settings:
|
||||||
|
- Add a new gtk-font-rendering setting
|
||||||
|
|
||||||
* Accessibility:
|
* Accessibility:
|
||||||
- Add support for GetRangeExtents to GtkAccessibleText
|
- Add support for GetRangeExtents to GtkAccessibleText
|
||||||
- Add support for GetOffsetAtPoint to GtkAccessibleText
|
- Add support for GetOffsetAtPoint to GtkAccessibleText
|
||||||
@@ -19,6 +102,7 @@ Overview of Changes in 4.15.0, xx-xx-xxxx
|
|||||||
- Add a callback-based cursor API
|
- Add a callback-based cursor API
|
||||||
|
|
||||||
* GSK:
|
* GSK:
|
||||||
|
- Use the Vulkan renderer by default
|
||||||
- Avoid an infinite recursion with offscreens in some cases
|
- Avoid an infinite recursion with offscreens in some cases
|
||||||
- Optimize graphics offload to make it more likely that compositors
|
- Optimize graphics offload to make it more likely that compositors
|
||||||
can use direct scanout
|
can use direct scanout
|
||||||
@@ -45,13 +129,20 @@ Overview of Changes in 4.15.0, xx-xx-xxxx
|
|||||||
- Require pango 1.52
|
- Require pango 1.52
|
||||||
- Require cairo 1.18
|
- Require cairo 1.18
|
||||||
- Add a missing dependency that was causing build failures
|
- 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:
|
* Deprecations:
|
||||||
- gdk_widget_set/get_font_options
|
- gdk_widget_set/get_font_options
|
||||||
|
- gdk_wayland/x11_display_set_cursor_theme
|
||||||
|
|
||||||
* Translation updates:
|
* Translation updates:
|
||||||
Basque
|
Basque
|
||||||
Brazilian Portuguese
|
Brazilian Portuguese
|
||||||
|
British English
|
||||||
Chinese (China)
|
Chinese (China)
|
||||||
Hebrew
|
Hebrew
|
||||||
Kabyle
|
Kabyle
|
||||||
|
|||||||
@@ -186,7 +186,7 @@
|
|||||||
"config-opts" : [
|
"config-opts" : [
|
||||||
"--libdir=/app/lib",
|
"--libdir=/app/lib",
|
||||||
"-Dbuildtype=debugoptimized",
|
"-Dbuildtype=debugoptimized",
|
||||||
"-Ddemo-profile=devel"
|
"-Dprofile=devel"
|
||||||
],
|
],
|
||||||
"sources" : [
|
"sources" : [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -115,7 +115,7 @@
|
|||||||
"config-opts" : [
|
"config-opts" : [
|
||||||
"--libdir=/app/lib",
|
"--libdir=/app/lib",
|
||||||
"-Dbuildtype=debugoptimized",
|
"-Dbuildtype=debugoptimized",
|
||||||
"-Ddemo-profile=devel"
|
"-Dprofile=devel"
|
||||||
],
|
],
|
||||||
"sources" : [
|
"sources" : [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -115,7 +115,7 @@
|
|||||||
"config-opts" : [
|
"config-opts" : [
|
||||||
"--libdir=/app/lib",
|
"--libdir=/app/lib",
|
||||||
"-Dbuildtype=debugoptimized",
|
"-Dbuildtype=debugoptimized",
|
||||||
"-Ddemo-profile=devel"
|
"-Dprofile=devel"
|
||||||
],
|
],
|
||||||
"sources" : [
|
"sources" : [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -115,7 +115,7 @@
|
|||||||
"config-opts" : [
|
"config-opts" : [
|
||||||
"--libdir=/app/lib",
|
"--libdir=/app/lib",
|
||||||
"-Dbuildtype=debugoptimized",
|
"-Dbuildtype=debugoptimized",
|
||||||
"-Ddemo-profile=devel"
|
"-Dprofile=devel"
|
||||||
],
|
],
|
||||||
"sources" : [
|
"sources" : [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -363,7 +363,9 @@ insert_markup_idle (gpointer data)
|
|||||||
|
|
||||||
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
|
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;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,7 +400,9 @@ parse_markup_idle (gpointer data)
|
|||||||
do {
|
do {
|
||||||
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
|
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;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
|
|||||||
{
|
{
|
||||||
wchar_t *langname_w = NULL;
|
wchar_t *langname_w = NULL;
|
||||||
wchar_t locale_abbrev_w[9];
|
wchar_t locale_abbrev_w[9];
|
||||||
gchar *langname, *locale_abbrev, *locale, *p;
|
gchar *langname, *locale_abbrev, *locale;
|
||||||
gint i;
|
gint i;
|
||||||
const LCTYPE iso639_lctypes[] = { LOCALE_SISO639LANGNAME, LOCALE_SISO639LANGNAME2 };
|
const LCTYPE iso639_lctypes[] = { LOCALE_SISO639LANGNAME, LOCALE_SISO639LANGNAME2 };
|
||||||
GHashTable *ht_scripts_langs = (GHashTable *) param;
|
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);
|
GetLocaleInfoEx (locale_w, LOCALE_SLOCALIZEDDISPLAYNAME, langname_w, langname_size);
|
||||||
langname = g_utf16_to_utf8 (langname_w, -1, NULL, NULL, NULL);
|
langname = g_utf16_to_utf8 (langname_w, -1, NULL, NULL, NULL);
|
||||||
locale = g_utf16_to_utf8 (locale_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);
|
lang = pango_language_from_string (locale);
|
||||||
if (g_hash_table_lookup (ht_scripts_langs, lang) == NULL)
|
if (g_hash_table_lookup (ht_scripts_langs, lang) == NULL)
|
||||||
g_hash_table_insert (ht_scripts_langs, lang, langname);
|
g_hash_table_insert (ht_scripts_langs, lang, langname);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
#include "demos.h"
|
#include "demos.h"
|
||||||
#include "fontify.h"
|
#include "fontify.h"
|
||||||
@@ -923,6 +924,34 @@ clear_search (GtkSearchBar *bar)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
search_results_update (GObject *filter_model,
|
||||||
|
GParamSpec *pspec,
|
||||||
|
GtkEntry *entry)
|
||||||
|
{
|
||||||
|
gsize n_items = g_list_model_get_n_items (G_LIST_MODEL (filter_model));
|
||||||
|
|
||||||
|
if (strlen (gtk_editable_get_text (GTK_EDITABLE (entry))) > 0)
|
||||||
|
{
|
||||||
|
char *text;
|
||||||
|
|
||||||
|
if (n_items > 0)
|
||||||
|
text = g_strdup_printf (ngettext ("%ld search result", "%ld search results", n_items), n_items);
|
||||||
|
else
|
||||||
|
text = g_strdup (_("No search results"));
|
||||||
|
|
||||||
|
gtk_accessible_update_property (GTK_ACCESSIBLE (entry),
|
||||||
|
GTK_ACCESSIBLE_PROPERTY_DESCRIPTION, text,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
g_free (text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_accessible_reset_property (GTK_ACCESSIBLE (entry), GTK_ACCESSIBLE_PROPERTY_DESCRIPTION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
activate (GApplication *app)
|
activate (GApplication *app)
|
||||||
{
|
{
|
||||||
@@ -970,6 +999,7 @@ activate (GApplication *app)
|
|||||||
|
|
||||||
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
|
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
|
||||||
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);
|
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);
|
||||||
|
g_signal_connect (filter_model, "notify::n-items", G_CALLBACK (search_results_update), search_entry);
|
||||||
|
|
||||||
selection = gtk_single_selection_new (G_LIST_MODEL (filter_model));
|
selection = gtk_single_selection_new (G_LIST_MODEL (filter_model));
|
||||||
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);
|
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);
|
||||||
|
|||||||
@@ -330,6 +330,7 @@ stroke bounds of the path.
|
|||||||
| offset | `<point>` | 0 0 | non-default |
|
| offset | `<point>` | 0 0 | non-default |
|
||||||
| hint-style | `<hint style>` | slight | non-default |
|
| hint-style | `<hint style>` | slight | non-default |
|
||||||
| antialias | `<antialias>` | gray | 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.
|
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 values for hint-style are none, slight or full.
|
||||||
Possible value for antialias are none or gray.
|
Possible value for antialias are none or gray.
|
||||||
|
Possible value for hint-metrics are on or off.
|
||||||
|
|
||||||
### texture
|
### texture
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,11 @@ Title: Cairo interaction
|
|||||||
[Cairo](http://cairographics.org) is a graphics library that supports vector
|
[Cairo](http://cairographics.org) is a graphics library that supports vector
|
||||||
graphics and image compositing that can be used with GTK.
|
graphics and image compositing that can be used with GTK.
|
||||||
|
|
||||||
GDK does not wrap the Cairo API; instead it allows to create Cairo
|
GDK does not wrap the Cairo API and it is not possible to use cairo directly
|
||||||
drawing contexts which can be used to draw on [class@Gdk.Surface]s.
|
to draw on a [class@Gdk.Surface]. You can either use a
|
||||||
|
[GtkDrawingArea](../gtk4/class.DrawingArea.html) widget or
|
||||||
|
[gtk_snapshot_append_cairo](../gtk4/func.Snapshot.append_cairo.html)
|
||||||
|
for drawing with cairo in a GTK4 application.
|
||||||
|
|
||||||
Additional functions allow use [struct@Gdk.Rectangle]s with Cairo
|
Additional functions allow use [struct@Gdk.Rectangle]s with Cairo
|
||||||
and to use [struct@Gdk.RGBA], `GdkPixbuf`, and [class@Gdk.Surface]
|
and to use [struct@Gdk.RGBA], `GdkPixbuf`, and [class@Gdk.Surface]
|
||||||
|
|||||||
@@ -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: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: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: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/#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/#child-combinators) | |
|
||||||
| E ~ F | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#general-sibling-combinators) | |
|
| E ~ F | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#general-sibling-combinators) | |
|
||||||
|
|||||||
@@ -56,6 +56,30 @@ follows:
|
|||||||
1 value:
|
1 value:
|
||||||
: all
|
: 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
|
## Colors
|
||||||
|
|
||||||
GTK extends the CSS syntax with several additional ways to specify colors.
|
GTK extends the CSS syntax with several additional ways to specify colors.
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ gtk4-broadwayd
|
|||||||
The Broadway display server
|
The Broadway display server
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
|
:Version: GTK
|
||||||
|
:Manual section: 1
|
||||||
|
:Manual group: GTK commands
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
| **gtk4-broadwayd** [OPTIONS...] <DISPLAY>
|
| **gtk4-broadwayd** [OPTIONS...] <DISPLAY>
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ gtk4-builder-tool
|
|||||||
GtkBuilder File Utility
|
GtkBuilder File Utility
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
:Version: GTK
|
||||||
|
:Manual section: 1
|
||||||
|
:Manual group: GTK commands
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
| **gtk4-builder-tool** <COMMAND> [OPTIONS...] <FILE>
|
| **gtk4-builder-tool** <COMMAND> [OPTIONS...] <FILE>
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ gtk4-demo-application
|
|||||||
Demonstrate GtkApplication
|
Demonstrate GtkApplication
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
|
:Version: GTK
|
||||||
|
:Manual section: 1
|
||||||
|
:Manual group: GTK commands
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ gtk4-demo
|
|||||||
Demonstrate GTK widgets
|
Demonstrate GTK widgets
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
:Version: GTK
|
||||||
|
:Manual section: 1
|
||||||
|
:Manual group: GTK commands
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ gtk4-encode-symbolic-svg
|
|||||||
Symbolic icon conversion utility
|
Symbolic icon conversion utility
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
|
:Version: GTK
|
||||||
|
:Manual section: 1
|
||||||
|
:Manual group: GTK commands
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ gtk4-icon-browser
|
|||||||
List themed icons
|
List themed icons
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
:Version: GTK
|
||||||
|
:Manual section: 1
|
||||||
|
:Manual group: GTK commands
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ gtk4-launch
|
|||||||
Launch an application
|
Launch an application
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
:Version: GTK
|
||||||
|
:Manual section: 1
|
||||||
|
:Manual group: GTK commands
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ gtk4-node-editor
|
|||||||
Editor render nodes
|
Editor render nodes
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
:Version: GTK
|
||||||
|
:Manual section: 1
|
||||||
|
:Manual group: GTK commands
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ gtk4-path-tool
|
|||||||
GskPath Utility
|
GskPath Utility
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
:Version: GTK
|
||||||
|
:Manual section: 1
|
||||||
|
:Manual group: GTK commands
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
| **gtk4-path-tool** <COMMAND> [OPTIONS...] <PATH>
|
| **gtk4-path-tool** <COMMAND> [OPTIONS...] <PATH>
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ gtk4-query-settings
|
|||||||
Print name and value of GTK settings
|
Print name and value of GTK settings
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
||||||
|
:Version: GTK
|
||||||
|
:Manual section: 1
|
||||||
|
:Manual group: GTK commands
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ gtk4-rendernode-tool
|
|||||||
GskRenderNode Utility
|
GskRenderNode Utility
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
:Version: GTK
|
||||||
|
:Manual section: 1
|
||||||
|
:Manual group: GTK commands
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
| **gtk4-rendernode-tool** <COMMAND> [OPTIONS...] <FILE>
|
| **gtk4-rendernode-tool** <COMMAND> [OPTIONS...] <FILE>
|
||||||
@@ -45,13 +49,14 @@ without any titlebar.
|
|||||||
Rendering
|
Rendering
|
||||||
^^^^^^^^^
|
^^^^^^^^^
|
||||||
|
|
||||||
The ``render`` command saves a rendering of the rendernode as a png or tiff image.
|
The ``render`` command saves a rendering of the rendernode as a png, tiff or svg
|
||||||
The name of the file to write can be specified as a second FILE argument.
|
image or as pdf document. The name of the file to write can be specified as a second
|
||||||
|
FILE argument.
|
||||||
|
|
||||||
``--renderer=RENDERER``
|
``--renderer=RENDERER``
|
||||||
|
|
||||||
Use the given renderer. Use ``--renderer=help`` to get a information
|
Use the given renderer. Use ``--renderer=help`` to get a information
|
||||||
about poassible values for the ``RENDERER``.
|
about possible values for the ``RENDERER``.
|
||||||
|
|
||||||
Benchmark
|
Benchmark
|
||||||
^^^^^^^^^
|
^^^^^^^^^
|
||||||
@@ -93,4 +98,4 @@ exit code is 1. If the images are identical, it is 0.
|
|||||||
|
|
||||||
``--quiet``
|
``--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
|
Icon theme caching utility
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
|
:Version: GTK
|
||||||
|
:Manual section: 1
|
||||||
|
:Manual group: GTK commands
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ gtk4-widget-factory
|
|||||||
Showcase GTK widgets and styles
|
Showcase GTK widgets and styles
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
||||||
|
:Version: GTK
|
||||||
|
:Manual section: 1
|
||||||
|
:Manual group: GTK commands
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ if get_option('man-pages') and rst2man.found()
|
|||||||
[ 'gtk4-path-tool', '1', ],
|
[ 'gtk4-path-tool', '1', ],
|
||||||
]
|
]
|
||||||
|
|
||||||
if get_option('demos')
|
if get_option('build-demos')
|
||||||
rst_files += [
|
rst_files += [
|
||||||
[ 'gtk4-demo', '1', ],
|
[ 'gtk4-demo', '1', ],
|
||||||
[ 'gtk4-demo-application', '1', ],
|
[ 'gtk4-demo-application', '1', ],
|
||||||
|
|||||||
@@ -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_MIN | “aria-valuemin” | double |
|
||||||
| %GTK_ACCESSIBLE_PROPERTY_VALUE_NOW | “aria-valuenow” | double |
|
| %GTK_ACCESSIBLE_PROPERTY_VALUE_NOW | “aria-valuenow” | double |
|
||||||
| %GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT | “aria-valuetext” | translatable string |
|
| %GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT | “aria-valuetext” | translatable string |
|
||||||
|
| %GTK_ACCESSIBLE_PROPERTY_HELP_TEXT | N/A | translatable string |
|
||||||
|
|
||||||
#### List of accessible relations
|
#### 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
|
the accessible attributes of each widget, and also provides an overlay that
|
||||||
can highlight accessibility issues.
|
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:
|
It is possible to set accessible attributes in UI files as well:
|
||||||
```xml
|
```xml
|
||||||
<object class="GtkButton" id="button1">
|
<object class="GtkButton" id="button1">
|
||||||
|
|||||||
@@ -143,31 +143,50 @@ static const GdkDebugKey gdk_debug_keys[] = {
|
|||||||
|
|
||||||
#ifdef G_HAS_CONSTRUCTORS
|
#ifdef G_HAS_CONSTRUCTORS
|
||||||
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
|
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
|
||||||
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(stash_desktop_startup_notification_id)
|
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(stash_and_unset_environment)
|
||||||
#endif
|
#endif
|
||||||
G_DEFINE_CONSTRUCTOR(stash_desktop_startup_notification_id)
|
G_DEFINE_CONSTRUCTOR(stash_and_unset_environment)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char *startup_notification_id = NULL;
|
static char *startup_notification_id = NULL;
|
||||||
|
static char *xdg_activation_token = NULL;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
stash_desktop_startup_notification_id (void)
|
stash_and_unset_environment (void)
|
||||||
{
|
{
|
||||||
const char *desktop_startup_id;
|
/* Copies environment variables and unsets them so they won't be inherited by
|
||||||
|
|
||||||
desktop_startup_id = g_getenv ("DESKTOP_STARTUP_ID");
|
|
||||||
if (desktop_startup_id && *desktop_startup_id != '\0')
|
|
||||||
{
|
|
||||||
if (!g_utf8_validate (desktop_startup_id, -1, NULL))
|
|
||||||
g_warning ("DESKTOP_STARTUP_ID contains invalid UTF-8");
|
|
||||||
else
|
|
||||||
startup_notification_id = g_strdup (desktop_startup_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clear the environment variable so it won't be inherited by
|
|
||||||
* child processes and confuse things.
|
* child processes and confuse things.
|
||||||
|
*
|
||||||
|
* Changing environment variables can be racy so we try to do this as early as
|
||||||
|
* possible in the program flow and before any printing that might involve
|
||||||
|
* environment variables.
|
||||||
*/
|
*/
|
||||||
g_unsetenv ("DESKTOP_STARTUP_ID");
|
struct {
|
||||||
|
const char *key;
|
||||||
|
char **dst;
|
||||||
|
} vars[] = {
|
||||||
|
{ "DESKTOP_STARTUP_ID", &startup_notification_id },
|
||||||
|
{ "XDG_ACTIVATION_TOKEN", &xdg_activation_token },
|
||||||
|
};
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (vars); i++)
|
||||||
|
*vars[i].dst = g_strdup (g_getenv (vars[i].key));
|
||||||
|
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (vars); i++)
|
||||||
|
g_unsetenv (vars[i].key);
|
||||||
|
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (vars); i++)
|
||||||
|
{
|
||||||
|
if (*vars[i].dst == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!g_utf8_validate (*vars[i].dst, -1, NULL))
|
||||||
|
{
|
||||||
|
g_warning ("%s contains invalid UTF-8", vars[i].key);
|
||||||
|
g_clear_pointer (vars[i].dst, g_free);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
@@ -292,7 +311,7 @@ gdk_pre_parse (void)
|
|||||||
gdk_gl_backend_use (GDK_GL_WGL);
|
gdk_gl_backend_use (GDK_GL_WGL);
|
||||||
|
|
||||||
#ifndef G_HAS_CONSTRUCTORS
|
#ifndef G_HAS_CONSTRUCTORS
|
||||||
stash_desktop_startup_notification_id ();
|
stash_and_unset_environment ();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,15 +345,20 @@ gdk_display_open_default (void)
|
|||||||
/*< private >
|
/*< private >
|
||||||
* gdk_get_startup_notification_id:
|
* gdk_get_startup_notification_id:
|
||||||
*
|
*
|
||||||
* Returns the original value of the DESKTOP_STARTUP_ID environment
|
* Returns the original value of the XDG_ACTIVATION_TOKEN environment
|
||||||
* variable if it was defined and valid, or %NULL otherwise.
|
* variable if it was defined and valid, otherwise it returns the original
|
||||||
|
* value of the DESKTOP_STARTUP_ID environment variable if it was defined
|
||||||
|
* and valid, or %NULL if neither of them were defined and valid.
|
||||||
*
|
*
|
||||||
* Returns: (nullable) (transfer none): the original value of the
|
* Returns: (nullable) (transfer none): the original value of the
|
||||||
* DESKTOP_STARTUP_ID environment variable
|
* XDG_ACTIVATION_TOKEN or DESKTOP_STARTUP_ID environment variable
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
gdk_get_startup_notification_id (void)
|
gdk_get_startup_notification_id (void)
|
||||||
{
|
{
|
||||||
|
if (xdg_activation_token)
|
||||||
|
return xdg_activation_token;
|
||||||
|
|
||||||
return startup_notification_id;
|
return startup_notification_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -144,8 +144,8 @@ struct _YUVCoefficients
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* multiplied by 65536 */
|
/* multiplied by 65536 */
|
||||||
//static const YUVCoefficients itu601_narrow = { 104597, -25675, -53279, 132201 };
|
static const YUVCoefficients itu601_narrow = { 104597, -25675, -53279, 132201 };
|
||||||
static const YUVCoefficients itu601_wide = { 74711, -25864, -38050, 133176 };
|
//static const YUVCoefficients itu601_wide = { 74711, -25864, -38050, 133176 };
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
get_uv_values (const YUVCoefficients *coeffs,
|
get_uv_values (const YUVCoefficients *coeffs,
|
||||||
@@ -229,7 +229,7 @@ download_nv12 (guchar *dst_data,
|
|||||||
int r, g, b;
|
int r, g, b;
|
||||||
gsize xs, ys;
|
gsize xs, ys;
|
||||||
|
|
||||||
get_uv_values (&itu601_wide, uv_data[x / X_SUB * 2 + U], uv_data[x / X_SUB * 2 + V], &r, &g, &b);
|
get_uv_values (&itu601_narrow, uv_data[x / X_SUB * 2 + U], uv_data[x / X_SUB * 2 + V], &r, &g, &b);
|
||||||
|
|
||||||
for (ys = 0; ys < Y_SUB && y + ys < height; ys++)
|
for (ys = 0; ys < Y_SUB && y + ys < height; ys++)
|
||||||
for (xs = 0; xs < X_SUB && x + xs < width; xs++)
|
for (xs = 0; xs < X_SUB && x + xs < width; xs++)
|
||||||
@@ -309,7 +309,7 @@ download_yuv_3 (guchar *dst_data,
|
|||||||
int r, g, b;
|
int r, g, b;
|
||||||
gsize xs, ys;
|
gsize xs, ys;
|
||||||
|
|
||||||
get_uv_values (&itu601_wide, u_data[x / X_SUB], v_data[x / X_SUB], &r, &g, &b);
|
get_uv_values (&itu601_narrow, u_data[x / X_SUB], v_data[x / X_SUB], &r, &g, &b);
|
||||||
|
|
||||||
for (ys = 0; ys < Y_SUB && y + ys < height; ys++)
|
for (ys = 0; ys < Y_SUB && y + ys < height; ys++)
|
||||||
for (xs = 0; xs < X_SUB && x + xs < width; xs++)
|
for (xs = 0; xs < X_SUB && x + xs < width; xs++)
|
||||||
@@ -365,7 +365,7 @@ download_yuyv (guchar *dst_data,
|
|||||||
{
|
{
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
|
|
||||||
get_uv_values (&itu601_wide, src_data[2 * x + U], src_data[2 * x + V], &r, &g, &b);
|
get_uv_values (&itu601_narrow, src_data[2 * x + U], src_data[2 * x + V], &r, &g, &b);
|
||||||
set_rgb_values (&dst_data[3 * x], src_data[2 * x + Y1], r, g, b);
|
set_rgb_values (&dst_data[3 * x], src_data[2 * x + Y1], r, g, b);
|
||||||
if (x + 1 < width)
|
if (x + 1 < width)
|
||||||
set_rgb_values (&dst_data[3 * (x + 1)], src_data[2 * x + Y2], r, g, b);
|
set_rgb_values (&dst_data[3 * (x + 1)], src_data[2 * x + Y2], r, g, b);
|
||||||
|
|||||||
+8
-2
@@ -163,6 +163,8 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
previous = gdk_gl_context_get_current ();
|
previous = gdk_gl_context_get_current ();
|
||||||
|
if (previous)
|
||||||
|
g_object_ref (previous);
|
||||||
formats = gdk_dmabuf_formats_builder_new ();
|
formats = gdk_dmabuf_formats_builder_new ();
|
||||||
external = gdk_dmabuf_formats_builder_new ();
|
external = gdk_dmabuf_formats_builder_new ();
|
||||||
|
|
||||||
@@ -194,7 +196,10 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (previous)
|
if (previous)
|
||||||
gdk_gl_context_make_current (previous);
|
{
|
||||||
|
gdk_gl_context_make_current (previous);
|
||||||
|
g_object_unref (previous);
|
||||||
|
}
|
||||||
|
|
||||||
return GDK_DMABUF_DOWNLOADER (renderer);
|
return GDK_DMABUF_DOWNLOADER (renderer);
|
||||||
}
|
}
|
||||||
@@ -239,7 +244,7 @@ gdk_dmabuf_egl_create_image (GdkDisplay *display,
|
|||||||
attribs[i++] = EGL_YUV_COLOR_SPACE_HINT_EXT;
|
attribs[i++] = EGL_YUV_COLOR_SPACE_HINT_EXT;
|
||||||
attribs[i++] = EGL_ITU_REC601_EXT;
|
attribs[i++] = EGL_ITU_REC601_EXT;
|
||||||
attribs[i++] = EGL_SAMPLE_RANGE_HINT_EXT;
|
attribs[i++] = EGL_SAMPLE_RANGE_HINT_EXT;
|
||||||
attribs[i++] = EGL_YUV_FULL_RANGE_EXT;
|
attribs[i++] = EGL_YUV_NARROW_RANGE_EXT;
|
||||||
|
|
||||||
#define ADD_PLANE(plane) \
|
#define ADD_PLANE(plane) \
|
||||||
{ \
|
{ \
|
||||||
@@ -265,6 +270,7 @@ gdk_dmabuf_egl_create_image (GdkDisplay *display,
|
|||||||
if (dmabuf->n_planes > 3) ADD_PLANE (3);
|
if (dmabuf->n_planes > 3) ADD_PLANE (3);
|
||||||
|
|
||||||
attribs[i++] = EGL_NONE;
|
attribs[i++] = EGL_NONE;
|
||||||
|
g_assert (i < G_N_ELEMENTS (attribs));
|
||||||
|
|
||||||
image = eglCreateImageKHR (egl_display,
|
image = eglCreateImageKHR (egl_display,
|
||||||
EGL_NO_CONTEXT,
|
EGL_NO_CONTEXT,
|
||||||
|
|||||||
@@ -192,13 +192,6 @@ compute_smooth_frame_time (GdkFrameClock *clock,
|
|||||||
* and new_frame_time >= old_frame_time. */
|
* and new_frame_time >= old_frame_time. */
|
||||||
frames_passed = (new_frame_time - smoothed_frame_time_base + frame_interval / 2) / frame_interval;
|
frames_passed = (new_frame_time - smoothed_frame_time_base + frame_interval / 2) / frame_interval;
|
||||||
|
|
||||||
if (frames_passed > 1)
|
|
||||||
gdk_profiler_add_markf ((smoothed_frame_time_base - (frame_interval * (frames_passed-1))) * 1000L,
|
|
||||||
frame_interval * (frames_passed-1) * 1000L,
|
|
||||||
"Dropped Frames",
|
|
||||||
"%u frames may have been dropped",
|
|
||||||
frames_passed-1);
|
|
||||||
|
|
||||||
/* We use an approximately whole number of frames in the future from
|
/* We use an approximately whole number of frames in the future from
|
||||||
* last smoothed frame time. This way we avoid minor jitter in the
|
* last smoothed frame time. This way we avoid minor jitter in the
|
||||||
* frame times making the animation speed uneven, but still animate
|
* frame times making the animation speed uneven, but still animate
|
||||||
|
|||||||
+72
-35
@@ -1956,8 +1956,6 @@ gdk_gl_context_get_glsl_version_string (GdkGLContext *self)
|
|||||||
return "#version 310 es";
|
return "#version 310 es";
|
||||||
else if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
|
else if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
|
||||||
return "#version 300 es";
|
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
|
else
|
||||||
return "#version 100";
|
return "#version 100";
|
||||||
}
|
}
|
||||||
@@ -2198,12 +2196,78 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
|
|||||||
|
|
||||||
gdk_display_init_dmabuf (display);
|
gdk_display_init_dmabuf (display);
|
||||||
|
|
||||||
if (!gdk_dmabuf_formats_contains (display->egl_external_formats, dmabuf->fourcc, dmabuf->modifier))
|
if (gdk_dmabuf_formats_contains (display->egl_dmabuf_formats, dmabuf->fourcc, dmabuf->modifier))
|
||||||
{
|
{
|
||||||
|
/* This is the path for modern drivers that support modifiers */
|
||||||
|
|
||||||
|
if (!gdk_dmabuf_formats_contains (display->egl_external_formats, dmabuf->fourcc, dmabuf->modifier))
|
||||||
|
{
|
||||||
|
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
|
||||||
|
width, height,
|
||||||
|
dmabuf,
|
||||||
|
GL_TEXTURE_2D);
|
||||||
|
if (texture_id == 0)
|
||||||
|
{
|
||||||
|
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||||
|
"Import of %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf failed",
|
||||||
|
width, height,
|
||||||
|
(char *) &dmabuf->fourcc, dmabuf->modifier);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||||
|
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_2D texture",
|
||||||
|
width, height,
|
||||||
|
(char *) &dmabuf->fourcc, dmabuf->modifier);
|
||||||
|
*external = FALSE;
|
||||||
|
return texture_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gdk_gl_context_get_use_es (self))
|
||||||
|
{
|
||||||
|
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||||
|
"Can't import external_only %.4s:%#" G_GINT64_MODIFIER "x outside of GLES",
|
||||||
|
(char *) &dmabuf->fourcc, dmabuf->modifier);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
|
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
|
||||||
width, height,
|
width, height,
|
||||||
dmabuf,
|
dmabuf,
|
||||||
GL_TEXTURE_2D);
|
GL_TEXTURE_EXTERNAL_OES);
|
||||||
|
if (texture_id == 0)
|
||||||
|
{
|
||||||
|
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||||
|
"Import of external_only %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf failed",
|
||||||
|
width, height,
|
||||||
|
(char *) &dmabuf->fourcc, dmabuf->modifier);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||||
|
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_EXTERNAL_OES texture",
|
||||||
|
width, height,
|
||||||
|
(char *) &dmabuf->fourcc, dmabuf->modifier);
|
||||||
|
*external = TRUE;
|
||||||
|
return texture_id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* This is the opportunistic path.
|
||||||
|
* We hit it both for drivers that do not support modifiers as well as for dmabufs
|
||||||
|
* that the driver did not explicitly advertise. */
|
||||||
|
int target;
|
||||||
|
|
||||||
|
if (gdk_gl_context_get_use_es (self))
|
||||||
|
target = GL_TEXTURE_EXTERNAL_OES;
|
||||||
|
else
|
||||||
|
target = GL_TEXTURE_2D;
|
||||||
|
|
||||||
|
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
|
||||||
|
width, height,
|
||||||
|
dmabuf,
|
||||||
|
target);
|
||||||
|
|
||||||
if (texture_id == 0)
|
if (texture_id == 0)
|
||||||
{
|
{
|
||||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||||
@@ -2214,40 +2278,13 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||||
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_2D texture",
|
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as %s texture",
|
||||||
width, height,
|
width, height,
|
||||||
(char *) &dmabuf->fourcc, dmabuf->modifier);
|
(char *) &dmabuf->fourcc, dmabuf->modifier,
|
||||||
*external = FALSE;
|
target == GL_TEXTURE_EXTERNAL_OES ? "GL_TEXTURE_EXTERNAL_OES" : "GL_TEXTURE_2D");
|
||||||
|
*external = target == GL_TEXTURE_EXTERNAL_OES;
|
||||||
return texture_id;
|
return texture_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gdk_gl_context_get_use_es (self))
|
|
||||||
{
|
|
||||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
|
||||||
"Can't import external_only %.4s:%#" G_GINT64_MODIFIER "x outside of GLES",
|
|
||||||
(char *) &dmabuf->fourcc, dmabuf->modifier);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
|
|
||||||
width, height,
|
|
||||||
dmabuf,
|
|
||||||
GL_TEXTURE_EXTERNAL_OES);
|
|
||||||
if (texture_id == 0)
|
|
||||||
{
|
|
||||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
|
||||||
"Import of external_only %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf failed",
|
|
||||||
width, height,
|
|
||||||
(char *) &dmabuf->fourcc, dmabuf->modifier);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
|
||||||
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_EXTERNAL_OES texture",
|
|
||||||
width, height,
|
|
||||||
(char *) &dmabuf->fourcc, dmabuf->modifier);
|
|
||||||
*external = TRUE;
|
|
||||||
return texture_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
|||||||
+1
-1
@@ -563,7 +563,7 @@ gdk_texture_new_from_bytes_internal (GBytes *bytes,
|
|||||||
{
|
{
|
||||||
if (gdk_is_png (bytes))
|
if (gdk_is_png (bytes))
|
||||||
{
|
{
|
||||||
return gdk_load_png (bytes, error);
|
return gdk_load_png (bytes, NULL, error);
|
||||||
}
|
}
|
||||||
else if (gdk_is_jpeg (bytes))
|
else if (gdk_is_jpeg (bytes))
|
||||||
{
|
{
|
||||||
|
|||||||
+45
-10
@@ -29,6 +29,7 @@
|
|||||||
#include "gdkdmabuffourccprivate.h"
|
#include "gdkdmabuffourccprivate.h"
|
||||||
#include "gdkdmabuftextureprivate.h"
|
#include "gdkdmabuftextureprivate.h"
|
||||||
#include "gdkdisplayprivate.h"
|
#include "gdkdisplayprivate.h"
|
||||||
|
#include "gdkprofilerprivate.h"
|
||||||
#include <glib/gi18n-lib.h>
|
#include <glib/gi18n-lib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@@ -631,6 +632,7 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
|
|||||||
{
|
{
|
||||||
GdkVulkanContext *context = GDK_VULKAN_CONTEXT (draw_context);
|
GdkVulkanContext *context = GDK_VULKAN_CONTEXT (draw_context);
|
||||||
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
|
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
|
||||||
|
VkResult acquire_result;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
if (depth != priv->current_format)
|
if (depth != priv->current_format)
|
||||||
@@ -652,12 +654,29 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
|
|||||||
cairo_region_union (priv->regions[i], region);
|
cairo_region_union (priv->regions[i], region);
|
||||||
}
|
}
|
||||||
|
|
||||||
GDK_VK_CHECK (vkAcquireNextImageKHR, gdk_vulkan_context_get_device (context),
|
acquire_next_image:
|
||||||
priv->swapchain,
|
acquire_result = GDK_VK_CHECK (vkAcquireNextImageKHR, gdk_vulkan_context_get_device (context),
|
||||||
UINT64_MAX,
|
priv->swapchain,
|
||||||
priv->draw_semaphore,
|
UINT64_MAX,
|
||||||
VK_NULL_HANDLE,
|
priv->draw_semaphore,
|
||||||
&priv->draw_index);
|
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]);
|
cairo_region_union (region, priv->regions[priv->draw_index]);
|
||||||
}
|
}
|
||||||
@@ -1110,6 +1129,7 @@ gdk_display_load_pipeline_cache (GdkDisplay *display)
|
|||||||
static gboolean
|
static gboolean
|
||||||
gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
||||||
{
|
{
|
||||||
|
G_GNUC_UNUSED gint64 begin_time = GDK_PROFILER_CURRENT_TIME;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
VkDevice device;
|
VkDevice device;
|
||||||
VkPipelineCache cache;
|
VkPipelineCache cache;
|
||||||
@@ -1124,14 +1144,13 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
|||||||
GDK_VK_CHECK (vkGetPipelineCacheData, device, cache, &size, NULL);
|
GDK_VK_CHECK (vkGetPipelineCacheData, device, cache, &size, NULL);
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (size == display->vk_pipeline_cache_size)
|
if (size == display->vk_pipeline_cache_size)
|
||||||
{
|
{
|
||||||
GDK_DEBUG (VULKAN, "pipeline cache size (%zu bytes) unchanged, skipping save", size);
|
GDK_DEBUG (VULKAN, "pipeline cache size (%zu bytes) unchanged, skipping save", size);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
data = g_malloc (size);
|
data = g_malloc (size);
|
||||||
if (GDK_VK_CHECK (vkGetPipelineCacheData, device, cache, &size, data) != VK_SUCCESS)
|
if (GDK_VK_CHECK (vkGetPipelineCacheData, device, cache, &size, data) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
@@ -1151,7 +1170,7 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
|||||||
|
|
||||||
file = gdk_vulkan_get_pipeline_cache_file (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,
|
if (!g_file_replace_contents (file,
|
||||||
data,
|
data,
|
||||||
@@ -1166,7 +1185,7 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
|||||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WRONG_ETAG))
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WRONG_ETAG))
|
||||||
{
|
{
|
||||||
VkPipelineCache new_cache;
|
VkPipelineCache new_cache;
|
||||||
|
|
||||||
GDK_DEBUG (VULKAN, "Pipeline cache file modified, merging into current");
|
GDK_DEBUG (VULKAN, "Pipeline cache file modified, merging into current");
|
||||||
new_cache = gdk_display_load_pipeline_cache (display);
|
new_cache = gdk_display_load_pipeline_cache (display);
|
||||||
if (new_cache)
|
if (new_cache)
|
||||||
@@ -1193,10 +1212,15 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
|||||||
return FALSE;
|
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_object_unref (file);
|
||||||
g_free (data);
|
g_free (data);
|
||||||
g_free (display->vk_pipeline_cache_etag);
|
g_free (display->vk_pipeline_cache_etag);
|
||||||
display->vk_pipeline_cache_etag = etag;
|
display->vk_pipeline_cache_etag = etag;
|
||||||
|
display->vk_pipeline_cache_size = size;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -1236,6 +1260,11 @@ gdk_display_create_pipeline_cache (GdkDisplay *display)
|
|||||||
},
|
},
|
||||||
NULL,
|
NULL,
|
||||||
&display->vk_pipeline_cache);
|
&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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1345,6 +1374,7 @@ static gboolean
|
|||||||
gdk_display_create_vulkan_device (GdkDisplay *display,
|
gdk_display_create_vulkan_device (GdkDisplay *display,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||||
uint32_t i, j, k;
|
uint32_t i, j, k;
|
||||||
const char *override;
|
const char *override;
|
||||||
gboolean list_devices;
|
gboolean list_devices;
|
||||||
@@ -1553,6 +1583,8 @@ gdk_display_create_vulkan_device (GdkDisplay *display,
|
|||||||
"Hum, what? This should not happen.")));
|
"Hum, what? This should not happen.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gdk_profiler_end_mark (start_time, "Create Vulkan device", NULL);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1591,6 +1623,7 @@ static gboolean
|
|||||||
gdk_display_create_vulkan_instance (GdkDisplay *display,
|
gdk_display_create_vulkan_instance (GdkDisplay *display,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
GPtrArray *used_extensions;
|
GPtrArray *used_extensions;
|
||||||
GPtrArray *used_layers;
|
GPtrArray *used_layers;
|
||||||
@@ -1752,6 +1785,8 @@ gdk_display_create_vulkan_instance (GdkDisplay *display,
|
|||||||
|
|
||||||
display->vk_shader_modules = g_hash_table_new (g_str_hash, g_str_equal);
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-3
@@ -127,15 +127,18 @@ png_simple_warning_callback (png_structp png,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* }}} */
|
/* }}} */
|
||||||
/* {{{ Public API */
|
/* {{{ Public API */
|
||||||
|
|
||||||
GdkTexture *
|
GdkTexture *
|
||||||
gdk_load_png (GBytes *bytes,
|
gdk_load_png (GBytes *bytes,
|
||||||
GError **error)
|
GHashTable *options,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
png_io io;
|
png_io io;
|
||||||
png_struct *png = NULL;
|
png_struct *png = NULL;
|
||||||
png_info *info;
|
png_info *info;
|
||||||
|
png_textp text;
|
||||||
|
int num_texts;
|
||||||
guint width, height;
|
guint width, height;
|
||||||
gsize i, stride;
|
gsize i, stride;
|
||||||
int depth, color_type;
|
int depth, color_type;
|
||||||
@@ -297,6 +300,17 @@ gdk_load_png (GBytes *bytes,
|
|||||||
texture = gdk_memory_texture_new (width, height, format, out_bytes, stride);
|
texture = gdk_memory_texture_new (width, height, format, out_bytes, stride);
|
||||||
g_bytes_unref (out_bytes);
|
g_bytes_unref (out_bytes);
|
||||||
|
|
||||||
|
if (options && png_get_text (png, info, &text, &num_texts))
|
||||||
|
{
|
||||||
|
for (i = 0; i < num_texts; i++)
|
||||||
|
{
|
||||||
|
if (text->compression != -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
g_hash_table_insert (options, g_strdup (text->key), g_strdup (text->text));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_free (row_pointers);
|
g_free (row_pointers);
|
||||||
png_destroy_read_struct (&png, &info, NULL);
|
png_destroy_read_struct (&png, &info, NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#define PNG_SIGNATURE "\x89PNG"
|
#define PNG_SIGNATURE "\x89PNG"
|
||||||
|
|
||||||
GdkTexture *gdk_load_png (GBytes *bytes,
|
GdkTexture *gdk_load_png (GBytes *bytes,
|
||||||
|
GHashTable *options,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
GBytes *gdk_save_png (GdkTexture *texture);
|
GBytes *gdk_save_png (GdkTexture *texture);
|
||||||
|
|||||||
@@ -161,7 +161,8 @@ void _gdk_macos_display_send_event (GdkMacosDisp
|
|||||||
void _gdk_macos_display_warp_pointer (GdkMacosDisplay *self,
|
void _gdk_macos_display_warp_pointer (GdkMacosDisplay *self,
|
||||||
int x,
|
int x,
|
||||||
int y);
|
int y);
|
||||||
NSEvent *_gdk_macos_display_get_nsevent (GdkEvent *event);
|
NSEvent *_gdk_macos_display_get_matching_nsevent (GdkEvent *event);
|
||||||
|
NSEvent *_gdk_macos_display_get_exact_nsevent (GdkEvent *event);
|
||||||
NSEvent *_gdk_macos_display_get_last_nsevent (void);
|
NSEvent *_gdk_macos_display_get_last_nsevent (void);
|
||||||
GdkDrag *_gdk_macos_display_find_drag (GdkMacosDisplay *self,
|
GdkDrag *_gdk_macos_display_find_drag (GdkMacosDisplay *self,
|
||||||
NSInteger sequence_number);
|
NSInteger sequence_number);
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ gdk_macos_display_get_setting (GdkDisplay *display,
|
|||||||
const char *setting,
|
const char *setting,
|
||||||
GValue *value)
|
GValue *value)
|
||||||
{
|
{
|
||||||
|
if (gdk_display_get_debug_flags (display) & GDK_DEBUG_DEFAULT_SETTINGS)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
return _gdk_macos_display_get_setting (GDK_MACOS_DISPLAY (display), setting, value);
|
return _gdk_macos_display_get_setting (GDK_MACOS_DISPLAY (display), setting, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -991,17 +994,41 @@ _gdk_macos_display_warp_pointer (GdkMacosDisplay *self,
|
|||||||
CGWarpMouseCursorPosition ((CGPoint) { x, y });
|
CGWarpMouseCursorPosition ((CGPoint) { x, y });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Find the matching `NSEvent` for an `GdkEvent`. This function
|
||||||
|
* return the `NSEvent`, also for rewritten `GdkEvent`'s.
|
||||||
|
*/
|
||||||
NSEvent *
|
NSEvent *
|
||||||
_gdk_macos_display_get_nsevent (GdkEvent *event)
|
_gdk_macos_display_get_matching_nsevent (GdkEvent *event)
|
||||||
{
|
{
|
||||||
for (const GList *iter = event_map.head; iter; iter = iter->next)
|
for (GList *iter = event_map.head; iter; iter = iter->next)
|
||||||
{
|
{
|
||||||
const GdkToNSEventMap *map = iter->data;
|
GdkToNSEventMap *map = iter->data;
|
||||||
|
|
||||||
if (map->gdk_event->event_type == event->event_type &&
|
if (map->gdk_event->event_type == event->event_type &&
|
||||||
map->gdk_event->device == event->device &&
|
map->gdk_event->device == event->device &&
|
||||||
map->gdk_event->time == event->time)
|
map->gdk_event->time == event->time)
|
||||||
return map->nsevent;
|
{
|
||||||
|
return map->nsevent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find the matching `NSEvent` for the original `GdkEvent`.
|
||||||
|
* If an event was rewritten, it returns `NULL`.
|
||||||
|
*/
|
||||||
|
NSEvent *
|
||||||
|
_gdk_macos_display_get_exact_nsevent (GdkEvent *event)
|
||||||
|
{
|
||||||
|
for (GList *iter = event_map.head; iter; iter = iter->next)
|
||||||
|
{
|
||||||
|
GdkToNSEventMap *map = iter->data;
|
||||||
|
|
||||||
|
if (map->gdk_event == event)
|
||||||
|
{
|
||||||
|
return map->nsevent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -738,7 +738,7 @@ gdk_macos_event_source_dispatch (GSource *source,
|
|||||||
|
|
||||||
if (!handled)
|
if (!handled)
|
||||||
{
|
{
|
||||||
NSEvent *nsevent = _gdk_macos_display_get_nsevent (event);
|
NSEvent *nsevent = _gdk_macos_display_get_exact_nsevent (event);
|
||||||
if (nsevent != NULL)
|
if (nsevent != NULL)
|
||||||
[NSApp sendEvent: nsevent];
|
[NSApp sendEvent: nsevent];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland);
|
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)
|
G_DEFINE_TYPE (GdkWaylandDisplay, gdk_wayland_display, GDK_TYPE_DISPLAY)
|
||||||
|
|
||||||
@@ -284,93 +287,6 @@ static const struct wl_shm_listener wl_shm_listener = {
|
|||||||
wl_shm_format
|
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 = *(dev_t *)device->data;
|
|
||||||
|
|
||||||
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 = *(dev_t *)device->data;
|
|
||||||
|
|
||||||
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
|
static void
|
||||||
server_decoration_manager_default_mode (void *data,
|
server_decoration_manager_default_mode (void *data,
|
||||||
struct org_kde_kwin_server_decoration_manager *manager,
|
struct org_kde_kwin_server_decoration_manager *manager,
|
||||||
@@ -437,7 +353,7 @@ gdk_registry_handle_global (void *data,
|
|||||||
{
|
{
|
||||||
display_wayland->compositor =
|
display_wayland->compositor =
|
||||||
wl_registry_bind (display_wayland->wl_registry, id,
|
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)
|
else if (strcmp (interface, "wl_shm") == 0)
|
||||||
{
|
{
|
||||||
@@ -447,12 +363,14 @@ gdk_registry_handle_global (void *data,
|
|||||||
}
|
}
|
||||||
else if (strcmp (interface, "zwp_linux_dmabuf_v1") == 0 && version >= 4)
|
else if (strcmp (interface, "zwp_linux_dmabuf_v1") == 0 && version >= 4)
|
||||||
{
|
{
|
||||||
|
struct zwp_linux_dmabuf_feedback_v1 *feedback;
|
||||||
|
|
||||||
display_wayland->linux_dmabuf =
|
display_wayland->linux_dmabuf =
|
||||||
wl_registry_bind (display_wayland->wl_registry, id, &zwp_linux_dmabuf_v1_interface, version);
|
wl_registry_bind (display_wayland->wl_registry, id, &zwp_linux_dmabuf_v1_interface, version);
|
||||||
display_wayland->linux_dmabuf_feedback =
|
feedback = zwp_linux_dmabuf_v1_get_default_feedback (display_wayland->linux_dmabuf);
|
||||||
zwp_linux_dmabuf_v1_get_default_feedback (display_wayland->linux_dmabuf);
|
display_wayland->dmabuf_formats_info = dmabuf_formats_info_new (GDK_DISPLAY (display_wayland),
|
||||||
zwp_linux_dmabuf_feedback_v1_add_listener (display_wayland->linux_dmabuf_feedback,
|
"default",
|
||||||
&linux_dmabuf_feedback_listener, display_wayland);
|
feedback);
|
||||||
_gdk_wayland_display_async_roundtrip (display_wayland);
|
_gdk_wayland_display_async_roundtrip (display_wayland);
|
||||||
}
|
}
|
||||||
else if (strcmp (interface, "xdg_wm_base") == 0)
|
else if (strcmp (interface, "xdg_wm_base") == 0)
|
||||||
@@ -825,9 +743,7 @@ gdk_wayland_display_dispose (GObject *object)
|
|||||||
g_clear_pointer (&display_wayland->presentation, wp_presentation_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->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, zwp_linux_dmabuf_v1_destroy);
|
||||||
g_clear_pointer (&display_wayland->linux_dmabuf_feedback, zwp_linux_dmabuf_feedback_v1_destroy);
|
g_clear_pointer (&display_wayland->dmabuf_formats_info, dmabuf_formats_info_free);
|
||||||
if (display_wayland->linux_dmabuf_formats)
|
|
||||||
munmap (display_wayland->linux_dmabuf_formats, display_wayland->linux_dmabuf_n_formats * 16);
|
|
||||||
|
|
||||||
g_clear_pointer (&display_wayland->shm, wl_shm_destroy);
|
g_clear_pointer (&display_wayland->shm, wl_shm_destroy);
|
||||||
g_clear_pointer (&display_wayland->wl_registry, wl_registry_destroy);
|
g_clear_pointer (&display_wayland->wl_registry, wl_registry_destroy);
|
||||||
@@ -1129,7 +1045,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
|||||||
display_class->get_monitors = gdk_wayland_display_get_monitors;
|
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_monitor_at_surface = gdk_wayland_display_get_monitor_at_surface;
|
||||||
display_class->get_setting = gdk_wayland_display_get_setting;
|
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
|
static void
|
||||||
@@ -1202,11 +1118,22 @@ get_cursor_theme (GdkWaylandDisplay *display_wayland,
|
|||||||
* @size: the size to use for cursors
|
* @size: the size to use for cursors
|
||||||
*
|
*
|
||||||
* Sets the cursor theme for the given @display.
|
* 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
|
void
|
||||||
gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
|
gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
|
||||||
const char *name,
|
const char *name,
|
||||||
int size)
|
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);
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY(display);
|
||||||
struct wl_cursor_theme *theme;
|
struct wl_cursor_theme *theme;
|
||||||
@@ -1275,7 +1202,7 @@ _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland)
|
|||||||
else
|
else
|
||||||
name = "default";
|
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);
|
g_value_unset (&v);
|
||||||
|
|
||||||
gdk_profiler_end_mark (before, "Wayland cursor theme load", NULL);
|
gdk_profiler_end_mark (before, "Wayland cursor theme load", NULL);
|
||||||
@@ -1903,6 +1830,7 @@ apply_portal_setting (TranslationEntry *entry,
|
|||||||
entry->fallback.s = g_intern_string (g_variant_get_string (value, NULL));
|
entry->fallback.s = g_intern_string (g_variant_get_string (value, NULL));
|
||||||
break;
|
break;
|
||||||
case G_TYPE_INT:
|
case G_TYPE_INT:
|
||||||
|
case G_TYPE_ENUM:
|
||||||
entry->fallback.i = g_variant_get_int32 (value);
|
entry->fallback.i = g_variant_get_int32 (value);
|
||||||
break;
|
break;
|
||||||
case G_TYPE_BOOLEAN:
|
case G_TYPE_BOOLEAN:
|
||||||
@@ -2152,6 +2080,9 @@ set_value_from_entry (GdkDisplay *display,
|
|||||||
case G_TYPE_BOOLEAN:
|
case G_TYPE_BOOLEAN:
|
||||||
g_value_set_boolean (value, entry->fallback.b);
|
g_value_set_boolean (value, entry->fallback.b);
|
||||||
break;
|
break;
|
||||||
|
case G_TYPE_ENUM:
|
||||||
|
g_value_set_enum (value, entry->fallback.i);
|
||||||
|
break;
|
||||||
case G_TYPE_NONE:
|
case G_TYPE_NONE:
|
||||||
if (g_str_equal (entry->setting, "gtk-fontconfig-timestamp"))
|
if (g_str_equal (entry->setting, "gtk-fontconfig-timestamp"))
|
||||||
g_value_set_uint (value, (guint)entry->fallback.i);
|
g_value_set_uint (value, (guint)entry->fallback.i);
|
||||||
|
|||||||
@@ -49,6 +49,7 @@
|
|||||||
|
|
||||||
#include "gdkdisplayprivate.h"
|
#include "gdkdisplayprivate.h"
|
||||||
#include "gdkwaylanddevice.h"
|
#include "gdkwaylanddevice.h"
|
||||||
|
#include "gdkdmabuf-wayland-private.h"
|
||||||
#include "cursor/wayland-cursor.h"
|
#include "cursor/wayland-cursor.h"
|
||||||
|
|
||||||
#include <epoxy/egl.h>
|
#include <epoxy/egl.h>
|
||||||
@@ -73,13 +74,6 @@ typedef enum _GdkWaylandShellVariant
|
|||||||
GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6
|
GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6
|
||||||
} GdkWaylandShellVariant;
|
} GdkWaylandShellVariant;
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t fourcc;
|
|
||||||
uint32_t padding;
|
|
||||||
uint64_t modifier;
|
|
||||||
} LinuxDmabufFormat;
|
|
||||||
|
|
||||||
struct _GdkWaylandDisplay
|
struct _GdkWaylandDisplay
|
||||||
{
|
{
|
||||||
GdkDisplay parent_instance;
|
GdkDisplay parent_instance;
|
||||||
@@ -105,9 +99,7 @@ struct _GdkWaylandDisplay
|
|||||||
struct wl_compositor *compositor;
|
struct wl_compositor *compositor;
|
||||||
struct wl_shm *shm;
|
struct wl_shm *shm;
|
||||||
struct zwp_linux_dmabuf_v1 *linux_dmabuf;
|
struct zwp_linux_dmabuf_v1 *linux_dmabuf;
|
||||||
struct zwp_linux_dmabuf_feedback_v1 *linux_dmabuf_feedback;
|
DmabufFormatsInfo *dmabuf_formats_info;
|
||||||
gsize linux_dmabuf_n_formats;
|
|
||||||
LinuxDmabufFormat *linux_dmabuf_formats;
|
|
||||||
struct xdg_wm_base *xdg_wm_base;
|
struct xdg_wm_base *xdg_wm_base;
|
||||||
struct zxdg_shell_v6 *zxdg_shell_v6;
|
struct zxdg_shell_v6 *zxdg_shell_v6;
|
||||||
struct gtk_shell1 *gtk_shell;
|
struct gtk_shell1 *gtk_shell;
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -781,8 +781,8 @@ pointer_handle_motion (void *data,
|
|||||||
{
|
{
|
||||||
double x, y;
|
double x, y;
|
||||||
gdk_event_get_position (event, &x, &y);
|
gdk_event_get_position (event, &x, &y);
|
||||||
g_message ("motion %f %f, seat %p state %d",
|
gdk_debug_message ("motion %f %f, seat %p state %d",
|
||||||
x, y, seat, gdk_event_get_modifier_state (event));
|
x, y, seat, gdk_event_get_modifier_state (event));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wl_seat_get_version (seat->wl_seat) < WL_POINTER_HAS_FRAME)
|
if (wl_seat_get_version (seat->wl_seat) < WL_POINTER_HAS_FRAME)
|
||||||
@@ -1664,7 +1664,7 @@ touch_handle_down (void *data,
|
|||||||
{
|
{
|
||||||
double xx, yy;
|
double xx, yy;
|
||||||
gdk_event_get_position (event, &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);
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||||
@@ -1699,7 +1699,7 @@ touch_handle_up (void *data,
|
|||||||
{
|
{
|
||||||
double x, y;
|
double x, y;
|
||||||
gdk_event_get_position (event, &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);
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||||
@@ -1747,7 +1747,7 @@ touch_handle_motion (void *data,
|
|||||||
{
|
{
|
||||||
double xx, yy;
|
double xx, yy;
|
||||||
gdk_event_get_position (event, &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);
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||||
@@ -1841,9 +1841,9 @@ emit_gesture_swipe_event (GdkWaylandSeat *seat,
|
|||||||
{
|
{
|
||||||
double x, y;
|
double x, y;
|
||||||
gdk_event_get_position (event, &x, &y);
|
gdk_event_get_position (event, &x, &y);
|
||||||
g_message ("swipe event %d, coords: %f %f, seat %p state %d",
|
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_event_type (event), x, y, seat,
|
||||||
gdk_event_get_modifier_state (event));
|
gdk_event_get_modifier_state (event));
|
||||||
}
|
}
|
||||||
|
|
||||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||||
@@ -1936,10 +1936,10 @@ emit_gesture_pinch_event (GdkWaylandSeat *seat,
|
|||||||
{
|
{
|
||||||
double x, y;
|
double x, y;
|
||||||
gdk_event_get_position (event, &x, &y);
|
gdk_event_get_position (event, &x, &y);
|
||||||
g_message ("pinch event %d, coords: %f %f, seat %p state %d",
|
gdk_debug_message ("pinch event %d, coords: %f %f, seat %p state %d",
|
||||||
gdk_event_get_event_type (event),
|
gdk_event_get_event_type (event),
|
||||||
x, y, seat,
|
x, y, seat,
|
||||||
gdk_event_get_modifier_state (event));
|
gdk_event_get_modifier_state (event));
|
||||||
}
|
}
|
||||||
|
|
||||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||||
@@ -2030,10 +2030,10 @@ emit_gesture_hold_event (GdkWaylandSeat *seat,
|
|||||||
{
|
{
|
||||||
double x, y;
|
double x, y;
|
||||||
gdk_event_get_position (event, &x, &y);
|
gdk_event_get_position (event, &x, &y);
|
||||||
g_message ("hold event %d, coords: %f %f, seat %p state %d",
|
gdk_debug_message ("hold event %d, coords: %f %f, seat %p state %d",
|
||||||
gdk_event_get_event_type (event),
|
gdk_event_get_event_type (event),
|
||||||
x, y, seat,
|
x, y, seat,
|
||||||
gdk_event_get_modifier_state (event));
|
gdk_event_get_modifier_state (event));
|
||||||
}
|
}
|
||||||
|
|
||||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||||
|
|||||||
@@ -408,60 +408,64 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
|
|||||||
if (has_background)
|
if (has_background)
|
||||||
ensure_bg_surface (self);
|
ensure_bg_surface (self);
|
||||||
|
|
||||||
if (self->dest.x != dest->origin.x ||
|
if (!scaled_rect_is_integral (dest, 1, &device_rect))
|
||||||
self->dest.y != dest->origin.y ||
|
|
||||||
self->dest.width != dest->size.width ||
|
|
||||||
self->dest.height != dest->size.height)
|
|
||||||
{
|
{
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
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->origin.x, dest->origin.y,
|
||||||
dest->size.width, dest->size.height,
|
dest->size.width, dest->size.height);
|
||||||
gdk_texture_get_width (texture),
|
|
||||||
gdk_texture_get_height (texture),
|
|
||||||
self);
|
|
||||||
}
|
}
|
||||||
else if (!scaled_rect_is_integral (dest, scale, &device_rect))
|
else if (!scaled_rect_is_integral (dest, scale, &device_rect))
|
||||||
{
|
{
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
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.origin.x, device_rect.origin.y,
|
||||||
device_rect.size.width, device_rect.size.height,
|
device_rect.size.width, device_rect.size.height,
|
||||||
scale,
|
scale);
|
||||||
self);
|
}
|
||||||
|
else if (background && !scaled_rect_is_integral (background, 1, &device_rect))
|
||||||
|
{
|
||||||
|
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||||
|
"[%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))
|
else if (background && !scaled_rect_is_integral (background, scale, &device_rect))
|
||||||
{
|
{
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||||
"Non-integral background device coordinates %g %g %g %g (fractional scale %.2f), hiding background of subsurface %p",
|
"[%p] 🗙 Non-integral background device coordinates %g %g %g %g (scale %.2f)",
|
||||||
|
self,
|
||||||
device_rect.origin.x, device_rect.origin.y,
|
device_rect.origin.x, device_rect.origin.y,
|
||||||
device_rect.size.width, device_rect.size.height,
|
device_rect.size.width, device_rect.size.height,
|
||||||
scale,
|
scale);
|
||||||
self);
|
|
||||||
}
|
}
|
||||||
else if (!GDK_IS_DMABUF_TEXTURE (texture) &&
|
else if (!GDK_IS_DMABUF_TEXTURE (texture) &&
|
||||||
!GDK_DISPLAY_DEBUG_CHECK (gdk_surface_get_display (sub->parent), FORCE_OFFLOAD))
|
!GDK_DISPLAY_DEBUG_CHECK (gdk_surface_get_display (sub->parent), FORCE_OFFLOAD))
|
||||||
{
|
{
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||||
"%dx%d %s is not a GdkDmabufTexture, hiding subsurface %p",
|
"[%p] 🗙 %s (%dx%d) is not a GdkDmabufTexture",
|
||||||
gdk_texture_get_width (texture),
|
self,
|
||||||
gdk_texture_get_height (texture),
|
|
||||||
G_OBJECT_TYPE_NAME (texture),
|
G_OBJECT_TYPE_NAME (texture),
|
||||||
self);
|
gdk_texture_get_width (texture),
|
||||||
|
gdk_texture_get_height (texture));
|
||||||
}
|
}
|
||||||
else if (!will_be_above &&
|
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,
|
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_width (texture),
|
||||||
gdk_texture_get_height (texture),
|
gdk_texture_get_height (texture));
|
||||||
self);
|
|
||||||
}
|
}
|
||||||
else if (has_background && !display->single_pixel_buffer)
|
else if (has_background && !display->single_pixel_buffer)
|
||||||
{
|
{
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||||
"Cannot offload subsurface %p with background, no single-pixel buffer support",
|
"[%p] 🗙 Texture has background, but no single-pixel buffer support",
|
||||||
self);
|
self);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -490,10 +494,13 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
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_width (texture),
|
||||||
gdk_texture_get_height (texture),
|
gdk_texture_get_height (texture),
|
||||||
self,
|
|
||||||
self->dest.x, self->dest.y,
|
self->dest.x, self->dest.y,
|
||||||
self->dest.width, self->dest.height);
|
self->dest.width, self->dest.height);
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
@@ -501,22 +508,25 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
|
||||||
"Compositor failed to create wl_buffer for %dx%d texture, hiding subsurface %p",
|
"[%p] 🗙 Failed to create wl_buffer",
|
||||||
gdk_texture_get_width (texture),
|
|
||||||
gdk_texture_get_height (texture),
|
|
||||||
self);
|
self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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;
|
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;
|
result = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -653,7 +663,7 @@ gdk_wayland_subsurface_detach (GdkSubsurface *sub)
|
|||||||
|
|
||||||
if (sub->parent == NULL)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -821,6 +821,11 @@ gdk_wayland_surface_fractional_scale_preferred_scale_cb (void *data,
|
|||||||
gdk_wayland_surface_update_size (surface,
|
gdk_wayland_surface_update_size (surface,
|
||||||
surface->width, surface->height,
|
surface->width, surface->height,
|
||||||
&GDK_FRACTIONAL_SCALE_INIT (scale));
|
&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 = {
|
static const struct wp_fractional_scale_v1_listener fractional_scale_listener = {
|
||||||
@@ -837,8 +842,8 @@ surface_enter (void *data,
|
|||||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||||
GdkMonitor *monitor;
|
GdkMonitor *monitor;
|
||||||
|
|
||||||
GDK_DISPLAY_DEBUG(gdk_surface_get_display (surface), EVENTS,
|
GDK_DISPLAY_DEBUG (gdk_surface_get_display (surface), EVENTS,
|
||||||
"surface enter, surface %p output %p", surface, output);
|
"surface enter, surface %p output %p", surface, output);
|
||||||
|
|
||||||
impl->display_server.outputs = g_slist_prepend (impl->display_server.outputs, output);
|
impl->display_server.outputs = g_slist_prepend (impl->display_server.outputs, output);
|
||||||
|
|
||||||
@@ -870,9 +875,38 @@ surface_leave (void *data,
|
|||||||
gdk_surface_leave_monitor (surface, monitor);
|
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 = {
|
static const struct wl_surface_listener surface_listener = {
|
||||||
surface_enter,
|
surface_enter,
|
||||||
surface_leave
|
surface_leave,
|
||||||
|
surface_preferred_buffer_scale,
|
||||||
|
surface_preferred_buffer_transform,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ GDK_AVAILABLE_IN_ALL
|
|||||||
struct wl_display *gdk_wayland_display_get_wl_display (GdkDisplay *display);
|
struct wl_display *gdk_wayland_display_get_wl_display (GdkDisplay *display);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
struct wl_compositor *gdk_wayland_display_get_wl_compositor (GdkDisplay *display);
|
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,
|
void gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
|
||||||
const char *name,
|
const char *name,
|
||||||
int size);
|
int size);
|
||||||
@@ -60,7 +60,7 @@ void gdk_wayland_display_set_startup_notification_id (GdkDisp
|
|||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
gboolean gdk_wayland_display_query_registry (GdkDisplay *display,
|
gboolean gdk_wayland_display_query_registry (GdkDisplay *display,
|
||||||
const char *global);
|
const char *global);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_4
|
GDK_AVAILABLE_IN_4_4
|
||||||
gpointer gdk_wayland_display_get_egl_display (GdkDisplay *display);
|
gpointer gdk_wayland_display_get_egl_display (GdkDisplay *display);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ gdk_wayland_sources = files([
|
|||||||
'gdkdevice-wayland.c',
|
'gdkdevice-wayland.c',
|
||||||
'gdkdevicepad-wayland.c',
|
'gdkdevicepad-wayland.c',
|
||||||
'gdkdisplay-wayland.c',
|
'gdkdisplay-wayland.c',
|
||||||
|
'gdkdmabuf-wayland.c',
|
||||||
'gdkdrag-wayland.c',
|
'gdkdrag-wayland.c',
|
||||||
'gdkdragsurface-wayland.c',
|
'gdkdragsurface-wayland.c',
|
||||||
'gdkdrop-wayland.c',
|
'gdkdrop-wayland.c',
|
||||||
|
|||||||
@@ -908,7 +908,9 @@ _gdk_win32_create_hicon_for_texture (GdkTexture *texture,
|
|||||||
width = cairo_image_surface_get_width (surface);
|
width = cairo_image_surface_get_width (surface);
|
||||||
height = cairo_image_surface_get_height (surface);
|
height = cairo_image_surface_get_height (surface);
|
||||||
|
|
||||||
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
|
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);
|
icon = pixbuf_to_hicon (pixbuf, is_icon, x, y);
|
||||||
|
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ create_dummy_gl_window (void)
|
|||||||
{
|
{
|
||||||
WNDCLASS wclass = { 0, };
|
WNDCLASS wclass = { 0, };
|
||||||
ATOM klass;
|
ATOM klass;
|
||||||
HWND hwnd;
|
HWND hwnd = NULL;
|
||||||
|
|
||||||
wclass.lpszClassName = "GdkGLDummyWindow";
|
wclass.lpszClassName = "GdkGLDummyWindow";
|
||||||
wclass.lpfnWndProc = DefWindowProc;
|
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));
|
GdkSurface *window = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
|
||||||
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
|
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
|
||||||
GdkWin32Surface *win32_surface = GDK_WIN32_SURFACE (window);
|
|
||||||
VkWin32SurfaceCreateInfoKHR info;
|
VkWin32SurfaceCreateInfoKHR info;
|
||||||
VkResult result;
|
VkResult result;
|
||||||
|
|
||||||
|
|||||||
@@ -274,11 +274,22 @@ gdk_x11_cursor_create_for_name (GdkDisplay *display,
|
|||||||
* will have to be handled by the application (GTK applications can learn
|
* will have to be handled by the application (GTK applications can learn
|
||||||
* about cursor theme changes by listening for change notification
|
* about cursor theme changes by listening for change notification
|
||||||
* for the corresponding `GtkSetting`).
|
* for the corresponding `GtkSetting`).
|
||||||
|
*
|
||||||
|
* Deprecated: 4.16: Use the cursor-related properties of
|
||||||
|
* [GtkSettings](../gtk4/class.Settings.html) to set the cursor theme
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gdk_x11_display_set_cursor_theme (GdkDisplay *display,
|
gdk_x11_display_set_cursor_theme (GdkDisplay *display,
|
||||||
const char *theme,
|
const char *theme,
|
||||||
const int size)
|
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
|
#if defined(HAVE_XCURSOR) && defined(HAVE_XFIXES) && XFIXES_MAJOR >= 2
|
||||||
GdkX11Screen *x11_screen;
|
GdkX11Screen *x11_screen;
|
||||||
|
|||||||
@@ -3078,7 +3078,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
|||||||
|
|
||||||
display_class->get_monitors = gdk_x11_display_get_monitors;
|
display_class->get_monitors = gdk_x11_display_get_monitors;
|
||||||
display_class->get_setting = gdk_x11_display_get_setting;
|
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;
|
class->xevent = gdk_event_source_xevent;
|
||||||
|
|
||||||
|
|||||||
@@ -206,6 +206,10 @@ GdkFilterReturn
|
|||||||
gdk_surface_cache_shape_filter (const XEvent *xevent,
|
gdk_surface_cache_shape_filter (const XEvent *xevent,
|
||||||
gpointer data);
|
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_cursor_display_finalize (GdkDisplay *display);
|
||||||
|
|
||||||
void _gdk_x11_surface_register_dnd (GdkSurface *window);
|
void _gdk_x11_surface_register_dnd (GdkSurface *window);
|
||||||
|
|||||||
@@ -68,6 +68,11 @@ gdk_x11_vulkan_context_end_frame (GdkDrawContext *context,
|
|||||||
GDK_DRAW_CONTEXT_CLASS (gdk_x11_vulkan_context_parent_class)->end_frame (context, painted);
|
GDK_DRAW_CONTEXT_CLASS (gdk_x11_vulkan_context_parent_class)->end_frame (context, painted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gdk_x11_vulkan_context_empty_frame (GdkDrawContext *draw_context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_x11_vulkan_context_class_init (GdkX11VulkanContextClass *klass)
|
gdk_x11_vulkan_context_class_init (GdkX11VulkanContextClass *klass)
|
||||||
{
|
{
|
||||||
@@ -75,6 +80,7 @@ gdk_x11_vulkan_context_class_init (GdkX11VulkanContextClass *klass)
|
|||||||
GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS (klass);
|
GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS (klass);
|
||||||
|
|
||||||
draw_context_class->end_frame = gdk_x11_vulkan_context_end_frame;
|
draw_context_class->end_frame = gdk_x11_vulkan_context_end_frame;
|
||||||
|
draw_context_class->empty_frame = gdk_x11_vulkan_context_empty_frame;
|
||||||
|
|
||||||
context_class->create_surface = gdk_x11_vulkan_context_create_surface;
|
context_class->create_surface = gdk_x11_vulkan_context_create_surface;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ GDK_AVAILABLE_IN_ALL
|
|||||||
void gdk_x11_display_set_program_class (GdkDisplay *display,
|
void gdk_x11_display_set_program_class (GdkDisplay *display,
|
||||||
const char *program_class);
|
const char *program_class);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_DEPRECATED_IN_4_16
|
||||||
void gdk_x11_display_set_cursor_theme (GdkDisplay *display,
|
void gdk_x11_display_set_cursor_theme (GdkDisplay *display,
|
||||||
const char *theme,
|
const char *theme,
|
||||||
const int size);
|
const int size);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ static gint64 profiler_buffer_uploads;
|
|||||||
static void
|
static void
|
||||||
gsk_gpu_buffer_class_init (GskGpuBufferClass *klass)
|
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
|
static void
|
||||||
|
|||||||
@@ -546,7 +546,7 @@ gsk_gpu_device_maybe_gc (GskGpuDevice *self)
|
|||||||
|
|
||||||
if (priv->cache_timeout == 0 || dead_texture_pixels > 1000000)
|
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 ());
|
gsk_gpu_device_gc (self, g_get_monotonic_time ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -345,8 +345,8 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
|
|||||||
|
|
||||||
area.x = 0;
|
area.x = 0;
|
||||||
area.y = 0;
|
area.y = 0;
|
||||||
area.width = ceilf (graphene_vec2_get_x (scale) * viewport->size.width - EPSILON);
|
area.width = MAX (1, ceilf (graphene_vec2_get_x (scale) * viewport->size.width - EPSILON));
|
||||||
area.height = ceilf (graphene_vec2_get_y (scale) * viewport->size.height - EPSILON);
|
area.height = MAX (1, ceilf (graphene_vec2_get_y (scale) * viewport->size.height - EPSILON));
|
||||||
|
|
||||||
image = gsk_gpu_device_create_offscreen_image (gsk_gpu_frame_get_device (frame),
|
image = gsk_gpu_device_create_offscreen_image (gsk_gpu_frame_get_device (frame),
|
||||||
FALSE,
|
FALSE,
|
||||||
|
|||||||
@@ -313,6 +313,11 @@ gsk_gpu_upload_texture_op_try (GskGpuFrame *frame,
|
|||||||
{
|
{
|
||||||
GEnumClass *enum_class = g_type_class_ref (GDK_TYPE_MEMORY_FORMAT);
|
GEnumClass *enum_class = g_type_class_ref (GDK_TYPE_MEMORY_FORMAT);
|
||||||
|
|
||||||
|
if (!GDK_IS_MEMORY_TEXTURE (texture))
|
||||||
|
{
|
||||||
|
gdk_debug_message ("Unoptimized upload for %s", G_OBJECT_TYPE_NAME (texture));
|
||||||
|
}
|
||||||
|
|
||||||
if (gdk_texture_get_format (texture) != gsk_gpu_image_get_format (image))
|
if (gdk_texture_get_format (texture) != gsk_gpu_image_get_format (image))
|
||||||
{
|
{
|
||||||
gdk_debug_message ("Unsupported format %s, converting on CPU to %s",
|
gdk_debug_message ("Unsupported format %s, converting on CPU to %s",
|
||||||
|
|||||||
@@ -48,5 +48,5 @@ gsk_vulkan_descriptors_bind (GskVulkanDescriptors *self,
|
|||||||
GskVulkanDescriptors *previous,
|
GskVulkanDescriptors *previous,
|
||||||
VkCommandBuffer vk_command_buffer)
|
VkCommandBuffer vk_command_buffer)
|
||||||
{
|
{
|
||||||
return GSK_VULKAN_DESCRIPTORS_GET_CLASS (self)->bind (self, previous, vk_command_buffer);
|
GSK_VULKAN_DESCRIPTORS_GET_CLASS (self)->bind (self, previous, vk_command_buffer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "gdk/gdkdisplayprivate.h"
|
#include "gdk/gdkdisplayprivate.h"
|
||||||
#include "gdk/gdkvulkancontextprivate.h"
|
#include "gdk/gdkvulkancontextprivate.h"
|
||||||
|
#include "gdk/gdkprofilerprivate.h"
|
||||||
|
|
||||||
struct _GskVulkanDevice
|
struct _GskVulkanDevice
|
||||||
{
|
{
|
||||||
@@ -786,7 +787,7 @@ gsk_vulkan_device_get_vk_conversion (GskVulkanDevice *self,
|
|||||||
.sType = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO,
|
||||||
.format = vk_format,
|
.format = vk_format,
|
||||||
.ycbcrModel = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601,
|
.ycbcrModel = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601,
|
||||||
.ycbcrRange = VK_SAMPLER_YCBCR_RANGE_ITU_FULL,
|
.ycbcrRange = VK_SAMPLER_YCBCR_RANGE_ITU_NARROW,
|
||||||
.components = (VkComponentMapping) {
|
.components = (VkComponentMapping) {
|
||||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
@@ -949,6 +950,9 @@ gsk_vulkan_device_get_vk_pipeline (GskVulkanDevice *self,
|
|||||||
GdkDisplay *display;
|
GdkDisplay *display;
|
||||||
const char *version_string;
|
const char *version_string;
|
||||||
char *vertex_shader_name, *fragment_shader_name;
|
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) {
|
cache_key = (PipelineCacheKey) {
|
||||||
.op_class = op_class,
|
.op_class = op_class,
|
||||||
@@ -1125,6 +1129,27 @@ gsk_vulkan_device_get_vk_pipeline (GskVulkanDevice *self,
|
|||||||
NULL,
|
NULL,
|
||||||
&pipeline);
|
&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 (fragment_shader_name);
|
||||||
g_free (vertex_shader_name);
|
g_free (vertex_shader_name);
|
||||||
|
|
||||||
|
|||||||
@@ -825,7 +825,7 @@ gsk_vulkan_image_new_for_dmabuf (GskVulkanDevice *device,
|
|||||||
self->vk_tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT;
|
self->vk_tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT;
|
||||||
self->vk_format = vk_format;
|
self->vk_format = vk_format;
|
||||||
self->vk_pipeline_stage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
self->vk_pipeline_stage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
||||||
self->vk_image_layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
self->vk_image_layout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
self->vk_access = 0;
|
self->vk_access = 0;
|
||||||
|
|
||||||
res = vkCreateImage (vk_device,
|
res = vkCreateImage (vk_device,
|
||||||
|
|||||||
+10
-22
@@ -130,18 +130,14 @@ find_texture_to_attach (GskOffload *self,
|
|||||||
gsk_rect_equal (&bounds, &subsurface_node->bounds) &&
|
gsk_rect_equal (&bounds, &subsurface_node->bounds) &&
|
||||||
gdk_rgba_equal (gsk_color_node_get_color (child), &GDK_RGBA_BLACK))
|
gdk_rgba_equal (gsk_color_node_get_color (child), &GDK_RGBA_BLACK))
|
||||||
{
|
{
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
|
||||||
"Offloading subsurface %p with background",
|
|
||||||
subsurface);
|
|
||||||
*has_background = TRUE;
|
*has_background = TRUE;
|
||||||
|
|
||||||
node = gsk_container_node_get_child (node, 1);
|
node = gsk_container_node_get_child (node, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
||||||
"Can't offload subsurface %p: too much content, container with %d children",
|
"[%p] 🗙 Too much content, container with %d children",
|
||||||
subsurface, gsk_container_node_get_n_children (node));
|
subsurface, gsk_container_node_get_n_children (node));
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@@ -153,7 +149,7 @@ find_texture_to_attach (GskOffload *self,
|
|||||||
{
|
{
|
||||||
char *s = gsk_transform_to_string (t);
|
char *s = gsk_transform_to_string (t);
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
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);
|
subsurface, s);
|
||||||
g_free (s);
|
g_free (s);
|
||||||
goto out;
|
goto out;
|
||||||
@@ -181,7 +177,7 @@ find_texture_to_attach (GskOffload *self,
|
|||||||
if (!gsk_rect_intersection (c, &clip, &clip))
|
if (!gsk_rect_intersection (c, &clip, &clip))
|
||||||
{
|
{
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
||||||
"Can't offload subsurface %p: empty clip", subsurface);
|
"[%p] 🗙 Empty clip", subsurface);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,7 +227,7 @@ find_texture_to_attach (GskOffload *self,
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
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));
|
subsurface, g_type_name_from_instance ((GTypeInstance *) node));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -492,7 +488,7 @@ visit_node (GskOffload *self,
|
|||||||
type != GSK_DEBUG_NODE)
|
type != GSK_DEBUG_NODE)
|
||||||
{
|
{
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
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,
|
info->subsurface,
|
||||||
g_type_name_from_instance ((GTypeInstance *) node));
|
g_type_name_from_instance ((GTypeInstance *) node));
|
||||||
info->can_raise = FALSE;
|
info->can_raise = FALSE;
|
||||||
@@ -635,19 +631,19 @@ complex_clip:
|
|||||||
if (info == NULL)
|
if (info == NULL)
|
||||||
{
|
{
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
||||||
"Can't offload: unknown subsurface %p",
|
"[%p] 🗙 Unknown subsurface",
|
||||||
subsurface);
|
subsurface);
|
||||||
}
|
}
|
||||||
else if (!self->current_clip->is_fully_contained)
|
else if (!self->current_clip->is_fully_contained)
|
||||||
{
|
{
|
||||||
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
||||||
"Can't offload subsurface %p: clipped",
|
"[%p] 🗙 Clipped",
|
||||||
subsurface);
|
subsurface);
|
||||||
}
|
}
|
||||||
else if (gsk_transform_get_category (transform) < 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,
|
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
|
||||||
"Can't offload subsurface %p: non-affine transform",
|
"[%p] 🗙 Non-affine transform",
|
||||||
subsurface);
|
subsurface);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -684,7 +680,6 @@ gsk_offload_new (GdkSurface *surface,
|
|||||||
GskRenderNode *root,
|
GskRenderNode *root,
|
||||||
cairo_region_t *diff)
|
cairo_region_t *diff)
|
||||||
{
|
{
|
||||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
|
||||||
GskOffload *self;
|
GskOffload *self;
|
||||||
|
|
||||||
self = g_new0 (GskOffload, 1);
|
self = g_new0 (GskOffload, 1);
|
||||||
@@ -752,17 +747,10 @@ gsk_offload_new (GdkSurface *surface,
|
|||||||
{
|
{
|
||||||
info->is_offloaded = FALSE;
|
info->is_offloaded = FALSE;
|
||||||
if (info->was_offloaded)
|
if (info->was_offloaded)
|
||||||
{
|
gdk_subsurface_detach (info->subsurface);
|
||||||
GDK_DISPLAY_DEBUG (display, OFFLOAD, "Hiding subsurface %p", info->subsurface);
|
|
||||||
gdk_subsurface_detach (info->subsurface);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->is_offloaded && gdk_subsurface_is_above_parent (info->subsurface))
|
info->is_above = info->is_offloaded && gdk_subsurface_is_above_parent (info->subsurface);
|
||||||
{
|
|
||||||
GDK_DISPLAY_DEBUG (display, OFFLOAD, "Raising subsurface %p", info->subsurface);
|
|
||||||
info->is_above = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gdk_subsurface_get_bounds (info->subsurface, &bounds);
|
gdk_subsurface_get_bounds (info->subsurface, &bounds);
|
||||||
|
|
||||||
|
|||||||
@@ -1143,10 +1143,10 @@ gsk_path_builder_rel_conic_to (GskPathBuilder *self,
|
|||||||
* @x2: x coordinate of second control point
|
* @x2: x coordinate of second control point
|
||||||
* @y2: y coordinate of second control point
|
* @y2: y coordinate of second control point
|
||||||
*
|
*
|
||||||
* Adds an elliptical arc from the current point to @x3, @y3
|
* Adds an elliptical arc from the current point to @x2, @y2
|
||||||
* with @x1, @y1 determining the tangent directions.
|
* with @x1, @y1 determining the tangent directions.
|
||||||
*
|
*
|
||||||
* After this, @x3, @y3 will be the new current point.
|
* After this, @x2, @y2 will be the new current point.
|
||||||
*
|
*
|
||||||
* Note: Two points and their tangents do not determine
|
* Note: Two points and their tangents do not determine
|
||||||
* a unique ellipse, so GSK just picks one. If you need more
|
* a unique ellipse, so GSK just picks one. If you need more
|
||||||
@@ -1180,7 +1180,7 @@ gsk_path_builder_arc_to (GskPathBuilder *self,
|
|||||||
* @x2: x coordinate of second control point
|
* @x2: x coordinate of second control point
|
||||||
* @y2: y coordinate of second control point
|
* @y2: y coordinate of second control point
|
||||||
*
|
*
|
||||||
* Adds an elliptical arc from the current point to @x3, @y3
|
* Adds an elliptical arc from the current point to @x2, @y2
|
||||||
* with @x1, @y1 determining the tangent directions.
|
* with @x1, @y1 determining the tangent directions.
|
||||||
*
|
*
|
||||||
* All coordinates are given relative to the current point.
|
* All coordinates are given relative to the current point.
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
/* path has only lines */
|
||||||
GSK_PATH_FLAT,
|
GSK_PATH_FLAT,
|
||||||
|
/* all contours are closed */
|
||||||
GSK_PATH_CLOSED
|
GSK_PATH_CLOSED
|
||||||
} GskPathFlags;
|
} GskPathFlags;
|
||||||
|
|
||||||
|
|||||||
+90
-57
@@ -1,5 +1,4 @@
|
|||||||
/* GSK - The GTK Scene Kit
|
/* GSK - The GTK Scene Kit
|
||||||
*
|
|
||||||
* Copyright 2016 Endless
|
* Copyright 2016 Endless
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* 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);
|
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;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,21 +494,6 @@ gsk_renderer_render (GskRenderer *renderer,
|
|||||||
|
|
||||||
renderer_class->render (renderer, root, clip);
|
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);
|
g_clear_pointer (&priv->prev_node, gsk_render_node_unref);
|
||||||
cairo_region_destroy (clip);
|
cairo_region_destroy (clip);
|
||||||
g_clear_pointer (&offload, gsk_offload_free);
|
g_clear_pointer (&offload, gsk_offload_free);
|
||||||
@@ -610,12 +579,17 @@ get_renderer_for_display (GdkSurface *surface)
|
|||||||
static GType
|
static GType
|
||||||
get_renderer_for_env_var (GdkSurface *surface)
|
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");
|
const char *renderer_name = g_getenv ("GSK_RENDERER");
|
||||||
env_var_type = get_renderer_for_name (renderer_name);
|
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;
|
return env_var_type;
|
||||||
@@ -633,63 +607,115 @@ get_renderer_for_backend (GdkSurface *surface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
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);
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||||
GdkGLContext *context;
|
GdkGLContext *context;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!gdk_display_prepare_gl (display, NULL))
|
if (!gdk_display_prepare_gl (display, &error))
|
||||||
return G_TYPE_INVALID;
|
{
|
||||||
|
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);
|
context = gdk_display_get_gl_context (display);
|
||||||
gdk_gl_context_make_current (context);
|
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
|
static GType
|
||||||
get_renderer_for_gl (GdkSurface *surface)
|
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 G_TYPE_INVALID;
|
||||||
|
|
||||||
return gsk_ngl_renderer_get_type ();
|
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
|
#ifdef GDK_RENDERING_VULKAN
|
||||||
static gboolean
|
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);
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||||
VkPhysicalDeviceProperties props;
|
VkPhysicalDeviceProperties props;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!gdk_display_init_vulkan (display, NULL))
|
if (!gdk_display_init_vulkan (display, &error))
|
||||||
return G_TYPE_INVALID;
|
{
|
||||||
|
if (!as_fallback)
|
||||||
|
GSK_DEBUG (RENDERER, "Not using Vulkan: %s", error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
vkGetPhysicalDeviceProperties (display->vk_physical_device, &props);
|
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
|
#endif
|
||||||
|
|
||||||
|
GSK_DEBUG (RENDERER, "Not using '%s': platform is not Wayland", g_type_name (renderer_type));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static GType
|
static GType
|
||||||
get_renderer_for_vulkan (GdkSurface *surface)
|
get_renderer_for_vulkan (GdkSurface *surface)
|
||||||
{
|
{
|
||||||
#ifdef GDK_RENDERING_VULKAN
|
if (!vulkan_supported_platform (surface, GSK_TYPE_VULKAN_RENDERER, FALSE))
|
||||||
if (vulkan_software_rendering (surface))
|
|
||||||
return G_TYPE_INVALID;
|
return G_TYPE_INVALID;
|
||||||
|
|
||||||
return GSK_TYPE_VULKAN_RENDERER;
|
return GSK_TYPE_VULKAN_RENDERER;
|
||||||
#else
|
|
||||||
return G_TYPE_INVALID;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GType
|
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
|
static GType
|
||||||
get_renderer_fallback (GdkSurface *surface)
|
get_renderer_fallback (GdkSurface *surface)
|
||||||
@@ -703,9 +729,14 @@ static struct {
|
|||||||
{ get_renderer_for_display },
|
{ get_renderer_for_display },
|
||||||
{ get_renderer_for_env_var },
|
{ get_renderer_for_env_var },
|
||||||
{ get_renderer_for_backend },
|
{ get_renderer_for_backend },
|
||||||
{ get_renderer_for_gl },
|
#ifdef GDK_RENDERING_VULKAN
|
||||||
{ get_renderer_for_gles2 },
|
|
||||||
{ get_renderer_for_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 },
|
{ get_renderer_fallback },
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -743,17 +774,19 @@ gsk_renderer_new_for_surface (GdkSurface *surface)
|
|||||||
|
|
||||||
if (gsk_renderer_realize (renderer, surface, &error))
|
if (gsk_renderer_realize (renderer, surface, &error))
|
||||||
{
|
{
|
||||||
GSK_RENDERER_DEBUG (renderer, RENDERER,
|
GSK_DEBUG (RENDERER,
|
||||||
"Using renderer of type '%s' for surface '%s'",
|
"Using renderer '%s' for surface '%s'",
|
||||||
G_OBJECT_TYPE_NAME (renderer),
|
G_OBJECT_TYPE_NAME (renderer),
|
||||||
G_OBJECT_TYPE_NAME (surface));
|
G_OBJECT_TYPE_NAME (surface));
|
||||||
return renderer;
|
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 (renderer),
|
||||||
G_OBJECT_TYPE_NAME (surface),
|
G_OBJECT_TYPE_NAME (surface),
|
||||||
error->message);
|
error->message);
|
||||||
|
|
||||||
g_object_unref (renderer);
|
g_object_unref (renderer);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2312,6 +2312,25 @@ parse_antialias (GtkCssParser *parser,
|
|||||||
return TRUE;
|
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 *
|
static GskRenderNode *
|
||||||
parse_text_node (GtkCssParser *parser,
|
parse_text_node (GtkCssParser *parser,
|
||||||
Context *context)
|
Context *context)
|
||||||
@@ -2322,6 +2341,7 @@ parse_text_node (GtkCssParser *parser,
|
|||||||
PangoGlyphString *glyphs = NULL;
|
PangoGlyphString *glyphs = NULL;
|
||||||
cairo_hint_style_t hint_style = CAIRO_HINT_STYLE_SLIGHT;
|
cairo_hint_style_t hint_style = CAIRO_HINT_STYLE_SLIGHT;
|
||||||
cairo_antialias_t antialias = CAIRO_ANTIALIAS_GRAY;
|
cairo_antialias_t antialias = CAIRO_ANTIALIAS_GRAY;
|
||||||
|
cairo_hint_metrics_t hint_metrics = CAIRO_HINT_METRICS_OFF;
|
||||||
PangoFont *hinted;
|
PangoFont *hinted;
|
||||||
const Declaration declarations[] = {
|
const Declaration declarations[] = {
|
||||||
{ "font", parse_font, clear_font, &font },
|
{ "font", parse_font, clear_font, &font },
|
||||||
@@ -2330,6 +2350,7 @@ parse_text_node (GtkCssParser *parser,
|
|||||||
{ "glyphs", parse_glyphs, clear_glyphs, &glyphs },
|
{ "glyphs", parse_glyphs, clear_glyphs, &glyphs },
|
||||||
{ "hint-style", parse_hint_style, NULL, &hint_style },
|
{ "hint-style", parse_hint_style, NULL, &hint_style },
|
||||||
{ "antialias", parse_antialias, NULL, &antialias },
|
{ "antialias", parse_antialias, NULL, &antialias },
|
||||||
|
{ "hint-metrics", parse_hint_metrics, NULL, &hint_metrics },
|
||||||
};
|
};
|
||||||
GskRenderNode *result;
|
GskRenderNode *result;
|
||||||
|
|
||||||
@@ -2341,7 +2362,7 @@ parse_text_node (GtkCssParser *parser,
|
|||||||
g_assert (font);
|
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);
|
g_object_unref (font);
|
||||||
font = hinted;
|
font = hinted;
|
||||||
|
|
||||||
@@ -3539,13 +3560,13 @@ append_texture_param (Printer *p,
|
|||||||
case GDK_MEMORY_U8:
|
case GDK_MEMORY_U8:
|
||||||
case GDK_MEMORY_U16:
|
case GDK_MEMORY_U16:
|
||||||
bytes = gdk_texture_save_to_png_bytes (texture);
|
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;
|
break;
|
||||||
|
|
||||||
case GDK_MEMORY_FLOAT16:
|
case GDK_MEMORY_FLOAT16:
|
||||||
case GDK_MEMORY_FLOAT32:
|
case GDK_MEMORY_FLOAT32:
|
||||||
bytes = gdk_texture_save_to_tiff_bytes (texture);
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -3604,7 +3625,7 @@ gsk_text_node_serialize_font (GskRenderNode *node,
|
|||||||
|
|
||||||
b64 = base64_encode_with_linebreaks ((const guchar *) data, len);
|
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);
|
append_escaping_newlines (p->str, b64);
|
||||||
g_string_append (p->str, "\")");
|
g_string_append (p->str, "\")");
|
||||||
|
|
||||||
@@ -3623,11 +3644,13 @@ gsk_text_node_serialize_font_options (GskRenderNode *node,
|
|||||||
cairo_font_options_t *options;
|
cairo_font_options_t *options;
|
||||||
cairo_hint_style_t hint_style;
|
cairo_hint_style_t hint_style;
|
||||||
cairo_antialias_t antialias;
|
cairo_antialias_t antialias;
|
||||||
|
cairo_hint_metrics_t hint_metrics;
|
||||||
|
|
||||||
options = cairo_font_options_create ();
|
options = cairo_font_options_create ();
|
||||||
cairo_scaled_font_get_font_options (sf, options);
|
cairo_scaled_font_get_font_options (sf, options);
|
||||||
hint_style = cairo_font_options_get_hint_style (options);
|
hint_style = cairo_font_options_get_hint_style (options);
|
||||||
antialias = cairo_font_options_get_antialias (options);
|
antialias = cairo_font_options_get_antialias (options);
|
||||||
|
hint_metrics = cairo_font_options_get_hint_metrics (options);
|
||||||
cairo_font_options_destroy (options);
|
cairo_font_options_destroy (options);
|
||||||
|
|
||||||
/* medium and full are identical in the absence of subpixel modes */
|
/* medium and full are identical in the absence of subpixel modes */
|
||||||
@@ -3643,6 +3666,12 @@ gsk_text_node_serialize_font_options (GskRenderNode *node,
|
|||||||
*/
|
*/
|
||||||
if (antialias == CAIRO_ANTIALIAS_NONE)
|
if (antialias == CAIRO_ANTIALIAS_NONE)
|
||||||
append_enum_param (p, "antialias", CAIRO_GOBJECT_TYPE_ANTIALIAS, antialias);
|
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
|
void
|
||||||
@@ -4414,7 +4443,7 @@ render_node_print (Printer *p,
|
|||||||
cairo_surface_write_to_png_stream (surface, cairo_write_array, array);
|
cairo_surface_write_to_png_stream (surface, cairo_write_array, array);
|
||||||
|
|
||||||
_indent (p);
|
_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);
|
b64 = base64_encode_with_linebreaks (array->data, array->len);
|
||||||
append_escaping_newlines (p->str, b64);
|
append_escaping_newlines (p->str, b64);
|
||||||
g_free (b64);
|
g_free (b64);
|
||||||
@@ -4434,7 +4463,7 @@ render_node_print (Printer *p,
|
|||||||
if (cairo_script_from_recording_surface (script, surface) == CAIRO_STATUS_SUCCESS)
|
if (cairo_script_from_recording_surface (script, surface) == CAIRO_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
_indent (p);
|
_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);
|
b64 = base64_encode_with_linebreaks (array->data, array->len);
|
||||||
append_escaping_newlines (p->str, b64);
|
append_escaping_newlines (p->str, b64);
|
||||||
g_free (b64);
|
g_free (b64);
|
||||||
|
|||||||
@@ -184,10 +184,4 @@
|
|||||||
</signal>
|
</signal>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
<interface name="org.a11y.atspi.Event.Focus">
|
|
||||||
<signal name="Focus"><arg direction="in" type="(suuv)"/>
|
|
||||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QSpiEvent"/>
|
|
||||||
</signal>
|
|
||||||
</interface>
|
|
||||||
|
|
||||||
</node>
|
</node>
|
||||||
|
|||||||
+19
-20
@@ -720,6 +720,16 @@ handle_accessible_get_property (GDBusConnection *connection,
|
|||||||
res = get_parent_context_ref (accessible);
|
res = get_parent_context_ref (accessible);
|
||||||
else if (g_strcmp0 (property_name, "ChildCount") == 0)
|
else if (g_strcmp0 (property_name, "ChildCount") == 0)
|
||||||
res = g_variant_new_int32 (gtk_at_spi_context_get_child_count (self));
|
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
|
else
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||||
"Unknown property '%s'", property_name);
|
"Unknown property '%s'", property_name);
|
||||||
@@ -899,24 +909,6 @@ emit_children_changed (GtkAtSpiContext *self,
|
|||||||
context_ref);
|
context_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
emit_focus (GtkAtSpiContext *self,
|
|
||||||
gboolean focus_in)
|
|
||||||
{
|
|
||||||
if (self->connection == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (focus_in)
|
|
||||||
g_dbus_connection_emit_signal (self->connection,
|
|
||||||
NULL,
|
|
||||||
self->context_path,
|
|
||||||
"org.a11y.atspi.Event.Focus",
|
|
||||||
"Focus",
|
|
||||||
g_variant_new ("(siiva{sv})",
|
|
||||||
"", 0, 0, g_variant_new_string ("0"), NULL),
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
emit_window_event (GtkAtSpiContext *self,
|
emit_window_event (GtkAtSpiContext *self,
|
||||||
const char *event_type)
|
const char *event_type)
|
||||||
@@ -1154,7 +1146,7 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (changed_properties & GTK_ACCESSIBLE_PROPERTY_CHANGE_DESCRIPTION)
|
if (changed_properties & GTK_ACCESSIBLE_PROPERTY_CHANGE_DESCRIPTION)
|
||||||
{
|
{
|
||||||
char *label = gtk_at_context_get_description (GTK_AT_CONTEXT (self));
|
char *label = gtk_at_context_get_description (GTK_AT_CONTEXT (self));
|
||||||
GVariant *v = g_variant_new_take_string (label);
|
GVariant *v = g_variant_new_take_string (label);
|
||||||
emit_property_changed (self, "accessible-description", v);
|
emit_property_changed (self, "accessible-description", v);
|
||||||
@@ -1167,6 +1159,14 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
|
|||||||
"accessible-value",
|
"accessible-value",
|
||||||
g_variant_new_double (gtk_number_accessible_value_get (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
|
static void
|
||||||
@@ -1196,7 +1196,6 @@ gtk_at_spi_context_platform_change (GtkATContext *ctx,
|
|||||||
gboolean state = gtk_accessible_get_platform_state (GTK_ACCESSIBLE (widget),
|
gboolean state = gtk_accessible_get_platform_state (GTK_ACCESSIBLE (widget),
|
||||||
GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED);
|
GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED);
|
||||||
emit_state_changed (self, "focused", state);
|
emit_state_changed (self, "focused", state);
|
||||||
emit_focus (self, state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed_platform & GTK_ACCESSIBLE_PLATFORM_CHANGE_ACTIVE)
|
if (changed_platform & GTK_ACCESSIBLE_PLATFORM_CHANGE_ACTIVE)
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
|
|||||||
return ATSPI_ROLE_FORM;
|
return ATSPI_ROLE_FORM;
|
||||||
|
|
||||||
case GTK_ACCESSIBLE_ROLE_GENERIC:
|
case GTK_ACCESSIBLE_ROLE_GENERIC:
|
||||||
return ATSPI_ROLE_FILLER;
|
return ATSPI_ROLE_PANEL;
|
||||||
|
|
||||||
case GTK_ACCESSIBLE_ROLE_GRID:
|
case GTK_ACCESSIBLE_ROLE_GRID:
|
||||||
return ATSPI_ROLE_TABLE;
|
return ATSPI_ROLE_TABLE;
|
||||||
@@ -106,7 +106,7 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
|
|||||||
return ATSPI_ROLE_TABLE_CELL;
|
return ATSPI_ROLE_TABLE_CELL;
|
||||||
|
|
||||||
case GTK_ACCESSIBLE_ROLE_GROUP:
|
case GTK_ACCESSIBLE_ROLE_GROUP:
|
||||||
return ATSPI_ROLE_PANEL;
|
return ATSPI_ROLE_GROUPING;
|
||||||
|
|
||||||
case GTK_ACCESSIBLE_ROLE_HEADING:
|
case GTK_ACCESSIBLE_ROLE_HEADING:
|
||||||
return ATSPI_ROLE_HEADING;
|
return ATSPI_ROLE_HEADING;
|
||||||
|
|||||||
+543
-47
@@ -26,24 +26,18 @@
|
|||||||
#include "gtkcsserror.h"
|
#include "gtkcsserror.h"
|
||||||
#include "gtkcsslocationprivate.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;
|
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
|
struct _GtkCssParserBlock
|
||||||
{
|
{
|
||||||
GtkCssLocation start_location;
|
GtkCssLocation start_location;
|
||||||
@@ -52,8 +46,97 @@ struct _GtkCssParserBlock
|
|||||||
GtkCssTokenType alternative_token;
|
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 *
|
static GtkCssParser *
|
||||||
gtk_css_parser_new (GtkCssTokenizer *tokenizer,
|
gtk_css_parser_new (GtkCssTokenizer *tokenizer,
|
||||||
|
GtkCssVariableValue *value,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
GtkCssParserErrorFunc error_func,
|
GtkCssParserErrorFunc error_func,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
@@ -64,17 +147,21 @@ gtk_css_parser_new (GtkCssTokenizer *tokenizer,
|
|||||||
self = g_new0 (GtkCssParser, 1);
|
self = g_new0 (GtkCssParser, 1);
|
||||||
|
|
||||||
self->ref_count = 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)
|
if (file)
|
||||||
{
|
self->file = g_object_ref (file);
|
||||||
self->file = g_object_ref (file);
|
|
||||||
self->directory = g_file_get_parent (file);
|
|
||||||
}
|
|
||||||
|
|
||||||
self->error_func = error_func;
|
self->error_func = error_func;
|
||||||
self->user_data = user_data;
|
self->user_data = user_data;
|
||||||
self->user_destroy = user_destroy;
|
self->user_destroy = user_destroy;
|
||||||
self->blocks = g_array_new (FALSE, FALSE, sizeof (GtkCssParserBlock));
|
gtk_css_parser_blocks_init (&self->blocks);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@@ -109,26 +196,50 @@ gtk_css_parser_new_for_bytes (GBytes *bytes,
|
|||||||
{
|
{
|
||||||
GtkCssTokenizer *tokenizer;
|
GtkCssTokenizer *tokenizer;
|
||||||
GtkCssParser *result;
|
GtkCssParser *result;
|
||||||
|
|
||||||
tokenizer = gtk_css_tokenizer_new (bytes);
|
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);
|
gtk_css_tokenizer_unref (tokenizer);
|
||||||
|
|
||||||
return result;
|
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
|
static void
|
||||||
gtk_css_parser_finalize (GtkCssParser *self)
|
gtk_css_parser_finalize (GtkCssParser *self)
|
||||||
{
|
{
|
||||||
if (self->user_destroy)
|
if (self->user_destroy)
|
||||||
self->user_destroy (self->user_data);
|
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->file);
|
||||||
g_clear_object (&self->directory);
|
g_clear_object (&self->directory);
|
||||||
if (self->blocks->len)
|
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
|
||||||
g_critical ("Finalizing CSS parser with %u remaining blocks", self->blocks->len);
|
g_critical ("Finalizing CSS parser with %lu remaining blocks", gtk_css_parser_blocks_get_size (&self->blocks));
|
||||||
g_array_free (self->blocks, TRUE);
|
gtk_css_parser_blocks_clear (&self->blocks);
|
||||||
|
|
||||||
g_free (self);
|
g_free (self);
|
||||||
}
|
}
|
||||||
@@ -163,6 +274,12 @@ gtk_css_parser_get_file (GtkCssParser *self)
|
|||||||
return self->file;
|
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:
|
* gtk_css_parser_resolve_url:
|
||||||
* @self: a `GtkCssParser`
|
* @self: a `GtkCssParser`
|
||||||
@@ -188,7 +305,12 @@ gtk_css_parser_resolve_url (GtkCssParser *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (self->directory == NULL)
|
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);
|
return g_file_resolve_relative_path (self->directory, url);
|
||||||
}
|
}
|
||||||
@@ -239,7 +361,7 @@ gtk_css_parser_get_start_location (GtkCssParser *self)
|
|||||||
const GtkCssLocation *
|
const GtkCssLocation *
|
||||||
gtk_css_parser_get_end_location (GtkCssParser *self)
|
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;
|
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, };
|
static const GtkCssLocation start_of_document = { 0, };
|
||||||
return &start_of_document;
|
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;
|
return &block->start_location;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,12 +395,14 @@ static void
|
|||||||
gtk_css_parser_ensure_token (GtkCssParser *self)
|
gtk_css_parser_ensure_token (GtkCssParser *self)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
GtkCssTokenizer *tokenizer;
|
||||||
|
|
||||||
if (!gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
|
if (!gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self->location = *gtk_css_tokenizer_get_location (self->tokenizer);
|
tokenizer = get_tokenizer (self);
|
||||||
if (!gtk_css_tokenizer_read_token (self->tokenizer, &self->token, &error))
|
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
|
/* We ignore the error here, because the resulting token will
|
||||||
* likely already trigger an error in the parsing code and
|
* 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);
|
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 *
|
const GtkCssToken *
|
||||||
@@ -295,9 +462,9 @@ gtk_css_parser_peek_token (GtkCssParser *self)
|
|||||||
|
|
||||||
gtk_css_parser_ensure_token (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) ||
|
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->inherited_end_token) ||
|
||||||
gtk_css_token_is (&self->token, block->alternative_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.inherited_end_token = GTK_CSS_TOKEN_EOF;
|
||||||
block.alternative_token = GTK_CSS_TOKEN_EOF;
|
block.alternative_token = GTK_CSS_TOKEN_EOF;
|
||||||
block.start_location = self->location;
|
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);
|
gtk_css_token_clear (&self->token);
|
||||||
}
|
}
|
||||||
@@ -364,13 +531,13 @@ gtk_css_parser_start_semicolon_block (GtkCssParser *self,
|
|||||||
GtkCssParserBlock block;
|
GtkCssParserBlock block;
|
||||||
|
|
||||||
block.end_token = GTK_CSS_TOKEN_SEMICOLON;
|
block.end_token = GTK_CSS_TOKEN_SEMICOLON;
|
||||||
if (self->blocks->len)
|
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
|
||||||
block.inherited_end_token = g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1).end_token;
|
block.inherited_end_token = gtk_css_parser_blocks_get_last (&self->blocks)->end_token;
|
||||||
else
|
else
|
||||||
block.inherited_end_token = GTK_CSS_TOKEN_EOF;
|
block.inherited_end_token = GTK_CSS_TOKEN_EOF;
|
||||||
block.alternative_token = alternative_token;
|
block.alternative_token = alternative_token;
|
||||||
block.start_location = self->location;
|
block.start_location = self->location;
|
||||||
g_array_append_val (self->blocks, block);
|
gtk_css_parser_blocks_append (&self->blocks, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -378,9 +545,9 @@ gtk_css_parser_end_block_prelude (GtkCssParser *self)
|
|||||||
{
|
{
|
||||||
GtkCssParserBlock *block;
|
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)
|
if (block->alternative_token == GTK_CSS_TOKEN_EOF)
|
||||||
return;
|
return;
|
||||||
@@ -405,11 +572,11 @@ gtk_css_parser_end_block (GtkCssParser *self)
|
|||||||
{
|
{
|
||||||
GtkCssParserBlock *block;
|
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);
|
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))
|
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_block_location (self),
|
||||||
gtk_css_parser_get_start_location (self),
|
gtk_css_parser_get_start_location (self),
|
||||||
"Unterminated block at end of document");
|
"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))
|
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_block_location (self),
|
||||||
gtk_css_parser_get_start_location (self),
|
gtk_css_parser_get_start_location (self),
|
||||||
"Expected ';' at end of block");
|
"Expected ';' at end of block");
|
||||||
g_array_set_size (self->blocks, self->blocks->len - 1);
|
gtk_css_parser_blocks_drop_last (&self->blocks);
|
||||||
}
|
}
|
||||||
else
|
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))
|
if (gtk_css_token_is_preserved (&self->token, NULL))
|
||||||
{
|
{
|
||||||
gtk_css_token_clear (&self->token);
|
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
|
void
|
||||||
gtk_css_parser_emit_error (GtkCssParser *self,
|
gtk_css_parser_emit_error (GtkCssParser *self,
|
||||||
const GtkCssLocation *start,
|
const GtkCssLocation *start,
|
||||||
@@ -1112,3 +1292,319 @@ gtk_css_parser_consume_any (GtkCssParser *parser,
|
|||||||
|
|
||||||
return result;
|
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 "gtkcssenums.h"
|
||||||
#include "gtkcsstokenizerprivate.h"
|
#include "gtkcsstokenizerprivate.h"
|
||||||
|
#include "gtkcssvariablevalueprivate.h"
|
||||||
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
@@ -58,10 +59,18 @@ GtkCssParser * gtk_css_parser_new_for_bytes (GBytes
|
|||||||
GtkCssParserErrorFunc error_func,
|
GtkCssParserErrorFunc error_func,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GDestroyNotify user_destroy);
|
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);
|
GtkCssParser * gtk_css_parser_ref (GtkCssParser *self);
|
||||||
void gtk_css_parser_unref (GtkCssParser *self);
|
void gtk_css_parser_unref (GtkCssParser *self);
|
||||||
|
|
||||||
GFile * gtk_css_parser_get_file (GtkCssParser *self) G_GNUC_PURE;
|
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,
|
GFile * gtk_css_parser_resolve_url (GtkCssParser *self,
|
||||||
const char *url);
|
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 (GtkCssParser *self);
|
||||||
void gtk_css_parser_skip_until (GtkCssParser *self,
|
void gtk_css_parser_skip_until (GtkCssParser *self,
|
||||||
GtkCssTokenType token_type);
|
GtkCssTokenType token_type);
|
||||||
|
void gtk_css_parser_skip_whitespace (GtkCssParser *self);
|
||||||
|
|
||||||
void gtk_css_parser_emit_error (GtkCssParser *self,
|
void gtk_css_parser_emit_error (GtkCssParser *self,
|
||||||
const GtkCssLocation *start,
|
const GtkCssLocation *start,
|
||||||
@@ -150,5 +160,14 @@ gsize gtk_css_parser_consume_any (GtkCssParser
|
|||||||
gsize n_options,
|
gsize n_options,
|
||||||
gpointer user_data);
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ struct _GtkCssSection
|
|||||||
int ref_count;
|
int ref_count;
|
||||||
GtkCssSection *parent;
|
GtkCssSection *parent;
|
||||||
GFile *file;
|
GFile *file;
|
||||||
|
GBytes *bytes;
|
||||||
GtkCssLocation start_location;
|
GtkCssLocation start_location;
|
||||||
GtkCssLocation end_location; /* end location if parser is %NULL */
|
GtkCssLocation end_location; /* end location if parser is %NULL */
|
||||||
};
|
};
|
||||||
@@ -48,6 +49,15 @@ GtkCssSection *
|
|||||||
gtk_css_section_new (GFile *file,
|
gtk_css_section_new (GFile *file,
|
||||||
const GtkCssLocation *start,
|
const GtkCssLocation *start,
|
||||||
const GtkCssLocation *end)
|
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;
|
GtkCssSection *result;
|
||||||
|
|
||||||
@@ -60,6 +70,8 @@ gtk_css_section_new (GFile *file,
|
|||||||
result->ref_count = 1;
|
result->ref_count = 1;
|
||||||
if (file)
|
if (file)
|
||||||
result->file = g_object_ref (file);
|
result->file = g_object_ref (file);
|
||||||
|
if (bytes)
|
||||||
|
result->bytes = g_bytes_ref (bytes);
|
||||||
result->start_location = *start;
|
result->start_location = *start;
|
||||||
result->end_location = *end;
|
result->end_location = *end;
|
||||||
|
|
||||||
@@ -104,6 +116,8 @@ gtk_css_section_unref (GtkCssSection *section)
|
|||||||
gtk_css_section_unref (section->parent);
|
gtk_css_section_unref (section->parent);
|
||||||
if (section->file)
|
if (section->file)
|
||||||
g_object_unref (section->file);
|
g_object_unref (section->file);
|
||||||
|
if (section->bytes)
|
||||||
|
g_bytes_unref (section->bytes);
|
||||||
|
|
||||||
g_free (section);
|
g_free (section);
|
||||||
}
|
}
|
||||||
@@ -151,6 +165,14 @@ gtk_css_section_get_file (const GtkCssSection *section)
|
|||||||
return section->file;
|
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:
|
* gtk_css_section_get_start_location:
|
||||||
* @section: the section
|
* @section: the section
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ GDK_AVAILABLE_IN_ALL
|
|||||||
GtkCssSection * gtk_css_section_new (GFile *file,
|
GtkCssSection * gtk_css_section_new (GFile *file,
|
||||||
const GtkCssLocation *start,
|
const GtkCssLocation *start,
|
||||||
const GtkCssLocation *end);
|
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
|
GDK_AVAILABLE_IN_ALL
|
||||||
GtkCssSection * gtk_css_section_ref (GtkCssSection *section);
|
GtkCssSection * gtk_css_section_ref (GtkCssSection *section);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
@@ -61,6 +66,8 @@ GDK_AVAILABLE_IN_ALL
|
|||||||
GtkCssSection * gtk_css_section_get_parent (const GtkCssSection *section);
|
GtkCssSection * gtk_css_section_get_parent (const GtkCssSection *section);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GFile * gtk_css_section_get_file (const GtkCssSection *section);
|
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
|
GDK_AVAILABLE_IN_ALL
|
||||||
const GtkCssLocation *
|
const GtkCssLocation *
|
||||||
gtk_css_section_get_start_location (const GtkCssSection *section);
|
gtk_css_section_get_start_location (const GtkCssSection *section);
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ struct _GtkCssTokenizer
|
|||||||
const char *end;
|
const char *end;
|
||||||
|
|
||||||
GtkCssLocation position;
|
GtkCssLocation position;
|
||||||
|
|
||||||
|
GtkCssLocation saved_position;
|
||||||
|
const char *saved_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -568,6 +571,14 @@ gtk_css_token_init_dimension (GtkCssToken *token,
|
|||||||
|
|
||||||
GtkCssTokenizer *
|
GtkCssTokenizer *
|
||||||
gtk_css_tokenizer_new (GBytes *bytes)
|
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;
|
GtkCssTokenizer *tokenizer;
|
||||||
|
|
||||||
@@ -576,8 +587,8 @@ gtk_css_tokenizer_new (GBytes *bytes)
|
|||||||
tokenizer->bytes = g_bytes_ref (bytes);
|
tokenizer->bytes = g_bytes_ref (bytes);
|
||||||
tokenizer->name_buffer = g_string_new (NULL);
|
tokenizer->name_buffer = g_string_new (NULL);
|
||||||
|
|
||||||
tokenizer->data = g_bytes_get_data (bytes, NULL);
|
tokenizer->data = g_bytes_get_region (bytes, 1, offset, length);
|
||||||
tokenizer->end = tokenizer->data + g_bytes_get_size (bytes);
|
tokenizer->end = tokenizer->data + length;
|
||||||
|
|
||||||
gtk_css_location_init (&tokenizer->position);
|
gtk_css_location_init (&tokenizer->position);
|
||||||
|
|
||||||
@@ -604,6 +615,12 @@ gtk_css_tokenizer_unref (GtkCssTokenizer *tokenizer)
|
|||||||
g_free (tokenizer);
|
g_free (tokenizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GBytes *
|
||||||
|
gtk_css_tokenizer_get_bytes (GtkCssTokenizer *tokenizer)
|
||||||
|
{
|
||||||
|
return tokenizer->bytes;
|
||||||
|
}
|
||||||
|
|
||||||
const GtkCssLocation *
|
const GtkCssLocation *
|
||||||
gtk_css_tokenizer_get_location (GtkCssTokenizer *tokenizer)
|
gtk_css_tokenizer_get_location (GtkCssTokenizer *tokenizer)
|
||||||
{
|
{
|
||||||
@@ -1020,7 +1037,7 @@ gtk_css_tokenizer_read_ident_like (GtkCssTokenizer *tokenizer,
|
|||||||
{
|
{
|
||||||
gtk_css_tokenizer_read_name (tokenizer);
|
gtk_css_tokenizer_read_name (tokenizer);
|
||||||
|
|
||||||
if (*tokenizer->data == '(')
|
if (gtk_css_tokenizer_remaining (tokenizer) > 0 && *tokenizer->data == '(')
|
||||||
{
|
{
|
||||||
gtk_css_tokenizer_consume_ascii (tokenizer);
|
gtk_css_tokenizer_consume_ascii (tokenizer);
|
||||||
if (g_ascii_strcasecmp (tokenizer->name_buffer->str, "url") == 0)
|
if (g_ascii_strcasecmp (tokenizer->name_buffer->str, "url") == 0)
|
||||||
@@ -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);
|
char * gtk_css_token_to_string (const GtkCssToken *token);
|
||||||
|
|
||||||
GtkCssTokenizer * gtk_css_tokenizer_new (GBytes *bytes);
|
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);
|
GtkCssTokenizer * gtk_css_tokenizer_ref (GtkCssTokenizer *tokenizer);
|
||||||
void gtk_css_tokenizer_unref (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;
|
const GtkCssLocation * gtk_css_tokenizer_get_location (GtkCssTokenizer *tokenizer) G_GNUC_CONST;
|
||||||
|
|
||||||
gboolean gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer,
|
gboolean gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer,
|
||||||
GtkCssToken *token,
|
GtkCssToken *token,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
void gtk_css_tokenizer_save (GtkCssTokenizer *tokenizer);
|
||||||
|
void gtk_css_tokenizer_restore (GtkCssTokenizer *tokenizer);
|
||||||
|
|
||||||
G_END_DECLS
|
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
|
||||||
+2
-1
@@ -6,8 +6,9 @@ gtk_css_public_sources = files([
|
|||||||
gtk_css_private_sources = files([
|
gtk_css_private_sources = files([
|
||||||
'gtkcssdataurl.c',
|
'gtkcssdataurl.c',
|
||||||
'gtkcssparser.c',
|
'gtkcssparser.c',
|
||||||
'gtkcsstokenizer.c',
|
|
||||||
'gtkcssserializer.c',
|
'gtkcssserializer.c',
|
||||||
|
'gtkcsstokenizer.c',
|
||||||
|
'gtkcssvariablevalue.c',
|
||||||
])
|
])
|
||||||
|
|
||||||
gtk_css_public_headers = files([
|
gtk_css_public_headers = files([
|
||||||
|
|||||||
+291
-105
@@ -21,9 +21,16 @@
|
|||||||
#include "gtkscalerprivate.h"
|
#include "gtkscalerprivate.h"
|
||||||
|
|
||||||
#include "gdk/gdktextureprivate.h"
|
#include "gdk/gdktextureprivate.h"
|
||||||
|
#include "gdk/loaders/gdkpngprivate.h"
|
||||||
|
|
||||||
/* {{{ Pixbuf helpers */
|
/* {{{ Pixbuf helpers */
|
||||||
|
|
||||||
|
static inline gboolean
|
||||||
|
pixbuf_is_only_fg (GdkPixbuf *pixbuf)
|
||||||
|
{
|
||||||
|
return gdk_pixbuf_get_option (pixbuf, "tEXt::only-foreground") != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static GdkPixbuf *
|
static GdkPixbuf *
|
||||||
load_from_stream (GdkPixbufLoader *loader,
|
load_from_stream (GdkPixbufLoader *loader,
|
||||||
GInputStream *stream,
|
GInputStream *stream,
|
||||||
@@ -199,6 +206,7 @@ _gdk_pixbuf_new_from_resource_at_scale (const char *resource_path,
|
|||||||
|
|
||||||
static GdkPixbuf *
|
static GdkPixbuf *
|
||||||
load_symbolic_svg (const char *escaped_file_data,
|
load_symbolic_svg (const char *escaped_file_data,
|
||||||
|
gsize len,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
const char *icon_width_str,
|
const char *icon_width_str,
|
||||||
@@ -214,37 +222,38 @@ load_symbolic_svg (const char *escaped_file_data,
|
|||||||
char *data;
|
char *data;
|
||||||
|
|
||||||
data = g_strconcat ("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
|
data = g_strconcat ("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
|
||||||
"<svg version=\"1.1\"\n"
|
"<svg version=\"1.1\" "
|
||||||
" xmlns=\"http://www.w3.org/2000/svg\"\n"
|
"xmlns=\"http://www.w3.org/2000/svg\" "
|
||||||
" xmlns:xi=\"http://www.w3.org/2001/XInclude\"\n"
|
"xmlns:xi=\"http://www.w3.org/2001/XInclude\" "
|
||||||
" width=\"", icon_width_str, "\"\n"
|
"width=\"", icon_width_str, "\" "
|
||||||
" height=\"", icon_height_str, "\">\n"
|
"height=\"", icon_height_str, "\">"
|
||||||
" <style type=\"text/css\">\n"
|
"<style type=\"text/css\">"
|
||||||
" rect,circle,path {\n"
|
"rect,circle,path {"
|
||||||
" fill: ", fg_string," !important;\n"
|
"fill: ", fg_string," !important;"
|
||||||
" }\n"
|
"}\n"
|
||||||
" .warning {\n"
|
".warning {"
|
||||||
" fill: ", warning_color_string, " !important;\n"
|
"fill: ", warning_color_string, " !important;"
|
||||||
" }\n"
|
"}\n"
|
||||||
" .error {\n"
|
".error {"
|
||||||
" fill: ", error_color_string ," !important;\n"
|
"fill: ", error_color_string ," !important;"
|
||||||
" }\n"
|
"}\n"
|
||||||
" .success {\n"
|
".success {"
|
||||||
" fill: ", success_color_string, " !important;\n"
|
"fill: ", success_color_string, " !important;"
|
||||||
" }\n"
|
"}"
|
||||||
" </style>\n"
|
"</style>"
|
||||||
" <xi:include href=\"data:text/xml;base64,", escaped_file_data, "\"/>\n"
|
"<xi:include href=\"data:text/xml;base64,",
|
||||||
"</svg>",
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
stream = g_memory_input_stream_new_from_data (data, -1, g_free);
|
stream = g_memory_input_stream_new_from_data (data, -1, g_free);
|
||||||
|
g_memory_input_stream_add_data (G_MEMORY_INPUT_STREAM (stream), escaped_file_data, len, NULL);
|
||||||
|
g_memory_input_stream_add_data (G_MEMORY_INPUT_STREAM (stream), "\"/></svg>", strlen ("\"/></svg>"), NULL);
|
||||||
pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream, width, height, TRUE, NULL, error);
|
pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream, width, height, TRUE, NULL, error);
|
||||||
g_object_unref (stream);
|
g_object_unref (stream);
|
||||||
|
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
extract_plane (GdkPixbuf *src,
|
extract_plane (GdkPixbuf *src,
|
||||||
GdkPixbuf *dst,
|
GdkPixbuf *dst,
|
||||||
int from_plane,
|
int from_plane,
|
||||||
@@ -255,6 +264,7 @@ extract_plane (GdkPixbuf *src,
|
|||||||
gsize src_stride, dst_stride;
|
gsize src_stride, dst_stride;
|
||||||
guchar *src_row, *dst_row;
|
guchar *src_row, *dst_row;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
gboolean all_clear = TRUE;
|
||||||
|
|
||||||
width = gdk_pixbuf_get_width (src);
|
width = gdk_pixbuf_get_width (src);
|
||||||
height = gdk_pixbuf_get_height (src);
|
height = gdk_pixbuf_get_height (src);
|
||||||
@@ -274,11 +284,109 @@ extract_plane (GdkPixbuf *src,
|
|||||||
dst_row = dst_data + dst_stride * y;
|
dst_row = dst_data + dst_stride * y;
|
||||||
for (x = 0; x < width; x++)
|
for (x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
|
if (src_row[from_plane] != 0)
|
||||||
|
all_clear = FALSE;
|
||||||
|
|
||||||
dst_row[to_plane] = src_row[from_plane];
|
dst_row[to_plane] = src_row[from_plane];
|
||||||
src_row += 4;
|
src_row += 4;
|
||||||
dst_row += 4;
|
dst_row += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return all_clear;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
keep_alpha (GdkPixbuf *src)
|
||||||
|
{
|
||||||
|
guchar *data;
|
||||||
|
int width, height;
|
||||||
|
gsize stride;
|
||||||
|
|
||||||
|
data = gdk_pixbuf_get_pixels (src);
|
||||||
|
width = gdk_pixbuf_get_width (src);
|
||||||
|
height = gdk_pixbuf_get_height (src);
|
||||||
|
stride = gdk_pixbuf_get_rowstride (src);
|
||||||
|
|
||||||
|
for (int y = 0; y < height; y++)
|
||||||
|
{
|
||||||
|
guchar *row = data + stride * y;
|
||||||
|
for (int x = 0; x < width; x++)
|
||||||
|
{
|
||||||
|
row[0] = row[1] = row[2] = 0;
|
||||||
|
row += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
svg_find_size_strings (const char *data,
|
||||||
|
gsize len,
|
||||||
|
char **width,
|
||||||
|
char **height)
|
||||||
|
{
|
||||||
|
gsize i, j, k, l;
|
||||||
|
|
||||||
|
*width = NULL;
|
||||||
|
*height = NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < len - 4; i++)
|
||||||
|
{
|
||||||
|
if (strncmp (data + i, "<svg", 4) == 0)
|
||||||
|
{
|
||||||
|
for (j = i + strlen ("<svg"); j < len - 9; j++)
|
||||||
|
{
|
||||||
|
if (strncmp (data + j, "height=\"", strlen ("height=\"")) == 0)
|
||||||
|
{
|
||||||
|
k = l = j + strlen ("height=\"");
|
||||||
|
while (l < len && data[l] != '\"')
|
||||||
|
l++;
|
||||||
|
|
||||||
|
*height = g_strndup (data + k, l - k);
|
||||||
|
|
||||||
|
if (*width && *height)
|
||||||
|
return;
|
||||||
|
|
||||||
|
j = l;
|
||||||
|
}
|
||||||
|
else if (strncmp (data + j, "width=\"", strlen ("width=\"")) == 0)
|
||||||
|
{
|
||||||
|
k = l = j + strlen ("width=\"");
|
||||||
|
while (l < len && data[l] != '\"')
|
||||||
|
l++;
|
||||||
|
|
||||||
|
*width = g_strndup (data + k, l - k);
|
||||||
|
|
||||||
|
if (*width && *height)
|
||||||
|
return;
|
||||||
|
|
||||||
|
j = l;
|
||||||
|
}
|
||||||
|
else if (data[j] == '>')
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*width = g_strdup ("16px");
|
||||||
|
*height = g_strdup ("16px");
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
svg_has_symbolic_classes (const char *data,
|
||||||
|
gsize len)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_MEMMEM
|
||||||
|
return memmem (data, len, "class=\"error\"", strlen ("class=\"error\"")) != NULL ||
|
||||||
|
memmem (data, len, "class=\"warning\"", strlen ("class=\"warning\"")) != NULL ||
|
||||||
|
memmem (data, len, "class=\"success\"", strlen ("class=\"success\"")) != NULL;
|
||||||
|
#else
|
||||||
|
return TRUE;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkPixbuf *
|
GdkPixbuf *
|
||||||
@@ -293,38 +401,46 @@ gtk_make_symbolic_pixbuf_from_data (const char *file_data,
|
|||||||
{
|
{
|
||||||
const char *r_string = "rgb(255,0,0)";
|
const char *r_string = "rgb(255,0,0)";
|
||||||
const char *g_string = "rgb(0,255,0)";
|
const char *g_string = "rgb(0,255,0)";
|
||||||
char *icon_width_str;
|
char *icon_width_str = NULL;
|
||||||
char *icon_height_str;
|
char *icon_height_str = NULL;
|
||||||
GdkPixbuf *loaded;
|
char *escaped_file_data = NULL;
|
||||||
|
gsize len;
|
||||||
GdkPixbuf *pixbuf = NULL;
|
GdkPixbuf *pixbuf = NULL;
|
||||||
int plane;
|
gboolean has_symbolic_classes;
|
||||||
int icon_width, icon_height;
|
gboolean only_fg = TRUE;
|
||||||
char *escaped_file_data;
|
|
||||||
|
has_symbolic_classes = svg_has_symbolic_classes (file_data, file_len);
|
||||||
|
|
||||||
/* Fetch size from the original icon */
|
/* Fetch size from the original icon */
|
||||||
GInputStream *stream = g_memory_input_stream_new_from_data (file_data, file_len, NULL);
|
if (has_symbolic_classes || width == 0 || height == 0)
|
||||||
GdkPixbuf *reference = gdk_pixbuf_new_from_stream (stream, NULL, error);
|
svg_find_size_strings (file_data, file_len, &icon_width_str, &icon_height_str);
|
||||||
|
|
||||||
g_object_unref (stream);
|
|
||||||
|
|
||||||
if (!reference)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
icon_width = gdk_pixbuf_get_width (reference);
|
|
||||||
icon_height = gdk_pixbuf_get_height (reference);
|
|
||||||
g_object_unref (reference);
|
|
||||||
|
|
||||||
escaped_file_data = g_base64_encode ((guchar *) file_data, file_len);
|
|
||||||
icon_width_str = g_strdup_printf ("%d", icon_width);
|
|
||||||
icon_height_str = g_strdup_printf ("%d", icon_height);
|
|
||||||
|
|
||||||
if (width == 0)
|
if (width == 0)
|
||||||
width = icon_width * scale;
|
width = (int) (g_ascii_strtoull (icon_width_str, NULL, 0) * scale);
|
||||||
if (height == 0)
|
if (height == 0)
|
||||||
height = icon_height * scale;
|
height = (int) (g_ascii_strtoull (icon_height_str, NULL, 0) * scale);
|
||||||
|
|
||||||
for (plane = 0; plane < 3; plane++)
|
if (!has_symbolic_classes)
|
||||||
{
|
{
|
||||||
|
GInputStream *stream;
|
||||||
|
|
||||||
|
stream = g_memory_input_stream_new_from_data (file_data, file_len, NULL);
|
||||||
|
pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream, width, height, TRUE, NULL, error);
|
||||||
|
g_object_unref (stream);
|
||||||
|
|
||||||
|
if (pixbuf)
|
||||||
|
keep_alpha (pixbuf);
|
||||||
|
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
escaped_file_data = g_base64_encode ((guchar *) file_data, file_len);
|
||||||
|
len = strlen (escaped_file_data);
|
||||||
|
|
||||||
|
for (int plane = 0; plane < 3; plane++)
|
||||||
|
{
|
||||||
|
GdkPixbuf *loaded;
|
||||||
|
|
||||||
/* Here we render the svg with all colors solid, this should
|
/* Here we render the svg with all colors solid, this should
|
||||||
* always make the alpha channel the same and it should match
|
* always make the alpha channel the same and it should match
|
||||||
* the final alpha channel for all possible renderings. We
|
* the final alpha channel for all possible renderings. We
|
||||||
@@ -337,7 +453,7 @@ gtk_make_symbolic_pixbuf_from_data (const char *file_data,
|
|||||||
* channels, with the color of the fg being implicitly
|
* channels, with the color of the fg being implicitly
|
||||||
* the "rest", as all color fractions should add up to 1.
|
* the "rest", as all color fractions should add up to 1.
|
||||||
*/
|
*/
|
||||||
loaded = load_symbolic_svg (escaped_file_data, width, height,
|
loaded = load_symbolic_svg (escaped_file_data, len, width, height,
|
||||||
icon_width_str,
|
icon_width_str,
|
||||||
icon_height_str,
|
icon_height_str,
|
||||||
g_string,
|
g_string,
|
||||||
@@ -358,25 +474,26 @@ gtk_make_symbolic_pixbuf_from_data (const char *file_data,
|
|||||||
g_free (filename);
|
g_free (filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixbuf == NULL)
|
if (plane == 0)
|
||||||
{
|
{
|
||||||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
|
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
|
||||||
gdk_pixbuf_get_width (loaded),
|
gdk_pixbuf_get_width (loaded),
|
||||||
gdk_pixbuf_get_height (loaded));
|
gdk_pixbuf_get_height (loaded));
|
||||||
gdk_pixbuf_fill (pixbuf, 0);
|
memset (gdk_pixbuf_get_pixels (pixbuf), 0, gdk_pixbuf_get_byte_length (pixbuf));
|
||||||
|
|
||||||
|
extract_plane (loaded, pixbuf, 3, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plane == 0)
|
only_fg &= extract_plane (loaded, pixbuf, 0, plane);
|
||||||
extract_plane (loaded, pixbuf, 3, 3);
|
|
||||||
|
|
||||||
extract_plane (loaded, pixbuf, 0, plane);
|
|
||||||
|
|
||||||
g_object_unref (loaded);
|
g_object_unref (loaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (escaped_file_data);
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
if (only_fg && pixbuf)
|
||||||
|
gdk_pixbuf_set_option (pixbuf, "tEXt::only-foreground", "true");
|
||||||
|
|
||||||
|
g_free (escaped_file_data);
|
||||||
g_free (icon_width_str);
|
g_free (icon_width_str);
|
||||||
g_free (icon_height_str);
|
g_free (icon_height_str);
|
||||||
|
|
||||||
@@ -409,17 +526,17 @@ make_symbolic_pixbuf_from_resource (const char *path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GdkPixbuf *
|
static GdkPixbuf *
|
||||||
make_symbolic_pixbuf_from_path (const char *path,
|
make_symbolic_pixbuf_from_filename (const char *filename,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
double scale,
|
double scale,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
char *data;
|
char *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
|
|
||||||
if (!g_file_get_contents (path, &data, &size, error))
|
if (!g_file_get_contents (filename, &data, &size, error))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pixbuf = gtk_make_symbolic_pixbuf_from_data (data, size, width, height, scale, NULL, error);
|
pixbuf = gtk_make_symbolic_pixbuf_from_data (data, size, width, height, scale, NULL, error);
|
||||||
@@ -453,11 +570,85 @@ make_symbolic_pixbuf_from_file (GFile *file,
|
|||||||
/* }}} */
|
/* }}} */
|
||||||
/* {{{ Texture API */
|
/* {{{ Texture API */
|
||||||
|
|
||||||
|
static GdkTexture *
|
||||||
|
texture_new_from_bytes (GBytes *bytes,
|
||||||
|
gboolean *only_fg,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GHashTable *options;
|
||||||
|
GdkTexture *texture;
|
||||||
|
|
||||||
|
if (!gdk_is_png (bytes))
|
||||||
|
return gdk_texture_new_from_bytes (bytes, error);
|
||||||
|
|
||||||
|
options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||||
|
texture = gdk_load_png (bytes, options, error);
|
||||||
|
*only_fg = g_hash_table_contains (options, "foreground-only");
|
||||||
|
g_hash_table_unref (options);
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
GdkTexture *
|
||||||
|
gdk_texture_new_from_filename_with_fg (const char *filename,
|
||||||
|
gboolean *only_fg,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GFile *file;
|
||||||
|
GBytes *bytes;
|
||||||
|
GdkTexture *texture = NULL;
|
||||||
|
|
||||||
|
file = g_file_new_for_path (filename);
|
||||||
|
bytes = g_file_load_bytes (file, NULL, NULL, error);
|
||||||
|
if (bytes)
|
||||||
|
texture = texture_new_from_bytes (bytes, only_fg, error);
|
||||||
|
g_bytes_unref (bytes);
|
||||||
|
g_object_unref (file);
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
GdkTexture *
|
||||||
|
gdk_texture_new_from_resource_with_fg (const char *path,
|
||||||
|
gboolean *only_fg)
|
||||||
|
{
|
||||||
|
GBytes *bytes;
|
||||||
|
GdkTexture *texture = NULL;
|
||||||
|
|
||||||
|
bytes = g_resources_lookup_data (path, 0, NULL);
|
||||||
|
if (bytes)
|
||||||
|
texture = texture_new_from_bytes (bytes, only_fg, NULL);
|
||||||
|
g_bytes_unref (bytes);
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
GdkTexture *
|
||||||
|
gdk_texture_new_from_stream_with_fg (GInputStream *stream,
|
||||||
|
gboolean *only_fg,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GdkPixbuf *pixbuf;
|
||||||
|
GdkTexture *texture = NULL;
|
||||||
|
|
||||||
|
pixbuf = _gdk_pixbuf_new_from_stream_scaled (stream, 0, cancellable, error);
|
||||||
|
if (pixbuf)
|
||||||
|
{
|
||||||
|
*only_fg = pixbuf_is_only_fg (pixbuf);
|
||||||
|
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||||
|
g_object_unref (pixbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
GdkTexture *
|
GdkTexture *
|
||||||
gdk_texture_new_from_stream_at_scale (GInputStream *stream,
|
gdk_texture_new_from_stream_at_scale (GInputStream *stream,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
gboolean aspect,
|
gboolean aspect,
|
||||||
|
gboolean *only_fg,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@@ -467,24 +658,7 @@ gdk_texture_new_from_stream_at_scale (GInputStream *stream,
|
|||||||
pixbuf = _gdk_pixbuf_new_from_stream_at_scale (stream, width, height, aspect, cancellable, error);
|
pixbuf = _gdk_pixbuf_new_from_stream_at_scale (stream, width, height, aspect, cancellable, error);
|
||||||
if (pixbuf)
|
if (pixbuf)
|
||||||
{
|
{
|
||||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
*only_fg = pixbuf_is_only_fg (pixbuf);
|
||||||
g_object_unref (pixbuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
GdkTexture *
|
|
||||||
gdk_texture_new_from_stream (GInputStream *stream,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
GdkPixbuf *pixbuf;
|
|
||||||
GdkTexture *texture = NULL;
|
|
||||||
|
|
||||||
pixbuf = _gdk_pixbuf_new_from_stream_scaled (stream, 0, cancellable, error);
|
|
||||||
if (pixbuf)
|
|
||||||
{
|
|
||||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
}
|
}
|
||||||
@@ -497,6 +671,7 @@ gdk_texture_new_from_resource_at_scale (const char *path,
|
|||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
gboolean preserve_aspect,
|
gboolean preserve_aspect,
|
||||||
|
gboolean *only_fg,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
@@ -505,6 +680,7 @@ gdk_texture_new_from_resource_at_scale (const char *path,
|
|||||||
pixbuf = _gdk_pixbuf_new_from_resource_at_scale (path, width, height, preserve_aspect, error);
|
pixbuf = _gdk_pixbuf_new_from_resource_at_scale (path, width, height, preserve_aspect, error);
|
||||||
if (pixbuf)
|
if (pixbuf)
|
||||||
{
|
{
|
||||||
|
*only_fg = pixbuf_is_only_fg (pixbuf);
|
||||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
}
|
}
|
||||||
@@ -516,18 +692,20 @@ gdk_texture_new_from_resource_at_scale (const char *path,
|
|||||||
/* {{{ Symbolic texture API */
|
/* {{{ Symbolic texture API */
|
||||||
|
|
||||||
GdkTexture *
|
GdkTexture *
|
||||||
gdk_texture_new_from_path_symbolic (const char *path,
|
gdk_texture_new_from_filename_symbolic (const char *filename,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
double scale,
|
double scale,
|
||||||
GError **error)
|
gboolean *only_fg,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
GdkTexture *texture = NULL;
|
GdkTexture *texture = NULL;
|
||||||
|
|
||||||
pixbuf = make_symbolic_pixbuf_from_path (path, width, height, scale, error);
|
pixbuf = make_symbolic_pixbuf_from_filename (filename, width, height, scale, error);
|
||||||
if (pixbuf)
|
if (pixbuf)
|
||||||
{
|
{
|
||||||
|
*only_fg = pixbuf_is_only_fg (pixbuf);
|
||||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
}
|
}
|
||||||
@@ -546,6 +724,7 @@ gdk_texture_new_from_resource_symbolic (const char *path,
|
|||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
double scale,
|
double scale,
|
||||||
|
gboolean *only_fg,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
@@ -554,6 +733,7 @@ gdk_texture_new_from_resource_symbolic (const char *path,
|
|||||||
pixbuf = make_symbolic_pixbuf_from_resource (path, width, height, scale, error);
|
pixbuf = make_symbolic_pixbuf_from_resource (path, width, height, scale, error);
|
||||||
if (pixbuf)
|
if (pixbuf)
|
||||||
{
|
{
|
||||||
|
*only_fg = pixbuf_is_only_fg (pixbuf);
|
||||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
}
|
}
|
||||||
@@ -588,14 +768,19 @@ gdk_texture_new_from_file_symbolic (GFile *file,
|
|||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
double scale,
|
double scale,
|
||||||
|
gboolean *only_fg,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
GdkTexture *texture;
|
GdkTexture *texture = NULL;
|
||||||
|
|
||||||
pixbuf = make_symbolic_pixbuf_from_file (file, width, height, scale, error);
|
pixbuf = make_symbolic_pixbuf_from_file (file, width, height, scale, error);
|
||||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
if (pixbuf)
|
||||||
g_object_unref (pixbuf);
|
{
|
||||||
|
*only_fg = pixbuf_is_only_fg (pixbuf);
|
||||||
|
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||||
|
g_object_unref (pixbuf);
|
||||||
|
}
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
@@ -604,7 +789,7 @@ gdk_texture_new_from_file_symbolic (GFile *file,
|
|||||||
/* {{{ Scaled paintable API */
|
/* {{{ Scaled paintable API */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int scale_factor;
|
double scale;
|
||||||
} LoaderData;
|
} LoaderData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -620,24 +805,24 @@ on_loader_size_prepared (GdkPixbufLoader *loader,
|
|||||||
format = gdk_pixbuf_loader_get_format (loader);
|
format = gdk_pixbuf_loader_get_format (loader);
|
||||||
if (!gdk_pixbuf_format_is_scalable (format))
|
if (!gdk_pixbuf_format_is_scalable (format))
|
||||||
{
|
{
|
||||||
loader_data->scale_factor = 1;
|
loader_data->scale = 1.0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_pixbuf_loader_set_size (loader,
|
gdk_pixbuf_loader_set_size (loader,
|
||||||
width * loader_data->scale_factor,
|
width * loader_data->scale,
|
||||||
height * loader_data->scale_factor);
|
height * loader_data->scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkPaintable *
|
static GdkPaintable *
|
||||||
gdk_paintable_new_from_bytes_scaled (GBytes *bytes,
|
gdk_paintable_new_from_bytes_scaled (GBytes *bytes,
|
||||||
int scale_factor)
|
double scale)
|
||||||
{
|
{
|
||||||
LoaderData loader_data;
|
LoaderData loader_data;
|
||||||
GdkTexture *texture;
|
GdkTexture *texture;
|
||||||
GdkPaintable *paintable;
|
GdkPaintable *paintable;
|
||||||
|
|
||||||
loader_data.scale_factor = scale_factor;
|
loader_data.scale = scale;
|
||||||
|
|
||||||
if (gdk_texture_can_load (bytes))
|
if (gdk_texture_can_load (bytes))
|
||||||
{
|
{
|
||||||
@@ -667,8 +852,8 @@ gdk_paintable_new_from_bytes_scaled (GBytes *bytes,
|
|||||||
texture = gdk_texture_new_for_pixbuf (gdk_pixbuf_loader_get_pixbuf (loader));
|
texture = gdk_texture_new_for_pixbuf (gdk_pixbuf_loader_get_pixbuf (loader));
|
||||||
g_object_unref (loader);
|
g_object_unref (loader);
|
||||||
|
|
||||||
if (loader_data.scale_factor != 1)
|
if (loader_data.scale != 1.0)
|
||||||
paintable = gtk_scaler_new (GDK_PAINTABLE (texture), loader_data.scale_factor);
|
paintable = gtk_scaler_new (GDK_PAINTABLE (texture), loader_data.scale);
|
||||||
else
|
else
|
||||||
paintable = g_object_ref (GDK_PAINTABLE (texture));
|
paintable = g_object_ref (GDK_PAINTABLE (texture));
|
||||||
|
|
||||||
@@ -679,20 +864,20 @@ gdk_paintable_new_from_bytes_scaled (GBytes *bytes,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GdkPaintable *
|
GdkPaintable *
|
||||||
gdk_paintable_new_from_path_scaled (const char *path,
|
gdk_paintable_new_from_filename_scaled (const char *filename,
|
||||||
int scale_factor)
|
double scale)
|
||||||
{
|
{
|
||||||
char *contents;
|
char *contents;
|
||||||
gsize length;
|
gsize length;
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
GdkPaintable *paintable;
|
GdkPaintable *paintable;
|
||||||
|
|
||||||
if (!g_file_get_contents (path, &contents, &length, NULL))
|
if (!g_file_get_contents (filename, &contents, &length, NULL))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
bytes = g_bytes_new_take (contents, length);
|
bytes = g_bytes_new_take (contents, length);
|
||||||
|
|
||||||
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale_factor);
|
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale);
|
||||||
|
|
||||||
g_bytes_unref (bytes);
|
g_bytes_unref (bytes);
|
||||||
|
|
||||||
@@ -701,7 +886,7 @@ gdk_paintable_new_from_path_scaled (const char *path,
|
|||||||
|
|
||||||
GdkPaintable *
|
GdkPaintable *
|
||||||
gdk_paintable_new_from_resource_scaled (const char *path,
|
gdk_paintable_new_from_resource_scaled (const char *path,
|
||||||
int scale_factor)
|
double scale)
|
||||||
{
|
{
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
GdkPaintable *paintable;
|
GdkPaintable *paintable;
|
||||||
@@ -710,15 +895,16 @@ gdk_paintable_new_from_resource_scaled (const char *path,
|
|||||||
if (!bytes)
|
if (!bytes)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale_factor);
|
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale);
|
||||||
|
|
||||||
g_bytes_unref (bytes);
|
g_bytes_unref (bytes);
|
||||||
|
|
||||||
return paintable;
|
return paintable;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkPaintable *
|
GdkPaintable *
|
||||||
gdk_paintable_new_from_file_scaled (GFile *file,
|
gdk_paintable_new_from_file_scaled (GFile *file,
|
||||||
int scale_factor)
|
double scale)
|
||||||
{
|
{
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
GdkPaintable *paintable;
|
GdkPaintable *paintable;
|
||||||
@@ -727,7 +913,7 @@ gdk_paintable_new_from_file_scaled (GFile *file,
|
|||||||
if (!bytes)
|
if (!bytes)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale_factor);
|
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale);
|
||||||
|
|
||||||
g_bytes_unref (bytes);
|
g_bytes_unref (bytes);
|
||||||
|
|
||||||
|
|||||||
@@ -29,45 +29,56 @@ GdkPixbuf *gtk_make_symbolic_pixbuf_from_data (const char *data,
|
|||||||
const char *debug_output_to,
|
const char *debug_output_to,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
GdkTexture *gdk_texture_new_from_stream (GInputStream *stream,
|
GdkTexture *gdk_texture_new_from_filename_with_fg (const char *filename,
|
||||||
|
gboolean *only_fg,
|
||||||
|
GError **error);
|
||||||
|
GdkTexture *gdk_texture_new_from_resource_with_fg (const char *path,
|
||||||
|
gboolean *only_fg);
|
||||||
|
GdkTexture *gdk_texture_new_from_stream_with_fg (GInputStream *stream,
|
||||||
|
gboolean *only_fg,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
GdkTexture *gdk_texture_new_from_stream_at_scale (GInputStream *stream,
|
GdkTexture *gdk_texture_new_from_stream_at_scale (GInputStream *stream,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
gboolean aspect,
|
gboolean aspect,
|
||||||
|
gboolean *only_fg,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
GdkTexture *gdk_texture_new_from_resource_at_scale (const char *path,
|
GdkTexture *gdk_texture_new_from_resource_at_scale (const char *path,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
gboolean aspect,
|
gboolean aspect,
|
||||||
|
gboolean *only_fg,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
GdkTexture *gdk_texture_new_from_path_symbolic (const char *path,
|
GdkTexture *gdk_texture_new_from_filename_symbolic (const char *path,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
double scale,
|
double scale,
|
||||||
|
gboolean *only_fg,
|
||||||
GError **error);
|
GError **error);
|
||||||
GdkTexture *gdk_texture_new_from_file_symbolic (GFile *file,
|
GdkTexture *gdk_texture_new_from_file_symbolic (GFile *file,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
double scale,
|
double scale,
|
||||||
|
gboolean *only_fg,
|
||||||
GError **error);
|
GError **error);
|
||||||
GdkTexture *gdk_texture_new_from_resource_symbolic (const char *path,
|
GdkTexture *gdk_texture_new_from_resource_symbolic (const char *path,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
double scale,
|
double scale,
|
||||||
|
gboolean *only_fg,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
GdkTexture *gtk_load_symbolic_texture_from_file (GFile *file);
|
GdkTexture *gtk_load_symbolic_texture_from_file (GFile *file);
|
||||||
GdkTexture *gtk_load_symbolic_texture_from_resource (const char *data);
|
GdkTexture *gtk_load_symbolic_texture_from_resource (const char *path);
|
||||||
|
|
||||||
GdkPaintable *gdk_paintable_new_from_path_scaled (const char *path,
|
GdkPaintable *gdk_paintable_new_from_filename_scaled (const char *filename,
|
||||||
int scale_factor);
|
double scale);
|
||||||
GdkPaintable *gdk_paintable_new_from_resource_scaled (const char *path,
|
GdkPaintable *gdk_paintable_new_from_resource_scaled (const char *path,
|
||||||
int scale_factor);
|
double scale);
|
||||||
GdkPaintable *gdk_paintable_new_from_file_scaled (GFile *file,
|
GdkPaintable *gdk_paintable_new_from_file_scaled (GFile *file,
|
||||||
int scale_factor);
|
double scale);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|||||||
+25
-6
@@ -28,6 +28,7 @@
|
|||||||
#include "gtkwidgetprivate.h"
|
#include "gtkwidgetprivate.h"
|
||||||
#include "gtkcsscolorvalueprivate.h"
|
#include "gtkcsscolorvalueprivate.h"
|
||||||
#include "gdk/gdkrgbaprivate.h"
|
#include "gdk/gdkrgbaprivate.h"
|
||||||
|
#include "gtkcssshadowvalueprivate.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@@ -97,6 +98,11 @@ gsk_pango_renderer_draw_glyph_item (PangoRenderer *renderer,
|
|||||||
{
|
{
|
||||||
GskPangoRenderer *crenderer = (GskPangoRenderer *) (renderer);
|
GskPangoRenderer *crenderer = (GskPangoRenderer *) (renderer);
|
||||||
GdkRGBA color;
|
GdkRGBA color;
|
||||||
|
gboolean has_shadow = FALSE;
|
||||||
|
|
||||||
|
if (crenderer->shadow_style)
|
||||||
|
has_shadow = gtk_css_shadow_value_push_snapshot (crenderer->shadow_style->font->text_shadow,
|
||||||
|
crenderer->snapshot);
|
||||||
|
|
||||||
get_color (crenderer, PANGO_RENDER_PART_FOREGROUND, &color);
|
get_color (crenderer, PANGO_RENDER_PART_FOREGROUND, &color);
|
||||||
|
|
||||||
@@ -106,6 +112,9 @@ gsk_pango_renderer_draw_glyph_item (PangoRenderer *renderer,
|
|||||||
&color,
|
&color,
|
||||||
(float) x / PANGO_SCALE,
|
(float) x / PANGO_SCALE,
|
||||||
(float) y / PANGO_SCALE);
|
(float) y / PANGO_SCALE);
|
||||||
|
|
||||||
|
if (has_shadow)
|
||||||
|
gtk_snapshot_pop (crenderer->snapshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -343,20 +352,20 @@ gsk_pango_renderer_prepare_run (PangoRenderer *renderer,
|
|||||||
GTK_IS_TEXT_VIEW (crenderer->widget))
|
GTK_IS_TEXT_VIEW (crenderer->widget))
|
||||||
{
|
{
|
||||||
GtkCssNode *node;
|
GtkCssNode *node;
|
||||||
GtkCssValue *value;
|
GtkCssStyle *style;
|
||||||
|
|
||||||
node = gtk_text_view_get_selection_node ((GtkTextView *)crenderer->widget);
|
node = gtk_text_view_get_selection_node ((GtkTextView *)crenderer->widget);
|
||||||
value = gtk_css_node_get_style (node)->core->color;
|
style = gtk_css_node_get_style (node);
|
||||||
fg_rgba = gtk_css_color_value_get_rgba (value);
|
fg_rgba = gtk_css_color_value_get_rgba (style->core->color);
|
||||||
}
|
}
|
||||||
else if (crenderer->state == GSK_PANGO_RENDERER_CURSOR && gtk_widget_has_focus (crenderer->widget))
|
else if (crenderer->state == GSK_PANGO_RENDERER_CURSOR && gtk_widget_has_focus (crenderer->widget))
|
||||||
{
|
{
|
||||||
GtkCssNode *node;
|
GtkCssNode *node;
|
||||||
GtkCssValue *value;
|
GtkCssStyle *style;
|
||||||
|
|
||||||
node = gtk_widget_get_css_node (crenderer->widget);
|
node = gtk_widget_get_css_node (crenderer->widget);
|
||||||
value = gtk_css_node_get_style (node)->background->background_color;
|
style = gtk_css_node_get_style (node);
|
||||||
fg_rgba = gtk_css_color_value_get_rgba (value);
|
fg_rgba = gtk_css_color_value_get_rgba (style->background->background_color);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fg_rgba = appearance->fg_rgba;
|
fg_rgba = appearance->fg_rgba;
|
||||||
@@ -382,6 +391,15 @@ gsk_pango_renderer_prepare_run (PangoRenderer *renderer,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
text_renderer_set_rgba (crenderer, PANGO_RENDER_PART_UNDERLINE, fg_rgba);
|
text_renderer_set_rgba (crenderer, PANGO_RENDER_PART_UNDERLINE, fg_rgba);
|
||||||
|
|
||||||
|
crenderer->shadow_style = NULL;
|
||||||
|
if (GTK_IS_TEXT_VIEW (crenderer->widget))
|
||||||
|
{
|
||||||
|
if (crenderer->state == GSK_PANGO_RENDERER_SELECTED)
|
||||||
|
crenderer->shadow_style = gtk_css_node_get_style (gtk_text_view_get_selection_node ((GtkTextView *)crenderer->widget));
|
||||||
|
else if (crenderer->state != GSK_PANGO_RENDERER_CURSOR)
|
||||||
|
crenderer->shadow_style = gtk_css_node_get_style (gtk_widget_get_css_node (crenderer->widget));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -439,6 +457,7 @@ gsk_pango_renderer_release (GskPangoRenderer *renderer)
|
|||||||
{
|
{
|
||||||
renderer->widget = NULL;
|
renderer->widget = NULL;
|
||||||
renderer->snapshot = NULL;
|
renderer->snapshot = NULL;
|
||||||
|
renderer->shadow_style = NULL;
|
||||||
|
|
||||||
if (renderer->error_color)
|
if (renderer->error_color)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <pango/pango.h>
|
#include <pango/pango.h>
|
||||||
#include "gtk/gtksnapshot.h"
|
#include "gtk/gtksnapshot.h"
|
||||||
|
#include "gtk/gtkcssstyleprivate.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@ struct _GskPangoRenderer
|
|||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GtkSnapshot *snapshot;
|
GtkSnapshot *snapshot;
|
||||||
const GdkRGBA *fg_color;
|
const GdkRGBA *fg_color;
|
||||||
|
GtkCssStyle *shadow_style;
|
||||||
|
|
||||||
/* Error underline color for this widget */
|
/* Error underline color for this widget */
|
||||||
GdkRGBA *error_color;
|
GdkRGBA *error_color;
|
||||||
|
|||||||
@@ -808,6 +808,11 @@ static const GtkAccessibleCollect collect_props[] = {
|
|||||||
.ctype = GTK_ACCESSIBLE_COLLECT_STRING,
|
.ctype = GTK_ACCESSIBLE_COLLECT_STRING,
|
||||||
.name = "valuetext"
|
.name = "valuetext"
|
||||||
},
|
},
|
||||||
|
[GTK_ACCESSIBLE_PROPERTY_HELP_TEXT] = {
|
||||||
|
.value = GTK_ACCESSIBLE_PROPERTY_HELP_TEXT,
|
||||||
|
.ctype = GTK_ACCESSIBLE_COLLECT_STRING,
|
||||||
|
.name = "helptext"
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* § 6.6.4 Relationship Attributes */
|
/* § 6.6.4 Relationship Attributes */
|
||||||
@@ -1662,7 +1667,7 @@ gtk_accessible_value_get_default_for_property (GtkAccessibleProperty property)
|
|||||||
{
|
{
|
||||||
const GtkAccessibleCollect *cstate = &collect_props[property];
|
const GtkAccessibleCollect *cstate = &collect_props[property];
|
||||||
|
|
||||||
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT, NULL);
|
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT, NULL);
|
||||||
|
|
||||||
switch (cstate->value)
|
switch (cstate->value)
|
||||||
{
|
{
|
||||||
@@ -1692,6 +1697,7 @@ gtk_accessible_value_get_default_for_property (GtkAccessibleProperty property)
|
|||||||
case GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER:
|
case GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER:
|
||||||
case GTK_ACCESSIBLE_PROPERTY_ROLE_DESCRIPTION:
|
case GTK_ACCESSIBLE_PROPERTY_ROLE_DESCRIPTION:
|
||||||
case GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT:
|
case GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT:
|
||||||
|
case GTK_ACCESSIBLE_PROPERTY_HELP_TEXT:
|
||||||
return gtk_undefined_accessible_value_new ();
|
return gtk_undefined_accessible_value_new ();
|
||||||
|
|
||||||
/* Token properties */
|
/* Token properties */
|
||||||
@@ -1732,7 +1738,7 @@ gtk_accessible_value_collect_for_property (GtkAccessibleProperty property,
|
|||||||
{
|
{
|
||||||
const GtkAccessibleCollect *cstate = &collect_props[property];
|
const GtkAccessibleCollect *cstate = &collect_props[property];
|
||||||
|
|
||||||
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT, NULL);
|
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT, NULL);
|
||||||
|
|
||||||
return gtk_accessible_value_collect_valist (cstate, error, args);
|
return gtk_accessible_value_collect_valist (cstate, error, args);
|
||||||
}
|
}
|
||||||
@@ -1760,7 +1766,7 @@ gtk_accessible_value_collect_for_property_value (GtkAccessibleProperty propert
|
|||||||
{
|
{
|
||||||
const GtkAccessibleCollect *cstate = &collect_props[property];
|
const GtkAccessibleCollect *cstate = &collect_props[property];
|
||||||
|
|
||||||
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT, NULL);
|
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT, NULL);
|
||||||
|
|
||||||
return gtk_accessible_value_collect_value (cstate, value, error);
|
return gtk_accessible_value_collect_value (cstate, value, error);
|
||||||
}
|
}
|
||||||
@@ -1773,7 +1779,7 @@ gtk_accessible_value_parse_for_property (GtkAccessibleProperty property,
|
|||||||
{
|
{
|
||||||
const GtkAccessibleCollect *cstate = &collect_props[property];
|
const GtkAccessibleCollect *cstate = &collect_props[property];
|
||||||
|
|
||||||
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT, NULL);
|
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT, NULL);
|
||||||
|
|
||||||
return gtk_accessible_value_parse (cstate, str, len, error);
|
return gtk_accessible_value_parse (cstate, str, len, error);
|
||||||
}
|
}
|
||||||
@@ -1794,7 +1800,7 @@ gtk_accessible_property_init_value (GtkAccessibleProperty property,
|
|||||||
{
|
{
|
||||||
const GtkAccessibleCollect *cstate = &collect_props[property];
|
const GtkAccessibleCollect *cstate = &collect_props[property];
|
||||||
|
|
||||||
g_return_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT);
|
g_return_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT);
|
||||||
|
|
||||||
gtk_accessible_attribute_init_value (cstate, value);
|
gtk_accessible_attribute_init_value (cstate, value);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-103
@@ -74,10 +74,6 @@
|
|||||||
* It is also possible to provide the menubar manually using
|
* It is also possible to provide the menubar manually using
|
||||||
* [method@Gtk.Application.set_menubar].
|
* [method@Gtk.Application.set_menubar].
|
||||||
*
|
*
|
||||||
* A custom 'Application' menu can be set using [method@Gtk.Application.set_app_menu].
|
|
||||||
* This is mainly relevant on macOS, where GTK will otherwise provide a standard
|
|
||||||
* app menu.
|
|
||||||
*
|
|
||||||
* `GtkApplication` will also automatically setup an icon search path for
|
* `GtkApplication` will also automatically setup an icon search path for
|
||||||
* the default icon theme by appending "icons" to the resource base
|
* the default icon theme by appending "icons" to the resource base
|
||||||
* path. This allows your application to easily store its icons as
|
* path. This allows your application to easily store its icons as
|
||||||
@@ -129,7 +125,6 @@ enum {
|
|||||||
PROP_ZERO,
|
PROP_ZERO,
|
||||||
PROP_REGISTER_SESSION,
|
PROP_REGISTER_SESSION,
|
||||||
PROP_SCREENSAVER_ACTIVE,
|
PROP_SCREENSAVER_ACTIVE,
|
||||||
PROP_APP_MENU,
|
|
||||||
PROP_MENUBAR,
|
PROP_MENUBAR,
|
||||||
PROP_ACTIVE_WINDOW,
|
PROP_ACTIVE_WINDOW,
|
||||||
NUM_PROPERTIES
|
NUM_PROPERTIES
|
||||||
@@ -144,7 +139,6 @@ typedef struct
|
|||||||
|
|
||||||
GList *windows;
|
GList *windows;
|
||||||
|
|
||||||
GMenuModel *app_menu;
|
|
||||||
GMenuModel *menubar;
|
GMenuModel *menubar;
|
||||||
guint last_window_id;
|
guint last_window_id;
|
||||||
|
|
||||||
@@ -221,9 +215,6 @@ gtk_application_load_resources (GtkApplication *application)
|
|||||||
{
|
{
|
||||||
GObject *menu;
|
GObject *menu;
|
||||||
|
|
||||||
menu = gtk_builder_get_object (priv->menus_builder, "app-menu");
|
|
||||||
if (menu != NULL && G_IS_MENU_MODEL (menu))
|
|
||||||
gtk_application_set_app_menu (application, G_MENU_MODEL (menu));
|
|
||||||
menu = gtk_builder_get_object (priv->menus_builder, "menubar");
|
menu = gtk_builder_get_object (priv->menus_builder, "menubar");
|
||||||
if (menu != NULL && G_IS_MENU_MODEL (menu))
|
if (menu != NULL && G_IS_MENU_MODEL (menu))
|
||||||
gtk_application_set_menubar (application, G_MENU_MODEL (menu));
|
gtk_application_set_menubar (application, G_MENU_MODEL (menu));
|
||||||
@@ -447,10 +438,6 @@ gtk_application_get_property (GObject *object,
|
|||||||
g_value_set_boolean (value, priv->screensaver_active);
|
g_value_set_boolean (value, priv->screensaver_active);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_APP_MENU:
|
|
||||||
g_value_set_object (value, gtk_application_get_app_menu (application));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PROP_MENUBAR:
|
case PROP_MENUBAR:
|
||||||
g_value_set_object (value, gtk_application_get_menubar (application));
|
g_value_set_object (value, gtk_application_get_menubar (application));
|
||||||
break;
|
break;
|
||||||
@@ -480,10 +467,6 @@ gtk_application_set_property (GObject *object,
|
|||||||
priv->register_session = g_value_get_boolean (value);
|
priv->register_session = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_APP_MENU:
|
|
||||||
gtk_application_set_app_menu (application, g_value_get_object (value));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PROP_MENUBAR:
|
case PROP_MENUBAR:
|
||||||
gtk_application_set_menubar (application, g_value_get_object (value));
|
gtk_application_set_menubar (application, g_value_get_object (value));
|
||||||
break;
|
break;
|
||||||
@@ -501,7 +484,6 @@ gtk_application_finalize (GObject *object)
|
|||||||
GtkApplicationPrivate *priv = gtk_application_get_instance_private (application);
|
GtkApplicationPrivate *priv = gtk_application_get_instance_private (application);
|
||||||
|
|
||||||
g_clear_object (&priv->menus_builder);
|
g_clear_object (&priv->menus_builder);
|
||||||
g_clear_object (&priv->app_menu);
|
|
||||||
g_clear_object (&priv->menubar);
|
g_clear_object (&priv->menubar);
|
||||||
g_clear_object (&priv->muxer);
|
g_clear_object (&priv->muxer);
|
||||||
g_clear_object (&priv->accels);
|
g_clear_object (&priv->accels);
|
||||||
@@ -629,21 +611,6 @@ gtk_application_class_init (GtkApplicationClass *class)
|
|||||||
FALSE,
|
FALSE,
|
||||||
G_PARAM_READABLE|G_PARAM_STATIC_STRINGS);
|
G_PARAM_READABLE|G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
/**
|
|
||||||
* GtkApplication:app-menu: (attributes org.gtk.Property.get=gtk_application_get_app_menu org.gtk.Property.set=gtk_application_set_app_menu)
|
|
||||||
*
|
|
||||||
* The `GMenuModel` to be used for the application's app menu.
|
|
||||||
*
|
|
||||||
* This is mainly relevant on macOS, where GTK will provide a
|
|
||||||
* standard app menu, unless it is overwritten by setting this property.
|
|
||||||
*
|
|
||||||
* Since: 4.16
|
|
||||||
*/
|
|
||||||
gtk_application_props[PROP_APP_MENU] =
|
|
||||||
g_param_spec_object ("app-menu", NULL, NULL,
|
|
||||||
G_TYPE_MENU_MODEL,
|
|
||||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkApplication:menubar: (attributes org.gtk.Property.get=gtk_application_get_menubar org.gtk.Property.set=gtk_application_set_menubar)
|
* GtkApplication:menubar: (attributes org.gtk.Property.get=gtk_application_get_menubar org.gtk.Property.set=gtk_application_set_menubar)
|
||||||
*
|
*
|
||||||
@@ -866,75 +833,6 @@ gtk_application_update_accels (GtkApplication *application)
|
|||||||
_gtk_window_notify_keys_changed (l->data);
|
_gtk_window_notify_keys_changed (l->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gtk_application_set_app_menu:
|
|
||||||
* @application: a #GtkApplication
|
|
||||||
* @app_menu: (allow-none): a #GMenuModel, or %NULL
|
|
||||||
*
|
|
||||||
* Sets or unsets the application menu for @application.
|
|
||||||
*
|
|
||||||
* This can only be done in the primary instance of the application,
|
|
||||||
* after it has been registered. #GApplication::startup is a good place
|
|
||||||
* to call this.
|
|
||||||
*
|
|
||||||
* The application menu is a single menu containing items that typically
|
|
||||||
* impact the application as a whole, rather than acting on a specific
|
|
||||||
* window or document. For example, you would expect to see
|
|
||||||
* “Preferences” or “Quit” in an application menu, but not “Save” or
|
|
||||||
* “Print”.
|
|
||||||
*
|
|
||||||
* If supported, the application menu will be rendered by the desktop
|
|
||||||
* environment.
|
|
||||||
*
|
|
||||||
* Use the base #GActionMap interface to add actions, to respond to the user
|
|
||||||
* selecting these menu items.
|
|
||||||
*
|
|
||||||
* Note that setting an app menu is mainly relevant on macOS, where GTK
|
|
||||||
* provides a standard app menu unless overwritten by this function.
|
|
||||||
*
|
|
||||||
* Since: 4.16
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gtk_application_set_app_menu (GtkApplication *application,
|
|
||||||
GMenuModel *app_menu)
|
|
||||||
{
|
|
||||||
GtkApplicationPrivate *priv = gtk_application_get_instance_private (application);
|
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_APPLICATION (application));
|
|
||||||
g_return_if_fail (g_application_get_is_registered (G_APPLICATION (application)));
|
|
||||||
g_return_if_fail (!g_application_get_is_remote (G_APPLICATION (application)));
|
|
||||||
g_return_if_fail (app_menu == NULL || G_IS_MENU_MODEL (app_menu));
|
|
||||||
|
|
||||||
if (g_set_object (&priv->app_menu, app_menu))
|
|
||||||
{
|
|
||||||
gtk_application_impl_set_app_menu (priv->impl, app_menu);
|
|
||||||
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (application), gtk_application_props[PROP_APP_MENU]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gtk_application_get_app_menu:
|
|
||||||
* @application: a #GtkApplication
|
|
||||||
*
|
|
||||||
* Returns the menu model that has been set with gtk_application_set_app_menu().
|
|
||||||
*
|
|
||||||
* Returns: (transfer none) (nullable): the application menu of @application
|
|
||||||
* or %NULL if no application menu has been set.
|
|
||||||
*
|
|
||||||
* Since: 4.16
|
|
||||||
*/
|
|
||||||
GMenuModel *
|
|
||||||
gtk_application_get_app_menu (GtkApplication *application)
|
|
||||||
{
|
|
||||||
GtkApplicationPrivate *priv = gtk_application_get_instance_private (application);
|
|
||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_APPLICATION (application), NULL);
|
|
||||||
|
|
||||||
return priv->app_menu;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_application_set_menubar: (attributes org.gtk.Method.set_property=menubar)
|
* gtk_application_set_menubar: (attributes org.gtk.Method.set_property=menubar)
|
||||||
* @application: a `GtkApplication`
|
* @application: a `GtkApplication`
|
||||||
@@ -1092,11 +990,13 @@ GtkActionMuxer *
|
|||||||
gtk_application_get_parent_muxer_for_window (GtkWindow *window)
|
gtk_application_get_parent_muxer_for_window (GtkWindow *window)
|
||||||
{
|
{
|
||||||
GtkApplication *application = gtk_window_get_application (window);
|
GtkApplication *application = gtk_window_get_application (window);
|
||||||
GtkApplicationPrivate *priv = gtk_application_get_instance_private (application);
|
GtkApplicationPrivate *priv;
|
||||||
|
|
||||||
if (!application)
|
if (!application)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
priv = gtk_application_get_instance_private (application);
|
||||||
|
|
||||||
return priv->muxer;
|
return priv->muxer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,12 +84,6 @@ void gtk_application_remove_window (GtkApplication *application,
|
|||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GList * gtk_application_get_windows (GtkApplication *application);
|
GList * gtk_application_get_windows (GtkApplication *application);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
GMenuModel * gtk_application_get_app_menu (GtkApplication *application);
|
|
||||||
GDK_AVAILABLE_IN_4_16
|
|
||||||
void gtk_application_set_app_menu (GtkApplication *application,
|
|
||||||
GMenuModel *app_menu);
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GMenuModel * gtk_application_get_menubar (GtkApplication *application);
|
GMenuModel * gtk_application_get_menubar (GtkApplication *application);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
|
|||||||
+6
-4
@@ -328,6 +328,7 @@ static const char *property_attrs[] = {
|
|||||||
[GTK_ACCESSIBLE_PROPERTY_VALUE_MIN] = "valuemin",
|
[GTK_ACCESSIBLE_PROPERTY_VALUE_MIN] = "valuemin",
|
||||||
[GTK_ACCESSIBLE_PROPERTY_VALUE_NOW] = "valuenow",
|
[GTK_ACCESSIBLE_PROPERTY_VALUE_NOW] = "valuenow",
|
||||||
[GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT] = "valuetext",
|
[GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT] = "valuetext",
|
||||||
|
[GTK_ACCESSIBLE_PROPERTY_HELP_TEXT] = "helptext",
|
||||||
};
|
};
|
||||||
|
|
||||||
/*< private >
|
/*< private >
|
||||||
@@ -342,7 +343,7 @@ const char *
|
|||||||
gtk_accessible_property_get_attribute_name (GtkAccessibleProperty property)
|
gtk_accessible_property_get_attribute_name (GtkAccessibleProperty property)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (property >= GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE &&
|
g_return_val_if_fail (property >= GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE &&
|
||||||
property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT,
|
property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT,
|
||||||
"<none>");
|
"<none>");
|
||||||
|
|
||||||
return property_attrs[property];
|
return property_attrs[property];
|
||||||
@@ -1055,6 +1056,7 @@ gtk_at_context_get_accessible_relation (GtkATContext *self,
|
|||||||
static guint8 naming[] = {
|
static guint8 naming[] = {
|
||||||
[GTK_ACCESSIBLE_ROLE_ALERT] = NAME_FROM_AUTHOR,
|
[GTK_ACCESSIBLE_ROLE_ALERT] = NAME_FROM_AUTHOR,
|
||||||
[GTK_ACCESSIBLE_ROLE_ALERT_DIALOG] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
[GTK_ACCESSIBLE_ROLE_ALERT_DIALOG] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||||
|
[GTK_ACCESSIBLE_ROLE_APPLICATION] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||||
[GTK_ACCESSIBLE_ROLE_ARTICLE] = NAME_FROM_AUTHOR,
|
[GTK_ACCESSIBLE_ROLE_ARTICLE] = NAME_FROM_AUTHOR,
|
||||||
[GTK_ACCESSIBLE_ROLE_BANNER] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
[GTK_ACCESSIBLE_ROLE_BANNER] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
||||||
[GTK_ACCESSIBLE_ROLE_BLOCK_QUOTE] = NAME_FROM_AUTHOR,
|
[GTK_ACCESSIBLE_ROLE_BLOCK_QUOTE] = NAME_FROM_AUTHOR,
|
||||||
@@ -1099,6 +1101,7 @@ static guint8 naming[] = {
|
|||||||
[GTK_ACCESSIBLE_ROLE_NONE] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
[GTK_ACCESSIBLE_ROLE_NONE] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
||||||
[GTK_ACCESSIBLE_ROLE_NOTE] = NAME_FROM_AUTHOR,
|
[GTK_ACCESSIBLE_ROLE_NOTE] = NAME_FROM_AUTHOR,
|
||||||
[GTK_ACCESSIBLE_ROLE_OPTION] = NAME_FROM_AUTHOR|NAME_FROM_CONTENT|GTK_ACCESSIBLE_NAME_REQUIRED,
|
[GTK_ACCESSIBLE_ROLE_OPTION] = NAME_FROM_AUTHOR|NAME_FROM_CONTENT|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||||
|
[GTK_ACCESSIBLE_ROLE_PARAGRAPH] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
||||||
[GTK_ACCESSIBLE_ROLE_PRESENTATION] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
[GTK_ACCESSIBLE_ROLE_PRESENTATION] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
||||||
[GTK_ACCESSIBLE_ROLE_PROGRESS_BAR] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
[GTK_ACCESSIBLE_ROLE_PROGRESS_BAR] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||||
[GTK_ACCESSIBLE_ROLE_RADIO] = NAME_FROM_AUTHOR|NAME_FROM_CONTENT|GTK_ACCESSIBLE_NAME_REQUIRED,
|
[GTK_ACCESSIBLE_ROLE_RADIO] = NAME_FROM_AUTHOR|NAME_FROM_CONTENT|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||||
@@ -1124,9 +1127,11 @@ static guint8 naming[] = {
|
|||||||
[GTK_ACCESSIBLE_ROLE_TABLE] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
[GTK_ACCESSIBLE_ROLE_TABLE] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||||
[GTK_ACCESSIBLE_ROLE_TAB_LIST] = NAME_FROM_AUTHOR,
|
[GTK_ACCESSIBLE_ROLE_TAB_LIST] = NAME_FROM_AUTHOR,
|
||||||
[GTK_ACCESSIBLE_ROLE_TAB_PANEL] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
[GTK_ACCESSIBLE_ROLE_TAB_PANEL] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||||
|
[GTK_ACCESSIBLE_ROLE_TERMINAL] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||||
[GTK_ACCESSIBLE_ROLE_TEXT_BOX] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
[GTK_ACCESSIBLE_ROLE_TEXT_BOX] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||||
[GTK_ACCESSIBLE_ROLE_TIME] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
[GTK_ACCESSIBLE_ROLE_TIME] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
||||||
[GTK_ACCESSIBLE_ROLE_TIMER] = NAME_FROM_AUTHOR,
|
[GTK_ACCESSIBLE_ROLE_TIMER] = NAME_FROM_AUTHOR,
|
||||||
|
[GTK_ACCESSIBLE_ROLE_TOGGLE_BUTTON] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||||
[GTK_ACCESSIBLE_ROLE_TOOLBAR] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_RECOMMENDED,
|
[GTK_ACCESSIBLE_ROLE_TOOLBAR] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_RECOMMENDED,
|
||||||
[GTK_ACCESSIBLE_ROLE_TOOLTIP] = NAME_FROM_AUTHOR|NAME_FROM_CONTENT,
|
[GTK_ACCESSIBLE_ROLE_TOOLTIP] = NAME_FROM_AUTHOR|NAME_FROM_CONTENT,
|
||||||
[GTK_ACCESSIBLE_ROLE_TREE] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
[GTK_ACCESSIBLE_ROLE_TREE] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||||
@@ -1134,9 +1139,6 @@ static guint8 naming[] = {
|
|||||||
[GTK_ACCESSIBLE_ROLE_TREE_ITEM] = NAME_FROM_AUTHOR|NAME_FROM_CONTENT|GTK_ACCESSIBLE_NAME_REQUIRED,
|
[GTK_ACCESSIBLE_ROLE_TREE_ITEM] = NAME_FROM_AUTHOR|NAME_FROM_CONTENT|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||||
[GTK_ACCESSIBLE_ROLE_WIDGET] = NAME_FROM_AUTHOR|NAME_FROM_CONTENT,
|
[GTK_ACCESSIBLE_ROLE_WIDGET] = NAME_FROM_AUTHOR|NAME_FROM_CONTENT,
|
||||||
[GTK_ACCESSIBLE_ROLE_WINDOW] = NAME_FROM_AUTHOR,
|
[GTK_ACCESSIBLE_ROLE_WINDOW] = NAME_FROM_AUTHOR,
|
||||||
[GTK_ACCESSIBLE_ROLE_TOGGLE_BUTTON] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
|
||||||
[GTK_ACCESSIBLE_ROLE_APPLICATION] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
|
||||||
[GTK_ACCESSIBLE_ROLE_PARAGRAPH] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* < private >
|
/* < private >
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ typedef enum {
|
|||||||
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_MAX = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_MAX,
|
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_MAX = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_MAX,
|
||||||
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_MIN = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_MIN,
|
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_MIN = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_MIN,
|
||||||
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_NOW = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_NOW,
|
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_NOW = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_NOW,
|
||||||
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_TEXT = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT
|
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_TEXT = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT,
|
||||||
|
GTK_ACCESSIBLE_PROPERTY_CHANGE_HELP_TEXT = 1 << GTK_ACCESSIBLE_PROPERTY_HELP_TEXT,
|
||||||
} GtkAccessiblePropertyChange;
|
} GtkAccessiblePropertyChange;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|||||||
@@ -32,8 +32,12 @@
|
|||||||
* `GtkBuilderListItemFactory` is a `GtkListItemFactory` that creates
|
* `GtkBuilderListItemFactory` is a `GtkListItemFactory` that creates
|
||||||
* widgets by instantiating `GtkBuilder` UI templates.
|
* widgets by instantiating `GtkBuilder` UI templates.
|
||||||
*
|
*
|
||||||
* The templates must be extending `GtkListItem`, and typically use
|
* The templates must extend the class that the parent widget expects.
|
||||||
* `GtkExpression`s to obtain data from the items in the model.
|
* For example, a factory provided to [property@Gtk.ListView:factory] must have
|
||||||
|
* a template that extends [class@Gtk.ListItem].
|
||||||
|
*
|
||||||
|
* Templates typically use `GtkExpression`s to obtain data from the items
|
||||||
|
* in the model.
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* ```xml
|
* ```xml
|
||||||
@@ -203,7 +207,7 @@ gtk_builder_list_item_factory_set_property (GObject *object,
|
|||||||
case PROP_RESOURCE:
|
case PROP_RESOURCE:
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
const char *resource;
|
const char *resource;
|
||||||
|
|
||||||
resource = g_value_get_string (value);
|
resource = g_value_get_string (value);
|
||||||
|
|||||||
@@ -1006,7 +1006,7 @@ gtk_check_button_set_group (GtkCheckButton *self,
|
|||||||
GtkCheckButton *group)
|
GtkCheckButton *group)
|
||||||
{
|
{
|
||||||
GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (self);
|
GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (self);
|
||||||
GtkCheckButtonPrivate *group_priv = gtk_check_button_get_instance_private (group);
|
GtkCheckButtonPrivate *group_priv;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_CHECK_BUTTON (self));
|
g_return_if_fail (GTK_IS_CHECK_BUTTON (self));
|
||||||
g_return_if_fail (self != group);
|
g_return_if_fail (self != group);
|
||||||
@@ -1037,6 +1037,8 @@ gtk_check_button_set_group (GtkCheckButton *self,
|
|||||||
if (priv->group_next == group)
|
if (priv->group_next == group)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
group_priv = gtk_check_button_get_instance_private (group);
|
||||||
|
|
||||||
priv->group_prev = NULL;
|
priv->group_prev = NULL;
|
||||||
if (group_priv->group_prev)
|
if (group_priv->group_prev)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -861,6 +861,8 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
|
|||||||
*
|
*
|
||||||
* The factory used for configuring rows.
|
* The factory used for configuring rows.
|
||||||
*
|
*
|
||||||
|
* The factory must be for configuring [class@Gtk.ColumnViewRow] objects.
|
||||||
|
*
|
||||||
* Since: 4.12
|
* Since: 4.12
|
||||||
*/
|
*/
|
||||||
properties[PROP_ROW_FACTORY] =
|
properties[PROP_ROW_FACTORY] =
|
||||||
@@ -926,6 +928,8 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
|
|||||||
*
|
*
|
||||||
* Factory for creating header widgets.
|
* Factory for creating header widgets.
|
||||||
*
|
*
|
||||||
|
* The factory must be for configuring [class@Gtk.ListHeader] objects.
|
||||||
|
*
|
||||||
* Since: 4.12
|
* Since: 4.12
|
||||||
*/
|
*/
|
||||||
properties[PROP_HEADER_FACTORY] =
|
properties[PROP_HEADER_FACTORY] =
|
||||||
|
|||||||
@@ -255,6 +255,8 @@ gtk_column_view_column_class_init (GtkColumnViewColumnClass *klass)
|
|||||||
* GtkColumnViewColumn:factory: (attributes org.gtk.Property.get=gtk_column_view_column_get_factory org.gtk.Property.set=gtk_column_view_column_set_factory)
|
* GtkColumnViewColumn:factory: (attributes org.gtk.Property.get=gtk_column_view_column_get_factory org.gtk.Property.set=gtk_column_view_column_set_factory)
|
||||||
*
|
*
|
||||||
* Factory for populating list items.
|
* Factory for populating list items.
|
||||||
|
*
|
||||||
|
* The factory must be for configuring [class@Gtk.ColumnViewCell] objects.
|
||||||
*/
|
*/
|
||||||
properties[PROP_FACTORY] =
|
properties[PROP_FACTORY] =
|
||||||
g_param_spec_object ("factory", NULL, NULL,
|
g_param_spec_object ("factory", NULL, NULL,
|
||||||
@@ -761,7 +763,7 @@ gtk_column_view_column_remove_from_sorter (GtkColumnViewColumn *self)
|
|||||||
{
|
{
|
||||||
if (self->view == NULL)
|
if (self->view == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gtk_column_view_sorter_remove_column (GTK_COLUMN_VIEW_SORTER (gtk_column_view_get_sorter (self->view)), self);
|
gtk_column_view_sorter_remove_column (GTK_COLUMN_VIEW_SORTER (gtk_column_view_get_sorter (self->view)), self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+144
-6
@@ -33,13 +33,59 @@
|
|||||||
#include "gtkcssstringvalueprivate.h"
|
#include "gtkcssstringvalueprivate.h"
|
||||||
#include "gtkcssstylepropertyprivate.h"
|
#include "gtkcssstylepropertyprivate.h"
|
||||||
#include "gtkcsstransitionprivate.h"
|
#include "gtkcsstransitionprivate.h"
|
||||||
|
#include "gtkcssvaluesprivate.h"
|
||||||
#include "gtkprivate.h"
|
#include "gtkprivate.h"
|
||||||
#include "gtkstyleanimationprivate.h"
|
#include "gtkstyleanimationprivate.h"
|
||||||
#include "gtkstylepropertyprivate.h"
|
#include "gtkstylepropertyprivate.h"
|
||||||
#include "gtkstyleproviderprivate.h"
|
#include "gtkstyleproviderprivate.h"
|
||||||
|
#include "gtkcsscustompropertypoolprivate.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (GtkCssAnimatedStyle, gtk_css_animated_style, GTK_TYPE_CSS_STYLE)
|
G_DEFINE_TYPE (GtkCssAnimatedStyle, gtk_css_animated_style, GTK_TYPE_CSS_STYLE)
|
||||||
|
|
||||||
|
#define DEFINE_VALUES(ENUM, TYPE, NAME) \
|
||||||
|
static inline void \
|
||||||
|
gtk_css_ ## NAME ## _values_recompute (GtkCssAnimatedStyle *animated) \
|
||||||
|
{ \
|
||||||
|
GtkCssStyle *style = (GtkCssStyle *)animated; \
|
||||||
|
GtkCssValue **values = (GtkCssValue **)((guint8*)(animated->style->NAME) + sizeof (GtkCssValues)); \
|
||||||
|
int i; \
|
||||||
|
\
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (NAME ## _props); i++) \
|
||||||
|
{ \
|
||||||
|
guint id = NAME ## _props[i]; \
|
||||||
|
GtkCssValue *original, *computed; \
|
||||||
|
\
|
||||||
|
if (values[i] == NULL) \
|
||||||
|
continue; \
|
||||||
|
\
|
||||||
|
original = gtk_css_style_get_original_value (style, id); \
|
||||||
|
if (original == NULL) \
|
||||||
|
continue; \
|
||||||
|
\
|
||||||
|
computed = _gtk_css_value_compute (original, \
|
||||||
|
id, \
|
||||||
|
animated->provider, \
|
||||||
|
style, \
|
||||||
|
animated->parent_style, \
|
||||||
|
NULL); \
|
||||||
|
if (computed == NULL) \
|
||||||
|
continue; \
|
||||||
|
\
|
||||||
|
gtk_css_animated_style_set_animated_value (animated, id, computed); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_VALUES (CORE, Core, core)
|
||||||
|
DEFINE_VALUES (BACKGROUND, Background, background)
|
||||||
|
DEFINE_VALUES (BORDER, Border, border)
|
||||||
|
DEFINE_VALUES (ICON, Icon, icon)
|
||||||
|
DEFINE_VALUES (OUTLINE, Outline, outline)
|
||||||
|
DEFINE_VALUES (FONT, Font, font)
|
||||||
|
DEFINE_VALUES (FONT_VARIANT, FontVariant, font_variant)
|
||||||
|
DEFINE_VALUES (ANIMATION, Animation, animation)
|
||||||
|
DEFINE_VALUES (TRANSITION, Transition, transition)
|
||||||
|
DEFINE_VALUES (SIZE, Size, size)
|
||||||
|
DEFINE_VALUES (OTHER, Other, other)
|
||||||
|
|
||||||
static GtkCssSection *
|
static GtkCssSection *
|
||||||
gtk_css_animated_style_get_section (GtkCssStyle *style,
|
gtk_css_animated_style_get_section (GtkCssStyle *style,
|
||||||
@@ -74,6 +120,15 @@ gtk_css_animated_style_get_static_style (GtkCssStyle *style)
|
|||||||
return (GtkCssStaticStyle *)animated->style;
|
return (GtkCssStaticStyle *)animated->style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GtkCssValue *
|
||||||
|
gtk_css_animated_style_get_original_value (GtkCssStyle *style,
|
||||||
|
guint id)
|
||||||
|
{
|
||||||
|
GtkCssAnimatedStyle *animated = GTK_CSS_ANIMATED_STYLE (style);
|
||||||
|
|
||||||
|
return gtk_css_style_get_original_value (animated->style, id);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_css_animated_style_dispose (GObject *object)
|
gtk_css_animated_style_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
@@ -96,6 +151,9 @@ gtk_css_animated_style_finalize (GObject *object)
|
|||||||
GtkCssAnimatedStyle *style = GTK_CSS_ANIMATED_STYLE (object);
|
GtkCssAnimatedStyle *style = GTK_CSS_ANIMATED_STYLE (object);
|
||||||
|
|
||||||
g_object_unref (style->style);
|
g_object_unref (style->style);
|
||||||
|
if (style->parent_style)
|
||||||
|
g_object_unref (style->parent_style);
|
||||||
|
g_object_unref (style->provider);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gtk_css_animated_style_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gtk_css_animated_style_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@@ -112,6 +170,7 @@ gtk_css_animated_style_class_init (GtkCssAnimatedStyleClass *klass)
|
|||||||
style_class->get_section = gtk_css_animated_style_get_section;
|
style_class->get_section = gtk_css_animated_style_get_section;
|
||||||
style_class->is_static = gtk_css_animated_style_is_static;
|
style_class->is_static = gtk_css_animated_style_is_static;
|
||||||
style_class->get_static_style = gtk_css_animated_style_get_static_style;
|
style_class->get_static_style = gtk_css_animated_style_get_static_style;
|
||||||
|
style_class->get_original_value = gtk_css_animated_style_get_original_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -546,6 +605,51 @@ gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
|
|||||||
return gtk_css_style_get_value (style->style, id);
|
return gtk_css_style_get_value (style->style, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gtk_css_animated_style_set_animated_custom_value (GtkCssAnimatedStyle *animated,
|
||||||
|
int id,
|
||||||
|
GtkCssVariableValue *value)
|
||||||
|
{
|
||||||
|
GtkCssStyle *style = (GtkCssStyle *)animated;
|
||||||
|
|
||||||
|
gtk_internal_return_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style));
|
||||||
|
gtk_internal_return_if_fail (value != NULL);
|
||||||
|
|
||||||
|
if (style->variables == NULL)
|
||||||
|
{
|
||||||
|
style->variables = gtk_css_variable_set_new ();
|
||||||
|
if (animated->parent_style)
|
||||||
|
gtk_css_variable_set_set_parent (style->variables,
|
||||||
|
animated->parent_style->variables);
|
||||||
|
}
|
||||||
|
else if (style->variables == animated->style->variables)
|
||||||
|
{
|
||||||
|
gtk_css_variable_set_unref (style->variables);
|
||||||
|
style->variables = gtk_css_variable_set_copy (animated->style->variables);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_css_variable_set_add (style->variables, id, value);
|
||||||
|
|
||||||
|
gtk_css_core_values_recompute (animated);
|
||||||
|
gtk_css_background_values_recompute (animated);
|
||||||
|
gtk_css_border_values_recompute (animated);
|
||||||
|
gtk_css_icon_values_recompute (animated);
|
||||||
|
gtk_css_outline_values_recompute (animated);
|
||||||
|
gtk_css_font_values_recompute (animated);
|
||||||
|
gtk_css_font_variant_values_recompute (animated);
|
||||||
|
gtk_css_animation_values_recompute (animated);
|
||||||
|
gtk_css_transition_values_recompute (animated);
|
||||||
|
gtk_css_size_values_recompute (animated);
|
||||||
|
gtk_css_other_values_recompute (animated);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkCssVariableValue *
|
||||||
|
gtk_css_animated_style_get_intrinsic_custom_value (GtkCssAnimatedStyle *style,
|
||||||
|
int id)
|
||||||
|
{
|
||||||
|
return gtk_css_style_get_custom_property (style->style, id);
|
||||||
|
}
|
||||||
|
|
||||||
static GPtrArray *
|
static GPtrArray *
|
||||||
gtk_css_animated_style_create_dynamic (GPtrArray *animations,
|
gtk_css_animated_style_create_dynamic (GPtrArray *animations,
|
||||||
GtkCssStyle *style,
|
GtkCssStyle *style,
|
||||||
@@ -770,7 +874,6 @@ gtk_css_animated_style_find_animation (GtkStyleAnimation **animations,
|
|||||||
static GPtrArray *
|
static GPtrArray *
|
||||||
gtk_css_animated_style_create_css_animations (GPtrArray *animations,
|
gtk_css_animated_style_create_css_animations (GPtrArray *animations,
|
||||||
GtkCssStyle *base_style,
|
GtkCssStyle *base_style,
|
||||||
GtkCssStyle *parent_style,
|
|
||||||
gint64 timestamp,
|
gint64 timestamp,
|
||||||
GtkStyleProvider *provider,
|
GtkStyleProvider *provider,
|
||||||
GtkCssStyle *source)
|
GtkCssStyle *source)
|
||||||
@@ -832,8 +935,6 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
|
|||||||
if (keyframes == NULL)
|
if (keyframes == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
keyframes = _gtk_css_keyframes_compute (keyframes, provider, base_style, parent_style);
|
|
||||||
|
|
||||||
animation = _gtk_css_animation_new (name,
|
animation = _gtk_css_animation_new (name,
|
||||||
keyframes,
|
keyframes,
|
||||||
timestamp,
|
timestamp,
|
||||||
@@ -844,7 +945,6 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
|
|||||||
_gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)),
|
_gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)),
|
||||||
_gtk_css_fill_mode_value_get (_gtk_css_array_value_get_nth (fill_modes, i)),
|
_gtk_css_fill_mode_value_get (_gtk_css_array_value_get_nth (fill_modes, i)),
|
||||||
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (iteration_counts, i), 100));
|
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (iteration_counts, i), 100));
|
||||||
_gtk_css_keyframes_unref (keyframes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!animations)
|
if (!animations)
|
||||||
@@ -893,7 +993,7 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
|
|||||||
if (previous_style != NULL)
|
if (previous_style != NULL)
|
||||||
animations = gtk_css_animated_style_create_css_transitions (animations, base_style, timestamp, previous_style);
|
animations = gtk_css_animated_style_create_css_transitions (animations, base_style, timestamp, previous_style);
|
||||||
|
|
||||||
animations = gtk_css_animated_style_create_css_animations (animations, base_style, parent_style, timestamp, provider, previous_style);
|
animations = gtk_css_animated_style_create_css_animations (animations, base_style, timestamp, provider, previous_style);
|
||||||
animations = gtk_css_animated_style_create_dynamic (animations, base_style, timestamp);
|
animations = gtk_css_animated_style_create_dynamic (animations, base_style, timestamp);
|
||||||
|
|
||||||
if (animations == NULL)
|
if (animations == NULL)
|
||||||
@@ -902,6 +1002,9 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
|
|||||||
result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
|
result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
|
||||||
|
|
||||||
result->style = g_object_ref (base_style);
|
result->style = g_object_ref (base_style);
|
||||||
|
if (parent_style)
|
||||||
|
result->parent_style = g_object_ref (parent_style);
|
||||||
|
result->provider = g_object_ref (provider);
|
||||||
result->current_time = timestamp;
|
result->current_time = timestamp;
|
||||||
result->n_animations = animations->len;
|
result->n_animations = animations->len;
|
||||||
result->animations = g_ptr_array_free (animations, FALSE);
|
result->animations = g_ptr_array_free (animations, FALSE);
|
||||||
@@ -918,6 +1021,8 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
|
|||||||
style->transition = (GtkCssTransitionValues *)gtk_css_values_ref ((GtkCssValues *)base_style->transition);
|
style->transition = (GtkCssTransitionValues *)gtk_css_values_ref ((GtkCssValues *)base_style->transition);
|
||||||
style->size = (GtkCssSizeValues *)gtk_css_values_ref ((GtkCssValues *)base_style->size);
|
style->size = (GtkCssSizeValues *)gtk_css_values_ref ((GtkCssValues *)base_style->size);
|
||||||
style->other = (GtkCssOtherValues *)gtk_css_values_ref ((GtkCssValues *)base_style->other);
|
style->other = (GtkCssOtherValues *)gtk_css_values_ref ((GtkCssValues *)base_style->other);
|
||||||
|
if (base_style->variables)
|
||||||
|
style->variables = gtk_css_variable_set_ref (base_style->variables);
|
||||||
|
|
||||||
gtk_css_animated_style_apply_animations (result);
|
gtk_css_animated_style_apply_animations (result);
|
||||||
|
|
||||||
@@ -927,7 +1032,9 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
|
|||||||
GtkCssStyle *
|
GtkCssStyle *
|
||||||
gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
|
gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
|
||||||
GtkCssStyle *base_style,
|
GtkCssStyle *base_style,
|
||||||
gint64 timestamp)
|
GtkCssStyle *parent_style,
|
||||||
|
gint64 timestamp,
|
||||||
|
GtkStyleProvider *provider)
|
||||||
{
|
{
|
||||||
GtkCssAnimatedStyle *result;
|
GtkCssAnimatedStyle *result;
|
||||||
GtkCssStyle *style;
|
GtkCssStyle *style;
|
||||||
@@ -936,6 +1043,8 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
|
|||||||
|
|
||||||
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (source), NULL);
|
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (source), NULL);
|
||||||
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (base_style), NULL);
|
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (base_style), NULL);
|
||||||
|
gtk_internal_return_val_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style), NULL);
|
||||||
|
gtk_internal_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
|
||||||
|
|
||||||
if (timestamp == 0)
|
if (timestamp == 0)
|
||||||
return g_object_ref (source->style);
|
return g_object_ref (source->style);
|
||||||
@@ -966,6 +1075,9 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
|
|||||||
result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
|
result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
|
||||||
|
|
||||||
result->style = g_object_ref (base_style);
|
result->style = g_object_ref (base_style);
|
||||||
|
if (parent_style)
|
||||||
|
result->parent_style = g_object_ref (parent_style);
|
||||||
|
result->provider = g_object_ref (provider);
|
||||||
result->current_time = timestamp;
|
result->current_time = timestamp;
|
||||||
result->n_animations = animations->len;
|
result->n_animations = animations->len;
|
||||||
result->animations = g_ptr_array_free (animations, FALSE);
|
result->animations = g_ptr_array_free (animations, FALSE);
|
||||||
@@ -982,8 +1094,34 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
|
|||||||
style->transition = (GtkCssTransitionValues *)gtk_css_values_ref ((GtkCssValues *)base_style->transition);
|
style->transition = (GtkCssTransitionValues *)gtk_css_values_ref ((GtkCssValues *)base_style->transition);
|
||||||
style->size = (GtkCssSizeValues *)gtk_css_values_ref ((GtkCssValues *)base_style->size);
|
style->size = (GtkCssSizeValues *)gtk_css_values_ref ((GtkCssValues *)base_style->size);
|
||||||
style->other = (GtkCssOtherValues *)gtk_css_values_ref ((GtkCssValues *)base_style->other);
|
style->other = (GtkCssOtherValues *)gtk_css_values_ref ((GtkCssValues *)base_style->other);
|
||||||
|
if (base_style->variables)
|
||||||
|
style->variables = gtk_css_variable_set_ref (base_style->variables);
|
||||||
|
|
||||||
gtk_css_animated_style_apply_animations (result);
|
gtk_css_animated_style_apply_animations (result);
|
||||||
|
|
||||||
return GTK_CSS_STYLE (result);
|
return GTK_CSS_STYLE (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GtkCssStyle *
|
||||||
|
gtk_css_animated_style_get_base_style (GtkCssAnimatedStyle *style)
|
||||||
|
{
|
||||||
|
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), NULL);
|
||||||
|
|
||||||
|
return style->style;
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkCssStyle *
|
||||||
|
gtk_css_animated_style_get_parent_style (GtkCssAnimatedStyle *style)
|
||||||
|
{
|
||||||
|
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), NULL);
|
||||||
|
|
||||||
|
return style->parent_style;
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkStyleProvider *
|
||||||
|
gtk_css_animated_style_get_provider (GtkCssAnimatedStyle *style)
|
||||||
|
{
|
||||||
|
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), NULL);
|
||||||
|
|
||||||
|
return style->provider;
|
||||||
|
}
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ struct _GtkCssAnimatedStyle
|
|||||||
GtkCssStyle parent;
|
GtkCssStyle parent;
|
||||||
|
|
||||||
GtkCssStyle *style; /* the style if we weren't animating */
|
GtkCssStyle *style; /* the style if we weren't animating */
|
||||||
|
GtkCssStyle *parent_style;
|
||||||
|
GtkStyleProvider *provider;
|
||||||
|
|
||||||
gint64 current_time; /* the current time in our world */
|
gint64 current_time; /* the current time in our world */
|
||||||
gpointer *animations; /* GtkStyleAnimation**, least important one first */
|
gpointer *animations; /* GtkStyleAnimation**, least important one first */
|
||||||
@@ -57,15 +59,26 @@ GtkCssStyle * gtk_css_animated_style_new (GtkCssStyle
|
|||||||
GtkStyleProvider *provider,
|
GtkStyleProvider *provider,
|
||||||
GtkCssStyle *previous_style);
|
GtkCssStyle *previous_style);
|
||||||
GtkCssStyle * gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
|
GtkCssStyle * gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
|
||||||
GtkCssStyle *base,
|
GtkCssStyle *base_style,
|
||||||
gint64 timestamp);
|
GtkCssStyle *parent_style,
|
||||||
|
gint64 timestamp,
|
||||||
|
GtkStyleProvider *provider);
|
||||||
|
|
||||||
void gtk_css_animated_style_set_animated_value(GtkCssAnimatedStyle *style,
|
void gtk_css_animated_style_set_animated_value(GtkCssAnimatedStyle *style,
|
||||||
guint id,
|
guint id,
|
||||||
GtkCssValue *value);
|
GtkCssValue *value);
|
||||||
|
|
||||||
GtkCssValue * gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
|
GtkCssValue * gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
|
||||||
guint id);
|
guint id);
|
||||||
|
|
||||||
|
void gtk_css_animated_style_set_animated_custom_value (GtkCssAnimatedStyle *animated,
|
||||||
|
int id,
|
||||||
|
GtkCssVariableValue *value);
|
||||||
|
GtkCssVariableValue * gtk_css_animated_style_get_intrinsic_custom_value (GtkCssAnimatedStyle *style,
|
||||||
|
int id);
|
||||||
|
|
||||||
|
GtkCssStyle * gtk_css_animated_style_get_base_style (GtkCssAnimatedStyle *style);
|
||||||
|
GtkCssStyle * gtk_css_animated_style_get_parent_style (GtkCssAnimatedStyle *style);
|
||||||
|
GtkStyleProvider * gtk_css_animated_style_get_provider (GtkCssAnimatedStyle *style);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|||||||
+36
-3
@@ -90,6 +90,9 @@ gtk_css_animation_apply_values (GtkStyleAnimation *style_animation,
|
|||||||
GtkCssAnimatedStyle *style)
|
GtkCssAnimatedStyle *style)
|
||||||
{
|
{
|
||||||
GtkCssAnimation *animation = (GtkCssAnimation *)style_animation;
|
GtkCssAnimation *animation = (GtkCssAnimation *)style_animation;
|
||||||
|
GtkCssStyle *base_style, *parent_style;
|
||||||
|
GtkStyleProvider *provider;
|
||||||
|
GtkCssKeyframes *resolved_keyframes;
|
||||||
double progress;
|
double progress;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
@@ -99,19 +102,49 @@ gtk_css_animation_apply_values (GtkStyleAnimation *style_animation,
|
|||||||
progress = gtk_css_animation_get_progress (animation);
|
progress = gtk_css_animation_get_progress (animation);
|
||||||
progress = _gtk_css_ease_value_transform (animation->ease, progress);
|
progress = _gtk_css_ease_value_transform (animation->ease, progress);
|
||||||
|
|
||||||
for (i = 0; i < _gtk_css_keyframes_get_n_properties (animation->keyframes); i++)
|
base_style = gtk_css_animated_style_get_base_style (style);
|
||||||
|
parent_style = gtk_css_animated_style_get_parent_style (style);
|
||||||
|
provider = gtk_css_animated_style_get_provider (style);
|
||||||
|
resolved_keyframes = _gtk_css_keyframes_compute (animation->keyframes,
|
||||||
|
provider,
|
||||||
|
base_style,
|
||||||
|
parent_style);
|
||||||
|
|
||||||
|
for (i = 0; i < _gtk_css_keyframes_get_n_variables (resolved_keyframes); i++)
|
||||||
|
{
|
||||||
|
GtkCssVariableValue *value;
|
||||||
|
int variable_id;
|
||||||
|
|
||||||
|
variable_id = _gtk_css_keyframes_get_variable_id (resolved_keyframes, i);
|
||||||
|
|
||||||
|
value = _gtk_css_keyframes_get_variable (resolved_keyframes,
|
||||||
|
i,
|
||||||
|
progress,
|
||||||
|
gtk_css_animated_style_get_intrinsic_custom_value (style, variable_id));
|
||||||
|
|
||||||
|
if (!value)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
gtk_css_animated_style_set_animated_custom_value (style, variable_id, value);
|
||||||
|
|
||||||
|
gtk_css_variable_value_unref (value);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < _gtk_css_keyframes_get_n_properties (resolved_keyframes); i++)
|
||||||
{
|
{
|
||||||
GtkCssValue *value;
|
GtkCssValue *value;
|
||||||
guint property_id;
|
guint property_id;
|
||||||
|
|
||||||
property_id = _gtk_css_keyframes_get_property_id (animation->keyframes, i);
|
property_id = _gtk_css_keyframes_get_property_id (resolved_keyframes, i);
|
||||||
|
|
||||||
value = _gtk_css_keyframes_get_value (animation->keyframes,
|
value = _gtk_css_keyframes_get_value (resolved_keyframes,
|
||||||
i,
|
i,
|
||||||
progress,
|
progress,
|
||||||
gtk_css_animated_style_get_intrinsic_value (style, property_id));
|
gtk_css_animated_style_get_intrinsic_value (style, property_id));
|
||||||
gtk_css_animated_style_set_animated_value (style, property_id, value);
|
gtk_css_animated_style_set_animated_value (style, property_id, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_gtk_css_keyframes_unref (resolved_keyframes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|||||||
+15
-10
@@ -41,11 +41,12 @@ gtk_css_value_array_free (GtkCssValue *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GtkCssValue *
|
static GtkCssValue *
|
||||||
gtk_css_value_array_compute (GtkCssValue *value,
|
gtk_css_value_array_compute (GtkCssValue *value,
|
||||||
guint property_id,
|
guint property_id,
|
||||||
GtkStyleProvider *provider,
|
GtkStyleProvider *provider,
|
||||||
GtkCssStyle *style,
|
GtkCssStyle *style,
|
||||||
GtkCssStyle *parent_style)
|
GtkCssStyle *parent_style,
|
||||||
|
GtkCssVariableSet *variables)
|
||||||
{
|
{
|
||||||
GtkCssValue *result;
|
GtkCssValue *result;
|
||||||
GtkCssValue *i_value;
|
GtkCssValue *i_value;
|
||||||
@@ -54,7 +55,7 @@ gtk_css_value_array_compute (GtkCssValue *value,
|
|||||||
result = NULL;
|
result = NULL;
|
||||||
for (i = 0; i < value->n_values; i++)
|
for (i = 0; i < value->n_values; i++)
|
||||||
{
|
{
|
||||||
i_value = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
|
i_value = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style, variables);
|
||||||
|
|
||||||
if (result == NULL &&
|
if (result == NULL &&
|
||||||
i_value != value->values[i])
|
i_value != value->values[i])
|
||||||
@@ -402,10 +403,13 @@ _gtk_css_array_value_new_from_array (GtkCssValue **values,
|
|||||||
for (i = 0; i < n_values; i ++)
|
for (i = 0; i < n_values; i ++)
|
||||||
{
|
{
|
||||||
if (!gtk_css_value_is_computed (values[i]))
|
if (!gtk_css_value_is_computed (values[i]))
|
||||||
{
|
result->is_computed = FALSE;
|
||||||
result->is_computed = FALSE;
|
|
||||||
break;
|
if (gtk_css_value_contains_variables (values[i]))
|
||||||
}
|
result->contains_variables = TRUE;
|
||||||
|
|
||||||
|
if (!result->is_computed && result->contains_variables)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -467,3 +471,4 @@ _gtk_css_array_value_get_n_values (const GtkCssValue *value)
|
|||||||
return value->n_values;
|
return value->n_values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+11
-10
@@ -41,11 +41,12 @@ gtk_css_value_bg_size_free (GtkCssValue *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GtkCssValue *
|
static GtkCssValue *
|
||||||
gtk_css_value_bg_size_compute (GtkCssValue *value,
|
gtk_css_value_bg_size_compute (GtkCssValue *value,
|
||||||
guint property_id,
|
guint property_id,
|
||||||
GtkStyleProvider *provider,
|
GtkStyleProvider *provider,
|
||||||
GtkCssStyle *style,
|
GtkCssStyle *style,
|
||||||
GtkCssStyle *parent_style)
|
GtkCssStyle *parent_style,
|
||||||
|
GtkCssVariableSet *variables)
|
||||||
{
|
{
|
||||||
GtkCssValue *x, *y;
|
GtkCssValue *x, *y;
|
||||||
|
|
||||||
@@ -55,10 +56,10 @@ gtk_css_value_bg_size_compute (GtkCssValue *value,
|
|||||||
x = y = NULL;
|
x = y = NULL;
|
||||||
|
|
||||||
if (value->x)
|
if (value->x)
|
||||||
x = _gtk_css_value_compute (value->x, property_id, provider, style, parent_style);
|
x = _gtk_css_value_compute (value->x, property_id, provider, style, parent_style, variables);
|
||||||
|
|
||||||
if (value->y)
|
if (value->y)
|
||||||
y = _gtk_css_value_compute (value->y, property_id, provider, style, parent_style);
|
y = _gtk_css_value_compute (value->y, property_id, provider, style, parent_style, variables);
|
||||||
|
|
||||||
if (x == value->x && y == value->y)
|
if (x == value->x && y == value->y)
|
||||||
{
|
{
|
||||||
@@ -163,9 +164,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_BG_SIZE = {
|
|||||||
gtk_css_value_bg_size_print
|
gtk_css_value_bg_size_print
|
||||||
};
|
};
|
||||||
|
|
||||||
static GtkCssValue auto_singleton = { >K_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, FALSE, NULL, NULL };
|
static GtkCssValue auto_singleton = { >K_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, FALSE, FALSE, NULL, NULL };
|
||||||
static GtkCssValue cover_singleton = { >K_CSS_VALUE_BG_SIZE, 1, TRUE, TRUE, FALSE, NULL, NULL };
|
static GtkCssValue cover_singleton = { >K_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, TRUE, FALSE, NULL, NULL };
|
||||||
static GtkCssValue contain_singleton = { >K_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, TRUE, NULL, NULL };
|
static GtkCssValue contain_singleton = { >K_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, FALSE, TRUE, NULL, NULL };
|
||||||
|
|
||||||
GtkCssValue *
|
GtkCssValue *
|
||||||
_gtk_css_bg_size_value_new (GtkCssValue *x,
|
_gtk_css_bg_size_value_new (GtkCssValue *x,
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user