Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 70eec3ee01 |
@@ -459,7 +459,6 @@ reference:
|
||||
- mv _build/docs/reference/gdk/gdk4-wayland/ _reference/gdk4-wayland/
|
||||
- mv _build/docs/reference/gsk/gsk4/ _reference/gsk4/
|
||||
- mv _build/docs/reference/gtk/gtk4/ _reference/gtk4/
|
||||
- mv _build/docs/reference/gtk/*.html _reference/gtk4/
|
||||
- mv _build/subprojects/pango/docs/Pango/ _reference/Pango/
|
||||
- mv _build/subprojects/pango/docs/PangoCairo/ _reference/PangoCairo/
|
||||
- mv _build/subprojects/pango/docs/PangoFc/ _reference/PangoFc/
|
||||
|
||||
@@ -1,75 +1,6 @@
|
||||
Overview of Changes in 4.15.2, xx-xx-xxxx
|
||||
Overview of Changes in 4.15.1, xx-xx-xxxx
|
||||
=========================================
|
||||
|
||||
Overview of Changes in 4.15.1, 21-05-2024
|
||||
=========================================
|
||||
|
||||
* GtkGraphicsOffload:
|
||||
- Don't crash without a child
|
||||
|
||||
* GtkSpinner:
|
||||
- Don't animate when unmapped
|
||||
|
||||
* CSS:
|
||||
- Support the :root selector
|
||||
- Support variables and custom properties (https://www.w3.org/TR/css-variables-1/)
|
||||
- Implement math functions (https://www.w3.org/TR/css-values-4/)
|
||||
- Support modern syntax and calc in rgb() and hsl()
|
||||
|
||||
* 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
|
||||
- Realize child contexts when necessary
|
||||
|
||||
* GDK:
|
||||
- Support XDG_ACTIVATION_TOKEN
|
||||
- dmabuf: Be more defensive when importing unknown formats to GL
|
||||
- dmabuf: Use narrow range for YUV
|
||||
- vulkan: Recreate swapchains when necessary or beneficial
|
||||
|
||||
* 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
|
||||
- cairo: Speed up mask nodes, since we use them for symbolic icons
|
||||
|
||||
* Wayland:
|
||||
- Use wl_compositor version 6
|
||||
|
||||
* X11:
|
||||
- Implement a missing method
|
||||
|
||||
* Build:
|
||||
- Fix many ubsan warnings
|
||||
|
||||
* Debugging:
|
||||
- Show more texture details in the recorder
|
||||
- Use GTK_DEBUG=css to see CSS deprecations
|
||||
|
||||
* macOS:
|
||||
- Fix problems with events handed back to the OS
|
||||
- Respect GDK_DEBUG=default-settings
|
||||
- Allow applictions to handle Dock > Quit
|
||||
|
||||
* Deprecations:
|
||||
- Use of @name colors in CSS
|
||||
|
||||
* Translation updates:
|
||||
Catalan
|
||||
Georgian
|
||||
Hungarian
|
||||
Korean
|
||||
Portuguese
|
||||
Turkish
|
||||
|
||||
|
||||
Overview of Changes in 4.15.0, 21-04-2024
|
||||
=========================================
|
||||
|
||||
|
||||
@@ -363,9 +363,7 @@ insert_markup_idle (gpointer data)
|
||||
|
||||
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
|
||||
{
|
||||
guint id;
|
||||
id = g_idle_add (insert_markup_idle, data);
|
||||
g_source_set_name_by_id (id, "[gtk-demo] insert_markup_idle");
|
||||
g_idle_add (insert_markup_idle, data);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
@@ -400,9 +398,7 @@ parse_markup_idle (gpointer data)
|
||||
do {
|
||||
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
|
||||
{
|
||||
guint id;
|
||||
id = g_idle_add (parse_markup_idle, data);
|
||||
g_source_set_name_by_id (id, "[gtk-demo] parse_markup_idle");
|
||||
g_idle_add (parse_markup_idle, data);
|
||||
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 locale_abbrev_w[9];
|
||||
gchar *langname, *locale_abbrev, *locale;
|
||||
gchar *langname, *locale_abbrev, *locale, *p;
|
||||
gint i;
|
||||
const LCTYPE iso639_lctypes[] = { LOCALE_SISO639LANGNAME, LOCALE_SISO639LANGNAME2 };
|
||||
GHashTable *ht_scripts_langs = (GHashTable *) param;
|
||||
@@ -59,6 +59,7 @@ get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
|
||||
GetLocaleInfoEx (locale_w, LOCALE_SLOCALIZEDDISPLAYNAME, langname_w, langname_size);
|
||||
langname = g_utf16_to_utf8 (langname_w, -1, NULL, NULL, NULL);
|
||||
locale = g_utf16_to_utf8 (locale_w, -1, NULL, NULL, NULL);
|
||||
p = strchr (locale, '-');
|
||||
lang = pango_language_from_string (locale);
|
||||
if (g_hash_table_lookup (ht_scripts_langs, lang) == NULL)
|
||||
g_hash_table_insert (ht_scripts_langs, lang, langname);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "config.h"
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "demos.h"
|
||||
#include "fontify.h"
|
||||
@@ -924,34 +923,6 @@ 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
|
||||
activate (GApplication *app)
|
||||
{
|
||||
@@ -999,7 +970,6 @@ activate (GApplication *app)
|
||||
|
||||
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 (filter_model, "notify::n-items", G_CALLBACK (search_results_update), search_entry);
|
||||
|
||||
selection = gtk_single_selection_new (G_LIST_MODEL (filter_model));
|
||||
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);
|
||||
|
||||
@@ -330,7 +330,6 @@ stroke bounds of the path.
|
||||
| offset | `<point>` | 0 0 | non-default |
|
||||
| hint-style | `<hint style>` | slight | non-default |
|
||||
| antialias | `<antialias>` | gray | non-default |
|
||||
| hint-metrics | `<hint metrics>` | off | non-default |
|
||||
|
||||
Creates a node like `gsk_text_node_new()` with the given properties.
|
||||
|
||||
@@ -347,7 +346,6 @@ font, an error node will be returned.
|
||||
|
||||
Possible values for hint-style are none, slight or full.
|
||||
Possible value for antialias are none or gray.
|
||||
Possible value for hint-metrics are on or off.
|
||||
|
||||
### texture
|
||||
|
||||
|
||||
@@ -5,11 +5,8 @@ Title: Cairo interaction
|
||||
[Cairo](http://cairographics.org) is a graphics library that supports vector
|
||||
graphics and image compositing that can be used with GTK.
|
||||
|
||||
GDK does not wrap the Cairo API and it is not possible to use cairo directly
|
||||
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.
|
||||
GDK does not wrap the Cairo API; instead it allows to create Cairo
|
||||
drawing contexts which can be used to draw on [class@Gdk.Surface]s.
|
||||
|
||||
Additional functions allow use [struct@Gdk.Rectangle]s with Cairo
|
||||
and to use [struct@Gdk.RGBA], `GdkPixbuf`, and [class@Gdk.Surface]
|
||||
|
||||
@@ -15,16 +15,16 @@ spec.
|
||||
The following units are supported for basic datatypes:
|
||||
|
||||
Length
|
||||
: px, pt, em, ex, rem, pc, in, cm, mm
|
||||
: px, pt, em, ex, rem, pc, in, cm, mm, calc()
|
||||
|
||||
Percentage
|
||||
: %
|
||||
: %, calc()
|
||||
|
||||
Angle
|
||||
: deg, rad, grad, turn
|
||||
: deg, grad, turn, calc()
|
||||
|
||||
Time
|
||||
: s, ms
|
||||
: s, ms, calc()
|
||||
|
||||
Length values with the em or ex units are resolved using the font
|
||||
size value, unless they occur in setting the font-size itself, in
|
||||
@@ -33,15 +33,11 @@ which case they are resolved using the inherited font size value.
|
||||
The rem unit is resolved using the initial font size value, which is
|
||||
not quite the same as the CSS definition of rem.
|
||||
|
||||
Length values using physical units (pt, pc, in, cm, mm) are translated
|
||||
to px using the dpi value specified by the -gtk-dpi property, which is
|
||||
different from the CSS definition, which uses a fixed dpi of 96.
|
||||
|
||||
The calc() notation adds considerable expressive power to all of these
|
||||
datatypes. There are limits on what types can be combined in such an
|
||||
expression (e.g. it does not make sense to add a number and a time).
|
||||
For the full details, see the
|
||||
[CSS Values and Units](https://www.w3.org/TR/css-values-4/) spec.
|
||||
The calc() notation adds considerable expressive power. There are limits
|
||||
on what types can be combined in such an expression (e.g. it does not make
|
||||
sense to add a number and a time). For the full details, see the
|
||||
[CSS3 Values and Units](https://www.w3.org/TR/css3-values/#calc-notation)
|
||||
spec.
|
||||
|
||||
A common pattern among shorthand properties (called 'four sides') is one
|
||||
where one to four values can be specified, to determine a value for each
|
||||
@@ -60,79 +56,38 @@ follows:
|
||||
1 value:
|
||||
: all
|
||||
|
||||
## Custom Properties
|
||||
|
||||
GTK supports custom properties as defined in the
|
||||
[CSS Custom Properties for Cascading Variables](https://www.w3.org/TR/css-variables-1)
|
||||
spec.
|
||||
|
||||
Custom properties are defined as follows:
|
||||
|
||||
```css
|
||||
--prop: red;
|
||||
```
|
||||
|
||||
and used via the `var` keyword:
|
||||
|
||||
```css
|
||||
color: var(--prop);
|
||||
```
|
||||
|
||||
Custom properties can have a fallback for when the referred property is invalid:
|
||||
|
||||
```css
|
||||
color: var(--prop, green);
|
||||
```
|
||||
|
||||
## Colors
|
||||
|
||||
### CSS Colors
|
||||
|
||||
Colors can be expressed in numerous ways in CSS (see the
|
||||
[Color Module](https://www.w3.org/TR/css-color-5/). GTK supports
|
||||
many (but not all) of these.
|
||||
|
||||
You can use rgb(), rgba(), hsl() with both the legacy or the modern CSS
|
||||
syntax, and calc() can be used as well in color expressions.
|
||||
|
||||
### Non-CSS Colors
|
||||
|
||||
GTK extends the CSS syntax with several additional ways to specify colors.
|
||||
|
||||
These extensions are deprecated and should be replaced by the equivalent
|
||||
standard CSS notions.
|
||||
|
||||
The first is a reference to a color defined via a @define-color rule in CSS.
|
||||
The syntax for @define-color rules is as follows:
|
||||
|
||||
```
|
||||
@define-color name color
|
||||
@define-color Name Color
|
||||
```
|
||||
|
||||
To refer to the color defined by a @define-color rule, prefix the name with @.
|
||||
|
||||
The standard CSS mechanisms that should be used instead of @define-color are
|
||||
custom properties, :root and var().
|
||||
|
||||
GTK also supports color expressions, which allow colors to be transformed to
|
||||
new ones. Color expressions can be nested, providing a rich language to
|
||||
define colors. Color expressions resemble functions, taking 1 or more colors
|
||||
and in some cases a number as arguments.
|
||||
|
||||
`lighter(color)`
|
||||
: produces a brighter variant of `color`.
|
||||
`lighter(Color)`
|
||||
: produces a brighter variant of Color
|
||||
|
||||
`darker(color)`
|
||||
: produces a darker variant of `color`.
|
||||
`darker(Color)`
|
||||
: produces a darker variant of Color
|
||||
|
||||
`shade(color, number)`
|
||||
: changes the lightness of `color`. The `number` ranges from 0 for black to 2 for white.
|
||||
`shade(Color, Number)`
|
||||
: changes the lightness of Color. The number ranges from 0 for black to 2 for white.
|
||||
|
||||
`alpha(color, number)`
|
||||
: multiplies the alpha value of `color` by `number` (between 0 and 1).
|
||||
`alpha(Color, Number)`
|
||||
: replaces the alpha value of color with number (between 0 and 1)
|
||||
|
||||
`mix(color1, color2, number)`
|
||||
: interpolates between the two colors.
|
||||
`mix(Color1, Color2, Number)`
|
||||
: interpolates between the two colors
|
||||
|
||||
## Images
|
||||
|
||||
@@ -140,7 +95,7 @@ GTK extends the CSS syntax for images and also uses it for specifying icons.
|
||||
To load a themed icon, use
|
||||
|
||||
```
|
||||
-gtk-icontheme(name)
|
||||
-gtk-icontheme(Name)
|
||||
```
|
||||
|
||||
The specified icon name is used to look up a themed icon, while taking into
|
||||
@@ -169,14 +124,14 @@ and the
|
||||
syntax makes this available. -gtk-recolor requires a url as first argument.
|
||||
The remaining arguments specify the color palette to use. If the palette is
|
||||
not explicitly specified, the current value of the -gtk-icon-palette property
|
||||
is used.
|
||||
is used.
|
||||
|
||||
GTK supports scaled rendering on hi-resolution displays. This works best if
|
||||
images can specify normal and hi-resolution variants. From CSS, this can be
|
||||
done with
|
||||
|
||||
```
|
||||
-gtk-scaled(image1, image2)
|
||||
-gtk-scaled(Image1, Image2)
|
||||
```
|
||||
|
||||
## GTK CSS Properties
|
||||
|
||||
@@ -82,7 +82,6 @@ content_files = [
|
||||
"wayland.md",
|
||||
"windows.md",
|
||||
"x11.md",
|
||||
"tools.md",
|
||||
"visual_index.md",
|
||||
]
|
||||
content_images = [
|
||||
|
||||
@@ -25,8 +25,7 @@ expand_content_md_files = [
|
||||
'section-tree-widget.md',
|
||||
'section-list-widget.md',
|
||||
'question_index.md',
|
||||
'visual_index.md',
|
||||
'tools.md',
|
||||
'visual_index.md'
|
||||
]
|
||||
|
||||
gtk_images = []
|
||||
@@ -61,39 +60,39 @@ if get_option('documentation')
|
||||
build_by_default: true,
|
||||
install: true,
|
||||
install_dir: docs_dir,
|
||||
install_tag: 'doc',
|
||||
)
|
||||
endif
|
||||
|
||||
rst2man = find_program('rst2man', 'rst2man.py', required: get_option('man-pages'))
|
||||
rst2html5 = find_program('rst2html5', 'rst2html5.py', required: get_option('documentation'))
|
||||
|
||||
rst_files = [
|
||||
[ 'gtk4-broadwayd', '1' ],
|
||||
[ 'gtk4-builder-tool', '1' ],
|
||||
[ 'gtk4-encode-symbolic-svg', '1', ],
|
||||
[ 'gtk4-launch', '1', ],
|
||||
[ 'gtk4-query-settings', '1', ],
|
||||
[ 'gtk4-rendernode-tool', '1' ],
|
||||
[ 'gtk4-update-icon-cache', '1', ],
|
||||
[ 'gtk4-path-tool', '1', ],
|
||||
]
|
||||
|
||||
if get_option('build-demos')
|
||||
rst_files += [
|
||||
[ 'gtk4-demo', '1', ],
|
||||
[ 'gtk4-demo-application', '1', ],
|
||||
[ 'gtk4-widget-factory', '1', ],
|
||||
[ 'gtk4-icon-browser', '1', ],
|
||||
[ 'gtk4-node-editor', '1', ],
|
||||
]
|
||||
rst2man = find_program('rst2man', 'rst2man.py', required: false)
|
||||
if get_option('man-pages') and not rst2man.found()
|
||||
error('No rst2man found, but man pages were explicitly enabled')
|
||||
endif
|
||||
|
||||
rst2x_flags = [
|
||||
'--syntax-highlight=none',
|
||||
]
|
||||
if get_option('man-pages') and rst2man.found()
|
||||
rst_files = [
|
||||
[ 'gtk4-broadwayd', '1' ],
|
||||
[ 'gtk4-builder-tool', '1' ],
|
||||
[ 'gtk4-encode-symbolic-svg', '1', ],
|
||||
[ 'gtk4-launch', '1', ],
|
||||
[ 'gtk4-query-settings', '1', ],
|
||||
[ 'gtk4-rendernode-tool', '1' ],
|
||||
[ 'gtk4-update-icon-cache', '1', ],
|
||||
[ 'gtk4-path-tool', '1', ],
|
||||
]
|
||||
|
||||
if get_option('man-pages')
|
||||
if get_option('build-demos')
|
||||
rst_files += [
|
||||
[ 'gtk4-demo', '1', ],
|
||||
[ 'gtk4-demo-application', '1', ],
|
||||
[ 'gtk4-widget-factory', '1', ],
|
||||
[ 'gtk4-icon-browser', '1', ],
|
||||
[ 'gtk4-node-editor', '1', ],
|
||||
]
|
||||
endif
|
||||
|
||||
rst2man_flags = [
|
||||
'--syntax-highlight=none',
|
||||
]
|
||||
|
||||
foreach rst: rst_files
|
||||
man_name = rst[0]
|
||||
@@ -104,34 +103,12 @@ if get_option('man-pages')
|
||||
output: '@0@.@1@'.format(man_name, man_section),
|
||||
command: [
|
||||
rst2man,
|
||||
rst2x_flags,
|
||||
rst2man_flags,
|
||||
'@INPUT@',
|
||||
],
|
||||
capture: true,
|
||||
install: true,
|
||||
install_dir: get_option('mandir') / 'man@0@'.format(man_section),
|
||||
install_tag: 'doc',
|
||||
)
|
||||
endforeach
|
||||
endif
|
||||
|
||||
if get_option('documentation')
|
||||
|
||||
foreach rst: rst_files
|
||||
man_name = rst[0]
|
||||
|
||||
custom_target(
|
||||
input: '@0@.rst'.format(man_name),
|
||||
output: '@0@.html'.format(man_name),
|
||||
command: [
|
||||
rst2html5,
|
||||
rst2x_flags,
|
||||
'@INPUT@',
|
||||
],
|
||||
capture: true,
|
||||
install: true,
|
||||
install_dir: docs_dir / 'gtk4',
|
||||
install_tag: 'doc',
|
||||
)
|
||||
endforeach
|
||||
endif
|
||||
|
||||
@@ -64,6 +64,6 @@ GTK is divided into three parts:
|
||||
[cairo]: https://www.cairographics.org/manual/
|
||||
[opengl]: https://www.opengl.org/about/
|
||||
[vulkan]: https://www.vulkan.org/
|
||||
[pango]: https://docs.gtk.org/Pango/
|
||||
[pango]: https://docs.gtk.org/pango/
|
||||
[gdkpixbuf]: https://docs.gtk.org/gdk-pixbuf/
|
||||
[graphene]: https://ebassi.github.io/graphene/
|
||||
|
||||
@@ -155,7 +155,6 @@ Each property name is part of the `GtkAccessibleProperty` enumeration.
|
||||
| %GTK_ACCESSIBLE_PROPERTY_VALUE_MIN | “aria-valuemin” | double |
|
||||
| %GTK_ACCESSIBLE_PROPERTY_VALUE_NOW | “aria-valuenow” | double |
|
||||
| %GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT | “aria-valuetext” | translatable string |
|
||||
| %GTK_ACCESSIBLE_PROPERTY_HELP_TEXT | N/A | translatable string |
|
||||
|
||||
#### List of accessible relations
|
||||
|
||||
@@ -217,10 +216,6 @@ are accessible as part of the development process. The GTK Inspector shows
|
||||
the accessible attributes of each widget, and also provides an overlay that
|
||||
can highlight accessibility issues.
|
||||
|
||||
If you support some non-standard keyboard interactions for a widget, you
|
||||
**should** set an appropriate `GTK_ACCESSIBLE_PROPERTY_HELP_TEXT` to help
|
||||
discoverability of the behavior.
|
||||
|
||||
It is possible to set accessible attributes in UI files as well:
|
||||
```xml
|
||||
<object class="GtkButton" id="button1">
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
Title: Tools and Demos
|
||||
|
||||
GTK ships with a number of tools and demos that come with their own
|
||||
documentation in the form of man pages.
|
||||
|
||||
- [gtk4-broadwayd](gtk4-broadwayd.html)
|
||||
- [gtk4-builder-tool](gtk4-builder-tool.html)
|
||||
- [gtk4-demo](gtk4-demo.html)
|
||||
- [gtk4-demo-application](gtk4-demo-application.html)
|
||||
- [gtk4-encode-symbolic-svg](gtk4-encode-symbolic-svg.html)
|
||||
- [gtk4-icon-browser](gtk4-icon-browser.html)
|
||||
- [gtk4-launch](gtk4-launch.html)
|
||||
- [gtk4-node-editor](gtk4-node-editor.html)
|
||||
- [gtk4-path-tool](gtk4-path-tool.html)
|
||||
- [gtk4-query-settings](gtk4-query-settings.html)
|
||||
- [gtk4-rendernode-tool](gtk4-rendernode-tool.html)
|
||||
- [gtk4-update-icon-cache](gtk4-update-icon-cache.html)
|
||||
- [gtk4-widget-factory](gtk4-widget-factory.html)
|
||||
@@ -143,50 +143,31 @@ static const GdkDebugKey gdk_debug_keys[] = {
|
||||
|
||||
#ifdef G_HAS_CONSTRUCTORS
|
||||
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
|
||||
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(stash_and_unset_environment)
|
||||
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(stash_desktop_startup_notification_id)
|
||||
#endif
|
||||
G_DEFINE_CONSTRUCTOR(stash_and_unset_environment)
|
||||
G_DEFINE_CONSTRUCTOR(stash_desktop_startup_notification_id)
|
||||
#endif
|
||||
|
||||
static char *startup_notification_id = NULL;
|
||||
static char *xdg_activation_token = NULL;
|
||||
|
||||
static void
|
||||
stash_and_unset_environment (void)
|
||||
stash_desktop_startup_notification_id (void)
|
||||
{
|
||||
/* Copies environment variables and unsets them so they won't be inherited by
|
||||
* 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.
|
||||
*/
|
||||
struct {
|
||||
const char *key;
|
||||
char **dst;
|
||||
} vars[] = {
|
||||
{ "DESKTOP_STARTUP_ID", &startup_notification_id },
|
||||
{ "XDG_ACTIVATION_TOKEN", &xdg_activation_token },
|
||||
};
|
||||
size_t i;
|
||||
const char *desktop_startup_id;
|
||||
|
||||
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++)
|
||||
desktop_startup_id = g_getenv ("DESKTOP_STARTUP_ID");
|
||||
if (desktop_startup_id && *desktop_startup_id != '\0')
|
||||
{
|
||||
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);
|
||||
}
|
||||
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.
|
||||
*/
|
||||
g_unsetenv ("DESKTOP_STARTUP_ID");
|
||||
}
|
||||
|
||||
static gpointer
|
||||
@@ -311,7 +292,7 @@ gdk_pre_parse (void)
|
||||
gdk_gl_backend_use (GDK_GL_WGL);
|
||||
|
||||
#ifndef G_HAS_CONSTRUCTORS
|
||||
stash_and_unset_environment ();
|
||||
stash_desktop_startup_notification_id ();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -345,20 +326,15 @@ gdk_display_open_default (void)
|
||||
/*< private >
|
||||
* gdk_get_startup_notification_id:
|
||||
*
|
||||
* Returns the original value of the XDG_ACTIVATION_TOKEN environment
|
||||
* 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 the original value of the DESKTOP_STARTUP_ID environment
|
||||
* variable if it was defined and valid, or %NULL otherwise.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the original value of the
|
||||
* XDG_ACTIVATION_TOKEN or DESKTOP_STARTUP_ID environment variable
|
||||
* DESKTOP_STARTUP_ID environment variable
|
||||
*/
|
||||
const char *
|
||||
gdk_get_startup_notification_id (void)
|
||||
{
|
||||
if (xdg_activation_token)
|
||||
return xdg_activation_token;
|
||||
|
||||
return startup_notification_id;
|
||||
}
|
||||
|
||||
|
||||
+8
-16
@@ -41,10 +41,8 @@ G_BEGIN_DECLS
|
||||
|
||||
#ifdef GDK_ARRAY_NULL_TERMINATED
|
||||
#define GDK_ARRAY_REAL_SIZE(_size) ((_size) + 1)
|
||||
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_) - 1)
|
||||
#else
|
||||
#define GDK_ARRAY_REAL_SIZE(_size) (_size)
|
||||
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_))
|
||||
#endif
|
||||
|
||||
/* make this readable */
|
||||
@@ -179,23 +177,18 @@ G_GNUC_UNUSED static inline void
|
||||
gdk_array(reserve) (GdkArray *self,
|
||||
gsize n)
|
||||
{
|
||||
gsize new_capacity, size, capacity;
|
||||
gsize new_size, size;
|
||||
|
||||
if (G_UNLIKELY (n > GDK_ARRAY_MAX_SIZE))
|
||||
g_error ("requesting array size of %zu, but maximum size is %zu", n, GDK_ARRAY_MAX_SIZE);
|
||||
|
||||
capacity = gdk_array(get_capacity) (self);
|
||||
if (n <= capacity)
|
||||
return;
|
||||
if (n <= gdk_array(get_capacity) (self))
|
||||
return;
|
||||
|
||||
size = gdk_array(get_size) (self);
|
||||
/* capacity * 2 can overflow, that's why we MAX() */
|
||||
new_capacity = MAX (GDK_ARRAY_REAL_SIZE (n), capacity * 2);
|
||||
new_size = ((gsize) 1) << g_bit_storage (MAX (GDK_ARRAY_REAL_SIZE (n), 16) - 1);
|
||||
|
||||
#ifdef GDK_ARRAY_PREALLOC
|
||||
if (self->start == self->preallocated)
|
||||
{
|
||||
self->start = g_new (_T_, new_capacity);
|
||||
self->start = g_new (_T_, new_size);
|
||||
memcpy (self->start, self->preallocated, sizeof (_T_) * GDK_ARRAY_REAL_SIZE (size));
|
||||
}
|
||||
else
|
||||
@@ -203,15 +196,15 @@ gdk_array(reserve) (GdkArray *self,
|
||||
#ifdef GDK_ARRAY_NULL_TERMINATED
|
||||
if (self->start == NULL)
|
||||
{
|
||||
self->start = g_new (_T_, new_capacity);
|
||||
self->start = g_new (_T_, new_size);
|
||||
*self->start = *(_T_[1]) { 0 };
|
||||
}
|
||||
else
|
||||
#endif
|
||||
self->start = g_renew (_T_, self->start, new_capacity);
|
||||
self->start = g_renew (_T_, self->start, new_size);
|
||||
|
||||
self->end = self->start + size;
|
||||
self->end_allocation = self->start + new_capacity;
|
||||
self->end_allocation = self->start + new_size;
|
||||
#ifdef GDK_ARRAY_NULL_TERMINATED
|
||||
self->end_allocation--;
|
||||
#endif
|
||||
@@ -319,7 +312,6 @@ gdk_array(get) (const GdkArray *self,
|
||||
#undef gdk_array_paste
|
||||
#undef gdk_array
|
||||
#undef GDK_ARRAY_REAL_SIZE
|
||||
#undef GDK_ARRAY_MAX_SIZE
|
||||
|
||||
#undef GDK_ARRAY_BY_VALUE
|
||||
#undef GDK_ARRAY_ELEMENT_TYPE
|
||||
|
||||
@@ -522,6 +522,8 @@ gdk_clipboard_get_content (GdkClipboard *clipboard)
|
||||
*
|
||||
* If the clipboard is not local, this function does nothing but report success.
|
||||
*
|
||||
* The @callback must call [method@Gdk.Clipboard.store_finish].
|
||||
*
|
||||
* The purpose of this call is to preserve clipboard contents beyond the
|
||||
* lifetime of an application, so this function is typically called on
|
||||
* exit. Depending on the platform, the functionality may not be available
|
||||
@@ -636,6 +638,9 @@ gdk_clipboard_read_internal (GdkClipboard *clipboard,
|
||||
* Asynchronously requests an input stream to read the @clipboard's
|
||||
* contents from.
|
||||
*
|
||||
* When the operation is finished @callback will be called. You must then
|
||||
* call [method@Gdk.Clipboard.read_finish] to get the result of the operation.
|
||||
*
|
||||
* The clipboard will choose the most suitable mime type from the given list
|
||||
* to fulfill the request, preferring the ones listed first.
|
||||
*/
|
||||
@@ -829,6 +834,9 @@ gdk_clipboard_read_value_internal (GdkClipboard *clipboard,
|
||||
* Asynchronously request the @clipboard contents converted to the given
|
||||
* @type.
|
||||
*
|
||||
* When the operation is finished @callback will be called. You must then call
|
||||
* [method@Gdk.Clipboard.read_value_finish] to get the resulting `GValue`.
|
||||
*
|
||||
* For local clipboard contents that are available in the given `GType`,
|
||||
* the value will be copied directly. Otherwise, GDK will try to use
|
||||
* [func@content_deserialize_async] to convert the clipboard's data.
|
||||
@@ -887,6 +895,9 @@ gdk_clipboard_read_value_finish (GdkClipboard *clipboard,
|
||||
*
|
||||
* Asynchronously request the @clipboard contents converted to a `GdkPixbuf`.
|
||||
*
|
||||
* When the operation is finished @callback will be called. You must then
|
||||
* call [method@Gdk.Clipboard.read_texture_finish] to get the result.
|
||||
*
|
||||
* This is a simple wrapper around [method@Gdk.Clipboard.read_value_async].
|
||||
* Use that function or [method@Gdk.Clipboard.read_async] directly if you
|
||||
* need more control over the operation.
|
||||
@@ -949,6 +960,9 @@ gdk_clipboard_read_texture_finish (GdkClipboard *clipboard,
|
||||
*
|
||||
* Asynchronously request the @clipboard contents converted to a string.
|
||||
*
|
||||
* When the operation is finished @callback will be called. You must then
|
||||
* call [method@Gdk.Clipboard.read_text_finish] to get the result.
|
||||
*
|
||||
* This is a simple wrapper around [method@Gdk.Clipboard.read_value_async].
|
||||
* Use that function or [method@Gdk.Clipboard.read_async] directly if you
|
||||
* need more control over the operation.
|
||||
|
||||
@@ -540,6 +540,9 @@ deserialize_not_found (GdkContentDeserializer *deserializer)
|
||||
*
|
||||
* The default I/O priority is %G_PRIORITY_DEFAULT (i.e. 0), and lower numbers
|
||||
* indicate a higher priority.
|
||||
*
|
||||
* When the operation is finished, @callback will be called. You must then
|
||||
* call [func@Gdk.content_deserialize_finish] to get the result of the operation.
|
||||
*/
|
||||
void
|
||||
gdk_content_deserialize_async (GInputStream *stream,
|
||||
|
||||
@@ -279,6 +279,10 @@ gdk_content_provider_content_changed (GdkContentProvider *provider)
|
||||
* Asynchronously writes the contents of @provider to @stream in the given
|
||||
* @mime_type.
|
||||
*
|
||||
* When the operation is finished @callback will be called. You must then call
|
||||
* [method@Gdk.ContentProvider.write_mime_type_finish] to get the result
|
||||
* of the operation.
|
||||
*
|
||||
* The given mime type does not need to be listed in the formats returned by
|
||||
* [method@Gdk.ContentProvider.ref_formats]. However, if the given `GType` is
|
||||
* not supported, `G_IO_ERROR_NOT_SUPPORTED` will be reported.
|
||||
|
||||
@@ -546,6 +546,9 @@ serialize_not_found (GdkContentSerializer *serializer)
|
||||
*
|
||||
* The default I/O priority is %G_PRIORITY_DEFAULT (i.e. 0), and lower numbers
|
||||
* indicate a higher priority.
|
||||
*
|
||||
* When the operation is finished, @callback will be called. You must then
|
||||
* call [func@Gdk.content_serialize_finish] to get the result of the operation.
|
||||
*/
|
||||
void
|
||||
gdk_content_serialize_async (GOutputStream *stream,
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ GdkCursor* gdk_cursor_new_from_name (const char *name,
|
||||
GdkCursor *fallback);
|
||||
|
||||
/**
|
||||
* GdkCursorGetTextureCallback:
|
||||
* GdkCursorGetTestureCallback:
|
||||
* @cursor: the `GdkCursor`
|
||||
* @cursor_size: the nominal cursor size, in application pixels
|
||||
* @scale: the device scale
|
||||
|
||||
+5
-5
@@ -144,8 +144,8 @@ struct _YUVCoefficients
|
||||
};
|
||||
|
||||
/* multiplied by 65536 */
|
||||
static const YUVCoefficients itu601_narrow = { 104597, -25675, -53279, 132201 };
|
||||
//static const YUVCoefficients itu601_wide = { 74711, -25864, -38050, 133176 };
|
||||
//static const YUVCoefficients itu601_narrow = { 104597, -25675, -53279, 132201 };
|
||||
static const YUVCoefficients itu601_wide = { 74711, -25864, -38050, 133176 };
|
||||
|
||||
static inline void
|
||||
get_uv_values (const YUVCoefficients *coeffs,
|
||||
@@ -229,7 +229,7 @@ download_nv12 (guchar *dst_data,
|
||||
int r, g, b;
|
||||
gsize xs, ys;
|
||||
|
||||
get_uv_values (&itu601_narrow, uv_data[x / X_SUB * 2 + U], uv_data[x / X_SUB * 2 + V], &r, &g, &b);
|
||||
get_uv_values (&itu601_wide, 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 (xs = 0; xs < X_SUB && x + xs < width; xs++)
|
||||
@@ -309,7 +309,7 @@ download_yuv_3 (guchar *dst_data,
|
||||
int r, g, b;
|
||||
gsize xs, ys;
|
||||
|
||||
get_uv_values (&itu601_narrow, u_data[x / X_SUB], v_data[x / X_SUB], &r, &g, &b);
|
||||
get_uv_values (&itu601_wide, u_data[x / X_SUB], v_data[x / X_SUB], &r, &g, &b);
|
||||
|
||||
for (ys = 0; ys < Y_SUB && y + ys < height; ys++)
|
||||
for (xs = 0; xs < X_SUB && x + xs < width; xs++)
|
||||
@@ -365,7 +365,7 @@ download_yuyv (guchar *dst_data,
|
||||
{
|
||||
int r, g, b;
|
||||
|
||||
get_uv_values (&itu601_narrow, src_data[2 * x + U], src_data[2 * x + V], &r, &g, &b);
|
||||
get_uv_values (&itu601_wide, 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);
|
||||
if (x + 1 < width)
|
||||
set_rgb_values (&dst_data[3 * (x + 1)], src_data[2 * x + Y2], r, g, b);
|
||||
|
||||
+2
-8
@@ -163,8 +163,6 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
|
||||
return NULL;
|
||||
|
||||
previous = gdk_gl_context_get_current ();
|
||||
if (previous)
|
||||
g_object_ref (previous);
|
||||
formats = gdk_dmabuf_formats_builder_new ();
|
||||
external = gdk_dmabuf_formats_builder_new ();
|
||||
|
||||
@@ -196,10 +194,7 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
|
||||
}
|
||||
|
||||
if (previous)
|
||||
{
|
||||
gdk_gl_context_make_current (previous);
|
||||
g_object_unref (previous);
|
||||
}
|
||||
gdk_gl_context_make_current (previous);
|
||||
|
||||
return GDK_DMABUF_DOWNLOADER (renderer);
|
||||
}
|
||||
@@ -244,7 +239,7 @@ gdk_dmabuf_egl_create_image (GdkDisplay *display,
|
||||
attribs[i++] = EGL_YUV_COLOR_SPACE_HINT_EXT;
|
||||
attribs[i++] = EGL_ITU_REC601_EXT;
|
||||
attribs[i++] = EGL_SAMPLE_RANGE_HINT_EXT;
|
||||
attribs[i++] = EGL_YUV_NARROW_RANGE_EXT;
|
||||
attribs[i++] = EGL_YUV_FULL_RANGE_EXT;
|
||||
|
||||
#define ADD_PLANE(plane) \
|
||||
{ \
|
||||
@@ -270,7 +265,6 @@ gdk_dmabuf_egl_create_image (GdkDisplay *display,
|
||||
if (dmabuf->n_planes > 3) ADD_PLANE (3);
|
||||
|
||||
attribs[i++] = EGL_NONE;
|
||||
g_assert (i < G_N_ELEMENTS (attribs));
|
||||
|
||||
image = eglCreateImageKHR (egl_display,
|
||||
EGL_NO_CONTEXT,
|
||||
|
||||
@@ -62,13 +62,6 @@ struct _GdkDmabufTextureClass
|
||||
GdkTextureClass parent_class;
|
||||
};
|
||||
|
||||
/**
|
||||
* gdk_dmabuf_error_quark:
|
||||
*
|
||||
* Registers an error quark for [class@Gdk.DmabufTexture] errors.
|
||||
*
|
||||
* Returns: the error quark
|
||||
**/
|
||||
G_DEFINE_QUARK (gdk-dmabuf-error-quark, gdk_dmabuf_error)
|
||||
|
||||
G_DEFINE_TYPE (GdkDmabufTexture, gdk_dmabuf_texture, GDK_TYPE_TEXTURE)
|
||||
|
||||
+6
-2
@@ -134,7 +134,7 @@ gdk_drop_read_local_async (GdkDrop *self,
|
||||
|
||||
g_object_get (priv->drag, "content", &content, NULL);
|
||||
content_formats = gdk_content_provider_ref_formats (content);
|
||||
g_object_unref (content);
|
||||
g_object_unref (content);
|
||||
content_formats = gdk_content_formats_union_serialize_mime_types (content_formats);
|
||||
mime_type = gdk_content_formats_match_mime_type (content_formats, formats);
|
||||
|
||||
@@ -784,7 +784,7 @@ gdk_drop_read_value_internal (GdkDrop *self,
|
||||
GdkContentFormats *formats;
|
||||
GValue *value;
|
||||
GTask *task;
|
||||
|
||||
|
||||
g_return_if_fail (priv->state != GDK_DROP_STATE_FINISHED);
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
@@ -849,6 +849,10 @@ gdk_drop_read_value_internal (GdkDrop *self,
|
||||
* Asynchronously request the drag operation's contents converted
|
||||
* to the given @type.
|
||||
*
|
||||
* When the operation is finished @callback will be called. You must
|
||||
* then call [method@Gdk.Drop.read_value_finish] to get the resulting
|
||||
* `GValue`.
|
||||
*
|
||||
* For local drag-and-drop operations that are available in the given
|
||||
* `GType`, the value will be copied directly. Otherwise, GDK will
|
||||
* try to use [func@Gdk.content_deserialize_async] to convert the data.
|
||||
|
||||
@@ -1371,8 +1371,6 @@ gdk_event_get_modifier_state (GdkEvent *event)
|
||||
* Extract the event surface relative x/y coordinates from an event.
|
||||
*
|
||||
* This position is in [surface coordinates](coordinates.html).
|
||||
*
|
||||
* Returns: whether the positions were set
|
||||
*/
|
||||
gboolean
|
||||
gdk_event_get_position (GdkEvent *event,
|
||||
|
||||
@@ -192,6 +192,13 @@ compute_smooth_frame_time (GdkFrameClock *clock,
|
||||
* and new_frame_time >= old_frame_time. */
|
||||
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
|
||||
* last smoothed frame time. This way we avoid minor jitter in the
|
||||
* frame times making the animation speed uneven, but still animate
|
||||
|
||||
+35
-79
@@ -152,13 +152,6 @@ enum {
|
||||
|
||||
static GParamSpec *properties[LAST_PROP] = { NULL, };
|
||||
|
||||
/**
|
||||
* gdk_gl_error_quark:
|
||||
*
|
||||
* Registers an error quark for [class@Gdk.GLContext] errors.
|
||||
*
|
||||
* Returns: the error quark
|
||||
**/
|
||||
G_DEFINE_QUARK (gdk-gl-error-quark, gdk_gl_error)
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkGLContext, gdk_gl_context, GDK_TYPE_DRAW_CONTEXT)
|
||||
@@ -1963,6 +1956,8 @@ gdk_gl_context_get_glsl_version_string (GdkGLContext *self)
|
||||
return "#version 310 es";
|
||||
else if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
|
||||
return "#version 300 es";
|
||||
else if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
|
||||
return "#version 300 es";
|
||||
else
|
||||
return "#version 100";
|
||||
}
|
||||
@@ -2203,78 +2198,12 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
|
||||
|
||||
gdk_display_init_dmabuf (display);
|
||||
|
||||
if (gdk_dmabuf_formats_contains (display->egl_dmabuf_formats, dmabuf->fourcc, dmabuf->modifier))
|
||||
if (!gdk_dmabuf_formats_contains (display->egl_external_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,
|
||||
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;
|
||||
}
|
||||
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);
|
||||
|
||||
GL_TEXTURE_2D);
|
||||
if (texture_id == 0)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||
@@ -2285,13 +2214,40 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
|
||||
}
|
||||
|
||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as %s texture",
|
||||
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_2D texture",
|
||||
width, height,
|
||||
(char *) &dmabuf->fourcc, dmabuf->modifier,
|
||||
target == GL_TEXTURE_EXTERNAL_OES ? "GL_TEXTURE_EXTERNAL_OES" : "GL_TEXTURE_2D");
|
||||
*external = target == GL_TEXTURE_EXTERNAL_OES;
|
||||
(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,
|
||||
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
|
||||
|
||||
+2
-13
@@ -396,18 +396,10 @@ gboolean
|
||||
*/
|
||||
char *
|
||||
gdk_rgba_to_string (const GdkRGBA *rgba)
|
||||
{
|
||||
return g_string_free (gdk_rgba_print (rgba, g_string_new ("")), FALSE);
|
||||
}
|
||||
|
||||
GString *
|
||||
gdk_rgba_print (const GdkRGBA *rgba,
|
||||
GString *string)
|
||||
{
|
||||
if (rgba->alpha > 0.999)
|
||||
{
|
||||
g_string_append_printf (string,
|
||||
"rgb(%d,%d,%d)",
|
||||
return g_strdup_printf ("rgb(%d,%d,%d)",
|
||||
(int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),
|
||||
(int)(0.5 + CLAMP (rgba->green, 0., 1.) * 255.),
|
||||
(int)(0.5 + CLAMP (rgba->blue, 0., 1.) * 255.));
|
||||
@@ -418,15 +410,12 @@ gdk_rgba_print (const GdkRGBA *rgba,
|
||||
|
||||
g_ascii_formatd (alpha, G_ASCII_DTOSTR_BUF_SIZE, "%g", CLAMP (rgba->alpha, 0, 1));
|
||||
|
||||
g_string_append_printf (string,
|
||||
"rgba(%d,%d,%d,%s)",
|
||||
return g_strdup_printf ("rgba(%d,%d,%d,%s)",
|
||||
(int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),
|
||||
(int)(0.5 + CLAMP (rgba->green, 0., 1.) * 255.),
|
||||
(int)(0.5 + CLAMP (rgba->blue, 0., 1.) * 255.),
|
||||
alpha);
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
||||
@@ -72,8 +72,5 @@ _gdk_rgba_equal (gconstpointer p1,
|
||||
rgba1->alpha == rgba2->alpha;
|
||||
}
|
||||
|
||||
GString * gdk_rgba_print (const GdkRGBA *rgba,
|
||||
GString *string);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+1
-8
@@ -50,13 +50,6 @@
|
||||
#include "loaders/gdktiffprivate.h"
|
||||
#include "loaders/gdkjpegprivate.h"
|
||||
|
||||
/**
|
||||
* gdk_texture_error_quark:
|
||||
*
|
||||
* Registers an error quark for [class@Gdk.Texture] errors.
|
||||
*
|
||||
* Returns: the error quark
|
||||
**/
|
||||
G_DEFINE_QUARK (gdk-texture-error-quark, gdk_texture_error)
|
||||
|
||||
/* HACK: So we don't need to include any (not-yet-created) GSK or GTK headers */
|
||||
@@ -570,7 +563,7 @@ gdk_texture_new_from_bytes_internal (GBytes *bytes,
|
||||
{
|
||||
if (gdk_is_png (bytes))
|
||||
{
|
||||
return gdk_load_png (bytes, NULL, error);
|
||||
return gdk_load_png (bytes, error);
|
||||
}
|
||||
else if (gdk_is_jpeg (bytes))
|
||||
{
|
||||
|
||||
@@ -767,6 +767,9 @@ gdk_toplevel_titlebar_gesture (GdkToplevel *toplevel,
|
||||
* This function asynchronously obtains a handle for a toplevel surface
|
||||
* that can be passed to other processes.
|
||||
*
|
||||
* When a handle has been obtained, @callback will be called, and can
|
||||
* receive the handle via [method@Gdk.Toplevel.export_handle_finish].
|
||||
*
|
||||
* It is an error to call this function on a surface that is already
|
||||
* exported.
|
||||
*
|
||||
|
||||
+3
-6
@@ -118,12 +118,9 @@ typedef enum
|
||||
|
||||
/**
|
||||
* GdkTitlebarGesture:
|
||||
* @GDK_TITLEBAR_GESTURE_DOUBLE_CLICK: double click gesture
|
||||
* @GDK_TITLEBAR_GESTURE_RIGHT_CLICK: right click gesture
|
||||
* @GDK_TITLEBAR_GESTURE_MIDDLE_CLICK: middle click gesture
|
||||
*
|
||||
* The kind of title bar gesture to emit with
|
||||
* [method@Gdk.Toplevel.titlebar_gesture].
|
||||
* @GDK_TITLEBAR_GESTURE_DOUBLE_CLICK:
|
||||
* @GDK_TITLEBAR_GESTURE_RIGHT_CLICK:
|
||||
* @GDK_TITLEBAR_GESTURE_MIDDLE_CLICK:
|
||||
*
|
||||
* Since: 4.4
|
||||
*/
|
||||
|
||||
+17
-65
@@ -29,7 +29,6 @@
|
||||
#include "gdkdmabuffourccprivate.h"
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkprofilerprivate.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <math.h>
|
||||
|
||||
@@ -94,13 +93,6 @@ enum {
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
/**
|
||||
* gdk_vulkan_error_quark:
|
||||
*
|
||||
* Registers an error quark for [class@Gdk.VulkanContext] errors.
|
||||
*
|
||||
* Returns: the error quark
|
||||
**/
|
||||
G_DEFINE_QUARK (gdk-vulkan-error-quark, gdk_vulkan_error)
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
@@ -614,8 +606,7 @@ physical_device_check_features (VkPhysicalDevice device)
|
||||
features |= GDK_VULKAN_FEATURE_YCBCR;
|
||||
|
||||
if (physical_device_supports_extension (device, VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME) &&
|
||||
physical_device_supports_extension (device, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME) &&
|
||||
physical_device_supports_extension (device, VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME))
|
||||
physical_device_supports_extension (device, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME))
|
||||
features |= GDK_VULKAN_FEATURE_DMABUF;
|
||||
|
||||
if (physical_device_supports_extension (device, VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME))
|
||||
@@ -640,7 +631,6 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
|
||||
{
|
||||
GdkVulkanContext *context = GDK_VULKAN_CONTEXT (draw_context);
|
||||
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
|
||||
VkResult acquire_result;
|
||||
guint i;
|
||||
|
||||
if (depth != priv->current_format)
|
||||
@@ -662,29 +652,12 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
|
||||
cairo_region_union (priv->regions[i], region);
|
||||
}
|
||||
|
||||
acquire_next_image:
|
||||
acquire_result = GDK_VK_CHECK (vkAcquireNextImageKHR, gdk_vulkan_context_get_device (context),
|
||||
priv->swapchain,
|
||||
UINT64_MAX,
|
||||
priv->draw_semaphore,
|
||||
VK_NULL_HANDLE,
|
||||
&priv->draw_index);
|
||||
if ((acquire_result == VK_ERROR_OUT_OF_DATE_KHR) ||
|
||||
(acquire_result == VK_SUBOPTIMAL_KHR))
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
GDK_DEBUG (VULKAN, "Recreating the swapchain");
|
||||
|
||||
if (!gdk_vulkan_context_check_swapchain (context, &error))
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
goto acquire_next_image;
|
||||
}
|
||||
GDK_VK_CHECK (vkAcquireNextImageKHR, gdk_vulkan_context_get_device (context),
|
||||
priv->swapchain,
|
||||
UINT64_MAX,
|
||||
priv->draw_semaphore,
|
||||
VK_NULL_HANDLE,
|
||||
&priv->draw_index);
|
||||
|
||||
cairo_region_union (region, priv->regions[priv->draw_index]);
|
||||
}
|
||||
@@ -1137,7 +1110,6 @@ gdk_display_load_pipeline_cache (GdkDisplay *display)
|
||||
static gboolean
|
||||
gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
||||
{
|
||||
G_GNUC_UNUSED gint64 begin_time = GDK_PROFILER_CURRENT_TIME;
|
||||
GError *error = NULL;
|
||||
VkDevice device;
|
||||
VkPipelineCache cache;
|
||||
@@ -1152,13 +1124,14 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
||||
GDK_VK_CHECK (vkGetPipelineCacheData, device, cache, &size, NULL);
|
||||
if (size == 0)
|
||||
return TRUE;
|
||||
|
||||
|
||||
if (size == display->vk_pipeline_cache_size)
|
||||
{
|
||||
GDK_DEBUG (VULKAN, "pipeline cache size (%zu bytes) unchanged, skipping save", size);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
data = g_malloc (size);
|
||||
if (GDK_VK_CHECK (vkGetPipelineCacheData, device, cache, &size, data) != VK_SUCCESS)
|
||||
{
|
||||
@@ -1178,7 +1151,7 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
||||
|
||||
file = gdk_vulkan_get_pipeline_cache_file (display);
|
||||
|
||||
GDK_DEBUG (VULKAN, "Saving pipeline cache of size %lu to %s", size, g_file_peek_path (file));
|
||||
GDK_DEBUG (VULKAN, "Saving pipeline cache to %s", g_file_peek_path (file));
|
||||
|
||||
if (!g_file_replace_contents (file,
|
||||
data,
|
||||
@@ -1193,7 +1166,7 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WRONG_ETAG))
|
||||
{
|
||||
VkPipelineCache new_cache;
|
||||
|
||||
|
||||
GDK_DEBUG (VULKAN, "Pipeline cache file modified, merging into current");
|
||||
new_cache = gdk_display_load_pipeline_cache (display);
|
||||
if (new_cache)
|
||||
@@ -1220,15 +1193,10 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gdk_profiler_end_markf (begin_time,
|
||||
"Save Vulkan pipeline cache", "%s size %lu",
|
||||
g_file_peek_path (file), size);
|
||||
|
||||
g_object_unref (file);
|
||||
g_free (data);
|
||||
g_free (display->vk_pipeline_cache_etag);
|
||||
display->vk_pipeline_cache_etag = etag;
|
||||
display->vk_pipeline_cache_size = size;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1268,11 +1236,6 @@ gdk_display_create_pipeline_cache (GdkDisplay *display)
|
||||
},
|
||||
NULL,
|
||||
&display->vk_pipeline_cache);
|
||||
GDK_DEBUG (VULKAN, "Creating empty pipeline cache");
|
||||
}
|
||||
else
|
||||
{
|
||||
GDK_DEBUG (VULKAN, "Loading pipeline cache (%lu bytes)", display->vk_pipeline_cache_size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1382,7 +1345,6 @@ static gboolean
|
||||
gdk_display_create_vulkan_device (GdkDisplay *display,
|
||||
GError **error)
|
||||
{
|
||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||
uint32_t i, j, k;
|
||||
const char *override;
|
||||
gboolean list_devices;
|
||||
@@ -1525,7 +1487,6 @@ gdk_display_create_vulkan_device (GdkDisplay *display,
|
||||
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME);
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME);
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME);
|
||||
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME);
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME);
|
||||
@@ -1592,8 +1553,6 @@ gdk_display_create_vulkan_device (GdkDisplay *display,
|
||||
"Hum, what? This should not happen.")));
|
||||
}
|
||||
|
||||
gdk_profiler_end_mark (start_time, "Create Vulkan device", NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1632,7 +1591,6 @@ static gboolean
|
||||
gdk_display_create_vulkan_instance (GdkDisplay *display,
|
||||
GError **error)
|
||||
{
|
||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||
uint32_t i;
|
||||
GPtrArray *used_extensions;
|
||||
GPtrArray *used_layers;
|
||||
@@ -1794,8 +1752,6 @@ gdk_display_create_vulkan_instance (GdkDisplay *display,
|
||||
|
||||
display->vk_shader_modules = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
gdk_profiler_end_mark (start_time, "Create Vulkan instance", NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1866,9 +1822,8 @@ gdk_display_unref_vulkan (GdkDisplay *display)
|
||||
{
|
||||
g_free (key);
|
||||
vkDestroyShaderModule (display->vk_device,
|
||||
*((VkShaderModule *)value),
|
||||
value,
|
||||
NULL);
|
||||
g_free (value);
|
||||
}
|
||||
g_hash_table_unref (display->vk_shader_modules);
|
||||
|
||||
@@ -1996,13 +1951,13 @@ VkShaderModule
|
||||
gdk_display_get_vk_shader_module (GdkDisplay *self,
|
||||
const char *resource_name)
|
||||
{
|
||||
VkShaderModule *shader;
|
||||
VkShaderModule shader;
|
||||
GError *error = NULL;
|
||||
GBytes *bytes;
|
||||
|
||||
shader = g_hash_table_lookup (self->vk_shader_modules, resource_name);
|
||||
if (shader)
|
||||
return *shader;
|
||||
return shader;
|
||||
|
||||
bytes = g_resources_lookup_data (resource_name, 0, &error);
|
||||
if (bytes == NULL)
|
||||
@@ -2012,7 +1967,6 @@ gdk_display_get_vk_shader_module (GdkDisplay *self,
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
shader = g_new0 (VkShaderModule, 1);
|
||||
if (GDK_VK_CHECK (vkCreateShaderModule, self->vk_device,
|
||||
&(VkShaderModuleCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
|
||||
@@ -2020,20 +1974,18 @@ gdk_display_get_vk_shader_module (GdkDisplay *self,
|
||||
.pCode = (uint32_t *) g_bytes_get_data (bytes, NULL),
|
||||
},
|
||||
NULL,
|
||||
shader) == VK_SUCCESS)
|
||||
&shader) == VK_SUCCESS)
|
||||
{
|
||||
g_hash_table_insert (self->vk_shader_modules, g_strdup (resource_name), shader);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (shader);
|
||||
|
||||
return VK_NULL_HANDLE;
|
||||
shader = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
return *shader;
|
||||
return shader;
|
||||
}
|
||||
|
||||
#else /* GDK_RENDERING_VULKAN */
|
||||
|
||||
+3
-17
@@ -127,18 +127,15 @@ png_simple_warning_callback (png_structp png,
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Public API */
|
||||
/* {{{ Public API */
|
||||
|
||||
GdkTexture *
|
||||
gdk_load_png (GBytes *bytes,
|
||||
GHashTable *options,
|
||||
GError **error)
|
||||
gdk_load_png (GBytes *bytes,
|
||||
GError **error)
|
||||
{
|
||||
png_io io;
|
||||
png_struct *png = NULL;
|
||||
png_info *info;
|
||||
png_textp text;
|
||||
int num_texts;
|
||||
guint width, height;
|
||||
gsize i, stride;
|
||||
int depth, color_type;
|
||||
@@ -300,17 +297,6 @@ gdk_load_png (GBytes *bytes,
|
||||
texture = gdk_memory_texture_new (width, height, format, out_bytes, stride);
|
||||
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);
|
||||
png_destroy_read_struct (&png, &info, NULL);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#define PNG_SIGNATURE "\x89PNG"
|
||||
|
||||
GdkTexture *gdk_load_png (GBytes *bytes,
|
||||
GHashTable *options,
|
||||
GError **error);
|
||||
|
||||
GBytes *gdk_save_png (GdkTexture *texture);
|
||||
|
||||
@@ -96,12 +96,12 @@ _gdk_macos_drag_surface_constructed (GObject *object)
|
||||
defer:NO
|
||||
screen:screen];
|
||||
|
||||
_gdk_macos_surface_set_native (self, window);
|
||||
|
||||
[window setOpaque:NO];
|
||||
[window setBackgroundColor:[NSColor clearColor]];
|
||||
[window setDecorated:NO];
|
||||
|
||||
_gdk_macos_surface_set_native (self, window);
|
||||
|
||||
frame_clock = _gdk_frame_clock_idle_new ();
|
||||
gdk_surface_set_frame_clock (surface, frame_clock);
|
||||
g_object_unref (frame_clock);
|
||||
|
||||
@@ -52,7 +52,6 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self,
|
||||
GdkRectangle bounds;
|
||||
GdkRectangle final_rect;
|
||||
int x, y;
|
||||
int shadow_left, shadow_right, shadow_top, shadow_bottom;
|
||||
|
||||
g_assert (GDK_IS_MACOS_POPUP_SURFACE (self));
|
||||
g_assert (layout != NULL);
|
||||
@@ -69,19 +68,10 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self,
|
||||
monitor = _gdk_macos_surface_get_best_monitor (GDK_MACOS_SURFACE (self));
|
||||
gdk_macos_monitor_get_workarea (monitor, &bounds);
|
||||
|
||||
gdk_popup_layout_get_shadow_width (layout,
|
||||
&shadow_left,
|
||||
&shadow_right,
|
||||
&shadow_top,
|
||||
&shadow_bottom);
|
||||
|
||||
gdk_surface_layout_popup_helper (GDK_SURFACE (self),
|
||||
width,
|
||||
height,
|
||||
shadow_left,
|
||||
shadow_right,
|
||||
shadow_top,
|
||||
shadow_bottom,
|
||||
0, 0, 0, 0, /* shadow-left/right/top/bottom */
|
||||
monitor,
|
||||
&bounds,
|
||||
self->layout,
|
||||
@@ -316,14 +306,14 @@ _gdk_macos_popup_surface_constructed (GObject *object)
|
||||
defer:NO
|
||||
screen:screen];
|
||||
|
||||
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
|
||||
|
||||
[window setOpaque:NO];
|
||||
[window setBackgroundColor:[NSColor clearColor]];
|
||||
[window setDecorated:NO];
|
||||
[window setExcludedFromWindowsMenu:YES];
|
||||
[window setLevel:NSPopUpMenuWindowLevel];
|
||||
|
||||
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
|
||||
|
||||
gdk_surface_set_frame_clock (surface, gdk_surface_get_frame_clock (surface->parent));
|
||||
|
||||
GDK_END_MACOS_ALLOC_POOL;
|
||||
|
||||
@@ -591,11 +591,11 @@ _gdk_macos_toplevel_surface_constructed (GObject *object)
|
||||
defer:NO
|
||||
screen:screen];
|
||||
|
||||
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
|
||||
|
||||
/* Allow NSWindow to go fullscreen */
|
||||
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||
|
||||
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
|
||||
|
||||
frame_clock = _gdk_frame_clock_idle_new ();
|
||||
gdk_surface_set_frame_clock (surface, frame_clock);
|
||||
g_object_unref (frame_clock);
|
||||
|
||||
+1
-1
@@ -128,8 +128,8 @@ install_headers(gdk_deprecated_headers, subdir: 'gtk-4.0/gdk/deprecated')
|
||||
gdk_sources = gdk_public_sources + gdk_deprecated_sources
|
||||
|
||||
gdk_private_h_sources = files([
|
||||
'gdkdevicetoolprivate.h',
|
||||
'gdkeventsprivate.h',
|
||||
'gdkdevicetoolprivate.h',
|
||||
'gdkhslaprivate.h',
|
||||
'gdkmonitorprivate.h',
|
||||
'gdkseatdefaultprivate.h',
|
||||
|
||||
@@ -165,29 +165,25 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
||||
double *scale)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
int desired_scale_factor;
|
||||
|
||||
desired_scale_factor = (int) ceil (desired_scale);
|
||||
|
||||
if (gdk_cursor_get_name (cursor))
|
||||
{
|
||||
struct wl_cursor *c;
|
||||
int scale_factor;
|
||||
|
||||
if (g_str_equal (gdk_cursor_get_name (cursor), "none"))
|
||||
{
|
||||
*hotspot_x = *hotspot_y = 0;
|
||||
*width = *height = 0;
|
||||
*scale = 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
scale_factor = (int) ceil (desired_scale);
|
||||
goto none;
|
||||
|
||||
c = gdk_wayland_cursor_load_for_name (display,
|
||||
display->cursor_theme,
|
||||
scale_factor,
|
||||
_gdk_wayland_display_get_cursor_theme (display),
|
||||
desired_scale_factor,
|
||||
gdk_cursor_get_name (cursor));
|
||||
if (c && c->image_count > 0)
|
||||
{
|
||||
struct wl_cursor_image *image;
|
||||
int cursor_scale;
|
||||
|
||||
if (image_index >= c->image_count)
|
||||
{
|
||||
@@ -199,23 +195,23 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
||||
|
||||
image = c->images[image_index];
|
||||
|
||||
*width = display->cursor_theme_size;
|
||||
*height = display->cursor_theme_size;
|
||||
*scale = image->width / (double) *width;
|
||||
*hotspot_x = image->hotspot_x / scale_factor;
|
||||
*hotspot_y = image->hotspot_y / scale_factor;
|
||||
|
||||
if (*scale != scale_factor && !use_viewporter)
|
||||
cursor_scale = desired_scale_factor;
|
||||
if ((image->width % cursor_scale != 0) ||
|
||||
(image->height % cursor_scale != 0))
|
||||
{
|
||||
g_warning (G_STRLOC " cursor image size (%d) not an integer "
|
||||
"multiple of theme size (%d)", image->width, *width);
|
||||
*width = image->width;
|
||||
*height = image->height;
|
||||
*hotspot_x = image->hotspot_x;
|
||||
*hotspot_y = image->hotspot_y;
|
||||
*scale = 1;
|
||||
g_warning (G_STRLOC " cursor image size (%dx%d) not an integer "
|
||||
"multiple of scale (%d)", image->width, image->height,
|
||||
cursor_scale);
|
||||
cursor_scale = 1;
|
||||
}
|
||||
|
||||
*hotspot_x = image->hotspot_x / cursor_scale;
|
||||
*hotspot_y = image->hotspot_y / cursor_scale;
|
||||
|
||||
*width = image->width / cursor_scale;
|
||||
*height = image->height / cursor_scale;
|
||||
*scale = cursor_scale;
|
||||
|
||||
return wl_cursor_image_get_buffer (image);
|
||||
}
|
||||
}
|
||||
@@ -261,7 +257,7 @@ from_texture:
|
||||
else
|
||||
{
|
||||
if (!use_viewporter)
|
||||
*scale = ceil (desired_scale);
|
||||
*scale = desired_scale_factor;
|
||||
else
|
||||
*scale = desired_scale;
|
||||
|
||||
@@ -298,23 +294,28 @@ from_texture:
|
||||
}
|
||||
|
||||
if (gdk_cursor_get_fallback (cursor))
|
||||
{
|
||||
return _gdk_wayland_cursor_get_buffer (display,
|
||||
gdk_cursor_get_fallback (cursor),
|
||||
desired_scale,
|
||||
use_viewporter,
|
||||
image_index,
|
||||
hotspot_x, hotspot_y,
|
||||
width, height,
|
||||
scale);
|
||||
}
|
||||
return _gdk_wayland_cursor_get_buffer (display,
|
||||
gdk_cursor_get_fallback (cursor),
|
||||
desired_scale,
|
||||
use_viewporter,
|
||||
image_index,
|
||||
hotspot_x, hotspot_y,
|
||||
width, height,
|
||||
scale);
|
||||
else
|
||||
{
|
||||
texture = gdk_texture_new_from_resource ("/org/gtk/libgdk/cursor/default");
|
||||
goto from_texture;
|
||||
}
|
||||
|
||||
g_assert_not_reached ();
|
||||
none:
|
||||
*hotspot_x = 0;
|
||||
*hotspot_y = 0;
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
*scale = 1;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
guint
|
||||
|
||||
@@ -97,7 +97,6 @@
|
||||
#define OUTPUT_VERSION_WITH_DONE 2
|
||||
#define NO_XDG_OUTPUT_DONE_SINCE_VERSION 3
|
||||
#define OUTPUT_VERSION 3
|
||||
#define XDG_WM_DIALOG_VERSION 1
|
||||
|
||||
#ifdef HAVE_TOPLEVEL_STATE_SUSPENDED
|
||||
#define XDG_WM_BASE_VERSION 6
|
||||
@@ -288,6 +287,97 @@ static const struct wl_shm_listener wl_shm_listener = {
|
||||
wl_shm_format
|
||||
};
|
||||
|
||||
static void
|
||||
linux_dmabuf_done (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1)
|
||||
{
|
||||
GDK_DEBUG (MISC, "dmabuf feedback done");
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_format_table (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
int32_t fd,
|
||||
uint32_t size)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = data;
|
||||
|
||||
display_wayland->linux_dmabuf_n_formats = size / 16;
|
||||
display_wayland->linux_dmabuf_formats = mmap (NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
|
||||
GDK_DEBUG (MISC, "got dmabuf format table (%lu entries)", display_wayland->linux_dmabuf_n_formats);
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_main_device (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
struct wl_array *device)
|
||||
{
|
||||
dev_t dev G_GNUC_UNUSED;
|
||||
|
||||
memcpy (&dev, device->data, sizeof (dev_t));
|
||||
|
||||
GDK_DEBUG (MISC, "got dmabuf main device: %u %u", major (dev), minor (dev));
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_done (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1)
|
||||
{
|
||||
GDK_DEBUG (MISC, "dmabuf feedback tranche done");
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_target_device (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
struct wl_array *device)
|
||||
{
|
||||
dev_t dev G_GNUC_UNUSED;
|
||||
|
||||
memcpy (&dev, device->data, sizeof (dev_t));
|
||||
|
||||
GDK_DEBUG (MISC, "got dmabuf tranche target device: %u %u", major (dev), minor (dev));
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_formats (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
struct wl_array *indices)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = data;
|
||||
|
||||
GDK_DEBUG (MISC, "got dmabuf tranche formats (%lu entries):", indices->size / sizeof (guint16));
|
||||
guint16 *pos;
|
||||
|
||||
wl_array_for_each (pos, indices)
|
||||
{
|
||||
LinuxDmabufFormat *fmt G_GNUC_UNUSED = &display_wayland->linux_dmabuf_formats[*pos];
|
||||
uint32_t f G_GNUC_UNUSED = fmt->fourcc;
|
||||
uint64_t m G_GNUC_UNUSED = fmt->modifier;
|
||||
GDK_DEBUG (MISC, " %.4s:%#" G_GINT64_MODIFIER "x", (char *) &f, m);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_flags (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
uint32_t flags)
|
||||
{
|
||||
GDK_DEBUG (MISC,
|
||||
"got dmabuf tranche flags: %s",
|
||||
flags & ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT ? "scanout" : "");
|
||||
}
|
||||
|
||||
static const struct zwp_linux_dmabuf_feedback_v1_listener linux_dmabuf_feedback_listener = {
|
||||
linux_dmabuf_done,
|
||||
linux_dmabuf_format_table,
|
||||
linux_dmabuf_main_device,
|
||||
linux_dmabuf_tranche_done,
|
||||
linux_dmabuf_tranche_target_device,
|
||||
linux_dmabuf_tranche_formats,
|
||||
linux_dmabuf_tranche_flags,
|
||||
};
|
||||
|
||||
static void
|
||||
server_decoration_manager_default_mode (void *data,
|
||||
struct org_kde_kwin_server_decoration_manager *manager,
|
||||
@@ -364,14 +454,12 @@ gdk_registry_handle_global (void *data,
|
||||
}
|
||||
else if (strcmp (interface, "zwp_linux_dmabuf_v1") == 0 && version >= 4)
|
||||
{
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback;
|
||||
|
||||
display_wayland->linux_dmabuf =
|
||||
wl_registry_bind (display_wayland->wl_registry, id, &zwp_linux_dmabuf_v1_interface, version);
|
||||
feedback = zwp_linux_dmabuf_v1_get_default_feedback (display_wayland->linux_dmabuf);
|
||||
display_wayland->dmabuf_formats_info = dmabuf_formats_info_new (GDK_DISPLAY (display_wayland),
|
||||
"default",
|
||||
feedback);
|
||||
display_wayland->linux_dmabuf_feedback =
|
||||
zwp_linux_dmabuf_v1_get_default_feedback (display_wayland->linux_dmabuf);
|
||||
zwp_linux_dmabuf_feedback_v1_add_listener (display_wayland->linux_dmabuf_feedback,
|
||||
&linux_dmabuf_feedback_listener, display_wayland);
|
||||
_gdk_wayland_display_async_roundtrip (display_wayland);
|
||||
}
|
||||
else if (strcmp (interface, "xdg_wm_base") == 0)
|
||||
@@ -383,13 +471,6 @@ gdk_registry_handle_global (void *data,
|
||||
{
|
||||
display_wayland->zxdg_shell_v6_id = id;
|
||||
}
|
||||
else if (strcmp (interface, "xdg_wm_dialog_v1") == 0)
|
||||
{
|
||||
display_wayland->xdg_wm_dialog =
|
||||
wl_registry_bind (display_wayland->wl_registry, id,
|
||||
&xdg_wm_dialog_v1_interface,
|
||||
MIN (version, XDG_WM_DIALOG_VERSION));
|
||||
}
|
||||
else if (strcmp (interface, "gtk_shell1") == 0)
|
||||
{
|
||||
display_wayland->gtk_shell =
|
||||
@@ -751,7 +832,9 @@ gdk_wayland_display_dispose (GObject *object)
|
||||
g_clear_pointer (&display_wayland->presentation, wp_presentation_destroy);
|
||||
g_clear_pointer (&display_wayland->single_pixel_buffer, wp_single_pixel_buffer_manager_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->linux_dmabuf, zwp_linux_dmabuf_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->dmabuf_formats_info, dmabuf_formats_info_free);
|
||||
g_clear_pointer (&display_wayland->linux_dmabuf_feedback, zwp_linux_dmabuf_feedback_v1_destroy);
|
||||
if (display_wayland->linux_dmabuf_formats)
|
||||
munmap (display_wayland->linux_dmabuf_formats, display_wayland->linux_dmabuf_n_formats * 16);
|
||||
|
||||
g_clear_pointer (&display_wayland->shm, wl_shm_destroy);
|
||||
g_clear_pointer (&display_wayland->wl_registry, wl_registry_destroy);
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#include <gdk/wayland/viewporter-client-protocol.h>
|
||||
#include <gdk/wayland/presentation-time-client-protocol.h>
|
||||
#include <gdk/wayland/single-pixel-buffer-v1-client-protocol.h>
|
||||
#include <gdk/wayland/xdg-dialog-v1-client-protocol.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <gdk/gdkkeys.h>
|
||||
@@ -50,7 +49,6 @@
|
||||
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkwaylanddevice.h"
|
||||
#include "gdkdmabuf-wayland-private.h"
|
||||
#include "cursor/wayland-cursor.h"
|
||||
|
||||
#include <epoxy/egl.h>
|
||||
@@ -75,6 +73,13 @@ typedef enum _GdkWaylandShellVariant
|
||||
GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6
|
||||
} GdkWaylandShellVariant;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t fourcc;
|
||||
uint32_t padding;
|
||||
uint64_t modifier;
|
||||
} LinuxDmabufFormat;
|
||||
|
||||
struct _GdkWaylandDisplay
|
||||
{
|
||||
GdkDisplay parent_instance;
|
||||
@@ -100,10 +105,11 @@ struct _GdkWaylandDisplay
|
||||
struct wl_compositor *compositor;
|
||||
struct wl_shm *shm;
|
||||
struct zwp_linux_dmabuf_v1 *linux_dmabuf;
|
||||
DmabufFormatsInfo *dmabuf_formats_info;
|
||||
struct zwp_linux_dmabuf_feedback_v1 *linux_dmabuf_feedback;
|
||||
gsize linux_dmabuf_n_formats;
|
||||
LinuxDmabufFormat *linux_dmabuf_formats;
|
||||
struct xdg_wm_base *xdg_wm_base;
|
||||
struct zxdg_shell_v6 *zxdg_shell_v6;
|
||||
struct xdg_wm_dialog_v1 *xdg_wm_dialog;
|
||||
struct gtk_shell1 *gtk_shell;
|
||||
struct wl_data_device_manager *data_device_manager;
|
||||
struct wl_subcompositor *subcompositor;
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -1,241 +0,0 @@
|
||||
#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);
|
||||
}
|
||||
@@ -37,7 +37,6 @@
|
||||
#include <wayland/presentation-time-client-protocol.h>
|
||||
#include <wayland/xdg-shell-unstable-v6-client-protocol.h>
|
||||
#include <wayland/xdg-foreign-unstable-v2-client-protocol.h>
|
||||
#include <wayland/xdg-dialog-v1-client-protocol.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -85,7 +84,6 @@ struct _GdkWaylandToplevel
|
||||
struct gtk_surface1 *gtk_surface;
|
||||
struct xdg_toplevel *xdg_toplevel;
|
||||
struct zxdg_toplevel_v6 *zxdg_toplevel_v6;
|
||||
struct xdg_dialog_v1 *xdg_dialog;
|
||||
} display_server;
|
||||
|
||||
GdkWaylandToplevel *transient_for;
|
||||
@@ -207,7 +205,6 @@ gdk_wayland_toplevel_clear_saved_size (GdkWaylandToplevel *toplevel)
|
||||
|
||||
static void maybe_set_gtk_surface_dbus_properties (GdkWaylandToplevel *wayland_toplevel);
|
||||
static void maybe_set_gtk_surface_modal (GdkWaylandToplevel *wayland_toplevel);
|
||||
static gboolean maybe_set_xdg_dialog_modal (GdkWaylandToplevel *wayland_toplevel);
|
||||
|
||||
static void
|
||||
gdk_wayland_toplevel_hide_surface (GdkWaylandSurface *wayland_surface)
|
||||
@@ -218,7 +215,6 @@ gdk_wayland_toplevel_hide_surface (GdkWaylandSurface *wayland_surface)
|
||||
|
||||
g_clear_pointer (&toplevel->display_server.xdg_toplevel, xdg_toplevel_destroy);
|
||||
g_clear_pointer (&toplevel->display_server.zxdg_toplevel_v6, zxdg_toplevel_v6_destroy);
|
||||
g_clear_pointer (&toplevel->display_server.xdg_dialog, xdg_dialog_v1_destroy);
|
||||
|
||||
if (toplevel->display_server.gtk_surface)
|
||||
{
|
||||
@@ -881,8 +877,7 @@ gdk_wayland_surface_create_xdg_toplevel (GdkWaylandToplevel *wayland_toplevel)
|
||||
gdk_wayland_toplevel_set_application_id (GDK_TOPLEVEL (wayland_toplevel), app_id);
|
||||
|
||||
maybe_set_gtk_surface_dbus_properties (wayland_toplevel);
|
||||
if (!maybe_set_xdg_dialog_modal (wayland_toplevel))
|
||||
maybe_set_gtk_surface_modal (wayland_toplevel);
|
||||
maybe_set_gtk_surface_modal (wayland_toplevel);
|
||||
|
||||
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "Wayland surface commit", NULL);
|
||||
wl_surface_commit (wayland_surface->display_server.wl_surface);
|
||||
@@ -1094,40 +1089,12 @@ maybe_set_gtk_surface_modal (GdkWaylandToplevel *wayland_toplevel)
|
||||
|
||||
}
|
||||
|
||||
static gboolean
|
||||
maybe_set_xdg_dialog_modal (GdkWaylandToplevel *wayland_toplevel)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland =
|
||||
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SURFACE (wayland_toplevel)));
|
||||
|
||||
if (!display_wayland->xdg_wm_dialog)
|
||||
return FALSE;
|
||||
if (!is_realized_toplevel (GDK_WAYLAND_SURFACE (wayland_toplevel)))
|
||||
return FALSE;
|
||||
|
||||
if (!wayland_toplevel->display_server.xdg_dialog)
|
||||
{
|
||||
wayland_toplevel->display_server.xdg_dialog =
|
||||
xdg_wm_dialog_v1_get_xdg_dialog (display_wayland->xdg_wm_dialog,
|
||||
wayland_toplevel->display_server.xdg_toplevel);
|
||||
}
|
||||
|
||||
if (GDK_SURFACE (wayland_toplevel)->modal_hint)
|
||||
xdg_dialog_v1_set_modal (wayland_toplevel->display_server.xdg_dialog);
|
||||
else
|
||||
xdg_dialog_v1_unset_modal (wayland_toplevel->display_server.xdg_dialog);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_toplevel_set_modal_hint (GdkWaylandToplevel *wayland_toplevel,
|
||||
gboolean modal)
|
||||
{
|
||||
GDK_SURFACE (wayland_toplevel)->modal_hint = modal;
|
||||
|
||||
if (!maybe_set_xdg_dialog_modal (wayland_toplevel))
|
||||
maybe_set_gtk_surface_modal (wayland_toplevel);
|
||||
maybe_set_gtk_surface_modal (wayland_toplevel);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+24
-122
@@ -8,7 +8,6 @@ gdk_wayland_sources = files([
|
||||
'gdkdevice-wayland.c',
|
||||
'gdkdevicepad-wayland.c',
|
||||
'gdkdisplay-wayland.c',
|
||||
'gdkdmabuf-wayland.c',
|
||||
'gdkdrag-wayland.c',
|
||||
'gdkdragsurface-wayland.c',
|
||||
'gdkdrop-wayland.c',
|
||||
@@ -48,133 +47,36 @@ gdk_wayland_deps = [
|
||||
wlegldep,
|
||||
]
|
||||
|
||||
# Fields:
|
||||
# - name: protocol name
|
||||
# - stability: protocol stability ('private', 'stable' or 'unstable')
|
||||
# - version: protocol version
|
||||
# - required: wayland_protocols version check
|
||||
wlmod = import('unstable-wayland')
|
||||
proto_sources = [
|
||||
{
|
||||
'name': 'gtk-shell',
|
||||
'stability': 'private',
|
||||
},
|
||||
{
|
||||
'name': 'primary-selection',
|
||||
'stability': 'unstable',
|
||||
'version': 1,
|
||||
},
|
||||
{
|
||||
'name': 'pointer-gestures',
|
||||
'stability': 'unstable',
|
||||
'version': 1,
|
||||
},
|
||||
{
|
||||
'name': 'viewporter',
|
||||
'stability': 'stable',
|
||||
},
|
||||
{
|
||||
'name': 'xdg-shell',
|
||||
'stability': 'unstable',
|
||||
'version': 6,
|
||||
},
|
||||
{
|
||||
'name': 'xdg-shell',
|
||||
'stability': 'stable',
|
||||
},
|
||||
{
|
||||
'name': 'xdg-foreign',
|
||||
'stability': 'unstable',
|
||||
'version': 1,
|
||||
},
|
||||
{
|
||||
'name': 'xdg-foreign',
|
||||
'stability': 'unstable',
|
||||
'version': 2,
|
||||
},
|
||||
{
|
||||
'name': 'tablet',
|
||||
'stability': 'unstable',
|
||||
'version': 2,
|
||||
},
|
||||
{
|
||||
'name': 'keyboard-shortcuts-inhibit',
|
||||
'stability': 'unstable',
|
||||
'version': 1,
|
||||
},
|
||||
{
|
||||
'name': 'server-decoration',
|
||||
'stability': 'private',
|
||||
},
|
||||
{
|
||||
'name': 'xdg-output',
|
||||
'stability': 'unstable',
|
||||
'version': 1,
|
||||
},
|
||||
{
|
||||
'name': 'idle-inhibit',
|
||||
'stability': 'unstable',
|
||||
'version': 1,
|
||||
},
|
||||
{
|
||||
'name': 'xdg-activation',
|
||||
'stability': 'staging',
|
||||
'version': 1,
|
||||
},
|
||||
{
|
||||
'name': 'fractional-scale',
|
||||
'stability': 'staging',
|
||||
'version': 1,
|
||||
},
|
||||
{
|
||||
'name': 'linux-dmabuf',
|
||||
'stability': 'unstable',
|
||||
'version': 1,
|
||||
},
|
||||
{
|
||||
'name': 'presentation-time',
|
||||
'stability': 'stable',
|
||||
'version': 1,
|
||||
},
|
||||
{
|
||||
'name': 'single-pixel-buffer',
|
||||
'stability': 'staging',
|
||||
'version': 1,
|
||||
},
|
||||
{
|
||||
'name': 'xdg-dialog',
|
||||
'stability': 'staging',
|
||||
'version': 1,
|
||||
},
|
||||
'protocol/gtk-shell.xml',
|
||||
'protocol/server-decoration.xml',
|
||||
wlmod.find_protocol('primary-selection', state: 'unstable', version: 1),
|
||||
wlmod.find_protocol('pointer-gestures', state: 'unstable', version: 1),
|
||||
wlmod.find_protocol('viewporter', state: 'stable'),
|
||||
wlmod.find_protocol('xdg-shell', state: 'unstable', version: 6),
|
||||
wlmod.find_protocol('xdg-shell', state: 'stable'),
|
||||
wlmod.find_protocol('xdg-foreign', state: 'unstable', version: 1),
|
||||
wlmod.find_protocol('xdg-foreign', state: 'unstable', version: 2),
|
||||
wlmod.find_protocol('tablet', state: 'unstable', version: 2),
|
||||
wlmod.find_protocol('keyboard-shortcuts-inhibit', state: 'unstable', version: 1),
|
||||
wlmod.find_protocol('xdg-output', state: 'unstable', version: 1),
|
||||
wlmod.find_protocol('idle-inhibit', state: 'unstable', version: 1),
|
||||
wlmod.find_protocol('xdg-activation', state: 'staging', version: 1),
|
||||
wlmod.find_protocol('fractional-scale', state: 'staging', version: 1),
|
||||
wlmod.find_protocol('linux-dmabuf', state: 'unstable', version: 1),
|
||||
wlmod.find_protocol('presentation-time', state: 'stable'),
|
||||
wlmod.find_protocol('single-pixel-buffer', state: 'staging', version: 1),
|
||||
]
|
||||
|
||||
gdk_wayland_gen_headers = []
|
||||
|
||||
wlmod = import('unstable-wayland')
|
||||
foreach p: proto_sources
|
||||
if wlprotocolsdep.version().version_compare(p.get('required', '>=0'))
|
||||
if p.get('stability') == 'private'
|
||||
if (p.has_key('version'))
|
||||
proto_file = 'protocol/@0@-v@1@.xml'.format(p.get('name'), p.get('version'))
|
||||
else
|
||||
proto_file = 'protocol/@0@.xml'.format(p.get('name'))
|
||||
endif
|
||||
elif p.get('stability') == 'stable'
|
||||
proto_file = wlmod.find_protocol(p.get('name'),
|
||||
state: p.get('stability'),
|
||||
)
|
||||
else
|
||||
proto_file = wlmod.find_protocol(p.get('name'),
|
||||
state: p.get('stability'),
|
||||
version: p.get('version'),
|
||||
)
|
||||
endif
|
||||
|
||||
# Returns a list [.c, .h]
|
||||
gen = wlmod.scan_xml(proto_file)
|
||||
assert(gen.length() == 2)
|
||||
gdk_wayland_sources += gen[0]
|
||||
gdk_wayland_gen_headers += gen[1]
|
||||
endif
|
||||
# Returns a list [.c, .h]
|
||||
gen = wlmod.scan_xml(p)
|
||||
assert(gen.length() == 2)
|
||||
gdk_wayland_sources += gen[0]
|
||||
gdk_wayland_gen_headers += gen[1]
|
||||
endforeach
|
||||
|
||||
libgdk_wayland = static_library('gdk-wayland',
|
||||
|
||||
@@ -1408,7 +1408,7 @@ register_clipboard_notification ()
|
||||
WNDCLASS wclass = { 0, };
|
||||
ATOM klass;
|
||||
|
||||
wclass.lpszClassName = L"GdkClipboardNotification";
|
||||
wclass.lpszClassName = "GdkClipboardNotification";
|
||||
wclass.lpfnWndProc = _clipboard_window_procedure;
|
||||
wclass.hInstance = this_module ();
|
||||
wclass.cbWndExtra = sizeof (GdkWin32ClipboardThread *);
|
||||
@@ -1506,9 +1506,9 @@ gdk_win32_clipdrop_init (GdkWin32Clipdrop *win32_clipdrop)
|
||||
GdkWin32ContentFormatPair fmt;
|
||||
HMODULE user32;
|
||||
|
||||
thread_wakeup_message = RegisterWindowMessage (L"GDK_WORKER_THREAD_WEAKEUP");
|
||||
thread_wakeup_message = RegisterWindowMessage ("GDK_WORKER_THREAD_WEAKEUP");
|
||||
|
||||
user32 = LoadLibrary (L"user32.dll");
|
||||
user32 = LoadLibrary ("user32.dll");
|
||||
win32_clipdrop->GetUpdatedClipboardFormats = (GetUpdatedClipboardFormatsFunc) GetProcAddress (user32, "GetUpdatedClipboardFormats");
|
||||
FreeLibrary (user32);
|
||||
|
||||
@@ -1557,21 +1557,21 @@ gdk_win32_clipdrop_init (GdkWin32Clipdrop *win32_clipdrop)
|
||||
* the lead and map the GDK contentformat "image/png" to the clipboard
|
||||
* format name "PNG" etc.
|
||||
*/
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_PNG) = RegisterClipboardFormat (L"PNG");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_JFIF) = RegisterClipboardFormat (L"JFIF");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_GIF) = RegisterClipboardFormat (L"GIF");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_PNG) = RegisterClipboardFormatA ("PNG");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_JFIF) = RegisterClipboardFormatA ("JFIF");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_GIF) = RegisterClipboardFormatA ("GIF");
|
||||
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_UNIFORMRESOURCELOCATORW) = RegisterClipboardFormat (L"UniformResourceLocatorW");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_CFSTR_SHELLIDLIST) = RegisterClipboardFormat (CFSTR_SHELLIDLIST);
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_HTML_FORMAT) = RegisterClipboardFormat (L"HTML Format");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_TEXT_HTML) = RegisterClipboardFormat (L"text/html");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_UNIFORMRESOURCELOCATORW) = RegisterClipboardFormatA ("UniformResourceLocatorW");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_CFSTR_SHELLIDLIST) = RegisterClipboardFormatA (CFSTR_SHELLIDLIST);
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_HTML_FORMAT) = RegisterClipboardFormatA ("HTML Format");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_TEXT_HTML) = RegisterClipboardFormatA ("text/html");
|
||||
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_PNG) = RegisterClipboardFormat (L"image/png");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_JPEG) = RegisterClipboardFormat (L"image/jpeg");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_BMP) = RegisterClipboardFormat (L"image/bmp");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_GIF) = RegisterClipboardFormat (L"image/gif");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_TEXT_URI_LIST) = RegisterClipboardFormat (L"text/uri-list");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_TEXT_PLAIN_UTF8) = RegisterClipboardFormat (L"text/plain;charset=utf-8");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_PNG) = RegisterClipboardFormatA ("image/png");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_JPEG) = RegisterClipboardFormatA ("image/jpeg");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_BMP) = RegisterClipboardFormatA ("image/bmp");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_IMAGE_GIF) = RegisterClipboardFormatA ("image/gif");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_TEXT_URI_LIST) = RegisterClipboardFormatA ("text/uri-list");
|
||||
_gdk_cf_array_index (cfs, GDK_WIN32_CF_INDEX_TEXT_PLAIN_UTF8) = RegisterClipboardFormatA ("text/plain;charset=utf-8");
|
||||
|
||||
win32_clipdrop->active_source_drags = g_hash_table_new_full (NULL, NULL, (GDestroyNotify) g_object_unref, NULL);
|
||||
|
||||
@@ -2364,9 +2364,9 @@ transmute_cf_dib_to_image_bmp (const guchar *data,
|
||||
* check?
|
||||
*/
|
||||
(IsClipboardFormatAvailable
|
||||
(RegisterClipboardFormat (L"application/x-moz-nativeimage")) ||
|
||||
(RegisterClipboardFormatA ("application/x-moz-nativeimage")) ||
|
||||
IsClipboardFormatAvailable
|
||||
(RegisterClipboardFormat (L"UniformResourceLocatorW"))) &&
|
||||
(RegisterClipboardFormatA ("UniformResourceLocatorW"))) &&
|
||||
#endif
|
||||
TRUE)
|
||||
{
|
||||
|
||||
+35
-38
@@ -31,13 +31,12 @@
|
||||
|
||||
static struct {
|
||||
char *name;
|
||||
const wchar_t *id;
|
||||
char *id;
|
||||
} default_cursors[] = {
|
||||
/* -- Win32 cursor names: -- */
|
||||
{ "appstarting", IDC_APPSTARTING },
|
||||
{ "arrow", IDC_ARROW },
|
||||
{ "cross", IDC_CROSS },
|
||||
{ "dnd-move", IDC_ARROW },
|
||||
{ "hand", IDC_HAND },
|
||||
{ "help", IDC_HELP },
|
||||
{ "ibeam", IDC_IBEAM },
|
||||
@@ -457,32 +456,32 @@ win32_cursor_create_win32hcursor (GdkWin32Display *display,
|
||||
break;
|
||||
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_NULL:
|
||||
result = gdk_win32_hcursor_new (display,
|
||||
LoadImage (NULL,
|
||||
cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
cursor->height,
|
||||
cursor->load_flags),
|
||||
LoadImageA (NULL,
|
||||
(const char *) cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
cursor->height,
|
||||
cursor->load_flags),
|
||||
cursor->load_flags & LR_SHARED ? FALSE : TRUE);
|
||||
break;
|
||||
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_THIS:
|
||||
result = gdk_win32_hcursor_new (display,
|
||||
LoadImage (GetModuleHandle (NULL),
|
||||
cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
cursor->height,
|
||||
cursor->load_flags),
|
||||
LoadImageA (GetModuleHandle (NULL),
|
||||
(const char *) cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
cursor->height,
|
||||
cursor->load_flags),
|
||||
cursor->load_flags & LR_SHARED ? FALSE : TRUE);
|
||||
break;
|
||||
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_GTK:
|
||||
result = gdk_win32_hcursor_new (display,
|
||||
LoadImage (this_module (),
|
||||
cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
cursor->height,
|
||||
cursor->load_flags),
|
||||
LoadImageA (this_module (),
|
||||
(const char *) cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
cursor->height,
|
||||
cursor->load_flags),
|
||||
cursor->load_flags & LR_SHARED ? FALSE : TRUE);
|
||||
break;
|
||||
case GDK_WIN32_CURSOR_CREATE:
|
||||
@@ -499,12 +498,12 @@ win32_cursor_create_win32hcursor (GdkWin32Display *display,
|
||||
}
|
||||
|
||||
static Win32Cursor *
|
||||
win32_cursor_new (GdkWin32CursorLoadType load_type,
|
||||
wchar_t *resource_name,
|
||||
int width,
|
||||
int height,
|
||||
guint load_flags,
|
||||
int xcursor_number)
|
||||
win32_cursor_new (GdkWin32CursorLoadType load_type,
|
||||
gpointer resource_name,
|
||||
int width,
|
||||
int height,
|
||||
guint load_flags,
|
||||
int xcursor_number)
|
||||
{
|
||||
Win32Cursor *result;
|
||||
|
||||
@@ -632,9 +631,9 @@ win32_cursor_theme_load_system (Win32CursorTheme *theme,
|
||||
|
||||
/* Prefer W32 cursors */
|
||||
if (cursors[i].builtin)
|
||||
shared_hcursor = LoadImage (NULL, cursors[i].builtin, IMAGE_CURSOR,
|
||||
size, size,
|
||||
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0));
|
||||
shared_hcursor = LoadImageA (NULL, cursors[i].builtin, IMAGE_CURSOR,
|
||||
size, size,
|
||||
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0));
|
||||
|
||||
/* Fall back to X cursors, but only if we've got no theme cursor */
|
||||
if (shared_hcursor == NULL && g_hash_table_lookup (theme->named_cursors, cursors[i].name) == NULL)
|
||||
@@ -646,7 +645,7 @@ win32_cursor_theme_load_system (Win32CursorTheme *theme,
|
||||
DestroyCursor (x_hcursor);
|
||||
|
||||
cursor = win32_cursor_new (shared_hcursor ? GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_NULL : GDK_WIN32_CURSOR_CREATE,
|
||||
(wchar_t*) cursors[i].builtin,
|
||||
(gpointer) cursors[i].builtin,
|
||||
size,
|
||||
size,
|
||||
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0),
|
||||
@@ -661,14 +660,14 @@ win32_cursor_theme_load_system (Win32CursorTheme *theme,
|
||||
if (default_cursors[i].name == NULL)
|
||||
break;
|
||||
|
||||
shared_hcursor = LoadImage (NULL, default_cursors[i].id, IMAGE_CURSOR, size, size,
|
||||
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0));
|
||||
shared_hcursor = LoadImageA (NULL, default_cursors[i].id, IMAGE_CURSOR, size, size,
|
||||
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0));
|
||||
|
||||
if (shared_hcursor == NULL)
|
||||
continue;
|
||||
|
||||
cursor = win32_cursor_new (GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_NULL,
|
||||
(wchar_t*) default_cursors[i].id,
|
||||
(gpointer) default_cursors[i].id,
|
||||
size,
|
||||
size,
|
||||
LR_SHARED | (size == 0 ? LR_DEFAULTSIZE : 0),
|
||||
@@ -780,8 +779,8 @@ win32hcursor_idc_from_name (GdkWin32Display *display,
|
||||
continue;
|
||||
|
||||
return gdk_win32_hcursor_new (display,
|
||||
LoadImage (NULL, default_cursors[i].id, IMAGE_CURSOR, 0, 0,
|
||||
LR_SHARED | LR_DEFAULTSIZE),
|
||||
LoadImageA (NULL, default_cursors[i].id, IMAGE_CURSOR, 0, 0,
|
||||
LR_SHARED | LR_DEFAULTSIZE),
|
||||
FALSE);
|
||||
}
|
||||
|
||||
@@ -885,7 +884,7 @@ gdk_win32hcursor_create_for_name (GdkWin32Display *display,
|
||||
/* Allow to load named cursor resources linked into the executable.
|
||||
* Cursors obtained with LoadCursor() cannot be destroyed.
|
||||
*/
|
||||
return gdk_win32_hcursor_new (display, LoadCursorA (hinstance, name), FALSE);
|
||||
return gdk_win32_hcursor_new (display, LoadCursor (hinstance, name), FALSE);
|
||||
}
|
||||
|
||||
static HICON
|
||||
@@ -909,9 +908,7 @@ _gdk_win32_create_hicon_for_texture (GdkTexture *texture,
|
||||
width = cairo_image_surface_get_width (surface);
|
||||
height = cairo_image_surface_get_height (surface);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
icon = pixbuf_to_hicon (pixbuf, is_icon, x, y);
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ gdk_device_manager_win32_finalize (GObject *object)
|
||||
#if DEBUG_WINTAB
|
||||
|
||||
static void
|
||||
print_lc(LOGCONTEXTA *lc)
|
||||
print_lc(LOGCONTEXT *lc)
|
||||
{
|
||||
g_print ("lcName = %s\n", lc->lcName);
|
||||
g_print ("lcOptions =");
|
||||
@@ -374,13 +374,13 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
|
||||
|
||||
wintab_contexts = NULL;
|
||||
|
||||
n = GetSystemDirectoryA (&dummy, 0);
|
||||
n = GetSystemDirectory (&dummy, 0);
|
||||
|
||||
if (n <= 0)
|
||||
return;
|
||||
|
||||
wintab32_dll_path = g_malloc (n + 1 + strlen (WINTAB32_DLL));
|
||||
k = GetSystemDirectoryA (wintab32_dll_path, n);
|
||||
k = GetSystemDirectory (wintab32_dll_path, n);
|
||||
|
||||
if (k == 0 || k > n)
|
||||
{
|
||||
@@ -392,7 +392,7 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
|
||||
strcat (wintab32_dll_path, G_DIR_SEPARATOR_S);
|
||||
strcat (wintab32_dll_path, WINTAB32_DLL);
|
||||
|
||||
if ((wintab32 = LoadLibraryA (wintab32_dll_path)) == NULL)
|
||||
if ((wintab32 = LoadLibrary (wintab32_dll_path)) == NULL)
|
||||
return;
|
||||
|
||||
if ((p_WTInfoA = (t_WTInfoA) GetProcAddress (wintab32, "WTInfoA")) == NULL)
|
||||
@@ -433,7 +433,7 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
|
||||
|
||||
for (devix = 0; devix < ndevices; devix++)
|
||||
{
|
||||
LOGCONTEXTA lc;
|
||||
LOGCONTEXT lc;
|
||||
|
||||
/* We open the Wintab device (hmm, what if there are several, or
|
||||
* can there even be several, probably not?) as a system
|
||||
|
||||
@@ -480,7 +480,7 @@ register_display_change_notification (GdkDisplay *display)
|
||||
WNDCLASS wclass = { 0, };
|
||||
ATOM klass;
|
||||
|
||||
wclass.lpszClassName = L"GdkDisplayChange";
|
||||
wclass.lpszClassName = "GdkDisplayChange";
|
||||
wclass.lpfnWndProc = display_change_window_procedure;
|
||||
wclass.hInstance = this_module ();
|
||||
wclass.style = CS_OWNDC;
|
||||
@@ -606,7 +606,7 @@ gdk_win32_display_get_name (GdkDisplay *display)
|
||||
window_station_name = "WinSta0";
|
||||
}
|
||||
|
||||
processIdToSessionId = (PFN_ProcessIdToSessionId) GetProcAddress (GetModuleHandle (L"kernel32.dll"), "ProcessIdToSessionId");
|
||||
processIdToSessionId = (PFN_ProcessIdToSessionId) GetProcAddress (GetModuleHandle ("kernel32.dll"), "ProcessIdToSessionId");
|
||||
if (!processIdToSessionId || !processIdToSessionId (GetCurrentProcessId (), &session_id))
|
||||
session_id = 0;
|
||||
|
||||
|
||||
@@ -134,7 +134,6 @@ struct _GdkWin32Display
|
||||
guint hasWglEXTSwapControl : 1;
|
||||
guint hasWglOMLSyncControl : 1;
|
||||
guint hasWglARBPixelFormat : 1;
|
||||
guint force_enable_depth_bits : 1;
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
guint hasEglKHRCreateContext : 1;
|
||||
|
||||
@@ -658,7 +658,7 @@ _gdk_win32_dnd_thread_main (gpointer data)
|
||||
/* Create a message queue */
|
||||
PeekMessage (&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
|
||||
|
||||
thread_wakeup_message = RegisterWindowMessage (L"GDK_WORKER_THREAD_WEAKEUP");
|
||||
thread_wakeup_message = RegisterWindowMessage ("GDK_WORKER_THREAD_WEAKEUP");
|
||||
|
||||
/* Signal the main thread that we're ready.
|
||||
* This is the only time the queue works in reverse.
|
||||
|
||||
@@ -419,7 +419,7 @@ set_up_low_level_keyboard_hook (void)
|
||||
else
|
||||
WIN32_API_FAILED ("SetWindowsHookEx");
|
||||
|
||||
aerosnap_message = RegisterWindowMessage (L"GDK_WIN32_AEROSNAP_MESSAGE");
|
||||
aerosnap_message = RegisterWindowMessage ("GDK_WIN32_AEROSNAP_MESSAGE");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -470,7 +470,7 @@ _gdk_events_init (GdkDisplay *display)
|
||||
};
|
||||
#endif
|
||||
|
||||
got_gdk_events_message = RegisterWindowMessage (L"GDK_WIN32_GOT_EVENTS");
|
||||
got_gdk_events_message = RegisterWindowMessage ("GDK_WIN32_GOT_EVENTS");
|
||||
|
||||
#if 0
|
||||
/* Check if we have some input locale identifier loaded that uses a
|
||||
@@ -1685,7 +1685,7 @@ _gdk_win32_surface_fill_min_max_info (GdkSurface *window,
|
||||
nearest_monitor = MonitorFromWindow (GDK_SURFACE_HWND (window), MONITOR_DEFAULTTONEAREST);
|
||||
nearest_info.cbSize = sizeof (nearest_info);
|
||||
|
||||
if (GetMonitorInfo (nearest_monitor, &nearest_info))
|
||||
if (GetMonitorInfoA (nearest_monitor, &nearest_info))
|
||||
{
|
||||
/* MSDN says that we must specify maximized window
|
||||
* size as if it was located on the primary monitor.
|
||||
|
||||
@@ -142,7 +142,8 @@ get_wgl_pfd (HDC hdc,
|
||||
|
||||
pfd->nSize = sizeof (PIXELFORMATDESCRIPTOR);
|
||||
|
||||
if (display_win32->hasWglARBPixelFormat)
|
||||
if (display_win32 != NULL &&
|
||||
display_win32->hasWglARBPixelFormat)
|
||||
{
|
||||
UINT num_formats;
|
||||
int colorbits = GetDeviceCaps (hdc, BITSPIXEL);
|
||||
@@ -175,18 +176,15 @@ get_wgl_pfd (HDC hdc,
|
||||
pixelAttribs[i++] = WGL_ALPHA_BITS_ARB;
|
||||
pixelAttribs[i++] = 8;
|
||||
|
||||
pixelAttribs[i++] = WGL_DEPTH_BITS_ARB;
|
||||
pixelAttribs[i++] = 0;
|
||||
|
||||
pixelAttribs[i++] = WGL_STENCIL_BITS_ARB;
|
||||
pixelAttribs[i++] = 0;
|
||||
|
||||
pixelAttribs[i++] = WGL_ACCUM_BITS_ARB;
|
||||
pixelAttribs[i++] = 0;
|
||||
|
||||
if (!display_win32->force_enable_depth_bits)
|
||||
{
|
||||
pixelAttribs[i++] = WGL_DEPTH_BITS_ARB;
|
||||
pixelAttribs[i++] = 0;
|
||||
}
|
||||
|
||||
/* end of "Update PIXEL_ATTRIBUTES above if any groups are added here!" */
|
||||
|
||||
pixelAttribs[i++] = 0; /* end of pixelAttribs */
|
||||
@@ -217,20 +215,8 @@ get_wgl_pfd (HDC hdc,
|
||||
pfd->cColorBits = GetDeviceCaps (hdc, BITSPIXEL);
|
||||
pfd->cAlphaBits = 8;
|
||||
pfd->iLayerType = PFD_MAIN_PLANE;
|
||||
pfd->cAccumBits = 0;
|
||||
pfd->cStencilBits = 0;
|
||||
|
||||
if (!display_win32->force_enable_depth_bits)
|
||||
pfd->cDepthBits = 0;
|
||||
|
||||
best_pf = ChoosePixelFormat (hdc, pfd);
|
||||
|
||||
/* try again if driver enforces depth buffers */
|
||||
if (best_pf == 0 && !display_win32->force_enable_depth_bits)
|
||||
{
|
||||
display_win32->force_enable_depth_bits = TRUE;
|
||||
get_wgl_pfd (hdc, pfd, display_win32);
|
||||
}
|
||||
}
|
||||
|
||||
return best_pf;
|
||||
@@ -248,7 +234,7 @@ gdk_init_dummy_wgl_context (GdkWin32Display *display_win32)
|
||||
|
||||
memset (&pfd, 0, sizeof (PIXELFORMATDESCRIPTOR));
|
||||
|
||||
best_idx = get_wgl_pfd (display_win32->dummy_context_wgl.hdc, &pfd, display_win32);
|
||||
best_idx = get_wgl_pfd (display_win32->dummy_context_wgl.hdc, &pfd, NULL);
|
||||
|
||||
if (best_idx != 0)
|
||||
set_pixel_format_result = SetPixelFormat (display_win32->dummy_context_wgl.hdc,
|
||||
@@ -281,9 +267,9 @@ create_dummy_gl_window (void)
|
||||
{
|
||||
WNDCLASS wclass = { 0, };
|
||||
ATOM klass;
|
||||
HWND hwnd = NULL;
|
||||
HWND hwnd;
|
||||
|
||||
wclass.lpszClassName = L"GdkGLDummyWindow";
|
||||
wclass.lpszClassName = "GdkGLDummyWindow";
|
||||
wclass.lpfnWndProc = DefWindowProc;
|
||||
wclass.hInstance = this_module ();
|
||||
wclass.style = CS_OWNDC;
|
||||
|
||||
@@ -730,7 +730,7 @@ _gdk_win32_key_to_string (LONG lParam)
|
||||
char buf[100];
|
||||
char *keyname_utf8;
|
||||
|
||||
if (GetKeyNameTextA (lParam, buf, sizeof (buf)) &&
|
||||
if (GetKeyNameText (lParam, buf, sizeof (buf)) &&
|
||||
(keyname_utf8 = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL)) != NULL)
|
||||
{
|
||||
char *retval = static_printf ("%s", keyname_utf8);
|
||||
@@ -780,7 +780,7 @@ _gdk_win32_cf_to_string (UINT format)
|
||||
if (format >= CF_PRIVATEFIRST &&
|
||||
format <= CF_PRIVATELAST)
|
||||
return static_printf ("CF_PRIVATE%d", format - CF_PRIVATEFIRST);
|
||||
if (GetClipboardFormatNameA (format, buf, sizeof (buf)))
|
||||
if (GetClipboardFormatName (format, buf, sizeof (buf)))
|
||||
return static_printf ("'%s'", buf);
|
||||
else
|
||||
return static_printf ("unk-%#lx", format);
|
||||
|
||||
@@ -197,7 +197,7 @@ typedef struct _Win32Cursor Win32Cursor;
|
||||
|
||||
struct _Win32Cursor {
|
||||
GdkWin32CursorLoadType load_type;
|
||||
wchar_t *resource_name;
|
||||
gunichar2 *resource_name;
|
||||
int width;
|
||||
int height;
|
||||
guint load_flags;
|
||||
|
||||
@@ -326,7 +326,7 @@ RegisterGdkClass (GType wtype)
|
||||
static WNDCLASSEXW wcl;
|
||||
ATOM klass = 0;
|
||||
|
||||
wcl.cbSize = sizeof (WNDCLASSEXW);
|
||||
wcl.cbSize = sizeof (WNDCLASSEX);
|
||||
wcl.style = 0; /* DON'T set CS_<H,V>REDRAW. It causes total redraw
|
||||
* on WM_SIZE and WM_MOVE. Flicker, Performance!
|
||||
*/
|
||||
@@ -340,7 +340,7 @@ RegisterGdkClass (GType wtype)
|
||||
/* initialize once! */
|
||||
if (0 == hAppIcon && 0 == hAppIconSm)
|
||||
{
|
||||
wchar_t sLoc [MAX_PATH+1];
|
||||
char sLoc [MAX_PATH+1];
|
||||
|
||||
// try to load first icon of executable program
|
||||
if (0 != GetModuleFileName (NULL, sLoc, MAX_PATH))
|
||||
@@ -2064,7 +2064,7 @@ stash_window (GdkSurface *window,
|
||||
hmonitor = MonitorFromWindow (GDK_SURFACE_HWND (window), MONITOR_DEFAULTTONEAREST);
|
||||
hmonitor_info.cbSize = sizeof (hmonitor_info);
|
||||
|
||||
if (!GetMonitorInfo (hmonitor, &hmonitor_info))
|
||||
if (!GetMonitorInfoA (hmonitor, &hmonitor_info))
|
||||
return;
|
||||
|
||||
if (impl->snap_stash == NULL)
|
||||
|
||||
@@ -38,6 +38,7 @@ gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context,
|
||||
{
|
||||
GdkSurface *window = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
|
||||
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
|
||||
GdkWin32Surface *win32_surface = GDK_WIN32_SURFACE (window);
|
||||
VkWin32SurfaceCreateInfoKHR info;
|
||||
VkResult result;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
static const struct { const char *name; const wchar_t *builtin; int type; guchar width; guchar height; guchar hotx; guchar hoty; char *data; } cursors[] = {
|
||||
static const struct { const char *name; const char *builtin; int type; guchar width; guchar height; guchar hotx; guchar hoty; char *data; } cursors[] = {
|
||||
{ "X_cursor", NULL, 0, 16, 16, 7, 7,
|
||||
"\125\000\000\125\152\100\001\251\152\220\006\251\152\244\032\251"
|
||||
"\032\251\152\244\006\252\252\220\001\252\252\100\000\152\251\000"
|
||||
|
||||
@@ -1776,6 +1776,11 @@ _gdk_x11_display_is_root_window (GdkDisplay *display,
|
||||
return GDK_SCREEN_XROOTWIN (display_x11->screen) == xroot_window;
|
||||
}
|
||||
|
||||
struct XPointerUngrabInfo {
|
||||
GdkDisplay *display;
|
||||
guint32 time;
|
||||
};
|
||||
|
||||
static void
|
||||
device_grab_update_callback (GdkDisplay *display,
|
||||
gpointer data,
|
||||
|
||||
@@ -68,11 +68,6 @@ gdk_x11_vulkan_context_end_frame (GdkDrawContext *context,
|
||||
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
|
||||
gdk_x11_vulkan_context_class_init (GdkX11VulkanContextClass *klass)
|
||||
{
|
||||
@@ -80,7 +75,6 @@ gdk_x11_vulkan_context_class_init (GdkX11VulkanContextClass *klass)
|
||||
GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS (klass);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ gsk_gl_glyph_library_init_atlas (GskGLTextureLibrary *self,
|
||||
else
|
||||
{
|
||||
gl_format = GL_BGRA;
|
||||
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
glBindTexture (GL_TEXTURE_2D, atlas->texture_id);
|
||||
|
||||
@@ -293,7 +293,7 @@ gsk_gl_glyph_library_upload_glyph (GskGLGlyphLibrary *self,
|
||||
{
|
||||
pixel_data = cairo_image_surface_get_data (surface);
|
||||
gl_format = GL_BGRA;
|
||||
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, stride / 4);
|
||||
|
||||
@@ -125,7 +125,7 @@ gsk_gl_icon_library_add (GskGLIconLibrary *self,
|
||||
{
|
||||
pixel_data = surface_data;
|
||||
gl_format = GL_BGRA;
|
||||
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
|
||||
texture_id = GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (icon_data);
|
||||
|
||||
@@ -41,15 +41,6 @@
|
||||
#include <gsk/gskroundedrectprivate.h>
|
||||
#include <gsk/gskrectprivate.h>
|
||||
|
||||
/**
|
||||
* GskGLRenderer:
|
||||
*
|
||||
* A GL based renderer.
|
||||
*
|
||||
* See [class@Gsk.Renderer].
|
||||
*
|
||||
* Since: 4.2
|
||||
*/
|
||||
struct _GskGLRendererClass
|
||||
{
|
||||
GskRendererClass parent_class;
|
||||
|
||||
@@ -70,10 +70,7 @@ gsk_gl_frame_cleanup (GskGpuFrame *frame)
|
||||
if (self->sync)
|
||||
{
|
||||
glClientWaitSync (self->sync, 0, -1);
|
||||
|
||||
/* can't use g_clear_pointer() on glDeleteSync(), see MR !7294 */
|
||||
glDeleteSync (self->sync);
|
||||
self->sync = NULL;
|
||||
g_clear_pointer (&self->sync, glDeleteSync);
|
||||
}
|
||||
|
||||
self->next_texture_slot = 0;
|
||||
|
||||
@@ -19,7 +19,7 @@ static gint64 profiler_buffer_uploads;
|
||||
static void
|
||||
gsk_gpu_buffer_class_init (GskGpuBufferClass *klass)
|
||||
{
|
||||
profiler_buffer_uploads_id = gdk_profiler_define_int_counter ("buffer-uploads", "Number of bytes uploaded to GPU");
|
||||
profiler_buffer_uploads_id = gdk_profiler_define_int_counter ("ngl-buffer-uploads", "Number of bytes uploaded to GPU");
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -546,7 +546,7 @@ gsk_gpu_device_maybe_gc (GskGpuDevice *self)
|
||||
|
||||
if (priv->cache_timeout == 0 || dead_texture_pixels > 1000000)
|
||||
{
|
||||
GSK_DEBUG (GLYPH_CACHE, "Pre-frame GC (%" G_GSIZE_FORMAT " dead pixels)", dead_texture_pixels);
|
||||
GSK_DEBUG (GLYPH_CACHE, "Pre-frame GC (%lu dead pixels)", dead_texture_pixels);
|
||||
gsk_gpu_device_gc (self, g_get_monotonic_time ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,13 +249,7 @@ gsk_gl_texture_data_free (gpointer user_data)
|
||||
|
||||
gdk_gl_context_make_current (data->context);
|
||||
|
||||
/* can't use g_clear_pointer() on glDeleteSync(), see MR !7294 */
|
||||
if (data->sync)
|
||||
{
|
||||
glDeleteSync (data->sync);
|
||||
data->sync = NULL;
|
||||
}
|
||||
|
||||
g_clear_pointer (&data->sync, glDeleteSync);
|
||||
glDeleteTextures (1, &data->texture_id);
|
||||
g_object_unref (data->context);
|
||||
|
||||
|
||||
@@ -345,8 +345,8 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
|
||||
|
||||
area.x = 0;
|
||||
area.y = 0;
|
||||
area.width = MAX (1, ceilf (graphene_vec2_get_x (scale) * viewport->size.width - EPSILON));
|
||||
area.height = MAX (1, ceilf (graphene_vec2_get_y (scale) * viewport->size.height - EPSILON));
|
||||
area.width = ceilf (graphene_vec2_get_x (scale) * viewport->size.width - EPSILON);
|
||||
area.height = ceilf (graphene_vec2_get_y (scale) * viewport->size.height - EPSILON);
|
||||
|
||||
image = gsk_gpu_device_create_offscreen_image (gsk_gpu_frame_get_device (frame),
|
||||
FALSE,
|
||||
|
||||
@@ -313,11 +313,6 @@ gsk_gpu_upload_texture_op_try (GskGpuFrame *frame,
|
||||
{
|
||||
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))
|
||||
{
|
||||
gdk_debug_message ("Unsupported format %s, converting on CPU to %s",
|
||||
|
||||
@@ -13,15 +13,6 @@
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
/**
|
||||
* GskNglRenderer:
|
||||
*
|
||||
* A GL based renderer.
|
||||
*
|
||||
* See [class@Gsk.Renderer].
|
||||
*
|
||||
* Since: 4.2
|
||||
*/
|
||||
struct _GskNglRenderer
|
||||
{
|
||||
GskGpuRenderer parent_instance;
|
||||
|
||||
+14
-46
@@ -81,7 +81,6 @@ struct _PipelineCacheKey
|
||||
GskGpuShaderClip clip;
|
||||
GskGpuBlend blend;
|
||||
VkFormat format;
|
||||
VkPipeline pipeline;
|
||||
};
|
||||
|
||||
struct _RenderPassCacheKey
|
||||
@@ -89,7 +88,6 @@ struct _RenderPassCacheKey
|
||||
VkFormat format;
|
||||
VkImageLayout from_layout;
|
||||
VkImageLayout to_layout;
|
||||
VkRenderPass render_pass;
|
||||
};
|
||||
|
||||
static guint
|
||||
@@ -299,10 +297,8 @@ gsk_vulkan_pipeline_layout_unref (GskVulkanDevice *self,
|
||||
g_hash_table_iter_init (&iter, layout->pipeline_cache);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
{
|
||||
vkDestroyPipeline (display->vk_device,
|
||||
((PipelineCacheKey *)key)->pipeline,
|
||||
NULL);
|
||||
g_free (key);
|
||||
vkDestroyPipeline (display->vk_device, value, NULL);
|
||||
}
|
||||
g_hash_table_unref (layout->pipeline_cache);
|
||||
|
||||
@@ -467,10 +463,8 @@ gsk_vulkan_device_finalize (GObject *object)
|
||||
g_hash_table_iter_init (&iter, self->render_pass_cache);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
{
|
||||
vkDestroyRenderPass (display->vk_device,
|
||||
((RenderPassCacheKey *)key)->render_pass,
|
||||
NULL);
|
||||
g_free (key);
|
||||
vkDestroyRenderPass (display->vk_device, value, NULL);
|
||||
}
|
||||
g_hash_table_unref (self->render_pass_cache);
|
||||
|
||||
@@ -793,7 +787,7 @@ gsk_vulkan_device_get_vk_conversion (GskVulkanDevice *self,
|
||||
.sType = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO,
|
||||
.format = vk_format,
|
||||
.ycbcrModel = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601,
|
||||
.ycbcrRange = VK_SAMPLER_YCBCR_RANGE_ITU_NARROW,
|
||||
.ycbcrRange = VK_SAMPLER_YCBCR_RANGE_ITU_FULL,
|
||||
.components = (VkComponentMapping) {
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
@@ -830,7 +824,6 @@ gsk_vulkan_device_get_vk_render_pass (GskVulkanDevice *self,
|
||||
VkImageLayout to_layout)
|
||||
{
|
||||
RenderPassCacheKey cache_key;
|
||||
RenderPassCacheKey *cached_result;
|
||||
VkRenderPass render_pass;
|
||||
GdkDisplay *display;
|
||||
|
||||
@@ -839,9 +832,9 @@ gsk_vulkan_device_get_vk_render_pass (GskVulkanDevice *self,
|
||||
.from_layout = from_layout,
|
||||
.to_layout = to_layout,
|
||||
};
|
||||
cached_result = g_hash_table_lookup (self->render_pass_cache, &cache_key);
|
||||
if (cached_result)
|
||||
return cached_result->render_pass;
|
||||
render_pass = g_hash_table_lookup (self->render_pass_cache, &cache_key);
|
||||
if (render_pass)
|
||||
return render_pass;
|
||||
|
||||
display = gsk_gpu_device_get_display (GSK_GPU_DEVICE (self));
|
||||
|
||||
@@ -885,10 +878,7 @@ gsk_vulkan_device_get_vk_render_pass (GskVulkanDevice *self,
|
||||
NULL,
|
||||
&render_pass);
|
||||
|
||||
cached_result = g_memdup (&cache_key, sizeof (RenderPassCacheKey));
|
||||
cached_result->render_pass = render_pass;
|
||||
|
||||
g_hash_table_insert (self->render_pass_cache, cached_result, cached_result);
|
||||
g_hash_table_insert (self->render_pass_cache, g_memdup (&cache_key, sizeof (RenderPassCacheKey)), render_pass);
|
||||
|
||||
return render_pass;
|
||||
}
|
||||
@@ -956,14 +946,11 @@ gsk_vulkan_device_get_vk_pipeline (GskVulkanDevice *self,
|
||||
VkRenderPass render_pass)
|
||||
{
|
||||
PipelineCacheKey cache_key;
|
||||
PipelineCacheKey *cached_result;
|
||||
VkPipeline pipeline;
|
||||
GdkDisplay *display;
|
||||
const char *version_string;
|
||||
char *vertex_shader_name, *fragment_shader_name;
|
||||
G_GNUC_UNUSED gint64 begin_time = GDK_PROFILER_CURRENT_TIME;
|
||||
const char *clip_name[] = { "NONE", "RECT", "ROUNDED" };
|
||||
const char *blend_name[] = { "OVER", "ADD", "CLEAR" };
|
||||
|
||||
cache_key = (PipelineCacheKey) {
|
||||
.op_class = op_class,
|
||||
@@ -972,9 +959,9 @@ gsk_vulkan_device_get_vk_pipeline (GskVulkanDevice *self,
|
||||
.blend = blend,
|
||||
.format = format,
|
||||
};
|
||||
cached_result = g_hash_table_lookup (layout->pipeline_cache, &cache_key);
|
||||
if (cached_result)
|
||||
return cached_result->pipeline;
|
||||
pipeline = g_hash_table_lookup (layout->pipeline_cache, &cache_key);
|
||||
if (pipeline)
|
||||
return pipeline;
|
||||
|
||||
display = gsk_gpu_device_get_display (GSK_GPU_DEVICE (self));
|
||||
if (gsk_vulkan_device_has_feature (self, GDK_VULKAN_FEATURE_DYNAMIC_INDEXING) &&
|
||||
@@ -1141,32 +1128,13 @@ gsk_vulkan_device_get_vk_pipeline (GskVulkanDevice *self,
|
||||
&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);
|
||||
"Create Vulkan pipeline frag=%s vert=%s",
|
||||
fragment_shader_name, vertex_shader_name);
|
||||
|
||||
g_free (fragment_shader_name);
|
||||
g_free (vertex_shader_name);
|
||||
|
||||
cached_result = g_memdup (&cache_key, sizeof (PipelineCacheKey));
|
||||
cached_result->pipeline = pipeline;
|
||||
g_hash_table_insert (layout->pipeline_cache, cached_result, cached_result);
|
||||
g_hash_table_insert (layout->pipeline_cache, g_memdup (&cache_key, sizeof (PipelineCacheKey)), pipeline);
|
||||
gdk_display_vulkan_pipeline_cache_updated (display);
|
||||
|
||||
return pipeline;
|
||||
@@ -1274,7 +1242,7 @@ gsk_vulkan_device_find_allocator (GskVulkanDevice *self,
|
||||
|
||||
g_assert (found < properties.memoryTypeCount);
|
||||
|
||||
return gsk_vulkan_allocator_ref (gsk_vulkan_device_get_allocator (self, found, &properties.memoryTypes[found]));
|
||||
return gsk_vulkan_allocator_ref (gsk_vulkan_device_get_allocator (self, i, &properties.memoryTypes[i]));
|
||||
}
|
||||
|
||||
GskVulkanAllocator *
|
||||
|
||||
@@ -178,7 +178,7 @@ gsk_vulkan_buddy_allocator_alloc (GskVulkanAllocator *allocator,
|
||||
if (self->cache.vk_memory)
|
||||
{
|
||||
*alloc = self->cache;
|
||||
self->cache.vk_memory = VK_NULL_HANDLE;
|
||||
self->cache.vk_memory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -240,7 +240,7 @@ restart:
|
||||
alloc->size <<= 1;
|
||||
if (slot == 0)
|
||||
{
|
||||
if (self->cache.vk_memory == VK_NULL_HANDLE)
|
||||
if (self->cache.vk_memory == NULL)
|
||||
self->cache = *alloc;
|
||||
else
|
||||
gsk_vulkan_free (self->allocator, alloc);
|
||||
|
||||
+1
-1
@@ -439,7 +439,7 @@ gsk_gl_shader_class_init (GskGLShaderClass *klass)
|
||||
object_class->constructed = gsk_gl_shader_constructed;
|
||||
|
||||
/**
|
||||
* GskGLShader:source: (attributes org.gtk.Property.get=gsk_gl_shader_get_source)
|
||||
* GskGLShader:sourcecode: (attributes org.gtk.Property.get=gsk_gl_shader_get_source)
|
||||
*
|
||||
* The source code for the shader, as a `GBytes`.
|
||||
*/
|
||||
|
||||
@@ -387,7 +387,6 @@ gsk_path_builder_add_reverse_path (GskPathBuilder *self,
|
||||
/**
|
||||
* gsk_path_builder_add_cairo_path:
|
||||
* @self: a `GskPathBuilder`
|
||||
* @path: a path
|
||||
*
|
||||
* Adds a Cairo path to the builder.
|
||||
*
|
||||
@@ -1144,10 +1143,10 @@ gsk_path_builder_rel_conic_to (GskPathBuilder *self,
|
||||
* @x2: x coordinate of second control point
|
||||
* @y2: y coordinate of second control point
|
||||
*
|
||||
* Adds an elliptical arc from the current point to @x2, @y2
|
||||
* Adds an elliptical arc from the current point to @x3, @y3
|
||||
* with @x1, @y1 determining the tangent directions.
|
||||
*
|
||||
* After this, @x2, @y2 will be the new current point.
|
||||
* After this, @x3, @y3 will be the new current point.
|
||||
*
|
||||
* Note: Two points and their tangents do not determine
|
||||
* a unique ellipse, so GSK just picks one. If you need more
|
||||
@@ -1181,7 +1180,7 @@ gsk_path_builder_arc_to (GskPathBuilder *self,
|
||||
* @x2: x coordinate of second control point
|
||||
* @y2: y coordinate of second control point
|
||||
*
|
||||
* Adds an elliptical arc from the current point to @x2, @y2
|
||||
* Adds an elliptical arc from the current point to @x3, @y3
|
||||
* with @x1, @y1 determining the tangent directions.
|
||||
*
|
||||
* All coordinates are given relative to the current point.
|
||||
|
||||
@@ -51,16 +51,6 @@ G_DEFINE_BOXED_TYPE (GskPathPoint, gsk_path_point,
|
||||
gsk_path_point_copy,
|
||||
gsk_path_point_free)
|
||||
|
||||
/**
|
||||
* gsk_path_point_copy:
|
||||
* @point: a path point
|
||||
*
|
||||
* Copies a path point.
|
||||
*
|
||||
* Returns: the copied point
|
||||
*
|
||||
* Since: 4.14
|
||||
*/
|
||||
GskPathPoint *
|
||||
gsk_path_point_copy (GskPathPoint *point)
|
||||
{
|
||||
@@ -73,14 +63,6 @@ gsk_path_point_copy (GskPathPoint *point)
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_path_point_free:
|
||||
* @point: a path point
|
||||
*
|
||||
* Frees a path point copied by [method@Gsk.PathPoint.copy].
|
||||
*
|
||||
* Since: 4.14
|
||||
*/
|
||||
void
|
||||
gsk_path_point_free (GskPathPoint *point)
|
||||
{
|
||||
|
||||
@@ -28,9 +28,7 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/* path has only lines */
|
||||
GSK_PATH_FLAT,
|
||||
/* all contours are closed */
|
||||
GSK_PATH_CLOSED
|
||||
} GskPathFlags;
|
||||
|
||||
|
||||
+72
-85
@@ -428,6 +428,21 @@ gsk_renderer_render_texture (GskRenderer *renderer,
|
||||
|
||||
texture = GSK_RENDERER_GET_CLASS (renderer)->render_texture (renderer, root, viewport);
|
||||
|
||||
if (GSK_RENDERER_DEBUG_CHECK (renderer, RENDERER))
|
||||
{
|
||||
GString *buf = g_string_new ("*** Texture stats ***\n\n");
|
||||
|
||||
gsk_profiler_append_counters (priv->profiler, buf);
|
||||
g_string_append_c (buf, '\n');
|
||||
|
||||
gsk_profiler_append_timers (priv->profiler, buf);
|
||||
g_string_append_c (buf, '\n');
|
||||
|
||||
g_print ("%s\n***\n\n", buf->str);
|
||||
|
||||
g_string_free (buf, TRUE);
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
@@ -494,6 +509,21 @@ gsk_renderer_render (GskRenderer *renderer,
|
||||
|
||||
renderer_class->render (renderer, root, clip);
|
||||
|
||||
if (GSK_RENDERER_DEBUG_CHECK (renderer, RENDERER))
|
||||
{
|
||||
GString *buf = g_string_new ("*** Frame stats ***\n\n");
|
||||
|
||||
gsk_profiler_append_counters (priv->profiler, buf);
|
||||
g_string_append_c (buf, '\n');
|
||||
|
||||
gsk_profiler_append_timers (priv->profiler, buf);
|
||||
g_string_append_c (buf, '\n');
|
||||
|
||||
g_print ("%s\n***\n\n", buf->str);
|
||||
|
||||
g_string_free (buf, TRUE);
|
||||
}
|
||||
|
||||
g_clear_pointer (&priv->prev_node, gsk_render_node_unref);
|
||||
cairo_region_destroy (clip);
|
||||
g_clear_pointer (&offload, gsk_offload_free);
|
||||
@@ -579,17 +609,12 @@ get_renderer_for_display (GdkSurface *surface)
|
||||
static GType
|
||||
get_renderer_for_env_var (GdkSurface *surface)
|
||||
{
|
||||
static GType env_var_type = G_TYPE_INVALID;
|
||||
static GType env_var_type = G_TYPE_NONE;
|
||||
|
||||
if (env_var_type == G_TYPE_INVALID)
|
||||
if (env_var_type == G_TYPE_NONE)
|
||||
{
|
||||
const char *renderer_name = g_getenv ("GSK_RENDERER");
|
||||
env_var_type = get_renderer_for_name (renderer_name);
|
||||
if (env_var_type != G_TYPE_INVALID)
|
||||
GSK_DEBUG (RENDERER,
|
||||
"Environment variable GSK_RENDERER=%s set, trying %s",
|
||||
renderer_name,
|
||||
g_type_name (env_var_type));
|
||||
}
|
||||
|
||||
return env_var_type;
|
||||
@@ -607,115 +632,83 @@ get_renderer_for_backend (GdkSurface *surface)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gl_supported_platform (GdkSurface *surface,
|
||||
GType renderer_type,
|
||||
gboolean as_fallback)
|
||||
gl_software_rendering (GdkSurface *surface)
|
||||
{
|
||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||
GdkGLContext *context;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!gdk_display_prepare_gl (display, &error))
|
||||
{
|
||||
if (!as_fallback)
|
||||
GSK_DEBUG (RENDERER, "Not using GL: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (as_fallback)
|
||||
return TRUE;
|
||||
if (!gdk_display_prepare_gl (display, NULL))
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
context = gdk_display_get_gl_context (display);
|
||||
gdk_gl_context_make_current (context);
|
||||
|
||||
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;
|
||||
return strstr ((const char *) glGetString (GL_RENDERER), "llvmpipe") != NULL;
|
||||
}
|
||||
|
||||
static GType
|
||||
get_renderer_for_gl (GdkSurface *surface)
|
||||
{
|
||||
if (!gl_supported_platform (surface, gsk_ngl_renderer_get_type (), FALSE))
|
||||
if (gl_software_rendering (surface))
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
return gsk_ngl_renderer_get_type ();
|
||||
}
|
||||
|
||||
static GType
|
||||
get_renderer_for_gl_fallback (GdkSurface *surface)
|
||||
{
|
||||
if (!gl_supported_platform (surface, GSK_TYPE_GL_RENDERER, TRUE))
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
return GSK_TYPE_GL_RENDERER;
|
||||
}
|
||||
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
static gboolean
|
||||
vulkan_supported_platform (GdkSurface *surface,
|
||||
GType renderer_type,
|
||||
gboolean as_fallback)
|
||||
vulkan_software_rendering (GdkSurface *surface)
|
||||
{
|
||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||
VkPhysicalDeviceProperties props;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!gdk_display_init_vulkan (display, &error))
|
||||
{
|
||||
if (!as_fallback)
|
||||
GSK_DEBUG (RENDERER, "Not using Vulkan: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
return FALSE;
|
||||
}
|
||||
if (!gdk_display_init_vulkan (display, NULL))
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
vkGetPhysicalDeviceProperties (display->vk_physical_device, &props);
|
||||
|
||||
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;
|
||||
}
|
||||
return props.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (as_fallback)
|
||||
return TRUE;
|
||||
static GType
|
||||
get_renderer_for_vulkan (GdkSurface *surface)
|
||||
{
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
if (vulkan_software_rendering (surface))
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
return GSK_TYPE_VULKAN_RENDERER;
|
||||
#else
|
||||
return G_TYPE_INVALID;
|
||||
#endif
|
||||
}
|
||||
|
||||
static gboolean
|
||||
vulkan_friendly_platform (GdkSurface *surface)
|
||||
{
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
if (GDK_IS_WAYLAND_DISPLAY (gdk_surface_get_display (surface)))
|
||||
return TRUE;
|
||||
#endif
|
||||
|
||||
GSK_DEBUG (RENDERER, "Not using '%s': platform is not Wayland", g_type_name (renderer_type));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GType
|
||||
get_renderer_for_vulkan (GdkSurface *surface)
|
||||
get_renderer_for_vulkan_friendly_platform (GdkSurface *surface)
|
||||
{
|
||||
if (!vulkan_supported_platform (surface, GSK_TYPE_VULKAN_RENDERER, FALSE))
|
||||
return G_TYPE_INVALID;
|
||||
if (vulkan_friendly_platform (surface))
|
||||
return get_renderer_for_vulkan (surface);
|
||||
|
||||
return GSK_TYPE_VULKAN_RENDERER;
|
||||
return G_TYPE_INVALID;
|
||||
}
|
||||
|
||||
static GType
|
||||
get_renderer_for_vulkan_fallback (GdkSurface *surface)
|
||||
get_renderer_for_gles2 (GdkSurface *surface)
|
||||
{
|
||||
if (!vulkan_supported_platform (surface, GSK_TYPE_VULKAN_RENDERER, TRUE))
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
return GSK_TYPE_VULKAN_RENDERER;
|
||||
return GSK_TYPE_GL_RENDERER;
|
||||
}
|
||||
#endif
|
||||
|
||||
static GType
|
||||
get_renderer_fallback (GdkSurface *surface)
|
||||
@@ -729,14 +722,10 @@ static struct {
|
||||
{ get_renderer_for_display },
|
||||
{ get_renderer_for_env_var },
|
||||
{ get_renderer_for_backend },
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
{ get_renderer_for_vulkan },
|
||||
#endif
|
||||
{ get_renderer_for_vulkan_friendly_platform },
|
||||
{ get_renderer_for_gl },
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
{ get_renderer_for_vulkan_fallback },
|
||||
#endif
|
||||
{ get_renderer_for_gl_fallback },
|
||||
{ get_renderer_for_vulkan },
|
||||
{ get_renderer_for_gles2 },
|
||||
{ get_renderer_fallback },
|
||||
};
|
||||
|
||||
@@ -774,19 +763,17 @@ gsk_renderer_new_for_surface (GdkSurface *surface)
|
||||
|
||||
if (gsk_renderer_realize (renderer, surface, &error))
|
||||
{
|
||||
GSK_DEBUG (RENDERER,
|
||||
"Using renderer '%s' for surface '%s'",
|
||||
G_OBJECT_TYPE_NAME (renderer),
|
||||
G_OBJECT_TYPE_NAME (surface));
|
||||
GSK_RENDERER_DEBUG (renderer, RENDERER,
|
||||
"Using renderer of type '%s' for surface '%s'",
|
||||
G_OBJECT_TYPE_NAME (renderer),
|
||||
G_OBJECT_TYPE_NAME (surface));
|
||||
return renderer;
|
||||
}
|
||||
|
||||
GSK_DEBUG (RENDERER,
|
||||
"Failed to realize renderer '%s' for surface '%s': %s",
|
||||
g_message ("Failed to realize renderer of type '%s' for surface '%s': %s\n",
|
||||
G_OBJECT_TYPE_NAME (renderer),
|
||||
G_OBJECT_TYPE_NAME (surface),
|
||||
error->message);
|
||||
|
||||
g_object_unref (renderer);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
@@ -48,13 +48,6 @@
|
||||
|
||||
#include <gobject/gvaluecollector.h>
|
||||
|
||||
/**
|
||||
* gsk_serialization_error_quark:
|
||||
*
|
||||
* Registers an error quark for [class@Gsk.RenderNode] errors.
|
||||
*
|
||||
* Returns: the error quark
|
||||
**/
|
||||
G_DEFINE_QUARK (gsk-serialization-error-quark, gsk_serialization_error)
|
||||
|
||||
#define GSK_RENDER_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_RENDER_NODE, GskRenderNodeClass))
|
||||
|
||||
@@ -6397,10 +6397,6 @@ gsk_mask_node_draw (GskRenderNode *node,
|
||||
graphene_matrix_t color_matrix;
|
||||
graphene_vec4_t color_offset;
|
||||
|
||||
/* clip so the push_group() creates a smaller surface */
|
||||
gsk_cairo_rectangle (cr, &node->bounds);
|
||||
cairo_clip (cr);
|
||||
|
||||
if (has_empty_clip (cr))
|
||||
return;
|
||||
|
||||
|
||||
+20
-38
@@ -2312,25 +2312,6 @@ parse_antialias (GtkCssParser *parser,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_hint_metrics (GtkCssParser *parser,
|
||||
Context *context,
|
||||
gpointer out)
|
||||
{
|
||||
if (!parse_enum (parser, CAIRO_GOBJECT_TYPE_HINT_METRICS, out))
|
||||
return FALSE;
|
||||
|
||||
if (*(cairo_hint_metrics_t *) out != CAIRO_HINT_METRICS_OFF &&
|
||||
*(cairo_hint_metrics_t *) out != CAIRO_HINT_METRICS_ON)
|
||||
{
|
||||
gtk_css_parser_error_value (parser, "Unsupported value for enum \"%s\"",
|
||||
g_type_name (CAIRO_GOBJECT_TYPE_HINT_METRICS));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
parse_text_node (GtkCssParser *parser,
|
||||
Context *context)
|
||||
@@ -2341,7 +2322,6 @@ parse_text_node (GtkCssParser *parser,
|
||||
PangoGlyphString *glyphs = NULL;
|
||||
cairo_hint_style_t hint_style = CAIRO_HINT_STYLE_SLIGHT;
|
||||
cairo_antialias_t antialias = CAIRO_ANTIALIAS_GRAY;
|
||||
cairo_hint_metrics_t hint_metrics = CAIRO_HINT_METRICS_OFF;
|
||||
PangoFont *hinted;
|
||||
const Declaration declarations[] = {
|
||||
{ "font", parse_font, clear_font, &font },
|
||||
@@ -2350,7 +2330,6 @@ parse_text_node (GtkCssParser *parser,
|
||||
{ "glyphs", parse_glyphs, clear_glyphs, &glyphs },
|
||||
{ "hint-style", parse_hint_style, NULL, &hint_style },
|
||||
{ "antialias", parse_antialias, NULL, &antialias },
|
||||
{ "hint-metrics", parse_hint_metrics, NULL, &hint_metrics },
|
||||
};
|
||||
GskRenderNode *result;
|
||||
|
||||
@@ -2362,7 +2341,7 @@ parse_text_node (GtkCssParser *parser,
|
||||
g_assert (font);
|
||||
}
|
||||
|
||||
hinted = gsk_reload_font (font, 1.0, hint_metrics, hint_style, antialias);
|
||||
hinted = gsk_reload_font (font, 1.0, CAIRO_HINT_METRICS_OFF, hint_style, antialias);
|
||||
g_object_unref (font);
|
||||
font = hinted;
|
||||
|
||||
@@ -3232,6 +3211,17 @@ append_rounded_rect (GString *str,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
append_rgba (GString *str,
|
||||
const GdkRGBA *rgba)
|
||||
{
|
||||
char *rgba_str = gdk_rgba_to_string (rgba);
|
||||
|
||||
g_string_append (str, rgba_str);
|
||||
|
||||
g_free (rgba_str);
|
||||
}
|
||||
|
||||
static void
|
||||
append_point (GString *str,
|
||||
const graphene_point_t *p)
|
||||
@@ -3277,7 +3267,7 @@ append_rgba_param (Printer *p,
|
||||
{
|
||||
_indent (p);
|
||||
g_string_append_printf (p->str, "%s: ", param_name);
|
||||
gdk_rgba_print (value, p->str);
|
||||
append_rgba (p->str, value);
|
||||
g_string_append_c (p->str, ';');
|
||||
g_string_append_c (p->str, '\n');
|
||||
}
|
||||
@@ -3431,7 +3421,7 @@ append_stops_param (Printer *p,
|
||||
|
||||
string_append_double (p->str, stops[i].offset);
|
||||
g_string_append_c (p->str, ' ');
|
||||
gdk_rgba_print (&stops[i].color, p->str);
|
||||
append_rgba (p->str, &stops[i].color);
|
||||
}
|
||||
g_string_append (p->str, ";\n");
|
||||
}
|
||||
@@ -3549,13 +3539,13 @@ append_texture_param (Printer *p,
|
||||
case GDK_MEMORY_U8:
|
||||
case GDK_MEMORY_U16:
|
||||
bytes = gdk_texture_save_to_png_bytes (texture);
|
||||
g_string_append (p->str, "url(\"data:image/png;base64,\\\n");
|
||||
g_string_append (p->str, "url(\"data:image/png;base64,");
|
||||
break;
|
||||
|
||||
case GDK_MEMORY_FLOAT16:
|
||||
case GDK_MEMORY_FLOAT32:
|
||||
bytes = gdk_texture_save_to_tiff_bytes (texture);
|
||||
g_string_append (p->str, "url(\"data:image/tiff;base64,\\\n");
|
||||
g_string_append (p->str, "url(\"data:image/tiff;base64,");
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -3614,7 +3604,7 @@ gsk_text_node_serialize_font (GskRenderNode *node,
|
||||
|
||||
b64 = base64_encode_with_linebreaks ((const guchar *) data, len);
|
||||
|
||||
g_string_append (p->str, " url(\"data:font/ttf;base64,\\\n");
|
||||
g_string_append (p->str, " url(\"data:font/ttf;base64,");
|
||||
append_escaping_newlines (p->str, b64);
|
||||
g_string_append (p->str, "\")");
|
||||
|
||||
@@ -3633,13 +3623,11 @@ gsk_text_node_serialize_font_options (GskRenderNode *node,
|
||||
cairo_font_options_t *options;
|
||||
cairo_hint_style_t hint_style;
|
||||
cairo_antialias_t antialias;
|
||||
cairo_hint_metrics_t hint_metrics;
|
||||
|
||||
options = cairo_font_options_create ();
|
||||
cairo_scaled_font_get_font_options (sf, options);
|
||||
hint_style = cairo_font_options_get_hint_style (options);
|
||||
antialias = cairo_font_options_get_antialias (options);
|
||||
hint_metrics = cairo_font_options_get_hint_metrics (options);
|
||||
cairo_font_options_destroy (options);
|
||||
|
||||
/* medium and full are identical in the absence of subpixel modes */
|
||||
@@ -3655,12 +3643,6 @@ gsk_text_node_serialize_font_options (GskRenderNode *node,
|
||||
*/
|
||||
if (antialias == CAIRO_ANTIALIAS_NONE)
|
||||
append_enum_param (p, "antialias", CAIRO_GOBJECT_TYPE_ANTIALIAS, antialias);
|
||||
|
||||
/* CAIRO_HINT_METRICS_ON is the only value we ever emit here, since off is the default,
|
||||
* and we don't accept any other values.
|
||||
*/
|
||||
if (hint_metrics == CAIRO_HINT_METRICS_ON)
|
||||
append_enum_param (p, "hint-metrics", CAIRO_GOBJECT_TYPE_HINT_METRICS, CAIRO_HINT_METRICS_ON);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -4057,7 +4039,7 @@ render_node_print (Printer *p,
|
||||
{
|
||||
if (i > 0)
|
||||
g_string_append_c (p->str, ' ');
|
||||
gdk_rgba_print (&colors[i], p->str);
|
||||
append_rgba (p->str, &colors[i]);
|
||||
}
|
||||
g_string_append (p->str, ";\n");
|
||||
}
|
||||
@@ -4432,7 +4414,7 @@ render_node_print (Printer *p,
|
||||
cairo_surface_write_to_png_stream (surface, cairo_write_array, array);
|
||||
|
||||
_indent (p);
|
||||
g_string_append (p->str, "pixels: url(\"data:image/png;base64,\\\n");
|
||||
g_string_append (p->str, "pixels: url(\"data:image/png;base64,");
|
||||
b64 = base64_encode_with_linebreaks (array->data, array->len);
|
||||
append_escaping_newlines (p->str, b64);
|
||||
g_free (b64);
|
||||
@@ -4452,7 +4434,7 @@ render_node_print (Printer *p,
|
||||
if (cairo_script_from_recording_surface (script, surface) == CAIRO_STATUS_SUCCESS)
|
||||
{
|
||||
_indent (p);
|
||||
g_string_append (p->str, "script: url(\"data:;base64,\\\n");
|
||||
g_string_append (p->str, "script: url(\"data:;base64,");
|
||||
b64 = base64_encode_with_linebreaks (array->data, array->len);
|
||||
append_escaping_newlines (p->str, b64);
|
||||
g_free (b64);
|
||||
|
||||
@@ -354,8 +354,6 @@ gsk_stroke_set_miter_limit (GskStroke *self,
|
||||
*
|
||||
* Returns the miter limit of a `GskStroke`.
|
||||
*
|
||||
* Returns: the miter limit
|
||||
*
|
||||
* Since: 4.14
|
||||
*/
|
||||
float
|
||||
@@ -480,8 +478,6 @@ gsk_stroke_set_dash_offset (GskStroke *self,
|
||||
*
|
||||
* Returns the dash_offset of a `GskStroke`.
|
||||
*
|
||||
* Returns: the dash_offset
|
||||
*
|
||||
* Since: 4.14
|
||||
*/
|
||||
float
|
||||
|
||||
+1
-1
@@ -2023,7 +2023,7 @@ GskTransformCategory
|
||||
return self->category;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* gsk_transform_new: (constructor):
|
||||
*
|
||||
* Creates a new identity transform.
|
||||
|
||||
@@ -184,4 +184,10 @@
|
||||
</signal>
|
||||
</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>
|
||||
|
||||
+20
-31
@@ -530,15 +530,6 @@ handle_accessible_method (GDBusConnection *connection,
|
||||
g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{ss}"));
|
||||
g_variant_builder_add (&builder, "{ss}", "toolkit", "GTK");
|
||||
|
||||
if (gtk_at_context_has_accessible_property (GTK_AT_CONTEXT (self), GTK_ACCESSIBLE_PROPERTY_LEVEL))
|
||||
{
|
||||
GtkAccessibleValue *value = gtk_at_context_get_accessible_property (GTK_AT_CONTEXT (self),
|
||||
GTK_ACCESSIBLE_PROPERTY_LEVEL);
|
||||
char *level = g_strdup_printf ("%d", gtk_int_accessible_value_get (value));
|
||||
g_variant_builder_add (&builder, "{ss}", "level", level);
|
||||
g_free (level);
|
||||
}
|
||||
|
||||
if (gtk_at_context_has_accessible_property (GTK_AT_CONTEXT (self), GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER))
|
||||
{
|
||||
GtkAccessibleValue *value;
|
||||
@@ -729,16 +720,6 @@ handle_accessible_get_property (GDBusConnection *connection,
|
||||
res = get_parent_context_ref (accessible);
|
||||
else if (g_strcmp0 (property_name, "ChildCount") == 0)
|
||||
res = g_variant_new_int32 (gtk_at_spi_context_get_child_count (self));
|
||||
else if (g_strcmp0 (property_name, "HelpText"))
|
||||
{
|
||||
if (gtk_at_context_has_accessible_property (GTK_AT_CONTEXT (self), GTK_ACCESSIBLE_PROPERTY_HELP_TEXT))
|
||||
{
|
||||
GtkAccessibleValue *value = gtk_at_context_get_accessible_property (GTK_AT_CONTEXT (self), GTK_ACCESSIBLE_PROPERTY_HELP_TEXT);
|
||||
res = g_variant_new_string (gtk_string_accessible_value_get (value));
|
||||
}
|
||||
else
|
||||
res = g_variant_new_string ("");
|
||||
}
|
||||
else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"Unknown property '%s'", property_name);
|
||||
@@ -918,6 +899,24 @@ emit_children_changed (GtkAtSpiContext *self,
|
||||
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
|
||||
emit_window_event (GtkAtSpiContext *self,
|
||||
const char *event_type)
|
||||
@@ -1155,7 +1154,7 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
|
||||
}
|
||||
|
||||
if (changed_properties & GTK_ACCESSIBLE_PROPERTY_CHANGE_DESCRIPTION)
|
||||
{
|
||||
{
|
||||
char *label = gtk_at_context_get_description (GTK_AT_CONTEXT (self));
|
||||
GVariant *v = g_variant_new_take_string (label);
|
||||
emit_property_changed (self, "accessible-description", v);
|
||||
@@ -1168,14 +1167,6 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
|
||||
"accessible-value",
|
||||
g_variant_new_double (gtk_number_accessible_value_get (value)));
|
||||
}
|
||||
|
||||
if (changed_properties & GTK_ACCESSIBLE_PROPERTY_CHANGE_HELP_TEXT)
|
||||
{
|
||||
value = gtk_accessible_attribute_set_get_value (properties, GTK_ACCESSIBLE_PROPERTY_HELP_TEXT);
|
||||
emit_property_changed (self,
|
||||
"accessible-help-text",
|
||||
g_variant_new_string (gtk_string_accessible_value_get (value)));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1205,6 +1196,7 @@ gtk_at_spi_context_platform_change (GtkATContext *ctx,
|
||||
gboolean state = gtk_accessible_get_platform_state (GTK_ACCESSIBLE (widget),
|
||||
GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED);
|
||||
emit_state_changed (self, "focused", state);
|
||||
emit_focus (self, state);
|
||||
}
|
||||
|
||||
if (changed_platform & GTK_ACCESSIBLE_PLATFORM_CHANGE_ACTIVE)
|
||||
@@ -1266,13 +1258,10 @@ gtk_at_spi_context_child_change (GtkATContext *ctx,
|
||||
}
|
||||
|
||||
if (change & GTK_ACCESSIBLE_CHILD_CHANGE_ADDED)
|
||||
{
|
||||
gtk_at_context_realize (child_context);
|
||||
emit_children_changed (self,
|
||||
GTK_AT_SPI_CONTEXT (child_context),
|
||||
idx,
|
||||
GTK_ACCESSIBLE_CHILD_STATE_ADDED);
|
||||
}
|
||||
else if (change & GTK_ACCESSIBLE_CHILD_CHANGE_REMOVED)
|
||||
emit_children_changed (self,
|
||||
GTK_AT_SPI_CONTEXT (child_context),
|
||||
|
||||
@@ -97,7 +97,7 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
|
||||
return ATSPI_ROLE_FORM;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_GENERIC:
|
||||
return ATSPI_ROLE_PANEL;
|
||||
return ATSPI_ROLE_FILLER;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_GRID:
|
||||
return ATSPI_ROLE_TABLE;
|
||||
@@ -106,7 +106,7 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
|
||||
return ATSPI_ROLE_TABLE_CELL;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_GROUP:
|
||||
return ATSPI_ROLE_GROUPING;
|
||||
return ATSPI_ROLE_PANEL;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_HEADING:
|
||||
return ATSPI_ROLE_HEADING;
|
||||
|
||||
@@ -21,26 +21,12 @@
|
||||
|
||||
#include "gtkcsserror.h"
|
||||
|
||||
/**
|
||||
* gtk_css_parser_error_quark:
|
||||
*
|
||||
* Registers an error quark for CSS parsing errors.
|
||||
*
|
||||
* Returns: the error quark
|
||||
**/
|
||||
GQuark
|
||||
gtk_css_parser_error_quark (void)
|
||||
{
|
||||
return g_quark_from_static_string ("gtk-css-parser-error-quark");
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_css_parser_warning_quark:
|
||||
*
|
||||
* Registers an error quark for CSS parsing warnings.
|
||||
*
|
||||
* Returns: the warning quark
|
||||
**/
|
||||
GQuark
|
||||
gtk_css_parser_warning_quark (void)
|
||||
{
|
||||
|
||||
@@ -27,11 +27,6 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkCssLocation GtkCssLocation;
|
||||
|
||||
/**
|
||||
* GtkCssLocation:
|
||||
*
|
||||
* A description of a location inside a CSS stream.
|
||||
*/
|
||||
struct _GtkCssLocation
|
||||
{
|
||||
gsize bytes;
|
||||
|
||||
+51
-580
@@ -26,22 +26,24 @@
|
||||
#include "gtkcsserror.h"
|
||||
#include "gtkcsslocationprivate.h"
|
||||
|
||||
/* We cannot include gtkdebug.h, so we must keep this in sync */
|
||||
extern unsigned int gtk_get_debug_flags (void);
|
||||
#define DEBUG_CHECK_CSS ((gtk_get_debug_flags () & GTK_CSS_PARSER_DEBUG_CSS) != 0)
|
||||
|
||||
static void clear_ref (GtkCssVariableValueReference *ref);
|
||||
|
||||
#define GDK_ARRAY_NAME gtk_css_parser_references
|
||||
#define GDK_ARRAY_TYPE_NAME GtkCssParserReferences
|
||||
#define GDK_ARRAY_ELEMENT_TYPE GtkCssVariableValueReference
|
||||
#define GDK_ARRAY_BY_VALUE 1
|
||||
#define GDK_ARRAY_NO_MEMSET 1
|
||||
#define GDK_ARRAY_FREE_FUNC clear_ref
|
||||
#include "gdk/gdkarrayimpl.c"
|
||||
|
||||
typedef struct _GtkCssParserBlock GtkCssParserBlock;
|
||||
|
||||
struct _GtkCssParser
|
||||
{
|
||||
volatile int ref_count;
|
||||
|
||||
GtkCssTokenizer *tokenizer;
|
||||
GFile *file;
|
||||
GFile *directory;
|
||||
GtkCssParserErrorFunc error_func;
|
||||
gpointer user_data;
|
||||
GDestroyNotify user_destroy;
|
||||
|
||||
GArray *blocks;
|
||||
GtkCssLocation location;
|
||||
GtkCssToken token;
|
||||
};
|
||||
|
||||
struct _GtkCssParserBlock
|
||||
{
|
||||
GtkCssLocation start_location;
|
||||
@@ -50,97 +52,8 @@ struct _GtkCssParserBlock
|
||||
GtkCssTokenType alternative_token;
|
||||
};
|
||||
|
||||
#define GDK_ARRAY_NAME gtk_css_parser_blocks
|
||||
#define GDK_ARRAY_TYPE_NAME GtkCssParserBlocks
|
||||
#define GDK_ARRAY_ELEMENT_TYPE GtkCssParserBlock
|
||||
#define GDK_ARRAY_PREALLOC 12
|
||||
#define GDK_ARRAY_NO_MEMSET 1
|
||||
#include "gdk/gdkarrayimpl.c"
|
||||
|
||||
static inline GtkCssParserBlock *
|
||||
gtk_css_parser_blocks_get_last (GtkCssParserBlocks *blocks)
|
||||
{
|
||||
return gtk_css_parser_blocks_index (blocks, gtk_css_parser_blocks_get_size (blocks) - 1);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gtk_css_parser_blocks_drop_last (GtkCssParserBlocks *blocks)
|
||||
{
|
||||
gtk_css_parser_blocks_set_size (blocks, gtk_css_parser_blocks_get_size (blocks) - 1);
|
||||
}
|
||||
|
||||
typedef struct _GtkCssTokenizerData GtkCssTokenizerData;
|
||||
|
||||
struct _GtkCssTokenizerData
|
||||
{
|
||||
GtkCssTokenizer *tokenizer;
|
||||
char *var_name;
|
||||
GtkCssVariableValue *variable;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_tokenizer_data_clear (gpointer data)
|
||||
{
|
||||
GtkCssTokenizerData *td = data;
|
||||
|
||||
gtk_css_tokenizer_unref (td->tokenizer);
|
||||
if (td->var_name)
|
||||
g_free (td->var_name);
|
||||
if (td->variable)
|
||||
gtk_css_variable_value_unref (td->variable);
|
||||
}
|
||||
|
||||
#define GDK_ARRAY_NAME gtk_css_tokenizers
|
||||
#define GDK_ARRAY_TYPE_NAME GtkCssTokenizers
|
||||
#define GDK_ARRAY_ELEMENT_TYPE GtkCssTokenizerData
|
||||
#define GDK_ARRAY_FREE_FUNC gtk_css_tokenizer_data_clear
|
||||
#define GDK_ARRAY_BY_VALUE 1
|
||||
#define GDK_ARRAY_PREALLOC 16
|
||||
#define GDK_ARRAY_NO_MEMSET 1
|
||||
#include "gdk/gdkarrayimpl.c"
|
||||
|
||||
static inline GtkCssTokenizerData *
|
||||
gtk_css_tokenizers_get_last (GtkCssTokenizers *tokenizers)
|
||||
{
|
||||
return gtk_css_tokenizers_index (tokenizers, gtk_css_tokenizers_get_size (tokenizers) - 1);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gtk_css_tokenizers_drop_last (GtkCssTokenizers *tokenizers)
|
||||
{
|
||||
gtk_css_tokenizers_set_size (tokenizers, gtk_css_tokenizers_get_size (tokenizers) - 1);
|
||||
}
|
||||
|
||||
struct _GtkCssParser
|
||||
{
|
||||
volatile int ref_count;
|
||||
|
||||
GtkCssTokenizers tokenizers;
|
||||
GFile *file;
|
||||
GFile *directory;
|
||||
GtkCssParserErrorFunc error_func;
|
||||
gpointer user_data;
|
||||
GDestroyNotify user_destroy;
|
||||
|
||||
GtkCssParserBlocks blocks;
|
||||
GtkCssLocation location;
|
||||
GtkCssToken token;
|
||||
|
||||
GtkCssVariableValue **refs;
|
||||
gsize n_refs;
|
||||
gsize next_ref;
|
||||
gboolean var_fallback;
|
||||
};
|
||||
|
||||
static inline GtkCssTokenizer *
|
||||
get_tokenizer (GtkCssParser *self)
|
||||
{
|
||||
return gtk_css_tokenizers_get_last (&self->tokenizers)->tokenizer;
|
||||
}
|
||||
|
||||
static GtkCssParser *
|
||||
gtk_css_parser_new (GtkCssTokenizer *tokenizer,
|
||||
GtkCssVariableValue *value,
|
||||
GFile *file,
|
||||
GtkCssParserErrorFunc error_func,
|
||||
gpointer user_data,
|
||||
@@ -151,21 +64,17 @@ gtk_css_parser_new (GtkCssTokenizer *tokenizer,
|
||||
self = g_new0 (GtkCssParser, 1);
|
||||
|
||||
self->ref_count = 1;
|
||||
|
||||
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 });
|
||||
|
||||
self->tokenizer = gtk_css_tokenizer_ref (tokenizer);
|
||||
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->user_data = user_data;
|
||||
self->user_destroy = user_destroy;
|
||||
gtk_css_parser_blocks_init (&self->blocks);
|
||||
self->blocks = g_array_new (FALSE, FALSE, sizeof (GtkCssParserBlock));
|
||||
|
||||
return self;
|
||||
}
|
||||
@@ -200,50 +109,26 @@ gtk_css_parser_new_for_bytes (GBytes *bytes,
|
||||
{
|
||||
GtkCssTokenizer *tokenizer;
|
||||
GtkCssParser *result;
|
||||
|
||||
|
||||
tokenizer = gtk_css_tokenizer_new (bytes);
|
||||
result = gtk_css_parser_new (tokenizer, NULL, file, error_func, user_data, user_destroy);
|
||||
result = gtk_css_parser_new (tokenizer, file, error_func, user_data, user_destroy);
|
||||
gtk_css_tokenizer_unref (tokenizer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkCssParser *
|
||||
gtk_css_parser_new_for_token_stream (GtkCssVariableValue *value,
|
||||
GFile *file,
|
||||
GtkCssVariableValue **refs,
|
||||
gsize n_refs,
|
||||
GtkCssParserErrorFunc error_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy)
|
||||
{
|
||||
GtkCssTokenizer *tokenizer;
|
||||
GtkCssParser *result;
|
||||
|
||||
tokenizer = gtk_css_tokenizer_new_for_range (value->bytes, value->offset,
|
||||
value->end_offset - value->offset);
|
||||
result = gtk_css_parser_new (tokenizer, value, file, error_func, user_data, user_destroy);
|
||||
gtk_css_tokenizer_unref (tokenizer);
|
||||
|
||||
result->refs = refs;
|
||||
result->n_refs = n_refs;
|
||||
result->next_ref = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_parser_finalize (GtkCssParser *self)
|
||||
{
|
||||
if (self->user_destroy)
|
||||
self->user_destroy (self->user_data);
|
||||
|
||||
gtk_css_tokenizers_clear (&self->tokenizers);
|
||||
g_clear_pointer (&self->tokenizer, gtk_css_tokenizer_unref);
|
||||
g_clear_object (&self->file);
|
||||
g_clear_object (&self->directory);
|
||||
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
|
||||
g_critical ("Finalizing CSS parser with %lu remaining blocks", gtk_css_parser_blocks_get_size (&self->blocks));
|
||||
gtk_css_parser_blocks_clear (&self->blocks);
|
||||
if (self->blocks->len)
|
||||
g_critical ("Finalizing CSS parser with %u remaining blocks", self->blocks->len);
|
||||
g_array_free (self->blocks, TRUE);
|
||||
|
||||
g_free (self);
|
||||
}
|
||||
@@ -278,12 +163,6 @@ gtk_css_parser_get_file (GtkCssParser *self)
|
||||
return self->file;
|
||||
}
|
||||
|
||||
GBytes *
|
||||
gtk_css_parser_get_bytes (GtkCssParser *self)
|
||||
{
|
||||
return gtk_css_tokenizer_get_bytes (gtk_css_tokenizers_get (&self->tokenizers, 0)->tokenizer);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_css_parser_resolve_url:
|
||||
* @self: a `GtkCssParser`
|
||||
@@ -309,12 +188,7 @@ gtk_css_parser_resolve_url (GtkCssParser *self,
|
||||
}
|
||||
|
||||
if (self->directory == NULL)
|
||||
{
|
||||
if (self->file)
|
||||
self->directory = g_file_get_parent (self->file);
|
||||
if (self->directory == NULL)
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
return g_file_resolve_relative_path (self->directory, url);
|
||||
}
|
||||
@@ -365,7 +239,7 @@ gtk_css_parser_get_start_location (GtkCssParser *self)
|
||||
const GtkCssLocation *
|
||||
gtk_css_parser_get_end_location (GtkCssParser *self)
|
||||
{
|
||||
return gtk_css_tokenizer_get_location (get_tokenizer (self));
|
||||
return gtk_css_tokenizer_get_location (self->tokenizer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -385,13 +259,13 @@ gtk_css_parser_get_block_location (GtkCssParser *self)
|
||||
{
|
||||
const GtkCssParserBlock *block;
|
||||
|
||||
if (gtk_css_parser_blocks_get_size (&self->blocks) == 0)
|
||||
if (self->blocks->len == 0)
|
||||
{
|
||||
static const GtkCssLocation start_of_document = { 0, };
|
||||
return &start_of_document;
|
||||
}
|
||||
|
||||
block = gtk_css_parser_blocks_get_last (&self->blocks);
|
||||
block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
|
||||
return &block->start_location;
|
||||
}
|
||||
|
||||
@@ -399,14 +273,12 @@ static void
|
||||
gtk_css_parser_ensure_token (GtkCssParser *self)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GtkCssTokenizer *tokenizer;
|
||||
|
||||
if (!gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
|
||||
return;
|
||||
|
||||
tokenizer = get_tokenizer (self);
|
||||
self->location = *gtk_css_tokenizer_get_location (tokenizer);
|
||||
if (!gtk_css_tokenizer_read_token (tokenizer, &self->token, &error))
|
||||
self->location = *gtk_css_tokenizer_get_location (self->tokenizer);
|
||||
if (!gtk_css_tokenizer_read_token (self->tokenizer, &self->token, &error))
|
||||
{
|
||||
/* We ignore the error here, because the resulting token will
|
||||
* likely already trigger an error in the parsing code and
|
||||
@@ -414,49 +286,6 @@ gtk_css_parser_ensure_token (GtkCssParser *self)
|
||||
*/
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
if (gtk_css_tokenizers_get_size (&self->tokenizers) > 1 && gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
gtk_css_tokenizers_drop_last (&self->tokenizers);
|
||||
gtk_css_parser_ensure_token (self);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Resolve var(--name): skip it and insert the resolved reference instead */
|
||||
if (self->n_refs > 0 && gtk_css_token_is_function (&self->token, "var") && self->var_fallback == 0)
|
||||
{
|
||||
GtkCssVariableValue *ref;
|
||||
GtkCssTokenizer *ref_tokenizer;
|
||||
|
||||
gtk_css_parser_start_block (self);
|
||||
|
||||
g_assert (gtk_css_parser_has_token (self, GTK_CSS_TOKEN_IDENT));
|
||||
|
||||
char *var_name = gtk_css_parser_consume_ident (self);
|
||||
g_assert (var_name[0] == '-' && var_name[1] == '-');
|
||||
|
||||
/* If we encounter var() in a fallback when we can already resolve the
|
||||
* actual variable, skip it */
|
||||
self->var_fallback++;
|
||||
gtk_css_parser_skip (self);
|
||||
gtk_css_parser_end_block (self);
|
||||
self->var_fallback--;
|
||||
|
||||
g_assert (self->next_ref < self->n_refs);
|
||||
|
||||
ref = self->refs[self->next_ref++];
|
||||
ref_tokenizer = gtk_css_tokenizer_new_for_range (ref->bytes, ref->offset,
|
||||
ref->end_offset - ref->offset);
|
||||
gtk_css_tokenizers_append (&self->tokenizers,
|
||||
&(GtkCssTokenizerData) {
|
||||
ref_tokenizer,
|
||||
g_strdup (var_name),
|
||||
gtk_css_variable_value_ref (ref)
|
||||
});
|
||||
|
||||
gtk_css_parser_ensure_token (self);
|
||||
g_free (var_name);
|
||||
}
|
||||
}
|
||||
|
||||
const GtkCssToken *
|
||||
@@ -466,9 +295,9 @@ gtk_css_parser_peek_token (GtkCssParser *self)
|
||||
|
||||
gtk_css_parser_ensure_token (self);
|
||||
|
||||
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
|
||||
if (self->blocks->len)
|
||||
{
|
||||
const GtkCssParserBlock *block = gtk_css_parser_blocks_get_last (&self->blocks);
|
||||
const GtkCssParserBlock *block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
|
||||
if (gtk_css_token_is (&self->token, block->end_token) ||
|
||||
gtk_css_token_is (&self->token, block->inherited_end_token) ||
|
||||
gtk_css_token_is (&self->token, block->alternative_token))
|
||||
@@ -523,7 +352,7 @@ gtk_css_parser_start_block (GtkCssParser *self)
|
||||
block.inherited_end_token = GTK_CSS_TOKEN_EOF;
|
||||
block.alternative_token = GTK_CSS_TOKEN_EOF;
|
||||
block.start_location = self->location;
|
||||
gtk_css_parser_blocks_append (&self->blocks, block);
|
||||
g_array_append_val (self->blocks, block);
|
||||
|
||||
gtk_css_token_clear (&self->token);
|
||||
}
|
||||
@@ -535,13 +364,13 @@ gtk_css_parser_start_semicolon_block (GtkCssParser *self,
|
||||
GtkCssParserBlock block;
|
||||
|
||||
block.end_token = GTK_CSS_TOKEN_SEMICOLON;
|
||||
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
|
||||
block.inherited_end_token = gtk_css_parser_blocks_get_last (&self->blocks)->end_token;
|
||||
if (self->blocks->len)
|
||||
block.inherited_end_token = g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1).end_token;
|
||||
else
|
||||
block.inherited_end_token = GTK_CSS_TOKEN_EOF;
|
||||
block.alternative_token = alternative_token;
|
||||
block.start_location = self->location;
|
||||
gtk_css_parser_blocks_append (&self->blocks, block);
|
||||
g_array_append_val (self->blocks, block);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -549,9 +378,9 @@ gtk_css_parser_end_block_prelude (GtkCssParser *self)
|
||||
{
|
||||
GtkCssParserBlock *block;
|
||||
|
||||
g_return_if_fail (gtk_css_parser_blocks_get_size (&self->blocks) > 0);
|
||||
g_return_if_fail (self->blocks->len > 0);
|
||||
|
||||
block = gtk_css_parser_blocks_get_last (&self->blocks);
|
||||
block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
|
||||
|
||||
if (block->alternative_token == GTK_CSS_TOKEN_EOF)
|
||||
return;
|
||||
@@ -576,11 +405,11 @@ gtk_css_parser_end_block (GtkCssParser *self)
|
||||
{
|
||||
GtkCssParserBlock *block;
|
||||
|
||||
g_return_if_fail (gtk_css_parser_blocks_get_size (&self->blocks) > 0);
|
||||
g_return_if_fail (self->blocks->len > 0);
|
||||
|
||||
gtk_css_parser_skip_until (self, GTK_CSS_TOKEN_EOF);
|
||||
|
||||
block = gtk_css_parser_blocks_get_last (&self->blocks);
|
||||
block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
|
||||
|
||||
if (gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
@@ -589,7 +418,7 @@ gtk_css_parser_end_block (GtkCssParser *self)
|
||||
gtk_css_parser_get_block_location (self),
|
||||
gtk_css_parser_get_start_location (self),
|
||||
"Unterminated block at end of document");
|
||||
gtk_css_parser_blocks_drop_last (&self->blocks);
|
||||
g_array_set_size (self->blocks, self->blocks->len - 1);
|
||||
}
|
||||
else if (gtk_css_token_is (&self->token, block->inherited_end_token))
|
||||
{
|
||||
@@ -599,11 +428,11 @@ gtk_css_parser_end_block (GtkCssParser *self)
|
||||
gtk_css_parser_get_block_location (self),
|
||||
gtk_css_parser_get_start_location (self),
|
||||
"Expected ';' at end of block");
|
||||
gtk_css_parser_blocks_drop_last (&self->blocks);
|
||||
g_array_set_size (self->blocks, self->blocks->len - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_css_parser_blocks_drop_last (&self->blocks);
|
||||
g_array_set_size (self->blocks, self->blocks->len - 1);
|
||||
if (gtk_css_token_is_preserved (&self->token, NULL))
|
||||
{
|
||||
gtk_css_token_clear (&self->token);
|
||||
@@ -630,7 +459,7 @@ void
|
||||
gtk_css_parser_skip (GtkCssParser *self)
|
||||
{
|
||||
const GtkCssToken *token;
|
||||
|
||||
|
||||
token = gtk_css_parser_get_token (self);
|
||||
if (gtk_css_token_is_preserved (token, NULL))
|
||||
{
|
||||
@@ -663,7 +492,7 @@ gtk_css_parser_skip_until (GtkCssParser *self,
|
||||
GtkCssTokenType token_type)
|
||||
{
|
||||
const GtkCssToken *token;
|
||||
|
||||
|
||||
for (token = gtk_css_parser_get_token (self);
|
||||
!gtk_css_token_is (token, token_type) &&
|
||||
!gtk_css_token_is (token, GTK_CSS_TOKEN_EOF);
|
||||
@@ -673,19 +502,6 @@ gtk_css_parser_skip_until (GtkCssParser *self,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_parser_skip_whitespace (GtkCssParser *self)
|
||||
{
|
||||
const GtkCssToken *token;
|
||||
|
||||
for (token = gtk_css_parser_peek_token (self);
|
||||
gtk_css_token_is (token, GTK_CSS_TOKEN_WHITESPACE);
|
||||
token = gtk_css_parser_peek_token (self))
|
||||
{
|
||||
gtk_css_parser_consume_token (self);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_parser_emit_error (GtkCssParser *self,
|
||||
const GtkCssLocation *start,
|
||||
@@ -816,29 +632,6 @@ gtk_css_parser_warn_syntax (GtkCssParser *self,
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_parser_warn_deprecated (GtkCssParser *self,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
if (DEBUG_CHECK_CSS)
|
||||
{
|
||||
va_list args;
|
||||
GError *error;
|
||||
|
||||
va_start (args, format);
|
||||
error = g_error_new_valist (GTK_CSS_PARSER_WARNING,
|
||||
GTK_CSS_PARSER_WARNING_DEPRECATED,
|
||||
format, args);
|
||||
gtk_css_parser_emit_error (self,
|
||||
gtk_css_parser_get_start_location (self),
|
||||
gtk_css_parser_get_end_location (self),
|
||||
error);
|
||||
g_error_free (error);
|
||||
va_end (args);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_css_parser_consume_function (GtkCssParser *self,
|
||||
guint min_args,
|
||||
@@ -1160,7 +953,7 @@ gtk_css_parser_parse_url_arg (GtkCssParser *parser,
|
||||
*out_url = gtk_css_parser_consume_string (parser);
|
||||
if (*out_url == NULL)
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1206,7 +999,7 @@ gtk_css_parser_consume_url (GtkCssParser *self)
|
||||
gtk_css_parser_error_syntax (self, "Expected a URL");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
@@ -1319,325 +1112,3 @@ gtk_css_parser_consume_any (GtkCssParser *parser,
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_css_parser_has_references (GtkCssParser *self)
|
||||
{
|
||||
GtkCssTokenizer *tokenizer = get_tokenizer (self);
|
||||
gboolean ret = FALSE;
|
||||
int inner_blocks = 0, i;
|
||||
|
||||
/* We don't want gtk_css_parser_ensure_token to expand references on us here */
|
||||
g_assert (self->n_refs == 0);
|
||||
|
||||
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 done;
|
||||
}
|
||||
}
|
||||
|
||||
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 (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 (strlen (var_name) < 3 || var_name[0] != '-' || var_name[1] != '-')
|
||||
goto done;
|
||||
|
||||
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 done;
|
||||
|
||||
ret = TRUE;
|
||||
/* We got our answer. Now get it out as fast as possible! */
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_SEMICOLON) &&
|
||||
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_CLOSE_CURLY));
|
||||
|
||||
done:
|
||||
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 ret;
|
||||
}
|
||||
|
||||
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 (strlen (var_name) < 3 || var_name[0] != '-' || var_name[1] != '-')
|
||||
{
|
||||
gtk_css_parser_error_syntax (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);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
gtk_css_parser_error_syntax (self, "Missing variable name");
|
||||
}
|
||||
else
|
||||
{
|
||||
char *s = gtk_css_token_to_string (token);
|
||||
gtk_css_parser_error_syntax (self, "Expected a variable name, not %s", s);
|
||||
g_free (s);
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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,7 +22,6 @@
|
||||
|
||||
#include "gtkcssenums.h"
|
||||
#include "gtkcsstokenizerprivate.h"
|
||||
#include "gtkcssvariablevalueprivate.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
@@ -59,18 +58,10 @@ GtkCssParser * gtk_css_parser_new_for_bytes (GBytes
|
||||
GtkCssParserErrorFunc error_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy);
|
||||
GtkCssParser * gtk_css_parser_new_for_token_stream (GtkCssVariableValue *value,
|
||||
GFile *file,
|
||||
GtkCssVariableValue **refs,
|
||||
gsize n_refs,
|
||||
GtkCssParserErrorFunc error_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy);
|
||||
GtkCssParser * gtk_css_parser_ref (GtkCssParser *self);
|
||||
void gtk_css_parser_unref (GtkCssParser *self);
|
||||
|
||||
GFile * gtk_css_parser_get_file (GtkCssParser *self) G_GNUC_PURE;
|
||||
GBytes * gtk_css_parser_get_bytes (GtkCssParser *self) G_GNUC_PURE;
|
||||
GFile * gtk_css_parser_resolve_url (GtkCssParser *self,
|
||||
const char *url);
|
||||
|
||||
@@ -90,7 +81,6 @@ void gtk_css_parser_end_block (GtkCssParser
|
||||
void gtk_css_parser_skip (GtkCssParser *self);
|
||||
void gtk_css_parser_skip_until (GtkCssParser *self,
|
||||
GtkCssTokenType token_type);
|
||||
void gtk_css_parser_skip_whitespace (GtkCssParser *self);
|
||||
|
||||
void gtk_css_parser_emit_error (GtkCssParser *self,
|
||||
const GtkCssLocation *start,
|
||||
@@ -120,9 +110,6 @@ void gtk_css_parser_warn (GtkCssParser
|
||||
void gtk_css_parser_warn_syntax (GtkCssParser *self,
|
||||
const char *format,
|
||||
...) G_GNUC_PRINTF(2, 3);
|
||||
void gtk_css_parser_warn_deprecated (GtkCssParser *self,
|
||||
const char *format,
|
||||
...) G_GNUC_PRINTF(2, 3);
|
||||
|
||||
|
||||
gboolean gtk_css_parser_has_token (GtkCssParser *self,
|
||||
@@ -163,18 +150,5 @@ gsize gtk_css_parser_consume_any (GtkCssParser
|
||||
gsize n_options,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean gtk_css_parser_has_references (GtkCssParser *parser);
|
||||
|
||||
GtkCssVariableValue * gtk_css_parser_parse_value_into_token_stream (GtkCssParser *parser);
|
||||
|
||||
void gtk_css_parser_get_expanding_variables (GtkCssParser *parser,
|
||||
GtkCssVariableValue ***variables,
|
||||
char ***names,
|
||||
gsize *n_variables);
|
||||
|
||||
|
||||
/* We cannot include gtkdebug.h, so we must keep this in sync */
|
||||
#define GTK_CSS_PARSER_DEBUG_CSS (1 << 20)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+1
-49
@@ -26,7 +26,6 @@ struct _GtkCssSection
|
||||
int ref_count;
|
||||
GtkCssSection *parent;
|
||||
GFile *file;
|
||||
GBytes *bytes;
|
||||
GtkCssLocation start_location;
|
||||
GtkCssLocation end_location; /* end location if parser is %NULL */
|
||||
};
|
||||
@@ -49,30 +48,6 @@ GtkCssSection *
|
||||
gtk_css_section_new (GFile *file,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end)
|
||||
{
|
||||
return gtk_css_section_new_with_bytes (file, NULL,start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_css_section_new_with_bytes: (constructor)
|
||||
* @file: (nullable) (transfer none): The file this section refers to
|
||||
* @bytes: (nullable) (transfer none): The bytes this sections refers to
|
||||
* @start: The start location
|
||||
* @end: The end location
|
||||
*
|
||||
* Creates a new `GtkCssSection` referring to the section
|
||||
* in the given `file` or the given `bytes` from the `start` location to the
|
||||
* `end` location.
|
||||
*
|
||||
* Returns: (transfer full): a new `GtkCssSection`
|
||||
*
|
||||
* Since: 4.16
|
||||
**/
|
||||
GtkCssSection *
|
||||
gtk_css_section_new_with_bytes (GFile *file,
|
||||
GBytes *bytes,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end)
|
||||
{
|
||||
GtkCssSection *result;
|
||||
|
||||
@@ -85,8 +60,6 @@ gtk_css_section_new_with_bytes (GFile *file,
|
||||
result->ref_count = 1;
|
||||
if (file)
|
||||
result->file = g_object_ref (file);
|
||||
if (bytes)
|
||||
result->bytes = g_bytes_ref (bytes);
|
||||
result->start_location = *start;
|
||||
result->end_location = *end;
|
||||
|
||||
@@ -131,8 +104,6 @@ gtk_css_section_unref (GtkCssSection *section)
|
||||
gtk_css_section_unref (section->parent);
|
||||
if (section->file)
|
||||
g_object_unref (section->file);
|
||||
if (section->bytes)
|
||||
g_bytes_unref (section->bytes);
|
||||
|
||||
g_free (section);
|
||||
}
|
||||
@@ -180,25 +151,6 @@ gtk_css_section_get_file (const GtkCssSection *section)
|
||||
return section->file;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_css_section_get_bytes:
|
||||
* @section: the section
|
||||
*
|
||||
* Gets the bytes that @section was parsed from.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the `GBytes` from which the `section`
|
||||
* was parsed
|
||||
*
|
||||
* Since: 4.16
|
||||
**/
|
||||
GBytes *
|
||||
gtk_css_section_get_bytes (const GtkCssSection *section)
|
||||
{
|
||||
g_return_val_if_fail (section != NULL, NULL);
|
||||
|
||||
return section->bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_css_section_get_start_location:
|
||||
* @section: the section
|
||||
@@ -268,7 +220,7 @@ gtk_css_section_print (const GtkCssSection *section,
|
||||
g_string_append (string, "<data>");
|
||||
}
|
||||
|
||||
g_string_append_printf (string, ":%zu:%zu",
|
||||
g_string_append_printf (string, ":%zu:%zu",
|
||||
section->start_location.lines + 1,
|
||||
section->start_location.line_chars + 1);
|
||||
if (section->start_location.lines != section->end_location.lines ||
|
||||
|
||||
@@ -46,11 +46,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
GtkCssSection * gtk_css_section_new (GFile *file,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end);
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GtkCssSection * gtk_css_section_new_with_bytes (GFile *file,
|
||||
GBytes *bytes,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkCssSection * gtk_css_section_ref (GtkCssSection *section);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
@@ -66,8 +61,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
GtkCssSection * gtk_css_section_get_parent (const GtkCssSection *section);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GFile * gtk_css_section_get_file (const GtkCssSection *section);
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GBytes * gtk_css_section_get_bytes (const GtkCssSection *section);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GtkCssLocation *
|
||||
gtk_css_section_get_start_location (const GtkCssSection *section);
|
||||
|
||||
@@ -36,9 +36,6 @@ struct _GtkCssTokenizer
|
||||
const char *end;
|
||||
|
||||
GtkCssLocation position;
|
||||
|
||||
GtkCssLocation saved_position;
|
||||
const char *saved_data;
|
||||
};
|
||||
|
||||
void
|
||||
@@ -571,14 +568,6 @@ gtk_css_token_init_dimension (GtkCssToken *token,
|
||||
|
||||
GtkCssTokenizer *
|
||||
gtk_css_tokenizer_new (GBytes *bytes)
|
||||
{
|
||||
return gtk_css_tokenizer_new_for_range (bytes, 0, g_bytes_get_size (bytes));
|
||||
}
|
||||
|
||||
GtkCssTokenizer *
|
||||
gtk_css_tokenizer_new_for_range (GBytes *bytes,
|
||||
gsize offset,
|
||||
gsize length)
|
||||
{
|
||||
GtkCssTokenizer *tokenizer;
|
||||
|
||||
@@ -587,8 +576,8 @@ gtk_css_tokenizer_new_for_range (GBytes *bytes,
|
||||
tokenizer->bytes = g_bytes_ref (bytes);
|
||||
tokenizer->name_buffer = g_string_new (NULL);
|
||||
|
||||
tokenizer->data = g_bytes_get_region (bytes, 1, offset, length);
|
||||
tokenizer->end = tokenizer->data + length;
|
||||
tokenizer->data = g_bytes_get_data (bytes, NULL);
|
||||
tokenizer->end = tokenizer->data + g_bytes_get_size (bytes);
|
||||
|
||||
gtk_css_location_init (&tokenizer->position);
|
||||
|
||||
@@ -615,12 +604,6 @@ gtk_css_tokenizer_unref (GtkCssTokenizer *tokenizer)
|
||||
g_free (tokenizer);
|
||||
}
|
||||
|
||||
GBytes *
|
||||
gtk_css_tokenizer_get_bytes (GtkCssTokenizer *tokenizer)
|
||||
{
|
||||
return tokenizer->bytes;
|
||||
}
|
||||
|
||||
const GtkCssLocation *
|
||||
gtk_css_tokenizer_get_location (GtkCssTokenizer *tokenizer)
|
||||
{
|
||||
@@ -1501,23 +1484,3 @@ 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,22 +138,15 @@ void gtk_css_token_print (const GtkCssTok
|
||||
char * gtk_css_token_to_string (const GtkCssToken *token);
|
||||
|
||||
GtkCssTokenizer * gtk_css_tokenizer_new (GBytes *bytes);
|
||||
GtkCssTokenizer * gtk_css_tokenizer_new_for_range (GBytes *bytes,
|
||||
gsize offset,
|
||||
gsize length);
|
||||
|
||||
GtkCssTokenizer * gtk_css_tokenizer_ref (GtkCssTokenizer *tokenizer);
|
||||
void gtk_css_tokenizer_unref (GtkCssTokenizer *tokenizer);
|
||||
|
||||
GBytes * gtk_css_tokenizer_get_bytes (GtkCssTokenizer *tokenizer);
|
||||
const GtkCssLocation * gtk_css_tokenizer_get_location (GtkCssTokenizer *tokenizer) G_GNUC_CONST;
|
||||
|
||||
gboolean gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer,
|
||||
GtkCssToken *token,
|
||||
GError **error);
|
||||
|
||||
void gtk_css_tokenizer_save (GtkCssTokenizer *tokenizer);
|
||||
void gtk_css_tokenizer_restore (GtkCssTokenizer *tokenizer);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
+1
-2
@@ -6,9 +6,8 @@ gtk_css_public_sources = files([
|
||||
gtk_css_private_sources = files([
|
||||
'gtkcssdataurl.c',
|
||||
'gtkcssparser.c',
|
||||
'gtkcssserializer.c',
|
||||
'gtkcsstokenizer.c',
|
||||
'gtkcssvariablevalue.c',
|
||||
'gtkcssserializer.c',
|
||||
])
|
||||
|
||||
gtk_css_public_headers = files([
|
||||
|
||||
@@ -689,11 +689,6 @@ gtk_cell_renderer_progress_class_init (GtkCellRendererProgressClass *klass)
|
||||
PROP_ORIENTATION,
|
||||
"orientation");
|
||||
|
||||
/**
|
||||
* GtkCellRendererProgress:inverted:
|
||||
*
|
||||
* Whether progess is inverted.
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_INVERTED,
|
||||
g_param_spec_boolean ("inverted", NULL, NULL,
|
||||
|
||||
@@ -175,8 +175,7 @@ gtk_cell_renderer_spinner_class_init (GtkCellRendererSpinnerClass *klass)
|
||||
cell_class->get_preferred_height = gtk_cell_renderer_spinner_get_preferred_height;
|
||||
cell_class->snapshot = gtk_cell_renderer_spinner_snapshot;
|
||||
|
||||
/**
|
||||
* GtkCellRendererSpinner:active:
|
||||
/* GtkCellRendererSpinner:active:
|
||||
*
|
||||
* Whether the spinner is active (ie. shown) in the cell
|
||||
*/
|
||||
@@ -254,7 +253,7 @@ gtk_cell_renderer_spinner_update_size (GtkCellRendererSpinner *cell,
|
||||
node = gtk_style_context_get_node (context);
|
||||
gtk_icon_size_set_style_classes (node, priv->icon_size);
|
||||
style = gtk_css_node_get_style (node);
|
||||
priv->size = gtk_css_number_value_get (style->icon->icon_size, 100);
|
||||
priv->size = _gtk_css_number_value_get (style->icon->icon_size, 100);
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ static int
|
||||
calc_indicator_size (GtkStyleContext *context)
|
||||
{
|
||||
GtkCssStyle *style = gtk_style_context_lookup_style (context);
|
||||
return gtk_css_number_value_get (style->icon->icon_size, 100);
|
||||
return _gtk_css_number_value_get (style->icon->icon_size, 100);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user