Compare commits
7 Commits
glyphy-no-
...
gridview-s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac03248334 | ||
|
|
2dcda12369 | ||
|
|
7eb2de05a0 | ||
|
|
dda24956a1 | ||
|
|
243914ff6a | ||
|
|
7fd42c4a05 | ||
|
|
b6d0a04199 |
@@ -222,7 +222,7 @@ macos:
|
||||
-Dcpp_std=c++11
|
||||
-Dpixman:tests=disabled
|
||||
-Dlibjpeg-turbo:simd=disabled
|
||||
-Dbuild-demos=false
|
||||
-Ddemos=false
|
||||
-Dbuild-tests=false
|
||||
-Dbuild-examples=false
|
||||
-Dbuild-testsuite=false
|
||||
@@ -385,27 +385,17 @@ asan-build:
|
||||
tags: [ asan ]
|
||||
stage: analysis
|
||||
needs: []
|
||||
when: manual
|
||||
variables:
|
||||
script:
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- CC=clang meson setup
|
||||
--buildtype=debugoptimized
|
||||
-Db_sanitize=address
|
||||
-Db_lundef=false
|
||||
-Dbuild-demos=false
|
||||
-Dbuild-tests=false
|
||||
-Dbuild-examples=false
|
||||
-Dintrospection=disabled
|
||||
-Df16c=disabled
|
||||
_build
|
||||
- CC=clang meson setup --buildtype=debugoptimized -Db_sanitize=address -Db_lundef=false -Dintrospection=disabled -Df16c=disabled _build
|
||||
- ninja -C _build
|
||||
- .gitlab-ci/run-tests.sh _build wayland
|
||||
- .gitlab-ci/run-tests.sh _build wayland_gles
|
||||
- .gitlab-ci/run-tests.sh _build x11
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- "${CI_PROJECT_DIR}/_build/meson-logs"
|
||||
- _build/meson-logs
|
||||
allow_failure: true
|
||||
|
||||
reference:
|
||||
image: $FEDORA_IMAGE
|
||||
|
||||
@@ -23,8 +23,8 @@ flatpak build ${builddir} meson \
|
||||
-Dbuild-testsuite=false \
|
||||
-Dbuild-examples=false \
|
||||
-Dintrospection=disabled \
|
||||
-Dbuild-demos=true \
|
||||
-Ddemo-profile=devel \
|
||||
-Ddemos=true \
|
||||
-Dprofile=devel \
|
||||
_flatpak_build
|
||||
|
||||
flatpak build ${builddir} ninja -C _flatpak_build install
|
||||
|
||||
@@ -9,7 +9,7 @@ backend=$2
|
||||
multiplier=${MESON_TEST_TIMEOUT_MULTIPLIER:-1}
|
||||
|
||||
# Ignore memory leaks lower in dependencies
|
||||
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0:detect_leaks=0:allocator_may_return_null=1
|
||||
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0:verbosity=1:log_threads=1
|
||||
export G_SLICE=always-malloc
|
||||
|
||||
case "${backend}" in
|
||||
|
||||
125
NEWS
125
NEWS
@@ -1,93 +1,4 @@
|
||||
Overview of Changes in 4.11.5, xx-xx-xxxx
|
||||
=========================================
|
||||
|
||||
Overview of Changes in 4.11.4, 03-07-2023
|
||||
=========================================
|
||||
|
||||
* GtkFileChooser:
|
||||
- Default to sorting folders first
|
||||
- Fix a crash when visiting recent files
|
||||
|
||||
* GtkTextView:
|
||||
- Fix corner cases in word navigation
|
||||
|
||||
* GtkMenuButton:
|
||||
- Normalize label layout
|
||||
|
||||
* GtkDropDown:
|
||||
- Add support for sections
|
||||
|
||||
* GtkVideo:
|
||||
- Make the overlay icon clickable
|
||||
|
||||
* GtkWindow:
|
||||
- Clear the resize cursors to avoid artifacts
|
||||
|
||||
* GtkFileDialog:
|
||||
- Always set initial-folder
|
||||
|
||||
* GtkDropDown:
|
||||
- Update on expression changes
|
||||
|
||||
* GtkMapListModel:
|
||||
- Implement GtkSectionModel
|
||||
|
||||
* Accessibility:
|
||||
- Improvements all over the place: GtkButton, GtkPasswordEntry,
|
||||
GtkFontChooserDialog, GtkColorChooserDialog, GtkShortcutsWindow,
|
||||
GtkMenuButton, GtkAboutDialog, GtkFileChooserDialog, GtkStackSidebar,
|
||||
GtkStackSwitcher, GtkMediaControls, GtkColorDialogButton, GtkDropDown,
|
||||
GtkInfoBar, GtkNotebook, GtkPrintUnixDialog, GtkModelButton
|
||||
- Make name computation follow the ARIA spec more closely
|
||||
- Adapt name computation for the common 'nested button' scenario
|
||||
- Change many containers to use `generic` instead of `group`
|
||||
- Use `generic` as the default role
|
||||
- Use `application` instead of `window` for windows
|
||||
- Add properties for accessible names of not directly exposed
|
||||
widgets in GtkListView, GtkGridView and GtkColumnView
|
||||
|
||||
* DND:
|
||||
- Fix criticals when drops are rejected
|
||||
|
||||
* X11:
|
||||
- Fix regressions in GLX setup
|
||||
|
||||
* Windows:
|
||||
- Center newly created transient windows
|
||||
|
||||
* Vulkan:
|
||||
- Add antialising for gradients
|
||||
- Do less work on clipped away nodes
|
||||
- Redo image uploading
|
||||
- Support different image depths and formats
|
||||
- Add a pipeline cache
|
||||
|
||||
* Demos:
|
||||
- gtk4-demo: Improve window sizing
|
||||
- gtk4-demo: Improve focus behavior
|
||||
- gtk4-demo: Add many missing a11y properties
|
||||
|
||||
* Tools:
|
||||
- gtk4-builder-tool: Make render an alias screenshot
|
||||
|
||||
* Inspector:
|
||||
- Show more information in the a11y tab
|
||||
- Add an accessibility overlay with warnings and recommendations
|
||||
- Limit the width of the a11y tab
|
||||
|
||||
* Build:
|
||||
- Require GLib 2.76
|
||||
- Make asan builds work again
|
||||
- Fix the build if ld is not ld.bdf
|
||||
|
||||
* Translation updates:
|
||||
Brazilian Portuguese
|
||||
Catalan
|
||||
Czech
|
||||
Georgian
|
||||
|
||||
|
||||
Overview of Changes in 4.11.3, 05-06-2023
|
||||
Overview of Changes in 4.11.3, xx-xx-xxxx
|
||||
=========================================
|
||||
|
||||
* GtkGridView:
|
||||
@@ -97,9 +8,6 @@ Overview of Changes in 4.11.3, 05-06-2023
|
||||
* GtkListView:
|
||||
- Don't leak the factories
|
||||
|
||||
* GtkColumnView:
|
||||
- Support displaying sections
|
||||
|
||||
* GtkNotebook:
|
||||
- Make the pages model implement GtkSelectionModel
|
||||
|
||||
@@ -109,41 +17,18 @@ Overview of Changes in 4.11.3, 05-06-2023
|
||||
* GtkPopoverMenu:
|
||||
- Avoid unnecessary left padding
|
||||
|
||||
* GtkSearchEntry:
|
||||
- Improve size allocation for the clear icon
|
||||
|
||||
* GtkBoxLayout:
|
||||
- Fix a regression from recent baseline work
|
||||
|
||||
* CSS:
|
||||
* Css:
|
||||
- Add new binding-friendly css provider apis
|
||||
|
||||
* Theme:
|
||||
- Show focus in the shortcuts window
|
||||
|
||||
* GDK:
|
||||
- Support grayscale and alpha texture formats for loading
|
||||
and saving to png and tiff, and in GL
|
||||
- Fix some regressions in GL context initialization
|
||||
|
||||
* GSK:
|
||||
- Support grayscale and alpha texture formats in the GL renderer
|
||||
- Support straight alpha textures in the GL renderer
|
||||
- Many improvements to the experimental Vulkan renderer
|
||||
* Tests:
|
||||
- Improve test coverage
|
||||
|
||||
* Wayland:
|
||||
- Make exporting surface handles more flexible
|
||||
|
||||
* X11:
|
||||
- Trap XRandr errors
|
||||
- Stop using passive grabs during DND
|
||||
|
||||
* Windows:
|
||||
- Many cleanups and simplifications
|
||||
|
||||
* Tests:
|
||||
- Improve test coverage
|
||||
|
||||
* Build:
|
||||
- Some build options have been renamed:
|
||||
demos -> build-demos
|
||||
@@ -163,9 +48,7 @@ Overview of Changes in 4.11.3, 05-06-2023
|
||||
* Translation updates:
|
||||
Basque
|
||||
Catalan
|
||||
Georgian
|
||||
Russian
|
||||
Turkish
|
||||
|
||||
|
||||
Overview of Changes in 4.11.2, 09-05-2023
|
||||
|
||||
@@ -162,10 +162,6 @@ create_page4 (GtkWidget *assistant)
|
||||
gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), progress_bar, GTK_ASSISTANT_PAGE_PROGRESS);
|
||||
gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), progress_bar, "Applying changes");
|
||||
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (progress_bar),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Applying changes",
|
||||
-1);
|
||||
|
||||
/* This prevents the assistant window from being
|
||||
* closed while we're "busy" applying changes.
|
||||
*/
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="resizable">1</property>
|
||||
<property name="title">Clipboard</property>
|
||||
<accessibility>
|
||||
<relation name="described-by">label</relation>
|
||||
</accessibility>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
@@ -16,7 +13,7 @@
|
||||
<property name="margin-bottom">12</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">“Copy” will copy the selected data the clipboard, “Paste” will show the current clipboard contents. You can also drag the data to the bottom.</property>
|
||||
<property name="wrap">1</property>
|
||||
<property name="max-width-chars">40</property>
|
||||
@@ -27,9 +24,6 @@
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkDropDown" id="source_chooser">
|
||||
<accessibility>
|
||||
<property name="label">Source Type</property>
|
||||
</accessibility>
|
||||
<property name="valign">center</property>
|
||||
<property name="model">
|
||||
<object class="GtkStringList">
|
||||
@@ -60,9 +54,6 @@
|
||||
<property name="name">Text</property>
|
||||
<property name="child">
|
||||
<object class="GtkEntry" id="source_text">
|
||||
<accessibility>
|
||||
<property name="label">Text Drag Source</property>
|
||||
</accessibility>
|
||||
<property name="valign">center</property>
|
||||
<signal name="notify::text" handler="text_changed_cb" object="copy_button"/>
|
||||
<property name="text">Copy this!</property>
|
||||
@@ -75,9 +66,6 @@
|
||||
<property name="name">Color</property>
|
||||
<property name="child">
|
||||
<object class="GtkColorDialogButton" id="source_color">
|
||||
<accessibility>
|
||||
<property name="label">Color Drag Source</property>
|
||||
</accessibility>
|
||||
<property name="dialog">
|
||||
<object class="GtkColorDialog">
|
||||
</object>
|
||||
@@ -99,17 +87,14 @@
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="image_rose">
|
||||
<accessibility>
|
||||
<property name="label">Photo Drag Source</property>
|
||||
</accessibility>
|
||||
<property name="active">1</property>
|
||||
<child>
|
||||
<object class="GtkDragSource">
|
||||
<signal name="prepare" handler="drag_prepare"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<accessibility>
|
||||
<property name="label">Portland Rose Photo</property>
|
||||
</accessibility>
|
||||
<style>
|
||||
<class name="large-icons"/>
|
||||
</style>
|
||||
@@ -120,9 +105,6 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="image_floppy">
|
||||
<accessibility>
|
||||
<property name="label">Icon Drag Source</property>
|
||||
</accessibility>
|
||||
<property name="group">image_rose</property>
|
||||
<child>
|
||||
<object class="GtkDragSource">
|
||||
@@ -131,9 +113,6 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<accessibility>
|
||||
<property name="label">Floppy Buddy Icon</property>
|
||||
</accessibility>
|
||||
<style>
|
||||
<class name="large-icons"/>
|
||||
</style>
|
||||
@@ -144,9 +123,6 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="image_logo">
|
||||
<accessibility>
|
||||
<property name="label">SVG Drag Source</property>
|
||||
</accessibility>
|
||||
<property name="group">image_floppy</property>
|
||||
<child>
|
||||
<object class="GtkDragSource">
|
||||
@@ -155,9 +131,6 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<accessibility>
|
||||
<property name="label">gtk-demo logo</property>
|
||||
</accessibility>
|
||||
<style>
|
||||
<class name="large-icons"/>
|
||||
</style>
|
||||
@@ -175,9 +148,6 @@
|
||||
<property name="name">File</property>
|
||||
<property name="child">
|
||||
<object class="GtkButton" id="source_file">
|
||||
<accessibility>
|
||||
<property name="label">File Drag Source</property>
|
||||
</accessibility>
|
||||
<child>
|
||||
<object class="GtkDragSource">
|
||||
<property name="propagation-phase">capture</property>
|
||||
@@ -202,9 +172,6 @@
|
||||
<property name="name">Folder</property>
|
||||
<property name="child">
|
||||
<object class="GtkButton" id="source_folder">
|
||||
<accessibility>
|
||||
<property name="label">Folder Drag Source</property>
|
||||
</accessibility>
|
||||
<child>
|
||||
<object class="GtkDragSource">
|
||||
<property name="propagation-phase">capture</property>
|
||||
@@ -258,7 +225,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="paste_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<lookup name="visible-child-name" type="GtkStack">
|
||||
@@ -285,9 +252,6 @@
|
||||
<property name="name">Text</property>
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<accessibility>
|
||||
<relation name="labelled-by">paste_label</relation>
|
||||
</accessibility>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="xalign">0</property>
|
||||
@@ -301,9 +265,6 @@
|
||||
<property name="name">Image</property>
|
||||
<property name="child">
|
||||
<object class="GtkImage">
|
||||
<accessibility>
|
||||
<relation name="labelled-by">paste_label</relation>
|
||||
</accessibility>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<style>
|
||||
@@ -322,9 +283,6 @@
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkColorSwatch">
|
||||
<accessibility>
|
||||
<relation name="labelled-by">paste_label</relation>
|
||||
</accessibility>
|
||||
<property name="accessible-role">img</property>
|
||||
<property name="can-focus">0</property>
|
||||
<property name="selectable">0</property>
|
||||
@@ -340,9 +298,6 @@
|
||||
<property name="name">File</property>
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<accessibility>
|
||||
<relation name="labelled-by">paste_label</relation>
|
||||
</accessibility>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="xalign">0</property>
|
||||
|
||||
@@ -387,8 +387,6 @@ demo3_widget_class_init (Demo3WidgetClass *class)
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/menu/demo3widget.ui");
|
||||
gtk_widget_class_bind_template_child (widget_class, Demo3Widget, menu);
|
||||
gtk_widget_class_bind_template_callback (widget_class, pressed_cb);
|
||||
|
||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_IMG);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
||||
@@ -19,14 +19,8 @@
|
||||
</item>
|
||||
</menu>
|
||||
<template class="Demo3Widget">
|
||||
<accessibility>
|
||||
<property name="label">Demo image</property>
|
||||
</accessibility>
|
||||
<child>
|
||||
<object class="GtkPopoverMenu" id="menu">
|
||||
<accessibility>
|
||||
<property name="label">Context menu</property>
|
||||
</accessibility>
|
||||
<property name="has-arrow">0</property>
|
||||
<property name="menu-model">model</property>
|
||||
</object>
|
||||
|
||||
@@ -162,39 +162,27 @@ click_done (GtkGesture *gesture)
|
||||
gtk_widget_insert_after (item, canvas, last_child);
|
||||
}
|
||||
|
||||
/* GtkSettings treats `GTK_THEME=foo:dark` as theme name `foo`, variant `dark`,
|
||||
* and our embedded CSS files let `foo-dark` work as an alias for `foo:dark`. */
|
||||
static gboolean
|
||||
has_dark_suffix (const char *theme)
|
||||
{
|
||||
return g_str_has_suffix (theme, ":dark") ||
|
||||
g_str_has_suffix (theme, "-dark");
|
||||
}
|
||||
|
||||
/* So we can make a good guess whether the current theme is dark by checking for
|
||||
* either: it is suffixed `[:-]dark`, or Settings:…prefer-dark-theme is TRUE. */
|
||||
static gboolean
|
||||
theme_is_dark (void)
|
||||
{
|
||||
const char *env_theme;
|
||||
GtkSettings *settings;
|
||||
char *theme;
|
||||
gboolean prefer_dark;
|
||||
gboolean dark;
|
||||
|
||||
/* Like GtkSettings, 1st see if theme is overridden by environment variable */
|
||||
env_theme = g_getenv ("GTK_THEME");
|
||||
if (env_theme != NULL)
|
||||
return has_dark_suffix (env_theme);
|
||||
|
||||
/* If not, test Settings:…theme-name in the same way OR :…prefer-dark-theme */
|
||||
settings = gtk_settings_get_default ();
|
||||
g_object_get (settings,
|
||||
"gtk-theme-name", &theme,
|
||||
"gtk-application-prefer-dark-theme", &prefer_dark,
|
||||
NULL);
|
||||
dark = prefer_dark || has_dark_suffix (theme);
|
||||
|
||||
if ((strcmp (theme, "Adwaita") == 0 && prefer_dark) || strcmp (theme, "HighContrastInverse") == 0)
|
||||
dark = TRUE;
|
||||
else
|
||||
dark = FALSE;
|
||||
|
||||
g_free (theme);
|
||||
|
||||
return dark;
|
||||
}
|
||||
|
||||
|
||||
@@ -334,17 +334,11 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
gtk_widget_set_vexpand (frame, TRUE);
|
||||
gtk_box_append (GTK_BOX (vbox), frame);
|
||||
|
||||
da = g_object_new (GTK_TYPE_DRAWING_AREA,
|
||||
"accessible-role", GTK_ACCESSIBLE_ROLE_IMG,
|
||||
NULL);
|
||||
gtk_frame_set_child (GTK_FRAME (frame), da);
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (da),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
|
||||
da = gtk_drawing_area_new ();
|
||||
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (da), 100);
|
||||
gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (da), 100);
|
||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), groups_draw, NULL, NULL);
|
||||
gtk_frame_set_child (GTK_FRAME (frame), da);
|
||||
|
||||
/*
|
||||
* Create the scribble area
|
||||
@@ -358,17 +352,11 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
gtk_widget_set_vexpand (frame, TRUE);
|
||||
gtk_box_append (GTK_BOX (vbox), frame);
|
||||
|
||||
da = g_object_new (GTK_TYPE_DRAWING_AREA,
|
||||
"accessible-role", GTK_ACCESSIBLE_ROLE_IMG,
|
||||
NULL);
|
||||
gtk_frame_set_child (GTK_FRAME (frame), da);
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (da),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
|
||||
da = gtk_drawing_area_new ();
|
||||
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (da), 100);
|
||||
gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (da), 100);
|
||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), scribble_draw, NULL, NULL);
|
||||
gtk_frame_set_child (GTK_FRAME (frame), da);
|
||||
|
||||
g_signal_connect (da, "resize",
|
||||
G_CALLBACK (scribble_resize), NULL);
|
||||
@@ -384,7 +372,7 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
||||
@@ -95,13 +95,6 @@ do_entry_completion (GtkWidget *do_widget)
|
||||
entry = gtk_entry_new ();
|
||||
gtk_box_append (GTK_BOX (vbox), entry);
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (entry),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (entry),
|
||||
GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE, GTK_ACCESSIBLE_AUTOCOMPLETE_LIST,
|
||||
-1);
|
||||
|
||||
/* Create the completion object */
|
||||
completion = gtk_entry_completion_new ();
|
||||
|
||||
|
||||
@@ -43,10 +43,6 @@ do_entry_undo (GtkWidget *do_widget)
|
||||
entry = gtk_entry_new ();
|
||||
gtk_editable_set_enable_undo (GTK_EDITABLE (entry), TRUE);
|
||||
gtk_box_append (GTK_BOX (vbox), entry);
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (entry),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
||||
@@ -22,15 +22,11 @@ validate_more_details (GtkEntry *entry,
|
||||
{
|
||||
gtk_widget_set_tooltip_text (GTK_WIDGET (entry), "Must have details first");
|
||||
gtk_widget_add_css_class (GTK_WIDGET (entry), "error");
|
||||
gtk_accessible_update_state (GTK_ACCESSIBLE (entry),
|
||||
GTK_ACCESSIBLE_STATE_INVALID, GTK_ACCESSIBLE_INVALID_TRUE,
|
||||
-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_tooltip_text (GTK_WIDGET (entry), "");
|
||||
gtk_widget_remove_css_class (GTK_WIDGET (entry), "error");
|
||||
gtk_accessible_reset_state (GTK_ACCESSIBLE (entry), GTK_ACCESSIBLE_STATE_INVALID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,18 +44,10 @@ mode_switch_state_set (GtkSwitch *sw,
|
||||
{
|
||||
gtk_widget_set_visible (label, FALSE);
|
||||
gtk_switch_set_state (sw, state);
|
||||
gtk_accessible_reset_relation (GTK_ACCESSIBLE (sw), GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE);
|
||||
gtk_accessible_reset_state (GTK_ACCESSIBLE (sw), GTK_ACCESSIBLE_STATE_INVALID);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_visible (label, TRUE);
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (sw),
|
||||
GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE, label,
|
||||
-1);
|
||||
gtk_accessible_update_state (GTK_ACCESSIBLE (sw),
|
||||
GTK_ACCESSIBLE_STATE_INVALID, GTK_ACCESSIBLE_INVALID_TRUE,
|
||||
-1);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -85,9 +73,6 @@ level_scale_value_changed (GtkRange *range,
|
||||
{
|
||||
gtk_switch_set_state (GTK_SWITCH (sw), FALSE);
|
||||
}
|
||||
|
||||
gtk_accessible_reset_relation (GTK_ACCESSIBLE (sw), GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE);
|
||||
gtk_accessible_reset_state (GTK_ACCESSIBLE (sw), GTK_ACCESSIBLE_STATE_INVALID);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
||||
@@ -59,9 +59,6 @@
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkFontDialogButton" id="font">
|
||||
<accessibility>
|
||||
<property name="label">Font</property>
|
||||
</accessibility>
|
||||
<property name="dialog">
|
||||
<object class="GtkFontDialog">
|
||||
</object>
|
||||
@@ -76,7 +73,7 @@
|
||||
<property name="column-spacing">10</property>
|
||||
<property name="row-spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="size_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Size</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
@@ -92,9 +89,6 @@
|
||||
<property name="width-request">100</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="adjustment">size_adjustment</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">size_label</relation>
|
||||
</accessibility>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">0</property>
|
||||
@@ -107,9 +101,6 @@
|
||||
<property name="max-width-chars">4</property>
|
||||
<property name="hexpand">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">size_label</relation>
|
||||
</accessibility>
|
||||
<signal name="activate" handler="basic_entry_activated"
|
||||
object="size_adjustment" swapped="false"/>
|
||||
<layout>
|
||||
@@ -119,7 +110,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="letterspacing_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Letterspacing</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
@@ -135,9 +126,6 @@
|
||||
<property name="width-request">100</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="adjustment">letterspacing_adjustment</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">letterspacing_label</relation>
|
||||
</accessibility>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">1</property>
|
||||
@@ -150,9 +138,6 @@
|
||||
<property name="max-width-chars">4</property>
|
||||
<property name="hexpand">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">letterspacing_label</relation>
|
||||
</accessibility>
|
||||
<signal name="activate" handler="basic_entry_activated"
|
||||
object="letterspacing_adjustment" swapped="false"/>
|
||||
<layout>
|
||||
@@ -162,7 +147,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="line_height_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Line Height</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
@@ -178,9 +163,6 @@
|
||||
<property name="width-request">100</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="adjustment">line_height_adjustment</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">line_height_label</relation>
|
||||
</accessibility>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">2</property>
|
||||
@@ -193,9 +175,6 @@
|
||||
<property name="max-width-chars">4</property>
|
||||
<property name="hexpand">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">line_height_label</relation>
|
||||
</accessibility>
|
||||
<signal name="activate" handler="basic_entry_activated"
|
||||
object="line_height_adjustment" swapped="false"/>
|
||||
<layout>
|
||||
@@ -205,7 +184,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="foreground_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Foreground</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
@@ -223,9 +202,6 @@
|
||||
</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="rgba">black</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">foreground_label</relation>
|
||||
</accessibility>
|
||||
<signal name="notify::rgba" handler="color_set_cb"/>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
@@ -234,7 +210,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="background_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Background</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
@@ -252,9 +228,6 @@
|
||||
</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="rgba">white</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">background_label</relation>
|
||||
</accessibility>
|
||||
<signal name="notify::rgba" handler="color_set_cb"/>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
@@ -267,9 +240,6 @@
|
||||
<property name="icon-name">object-flip-vertical-symbolic</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<accessibility>
|
||||
<property name="label">Swap colors</property>
|
||||
</accessibility>
|
||||
<style>
|
||||
<class name="circular"/>
|
||||
</style>
|
||||
@@ -371,9 +341,6 @@
|
||||
<property name="yalign">0</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="selectable">1</property>
|
||||
<accessibility>
|
||||
<property name="label">Font example</property>
|
||||
</accessibility>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
@@ -383,9 +350,6 @@
|
||||
<property name="name">entry</property>
|
||||
<property name="child">
|
||||
<object class="GtkTextView" id="entry">
|
||||
<accessibility>
|
||||
<property name="label">Example text</property>
|
||||
</accessibility>
|
||||
<property name="buffer">
|
||||
<object class="GtkTextBuffer">
|
||||
<property name="text">Grumpy wizards make toxic brew for the evil Queen and Jack. A quick movement of the enemy will jeopardize six gunboats. The job of waxing linoleum frequently peeves chintzy kids. My girl wove six dozen plaid jackets before she quit. Twelve ziggurats quickly jumped a finch box.
|
||||
@@ -482,9 +446,6 @@
|
||||
<property name="icon-name">document-edit-symbolic</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">end</property>
|
||||
<accessibility>
|
||||
<property name="label">Edit text</property>
|
||||
</accessibility>
|
||||
<signal name="clicked" handler="font_features_toggle_edit"/>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
@@ -306,7 +306,7 @@ retry:
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf2);
|
||||
gtk_picture_set_paintable (GTK_PICTURE (image), GDK_PAINTABLE (texture));
|
||||
g_object_unref (pixbuf2);
|
||||
g_object_unref (texture);
|
||||
g_object_unref (pixbuf2);
|
||||
}
|
||||
|
||||
static gboolean fading = FALSE;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<property name="row-spacing">10</property>
|
||||
<property name="column-spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="text_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="label">Text</property>
|
||||
<property name="xalign">1</property>
|
||||
@@ -57,13 +57,10 @@
|
||||
<layout>
|
||||
<property name="column">2</property>
|
||||
</layout>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">text_label</relation>
|
||||
</accessibility>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="font_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="label">Font</property>
|
||||
<property name="xalign">1</property>
|
||||
@@ -78,9 +75,6 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFontDialogButton" id="font_button">
|
||||
<accessibility>
|
||||
<relation name="labelled-by">font_label</relation>
|
||||
</accessibility>
|
||||
<property name="dialog">
|
||||
<object class="GtkFontDialog">
|
||||
</object>
|
||||
@@ -192,9 +186,6 @@
|
||||
<property name="icon-name">list-add-symbolic</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<accessibility>
|
||||
<property name="label">Zoom in</property>
|
||||
</accessibility>
|
||||
<style>
|
||||
<class name="circular"/>
|
||||
</style>
|
||||
@@ -220,9 +211,6 @@
|
||||
<property name="icon-name">list-remove-symbolic</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<accessibility>
|
||||
<property name="label">Zoom out</property>
|
||||
</accessibility>
|
||||
<style>
|
||||
<class name="circular"/>
|
||||
</style>
|
||||
@@ -263,9 +251,6 @@
|
||||
<property name="vexpand">1</property>
|
||||
<child>
|
||||
<object class="GtkPicture" id="image">
|
||||
<accessibility>
|
||||
<property name="label">Font rendering example</property>
|
||||
</accessibility>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="can-shrink">0</property>
|
||||
|
||||
@@ -18,7 +18,6 @@ do_headerbar (GtkWidget *do_widget)
|
||||
GtkWidget *header;
|
||||
GtkWidget *button;
|
||||
GtkWidget *box;
|
||||
GtkWidget *content;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
@@ -38,26 +37,16 @@ do_headerbar (GtkWidget *do_widget)
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_add_css_class (box, "linked");
|
||||
button = gtk_button_new_from_icon_name ("go-previous-symbolic");
|
||||
gtk_widget_set_tooltip_text (button, "Back");
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
button = gtk_button_new_from_icon_name ("go-next-symbolic");
|
||||
gtk_widget_set_tooltip_text (button, "Forward");
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), box);
|
||||
button = gtk_switch_new ();
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Change something",
|
||||
-1);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), gtk_switch_new ());
|
||||
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
|
||||
content = gtk_text_view_new ();
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (content),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Content",
|
||||
-1);
|
||||
gtk_window_set_child (GTK_WINDOW (window), content);
|
||||
gtk_window_set_child (GTK_WINDOW (window), gtk_text_view_new ());
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
||||
@@ -164,18 +164,12 @@ do_image_scaling (GtkWidget *do_widget)
|
||||
scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, -10., 10., 0.1);
|
||||
gtk_scale_add_mark (GTK_SCALE (scale), 0., GTK_POS_TOP, NULL);
|
||||
gtk_widget_set_tooltip_text (scale, "Zoom");
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (scale),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Zoom",
|
||||
-1);
|
||||
gtk_range_set_value (GTK_RANGE (scale), 0.);
|
||||
gtk_widget_set_hexpand (scale, TRUE);
|
||||
gtk_box_append (GTK_BOX (box2), scale);
|
||||
|
||||
dropdown = gtk_drop_down_new (G_LIST_MODEL (gtk_string_list_new ((const char *[]){ "Linear", "Nearest", "Trilinear", NULL })), NULL);
|
||||
gtk_widget_set_tooltip_text (dropdown, "Filter");
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (dropdown),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Filter",
|
||||
-1);
|
||||
gtk_box_append (GTK_BOX (box2), dropdown);
|
||||
|
||||
g_object_bind_property (dropdown, "selected", widget, "filter", G_BINDING_DEFAULT);
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">switch</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@@ -74,7 +73,6 @@
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">check</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@@ -112,7 +110,6 @@
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="opacity">0</property>
|
||||
<property name="accessible-role">status</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -153,11 +150,10 @@
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">scale</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScale" id="scale">
|
||||
<object class="GtkScale">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="draw-value">0</property>
|
||||
@@ -189,11 +185,10 @@
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">spin</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="spin">
|
||||
<object class="GtkSpinButton">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="adjustment">
|
||||
@@ -222,11 +217,10 @@
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">dropdown</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkDropDown" id="dropdown">
|
||||
<object class="GtkDropDown">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="model">
|
||||
@@ -258,11 +252,10 @@
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">entry</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry">
|
||||
<object class="GtkEntry">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="placeholder-text">Type here…</property>
|
||||
|
||||
@@ -52,10 +52,6 @@ setup_listitem_cb (GtkListItemFactory *factory,
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
||||
image = gtk_image_new ();
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (image),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL,
|
||||
"App icon",
|
||||
-1);
|
||||
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
|
||||
gtk_box_append (GTK_BOX (box), image);
|
||||
label = gtk_label_new ("");
|
||||
@@ -83,7 +79,6 @@ bind_listitem_cb (GtkListItemFactory *factory,
|
||||
|
||||
gtk_image_set_from_gicon (GTK_IMAGE (image), g_app_info_get_icon (app_info));
|
||||
gtk_label_set_label (GTK_LABEL (label), g_app_info_get_display_name (app_info));
|
||||
gtk_list_item_set_accessible_label (list_item, g_app_info_get_display_name (app_info));
|
||||
}
|
||||
|
||||
/* In more complex code, we would also need functions to unbind and teardown
|
||||
|
||||
@@ -431,9 +431,6 @@ setup_listitem_cb (GtkListItemFactory *factory,
|
||||
picture = gtk_picture_new ();
|
||||
gtk_expression_bind (expression, picture, "paintable", picture);
|
||||
gtk_box_append (GTK_BOX (box), picture);
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (picture),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, location_label, NULL,
|
||||
-1);
|
||||
|
||||
|
||||
/* And finally, everything comes together.
|
||||
@@ -490,9 +487,6 @@ do_listview_clocks (GtkWidget *do_widget)
|
||||
|
||||
model = GTK_SELECTION_MODEL (gtk_no_selection_new (create_clocks_model ()));
|
||||
gridview = gtk_grid_view_new (model, factory);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (gridview),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Clocks",
|
||||
-1);
|
||||
gtk_scrollable_set_hscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
|
||||
gtk_scrollable_set_vscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
|
||||
|
||||
|
||||
@@ -368,38 +368,6 @@ match_func (MatchObject *obj,
|
||||
g_free (tmp2);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_header (GtkSignalListItemFactory *factory,
|
||||
GObject *list_item,
|
||||
gpointer data)
|
||||
{
|
||||
GtkListHeader *self = GTK_LIST_HEADER (list_item);
|
||||
GtkWidget *child;
|
||||
|
||||
child = gtk_label_new ("");
|
||||
gtk_label_set_xalign (GTK_LABEL (child), 0);
|
||||
gtk_label_set_use_markup (GTK_LABEL (child), TRUE);
|
||||
gtk_widget_set_margin_top (child, 10);
|
||||
gtk_widget_set_margin_bottom (child, 10);
|
||||
|
||||
gtk_list_header_set_child (self, child);
|
||||
}
|
||||
|
||||
static void
|
||||
bind_header (GtkSignalListItemFactory *factory,
|
||||
GObject *list_item,
|
||||
gpointer data)
|
||||
{
|
||||
GtkListHeader *self = GTK_LIST_HEADER (list_item);
|
||||
GtkWidget *child = gtk_list_header_get_child (self);
|
||||
GObject *item = gtk_list_header_get_item (self);
|
||||
|
||||
if (strstr (gtk_string_object_get_string (GTK_STRING_OBJECT (item)), "hour"))
|
||||
gtk_label_set_label (GTK_LABEL (child), "<big><b>Hours</b></big>");
|
||||
else
|
||||
gtk_label_set_label (GTK_LABEL (child), "<big><b>Minutes</b></big>");
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_listview_selections (GtkWidget *do_widget)
|
||||
{
|
||||
@@ -409,12 +377,10 @@ do_listview_selections (GtkWidget *do_widget)
|
||||
GtkExpression *expression;
|
||||
GtkListItemFactory *factory;
|
||||
const char * const times[] = { "1 minute", "2 minutes", "5 minutes", "20 minutes", NULL };
|
||||
const char * const minutes[] = {
|
||||
const char * const many_times[] = {
|
||||
"1 minute", "2 minutes", "5 minutes", "10 minutes", "15 minutes", "20 minutes",
|
||||
"25 minutes", "30 minutes", "35 minutes", "40 minutes", "45 minutes", "50 minutes",
|
||||
"55 minutes", NULL
|
||||
};
|
||||
const char * const hours[] = { "1 hour", "2 hours", "3 hours", "5 hours", "6 hours", "7 hours",
|
||||
"55 minutes", "1 hour", "2 hours", "3 hours", "5 hours", "6 hours", "7 hours",
|
||||
"8 hours", "9 hours", "10 hours", "11 hours", "12 hours", NULL
|
||||
};
|
||||
const char * const device_titles[] = { "Digital Output", "Headphones", "Digital Output", "Analog Output", NULL };
|
||||
@@ -429,10 +395,6 @@ do_listview_selections (GtkWidget *do_widget)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkStringList *minutes_model, *hours_model;
|
||||
GListStore *store;
|
||||
GtkFlattenListModel *flat;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
@@ -460,25 +422,14 @@ do_listview_selections (GtkWidget *do_widget)
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
/* A dropdown using an expression to obtain strings */
|
||||
minutes_model = gtk_string_list_new (minutes);
|
||||
hours_model = gtk_string_list_new (hours);
|
||||
store = g_list_store_new (G_TYPE_LIST_MODEL);
|
||||
g_list_store_append (store, minutes_model);
|
||||
g_list_store_append (store, hours_model);
|
||||
g_object_unref (minutes_model);
|
||||
g_object_unref (hours_model);
|
||||
flat = gtk_flatten_list_model_new (G_LIST_MODEL (store));
|
||||
button = drop_down_new_from_strings (many_times, NULL, NULL);
|
||||
gtk_drop_down_set_enable_search (GTK_DROP_DOWN (button), TRUE);
|
||||
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||
0, NULL,
|
||||
(GCallback)get_title,
|
||||
NULL, NULL);
|
||||
button = gtk_drop_down_new (G_LIST_MODEL (flat), expression);
|
||||
gtk_drop_down_set_enable_search (GTK_DROP_DOWN (button), TRUE);
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_header), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_header), NULL);
|
||||
gtk_drop_down_set_header_factory (GTK_DROP_DOWN (button), factory);
|
||||
g_object_unref (factory);
|
||||
gtk_drop_down_set_expression (GTK_DROP_DOWN (button), expression);
|
||||
gtk_expression_unref (expression);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
button = gtk_drop_down_new (NULL, NULL);
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
<property name="child">
|
||||
<object class="GtkInscription">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="nat-chars">25</property>
|
||||
<property name="text-overflow">ellipsize-end</property>
|
||||
<binding name="text">
|
||||
<lookup name="title" type="GtkDemo">
|
||||
<lookup name="item">expander</lookup>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
@@ -267,9 +268,9 @@ activate_run (GSimpleAction *action,
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
display_image (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *label)
|
||||
display_image (const char *format,
|
||||
const char *resource,
|
||||
char **label)
|
||||
{
|
||||
GtkWidget *sw, *image;
|
||||
|
||||
@@ -279,17 +280,13 @@ display_image (const char *format,
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), image);
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (image),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
|
||||
return sw;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
display_images (const char *format,
|
||||
const char *resource_dir,
|
||||
GtkWidget *label)
|
||||
display_images (const char *format,
|
||||
const char *resource_dir,
|
||||
char **label)
|
||||
{
|
||||
char **resources;
|
||||
GtkWidget *grid;
|
||||
@@ -314,15 +311,13 @@ display_images (const char *format,
|
||||
{
|
||||
char *resource_name;
|
||||
GtkWidget *box;
|
||||
GtkWidget *image_label;
|
||||
|
||||
resource_name = g_strconcat (resource_dir, "/", resources[i], NULL);
|
||||
|
||||
image_label = gtk_label_new (resources[i]);
|
||||
widget = display_image (NULL, resource_name, image_label);
|
||||
widget = display_image (NULL, resource_name, NULL);
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_box_append (GTK_BOX (box), widget);
|
||||
gtk_box_append (GTK_BOX (box), image_label);
|
||||
gtk_box_append (GTK_BOX (box), gtk_label_new (resources[i]));
|
||||
gtk_flow_box_insert (GTK_FLOW_BOX (grid), box, -1);
|
||||
|
||||
g_free (resource_name);
|
||||
@@ -330,19 +325,15 @@ display_images (const char *format,
|
||||
|
||||
g_strfreev (resources);
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (label), "Images");
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (grid),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
*label = g_strdup ("Images");
|
||||
|
||||
return sw;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
display_text (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *label)
|
||||
display_text (const char *format,
|
||||
const char *resource,
|
||||
char **label)
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
GtkWidget *textview, *sw;
|
||||
@@ -377,10 +368,6 @@ display_text (const char *format,
|
||||
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (textview), buffer);
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (textview),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
@@ -391,19 +378,15 @@ display_text (const char *format,
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
display_video (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *label)
|
||||
display_video (const char *format,
|
||||
const char *resource,
|
||||
char **label)
|
||||
{
|
||||
GtkWidget *video;
|
||||
|
||||
video = gtk_video_new_for_resource (resource);
|
||||
gtk_video_set_loop (GTK_VIDEO (video), TRUE);
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (video),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
|
||||
return video;
|
||||
}
|
||||
|
||||
@@ -425,9 +408,9 @@ display_nothing (const char *resource)
|
||||
static struct {
|
||||
const char *extension;
|
||||
const char *format;
|
||||
GtkWidget * (* display_func) (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *label);
|
||||
GtkWidget * (* display_func) (const char *format,
|
||||
const char *resource,
|
||||
char **label);
|
||||
} display_funcs[] = {
|
||||
{ ".gif", NULL, display_image },
|
||||
{ ".jpg", NULL, display_image },
|
||||
@@ -450,6 +433,7 @@ add_data_tab (const char *demoname)
|
||||
char **resources;
|
||||
GtkWidget *widget, *label;
|
||||
guint i, j;
|
||||
char *label_string;
|
||||
|
||||
resource_dir = g_strconcat ("/", demoname, NULL);
|
||||
resources = g_resources_enumerate_children (resource_dir, 0, NULL);
|
||||
@@ -469,21 +453,23 @@ add_data_tab (const char *demoname)
|
||||
break;
|
||||
}
|
||||
|
||||
label = gtk_label_new (resources[i]);
|
||||
label_string = NULL;
|
||||
|
||||
if (j < G_N_ELEMENTS (display_funcs))
|
||||
widget = display_funcs[j].display_func (display_funcs[j].format,
|
||||
resource_name,
|
||||
label);
|
||||
&label_string);
|
||||
else
|
||||
widget = display_nothing (resource_name);
|
||||
|
||||
label = gtk_label_new (label_string ? label_string : resources[i]);
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, label);
|
||||
g_object_set (gtk_notebook_get_page (GTK_NOTEBOOK (notebook), widget),
|
||||
"tab-expand", FALSE,
|
||||
NULL);
|
||||
|
||||
g_free (resource_name);
|
||||
g_free (label_string);
|
||||
}
|
||||
|
||||
g_strfreev (resources);
|
||||
|
||||
@@ -57,17 +57,14 @@
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="width-request">220</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkSearchBar" id="searchbar">
|
||||
<accessibility>
|
||||
<relation name="labelled-by">search-entry</relation>
|
||||
</accessibility>
|
||||
<property name="key-capture-widget">window</property>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="search-entry">
|
||||
<accessibility>
|
||||
<property name="label" translatable="yes">Search</property>
|
||||
<relation name="controls">listview</relation>
|
||||
</accessibility>
|
||||
</object>
|
||||
@@ -79,15 +76,15 @@
|
||||
<style>
|
||||
<class name="sidebar"/>
|
||||
</style>
|
||||
<property name="width-request">120</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="propagate-natural-width">1</property>
|
||||
<property name="min-content-width">150</property>
|
||||
<property name="vexpand">1</property>
|
||||
<child>
|
||||
<object class="GtkListView" id="listview">
|
||||
<style>
|
||||
<class name="navigation-sidebar"/>
|
||||
</style>
|
||||
<property name="tab-behavior">item</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="resource">/ui/main-listitem.ui</property>
|
||||
|
||||
@@ -158,7 +158,17 @@ demos_h = custom_target('gtk4 demo header',
|
||||
command: [ find_program('geninclude.py'), '@OUTPUT@', '@INPUT@' ],
|
||||
)
|
||||
|
||||
if can_use_objcopy_for_resources
|
||||
objcopy_supports_add_symbol = false
|
||||
objcopy = find_program('objcopy', required : false)
|
||||
if objcopy.found()
|
||||
objcopy_supports_add_symbol = run_command(objcopy, '--help', check: false).stdout().contains('--add-symbol')
|
||||
endif
|
||||
|
||||
ld = find_program('ld', required : false)
|
||||
|
||||
if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
|
||||
glib_compile_resources = find_program('glib-compile-resources')
|
||||
|
||||
# Create the resource blob
|
||||
gtkdemo_gresource = custom_target('gtkdemo.gresource',
|
||||
input : 'demo.gresource.xml',
|
||||
|
||||
@@ -68,9 +68,6 @@ do_password_entry (GtkWidget *do_widget)
|
||||
"placeholder-text", "Password",
|
||||
"activates-default", TRUE,
|
||||
NULL);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (entry),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Password",
|
||||
-1);
|
||||
g_signal_connect (entry, "notify::text", G_CALLBACK (update_button), NULL);
|
||||
gtk_box_append (GTK_BOX (box), entry);
|
||||
|
||||
@@ -80,9 +77,6 @@ do_password_entry (GtkWidget *do_widget)
|
||||
"placeholder-text", "Confirm",
|
||||
"activates-default", TRUE,
|
||||
NULL);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (entry2),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Confirm",
|
||||
-1);
|
||||
g_signal_connect (entry2, "notify::text", G_CALLBACK (update_button), NULL);
|
||||
gtk_box_append (GTK_BOX (box), entry2);
|
||||
|
||||
|
||||
@@ -189,7 +189,6 @@ do_pickers (GtkWidget *do_widget)
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
|
||||
|
||||
picker = gtk_color_dialog_button_new (gtk_color_dialog_new ());
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), picker);
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 1, 0, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Font:");
|
||||
@@ -199,7 +198,6 @@ do_pickers (GtkWidget *do_widget)
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1);
|
||||
|
||||
picker = gtk_font_dialog_button_new (gtk_font_dialog_new ());
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), picker);
|
||||
gtk_grid_attach (GTK_GRID (table), picker, 1, 1, 1, 1);
|
||||
|
||||
label = gtk_label_new ("File:");
|
||||
@@ -210,9 +208,6 @@ do_pickers (GtkWidget *do_widget)
|
||||
|
||||
picker = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
button = gtk_button_new_from_icon_name ("document-open-symbolic");
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Select File",
|
||||
-1);
|
||||
|
||||
label = gtk_label_new ("None");
|
||||
|
||||
@@ -228,9 +223,6 @@ do_pickers (GtkWidget *do_widget)
|
||||
gtk_box_append (GTK_BOX (picker), button);
|
||||
app_picker = gtk_button_new_from_icon_name ("emblem-system-symbolic");
|
||||
gtk_widget_set_halign (app_picker, GTK_ALIGN_END);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (app_picker),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Open File",
|
||||
-1);
|
||||
gtk_widget_set_sensitive (app_picker, FALSE);
|
||||
g_signal_connect (app_picker, "clicked", G_CALLBACK (open_app), NULL);
|
||||
gtk_box_append (GTK_BOX (picker), app_picker);
|
||||
@@ -249,7 +241,7 @@ do_pickers (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
||||
@@ -150,36 +150,20 @@ do_video_player (GtkWidget *do_widget)
|
||||
|
||||
button = gtk_button_new ();
|
||||
image = gtk_image_new_from_resource ("/cursors/images/gtk_logo_cursor.png");
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (image),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, button, NULL,
|
||||
-1);
|
||||
gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
|
||||
gtk_button_set_child (GTK_BUTTON (button), image);
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (logo_clicked_cb), video);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "GTK Logo",
|
||||
-1);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (title), button);
|
||||
|
||||
button = gtk_button_new ();
|
||||
image = gtk_image_new_from_resource ("/video-player/bbb.png");
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (image),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, button, NULL,
|
||||
-1);
|
||||
gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
|
||||
gtk_button_set_child (GTK_BUTTON (button), image);
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (bbb_clicked_cb), video);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Big Buck Bunny",
|
||||
-1);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (title), button);
|
||||
|
||||
fullscreen_button = gtk_button_new_from_icon_name ("view-fullscreen-symbolic");
|
||||
g_signal_connect (fullscreen_button, "clicked", G_CALLBACK (fullscreen_clicked_cb), NULL);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (fullscreen_button),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Fullscreen",
|
||||
-1);
|
||||
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (title), fullscreen_button);
|
||||
|
||||
controller = gtk_shortcut_controller_new ();
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
# demos/widget-factory
|
||||
|
||||
if can_use_objcopy_for_resources
|
||||
objcopy_supports_add_symbol = false
|
||||
objcopy = find_program('objcopy', required : false)
|
||||
if objcopy.found()
|
||||
objcopy_supports_add_symbol = run_command(objcopy, '--help', check: false).stdout().contains('--add-symbol')
|
||||
endif
|
||||
|
||||
ld = find_program('ld', required : false)
|
||||
|
||||
if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
|
||||
glib_compile_resources = find_program('glib-compile-resources')
|
||||
|
||||
# Create the resource blob
|
||||
widgetfactory_gresource = custom_target('widgetfactory.gresource',
|
||||
input : 'widget-factory.gresource.xml',
|
||||
|
||||
@@ -1572,9 +1572,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<property name="valign">3</property>
|
||||
<child>
|
||||
<object class="GtkVolumeButton">
|
||||
<accessibility>
|
||||
<property name="label" translatable="1">Volume</property>
|
||||
</accessibility>
|
||||
<property name="orientation">1</property>
|
||||
<property name="valign">3</property>
|
||||
<property name="value">.5</property>
|
||||
@@ -1587,9 +1584,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScaleButton" id="mic-button">
|
||||
<accessibility>
|
||||
<property name="label" translatable="1">Microphone gain</property>
|
||||
</accessibility>
|
||||
<property name="has-tooltip">1</property>
|
||||
<property name="icons">microphone-sensitivity-muted-symbolic
|
||||
microphone-sensitivity-high-symbolic
|
||||
|
||||
@@ -23,7 +23,7 @@ When it comes to rendering, GTK follows the CSS box model as far as practical.
|
||||
|
||||
The CSS stylesheet that is in use determines the sizes (and appearance) of the
|
||||
margin, border and padding areas for each widget. The size of the content area
|
||||
is determined by GTKs layout algorithm using each widget’s [vfunc@Gtk.Widget.measure]
|
||||
is determined by GTKs layout algorithm using each widgets [vfunc@Gtk.Widget.measure]
|
||||
and [vfunc@Gtk.Widget.size_allocate] vfuncs.
|
||||
|
||||
You can learn more about the CSS box model by reading the
|
||||
@@ -37,11 +37,11 @@ To learn more about where GTK CSS differs from CSS on the web, see the
|
||||
|
||||
The content area in the CSS box model is the region that the widget considers its own.
|
||||
|
||||
The origin of the widget’s coordinate system is the top left corner of the content area,
|
||||
and its size is the widget’s size. The size can be queried with [method@Gtk.Widget.get_width]
|
||||
The origin of the widgets coordinate system is the top left corner of the content area,
|
||||
and its size is the widgets size. The size can be queried with [method@Gtk.Widget.get_width]
|
||||
and [method@Gtk.Widget.get_height]. GTK allows general 3D transformations to position
|
||||
widgets (although most of the time, the transformation will be a simple 2D translation).
|
||||
The transform to go from one widget’s coordinate system to another one can be obtained
|
||||
The transform to go from one widgets coordinate system to another one can be obtained
|
||||
with [method@Gtk.Widget.compute_transform].
|
||||
|
||||
In addition to a size, widgets can optionally have a **_baseline_** to position text on.
|
||||
@@ -55,8 +55,8 @@ or [method@Gtk.Widget.compute_bounds]. These methods can fail (either because th
|
||||
don't share a common ancestor, or because of a singular transformation), and callers need
|
||||
to handle this eventuality.
|
||||
|
||||
Another area that is occasionally relevant are the widget’s **_bounds_**, which is the area
|
||||
that a widget’s rendering is typically confined to (technically, widgets can draw outside
|
||||
Another area that is occasionally relevant are the widgets **_bounds_**, which is the area
|
||||
that a widgets rendering is typically confined to (technically, widgets can draw outside
|
||||
of this area, unless clipping is enforced via the [property@Gtk.Widget:overflow] property).
|
||||
In CSS terms, the bounds of a widget correspond to the border area.
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ SYNOPSIS
|
||||
| **gtk4-builder-tool** enumerate [OPTIONS...] <FILE>
|
||||
| **gtk4-builder-tool** simplify [OPTIONS...] <FILE>
|
||||
| **gtk4-builder-tool** preview [OPTIONS...] <FILE>
|
||||
| **gtk4-builder-tool** render [OPTIONS...] <FILE>
|
||||
| **gtk4-builder-tool** screenshot [OPTIONS...] <FILE>
|
||||
|
||||
DESCRIPTION
|
||||
@@ -70,11 +69,12 @@ file to use.
|
||||
|
||||
Load style information from the given CSS file.
|
||||
|
||||
Render
|
||||
^^^^^^
|
||||
Screenshot
|
||||
^^^^^^^^^^
|
||||
|
||||
The ``render`` command saves a rendering of the UI definition file as a png image
|
||||
or node file. The name of the file to write can be specified as a second FILE argument.
|
||||
The ``screenshot`` command saves a rendering of the UI definition file
|
||||
as a png image or node file. The name of the file to write can be specified as
|
||||
a second FILE argument.
|
||||
|
||||
This command accepts options to specify the ID of the toplevel object and a CSS
|
||||
file to use.
|
||||
@@ -96,11 +96,6 @@ file to use.
|
||||
|
||||
Overwrite an existing file.
|
||||
|
||||
Screenshot
|
||||
^^^^^^^^^^
|
||||
|
||||
The ``screenshot`` command is an alias for ``render``.
|
||||
|
||||
Simplification
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
@@ -208,12 +208,6 @@ A number of options affect behavior instead of logging:
|
||||
`nograbs`
|
||||
: Turn off all pointer and keyboard grabs
|
||||
|
||||
`portals`
|
||||
: Force the use of [portals](https://docs.flatpak.org/en/latest/portals.html)
|
||||
|
||||
`no-portals`
|
||||
: Disable use of [portals](https://docs.flatpak.org/en/latest/portals.html)
|
||||
|
||||
`gl-disable`
|
||||
: Disable OpenGL support
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ described by a set of *attributes*.
|
||||
Roles define the taxonomy and semantics of a UI control to any assistive
|
||||
technology application; for instance, a button will have a role of
|
||||
`GTK_ACCESSIBLE_ROLE_BUTTON`; an entry will have a role of
|
||||
`GTK_ACCESSIBLE_ROLE_TEXTBOX`; a check button will have a role of
|
||||
`GTK_ACCESSIBLE_ROLE_TEXTBOX`; a toggle button will have a role of
|
||||
`GTK_ACCESSIBLE_ROLE_CHECKBOX`; etc.
|
||||
|
||||
Each role is part of the widget's instance, and **cannot** be changed over
|
||||
@@ -46,7 +46,6 @@ Each role name is part of the #GtkAccessibleRole enumeration.
|
||||
|
||||
| Role name | Description | Related GTK widget |
|
||||
|-----------|-------------|--------------------|
|
||||
| `APPLICATION` | An application window | [class@Gtk.Window] |
|
||||
| `BUTTON` | A control that performs an action when pressed | [class@Gtk.Button], [class@Gtk.LinkButton], [class@Gtk.Expander] |
|
||||
| `CHECKBOX` | A control that has three possible value: `true`, `false`, or `undefined` | [class@Gtk.CheckButton] |
|
||||
| `COMBOBOX` | A control that can be expanded to show a list of possible values to select | [class@Gtk.ComboBox] |
|
||||
@@ -79,6 +78,7 @@ Each role name is part of the #GtkAccessibleRole enumeration.
|
||||
| `TAB_PANEL` | A page in a notebook or stack | [class@Gtk.Stack] |
|
||||
| `TEXT_BOX` | A type of input that allows free-form text as its value. | [class@Gtk.Entry], [class@Gtk.PasswordEntry], [class@Gtk.TextView] |
|
||||
| `TREE_GRID` | A treeview-like columned list | [class@Gtk.ColumnView] |
|
||||
| `WINDOW` | An application window | [class@Gtk.Window] |
|
||||
| `...` | … |
|
||||
|
||||
See the [WAI-ARIA](https://www.w3.org/WAI/PF/aria/appendices#quickref) list
|
||||
@@ -204,27 +204,19 @@ you should ensure that:
|
||||
readable and localised action performed when pressed; for instance "Copy",
|
||||
"Paste", "Add layer", or "Remove"
|
||||
|
||||
GTK will try to fill in some information by using ancillary UI control properties,
|
||||
for instance the accessible name will be taken from the label used by the UI control,
|
||||
or from its tooltip, if the `GTK_ACCESSIBLE_PROPERTY_LABEL` property or the
|
||||
`GTK_ACCESSIBLE_RELATION_LABELLED_BY` relation are unset. Similary for the accessible
|
||||
description. Nevertheless, it is good practice and project hygiene to explicitly specify
|
||||
the accessible properties, just like it's good practice to specify tooltips and style classes.
|
||||
GTK will try to fill in some information by using ancillary UI control
|
||||
properties, for instance the accessible label will be taken from the label or
|
||||
placeholder text used by the UI control, or from its tooltip, if the
|
||||
`GTK_ACCESSIBLE_PROPERTY_LABEL` property or the `GTK_ACCESSIBLE_RELATION_LABELLED_BY`
|
||||
relation are unset. Nevertheless, it is good practice and project hygiene
|
||||
to explicitly specify the accessible properties, just like it's good practice
|
||||
to specify tooltips and style classes.
|
||||
|
||||
Application developers using GTK **should** ensure that their UI controls
|
||||
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.
|
||||
|
||||
It is possible to set accessible attributes in UI files as well:
|
||||
```xml
|
||||
<object class="GtkButton" id="button1">
|
||||
<accessibility>
|
||||
<property name="label">Download</property>
|
||||
<relation name="labelled-by">label1</relation>
|
||||
/accessibility>
|
||||
</object>
|
||||
```
|
||||
are accessible as part of the development process. When using `GtkBuilder`
|
||||
templates and UI definition files, GTK provides a validation tool that
|
||||
verifies that each UI element has a valid role and properties; this tool can
|
||||
be used as part of the application's test suite to avoid regressions.
|
||||
|
||||
## Implementations
|
||||
|
||||
@@ -267,13 +259,6 @@ turn automatically any widget into a `GtkButton`; but if your widget behaves
|
||||
like a button, using the %GTK_ACCESSIBLE_ROLE_BUTTON will allow any
|
||||
assistive technology to handle it like they would a `GtkButton`.
|
||||
|
||||
For widgets that act as containers of other widgets, you should use
|
||||
%GTK_ACCESSIBLE_ROLE_GROUP if the grouping of the children is semantic
|
||||
in nature; for instance, the children of a [class@Gtk.HeaderBar] are
|
||||
grouped together on the header of a window. For generic containers that
|
||||
only impose a layout on their children, you should use
|
||||
%GTK_ACCESSIBLE_ROLE_GENERIC instead.
|
||||
|
||||
### Attributes can both hide and enhance
|
||||
|
||||
Accessible attributes can be used to override the content of a UI element,
|
||||
@@ -382,6 +367,3 @@ To allow changing the value via accessible technologies, you can export
|
||||
actions. Since the accessibility interfaces only support actions
|
||||
without parameters, you should provide actions such as `increase-value`
|
||||
and `decrease-value`.
|
||||
|
||||
Since GTK 4.10, the best way to suppose changing the value is by implementing
|
||||
the [iface@Gtk.AccessibleRange] interface.
|
||||
|
||||
@@ -30,12 +30,12 @@ Views display data from a **_model_**. Models implement the [`iface@Gio.ListMode
|
||||
interface and can be provided in a variety of ways:
|
||||
|
||||
* List model implementations for many specific types of data already exist, for
|
||||
example [`class@Gtk.DirectoryList`] or [`class@Gtk.StringList`].
|
||||
example `GtkDirectoryList` or `GtkStringList`.
|
||||
|
||||
* There are generic list model implementations like [`class@Gio.ListStore`] that allow building
|
||||
* There are generic list model implementations like`GListStore` that allow building
|
||||
lists of arbitrary objects.
|
||||
|
||||
* Wrapping list models like [`class@Gtk.FilterListModel`] or [`class@Gtk.SortListModel`]
|
||||
* Wrapping list models like `GtkFilterListModel` or `GtkSortListModel`
|
||||
modify, adapt or combine other models.
|
||||
|
||||
* Last but not least, developers are encouraged to create their own `GListModel`
|
||||
@@ -133,8 +133,8 @@ tradeoffs of those and experiment with them.
|
||||
|
||||
GTK offers a wide variety of wrapping models which change or supplement an
|
||||
existing model (or models) in some way. But when it comes to storing your
|
||||
actual data, there are only a few ready-made choices available:
|
||||
[`class@Gio.ListStore`], [`class@Gtk.StringList`], and [`class@Gtk.DirectoryList`].
|
||||
actual data, there are only a few ready-made choices available: [`class@Gio.ListStore`]
|
||||
and [`class@Gtk.StringList`].
|
||||
|
||||
`GListStore` is backed by a balanced tree and has performance characteristics
|
||||
that are expected for that data structure. It works reasonably well for dataset
|
||||
@@ -147,10 +147,6 @@ that are expected for that data structure. `GtkStringList` is a good fit for any
|
||||
place where you would otherwise use `char*[]` and works best if the dataset
|
||||
is not very dynamic.
|
||||
|
||||
`GtkDirectoryList` is a list model that wraps [`method@Gio.File.enumerate_children_async`].
|
||||
It presents a `GListModel` and fills it asynchronously with the [`iface@Gio.File`]s
|
||||
returned from that function.
|
||||
|
||||
If these models don't fit your use case or scalability requirements, you
|
||||
should make a custom `GListModel` implementation. It is a small interface and
|
||||
not very hard to implement.
|
||||
@@ -203,7 +199,7 @@ the `.data-table` style class.
|
||||
## Sections
|
||||
|
||||
List models can optionally group their items into **_sections_**, by implementing
|
||||
the `GtkSectionModel` interface. `GtkListView` can
|
||||
the `GtkSectionModel` interface. Both `GtkListView` and `GtkGridView` can
|
||||
display headers for sections, by installing a separate **_header factory_**.
|
||||
|
||||
Many GTK list models support section inherently, or they pass through the
|
||||
|
||||
@@ -34,7 +34,7 @@ gdk_broadway_cairo_context_dispose (GObject *object)
|
||||
|
||||
static void
|
||||
gdk_broadway_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkBroadwayCairoContext *self = GDK_BROADWAY_CAIRO_CONTEXT (draw_context);
|
||||
|
||||
@@ -34,7 +34,7 @@ gdk_broadway_draw_context_dispose (GObject *object)
|
||||
|
||||
static void
|
||||
gdk_broadway_draw_context_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkBroadwayDrawContext *self = GDK_BROADWAY_DRAW_CONTEXT (draw_context);
|
||||
|
||||
@@ -645,9 +645,6 @@ gdk_content_formats_builder_clear (GdkContentFormatsBuilder *builder)
|
||||
{
|
||||
g_clear_pointer (&builder->gtypes, g_slist_free);
|
||||
g_clear_pointer (&builder->mime_types, g_slist_free);
|
||||
|
||||
builder->n_gtypes = 0;
|
||||
builder->n_mime_types = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "gdkglcontextprivate.h"
|
||||
#include "gdkmonitorprivate.h"
|
||||
#include "gdkrectangle.h"
|
||||
#include "gdkvulkancontext.h"
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
#include <epoxy/egl.h>
|
||||
@@ -384,9 +383,6 @@ gdk_display_dispose (GObject *object)
|
||||
#endif
|
||||
g_clear_error (&priv->gl_error);
|
||||
|
||||
for (GList *l = display->seats; l; l = l->next)
|
||||
g_object_run_dispose (G_OBJECT (l->data));
|
||||
|
||||
G_OBJECT_CLASS (gdk_display_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
@@ -1217,49 +1213,6 @@ gdk_display_get_keymap (GdkDisplay *display)
|
||||
return GDK_DISPLAY_GET_CLASS (display)->get_keymap (display);
|
||||
}
|
||||
|
||||
/*<private>
|
||||
* gdk_display_create_vulkan_context:
|
||||
* @self: a `GdkDisplay`
|
||||
* @error: return location for an error
|
||||
*
|
||||
* Creates a new `GdkVulkanContext` for use with @display.
|
||||
*
|
||||
* The context can not be used to draw to surfaces, it can only be
|
||||
* used for custom rendering or compute.
|
||||
*
|
||||
* If the creation of the `GdkVulkanContext` failed, @error will be set.
|
||||
*
|
||||
* Returns: (transfer full): the newly created `GdkVulkanContext`, or
|
||||
* %NULL on error
|
||||
*/
|
||||
GdkVulkanContext *
|
||||
gdk_display_create_vulkan_context (GdkDisplay *self,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (self), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
if (gdk_display_get_debug_flags (self) & GDK_DEBUG_VULKAN_DISABLE)
|
||||
{
|
||||
g_set_error_literal (error, GDK_VULKAN_ERROR, GDK_VULKAN_ERROR_NOT_AVAILABLE,
|
||||
_("Vulkan support disabled via GDK_DEBUG"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (GDK_DISPLAY_GET_CLASS (self)->vk_extension_name == NULL)
|
||||
{
|
||||
g_set_error (error, GDK_VULKAN_ERROR, GDK_VULKAN_ERROR_UNSUPPORTED,
|
||||
"The %s backend has no Vulkan support.", G_OBJECT_TYPE_NAME (self));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return g_initable_new (GDK_DISPLAY_GET_CLASS (self)->vk_context_type,
|
||||
NULL,
|
||||
error,
|
||||
"display", self,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_display_init_gl (GdkDisplay *self)
|
||||
{
|
||||
|
||||
@@ -100,11 +100,6 @@ struct _GdkDisplay
|
||||
VkDevice vk_device;
|
||||
VkQueue vk_queue;
|
||||
uint32_t vk_queue_family_index;
|
||||
VkPipelineCache vk_pipeline_cache;
|
||||
gsize vk_pipeline_cache_size;
|
||||
char *vk_pipeline_cache_etag;
|
||||
guint vk_save_pipeline_cache_source;
|
||||
GHashTable *vk_shader_modules;
|
||||
|
||||
guint vulkan_refcount;
|
||||
#endif /* GDK_RENDERING_VULKAN */
|
||||
@@ -207,9 +202,6 @@ gulong _gdk_display_get_next_serial (GdkDisplay *display
|
||||
void _gdk_display_pause_events (GdkDisplay *display);
|
||||
void _gdk_display_unpause_events (GdkDisplay *display);
|
||||
|
||||
GdkVulkanContext * gdk_display_create_vulkan_context (GdkDisplay *self,
|
||||
GError **error);
|
||||
|
||||
GdkGLContext * gdk_display_get_gl_context (GdkDisplay *display);
|
||||
|
||||
gboolean gdk_display_init_egl (GdkDisplay *display,
|
||||
|
||||
@@ -311,20 +311,19 @@ gdk_draw_context_begin_frame (GdkDrawContext *context,
|
||||
g_return_if_fail (priv->surface != NULL);
|
||||
g_return_if_fail (region != NULL);
|
||||
|
||||
gdk_draw_context_begin_frame_full (context, GDK_MEMORY_U8, region);
|
||||
gdk_draw_context_begin_frame_full (context, FALSE, region);
|
||||
}
|
||||
|
||||
/*
|
||||
* @depth: best depth to render in
|
||||
* @prefers_high_depth: %TRUE to request a higher bit depth
|
||||
*
|
||||
* If the given depth is not `GDK_MEMORY_U8`, GDK will see about providing a
|
||||
* rendering target that supports a higher bit depth than 8 bits per channel.
|
||||
* Typically this means a target supporting 16bit floating point pixels, but
|
||||
* that is not guaranteed.
|
||||
* If high depth is preferred, GDK will see about providing a rendering target
|
||||
* that supports higher bit depth than 8 bits per channel. Typically this means
|
||||
* a target supporting 16bit floating point pixels, but that is not guaranteed.
|
||||
*
|
||||
* This is only a request and if the GDK backend does not support HDR rendering
|
||||
* or does not consider it worthwhile, it may choose to not honor the request.
|
||||
* It may also choose to provide a differnet depth even if it was not requested.
|
||||
* It may also choose to provide high depth even if it was not requested.
|
||||
* Typically the steps undertaken by a backend are:
|
||||
* 1. Check if high depth is supported by this drawing backend.
|
||||
* 2. Check if the compositor supports high depth.
|
||||
@@ -334,12 +333,12 @@ gdk_draw_context_begin_frame (GdkDrawContext *context,
|
||||
* In either of those cases, the context will usually choose to not honor the request.
|
||||
*
|
||||
* The rendering code must be able to deal with content in any bit depth, no matter
|
||||
* the preference. The depth argument is only a hint and GDK is free
|
||||
* the preference. The prefers_high_depth argument is only a hint and GDK is free
|
||||
* to choose.
|
||||
*/
|
||||
void
|
||||
gdk_draw_context_begin_frame_full (GdkDrawContext *context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
const cairo_region_t *region)
|
||||
{
|
||||
GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context);
|
||||
@@ -366,12 +365,12 @@ gdk_draw_context_begin_frame_full (GdkDrawContext *context,
|
||||
}
|
||||
|
||||
if (gdk_display_get_debug_flags (priv->display) & GDK_DEBUG_HIGH_DEPTH)
|
||||
depth = GDK_MEMORY_FLOAT32;
|
||||
prefers_high_depth = TRUE;
|
||||
|
||||
priv->frame_region = cairo_region_copy (region);
|
||||
priv->surface->paint_context = g_object_ref (context);
|
||||
|
||||
GDK_DRAW_CONTEXT_GET_CLASS (context)->begin_frame (context, depth, priv->frame_region);
|
||||
GDK_DRAW_CONTEXT_GET_CLASS (context)->begin_frame (context, prefers_high_depth, priv->frame_region);
|
||||
|
||||
cairo_region_intersect_rectangle (priv->frame_region,
|
||||
&(cairo_rectangle_int_t) {
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include "gdkdrawcontext.h"
|
||||
|
||||
#include "gdkmemoryformatprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_DRAW_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAW_CONTEXT, GdkDrawContextClass))
|
||||
@@ -42,7 +40,7 @@ struct _GdkDrawContextClass
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (* begin_frame) (GdkDrawContext *context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *update_area);
|
||||
void (* end_frame) (GdkDrawContext *context,
|
||||
cairo_region_t *painted);
|
||||
@@ -52,7 +50,7 @@ struct _GdkDrawContextClass
|
||||
void gdk_draw_context_surface_resized (GdkDrawContext *context);
|
||||
|
||||
void gdk_draw_context_begin_frame_full (GdkDrawContext *context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
const cairo_region_t *region);
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <gdk/version/gdkversionmacros.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
@@ -308,20 +306,6 @@ typedef enum
|
||||
* the alpha value. Since: 4.6
|
||||
* @GDK_MEMORY_R32G32B32A32_FLOAT: 4 float values; for red, green, blue and
|
||||
* alpha. Since: 4.6
|
||||
* @GDK_MEMORY_G8A8_PREMULTIPLIED: 2 bytes; for grayscale, alpha. The color
|
||||
* values are premultiplied with the alpha value. Since: 4.12
|
||||
* @GDK_MEMORY_G8A8: 2 bytes; for grayscale, alpha. Since: 4.12
|
||||
* @GDK_MEMORY_G8: One byte; for grayscale. The data is opaque.
|
||||
* Since: 4.12
|
||||
* @GDK_MEMORY_G16A16_PREMULTIPLIED: 2 guint16 values; for grayscale, alpha.
|
||||
* The color values are premultiplied with the alpha value. Since: 4.12
|
||||
* @GDK_MEMORY_G16A16: 2 guint16 values; for grayscale, alpha. Since: 4.12
|
||||
* @GDK_MEMORY_G16: One guint16 value; for grayscale. The data is opaque.
|
||||
* Since: 4.12
|
||||
* @GDK_MEMORY_A8: One byte; for alpha.
|
||||
* Since: 4.12
|
||||
* @GDK_MEMORY_A16: One guint16 value; for alpha.
|
||||
* Since: 4.12
|
||||
* @GDK_MEMORY_N_FORMATS: The number of formats. This value will change as
|
||||
* more formats get added, so do not rely on its concrete integer.
|
||||
*
|
||||
@@ -356,14 +340,6 @@ typedef enum {
|
||||
GDK_MEMORY_R32G32B32_FLOAT,
|
||||
GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
|
||||
GDK_MEMORY_R32G32B32A32_FLOAT,
|
||||
GDK_MEMORY_G8A8_PREMULTIPLIED GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GDK_MEMORY_G8A8 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GDK_MEMORY_G8 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GDK_MEMORY_G16A16_PREMULTIPLIED GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GDK_MEMORY_G16A16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GDK_MEMORY_G16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GDK_MEMORY_A8 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
GDK_MEMORY_A16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
|
||||
|
||||
GDK_MEMORY_N_FORMATS
|
||||
} GdkMemoryFormat;
|
||||
|
||||
@@ -173,8 +173,12 @@ static GPrivate thread_current_context = G_PRIVATE_INIT (unref_unmasked);
|
||||
static void
|
||||
gdk_gl_context_clear_old_updated_area (GdkGLContext *context)
|
||||
{
|
||||
for (unsigned int i = 0; i < GDK_GL_MAX_TRACKED_BUFFERS; i++)
|
||||
g_clear_pointer (&context->old_updated_area[i], cairo_region_destroy);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
g_clear_pointer (&context->old_updated_area[i], cairo_region_destroy);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -581,7 +585,7 @@ gdk_gl_context_get_scale (GdkGLContext *self)
|
||||
|
||||
static void
|
||||
gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
|
||||
@@ -597,7 +601,7 @@ gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
if (priv->egl_context)
|
||||
gdk_surface_ensure_egl_surface (surface, depth != GDK_MEMORY_U8);
|
||||
gdk_surface_ensure_egl_surface (surface, prefers_high_depth);
|
||||
#endif
|
||||
|
||||
damage = GDK_GL_CONTEXT_GET_CLASS (context)->get_damage (context);
|
||||
@@ -1552,7 +1556,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
|
||||
|
||||
priv->has_sync = gdk_gl_context_check_version (context, "3.2", "3.0") ||
|
||||
epoxy_has_gl_extension ("GL_ARB_sync") ||
|
||||
epoxy_has_gl_extension ("GL_APPLE_sync");
|
||||
epoxy_has_gl_extension ("GK_APPLE_sync");
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
{
|
||||
|
||||
@@ -138,7 +138,6 @@ static gboolean
|
||||
gdk_gl_texture_find_format (gboolean use_es,
|
||||
guint gl_major,
|
||||
guint gl_minor,
|
||||
GdkMemoryAlpha alpha,
|
||||
GLint gl_format,
|
||||
GLint gl_type,
|
||||
GdkMemoryFormat *out_format)
|
||||
@@ -148,12 +147,8 @@ gdk_gl_texture_find_format (gboolean use_es,
|
||||
for (format = 0; format < GDK_MEMORY_N_FORMATS; format++)
|
||||
{
|
||||
GLenum q_internal_format, q_format, q_type;
|
||||
GLint q_swizzle[4];
|
||||
|
||||
if (gdk_memory_format_alpha (format) != alpha)
|
||||
continue;
|
||||
|
||||
if (!gdk_memory_format_gl_format (format, use_es, gl_major, gl_minor, &q_internal_format, &q_format, &q_type, &q_swizzle))
|
||||
if (!gdk_memory_format_gl_format (format, use_es, gl_major, gl_minor, &q_internal_format, &q_format, &q_type))
|
||||
continue;
|
||||
|
||||
if (q_format != gl_format || q_type != gl_type)
|
||||
@@ -172,57 +167,23 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
|
||||
gpointer download_)
|
||||
{
|
||||
GdkTexture *texture = GDK_TEXTURE (self);
|
||||
GdkMemoryFormat format;
|
||||
gsize expected_stride;
|
||||
Download *download = download_;
|
||||
GLenum gl_internal_format, gl_format, gl_type;
|
||||
GLint gl_swizzle[4];
|
||||
int major, minor;
|
||||
|
||||
format = gdk_texture_get_format (texture),
|
||||
expected_stride = texture->width * gdk_memory_format_bytes_per_pixel (download->format);
|
||||
gdk_gl_context_get_version (context, &major, &minor);
|
||||
|
||||
if (!gdk_gl_context_get_use_es (context) &&
|
||||
gdk_memory_format_gl_format (format,
|
||||
FALSE,
|
||||
major, minor,
|
||||
&gl_internal_format,
|
||||
&gl_format, &gl_type, &gl_swizzle))
|
||||
if (download->stride == expected_stride &&
|
||||
!gdk_gl_context_get_use_es (context) &&
|
||||
gdk_memory_format_gl_format (download->format, TRUE, major, minor, &gl_internal_format, &gl_format, &gl_type))
|
||||
{
|
||||
if (download->stride == expected_stride &&
|
||||
download->format == format)
|
||||
{
|
||||
glGetTexImage (GL_TEXTURE_2D,
|
||||
0,
|
||||
gl_format,
|
||||
gl_type,
|
||||
download->data);
|
||||
}
|
||||
else
|
||||
{
|
||||
gsize stride = texture->width * gdk_memory_format_bytes_per_pixel (format);
|
||||
guchar *pixels = g_malloc_n (stride, texture->height);
|
||||
|
||||
glPixelStorei (GL_PACK_ALIGNMENT, 1);
|
||||
glGetTexImage (GL_TEXTURE_2D,
|
||||
0,
|
||||
gl_format,
|
||||
gl_type,
|
||||
pixels);
|
||||
|
||||
gdk_memory_convert (download->data,
|
||||
download->stride,
|
||||
download->format,
|
||||
pixels,
|
||||
stride,
|
||||
format,
|
||||
texture->width,
|
||||
texture->height);
|
||||
|
||||
g_free (pixels);
|
||||
|
||||
}
|
||||
glGetTexImage (GL_TEXTURE_2D,
|
||||
0,
|
||||
gl_format,
|
||||
gl_type,
|
||||
download->data);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -235,26 +196,17 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
|
||||
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, self->id, 0);
|
||||
if (gdk_gl_context_check_version (context, "4.3", "3.1"))
|
||||
{
|
||||
gdk_gl_context_get_version (context, &major, &minor);
|
||||
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_read_format);
|
||||
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_TYPE, &gl_read_type);
|
||||
if (!gdk_gl_texture_find_format (TRUE, major, minor, gdk_memory_format_alpha (format), gl_read_format, gl_read_type, &actual_format))
|
||||
{
|
||||
gl_read_format = GL_RGBA;
|
||||
gl_read_type = GL_UNSIGNED_BYTE;
|
||||
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_PREMULTIPLIED)
|
||||
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
|
||||
else
|
||||
actual_format = GDK_MEMORY_R8G8B8A8;
|
||||
}
|
||||
if (!gdk_gl_texture_find_format (gdk_gl_context_get_use_es (context), major, minor, gl_read_format, gl_read_type, &actual_format))
|
||||
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_read_format = GL_RGBA;
|
||||
gl_read_type = GL_UNSIGNED_BYTE;
|
||||
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_PREMULTIPLIED)
|
||||
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
|
||||
else
|
||||
actual_format = GDK_MEMORY_R8G8B8A8;
|
||||
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
||||
}
|
||||
|
||||
if (download->format == actual_format &&
|
||||
@@ -269,95 +221,19 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
|
||||
else
|
||||
{
|
||||
gsize actual_bpp = gdk_memory_format_bytes_per_pixel (actual_format);
|
||||
gsize stride = actual_bpp * texture->width;
|
||||
guchar *pixels = g_malloc_n (stride, texture->height);
|
||||
guchar *pixels = g_malloc_n (texture->width * actual_bpp, texture->height);
|
||||
|
||||
glPixelStorei (GL_PACK_ALIGNMENT, 1);
|
||||
glReadPixels (0, 0,
|
||||
texture->width, texture->height,
|
||||
gl_read_format,
|
||||
gl_read_type,
|
||||
pixels);
|
||||
|
||||
/* Fix up gles inadequacies */
|
||||
|
||||
if (gl_read_format == GL_RGBA &&
|
||||
gl_read_type == GL_UNSIGNED_BYTE &&
|
||||
(format == GDK_MEMORY_G8A8 ||
|
||||
format == GDK_MEMORY_G8A8_PREMULTIPLIED ||
|
||||
format == GDK_MEMORY_G8 ||
|
||||
format == GDK_MEMORY_A8))
|
||||
{
|
||||
for (unsigned int y = 0; y < texture->height; y++)
|
||||
{
|
||||
for (unsigned int x = 0; x < texture->width; x++)
|
||||
{
|
||||
guchar *data = &pixels[y * stride + x * actual_bpp];
|
||||
if (format == GDK_MEMORY_G8A8 ||
|
||||
format == GDK_MEMORY_G8A8_PREMULTIPLIED)
|
||||
{
|
||||
data[3] = data[1];
|
||||
data[1] = data[0];
|
||||
data[2] = data[0];
|
||||
}
|
||||
else if (format == GDK_MEMORY_G8)
|
||||
{
|
||||
data[1] = data[0];
|
||||
data[2] = data[0];
|
||||
data[3] = 0xff;
|
||||
}
|
||||
else if (format == GDK_MEMORY_A8)
|
||||
{
|
||||
data[3] = data[0];
|
||||
data[0] = 0;
|
||||
data[1] = 0;
|
||||
data[2] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gl_read_format == GL_RGBA &&
|
||||
gl_read_type == GL_UNSIGNED_SHORT &&
|
||||
(format == GDK_MEMORY_G16A16 ||
|
||||
format == GDK_MEMORY_G16A16_PREMULTIPLIED ||
|
||||
format == GDK_MEMORY_G16 ||
|
||||
format == GDK_MEMORY_A16))
|
||||
{
|
||||
for (unsigned int y = 0; y < texture->height; y++)
|
||||
{
|
||||
for (unsigned int x = 0; x < texture->width; x++)
|
||||
{
|
||||
guint16 *data = (guint16 *) &pixels[y * stride + x * actual_bpp];
|
||||
if (format == GDK_MEMORY_G16A16 ||
|
||||
format == GDK_MEMORY_G16A16_PREMULTIPLIED)
|
||||
{
|
||||
data[3] = data[1];
|
||||
data[1] = data[0];
|
||||
data[2] = data[0];
|
||||
}
|
||||
else if (format == GDK_MEMORY_G16)
|
||||
{
|
||||
data[1] = data[0];
|
||||
data[2] = data[0];
|
||||
data[3] = 0xffff;
|
||||
}
|
||||
else if (format == GDK_MEMORY_A16)
|
||||
{
|
||||
data[3] = data[0];
|
||||
data[0] = 0;
|
||||
data[1] = 0;
|
||||
data[2] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gdk_memory_convert (download->data,
|
||||
download->stride,
|
||||
download->format,
|
||||
pixels,
|
||||
stride,
|
||||
texture->width * actual_bpp,
|
||||
actual_format,
|
||||
texture->width,
|
||||
texture->height);
|
||||
|
||||
@@ -644,18 +644,10 @@ gdk_gl_texture_builder_get_format (GdkGLTextureBuilder *self)
|
||||
* The format is the preferred format the texture data should be downloaded to. The
|
||||
* format must be supported by the GL version of [property@Gdk.GLTextureBuilder:context].
|
||||
*
|
||||
* GDK's texture download code assumes that the format corresponds to the storage
|
||||
* parameters of the GL texture in an obvious way. For example, a format of
|
||||
* `GDK_MEMORY_R16G16B16A16_PREMULTIPLIED` is expected to be stored as `GL_RGBA16`
|
||||
* texture, and `GDK_MEMORY_G8A8` is expected to be stored as `GL_RG8` texture.
|
||||
*
|
||||
* Setting the right format is particularly useful when using high bit depth textures
|
||||
* to preserve the bit depth, to set the correct value for unpremultiplied textures
|
||||
* and to make sure opaque textures are treated as such.
|
||||
*
|
||||
* Non-RGBA textures need to have swizzling parameters set up properly to be usable
|
||||
* in GSK's shaders.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
void
|
||||
|
||||
@@ -60,36 +60,6 @@ name ## _from_float (guchar *dest_data, \
|
||||
} \
|
||||
}
|
||||
|
||||
#define TYPED_GRAY_FUNCS(name, T, G, A, bpp, scale) \
|
||||
static void \
|
||||
name ## _to_float (float *dest, \
|
||||
const guchar *src_data, \
|
||||
gsize n) \
|
||||
{ \
|
||||
for (gsize i = 0; i < n; i++) \
|
||||
{ \
|
||||
T *src = (T *) (src_data + i * bpp); \
|
||||
if (G >= 0) dest[0] = (float) src[G] / scale; else dest[0] = 1.0; \
|
||||
dest[1] = dest[2] = dest[0]; \
|
||||
if (A >= 0) dest[3] = (float) src[A] / scale; else dest[3] = 1.0; \
|
||||
dest += 4; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
static void \
|
||||
name ## _from_float (guchar *dest_data, \
|
||||
const float *src, \
|
||||
gsize n) \
|
||||
{ \
|
||||
for (gsize i = 0; i < n; i++) \
|
||||
{ \
|
||||
T *dest = (T *) (dest_data + i * bpp); \
|
||||
if (G >= 0) dest[G] = CLAMP ((src[0] + src[1] + src[2]) * scale / 3.f + 0.5, 0, scale); \
|
||||
if (A >= 0) dest[A] = CLAMP (src[3] * scale + 0.5, 0, scale); \
|
||||
src += 4; \
|
||||
} \
|
||||
}
|
||||
|
||||
TYPED_FUNCS (b8g8r8a8_premultiplied, guchar, 2, 1, 0, 3, 4, 255)
|
||||
TYPED_FUNCS (a8r8g8b8_premultiplied, guchar, 1, 2, 3, 0, 4, 255)
|
||||
TYPED_FUNCS (r8g8b8a8_premultiplied, guchar, 0, 1, 2, 3, 4, 255)
|
||||
@@ -102,15 +72,6 @@ TYPED_FUNCS (b8g8r8, guchar, 2, 1, 0, -1, 3, 255)
|
||||
TYPED_FUNCS (r16g16b16, guint16, 0, 1, 2, -1, 6, 65535)
|
||||
TYPED_FUNCS (r16g16b16a16, guint16, 0, 1, 2, 3, 8, 65535)
|
||||
|
||||
TYPED_GRAY_FUNCS (g8a8_premultiplied, guchar, 0, 1, 2, 255)
|
||||
TYPED_GRAY_FUNCS (g8a8, guchar, 0, 1, 2, 255)
|
||||
TYPED_GRAY_FUNCS (g8, guchar, 0, -1, 1, 255)
|
||||
TYPED_GRAY_FUNCS (a8, guchar, -1, 0, 1, 255)
|
||||
TYPED_GRAY_FUNCS (g16a16_premultiplied, guint16, 0, 1, 4, 65535)
|
||||
TYPED_GRAY_FUNCS (g16a16, guint16, 0, 1, 4, 65535)
|
||||
TYPED_GRAY_FUNCS (g16, guint16, 0, -1, 2, 65535)
|
||||
TYPED_GRAY_FUNCS (a16, guint16, -1, 0, 2, 65535)
|
||||
|
||||
static void
|
||||
r16g16b16_float_to_float (float *dest,
|
||||
const guchar *src_data,
|
||||
@@ -258,7 +219,7 @@ struct _GdkMemoryFormatDescription
|
||||
GdkMemoryAlpha alpha;
|
||||
gsize bytes_per_pixel;
|
||||
gsize alignment;
|
||||
GdkMemoryDepth depth;
|
||||
gboolean prefers_high_depth;
|
||||
struct {
|
||||
guint gl_major;
|
||||
guint gl_minor;
|
||||
@@ -269,7 +230,6 @@ struct _GdkMemoryFormatDescription
|
||||
guint internal_format;
|
||||
guint format;
|
||||
guint type;
|
||||
GLint swizzle[4];
|
||||
} gl;
|
||||
/* no premultiplication going on here */
|
||||
void (* to_float) (float *, const guchar*, gsize);
|
||||
@@ -289,9 +249,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
GDK_MEMORY_U8,
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE },
|
||||
b8g8r8a8_premultiplied_to_float,
|
||||
b8g8r8a8_premultiplied_from_float,
|
||||
},
|
||||
@@ -299,9 +259,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
GDK_MEMORY_U8,
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
|
||||
a8r8g8b8_premultiplied_to_float,
|
||||
a8r8g8b8_premultiplied_from_float,
|
||||
},
|
||||
@@ -309,9 +269,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
GDK_MEMORY_U8,
|
||||
FALSE,
|
||||
{ 0, 0, 0, 0 },
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE },
|
||||
r8g8b8a8_premultiplied_to_float,
|
||||
r8g8b8a8_premultiplied_from_float,
|
||||
},
|
||||
@@ -319,9 +279,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
GDK_MEMORY_U8,
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE },
|
||||
b8g8r8a8_to_float,
|
||||
b8g8r8a8_from_float,
|
||||
},
|
||||
@@ -329,9 +289,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
GDK_MEMORY_U8,
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGBA8, GL_RGBA, GDK_GL_UNSIGNED_BYTE_FLIPPED, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
{ GL_RGBA8, GL_RGBA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
|
||||
a8r8g8b8_to_float,
|
||||
a8r8g8b8_from_float,
|
||||
},
|
||||
@@ -339,9 +299,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
GDK_MEMORY_U8,
|
||||
FALSE,
|
||||
{ 0, 0, 0, 0 },
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE },
|
||||
r8g8b8a8_to_float,
|
||||
r8g8b8a8_from_float,
|
||||
},
|
||||
@@ -349,9 +309,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
4,
|
||||
G_ALIGNOF (guchar),
|
||||
GDK_MEMORY_U8,
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
|
||||
a8b8g8r8_to_float,
|
||||
a8b8g8r8_from_float,
|
||||
},
|
||||
@@ -359,9 +319,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_OPAQUE,
|
||||
3,
|
||||
G_ALIGNOF (guchar),
|
||||
GDK_MEMORY_U8,
|
||||
FALSE,
|
||||
{ 0, 0, 0, 0 },
|
||||
{ GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
|
||||
{ GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE },
|
||||
r8g8b8_to_float,
|
||||
r8g8b8_from_float,
|
||||
},
|
||||
@@ -369,9 +329,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_OPAQUE,
|
||||
3,
|
||||
G_ALIGNOF (guchar),
|
||||
GDK_MEMORY_U8,
|
||||
FALSE,
|
||||
{ 0, 0, G_MAXUINT, G_MAXUINT },
|
||||
{ GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
|
||||
{ GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE },
|
||||
b8g8r8_to_float,
|
||||
b8g8r8_from_float,
|
||||
},
|
||||
@@ -379,9 +339,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_OPAQUE,
|
||||
6,
|
||||
G_ALIGNOF (guint16),
|
||||
GDK_MEMORY_U16,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
|
||||
{ GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT },
|
||||
r16g16b16_to_float,
|
||||
r16g16b16_from_float,
|
||||
},
|
||||
@@ -389,9 +349,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
8,
|
||||
G_ALIGNOF (guint16),
|
||||
GDK_MEMORY_U16,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
|
||||
r16g16b16a16_to_float,
|
||||
r16g16b16a16_from_float,
|
||||
},
|
||||
@@ -399,9 +359,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
8,
|
||||
G_ALIGNOF (guint16),
|
||||
GDK_MEMORY_U16,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
|
||||
r16g16b16a16_to_float,
|
||||
r16g16b16a16_from_float,
|
||||
},
|
||||
@@ -409,9 +369,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_OPAQUE,
|
||||
6,
|
||||
G_ALIGNOF (guint16),
|
||||
GDK_MEMORY_FLOAT16,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGB16F, GL_RGB, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
|
||||
{ GL_RGB16F, GL_RGB, GL_HALF_FLOAT },
|
||||
r16g16b16_float_to_float,
|
||||
r16g16b16_float_from_float,
|
||||
},
|
||||
@@ -419,9 +379,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
8,
|
||||
G_ALIGNOF (guint16),
|
||||
GDK_MEMORY_FLOAT16,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT },
|
||||
r16g16b16a16_float_to_float,
|
||||
r16g16b16a16_float_from_float,
|
||||
},
|
||||
@@ -429,9 +389,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
8,
|
||||
G_ALIGNOF (guint16),
|
||||
GDK_MEMORY_FLOAT16,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT },
|
||||
r16g16b16a16_float_to_float,
|
||||
r16g16b16a16_float_from_float,
|
||||
},
|
||||
@@ -439,9 +399,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_OPAQUE,
|
||||
12,
|
||||
G_ALIGNOF (float),
|
||||
GDK_MEMORY_FLOAT32,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGB32F, GL_RGB, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
|
||||
{ GL_RGB32F, GL_RGB, GL_FLOAT },
|
||||
r32g32b32_float_to_float,
|
||||
r32g32b32_float_from_float,
|
||||
},
|
||||
@@ -451,7 +411,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
G_ALIGNOF (float),
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA32F, GL_RGBA, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
{ GL_RGBA32F, GL_RGBA, GL_FLOAT },
|
||||
r32g32b32a32_float_to_float,
|
||||
r32g32b32a32_float_from_float,
|
||||
},
|
||||
@@ -459,91 +419,11 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
16,
|
||||
G_ALIGNOF (float),
|
||||
GDK_MEMORY_FLOAT32,
|
||||
TRUE,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RGBA32F, GL_RGBA, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
|
||||
{ GL_RGBA32F, GL_RGBA, GL_FLOAT },
|
||||
r32g32b32a32_float_to_float,
|
||||
r32g32b32a32_float_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G8A8_PREMULTIPLIED] = {
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
2,
|
||||
G_ALIGNOF (guchar),
|
||||
GDK_MEMORY_U8,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RG8, GL_RG, GL_UNSIGNED_BYTE, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
|
||||
g8a8_premultiplied_to_float,
|
||||
g8a8_premultiplied_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G8A8] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
2,
|
||||
G_ALIGNOF (guchar),
|
||||
GDK_MEMORY_U8,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RG8, GL_RG, GL_UNSIGNED_BYTE, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
|
||||
g8a8_to_float,
|
||||
g8a8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G8] = {
|
||||
GDK_MEMORY_ALPHA_OPAQUE,
|
||||
1,
|
||||
G_ALIGNOF (guchar),
|
||||
GDK_MEMORY_U8,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_R8, GL_RED, GL_UNSIGNED_BYTE, { GL_RED, GL_RED, GL_RED, GL_ONE } },
|
||||
g8_to_float,
|
||||
g8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G16A16_PREMULTIPLIED] = {
|
||||
GDK_MEMORY_ALPHA_PREMULTIPLIED,
|
||||
4,
|
||||
G_ALIGNOF (guint16),
|
||||
GDK_MEMORY_U16,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RG16, GL_RG, GL_UNSIGNED_SHORT, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
|
||||
g16a16_premultiplied_to_float,
|
||||
g16a16_premultiplied_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G16A16] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
4,
|
||||
G_ALIGNOF (guint16),
|
||||
GDK_MEMORY_U16,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_RG16, GL_RG, GL_UNSIGNED_SHORT, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
|
||||
g16a16_to_float,
|
||||
g16a16_from_float,
|
||||
},
|
||||
[GDK_MEMORY_G16] = {
|
||||
GDK_MEMORY_ALPHA_OPAQUE,
|
||||
2,
|
||||
G_ALIGNOF (guint16),
|
||||
GDK_MEMORY_U16,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_R16, GL_RED, GL_UNSIGNED_SHORT, { GL_RED, GL_RED, GL_RED, GL_ONE } },
|
||||
g16_to_float,
|
||||
g16_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A8] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
1,
|
||||
G_ALIGNOF (guchar),
|
||||
GDK_MEMORY_U8,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_R8, GL_RED, GL_UNSIGNED_BYTE, { GL_ONE, GL_ONE, GL_ONE, GL_RED } },
|
||||
a8_to_float,
|
||||
a8_from_float,
|
||||
},
|
||||
[GDK_MEMORY_A16] = {
|
||||
GDK_MEMORY_ALPHA_STRAIGHT,
|
||||
2,
|
||||
G_ALIGNOF (guint16),
|
||||
GDK_MEMORY_U16,
|
||||
{ 0, 0, 3, 0 },
|
||||
{ GL_R16, GL_RED, GL_UNSIGNED_SHORT, { GL_ONE, GL_ONE, GL_ONE, GL_RED } },
|
||||
a16_to_float,
|
||||
a16_from_float,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -566,57 +446,23 @@ gdk_memory_format_alignment (GdkMemoryFormat format)
|
||||
}
|
||||
|
||||
/*<private>
|
||||
* gdk_memory_format_get_depth:
|
||||
* gdk_memory_format_prefers_high_depth:
|
||||
* @format: a memory format
|
||||
*
|
||||
* Gets the depth of the individual channels of the format.
|
||||
* See gsk_render_node_prefers_high_depth() for more
|
||||
* information on this.
|
||||
* Checks if the given format benefits from being rendered
|
||||
* in bit depths higher than 8bits per pixel. See
|
||||
* gsk_render_node_prefers_high_depth() for more information
|
||||
* on this.
|
||||
* Usually this is the case when
|
||||
* gdk_memory_format_bytes_per_pixel() is larger than 4.
|
||||
*
|
||||
* Usually renderers want to use higher depth for render
|
||||
* targets to match these formats.
|
||||
*
|
||||
* Returns: The depth of this format
|
||||
* Returns: %TRUE if the format benefits from being
|
||||
* composited in hgiher bit depths.
|
||||
**/
|
||||
GdkMemoryDepth
|
||||
gdk_memory_format_get_depth (GdkMemoryFormat format)
|
||||
gboolean
|
||||
gdk_memory_format_prefers_high_depth (GdkMemoryFormat format)
|
||||
{
|
||||
return memory_formats[format].depth;
|
||||
}
|
||||
|
||||
/*<private>
|
||||
* gdk_memory_depth_merge:
|
||||
* @depth1: the first depth
|
||||
* @depth2: the second depth
|
||||
*
|
||||
* Returns a depth that can accomodate both given depths
|
||||
* without any loss of precision.
|
||||
*
|
||||
* Returns: The merged depth
|
||||
**/
|
||||
GdkMemoryDepth
|
||||
gdk_memory_depth_merge (GdkMemoryDepth depth1,
|
||||
GdkMemoryDepth depth2)
|
||||
{
|
||||
switch (depth1)
|
||||
{
|
||||
case GDK_MEMORY_U8:
|
||||
return depth2;
|
||||
|
||||
case GDK_MEMORY_FLOAT32:
|
||||
return GDK_MEMORY_FLOAT32;
|
||||
|
||||
case GDK_MEMORY_U16:
|
||||
case GDK_MEMORY_FLOAT16:
|
||||
if (depth2 == depth1 || depth2 == GDK_MEMORY_U8)
|
||||
return depth1;
|
||||
else
|
||||
return GDK_MEMORY_FLOAT32;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return GDK_MEMORY_U8;
|
||||
}
|
||||
return memory_formats[format].prefers_high_depth;
|
||||
}
|
||||
|
||||
gboolean
|
||||
@@ -626,13 +472,14 @@ gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||
guint gl_minor,
|
||||
guint *out_internal_format,
|
||||
guint *out_format,
|
||||
guint *out_type,
|
||||
GLint (*out_swizzle)[4])
|
||||
guint *out_type)
|
||||
{
|
||||
*out_internal_format = memory_formats[format].gl.internal_format;
|
||||
*out_format = memory_formats[format].gl.format;
|
||||
*out_type = memory_formats[format].gl.type;
|
||||
memcpy (out_swizzle, &memory_formats[format].gl.swizzle, sizeof(GLint) * 4);
|
||||
|
||||
if (memory_formats[format].alpha == GDK_MEMORY_ALPHA_STRAIGHT)
|
||||
return FALSE;
|
||||
|
||||
if (gles)
|
||||
{
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
|
||||
#include "gdkenums.h"
|
||||
|
||||
#include <epoxy/gl.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef enum {
|
||||
@@ -31,27 +29,17 @@ typedef enum {
|
||||
GDK_MEMORY_ALPHA_OPAQUE
|
||||
} GdkMemoryAlpha;
|
||||
|
||||
typedef enum {
|
||||
GDK_MEMORY_U8,
|
||||
GDK_MEMORY_U16,
|
||||
GDK_MEMORY_FLOAT16,
|
||||
GDK_MEMORY_FLOAT32
|
||||
} GdkMemoryDepth;
|
||||
|
||||
gsize gdk_memory_format_alignment (GdkMemoryFormat format) G_GNUC_CONST;
|
||||
GdkMemoryAlpha gdk_memory_format_alpha (GdkMemoryFormat format) G_GNUC_CONST;
|
||||
gsize gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format) G_GNUC_CONST;
|
||||
GdkMemoryDepth gdk_memory_format_get_depth (GdkMemoryFormat format) G_GNUC_CONST;
|
||||
GdkMemoryDepth gdk_memory_depth_merge (GdkMemoryDepth depth1,
|
||||
GdkMemoryDepth depth2) G_GNUC_CONST;
|
||||
gboolean gdk_memory_format_prefers_high_depth(GdkMemoryFormat format) G_GNUC_CONST;
|
||||
gboolean gdk_memory_format_gl_format (GdkMemoryFormat format,
|
||||
gboolean gles,
|
||||
guint gl_major,
|
||||
guint gl_minor,
|
||||
guint *out_internal_format,
|
||||
guint *out_format,
|
||||
guint *out_type,
|
||||
GLint (*out_gizzle)[4]);
|
||||
guint *out_type);
|
||||
|
||||
void gdk_memory_convert (guchar *dest_data,
|
||||
gsize dest_stride,
|
||||
|
||||
@@ -55,7 +55,7 @@ typedef enum {
|
||||
GDK_SEAT_CAPABILITY_KEYBOARD = 1 << 3,
|
||||
GDK_SEAT_CAPABILITY_TABLET_PAD = 1 << 4,
|
||||
GDK_SEAT_CAPABILITY_ALL_POINTING = (GDK_SEAT_CAPABILITY_POINTER | GDK_SEAT_CAPABILITY_TOUCH | GDK_SEAT_CAPABILITY_TABLET_STYLUS),
|
||||
GDK_SEAT_CAPABILITY_ALL = (GDK_SEAT_CAPABILITY_ALL_POINTING | GDK_SEAT_CAPABILITY_KEYBOARD | GDK_SEAT_CAPABILITY_TABLET_PAD)
|
||||
GDK_SEAT_CAPABILITY_ALL = (GDK_SEAT_CAPABILITY_ALL_POINTING | GDK_SEAT_CAPABILITY_KEYBOARD)
|
||||
} GdkSeatCapabilities;
|
||||
|
||||
struct _GdkSeat
|
||||
|
||||
@@ -25,8 +25,7 @@
|
||||
* multiple frames, and will be used for a long time.
|
||||
*
|
||||
* There are various ways to create `GdkTexture` objects from a
|
||||
* [class@GdkPixbuf.Pixbuf], or from bytes stored in memory, a file, or a
|
||||
* [struct@Gio.Resource].
|
||||
* [class@GdkPixbuf.Pixbuf], or a Cairo surface, or other pixel data.
|
||||
*
|
||||
* The ownership of the pixel data is transferred to the `GdkTexture`
|
||||
* instance; you can only make a copy of it, via [method@Gdk.Texture.download].
|
||||
|
||||
@@ -47,12 +47,7 @@ typedef struct _GdkVulkanContextPrivate GdkVulkanContextPrivate;
|
||||
struct _GdkVulkanContextPrivate {
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
VkSurfaceKHR surface;
|
||||
struct {
|
||||
VkSurfaceFormatKHR vk_format;
|
||||
GdkMemoryFormat gdk_format;
|
||||
} formats[4];
|
||||
GdkMemoryDepth current_format;
|
||||
GdkMemoryFormat offscreen_formats[4];
|
||||
VkSurfaceFormatKHR image_format;
|
||||
|
||||
VkSwapchainKHR swapchain;
|
||||
VkSemaphore draw_semaphore;
|
||||
@@ -383,13 +378,6 @@ gdk_vulkan_context_check_swapchain (GdkVulkanContext *context,
|
||||
|
||||
device = gdk_vulkan_context_get_device (context);
|
||||
|
||||
/*
|
||||
* Wait for device to be idle because this function is also called in window resizes.
|
||||
* And if we destroy old swapchain it also destroy the old VkImages, those images could
|
||||
* be in use by a vulkan render.
|
||||
*/
|
||||
vkDeviceWaitIdle (device);
|
||||
|
||||
res = GDK_VK_CHECK (vkGetPhysicalDeviceSurfaceCapabilitiesKHR, gdk_vulkan_context_get_physical_device (context),
|
||||
priv->surface,
|
||||
&capabilities);
|
||||
@@ -441,8 +429,8 @@ gdk_vulkan_context_check_swapchain (GdkVulkanContext *context,
|
||||
.minImageCount = CLAMP (4,
|
||||
capabilities.minImageCount,
|
||||
capabilities.maxImageCount ? capabilities.maxImageCount : G_MAXUINT32),
|
||||
.imageFormat = priv->formats[priv->current_format].vk_format.format,
|
||||
.imageColorSpace = priv->formats[priv->current_format].vk_format.colorSpace,
|
||||
.imageFormat = priv->image_format.format,
|
||||
.imageColorSpace = priv->image_format.colorSpace,
|
||||
.imageExtent = capabilities.currentExtent,
|
||||
.imageArrayLayers = 1,
|
||||
.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
||||
@@ -511,20 +499,19 @@ gdk_vulkan_context_check_swapchain (GdkVulkanContext *context,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
physical_device_supports_extension (VkPhysicalDevice device,
|
||||
const char *extension_name)
|
||||
device_supports_incremental_present (VkPhysicalDevice device)
|
||||
{
|
||||
VkExtensionProperties *extensions;
|
||||
uint32_t n_device_extensions;
|
||||
|
||||
GDK_VK_CHECK (vkEnumerateDeviceExtensionProperties, device, NULL, &n_device_extensions, NULL);
|
||||
vkEnumerateDeviceExtensionProperties (device, NULL, &n_device_extensions, NULL);
|
||||
|
||||
extensions = g_newa (VkExtensionProperties, n_device_extensions);
|
||||
GDK_VK_CHECK (vkEnumerateDeviceExtensionProperties, device, NULL, &n_device_extensions, extensions);
|
||||
vkEnumerateDeviceExtensionProperties (device, NULL, &n_device_extensions, extensions);
|
||||
|
||||
for (uint32_t i = 0; i < n_device_extensions; i++)
|
||||
{
|
||||
if (g_str_equal (extensions[i].extensionName, extension_name))
|
||||
if (g_str_equal (extensions[i].extensionName, VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -533,27 +520,13 @@ physical_device_supports_extension (VkPhysicalDevice device,
|
||||
|
||||
static void
|
||||
gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkVulkanContext *context = GDK_VULKAN_CONTEXT (draw_context);
|
||||
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
|
||||
guint i;
|
||||
|
||||
if (depth != priv->current_format)
|
||||
{
|
||||
if (priv->formats[depth].gdk_format != priv->formats[priv->current_format].gdk_format)
|
||||
{
|
||||
GError *error = NULL;
|
||||
if (!gdk_vulkan_context_check_swapchain (context, &error))
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
priv->current_format = depth;
|
||||
}
|
||||
for (i = 0; i < priv->n_images; i++)
|
||||
{
|
||||
cairo_region_union (priv->regions[i], region);
|
||||
@@ -692,7 +665,6 @@ gdk_vulkan_context_real_init (GInitable *initable,
|
||||
GdkVulkanContext *context = GDK_VULKAN_CONTEXT (initable);
|
||||
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
|
||||
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
|
||||
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
|
||||
VkResult res;
|
||||
VkBool32 supported;
|
||||
uint32_t i;
|
||||
@@ -701,22 +673,6 @@ gdk_vulkan_context_real_init (GInitable *initable,
|
||||
if (!priv->vulkan_ref)
|
||||
return FALSE;
|
||||
|
||||
priv->offscreen_formats[GDK_MEMORY_U8] = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED;
|
||||
priv->offscreen_formats[GDK_MEMORY_U16] = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED;
|
||||
priv->offscreen_formats[GDK_MEMORY_FLOAT16] = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED;
|
||||
priv->offscreen_formats[GDK_MEMORY_FLOAT32] = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED;
|
||||
|
||||
if (surface == NULL)
|
||||
{
|
||||
for (i = 0; i < G_N_ELEMENTS (priv->formats); i++)
|
||||
{
|
||||
priv->formats[i].vk_format.format = VK_FORMAT_B8G8R8A8_UNORM;
|
||||
priv->formats[i].vk_format.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
|
||||
priv->formats[i].gdk_format = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
res = GDK_VULKAN_CONTEXT_GET_CLASS (context)->create_surface (context, &priv->surface);
|
||||
if (res != VK_SUCCESS)
|
||||
{
|
||||
@@ -751,74 +707,17 @@ gdk_vulkan_context_real_init (GInitable *initable,
|
||||
&n_formats, formats);
|
||||
for (i = 0; i < n_formats; i++)
|
||||
{
|
||||
if (formats[i].colorSpace != VK_COLOR_SPACE_SRGB_NONLINEAR_KHR)
|
||||
continue;
|
||||
|
||||
switch ((int) formats[i].format)
|
||||
{
|
||||
case VK_FORMAT_B8G8R8A8_UNORM:
|
||||
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED)
|
||||
{
|
||||
priv->formats[GDK_MEMORY_U8].vk_format = formats[i];
|
||||
priv->formats[GDK_MEMORY_U8].gdk_format = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED;
|
||||
priv->offscreen_formats[GDK_MEMORY_U8] = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED;
|
||||
};
|
||||
break;
|
||||
|
||||
case VK_FORMAT_R8G8B8A8_UNORM:
|
||||
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED)
|
||||
{
|
||||
priv->formats[GDK_MEMORY_U8].vk_format = formats[i];
|
||||
priv->formats[GDK_MEMORY_U8].gdk_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_FORMAT_R16G16B16A16_UNORM:
|
||||
priv->formats[GDK_MEMORY_U16].vk_format = formats[i];
|
||||
priv->formats[GDK_MEMORY_U16].gdk_format = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED;
|
||||
break;
|
||||
|
||||
case VK_FORMAT_R16G16B16A16_SFLOAT:
|
||||
priv->formats[GDK_MEMORY_FLOAT16].vk_format = formats[i];
|
||||
priv->formats[GDK_MEMORY_FLOAT16].gdk_format = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED;
|
||||
break;
|
||||
|
||||
case VK_FORMAT_R32G32B32A32_SFLOAT:
|
||||
priv->formats[GDK_MEMORY_FLOAT32].vk_format = formats[i];
|
||||
priv->formats[GDK_MEMORY_FLOAT32].gdk_format = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (formats[i].format == VK_FORMAT_B8G8R8A8_UNORM)
|
||||
break;
|
||||
}
|
||||
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED)
|
||||
if (i == n_formats)
|
||||
{
|
||||
g_set_error_literal (error, GDK_VULKAN_ERROR, GDK_VULKAN_ERROR_NOT_AVAILABLE,
|
||||
"No supported image format found.");
|
||||
goto out_surface;
|
||||
}
|
||||
/* Ensure all the formats exist:
|
||||
* - If a format was found, keep that one.
|
||||
* - FLOAT32 chooses the best format we have.
|
||||
* - FLOAT16 and U16 pick the format FLOAT32 uses
|
||||
*/
|
||||
if (priv->formats[GDK_MEMORY_FLOAT32].vk_format.format == VK_FORMAT_UNDEFINED)
|
||||
{
|
||||
if (priv->formats[GDK_MEMORY_FLOAT16].vk_format.format != VK_FORMAT_UNDEFINED)
|
||||
priv->formats[GDK_MEMORY_FLOAT32] = priv->formats[GDK_MEMORY_FLOAT16];
|
||||
else if (priv->formats[GDK_MEMORY_U16].vk_format.format != VK_FORMAT_UNDEFINED)
|
||||
priv->formats[GDK_MEMORY_FLOAT32] = priv->formats[GDK_MEMORY_U16];
|
||||
else
|
||||
priv->formats[GDK_MEMORY_FLOAT32] = priv->formats[GDK_MEMORY_U8];
|
||||
}
|
||||
if (priv->formats[GDK_MEMORY_FLOAT16].vk_format.format == VK_FORMAT_UNDEFINED)
|
||||
priv->formats[GDK_MEMORY_FLOAT16] = priv->formats[GDK_MEMORY_FLOAT32];
|
||||
if (priv->formats[GDK_MEMORY_U16].vk_format.format == VK_FORMAT_UNDEFINED)
|
||||
priv->formats[GDK_MEMORY_U16] = priv->formats[GDK_MEMORY_FLOAT32];
|
||||
|
||||
priv->has_present_region = physical_device_supports_extension (display->vk_physical_device,
|
||||
VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
|
||||
priv->image_format = formats[i];
|
||||
priv->has_present_region = device_supports_incremental_present (display->vk_physical_device);
|
||||
|
||||
if (!gdk_vulkan_context_check_swapchain (context, error))
|
||||
goto out_surface;
|
||||
@@ -841,15 +740,6 @@ out_surface:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GdkMemoryFormat
|
||||
gdk_vulkan_context_get_offscreen_format (GdkVulkanContext *context,
|
||||
GdkMemoryDepth depth)
|
||||
{
|
||||
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
|
||||
|
||||
return priv->offscreen_formats[depth];
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_vulkan_context_initable_init (GInitableIface *iface)
|
||||
{
|
||||
@@ -938,216 +828,6 @@ gdk_vulkan_context_get_queue_family_index (GdkVulkanContext *context)
|
||||
return gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context))->vk_queue_family_index;
|
||||
}
|
||||
|
||||
static char *
|
||||
gdk_vulkan_get_pipeline_cache_dirname (void)
|
||||
{
|
||||
return g_build_filename (g_get_user_cache_dir (), "gtk-4.0", "vulkan-pipeline-cache", NULL);
|
||||
}
|
||||
|
||||
static GFile *
|
||||
gdk_vulkan_get_pipeline_cache_file (GdkDisplay *display)
|
||||
{
|
||||
VkPhysicalDeviceProperties props;
|
||||
char *dirname, *basename, *path;
|
||||
GFile *result;
|
||||
|
||||
vkGetPhysicalDeviceProperties (display->vk_physical_device, &props);
|
||||
|
||||
dirname = gdk_vulkan_get_pipeline_cache_dirname ();
|
||||
basename = g_strdup_printf ("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x"
|
||||
"-%02x%02x%02x%02x%02x%02x.%u",
|
||||
props.pipelineCacheUUID[0], props.pipelineCacheUUID[1],
|
||||
props.pipelineCacheUUID[2], props.pipelineCacheUUID[3],
|
||||
props.pipelineCacheUUID[4], props.pipelineCacheUUID[5],
|
||||
props.pipelineCacheUUID[6], props.pipelineCacheUUID[7],
|
||||
props.pipelineCacheUUID[8], props.pipelineCacheUUID[9],
|
||||
props.pipelineCacheUUID[10], props.pipelineCacheUUID[11],
|
||||
props.pipelineCacheUUID[12], props.pipelineCacheUUID[13],
|
||||
props.pipelineCacheUUID[14], props.pipelineCacheUUID[15],
|
||||
props.driverVersion);
|
||||
|
||||
path = g_build_filename (dirname, basename, NULL);
|
||||
result = g_file_new_for_path (path);
|
||||
|
||||
g_free (path);
|
||||
g_free (basename);
|
||||
g_free (dirname);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static VkPipelineCache
|
||||
gdk_display_load_pipeline_cache (GdkDisplay *display)
|
||||
{
|
||||
GError *error = NULL;
|
||||
VkPipelineCache result;
|
||||
GFile *cache_file;
|
||||
char *etag, *data;
|
||||
gsize size;
|
||||
|
||||
cache_file = gdk_vulkan_get_pipeline_cache_file (display);
|
||||
if (!g_file_load_contents (cache_file, NULL, &data, &size, &etag, &error))
|
||||
{
|
||||
GDK_DEBUG (VULKAN, "failed to load Vulkan pipeline cache file '%s': %s\n",
|
||||
g_file_peek_path (cache_file), error->message);
|
||||
g_object_unref (cache_file);
|
||||
g_clear_error (&error);
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
if (GDK_VK_CHECK (vkCreatePipelineCache, display->vk_device,
|
||||
&(VkPipelineCacheCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO,
|
||||
.initialDataSize = size,
|
||||
.pInitialData = data,
|
||||
},
|
||||
NULL,
|
||||
&result) != VK_SUCCESS)
|
||||
result = VK_NULL_HANDLE;
|
||||
|
||||
g_free (data);
|
||||
g_free (display->vk_pipeline_cache_etag);
|
||||
display->vk_pipeline_cache_etag = etag;
|
||||
display->vk_pipeline_cache_size = size;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
||||
{
|
||||
GError *error = NULL;
|
||||
VkDevice device;
|
||||
VkPipelineCache cache;
|
||||
GFile *file;
|
||||
char *path;
|
||||
size_t size;
|
||||
char *data, *etag;
|
||||
|
||||
device = display->vk_device;
|
||||
cache = display->vk_pipeline_cache;
|
||||
|
||||
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)
|
||||
{
|
||||
g_free (data);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
path = gdk_vulkan_get_pipeline_cache_dirname ();
|
||||
if (g_mkdir_with_parents (path, 0755) != 0)
|
||||
{
|
||||
g_warning_once ("Failed to create pipeline cache directory");
|
||||
g_free (path);
|
||||
return FALSE;
|
||||
}
|
||||
g_free (path);
|
||||
|
||||
file = gdk_vulkan_get_pipeline_cache_file (display);
|
||||
|
||||
GDK_DEBUG (VULKAN, "Saving pipeline cache to %s", g_file_peek_path (file));
|
||||
|
||||
if (!g_file_replace_contents (file,
|
||||
data,
|
||||
size,
|
||||
display->vk_pipeline_cache_etag,
|
||||
FALSE,
|
||||
0,
|
||||
&etag,
|
||||
NULL,
|
||||
&error))
|
||||
{
|
||||
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)
|
||||
{
|
||||
GDK_VK_CHECK (vkMergePipelineCaches, device, cache, 1, &new_cache);
|
||||
vkDestroyPipelineCache (device, new_cache, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_clear_pointer (&display->vk_pipeline_cache_etag, g_free);
|
||||
}
|
||||
g_clear_error (&error);
|
||||
g_object_unref (file);
|
||||
|
||||
/* try again */
|
||||
return gdk_vulkan_save_pipeline_cache (display);
|
||||
}
|
||||
|
||||
g_warning ("Failed to save pipeline cache: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
g_object_unref (file);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_object_unref (file);
|
||||
g_free (display->vk_pipeline_cache_etag);
|
||||
display->vk_pipeline_cache_etag = etag;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_vulkan_save_pipeline_cache_cb (gpointer data)
|
||||
{
|
||||
GdkDisplay *display = data;
|
||||
|
||||
gdk_vulkan_save_pipeline_cache (display);
|
||||
|
||||
display->vk_save_pipeline_cache_source = 0;
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_vulkan_context_pipeline_cache_updated (GdkVulkanContext *self)
|
||||
{
|
||||
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (self));
|
||||
|
||||
g_clear_handle_id (&display->vk_save_pipeline_cache_source, g_source_remove);
|
||||
display->vk_save_pipeline_cache_source = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE - 10,
|
||||
10, /* random choice that is not now */
|
||||
gdk_vulkan_save_pipeline_cache_cb,
|
||||
display,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_display_create_pipeline_cache (GdkDisplay *display)
|
||||
{
|
||||
display->vk_pipeline_cache = gdk_display_load_pipeline_cache (display);
|
||||
|
||||
GDK_VK_CHECK (vkCreatePipelineCache, display->vk_device,
|
||||
&(VkPipelineCacheCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO,
|
||||
},
|
||||
NULL,
|
||||
&display->vk_pipeline_cache);
|
||||
}
|
||||
|
||||
VkPipelineCache
|
||||
gdk_vulkan_context_get_pipeline_cache (GdkVulkanContext *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_VULKAN_CONTEXT (self), NULL);
|
||||
|
||||
return gdk_draw_context_get_display (GDK_DRAW_CONTEXT (self))->vk_pipeline_cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_vulkan_context_get_image_format:
|
||||
* @context: a `GdkVulkanContext`
|
||||
@@ -1163,7 +843,7 @@ gdk_vulkan_context_get_image_format (GdkVulkanContext *context)
|
||||
|
||||
g_return_val_if_fail (GDK_IS_VULKAN_CONTEXT (context), VK_FORMAT_UNDEFINED);
|
||||
|
||||
return priv->formats[priv->current_format].vk_format.format;
|
||||
return priv->image_format.format;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1359,10 +1039,6 @@ gdk_display_create_vulkan_device (GdkDisplay *display,
|
||||
for (i = first; i < last; i++)
|
||||
{
|
||||
uint32_t n_queue_props;
|
||||
|
||||
if (!physical_device_supports_extension (devices[i], VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME))
|
||||
continue;
|
||||
|
||||
vkGetPhysicalDeviceQueueFamilyProperties (devices[i], &n_queue_props, NULL);
|
||||
VkQueueFamilyProperties *queue_props = g_newa (VkQueueFamilyProperties, n_queue_props);
|
||||
vkGetPhysicalDeviceQueueFamilyProperties (devices[i], &n_queue_props, queue_props);
|
||||
@@ -1373,36 +1049,30 @@ gdk_display_create_vulkan_device (GdkDisplay *display,
|
||||
GPtrArray *device_extensions;
|
||||
gboolean has_incremental_present;
|
||||
|
||||
has_incremental_present = physical_device_supports_extension (devices[i],
|
||||
VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
|
||||
has_incremental_present = device_supports_incremental_present (devices[i]);
|
||||
|
||||
device_extensions = g_ptr_array_new ();
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_SWAPCHAIN_EXTENSION_NAME);
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_MAINTENANCE_3_EXTENSION_NAME);
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
|
||||
if (has_incremental_present)
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
|
||||
|
||||
GDK_DISPLAY_DEBUG (display, VULKAN, "Using Vulkan device %u, queue %u", i, j);
|
||||
if (GDK_VK_CHECK (vkCreateDevice, devices[i],
|
||||
&(VkDeviceCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||
.queueCreateInfoCount = 1,
|
||||
.pQueueCreateInfos = &(VkDeviceQueueCreateInfo) {
|
||||
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||
NULL,
|
||||
0,
|
||||
1,
|
||||
&(VkDeviceQueueCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
|
||||
.queueFamilyIndex = j,
|
||||
.queueCount = 1,
|
||||
.pQueuePriorities = (float []) { 1.0f },
|
||||
},
|
||||
.enabledExtensionCount = device_extensions->len,
|
||||
.ppEnabledExtensionNames = (const char * const *) device_extensions->pdata,
|
||||
.pNext = &(VkPhysicalDeviceDescriptorIndexingFeatures) {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES,
|
||||
.descriptorBindingPartiallyBound = VK_TRUE,
|
||||
.descriptorBindingVariableDescriptorCount = VK_TRUE,
|
||||
.descriptorBindingSampledImageUpdateAfterBind = VK_TRUE,
|
||||
.descriptorBindingStorageBufferUpdateAfterBind = VK_TRUE,
|
||||
}
|
||||
0,
|
||||
NULL,
|
||||
device_extensions->len,
|
||||
(const char * const *) device_extensions->pdata
|
||||
},
|
||||
NULL,
|
||||
&display->vk_device) != VK_SUCCESS)
|
||||
@@ -1474,7 +1144,6 @@ gdk_display_create_vulkan_instance (GdkDisplay *display,
|
||||
|
||||
used_extensions = g_ptr_array_new ();
|
||||
g_ptr_array_add (used_extensions, (gpointer) VK_KHR_SURFACE_EXTENSION_NAME);
|
||||
g_ptr_array_add (used_extensions, (gpointer) VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
||||
g_ptr_array_add (used_extensions, (gpointer) GDK_DISPLAY_GET_CLASS (display)->vk_extension_name);
|
||||
|
||||
for (i = 0; i < n_extensions; i++)
|
||||
@@ -1546,7 +1215,7 @@ gdk_display_create_vulkan_instance (GdkDisplay *display,
|
||||
.enabledLayerCount = used_layers->len,
|
||||
.ppEnabledLayerNames = (const char * const *) used_layers->pdata,
|
||||
.enabledExtensionCount = used_extensions->len,
|
||||
.ppEnabledExtensionNames = (const char * const *) used_extensions->pdata,
|
||||
.ppEnabledExtensionNames = (const char * const *) used_extensions->pdata
|
||||
},
|
||||
NULL,
|
||||
&display->vk_instance);
|
||||
@@ -1598,10 +1267,6 @@ gdk_display_create_vulkan_instance (GdkDisplay *display,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gdk_display_create_pipeline_cache (display);
|
||||
|
||||
display->vk_shader_modules = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1623,9 +1288,6 @@ gdk_display_ref_vulkan (GdkDisplay *display,
|
||||
void
|
||||
gdk_display_unref_vulkan (GdkDisplay *display)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
gpointer key, value;
|
||||
|
||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||
g_return_if_fail (display->vulkan_refcount > 0);
|
||||
|
||||
@@ -1633,26 +1295,6 @@ gdk_display_unref_vulkan (GdkDisplay *display)
|
||||
if (display->vulkan_refcount > 0)
|
||||
return;
|
||||
|
||||
display->vk_shader_modules = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
g_hash_table_iter_init (&iter, display->vk_shader_modules);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
{
|
||||
g_free (key);
|
||||
vkDestroyShaderModule (display->vk_device,
|
||||
value,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (display->vk_save_pipeline_cache_source)
|
||||
{
|
||||
gdk_vulkan_save_pipeline_cache_cb (display);
|
||||
g_assert (display->vk_save_pipeline_cache_source == 0);
|
||||
}
|
||||
vkDestroyPipelineCache (display->vk_device, display->vk_pipeline_cache, NULL);
|
||||
display->vk_device = VK_NULL_HANDLE;
|
||||
g_clear_pointer (&display->vk_pipeline_cache_etag, g_free);
|
||||
display->vk_pipeline_cache_size = 0;
|
||||
|
||||
vkDestroyDevice (display->vk_device, NULL);
|
||||
display->vk_device = VK_NULL_HANDLE;
|
||||
if (display->vk_debug_callback != VK_NULL_HANDLE)
|
||||
@@ -1669,47 +1311,6 @@ gdk_display_unref_vulkan (GdkDisplay *display)
|
||||
display->vk_instance = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
VkShaderModule
|
||||
gdk_display_get_vk_shader_module (GdkDisplay *self,
|
||||
const char *resource_name)
|
||||
{
|
||||
VkShaderModule shader;
|
||||
GError *error = NULL;
|
||||
GBytes *bytes;
|
||||
|
||||
shader = g_hash_table_lookup (self->vk_shader_modules, resource_name);
|
||||
if (shader)
|
||||
return shader;
|
||||
|
||||
bytes = g_resources_lookup_data (resource_name, 0, &error);
|
||||
if (bytes == NULL)
|
||||
{
|
||||
GDK_DEBUG (VULKAN, "Error loading shader data: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
if (GDK_VK_CHECK (vkCreateShaderModule, self->vk_device,
|
||||
&(VkShaderModuleCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
|
||||
.codeSize = g_bytes_get_size (bytes),
|
||||
.pCode = (uint32_t *) g_bytes_get_data (bytes, NULL),
|
||||
},
|
||||
NULL,
|
||||
&shader) == VK_SUCCESS)
|
||||
{
|
||||
g_hash_table_insert (self->vk_shader_modules, g_strdup (resource_name), shader);
|
||||
}
|
||||
else
|
||||
{
|
||||
shader = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
#else /* GDK_RENDERING_VULKAN */
|
||||
|
||||
static void
|
||||
|
||||
@@ -69,18 +69,9 @@ gdk_vulkan_handle_result (VkResult res,
|
||||
|
||||
#define GDK_VK_CHECK(func, ...) gdk_vulkan_handle_result (func (__VA_ARGS__), G_STRINGIFY (func))
|
||||
|
||||
gboolean gdk_display_ref_vulkan (GdkDisplay *display,
|
||||
GError **error);
|
||||
void gdk_display_unref_vulkan (GdkDisplay *display);
|
||||
|
||||
VkShaderModule gdk_display_get_vk_shader_module (GdkDisplay *display,
|
||||
const char *resource_name);
|
||||
|
||||
VkPipelineCache gdk_vulkan_context_get_pipeline_cache (GdkVulkanContext *self);
|
||||
void gdk_vulkan_context_pipeline_cache_updated (GdkVulkanContext *self);
|
||||
|
||||
GdkMemoryFormat gdk_vulkan_context_get_offscreen_format (GdkVulkanContext *context,
|
||||
GdkMemoryDepth depth);
|
||||
gboolean gdk_display_ref_vulkan (GdkDisplay *display,
|
||||
GError **error);
|
||||
void gdk_display_unref_vulkan (GdkDisplay *display);
|
||||
|
||||
#else /* !GDK_RENDERING_VULKAN */
|
||||
|
||||
|
||||
@@ -183,7 +183,8 @@ gdk_load_png (GBytes *bytes,
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_set_palette_to_rgb (png);
|
||||
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY)
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
png_set_expand_gray_1_2_4_to_8 (png);
|
||||
|
||||
if (png_get_valid (png, info, PNG_INFO_tRNS))
|
||||
@@ -192,6 +193,10 @@ gdk_load_png (GBytes *bytes,
|
||||
if (depth < 8)
|
||||
png_set_packing (png);
|
||||
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
png_set_gray_to_rgb (png);
|
||||
|
||||
if (interlace != PNG_INTERLACE_NONE)
|
||||
png_set_interlace_handling (png);
|
||||
|
||||
@@ -234,26 +239,6 @@ gdk_load_png (GBytes *bytes,
|
||||
format = GDK_MEMORY_R16G16B16;
|
||||
}
|
||||
break;
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
if (depth == 8)
|
||||
{
|
||||
format = GDK_MEMORY_G8;
|
||||
}
|
||||
else if (depth == 16)
|
||||
{
|
||||
format = GDK_MEMORY_G16;
|
||||
}
|
||||
break;
|
||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||
if (depth == 8)
|
||||
{
|
||||
format = GDK_MEMORY_G8A8;
|
||||
}
|
||||
else if (depth == 16)
|
||||
{
|
||||
format = GDK_MEMORY_G16A16;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
png_destroy_read_struct (&png, &info, NULL);
|
||||
g_set_error (error,
|
||||
@@ -364,34 +349,6 @@ gdk_save_png (GdkTexture *texture)
|
||||
depth = 16;
|
||||
break;
|
||||
|
||||
case GDK_MEMORY_G8:
|
||||
format = GDK_MEMORY_G8;
|
||||
png_format = PNG_COLOR_TYPE_GRAY;
|
||||
depth = 8;
|
||||
break;
|
||||
|
||||
case GDK_MEMORY_G8A8_PREMULTIPLIED:
|
||||
case GDK_MEMORY_G8A8:
|
||||
case GDK_MEMORY_A8:
|
||||
format = GDK_MEMORY_G8A8;
|
||||
png_format = PNG_COLOR_TYPE_GRAY_ALPHA;
|
||||
depth = 8;
|
||||
break;
|
||||
|
||||
case GDK_MEMORY_G16:
|
||||
format = GDK_MEMORY_G16;
|
||||
png_format = PNG_COLOR_TYPE_GRAY;
|
||||
depth = 16;
|
||||
break;
|
||||
|
||||
case GDK_MEMORY_G16A16_PREMULTIPLIED:
|
||||
case GDK_MEMORY_G16A16:
|
||||
case GDK_MEMORY_A16:
|
||||
format = GDK_MEMORY_G16A16;
|
||||
png_format = PNG_COLOR_TYPE_GRAY_ALPHA;
|
||||
depth = 16;
|
||||
break;
|
||||
|
||||
case GDK_MEMORY_N_FORMATS:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
|
||||
@@ -229,36 +229,27 @@ struct _FormatData {
|
||||
guint16 samples_per_pixel;
|
||||
guint16 sample_format;
|
||||
guint16 alpha_samples;
|
||||
guint16 photometric;
|
||||
};
|
||||
|
||||
static const FormatData format_data[] = {
|
||||
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_B8G8R8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_A8R8G8B8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R8G8B8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_A8B8G8R8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R8G8B8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_B8G8R8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R16G16B16] = { GDK_MEMORY_R16G16B16, 16, 3, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R16G16B16A16] = { GDK_MEMORY_R16G16B16A16, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R16G16B16_FLOAT] = { GDK_MEMORY_R16G16B16_FLOAT, 16, 3, SAMPLEFORMAT_IEEEFP, 0, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R16G16B16A16_FLOAT] = { GDK_MEMORY_R16G16B16A16_FLOAT, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R32G32B32_FLOAT] = { GDK_MEMORY_R32G32B32_FLOAT, 32, 3, SAMPLEFORMAT_IEEEFP, 0, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_R32G32B32A32_FLOAT] = { GDK_MEMORY_R32G32B32A32_FLOAT, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
|
||||
[GDK_MEMORY_G8A8_PREMULTIPLIED] = { GDK_MEMORY_G8A8_PREMULTIPLIED, 8, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_MINISBLACK },
|
||||
[GDK_MEMORY_G8A8] = { GDK_MEMORY_G8A8, 8, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
|
||||
[GDK_MEMORY_G8] = { GDK_MEMORY_G8, 8, 1, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_MINISBLACK },
|
||||
[GDK_MEMORY_G16A16_PREMULTIPLIED] = { GDK_MEMORY_G16A16_PREMULTIPLIED, 16, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_MINISBLACK },
|
||||
[GDK_MEMORY_G16A16] = { GDK_MEMORY_G16A16, 16, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
|
||||
[GDK_MEMORY_G16] = { GDK_MEMORY_G16, 16, 1, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_MINISBLACK },
|
||||
[GDK_MEMORY_A8] = { GDK_MEMORY_G8A8, 8, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
|
||||
[GDK_MEMORY_A16] = { GDK_MEMORY_G16A16, 16, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
|
||||
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
|
||||
[GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
|
||||
[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
|
||||
[GDK_MEMORY_B8G8R8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
|
||||
[GDK_MEMORY_A8R8G8B8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
|
||||
[GDK_MEMORY_R8G8B8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
|
||||
[GDK_MEMORY_A8B8G8R8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
|
||||
[GDK_MEMORY_R8G8B8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0 },
|
||||
[GDK_MEMORY_B8G8R8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0 },
|
||||
[GDK_MEMORY_R16G16B16] = { GDK_MEMORY_R16G16B16, 16, 3, SAMPLEFORMAT_UINT, 0 },
|
||||
[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
|
||||
[GDK_MEMORY_R16G16B16A16] = { GDK_MEMORY_R16G16B16A16, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
|
||||
[GDK_MEMORY_R16G16B16_FLOAT] = { GDK_MEMORY_R16G16B16_FLOAT, 16, 3, SAMPLEFORMAT_IEEEFP, 0 },
|
||||
[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA },
|
||||
[GDK_MEMORY_R16G16B16A16_FLOAT] = { GDK_MEMORY_R16G16B16A16_FLOAT, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA },
|
||||
[GDK_MEMORY_R32G32B32_FLOAT] = { GDK_MEMORY_R32G32B32_FLOAT, 32, 3, SAMPLEFORMAT_IEEEFP, 0 },
|
||||
[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA },
|
||||
[GDK_MEMORY_R32G32B32A32_FLOAT] = { GDK_MEMORY_R32G32B32A32_FLOAT, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA },
|
||||
};
|
||||
|
||||
/* if this fails, somebody forgot to add formats above */
|
||||
@@ -298,7 +289,7 @@ gdk_save_tiff (GdkTexture *texture)
|
||||
if (fdata->alpha_samples)
|
||||
TIFFSetField (tif, TIFFTAG_EXTRASAMPLES, 1, &fdata->alpha_samples);
|
||||
|
||||
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, fdata->photometric);
|
||||
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
|
||||
TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
|
||||
gdk_texture_downloader_init (&downloader, texture);
|
||||
@@ -406,7 +397,7 @@ gdk_load_tiff (GBytes *input_bytes,
|
||||
TIFFGetFieldDefaulted (tif, TIFFTAG_IMAGEWIDTH, &width);
|
||||
TIFFGetFieldDefaulted (tif, TIFFTAG_IMAGELENGTH, &height);
|
||||
|
||||
if (samples_per_pixel == 2 || samples_per_pixel == 4)
|
||||
if (samples_per_pixel == 4)
|
||||
{
|
||||
guint16 extra;
|
||||
guint16 *extra_types;
|
||||
@@ -435,15 +426,14 @@ gdk_load_tiff (GBytes *input_bytes,
|
||||
if (format_data[format].sample_format == sample_format &&
|
||||
format_data[format].bits_per_sample == bits_per_sample &&
|
||||
format_data[format].samples_per_pixel == samples_per_pixel &&
|
||||
format_data[format].alpha_samples == alpha_samples &&
|
||||
format_data[format].photometric == photometric)
|
||||
format_data[format].alpha_samples == alpha_samples)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (format == G_N_ELEMENTS(format_data) ||
|
||||
(photometric != PHOTOMETRIC_RGB && photometric != PHOTOMETRIC_MINISBLACK) ||
|
||||
photometric != PHOTOMETRIC_RGB ||
|
||||
planarconfig != PLANARCONFIG_CONTIG ||
|
||||
TIFFIsTiled (tif) ||
|
||||
orientation != ORIENTATION_TOPLEFT)
|
||||
|
||||
@@ -190,7 +190,7 @@ copy_surface_data (GdkMacosBuffer *from,
|
||||
|
||||
static void
|
||||
_gdk_macos_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkMacosCairoContext *self = (GdkMacosCairoContext *)draw_context;
|
||||
|
||||
@@ -344,14 +344,14 @@ create_pixel_format (GdkGLVersion *version,
|
||||
if (gdk_gl_version_get_major (version) >= 4)
|
||||
{
|
||||
attrs[1] = (CGLPixelFormatAttribute)kCGLOGLPVersion_GL4_Core;
|
||||
if (CHECK (error, CGLChoosePixelFormat (attrs, &format, &n_format)))
|
||||
if (CGLChoosePixelFormat (attrs, &format, &n_format))
|
||||
return g_steal_pointer (&format);
|
||||
}
|
||||
|
||||
if (gdk_gl_version_greater_equal (version, &GDK_GL_MIN_GL_VERSION))
|
||||
{
|
||||
attrs[1] = (CGLPixelFormatAttribute)kCGLOGLPVersion_GL3_Core;
|
||||
if (CHECK (error, CGLChoosePixelFormat (attrs, &format, &n_format)))
|
||||
if (CGLChoosePixelFormat (attrs, &format, &n_format))
|
||||
return g_steal_pointer (&format);
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
|
||||
gdk_gl_context_get_matching_version (context,
|
||||
GDK_GL_API_GL,
|
||||
FALSE,
|
||||
&min_version);
|
||||
&version);
|
||||
|
||||
display = gdk_gl_context_get_display (context);
|
||||
shared = gdk_display_get_gl_context (display);
|
||||
@@ -480,7 +480,7 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
|
||||
|
||||
static void
|
||||
gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkMacosGLContext *self = (GdkMacosGLContext *)context;
|
||||
|
||||
@@ -207,7 +207,7 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
|
||||
{
|
||||
char *path;
|
||||
XcursorImages *images;
|
||||
struct wl_cursor *cursor;
|
||||
struct cursor *cursor;
|
||||
struct cursor_image *image;
|
||||
int i, nbytes;
|
||||
unsigned int load_size;
|
||||
@@ -240,16 +240,17 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cursor->images =
|
||||
malloc(images->nimage * sizeof cursor->images[0]);
|
||||
if (!cursor->images) {
|
||||
cursor->cursor.images =
|
||||
malloc(images->nimage * sizeof cursor->cursor.images[0]);
|
||||
if (!cursor->cursor.images) {
|
||||
free(cursor);
|
||||
xcursor_images_destroy (images);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cursor->name = strdup(name);
|
||||
cursor->size = load_size;
|
||||
cursor->cursor.name = strdup(name);
|
||||
cursor->cursor.size = load_size;
|
||||
cursor->total_delay = 0;
|
||||
|
||||
for (i = 0; i < images->nimage; i++) {
|
||||
image = malloc(sizeof *image);
|
||||
@@ -290,13 +291,14 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor->images[i] = (struct wl_cursor_image *) image;
|
||||
cursor->total_delay += image->image.delay;
|
||||
cursor->cursor.images[i] = (struct wl_cursor_image *) image;
|
||||
}
|
||||
cursor->image_count = i;
|
||||
cursor->cursor.image_count = i;
|
||||
|
||||
if (cursor->image_count == 0) {
|
||||
free(cursor->name);
|
||||
free(cursor->images);
|
||||
if (cursor->cursor.image_count == 0) {
|
||||
free(cursor->cursor.name);
|
||||
free(cursor->cursor.images);
|
||||
free(cursor);
|
||||
xcursor_images_destroy (images);
|
||||
return NULL;
|
||||
@@ -304,7 +306,7 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
|
||||
|
||||
xcursor_images_destroy (images);
|
||||
|
||||
return cursor;
|
||||
return &cursor->cursor;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -145,7 +145,7 @@ gdk_wayland_cairo_context_create_surface (GdkWaylandCairoContext *self)
|
||||
|
||||
static void
|
||||
gdk_wayland_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkWaylandCairoContext *self = GDK_WAYLAND_CAIRO_CONTEXT (draw_context);
|
||||
|
||||
@@ -698,36 +698,7 @@ gdk_wayland_display_dispose (GObject *object)
|
||||
|
||||
g_list_free_full (display_wayland->on_has_globals_closures, g_free);
|
||||
|
||||
g_clear_pointer (&display_wayland->cursor_theme, wl_cursor_theme_destroy);
|
||||
g_clear_pointer (&display_wayland->compositor, wl_compositor_destroy);
|
||||
g_clear_pointer (&display_wayland->xdg_wm_base, xdg_wm_base_destroy);
|
||||
g_clear_pointer (&display_wayland->zxdg_shell_v6, zxdg_shell_v6_destroy);
|
||||
g_clear_pointer (&display_wayland->gtk_shell, gtk_shell1_destroy);
|
||||
g_clear_pointer (&display_wayland->data_device_manager, wl_data_device_manager_destroy);
|
||||
g_clear_pointer (&display_wayland->subcompositor, wl_subcompositor_destroy);
|
||||
g_clear_pointer (&display_wayland->pointer_gestures, zwp_pointer_gestures_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->primary_selection_manager, zwp_primary_selection_device_manager_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->tablet_manager, zwp_tablet_manager_v2_destroy);
|
||||
g_clear_pointer (&display_wayland->xdg_exporter, zxdg_exporter_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->xdg_exporter_v2, zxdg_exporter_v2_destroy);
|
||||
g_clear_pointer (&display_wayland->xdg_importer, zxdg_importer_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->xdg_importer_v2, zxdg_importer_v2_destroy);
|
||||
g_clear_pointer (&display_wayland->keyboard_shortcuts_inhibit, zwp_keyboard_shortcuts_inhibit_manager_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->server_decoration_manager, org_kde_kwin_server_decoration_manager_destroy);
|
||||
g_clear_pointer (&display_wayland->xdg_output_manager, zxdg_output_manager_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->idle_inhibit_manager, zwp_idle_inhibit_manager_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->xdg_activation, xdg_activation_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->fractional_scale, wp_fractional_scale_manager_v1_destroy);
|
||||
g_clear_pointer (&display_wayland->viewporter, wp_viewporter_destroy);
|
||||
|
||||
g_clear_pointer (&display_wayland->shm, wl_shm_destroy);
|
||||
g_clear_pointer (&display_wayland->wl_registry, wl_registry_destroy);
|
||||
|
||||
g_list_store_remove_all (display_wayland->monitors);
|
||||
|
||||
G_OBJECT_CLASS (gdk_wayland_display_parent_class)->dispose (object);
|
||||
|
||||
g_clear_pointer (&display_wayland->wl_display, wl_display_disconnect);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -737,17 +708,22 @@ gdk_wayland_display_finalize (GObject *object)
|
||||
|
||||
_gdk_wayland_display_finalize_cursors (display_wayland);
|
||||
|
||||
g_object_unref (display_wayland->monitors);
|
||||
|
||||
g_free (display_wayland->startup_notification_id);
|
||||
g_free (display_wayland->cursor_theme_name);
|
||||
xkb_context_unref (display_wayland->xkb_context);
|
||||
|
||||
g_clear_pointer (&display_wayland->cursor_theme, wl_cursor_theme_destroy);
|
||||
|
||||
g_list_store_remove_all (display_wayland->monitors);
|
||||
g_object_unref (display_wayland->monitors);
|
||||
|
||||
if (display_wayland->settings)
|
||||
g_hash_table_destroy (display_wayland->settings);
|
||||
|
||||
g_clear_object (&display_wayland->settings_portal);
|
||||
|
||||
wl_display_disconnect (display_wayland->wl_display);
|
||||
|
||||
G_OBJECT_CLASS (gdk_wayland_display_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ struct _GdkWaylandDisplay
|
||||
struct xdg_wm_base *xdg_wm_base;
|
||||
struct zxdg_shell_v6 *zxdg_shell_v6;
|
||||
struct gtk_shell1 *gtk_shell;
|
||||
struct wl_input_device *input_device;
|
||||
struct wl_data_device_manager *data_device_manager;
|
||||
struct wl_subcompositor *subcompositor;
|
||||
struct zwp_pointer_gestures_v1 *pointer_gestures;
|
||||
|
||||
@@ -48,12 +48,12 @@ G_DEFINE_TYPE (GdkWaylandGLContext, gdk_wayland_gl_context, GDK_TYPE_GL_CONTEXT)
|
||||
|
||||
static void
|
||||
gdk_wayland_gl_context_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
gdk_wayland_surface_ensure_wl_egl_window (gdk_draw_context_get_surface (draw_context));
|
||||
|
||||
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->begin_frame (draw_context, depth, region);
|
||||
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->begin_frame (draw_context, prefers_high_depth, region);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -2143,13 +2143,10 @@ _gdk_wayland_seat_remove_tablet_pad (GdkWaylandSeat *seat,
|
||||
{
|
||||
seat->tablet_pads = g_list_remove (seat->tablet_pads, pad);
|
||||
|
||||
if (pad->device)
|
||||
{
|
||||
gdk_seat_device_removed (GDK_SEAT (seat), pad->device);
|
||||
_gdk_device_set_associated_device (pad->device, NULL);
|
||||
g_object_unref (pad->device);
|
||||
}
|
||||
gdk_seat_device_removed (GDK_SEAT (seat), pad->device);
|
||||
_gdk_device_set_associated_device (pad->device, NULL);
|
||||
|
||||
g_object_unref (pad->device);
|
||||
g_free (pad);
|
||||
}
|
||||
|
||||
@@ -3064,9 +3061,9 @@ tablet_tool_handle_button (void *data,
|
||||
tablet->pointer_info.press_serial = serial;
|
||||
|
||||
if (button == BTN_STYLUS)
|
||||
n_button = GDK_BUTTON_MIDDLE;
|
||||
else if (button == BTN_STYLUS2)
|
||||
n_button = GDK_BUTTON_SECONDARY;
|
||||
else if (button == BTN_STYLUS2)
|
||||
n_button = GDK_BUTTON_MIDDLE;
|
||||
else if (button == BTN_STYLUS3)
|
||||
n_button = 8; /* Back */
|
||||
else
|
||||
@@ -3538,10 +3535,21 @@ static void
|
||||
tablet_pad_handle_done (void *data,
|
||||
struct zwp_tablet_pad_v2 *wp_tablet_pad)
|
||||
{
|
||||
G_GNUC_UNUSED GdkWaylandTabletPadData *pad = data;
|
||||
GdkWaylandTabletPadData *pad = data;
|
||||
|
||||
GDK_SEAT_DEBUG (pad->seat, EVENTS,
|
||||
"tablet pad handle done, pad = %p", wp_tablet_pad);
|
||||
|
||||
pad->device =
|
||||
g_object_new (GDK_TYPE_WAYLAND_DEVICE_PAD,
|
||||
"name", "Pad device",
|
||||
"source", GDK_SOURCE_TABLET_PAD,
|
||||
"display", gdk_seat_get_display (pad->seat),
|
||||
"seat", pad->seat,
|
||||
NULL);
|
||||
|
||||
_gdk_device_set_associated_device (pad->device, GDK_WAYLAND_SEAT (pad->seat)->logical_keyboard);
|
||||
gdk_seat_device_added (GDK_SEAT (pad->seat), pad->device);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3598,44 +3606,9 @@ tablet_pad_handle_enter (void *data,
|
||||
"tablet pad handle enter, pad = %p, tablet = %p surface = %p",
|
||||
wp_tablet_pad, wp_tablet, surface);
|
||||
|
||||
if (pad->device && pad->current_tablet != tablet)
|
||||
{
|
||||
gdk_seat_device_removed (GDK_SEAT (pad->seat), pad->device);
|
||||
_gdk_device_set_associated_device (pad->device, NULL);
|
||||
g_clear_object (&pad->device);
|
||||
}
|
||||
|
||||
/* Relate pad and tablet */
|
||||
tablet->pads = g_list_prepend (tablet->pads, pad);
|
||||
pad->current_tablet = tablet;
|
||||
|
||||
if (!pad->device)
|
||||
{
|
||||
gchar *name, *vid, *pid;
|
||||
|
||||
name = g_strdup_printf ("%s Pad %d",
|
||||
tablet->name,
|
||||
g_list_index (tablet->pads, pad) + 1);
|
||||
vid = g_strdup_printf ("%.4x", tablet->vid);
|
||||
pid = g_strdup_printf ("%.4x", tablet->pid);
|
||||
|
||||
pad->device =
|
||||
g_object_new (GDK_TYPE_WAYLAND_DEVICE_PAD,
|
||||
"name", name,
|
||||
"vendor-id", vid,
|
||||
"product-id", pid,
|
||||
"source", GDK_SOURCE_TABLET_PAD,
|
||||
"display", gdk_seat_get_display (pad->seat),
|
||||
"seat", pad->seat,
|
||||
NULL);
|
||||
|
||||
_gdk_device_set_associated_device (pad->device, GDK_WAYLAND_SEAT (pad->seat)->logical_keyboard);
|
||||
gdk_seat_device_added (GDK_SEAT (pad->seat), pad->device);
|
||||
|
||||
g_free (name);
|
||||
g_free (vid);
|
||||
g_free (pid);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3651,7 +3624,10 @@ tablet_pad_handle_leave (void *data,
|
||||
wp_tablet_pad, surface);
|
||||
|
||||
if (pad->current_tablet)
|
||||
pad->current_tablet->pads = g_list_remove (pad->current_tablet->pads, pad);
|
||||
{
|
||||
pad->current_tablet->pads = g_list_remove (pad->current_tablet->pads, pad);
|
||||
pad->current_tablet = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3899,23 +3875,6 @@ gdk_wayland_pointer_data_finalize (GdkWaylandPointerData *pointer)
|
||||
g_slist_free (pointer->pointer_surface_outputs);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_seat_dispose (GObject *object)
|
||||
{
|
||||
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (object);
|
||||
|
||||
g_clear_pointer (&seat->wl_seat, wl_seat_destroy);
|
||||
g_clear_pointer (&seat->wl_pointer, wl_pointer_destroy);
|
||||
g_clear_pointer (&seat->wl_keyboard, wl_keyboard_destroy);
|
||||
g_clear_pointer (&seat->wl_touch, wl_touch_destroy);
|
||||
g_clear_pointer (&seat->wp_pointer_gesture_swipe, zwp_pointer_gesture_swipe_v1_destroy);
|
||||
g_clear_pointer (&seat->wp_pointer_gesture_pinch, zwp_pointer_gesture_pinch_v1_destroy);
|
||||
g_clear_pointer (&seat->wp_pointer_gesture_hold, zwp_pointer_gesture_hold_v1_destroy);
|
||||
g_clear_pointer (&seat->wp_tablet_seat, zwp_tablet_seat_v2_destroy);
|
||||
|
||||
G_OBJECT_CLASS (gdk_wayland_seat_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_seat_finalize (GObject *object)
|
||||
{
|
||||
@@ -4230,7 +4189,6 @@ gdk_wayland_seat_class_init (GdkWaylandSeatClass *klass)
|
||||
GdkSeatClass *seat_class = GDK_SEAT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gdk_wayland_seat_finalize;
|
||||
object_class->dispose = gdk_wayland_seat_dispose;
|
||||
|
||||
seat_class->get_capabilities = gdk_wayland_seat_get_capabilities;
|
||||
seat_class->grab = gdk_wayland_seat_grab;
|
||||
|
||||
@@ -53,7 +53,7 @@ create_cairo_surface_for_surface (GdkSurface *surface,
|
||||
|
||||
static void
|
||||
gdk_win32_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkWin32CairoContext *self = GDK_WIN32_CAIRO_CONTEXT (draw_context);
|
||||
|
||||
@@ -1436,7 +1436,7 @@ register_clipboard_notification ()
|
||||
|
||||
wclass.lpszClassName = "GdkClipboardNotification";
|
||||
wclass.lpfnWndProc = _clipboard_window_procedure;
|
||||
wclass.hInstance = this_module ();
|
||||
wclass.hInstance = _gdk_dll_hinstance;
|
||||
wclass.cbWndExtra = sizeof (GdkWin32ClipboardThread *);
|
||||
|
||||
klass = RegisterClass (&wclass);
|
||||
@@ -1446,7 +1446,7 @@ register_clipboard_notification ()
|
||||
clipboard_thread_data->clipboard_window = CreateWindow (MAKEINTRESOURCE (klass),
|
||||
NULL, WS_POPUP,
|
||||
0, 0, 0, 0, NULL, NULL,
|
||||
this_module (), NULL);
|
||||
_gdk_dll_hinstance, NULL);
|
||||
|
||||
if (clipboard_thread_data->clipboard_window == NULL)
|
||||
goto failed;
|
||||
@@ -1471,7 +1471,7 @@ register_clipboard_notification ()
|
||||
|
||||
failed:
|
||||
g_critical ("Failed to install clipboard viewer");
|
||||
UnregisterClass (MAKEINTRESOURCE (klass), this_module ());
|
||||
UnregisterClass (MAKEINTRESOURCE (klass), _gdk_dll_hinstance);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -417,12 +417,13 @@ hcursor_from_x_cursor (int i,
|
||||
#undef SET_BIT
|
||||
#undef RESET_BIT
|
||||
|
||||
rv = CreateCursor (NULL, cursors[i].hotx, cursors[i].hoty,
|
||||
rv = CreateCursor (_gdk_app_hmodule, cursors[i].hotx, cursors[i].hoty,
|
||||
w, h, and_plane, xor_plane);
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = CreateCursor (NULL, 0, 0, w, h, and_plane, xor_plane);
|
||||
rv = CreateCursor (_gdk_app_hmodule, 0, 0,
|
||||
w, h, and_plane, xor_plane);
|
||||
}
|
||||
|
||||
if (rv == NULL)
|
||||
@@ -465,7 +466,7 @@ win32_cursor_create_win32hcursor (GdkWin32Display *display,
|
||||
break;
|
||||
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_THIS:
|
||||
result = gdk_win32_hcursor_new (display,
|
||||
LoadImageA (GetModuleHandle (NULL),
|
||||
LoadImageA (_gdk_app_hmodule,
|
||||
(const char *) cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
@@ -475,7 +476,7 @@ win32_cursor_create_win32hcursor (GdkWin32Display *display,
|
||||
break;
|
||||
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_GTK:
|
||||
result = gdk_win32_hcursor_new (display,
|
||||
LoadImageA (this_module (),
|
||||
LoadImageA (_gdk_dll_hinstance,
|
||||
(const char *) cursor->resource_name,
|
||||
IMAGE_CURSOR,
|
||||
cursor->width,
|
||||
@@ -857,7 +858,9 @@ create_blank_win32hcursor (GdkWin32Display *display)
|
||||
xor_plane = g_malloc ((w/8) * h);
|
||||
memset (xor_plane, 0, (w/8) * h);
|
||||
|
||||
rv = CreateCursor (NULL, 0, 0, w, h, and_plane, xor_plane);
|
||||
rv = CreateCursor (_gdk_app_hmodule, 0, 0,
|
||||
w, h, and_plane, xor_plane);
|
||||
|
||||
if (rv == NULL)
|
||||
WIN32_API_FAILED ("CreateCursor");
|
||||
|
||||
@@ -868,7 +871,6 @@ static GdkWin32HCursor *
|
||||
gdk_win32hcursor_create_for_name (GdkWin32Display *display,
|
||||
const char *name)
|
||||
{
|
||||
const HINSTANCE hinstance = GetModuleHandle (NULL);
|
||||
GdkWin32HCursor *win32hcursor = NULL;
|
||||
|
||||
/* Blank cursor case */
|
||||
@@ -883,7 +885,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, LoadCursor (hinstance, name), FALSE);
|
||||
return gdk_win32_hcursor_new (display, LoadCursor (_gdk_app_hmodule, name), FALSE);
|
||||
}
|
||||
|
||||
static HICON
|
||||
@@ -1450,6 +1452,27 @@ pixbuf_to_hicon (GdkPixbuf *pixbuf,
|
||||
return icon;
|
||||
}
|
||||
|
||||
HICON
|
||||
_gdk_win32_texture_to_hicon (GdkTexture *texture)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
GdkPixbuf *pixbuf;
|
||||
int width, height;
|
||||
HICON icon;
|
||||
|
||||
surface = gdk_texture_download_surface (texture);
|
||||
width = cairo_image_surface_get_width (surface);
|
||||
height = cairo_image_surface_get_height (surface);
|
||||
|
||||
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
|
||||
|
||||
icon = pixbuf_to_hicon (pixbuf, TRUE, 0, 0);
|
||||
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_win32_display_get_win32hcursor:
|
||||
* @display: (type GdkWin32Display): a `GdkDisplay`
|
||||
|
||||
@@ -292,7 +292,6 @@ _gdk_win32_display_init_monitors (GdkWin32Display *win32_display)
|
||||
if (!w32_ex_monitor->remove)
|
||||
continue;
|
||||
|
||||
w32_ex_monitor->hmonitor = NULL;
|
||||
g_list_store_remove (G_LIST_STORE (win32_display->monitors), i);
|
||||
gdk_monitor_invalidate (ex_monitor);
|
||||
}
|
||||
@@ -481,7 +480,7 @@ register_display_change_notification (GdkDisplay *display)
|
||||
|
||||
wclass.lpszClassName = "GdkDisplayChange";
|
||||
wclass.lpfnWndProc = display_change_window_procedure;
|
||||
wclass.hInstance = this_module ();
|
||||
wclass.hInstance = _gdk_app_hmodule;
|
||||
wclass.style = CS_OWNDC;
|
||||
|
||||
klass = RegisterClass (&wclass);
|
||||
@@ -490,10 +489,10 @@ register_display_change_notification (GdkDisplay *display)
|
||||
display_win32->hwnd = CreateWindow (MAKEINTRESOURCE (klass),
|
||||
NULL, WS_POPUP,
|
||||
0, 0, 0, 0, NULL, NULL,
|
||||
this_module (), NULL);
|
||||
_gdk_app_hmodule, NULL);
|
||||
if (!display_win32->hwnd)
|
||||
{
|
||||
UnregisterClass (MAKEINTRESOURCE (klass), this_module ());
|
||||
UnregisterClass (MAKEINTRESOURCE (klass), _gdk_app_hmodule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +139,7 @@ static GSourceFuncs event_funcs = {
|
||||
|
||||
static GdkSurface *mouse_window = NULL;
|
||||
static GdkSurface *mouse_window_ignored_leave = NULL;
|
||||
static int current_x, current_y;
|
||||
static int current_root_x, current_root_y;
|
||||
|
||||
static UINT got_gdk_events_message;
|
||||
@@ -412,7 +413,8 @@ set_up_low_level_keyboard_hook (void)
|
||||
|
||||
hook_handle = SetWindowsHookEx (WH_KEYBOARD_LL,
|
||||
(HOOKPROC) low_level_keyboard_proc,
|
||||
this_module (), 0);
|
||||
_gdk_dll_hinstance,
|
||||
0);
|
||||
|
||||
if (hook_handle != NULL)
|
||||
keyboard_hook = hook_handle;
|
||||
@@ -1521,15 +1523,14 @@ generate_button_event (GdkEventType type,
|
||||
GdkEvent *event;
|
||||
GdkDeviceManagerWin32 *device_manager;
|
||||
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
||||
double x, y;
|
||||
|
||||
if (_gdk_input_ignore_core > 0)
|
||||
return;
|
||||
|
||||
device_manager = GDK_DEVICE_MANAGER_WIN32 (_gdk_device_manager);
|
||||
|
||||
x = (double) GET_X_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
y = (double) GET_Y_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
current_x = (gint16) GET_X_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
current_y = (gint16) GET_Y_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
|
||||
_gdk_device_virtual_set_active (_gdk_device_manager->core_pointer,
|
||||
_gdk_device_manager->system_pointer);
|
||||
@@ -1541,10 +1542,10 @@ generate_button_event (GdkEventType type,
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
build_pointer_event_state (msg),
|
||||
button,
|
||||
x,
|
||||
y,
|
||||
current_x,
|
||||
current_y,
|
||||
NULL);
|
||||
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
}
|
||||
|
||||
@@ -2350,19 +2351,19 @@ gdk_event_translate (MSG *msg,
|
||||
* sends WM_MOUSEMOVE messages after a new window is shown under
|
||||
* the mouse, even if the mouse hasn't moved. This disturbs gtk.
|
||||
*/
|
||||
if (msg->pt.x == current_root_x &&
|
||||
msg->pt.y == current_root_y)
|
||||
if (msg->pt.x / impl->surface_scale == current_root_x &&
|
||||
msg->pt.y / impl->surface_scale == current_root_y)
|
||||
break;
|
||||
|
||||
current_root_x = msg->pt.x;
|
||||
current_root_y = msg->pt.y;
|
||||
current_root_x = msg->pt.x / impl->surface_scale;
|
||||
current_root_y = msg->pt.y / impl->surface_scale;
|
||||
|
||||
if (impl->drag_move_resize_context.op != GDK_WIN32_DRAGOP_NONE)
|
||||
gdk_win32_surface_do_move_resize_drag (window, msg->pt.x, msg->pt.y);
|
||||
gdk_win32_surface_do_move_resize_drag (window, current_root_x, current_root_y);
|
||||
else if (_gdk_input_ignore_core == 0)
|
||||
{
|
||||
double x = (double) GET_X_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
double y = (double) GET_Y_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
current_x = (gint16) GET_X_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
current_y = (gint16) GET_Y_LPARAM (msg->lParam) / impl->surface_scale;
|
||||
|
||||
_gdk_device_virtual_set_active (_gdk_device_manager->core_pointer,
|
||||
_gdk_device_manager->system_pointer);
|
||||
@@ -2372,8 +2373,8 @@ gdk_event_translate (MSG *msg,
|
||||
NULL,
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
build_pointer_event_state (msg),
|
||||
x,
|
||||
y,
|
||||
current_x,
|
||||
current_y,
|
||||
NULL);
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
@@ -2734,10 +2735,6 @@ gdk_event_translate (MSG *msg,
|
||||
if (GDK_IS_DRAG_SURFACE (window) ||
|
||||
_gdk_modal_blocked (window))
|
||||
{
|
||||
/* Focus the modal window */
|
||||
GdkSurface *modal_window = _gdk_modal_current ();
|
||||
if (modal_window != NULL)
|
||||
SetFocus (GDK_SURFACE_HWND (modal_window));
|
||||
*ret_valp = MA_NOACTIVATE;
|
||||
return_val = TRUE;
|
||||
}
|
||||
@@ -2748,10 +2745,6 @@ gdk_event_translate (MSG *msg,
|
||||
if (GDK_IS_DRAG_SURFACE (window) ||
|
||||
_gdk_modal_blocked (window))
|
||||
{
|
||||
/* Focus the modal window */
|
||||
GdkSurface *modal_window = _gdk_modal_current ();
|
||||
if (modal_window != NULL)
|
||||
SetFocus (GDK_SURFACE_HWND (modal_window));
|
||||
*ret_valp = PA_NOACTIVATE;
|
||||
return_val = TRUE;
|
||||
}
|
||||
|
||||
@@ -109,12 +109,12 @@ gdk_win32_gl_context_egl_end_frame (GdkDrawContext *draw_context,
|
||||
|
||||
static void
|
||||
gdk_win32_gl_context_egl_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *update_area)
|
||||
{
|
||||
gdk_win32_surface_handle_queued_move_resize (draw_context);
|
||||
|
||||
GDK_DRAW_CONTEXT_CLASS (gdk_win32_gl_context_egl_parent_class)->begin_frame (draw_context, depth, update_area);
|
||||
GDK_DRAW_CONTEXT_CLASS (gdk_win32_gl_context_egl_parent_class)->begin_frame (draw_context, prefers_high_depth, update_area);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -118,12 +118,12 @@ gdk_win32_gl_context_wgl_end_frame (GdkDrawContext *draw_context,
|
||||
|
||||
static void
|
||||
gdk_win32_gl_context_wgl_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *update_area)
|
||||
{
|
||||
gdk_win32_surface_handle_queued_move_resize (draw_context);
|
||||
|
||||
GDK_DRAW_CONTEXT_CLASS (gdk_win32_gl_context_wgl_parent_class)->begin_frame (draw_context, depth, update_area);
|
||||
GDK_DRAW_CONTEXT_CLASS (gdk_win32_gl_context_wgl_parent_class)->begin_frame (draw_context, prefers_high_depth, update_area);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -261,7 +261,7 @@ create_dummy_gl_window (void)
|
||||
|
||||
wclass.lpszClassName = "GdkGLDummyWindow";
|
||||
wclass.lpfnWndProc = DefWindowProc;
|
||||
wclass.hInstance = this_module ();
|
||||
wclass.hInstance = _gdk_app_hmodule;
|
||||
wclass.style = CS_OWNDC;
|
||||
|
||||
klass = RegisterClass (&wclass);
|
||||
@@ -270,10 +270,10 @@ create_dummy_gl_window (void)
|
||||
hwnd = CreateWindow (MAKEINTRESOURCE (klass),
|
||||
NULL, WS_POPUP,
|
||||
0, 0, 0, 0, NULL, NULL,
|
||||
this_module (), NULL);
|
||||
_gdk_app_hmodule, NULL);
|
||||
if (!hwnd)
|
||||
{
|
||||
UnregisterClass (MAKEINTRESOURCE (klass), this_module ());
|
||||
UnregisterClass (MAKEINTRESOURCE (klass), _gdk_app_hmodule);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
GdkDisplay *_gdk_display = NULL;
|
||||
GdkDeviceManagerWin32 *_gdk_device_manager = NULL;
|
||||
|
||||
HDC _gdk_display_hdc;
|
||||
HINSTANCE _gdk_dll_hinstance;
|
||||
HINSTANCE _gdk_app_hmodule;
|
||||
|
||||
int _gdk_input_ignore_core;
|
||||
|
||||
HKL _gdk_input_locale;
|
||||
|
||||
@@ -271,10 +271,9 @@ winpointer_make_event (GdkDeviceWinpointer *device,
|
||||
y /= impl->surface_scale;
|
||||
|
||||
state = 0;
|
||||
/* Note that info->dwKeyStates is not reliable, use GetKeyState() */
|
||||
if (GetKeyState (VK_CONTROL) < 0)
|
||||
if (info->dwKeyStates & POINTER_MOD_CTRL)
|
||||
state |= GDK_CONTROL_MASK;
|
||||
if (GetKeyState (VK_SHIFT) < 0)
|
||||
if (info->dwKeyStates & POINTER_MOD_SHIFT)
|
||||
state |= GDK_SHIFT_MASK;
|
||||
if (GetKeyState (VK_MENU) < 0)
|
||||
state |= GDK_ALT_MASK;
|
||||
@@ -1004,7 +1003,7 @@ winpointer_notif_window_create (void)
|
||||
wndclassex.cbSize = sizeof (wndclassex);
|
||||
wndclassex.lpszClassName = L"GdkWin32WinpointerNotificationsWindowClass";
|
||||
wndclassex.lpfnWndProc = winpointer_notifications_window_procedure;
|
||||
wndclassex.hInstance = this_module ();
|
||||
wndclassex.hInstance = _gdk_dll_hinstance;
|
||||
|
||||
if ((notifications_window_class = RegisterClassExW (&wndclassex)) == 0)
|
||||
{
|
||||
@@ -1019,7 +1018,7 @@ winpointer_notif_window_create (void)
|
||||
0, 0, 0, 0,
|
||||
HWND_MESSAGE,
|
||||
NULL,
|
||||
this_module (),
|
||||
_gdk_dll_hinstance,
|
||||
NULL)))
|
||||
{
|
||||
WIN32_API_FAILED ("CreateWindowExW");
|
||||
|
||||
@@ -576,6 +576,19 @@ gdk_mod_mask_to_mod_bits (GdkModifierType mod_mask)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* keypad decimal mark depends on active keyboard layout
|
||||
* return current decimal mark as unicode character
|
||||
*/
|
||||
guint32
|
||||
_gdk_win32_keymap_get_decimal_mark (GdkWin32Keymap *keymap)
|
||||
{
|
||||
guint32 c = MapVirtualKeyW (VK_DECIMAL, MAPVK_VK_TO_CHAR);
|
||||
if (!c)
|
||||
c = (guint32) '.';
|
||||
return c;
|
||||
}
|
||||
|
||||
static void
|
||||
update_keymap (GdkWin32Keymap *keymap)
|
||||
{
|
||||
|
||||
@@ -45,6 +45,9 @@
|
||||
#include <wintab.h>
|
||||
#include <imm.h>
|
||||
|
||||
/* for CFSTR_SHELLIDLIST */
|
||||
#include <shlobj.h>
|
||||
|
||||
static gboolean gdk_synchronize = FALSE;
|
||||
|
||||
/* Whether GDK initialized COM */
|
||||
@@ -63,6 +66,8 @@ _gdk_win32_surfaceing_init (void)
|
||||
if (gdk_synchronize)
|
||||
GdiSetBatchLimit (1);
|
||||
|
||||
_gdk_app_hmodule = GetModuleHandle (NULL);
|
||||
_gdk_display_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
|
||||
_gdk_input_locale = GetKeyboardLayout (0);
|
||||
_gdk_win32_keymap_set_active_layout (win32_keymap, _gdk_input_locale);
|
||||
|
||||
@@ -182,6 +187,135 @@ static_printf (const char *format,
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
|
||||
const int nentries)
|
||||
{
|
||||
char buf[20];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nentries; i++)
|
||||
g_print (" %3d %02x: %02x %02x %02x%s\n",
|
||||
i, i,
|
||||
pep[i].peRed, pep[i].peGreen, pep[i].peBlue,
|
||||
(pep[i].peFlags == 0 ? "" :
|
||||
(pep[i].peFlags == PC_EXPLICIT ? " PC_EXPLICIT" :
|
||||
(pep[i].peFlags == PC_NOCOLLAPSE ? " PC_NOCOLLAPSE" :
|
||||
(pep[i].peFlags == PC_RESERVED ? " PC_RESERVED" :
|
||||
(g_sprintf (buf, " %d", pep[i].peFlags), buf))))));
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_print_system_palette (void)
|
||||
{
|
||||
PALETTEENTRY *pe;
|
||||
int k;
|
||||
|
||||
k = GetSystemPaletteEntries (_gdk_display_hdc, 0, 0, NULL);
|
||||
pe = g_new (PALETTEENTRY, k);
|
||||
k = GetSystemPaletteEntries (_gdk_display_hdc, 0, k, pe);
|
||||
|
||||
if (!k)
|
||||
g_print ("GetSystemPaletteEntries failed: %s\n",
|
||||
g_win32_error_message (GetLastError ()));
|
||||
else
|
||||
{
|
||||
g_print ("System palette: %d entries\n", k);
|
||||
_gdk_win32_print_paletteentries (pe, k);
|
||||
}
|
||||
g_free (pe);
|
||||
}
|
||||
|
||||
static int
|
||||
palette_size (HPALETTE hpal)
|
||||
{
|
||||
WORD npal = 0;
|
||||
|
||||
if (!GetObject (hpal, sizeof (npal), &npal))
|
||||
WIN32_GDI_FAILED ("GetObject (HPALETTE)");
|
||||
|
||||
return npal;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_print_hpalette (HPALETTE hpal)
|
||||
{
|
||||
PALETTEENTRY *pe;
|
||||
int n, npal;
|
||||
|
||||
npal = palette_size (hpal);
|
||||
pe = g_new (PALETTEENTRY, npal);
|
||||
n = GetPaletteEntries (hpal, 0, npal, pe);
|
||||
|
||||
if (!n)
|
||||
g_print ("HPALETTE %p: GetPaletteEntries failed: %s\n",
|
||||
hpal, g_win32_error_message (GetLastError ()));
|
||||
else
|
||||
{
|
||||
g_print ("HPALETTE %p: %d (%d) entries\n", hpal, n, npal);
|
||||
_gdk_win32_print_paletteentries (pe, n);
|
||||
}
|
||||
g_free (pe);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_print_dc (HDC hdc)
|
||||
{
|
||||
HGDIOBJ obj;
|
||||
LOGBRUSH logbrush;
|
||||
EXTLOGPEN extlogpen;
|
||||
HRGN hrgn;
|
||||
RECT rect;
|
||||
int flag;
|
||||
|
||||
g_print ("%p:\n", hdc);
|
||||
obj = GetCurrentObject (hdc, OBJ_BRUSH);
|
||||
GetObject (obj, sizeof (LOGBRUSH), &logbrush);
|
||||
g_print ("brush: %s color=%06lx hatch=%p\n",
|
||||
_gdk_win32_lbstyle_to_string (logbrush.lbStyle),
|
||||
logbrush.lbColor, (gpointer) logbrush.lbHatch);
|
||||
obj = GetCurrentObject (hdc, OBJ_PEN);
|
||||
GetObject (obj, sizeof (EXTLOGPEN), &extlogpen);
|
||||
g_print ("pen: %s %s %s %s w=%d %s\n",
|
||||
_gdk_win32_pstype_to_string (extlogpen.elpPenStyle),
|
||||
_gdk_win32_psstyle_to_string (extlogpen.elpPenStyle),
|
||||
_gdk_win32_psendcap_to_string (extlogpen.elpPenStyle),
|
||||
_gdk_win32_psjoin_to_string (extlogpen.elpPenStyle),
|
||||
(int) extlogpen.elpWidth,
|
||||
_gdk_win32_lbstyle_to_string (extlogpen.elpBrushStyle));
|
||||
g_print ("rop2: %s textcolor=%06lx\n",
|
||||
_gdk_win32_rop2_to_string (GetROP2 (hdc)),
|
||||
GetTextColor (hdc));
|
||||
hrgn = CreateRectRgn (0, 0, 0, 0);
|
||||
if ((flag = GetClipRgn (hdc, hrgn)) == -1)
|
||||
WIN32_API_FAILED ("GetClipRgn");
|
||||
else if (flag == 0)
|
||||
g_print ("no clip region\n");
|
||||
else if (flag == 1)
|
||||
{
|
||||
GetRgnBox (hrgn, &rect);
|
||||
g_print ("clip region: %p bbox: %s\n",
|
||||
hrgn, _gdk_win32_rect_to_string (&rect));
|
||||
}
|
||||
DeleteObject (hrgn);
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol)
|
||||
{
|
||||
switch (protocol)
|
||||
{
|
||||
#define CASE(x) case GDK_DRAG_PROTO_##x: return #x
|
||||
CASE (NONE);
|
||||
CASE (WIN32_DROPFILES);
|
||||
CASE (OLE2);
|
||||
#undef CASE
|
||||
default: return static_printf ("illegal_%d", protocol);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_surface_state_to_string (GdkToplevelState state)
|
||||
{
|
||||
@@ -344,7 +478,7 @@ _gdk_win32_drag_action_to_string (GdkDragAction actions)
|
||||
return static_printf ("%s", buf);
|
||||
}
|
||||
|
||||
static char *
|
||||
char *
|
||||
_gdk_win32_rop2_to_string (int rop2)
|
||||
{
|
||||
switch (rop2)
|
||||
@@ -373,7 +507,7 @@ _gdk_win32_rop2_to_string (int rop2)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
char *
|
||||
_gdk_win32_lbstyle_to_string (UINT brush_style)
|
||||
{
|
||||
switch (brush_style)
|
||||
@@ -392,7 +526,7 @@ _gdk_win32_lbstyle_to_string (UINT brush_style)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
char *
|
||||
_gdk_win32_pstype_to_string (DWORD pen_style)
|
||||
{
|
||||
switch (pen_style & PS_TYPE_MASK)
|
||||
@@ -405,7 +539,7 @@ _gdk_win32_pstype_to_string (DWORD pen_style)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
char *
|
||||
_gdk_win32_psstyle_to_string (DWORD pen_style)
|
||||
{
|
||||
switch (pen_style & PS_STYLE_MASK)
|
||||
@@ -427,7 +561,7 @@ _gdk_win32_psstyle_to_string (DWORD pen_style)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
char *
|
||||
_gdk_win32_psendcap_to_string (DWORD pen_style)
|
||||
{
|
||||
switch (pen_style & PS_ENDCAP_MASK)
|
||||
@@ -443,7 +577,7 @@ _gdk_win32_psendcap_to_string (DWORD pen_style)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
char *
|
||||
_gdk_win32_psjoin_to_string (DWORD pen_style)
|
||||
{
|
||||
switch (pen_style & PS_JOIN_MASK)
|
||||
@@ -459,56 +593,6 @@ _gdk_win32_psjoin_to_string (DWORD pen_style)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_print_dc (HDC hdc)
|
||||
{
|
||||
HGDIOBJ obj;
|
||||
LOGBRUSH logbrush;
|
||||
EXTLOGPEN extlogpen;
|
||||
HRGN hrgn;
|
||||
RECT rect;
|
||||
int flag;
|
||||
|
||||
g_print ("%p:\n", hdc);
|
||||
|
||||
obj = GetCurrentObject (hdc, OBJ_BRUSH);
|
||||
GetObject (obj, sizeof (LOGBRUSH), &logbrush);
|
||||
|
||||
g_print ("brush: %s color=%06lx hatch=%p\n",
|
||||
_gdk_win32_lbstyle_to_string (logbrush.lbStyle),
|
||||
logbrush.lbColor, (gpointer) logbrush.lbHatch);
|
||||
|
||||
obj = GetCurrentObject (hdc, OBJ_PEN);
|
||||
GetObject (obj, sizeof (EXTLOGPEN), &extlogpen);
|
||||
|
||||
g_print ("pen: %s %s %s %s w=%d %s\n",
|
||||
_gdk_win32_pstype_to_string (extlogpen.elpPenStyle),
|
||||
_gdk_win32_psstyle_to_string (extlogpen.elpPenStyle),
|
||||
_gdk_win32_psendcap_to_string (extlogpen.elpPenStyle),
|
||||
_gdk_win32_psjoin_to_string (extlogpen.elpPenStyle),
|
||||
(int) extlogpen.elpWidth,
|
||||
_gdk_win32_lbstyle_to_string (extlogpen.elpBrushStyle));
|
||||
|
||||
g_print ("rop2: %s textcolor=%06lx\n",
|
||||
_gdk_win32_rop2_to_string (GetROP2 (hdc)),
|
||||
GetTextColor (hdc));
|
||||
|
||||
hrgn = CreateRectRgn (0, 0, 0, 0);
|
||||
|
||||
if ((flag = GetClipRgn (hdc, hrgn)) == -1)
|
||||
WIN32_API_FAILED ("GetClipRgn");
|
||||
else if (flag == 0)
|
||||
g_print ("no clip region\n");
|
||||
else if (flag == 1)
|
||||
{
|
||||
GetRgnBox (hrgn, &rect);
|
||||
g_print ("clip region: %p bbox: %s\n",
|
||||
hrgn, _gdk_win32_rect_to_string (&rect));
|
||||
}
|
||||
|
||||
DeleteObject (hrgn);
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_message_to_string (UINT msg)
|
||||
{
|
||||
@@ -809,6 +893,26 @@ _gdk_win32_cf_to_string (UINT format)
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_data_to_string (const guchar *data,
|
||||
int nbytes)
|
||||
{
|
||||
GString *s = g_string_new ("");
|
||||
int i;
|
||||
char *retval;
|
||||
|
||||
for (i = 0; i < nbytes; i++)
|
||||
if (data[i] >=' ' && data[i] <= '~')
|
||||
g_string_append_printf (s, "%c ", data[i]);
|
||||
else
|
||||
g_string_append_printf (s, "%02X ", data[i]);
|
||||
|
||||
retval = static_printf ("%s", s->str);
|
||||
g_string_free (s, TRUE);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_rect_to_string (const RECT *rect)
|
||||
{
|
||||
@@ -817,4 +921,34 @@ _gdk_win32_rect_to_string (const RECT *rect)
|
||||
rect->left, rect->top);
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_gdkrectangle_to_string (const GdkRectangle *rect)
|
||||
{
|
||||
return static_printf ("%dx%d@%+d%+d",
|
||||
rect->width, rect->height,
|
||||
rect->x, rect->y);
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_cairo_region_to_string (const cairo_region_t *rgn)
|
||||
{
|
||||
cairo_rectangle_int_t extents;
|
||||
cairo_region_get_extents (rgn, &extents);
|
||||
return static_printf ("%dx%d@%+d%+d",
|
||||
extents.width, extents.height,
|
||||
extents.x, extents.y);
|
||||
}
|
||||
|
||||
char *
|
||||
_gdk_win32_surface_description (GdkSurface *d)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SURFACE (d), NULL);
|
||||
|
||||
return static_printf ("%s:%p:%dx%d",
|
||||
G_OBJECT_TYPE_NAME (d),
|
||||
GDK_SURFACE_HWND (d),
|
||||
gdk_surface_get_width (GDK_SURFACE (d)),
|
||||
gdk_surface_get_height (GDK_SURFACE (d)));
|
||||
}
|
||||
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
|
||||
@@ -443,6 +443,9 @@ populate_monitor_devices_from_display_config (GPtrArray *monitors)
|
||||
char *path, *path_lower;
|
||||
DISPLAYCONFIG_RATIONAL *refresh;
|
||||
|
||||
if ((dispconf_paths[path_index].flags & DISPLAYCONFIG_PATH_ACTIVE) == 0)
|
||||
continue;
|
||||
|
||||
tdn.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME;
|
||||
tdn.header.size = sizeof (tdn);
|
||||
tdn.header.adapterId = dispconf_paths[path_index].targetInfo.adapterId;
|
||||
@@ -478,12 +481,6 @@ populate_monitor_devices_from_display_config (GPtrArray *monitors)
|
||||
if (w32mon == NULL)
|
||||
continue;
|
||||
|
||||
if ((dispconf_paths[path_index].flags & DISPLAYCONFIG_PATH_ACTIVE) == 0)
|
||||
{
|
||||
w32mon->remove = TRUE;
|
||||
continue;
|
||||
}
|
||||
|
||||
mon = GDK_MONITOR (w32mon);
|
||||
|
||||
if (!tdn.flags.friendlyNameForced)
|
||||
@@ -601,8 +598,6 @@ enum_monitor (HMONITOR hmonitor,
|
||||
|
||||
if (w32mon == NULL)
|
||||
continue;
|
||||
|
||||
w32mon->hmonitor = hmonitor;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -35,9 +35,6 @@ struct _GdkWin32Monitor
|
||||
/* Device instance path (used to match GdkWin32Monitor to monitor device) */
|
||||
char *instance_path;
|
||||
|
||||
/* MOnitor handle (used to fullscreen windows on monitors) */
|
||||
HMONITOR hmonitor;
|
||||
|
||||
/* TRUE if monitor is made up by us
|
||||
* (this happens when system has logical monitors, but no physical ones).
|
||||
*/
|
||||
|
||||
@@ -15,9 +15,14 @@
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#pragma once
|
||||
|
||||
#include <gdk/gdkcursorprivate.h>
|
||||
#include <gdk/gdkdebugprivate.h>
|
||||
@@ -27,6 +32,10 @@
|
||||
#include <gdk/win32/gdkwin32keys.h>
|
||||
#include <gdk/win32/gdkdevicemanager-win32.h>
|
||||
#include <gdk/win32/gdkclipdrop-win32.h>
|
||||
//#include <gdk/win32/gdkselection-win32.h>
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
/* Old debug macros */
|
||||
@@ -45,6 +54,62 @@
|
||||
|
||||
#endif
|
||||
|
||||
/* Make up for some minor w32api or MSVC6 header lossage */
|
||||
|
||||
#ifndef PS_JOIN_MASK
|
||||
#define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
|
||||
#endif
|
||||
|
||||
#ifndef FS_VIETNAMESE
|
||||
#define FS_VIETNAMESE 0x100
|
||||
#endif
|
||||
|
||||
#ifndef WM_GETOBJECT
|
||||
#define WM_GETOBJECT 0x3D
|
||||
#endif
|
||||
#ifndef WM_NCXBUTTONDOWN
|
||||
#define WM_NCXBUTTONDOWN 0xAB
|
||||
#endif
|
||||
#ifndef WM_NCXBUTTONUP
|
||||
#define WM_NCXBUTTONUP 0xAC
|
||||
#endif
|
||||
#ifndef WM_NCXBUTTONDBLCLK
|
||||
#define WM_NCXBUTTONDBLCLK 0xAD
|
||||
#endif
|
||||
#ifndef WM_CHANGEUISTATE
|
||||
#define WM_CHANGEUISTATE 0x127
|
||||
#endif
|
||||
#ifndef WM_UPDATEUISTATE
|
||||
#define WM_UPDATEUISTATE 0x128
|
||||
#endif
|
||||
#ifndef WM_QUERYUISTATE
|
||||
#define WM_QUERYUISTATE 0x129
|
||||
#endif
|
||||
#ifndef WM_XBUTTONDOWN
|
||||
#define WM_XBUTTONDOWN 0x20B
|
||||
#endif
|
||||
#ifndef WM_XBUTTONUP
|
||||
#define WM_XBUTTONUP 0x20C
|
||||
#endif
|
||||
#ifndef WM_XBUTTONDBLCLK
|
||||
#define WM_XBUTTONDBLCLK 0x20D
|
||||
#endif
|
||||
#ifndef WM_NCMOUSEHOVER
|
||||
#define WM_NCMOUSEHOVER 0x2A0
|
||||
#endif
|
||||
#ifndef WM_NCMOUSELEAVE
|
||||
#define WM_NCMOUSELEAVE 0x2A2
|
||||
#endif
|
||||
#ifndef WM_APPCOMMAND
|
||||
#define WM_APPCOMMAND 0x319
|
||||
#endif
|
||||
#ifndef WM_MOUSEHWHEEL
|
||||
#define WM_MOUSEHWHEEL 0x20E
|
||||
#endif
|
||||
#ifndef WM_DPICHANGED
|
||||
#define WM_DPICHANGED 0x02E0
|
||||
#endif
|
||||
|
||||
/* According to
|
||||
* http://blog.airesoft.co.uk/2009/11/wm_messages/
|
||||
* this is the actual internal name MS uses for this undocumented message.
|
||||
@@ -57,6 +122,11 @@
|
||||
#define WM_SYSMENU 0x313
|
||||
#endif
|
||||
|
||||
#ifndef CF_DIBV5
|
||||
#define CF_DIBV5 17
|
||||
#endif
|
||||
|
||||
|
||||
/* Define some combinations of GdkDebugFlags */
|
||||
#define GDK_DEBUG_EVENTS_OR_INPUT (GDK_DEBUG_EVENTS|GDK_DEBUG_INPUT)
|
||||
#define GDK_DEBUG_MISC_OR_EVENTS (GDK_DEBUG_MISC|GDK_DEBUG_EVENTS)
|
||||
@@ -70,6 +140,22 @@ GdkWin32Screen *GDK_SURFACE_SCREEN(GObject *win);
|
||||
*/
|
||||
#define SWP_NOZORDER_SPECIFIED HWND_TOP
|
||||
|
||||
typedef struct _GdkWin32SingleFont GdkWin32SingleFont;
|
||||
|
||||
struct _GdkWin32SingleFont
|
||||
{
|
||||
HFONT hfont;
|
||||
UINT charset;
|
||||
UINT codepage;
|
||||
FONTSIGNATURE fs;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
GDK_WIN32_PE_STATIC,
|
||||
GDK_WIN32_PE_AVAILABLE,
|
||||
GDK_WIN32_PE_INUSE
|
||||
} GdkWin32PalEntryState;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_DRAG_PROTO_NONE = 0,
|
||||
@@ -77,23 +163,51 @@ typedef enum
|
||||
GDK_DRAG_PROTO_OLE2,
|
||||
} GdkDragProtocol;
|
||||
|
||||
GType _gdk_gc_win32_get_type (void);
|
||||
|
||||
gulong _gdk_win32_get_next_tick (gulong suggested_tick);
|
||||
|
||||
BOOL _gdk_win32_get_cursor_pos (LPPOINT lpPoint);
|
||||
|
||||
void _gdk_surface_init_position (GdkSurface *window);
|
||||
void _gdk_surface_move_resize_child (GdkSurface *window,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
gboolean _gdk_win32_surface_enable_transparency (GdkSurface *window);
|
||||
|
||||
|
||||
/* GdkSurfaceImpl methods */
|
||||
void _gdk_win32_surface_scroll (GdkSurface *window,
|
||||
int dx,
|
||||
int dy);
|
||||
void _gdk_win32_surface_move_region (GdkSurface *window,
|
||||
const cairo_region_t *region,
|
||||
int dx,
|
||||
int dy);
|
||||
|
||||
|
||||
void _gdk_win32_selection_init (void);
|
||||
void _gdk_win32_dnd_exit (void);
|
||||
|
||||
void gdk_win32_handle_table_insert (HANDLE *handle,
|
||||
gpointer data);
|
||||
void gdk_win32_handle_table_remove (HANDLE handle);
|
||||
|
||||
HRGN _gdk_win32_cairo_region_to_hrgn (const cairo_region_t *region,
|
||||
int x_origin,
|
||||
int y_origin);
|
||||
|
||||
cairo_region_t *_gdk_win32_hrgn_to_region (HRGN hrgn,
|
||||
guint scale);
|
||||
|
||||
void _gdk_win32_adjust_client_rect (GdkSurface *window,
|
||||
RECT *RECT);
|
||||
|
||||
void _gdk_selection_property_delete (GdkSurface *);
|
||||
|
||||
void _gdk_push_modal_window (GdkSurface *window);
|
||||
void _gdk_remove_modal_window (GdkSurface *window);
|
||||
GdkSurface *_gdk_modal_current (void);
|
||||
@@ -103,22 +217,41 @@ gboolean gdk_win32_ensure_com (void);
|
||||
gboolean gdk_win32_ensure_ole (void);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
void _gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
|
||||
const int nentries);
|
||||
void _gdk_win32_print_system_palette (void);
|
||||
void _gdk_win32_print_hpalette (HPALETTE hpal);
|
||||
void _gdk_win32_print_dc (HDC hdc);
|
||||
|
||||
char *_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol);
|
||||
char *_gdk_win32_surface_state_to_string (GdkToplevelState state);
|
||||
char *_gdk_win32_surface_style_to_string (LONG style);
|
||||
char *_gdk_win32_surface_exstyle_to_string (LONG style);
|
||||
char *_gdk_win32_surface_pos_bits_to_string (UINT flags);
|
||||
char *_gdk_win32_drag_action_to_string (GdkDragAction actions);
|
||||
char *_gdk_win32_surface_description (GdkSurface *d);
|
||||
|
||||
char *_gdk_win32_rop2_to_string (int rop2);
|
||||
char *_gdk_win32_lbstyle_to_string (UINT brush_style);
|
||||
char *_gdk_win32_pstype_to_string (DWORD pen_style);
|
||||
char *_gdk_win32_psstyle_to_string (DWORD pen_style);
|
||||
char *_gdk_win32_psendcap_to_string (DWORD pen_style);
|
||||
char *_gdk_win32_psjoin_to_string (DWORD pen_style);
|
||||
char *_gdk_win32_message_to_string (UINT msg);
|
||||
char *_gdk_win32_key_to_string (LONG lParam);
|
||||
char *_gdk_win32_cf_to_string (UINT format);
|
||||
char *_gdk_win32_data_to_string (const guchar*data,
|
||||
int nbytes);
|
||||
char *_gdk_win32_rect_to_string (const RECT *rect);
|
||||
|
||||
char *_gdk_win32_gdkrectangle_to_string (const GdkRectangle *rect);
|
||||
char *_gdk_win32_cairo_region_to_string (const cairo_region_t *box);
|
||||
|
||||
void _gdk_win32_print_event (GdkEvent *event);
|
||||
|
||||
#endif
|
||||
|
||||
char *_gdk_win32_last_error_string (void);
|
||||
void _gdk_win32_api_failed (const char *where,
|
||||
const char *api);
|
||||
void _gdk_other_api_failed (const char *where,
|
||||
@@ -151,6 +284,10 @@ extern GdkDisplay *_gdk_display;
|
||||
|
||||
extern GdkDeviceManagerWin32 *_gdk_device_manager;
|
||||
|
||||
extern HDC _gdk_display_hdc;
|
||||
extern HINSTANCE _gdk_dll_hinstance;
|
||||
extern HINSTANCE _gdk_app_hmodule;
|
||||
|
||||
extern int _gdk_input_ignore_core;
|
||||
|
||||
/* These are thread specific, but GDK/win32 works OK only when invoked
|
||||
@@ -167,6 +304,8 @@ extern GdkWin32Clipdrop *_win32_clipdrop;
|
||||
/* Used to identify the main thread */
|
||||
extern GThread *_win32_main_thread;
|
||||
|
||||
void _gdk_win32_dnd_do_dragdrop (void);
|
||||
|
||||
typedef enum {
|
||||
GDK_WIN32_MODAL_OP_NONE = 0x0,
|
||||
GDK_WIN32_MODAL_OP_SIZE = 0x1 << 0,
|
||||
@@ -185,9 +324,16 @@ extern HWND _modal_move_resize_window;
|
||||
void _gdk_win32_begin_modal_call (GdkWin32ModalOpKind kind);
|
||||
void _gdk_win32_end_modal_call (GdkWin32ModalOpKind kind);
|
||||
|
||||
/* Convert a pixbuf to an HICON (or HCURSOR). Supports alpha under
|
||||
* Windows XP, thresholds alpha otherwise.
|
||||
*/
|
||||
HICON _gdk_win32_texture_to_hicon (GdkTexture *texture);
|
||||
|
||||
void _gdk_win32_display_init_cursors (GdkWin32Display *display);
|
||||
void _gdk_win32_display_finalize_cursors (GdkWin32Display *display);
|
||||
void _gdk_win32_display_update_cursors (GdkWin32Display *display);
|
||||
GdkCursor *_gdk_win32_display_get_cursor_for_name (GdkDisplay *display, const char * cursor_name);
|
||||
GdkCursor *gdk_win32_display_cursor_from_hcursor (GdkDisplay *display, HCURSOR hcursor);
|
||||
|
||||
typedef struct _Win32CursorTheme Win32CursorTheme;
|
||||
|
||||
@@ -221,6 +367,9 @@ Win32Cursor * win32_cursor_theme_get_cursor (Win32CursorTheme *theme,
|
||||
void win32_cursor_theme_destroy (Win32CursorTheme *theme);
|
||||
Win32CursorTheme *_gdk_win32_display_get_cursor_theme (GdkWin32Display *win32_display);
|
||||
|
||||
/* GdkDisplay member functions */
|
||||
GList *_gdk_win32_display_list_devices (GdkDisplay *dpy);
|
||||
|
||||
gboolean _gdk_win32_display_has_pending (GdkDisplay *display);
|
||||
void _gdk_win32_display_queue_events (GdkDisplay *display);
|
||||
|
||||
@@ -246,11 +395,16 @@ GdkDrag *_gdk_win32_surface_drag_begin (GdkSurface *window,
|
||||
/* Stray GdkWin32Screen members */
|
||||
gboolean _gdk_win32_get_setting (const char *name, GValue *value);
|
||||
void _gdk_win32_screen_on_displaychange_event (GdkWin32Screen *screen);
|
||||
GdkSurface *gdk_win32_screen_get_root_window (GdkWin32Screen *screen);
|
||||
GdkSurface *gdk_win32_display_get_root_window (GdkDisplay *display);
|
||||
|
||||
/* Distributed display manager implementation */
|
||||
GdkDisplay *_gdk_win32_display_open (const char *display_name);
|
||||
void _gdk_win32_append_event (GdkEvent *event);
|
||||
|
||||
|
||||
guint32 _gdk_win32_keymap_get_decimal_mark (GdkWin32Keymap *keymap);
|
||||
|
||||
void _gdk_win32_surface_handle_aerosnap (GdkSurface *window,
|
||||
GdkWin32AeroSnapCombo combo);
|
||||
|
||||
@@ -295,15 +449,8 @@ gboolean _gdk_win32_check_processor (GdkWin32ProcessorCheckType check_type);
|
||||
GdkPixbuf *gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
|
||||
double *x_hot,
|
||||
double *y_hot);
|
||||
HICON gdk_win32_pixbuf_to_hicon_libgtk_only (GdkPixbuf *pixbuf);
|
||||
void gdk_win32_set_modal_dialog_libgtk_only (HWND window);
|
||||
|
||||
gpointer gdk_win32_handle_table_lookup_ (HWND handle);
|
||||
|
||||
extern IMAGE_DOS_HEADER __ImageBase;
|
||||
|
||||
static inline HMODULE
|
||||
this_module (void)
|
||||
{
|
||||
return (HMODULE) &__ImageBase;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,15 +113,7 @@ _gdk_win32_get_setting (const char *name,
|
||||
}
|
||||
else if (strcmp ("gtk-font-name", name) == 0)
|
||||
{
|
||||
char *font_name = NULL;
|
||||
HDC hdc = NULL;
|
||||
|
||||
if ((hdc = GetDC (HWND_DESKTOP)) != NULL)
|
||||
{
|
||||
font_name = _get_system_font_name (hdc);
|
||||
ReleaseDC (HWND_DESKTOP, hdc);
|
||||
hdc = NULL;
|
||||
}
|
||||
char *font_name = _get_system_font_name (_gdk_display_hdc);
|
||||
|
||||
if (font_name)
|
||||
{
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
#include "gdkdisplay-win32.h"
|
||||
#include "gdkdevice-win32.h"
|
||||
#include "gdkcairocontext-win32.h"
|
||||
#include "gdkmonitor-win32.h"
|
||||
|
||||
#include <cairo-win32.h>
|
||||
#include <dwmapi.h>
|
||||
@@ -339,7 +338,7 @@ RegisterGdkClass (GType wtype)
|
||||
wcl.lpfnWndProc = _gdk_win32_surface_procedure;
|
||||
wcl.cbClsExtra = 0;
|
||||
wcl.cbWndExtra = 0;
|
||||
wcl.hInstance = this_module ();
|
||||
wcl.hInstance = _gdk_dll_hinstance;
|
||||
wcl.hIcon = 0;
|
||||
wcl.hIconSm = 0;
|
||||
|
||||
@@ -356,7 +355,7 @@ RegisterGdkClass (GType wtype)
|
||||
if (0 == hAppIcon && 0 == hAppIconSm)
|
||||
{
|
||||
// fallback : load icon from GTK DLL
|
||||
if (0 != GetModuleFileName (this_module (), sLoc, MAX_PATH))
|
||||
if (0 != GetModuleFileName (_gdk_dll_hinstance, sLoc, MAX_PATH))
|
||||
{
|
||||
ExtractIconEx (sLoc, 0, &hAppIcon, &hAppIconSm, 1);
|
||||
}
|
||||
@@ -493,7 +492,7 @@ gdk_win32_surface_constructed (GObject *object)
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
owner,
|
||||
NULL,
|
||||
this_module (),
|
||||
_gdk_dll_hinstance,
|
||||
surface);
|
||||
if (impl->handle == NULL)
|
||||
{
|
||||
@@ -626,8 +625,7 @@ get_outer_rect (GdkSurface *window,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_win32_surface_fullscreen (GdkSurface *window,
|
||||
GdkMonitor *monitor);
|
||||
gdk_win32_surface_fullscreen (GdkSurface *window);
|
||||
|
||||
static void
|
||||
show_window_internal (GdkSurface *window,
|
||||
@@ -725,7 +723,11 @@ show_window_internal (GdkSurface *window,
|
||||
|
||||
if (center)
|
||||
{
|
||||
GetWindowRect (GDK_SURFACE_HWND (window), &window_rect);
|
||||
window_rect.left = 0;
|
||||
window_rect.top = 0;
|
||||
window_rect.right = window->width * surface->surface_scale;
|
||||
window_rect.bottom = window->height * surface->surface_scale;
|
||||
_gdk_win32_adjust_client_rect (window, &window_rect);
|
||||
|
||||
x = center_on_rect.left + ((center_on_rect.right - center_on_rect.left) - (window_rect.right - window_rect.left)) / 2;
|
||||
y = center_on_rect.top + ((center_on_rect.bottom - center_on_rect.top) - (window_rect.bottom - window_rect.top)) / 2;
|
||||
@@ -787,7 +789,11 @@ show_window_internal (GdkSurface *window,
|
||||
}
|
||||
|
||||
|
||||
if (window->state & GDK_TOPLEVEL_STATE_MAXIMIZED)
|
||||
if (window->state & GDK_TOPLEVEL_STATE_FULLSCREEN)
|
||||
{
|
||||
gdk_win32_surface_fullscreen (window);
|
||||
}
|
||||
else if (window->state & GDK_TOPLEVEL_STATE_MAXIMIZED)
|
||||
{
|
||||
GtkShowWindow (window, SW_MAXIMIZE);
|
||||
}
|
||||
@@ -2400,7 +2406,7 @@ RegisterGdkDumbClass ()
|
||||
wcl.lpfnWndProc = DefWindowProcW;
|
||||
wcl.cbClsExtra = 0;
|
||||
wcl.cbWndExtra = 0;
|
||||
wcl.hInstance = this_module ();
|
||||
wcl.hInstance = _gdk_dll_hinstance;
|
||||
wcl.hIcon = 0;
|
||||
wcl.hIconSm = 0;
|
||||
wcl.lpszMenuName = NULL;
|
||||
@@ -2441,7 +2447,7 @@ ensure_snap_indicator_exists (GdkW32DragMoveResizeContext *context)
|
||||
0, 0,
|
||||
NULL,
|
||||
NULL,
|
||||
this_module (),
|
||||
_gdk_dll_hinstance,
|
||||
NULL);
|
||||
|
||||
context->shape_indicator = handle;
|
||||
@@ -3535,8 +3541,6 @@ setup_drag_move_resize_context (GdkSurface *surface,
|
||||
context->button = button;
|
||||
context->start_root_x = root_x;
|
||||
context->start_root_y = root_y;
|
||||
context->current_root_x = root_x;
|
||||
context->current_root_y = root_y;
|
||||
context->timestamp = timestamp;
|
||||
context->start_rect = rect;
|
||||
|
||||
@@ -3652,16 +3656,6 @@ gdk_win32_surface_do_move_resize_drag (GdkSurface *window,
|
||||
if (!_gdk_win32_get_window_rect (window, &rect))
|
||||
return;
|
||||
|
||||
x /= impl->surface_scale;
|
||||
y /= impl->surface_scale;
|
||||
|
||||
if (context->current_root_x == x &&
|
||||
context->current_root_y == y)
|
||||
return;
|
||||
|
||||
context->current_root_x = x;
|
||||
context->current_root_y = y;
|
||||
|
||||
new_rect = context->start_rect;
|
||||
diffx = (x - context->start_root_x) * impl->surface_scale;
|
||||
diffy = (y - context->start_root_y) * impl->surface_scale;
|
||||
@@ -4014,12 +4008,11 @@ gdk_win32_surface_unmaximize (GdkSurface *surface)
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_win32_surface_fullscreen (GdkSurface *window,
|
||||
GdkMonitor *monitor)
|
||||
gdk_win32_surface_fullscreen (GdkSurface *window)
|
||||
{
|
||||
int x, y, width, height;
|
||||
FullscreenInfo *fi;
|
||||
HMONITOR hmonitor = NULL;
|
||||
HMONITOR monitor;
|
||||
MONITORINFO mi;
|
||||
|
||||
g_return_if_fail (GDK_IS_SURFACE (window));
|
||||
@@ -4032,14 +4025,9 @@ gdk_win32_surface_fullscreen (GdkSurface *window,
|
||||
{
|
||||
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
|
||||
|
||||
if (monitor && GDK_IS_WIN32_MONITOR (monitor))
|
||||
hmonitor = GDK_WIN32_MONITOR (monitor)->hmonitor;
|
||||
|
||||
if (!hmonitor)
|
||||
hmonitor = MonitorFromWindow (GDK_SURFACE_HWND (window), MONITOR_DEFAULTTONEAREST);
|
||||
|
||||
monitor = MonitorFromWindow (GDK_SURFACE_HWND (window), MONITOR_DEFAULTTONEAREST);
|
||||
mi.cbSize = sizeof (mi);
|
||||
if (hmonitor && GetMonitorInfo (hmonitor, &mi))
|
||||
if (monitor && GetMonitorInfo (monitor, &mi))
|
||||
{
|
||||
x = mi.rcMonitor.left;
|
||||
y = mi.rcMonitor.top;
|
||||
@@ -4881,16 +4869,9 @@ gdk_win32_toplevel_present (GdkToplevel *toplevel,
|
||||
if (gdk_toplevel_layout_get_fullscreen (layout, &fullscreen))
|
||||
{
|
||||
if (fullscreen)
|
||||
{
|
||||
GdkMonitor *monitor;
|
||||
|
||||
monitor = gdk_toplevel_layout_get_fullscreen_monitor (layout);
|
||||
gdk_win32_surface_fullscreen (surface, monitor);
|
||||
}
|
||||
gdk_win32_surface_fullscreen (surface);
|
||||
else
|
||||
{
|
||||
gdk_win32_surface_unfullscreen (surface);
|
||||
}
|
||||
gdk_win32_surface_unfullscreen (surface);
|
||||
}
|
||||
|
||||
gdk_win32_surface_show (surface, FALSE);
|
||||
|
||||
@@ -137,12 +137,6 @@ struct _GdkW32DragMoveResizeContext
|
||||
int start_root_x;
|
||||
int start_root_y;
|
||||
|
||||
/* Last processed cursor position. Values are divided by the window
|
||||
* scale.
|
||||
*/
|
||||
int current_root_x;
|
||||
int current_root_y;
|
||||
|
||||
/* Initial window rectangle (position and size).
|
||||
* The window is resized/moved relative to this (see start_root_*).
|
||||
*/
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include "gdkprivate-win32.h"
|
||||
#include "gdkwin32misc.h"
|
||||
|
||||
extern HINSTANCE _gdk_dll_hinstance;
|
||||
|
||||
G_DEFINE_TYPE (GdkWin32VulkanContext, gdk_win32_vulkan_context, GDK_TYPE_VULKAN_CONTEXT)
|
||||
|
||||
static VkResult
|
||||
@@ -45,7 +47,7 @@ gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context,
|
||||
info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
|
||||
info.pNext = NULL;
|
||||
info.flags = 0;
|
||||
info.hinstance = this_module ();
|
||||
info.hinstance = _gdk_dll_hinstance;
|
||||
info.hwnd = GDK_SURFACE_HWND (window);
|
||||
|
||||
/* This is necessary so that Vulkan sees the Window.
|
||||
@@ -66,12 +68,12 @@ gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context,
|
||||
|
||||
static void
|
||||
gdk_win32_vulkan_context_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *update_area)
|
||||
{
|
||||
gdk_win32_surface_handle_queued_move_resize (draw_context);
|
||||
|
||||
GDK_DRAW_CONTEXT_CLASS (gdk_win32_vulkan_context_parent_class)->begin_frame (draw_context, depth, update_area);
|
||||
GDK_DRAW_CONTEXT_CLASS (gdk_win32_vulkan_context_parent_class)->begin_frame (draw_context, prefers_high_depth, update_area);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -55,7 +55,7 @@ create_cairo_surface_for_surface (GdkSurface *surface)
|
||||
|
||||
static void
|
||||
gdk_x11_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
||||
GdkMemoryDepth depth,
|
||||
gboolean prefers_high_depth,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkX11CairoContext *self = GDK_X11_CAIRO_CONTEXT (draw_context);
|
||||
|
||||
@@ -134,6 +134,35 @@ struct _GdkX11DragClass
|
||||
GdkDragClass parent_class;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int keysym;
|
||||
int modifiers;
|
||||
} GrabKey;
|
||||
|
||||
static GrabKey grab_keys[] = {
|
||||
{ XK_Escape, 0 },
|
||||
{ XK_space, 0 },
|
||||
{ XK_KP_Space, 0 },
|
||||
{ XK_Return, 0 },
|
||||
{ XK_KP_Enter, 0 },
|
||||
{ XK_Up, 0 },
|
||||
{ XK_Up, Mod1Mask },
|
||||
{ XK_Down, 0 },
|
||||
{ XK_Down, Mod1Mask },
|
||||
{ XK_Left, 0 },
|
||||
{ XK_Left, Mod1Mask },
|
||||
{ XK_Right, 0 },
|
||||
{ XK_Right, Mod1Mask },
|
||||
{ XK_KP_Up, 0 },
|
||||
{ XK_KP_Up, Mod1Mask },
|
||||
{ XK_KP_Down, 0 },
|
||||
{ XK_KP_Down, Mod1Mask },
|
||||
{ XK_KP_Left, 0 },
|
||||
{ XK_KP_Left, Mod1Mask },
|
||||
{ XK_KP_Right, 0 },
|
||||
{ XK_KP_Right, Mod1Mask }
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
|
||||
static GdkSurfaceCache *gdk_surface_cache_ref (GdkSurfaceCache *cache);
|
||||
@@ -1832,15 +1861,20 @@ drag_grab (GdkDrag *drag)
|
||||
{
|
||||
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
|
||||
GdkSeatCapabilities capabilities;
|
||||
GdkDisplay *display;
|
||||
Window root;
|
||||
GdkSeat *seat;
|
||||
int keycode, i;
|
||||
GdkCursor *cursor;
|
||||
|
||||
if (!x11_drag->ipc_surface)
|
||||
return FALSE;
|
||||
|
||||
display = gdk_drag_get_display (drag);
|
||||
root = GDK_DISPLAY_XROOTWIN (display);
|
||||
seat = gdk_device_get_seat (gdk_drag_get_device (drag));
|
||||
|
||||
capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING;
|
||||
capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING | GDK_SEAT_CAPABILITY_KEYBOARD;
|
||||
|
||||
cursor = gdk_drag_get_cursor (drag, x11_drag->current_action);
|
||||
g_set_object (&x11_drag->cursor, cursor);
|
||||
@@ -1852,6 +1886,46 @@ drag_grab (GdkDrag *drag)
|
||||
|
||||
g_set_object (&x11_drag->grab_seat, seat);
|
||||
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i)
|
||||
{
|
||||
int deviceid = gdk_x11_device_get_id (gdk_seat_get_keyboard (seat));
|
||||
unsigned char mask[XIMaskLen(XI_LASTEVENT)];
|
||||
XIGrabModifiers mods;
|
||||
XIEventMask evmask;
|
||||
int num_mods;
|
||||
|
||||
keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display),
|
||||
grab_keys[i].keysym);
|
||||
if (keycode == NoSymbol)
|
||||
continue;
|
||||
|
||||
memset (mask, 0, sizeof (mask));
|
||||
XISetMask (mask, XI_KeyPress);
|
||||
XISetMask (mask, XI_KeyRelease);
|
||||
|
||||
evmask.deviceid = deviceid;
|
||||
evmask.mask_len = sizeof (mask);
|
||||
evmask.mask = mask;
|
||||
|
||||
num_mods = 1;
|
||||
mods.modifiers = grab_keys[i].modifiers;
|
||||
|
||||
XIGrabKeycode (GDK_DISPLAY_XDISPLAY (display),
|
||||
deviceid,
|
||||
keycode,
|
||||
root,
|
||||
GrabModeAsync,
|
||||
GrabModeAsync,
|
||||
False,
|
||||
&evmask,
|
||||
num_mods,
|
||||
&mods);
|
||||
}
|
||||
|
||||
gdk_x11_display_error_trap_pop_ignored (display);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1859,13 +1933,41 @@ static void
|
||||
drag_ungrab (GdkDrag *drag)
|
||||
{
|
||||
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
|
||||
GdkDisplay *display;
|
||||
GdkDevice *keyboard;
|
||||
Window root;
|
||||
int keycode, i;
|
||||
|
||||
if (!x11_drag->grab_seat)
|
||||
return;
|
||||
|
||||
gdk_seat_ungrab (x11_drag->grab_seat);
|
||||
|
||||
display = gdk_drag_get_display (drag);
|
||||
keyboard = gdk_seat_get_keyboard (x11_drag->grab_seat);
|
||||
root = GDK_DISPLAY_XROOTWIN (display);
|
||||
g_clear_object (&x11_drag->grab_seat);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i)
|
||||
{
|
||||
XIGrabModifiers mods;
|
||||
int num_mods;
|
||||
|
||||
keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display),
|
||||
grab_keys[i].keysym);
|
||||
if (keycode == NoSymbol)
|
||||
continue;
|
||||
|
||||
num_mods = 1;
|
||||
mods.modifiers = grab_keys[i].modifiers;
|
||||
|
||||
XIUngrabKeycode (GDK_DISPLAY_XDISPLAY (display),
|
||||
gdk_x11_device_get_id (keyboard),
|
||||
keycode,
|
||||
root,
|
||||
num_mods,
|
||||
&mods);
|
||||
}
|
||||
}
|
||||
|
||||
GdkDrag *
|
||||
@@ -2089,6 +2191,103 @@ gdk_dnd_handle_motion_event (GdkDrag *drag,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_key_event (GdkDrag *drag,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
|
||||
GdkModifierType state;
|
||||
GdkDevice *pointer;
|
||||
GdkSeat *seat;
|
||||
int dx, dy;
|
||||
|
||||
dx = dy = 0;
|
||||
state = gdk_event_get_modifier_state (event);
|
||||
seat = gdk_event_get_seat (event);
|
||||
pointer = gdk_seat_get_pointer (seat);
|
||||
|
||||
if (event->event_type == GDK_KEY_PRESS)
|
||||
{
|
||||
guint keyval = gdk_key_event_get_keyval (event);
|
||||
|
||||
switch (keyval)
|
||||
{
|
||||
case GDK_KEY_Escape:
|
||||
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_USER_CANCELLED);
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_space:
|
||||
case GDK_KEY_Return:
|
||||
case GDK_KEY_ISO_Enter:
|
||||
case GDK_KEY_KP_Enter:
|
||||
case GDK_KEY_KP_Space:
|
||||
if ((gdk_drag_get_selected_action (drag) != 0) &&
|
||||
(x11_drag->proxy_xid != None))
|
||||
{
|
||||
g_signal_emit_by_name (drag, "drop-performed");
|
||||
}
|
||||
else
|
||||
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET);
|
||||
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_Up:
|
||||
case GDK_KEY_KP_Up:
|
||||
dy = (state & GDK_ALT_MASK) ? -BIG_STEP : -SMALL_STEP;
|
||||
break;
|
||||
|
||||
case GDK_KEY_Down:
|
||||
case GDK_KEY_KP_Down:
|
||||
dy = (state & GDK_ALT_MASK) ? BIG_STEP : SMALL_STEP;
|
||||
break;
|
||||
|
||||
case GDK_KEY_Left:
|
||||
case GDK_KEY_KP_Left:
|
||||
dx = (state & GDK_ALT_MASK) ? -BIG_STEP : -SMALL_STEP;
|
||||
break;
|
||||
|
||||
case GDK_KEY_Right:
|
||||
case GDK_KEY_KP_Right:
|
||||
dx = (state & GDK_ALT_MASK) ? BIG_STEP : SMALL_STEP;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* The state is not yet updated in the event, so we need
|
||||
* to query it here. We could use XGetModifierMapping, but
|
||||
* that would be overkill.
|
||||
*/
|
||||
gdk_x11_device_xi2_query_state (pointer, NULL, NULL, NULL, &state);
|
||||
|
||||
if (dx != 0 || dy != 0)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
Display *xdisplay;
|
||||
GdkX11Screen *screen;
|
||||
Window dest;
|
||||
|
||||
x11_drag->last_x += dx;
|
||||
x11_drag->last_y += dy;
|
||||
|
||||
display = gdk_event_get_display ((GdkEvent *)event);
|
||||
xdisplay = GDK_DISPLAY_XDISPLAY (display);
|
||||
screen = GDK_X11_DISPLAY (display)->screen;
|
||||
dest = GDK_SCREEN_XROOTWIN (screen);
|
||||
|
||||
XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0,
|
||||
round (x11_drag->last_x * screen->surface_scale),
|
||||
round (x11_drag->last_y * screen->surface_scale));
|
||||
}
|
||||
|
||||
gdk_drag_update (drag, x11_drag->last_x, x11_drag->last_y, state,
|
||||
gdk_event_get_time (event));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_grab_broken_event (GdkDrag *drag,
|
||||
GdkEvent *event)
|
||||
@@ -2155,6 +2354,10 @@ gdk_x11_drag_handle_event (GdkDrag *drag,
|
||||
case GDK_BUTTON_RELEASE:
|
||||
return gdk_dnd_handle_button_event (drag, event);
|
||||
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
return gdk_dnd_handle_key_event (drag, event);
|
||||
|
||||
case GDK_GRAB_BROKEN:
|
||||
return gdk_dnd_handle_grab_broken_event (drag, event);
|
||||
|
||||
|
||||
@@ -543,6 +543,8 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
|
||||
if (share != NULL)
|
||||
share_glx = GDK_X11_GL_CONTEXT_GLX (share);
|
||||
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
|
||||
supported_versions = gdk_gl_versions_get_for_api (api);
|
||||
for (j = 0; gdk_gl_version_greater_equal (&supported_versions[j], &version); j++)
|
||||
{
|
||||
@@ -566,13 +568,19 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
|
||||
True,
|
||||
context_attribs);
|
||||
|
||||
if (ctx != NULL)
|
||||
if (ctx)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ctx == NULL)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (display, OPENGL, "Failed to create a GLX context");
|
||||
gdk_x11_display_error_trap_pop_ignored (display);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (gdk_x11_display_error_trap_pop (display))
|
||||
{
|
||||
glXDestroyContext (dpy, ctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -656,42 +664,25 @@ gdk_x11_gl_context_glx_realize (GdkGLContext *context,
|
||||
if (share != NULL && gdk_gl_context_is_legacy (share))
|
||||
legacy = TRUE;
|
||||
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
|
||||
/* Increase XNextRequest because GLX may fake errors with the last request
|
||||
* and we want the error trap to catch them */
|
||||
XChangeWindowAttributes (GDK_DISPLAY_XDISPLAY (display),
|
||||
GDK_X11_DISPLAY (display)->leader_window,
|
||||
0,
|
||||
(XSetWindowAttributes[1]) { 0, });
|
||||
|
||||
if (preferred_api == GDK_GL_API_GL)
|
||||
{
|
||||
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy);
|
||||
if (api == 0)
|
||||
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, legacy);
|
||||
if (api == 0)
|
||||
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE);
|
||||
if ((api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy)) ||
|
||||
(api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, legacy)) ||
|
||||
(api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE)))
|
||||
return api;
|
||||
}
|
||||
else
|
||||
{
|
||||
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, FALSE);
|
||||
if (api == 0)
|
||||
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy);
|
||||
if (api == 0)
|
||||
api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE);
|
||||
if ((api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, FALSE)) ||
|
||||
(api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy)) ||
|
||||
(api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE)))
|
||||
return api;
|
||||
}
|
||||
|
||||
gdk_x11_display_error_trap_pop_ignored (display);
|
||||
|
||||
if (api == 0)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("Unable to create a GL context"));
|
||||
}
|
||||
|
||||
return api;
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("Unable to create a GL context"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#undef N_GLX_ATTRS
|
||||
|
||||
@@ -685,13 +685,8 @@ init_randr13 (GdkX11Screen *x11_screen)
|
||||
for (i = 0; i < resources->noutput; ++i)
|
||||
{
|
||||
RROutput output = resources->outputs[i];
|
||||
XRROutputInfo *output_info;
|
||||
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
output_info = XRRGetOutputInfo (x11_screen->xdisplay, resources, output);
|
||||
|
||||
if (gdk_x11_display_error_trap_pop (display))
|
||||
continue;
|
||||
XRROutputInfo *output_info =
|
||||
XRRGetOutputInfo (x11_screen->xdisplay, resources, output);
|
||||
|
||||
if (output_info->connection == RR_Disconnected)
|
||||
{
|
||||
@@ -702,22 +697,13 @@ init_randr13 (GdkX11Screen *x11_screen)
|
||||
if (output_info->crtc)
|
||||
{
|
||||
GdkX11Monitor *monitor;
|
||||
XRRCrtcInfo *crtc;
|
||||
XRRCrtcInfo *crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources, output_info->crtc);
|
||||
char *name;
|
||||
GdkRectangle geometry;
|
||||
GdkRectangle newgeo;
|
||||
int j;
|
||||
int refresh_rate = 0;
|
||||
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources, output_info->crtc);
|
||||
|
||||
if (gdk_x11_display_error_trap_pop (display))
|
||||
{
|
||||
XRRFreeOutputInfo (output_info);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < resources->nmode; j++)
|
||||
{
|
||||
XRRModeInfo *xmode = &resources->modes[j];
|
||||
@@ -789,10 +775,8 @@ init_randr13 (GdkX11Screen *x11_screen)
|
||||
}
|
||||
|
||||
x11_display->primary_monitor = 0;
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
primary_output = XRRGetOutputPrimary (x11_screen->xdisplay,
|
||||
x11_screen->xroot_window);
|
||||
gdk_x11_display_error_trap_pop_ignored (display);
|
||||
|
||||
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)); i++)
|
||||
{
|
||||
|
||||
@@ -89,7 +89,7 @@ gdk_x11_selection_input_stream_fill_buffer (GdkX11SelectionInputStream *stream,
|
||||
if (size == 0)
|
||||
{
|
||||
/* EOF marker, put it back */
|
||||
g_async_queue_push_front_unlocked (priv->chunks, g_steal_pointer (&bytes));
|
||||
g_async_queue_push_front_unlocked (priv->chunks, bytes);
|
||||
break;
|
||||
}
|
||||
else if (size > count)
|
||||
@@ -107,7 +107,7 @@ gdk_x11_selection_input_stream_fill_buffer (GdkX11SelectionInputStream *stream,
|
||||
memcpy (buffer, g_bytes_get_data (bytes, NULL), size);
|
||||
}
|
||||
|
||||
g_bytes_unref (g_steal_pointer (&bytes));
|
||||
g_bytes_unref (bytes);
|
||||
result += size;
|
||||
if (buffer)
|
||||
buffer += size;
|
||||
@@ -165,7 +165,9 @@ gdk_x11_selection_input_stream_complete (GdkX11SelectionInputStream *stream)
|
||||
GDK_X11_DISPLAY (priv->display)->streams = g_slist_remove (GDK_X11_DISPLAY (priv->display)->streams, stream);
|
||||
g_signal_handlers_disconnect_by_func (priv->display,
|
||||
gdk_x11_selection_input_stream_xevent,
|
||||
g_steal_pointer (&stream));
|
||||
stream);
|
||||
|
||||
g_object_unref (stream);
|
||||
}
|
||||
|
||||
static gssize
|
||||
@@ -414,7 +416,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
|
||||
"%s:%s: got PropertyNotify erroring out of INCR",
|
||||
priv->selection, priv->target);
|
||||
/* error, should we signal one? */
|
||||
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
|
||||
gdk_x11_selection_input_stream_complete (stream);
|
||||
}
|
||||
else if (g_bytes_get_size (bytes) == 0 || type == None)
|
||||
{
|
||||
@@ -422,7 +424,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
|
||||
"%s:%s: got PropertyNotify ending INCR",
|
||||
priv->selection, priv->target);
|
||||
g_bytes_unref (bytes);
|
||||
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
|
||||
gdk_x11_selection_input_stream_complete (stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -465,7 +467,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_NOT_FOUND,
|
||||
_("Format %s not supported"), priv->target);
|
||||
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
|
||||
gdk_x11_selection_input_stream_complete (stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -476,7 +478,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
|
||||
|
||||
if (bytes == NULL)
|
||||
{
|
||||
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
|
||||
gdk_x11_selection_input_stream_complete (stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -498,7 +500,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
|
||||
g_bytes_get_size (bytes));
|
||||
g_async_queue_push (priv->chunks, bytes);
|
||||
|
||||
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
|
||||
gdk_x11_selection_input_stream_complete (stream);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,10 +541,7 @@ gdk_x11_selection_input_stream_new_async (GdkDisplay *display,
|
||||
priv->property = g_strdup_printf ("GDK_SELECTION_%p", stream);
|
||||
priv->xproperty = gdk_x11_get_xatom_by_name_for_display (display, priv->property);
|
||||
|
||||
g_signal_connect_data (display, "xevent",
|
||||
G_CALLBACK (gdk_x11_selection_input_stream_xevent),
|
||||
g_steal_pointer (&stream),
|
||||
(GClosureNotify) g_object_unref, 0);
|
||||
g_signal_connect (display, "xevent", G_CALLBACK (gdk_x11_selection_input_stream_xevent), stream);
|
||||
|
||||
XConvertSelection (GDK_DISPLAY_XDISPLAY (display),
|
||||
priv->xselection,
|
||||
@@ -578,6 +577,7 @@ gdk_x11_selection_input_stream_new_finish (GAsyncResult *result,
|
||||
*type = priv->type;
|
||||
if (format)
|
||||
*format = priv->format;
|
||||
g_object_ref (stream);
|
||||
}
|
||||
|
||||
return G_INPUT_STREAM (stream);
|
||||
|
||||
@@ -165,7 +165,7 @@ void half_to_float4 (const guint16 h[4], float f[4]) __attribute__((ifunc ("reso
|
||||
void float_to_half (const float *f, guint16 *h, int n) __attribute__((ifunc ("resolve_float_to_half")));
|
||||
void half_to_float (const guint16 *h, float *f, int n) __attribute__((ifunc ("resolve_half_to_float")));
|
||||
|
||||
static void * __attribute__ ((no_sanitize_address))
|
||||
static void *
|
||||
resolve_float_to_half4 (void)
|
||||
{
|
||||
__builtin_cpu_init ();
|
||||
@@ -175,7 +175,7 @@ resolve_float_to_half4 (void)
|
||||
return float_to_half4_c;
|
||||
}
|
||||
|
||||
static void * __attribute__ ((no_sanitize_address))
|
||||
static void *
|
||||
resolve_half_to_float4 (void)
|
||||
{
|
||||
__builtin_cpu_init ();
|
||||
@@ -185,7 +185,7 @@ resolve_half_to_float4 (void)
|
||||
return half_to_float4_c;
|
||||
}
|
||||
|
||||
static void * __attribute__ ((no_sanitize_address))
|
||||
static void *
|
||||
resolve_float_to_half (void)
|
||||
{
|
||||
__builtin_cpu_init ();
|
||||
@@ -195,7 +195,7 @@ resolve_float_to_half (void)
|
||||
return float_to_half_c;
|
||||
}
|
||||
|
||||
static void * __attribute__ ((no_sanitize_address))
|
||||
static void *
|
||||
resolve_half_to_float (void)
|
||||
{
|
||||
__builtin_cpu_init ();
|
||||
|
||||
@@ -1447,7 +1447,6 @@ gsk_gl_command_queue_create_framebuffer (GskGLCommandQueue *self)
|
||||
return fbo_id;
|
||||
}
|
||||
|
||||
|
||||
static GdkMemoryFormat
|
||||
memory_format_gl_format (GdkMemoryFormat data_format,
|
||||
gboolean use_es,
|
||||
@@ -1455,65 +1454,18 @@ memory_format_gl_format (GdkMemoryFormat data_format,
|
||||
guint minor,
|
||||
guint *gl_internalformat,
|
||||
guint *gl_format,
|
||||
guint *gl_type,
|
||||
GLint (*gl_swizzle)[4])
|
||||
guint *gl_type)
|
||||
{
|
||||
GdkMemoryDepth depth;
|
||||
|
||||
/* First, try the format itself */
|
||||
if (gdk_memory_format_gl_format (data_format,
|
||||
use_es,
|
||||
major,
|
||||
minor,
|
||||
gl_internalformat,
|
||||
gl_format,
|
||||
gl_type,
|
||||
gl_swizzle) &&
|
||||
gdk_memory_format_alpha (data_format) != GDK_MEMORY_ALPHA_STRAIGHT)
|
||||
gl_type))
|
||||
return data_format;
|
||||
|
||||
depth = gdk_memory_format_get_depth (data_format);
|
||||
|
||||
/* Next, try the generic format for the given bit depth */
|
||||
switch (depth)
|
||||
{
|
||||
case GDK_MEMORY_FLOAT16:
|
||||
data_format = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED;
|
||||
if (gdk_memory_format_gl_format (data_format,
|
||||
use_es,
|
||||
major,
|
||||
minor,
|
||||
gl_internalformat,
|
||||
gl_format,
|
||||
gl_type,
|
||||
gl_swizzle))
|
||||
return data_format;
|
||||
break;
|
||||
|
||||
case GDK_MEMORY_U16:
|
||||
data_format = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED;
|
||||
if (gdk_memory_format_gl_format (data_format,
|
||||
use_es,
|
||||
major,
|
||||
minor,
|
||||
gl_internalformat,
|
||||
gl_format,
|
||||
gl_type,
|
||||
gl_swizzle))
|
||||
return data_format;
|
||||
break;
|
||||
|
||||
case GDK_MEMORY_FLOAT32:
|
||||
case GDK_MEMORY_U8:
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
/* If the format is high depth, also try float32 */
|
||||
if (depth != GDK_MEMORY_U8)
|
||||
if (gdk_memory_format_prefers_high_depth (data_format))
|
||||
{
|
||||
data_format = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED;
|
||||
if (gdk_memory_format_gl_format (data_format,
|
||||
@@ -1522,12 +1474,10 @@ memory_format_gl_format (GdkMemoryFormat data_format,
|
||||
minor,
|
||||
gl_internalformat,
|
||||
gl_format,
|
||||
gl_type,
|
||||
gl_swizzle))
|
||||
gl_type))
|
||||
return data_format;
|
||||
}
|
||||
|
||||
/* If all else fails, pick the one format that's always supported */
|
||||
data_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
||||
if (!gdk_memory_format_gl_format (data_format,
|
||||
use_es,
|
||||
@@ -1535,8 +1485,7 @@ memory_format_gl_format (GdkMemoryFormat data_format,
|
||||
minor,
|
||||
gl_internalformat,
|
||||
gl_format,
|
||||
gl_type,
|
||||
gl_swizzle))
|
||||
gl_type))
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
@@ -1559,7 +1508,6 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self,
|
||||
GLenum gl_internalformat;
|
||||
GLenum gl_format;
|
||||
GLenum gl_type;
|
||||
GLint gl_swizzle[4];
|
||||
gsize bpp;
|
||||
gboolean use_es;
|
||||
int major, minor;
|
||||
@@ -1576,8 +1524,7 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self,
|
||||
minor,
|
||||
&gl_internalformat,
|
||||
&gl_format,
|
||||
&gl_type,
|
||||
&gl_swizzle);
|
||||
&gl_type);
|
||||
|
||||
gdk_texture_downloader_init (&downloader, texture);
|
||||
gdk_texture_downloader_set_format (&downloader, data_format);
|
||||
@@ -1612,18 +1559,6 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self,
|
||||
|
||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||
|
||||
/* Only apply swizzle if really needed, might not even be
|
||||
* supported if default values are set
|
||||
*/
|
||||
if (gl_swizzle[0] != GL_RED || gl_swizzle[1] != GL_GREEN || gl_swizzle[2] != GL_BLUE)
|
||||
{
|
||||
/* Set each channel independently since GLES 3.0 doesn't support the iv method */
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, gl_swizzle[0]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, gl_swizzle[1]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, gl_swizzle[2]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, gl_swizzle[3]);
|
||||
}
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
@@ -1638,7 +1573,6 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
|
||||
GLenum gl_internalformat;
|
||||
GLenum gl_format;
|
||||
GLenum gl_type;
|
||||
GLint gl_swizzle[4];
|
||||
gboolean use_es;
|
||||
int texture_id;
|
||||
int major, minor;
|
||||
@@ -1677,14 +1611,13 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
|
||||
use_es = gdk_gl_context_get_use_es (self->context);
|
||||
gdk_gl_context_get_version (self->context, &major, &minor);
|
||||
data_format = gdk_texture_get_format (chunks[0].texture);
|
||||
data_format = memory_format_gl_format (data_format,
|
||||
use_es,
|
||||
major,
|
||||
minor,
|
||||
&gl_internalformat,
|
||||
&gl_format,
|
||||
&gl_type,
|
||||
&gl_swizzle);
|
||||
memory_format_gl_format (data_format,
|
||||
use_es,
|
||||
major,
|
||||
minor,
|
||||
&gl_internalformat,
|
||||
&gl_format,
|
||||
&gl_type);
|
||||
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, gl_internalformat, width, height, 0, gl_format, gl_type, NULL);
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "gskglcommandqueueprivate.h"
|
||||
#include "gskglcompilerprivate.h"
|
||||
#include "gskglglyphlibraryprivate.h"
|
||||
#include "gskglglyphylibraryprivate.h"
|
||||
#include "gskgliconlibraryprivate.h"
|
||||
#include "gskglprogramprivate.h"
|
||||
#include "gskglshadowlibraryprivate.h"
|
||||
@@ -274,7 +273,6 @@ gsk_gl_driver_dispose (GObject *object)
|
||||
}
|
||||
|
||||
g_clear_object (&self->glyphs_library);
|
||||
g_clear_object (&self->glyphy_library);
|
||||
g_clear_object (&self->icons_library);
|
||||
g_clear_object (&self->shadows_library);
|
||||
|
||||
@@ -465,7 +463,6 @@ gsk_gl_driver_new (GskGLCommandQueue *command_queue,
|
||||
}
|
||||
|
||||
self->glyphs_library = gsk_gl_glyph_library_new (self);
|
||||
self->glyphy_library = gsk_gl_glyphy_library_new (self);
|
||||
self->icons_library = gsk_gl_icon_library_new (self);
|
||||
self->shadows_library = gsk_gl_shadow_library_new (self);
|
||||
|
||||
@@ -576,8 +573,6 @@ gsk_gl_driver_begin_frame (GskGLDriver *self,
|
||||
self->current_frame_id);
|
||||
gsk_gl_texture_library_begin_frame (GSK_GL_TEXTURE_LIBRARY (self->glyphs_library),
|
||||
self->current_frame_id);
|
||||
gsk_gl_texture_library_begin_frame (GSK_GL_TEXTURE_LIBRARY (self->glyphy_library),
|
||||
self->current_frame_id);
|
||||
|
||||
/* Cleanup old shadows */
|
||||
gsk_gl_shadow_library_begin_frame (self->shadows_library);
|
||||
@@ -691,21 +686,17 @@ gsk_gl_driver_cache_texture (GskGLDriver *self,
|
||||
const GskTextureKey *key,
|
||||
guint texture_id)
|
||||
{
|
||||
GskTextureKey *k;
|
||||
|
||||
g_assert (GSK_IS_GL_DRIVER (self));
|
||||
g_assert (key != NULL);
|
||||
g_assert (texture_id > 0);
|
||||
g_assert (g_hash_table_contains (self->textures, GUINT_TO_POINTER (texture_id)));
|
||||
|
||||
if (!g_hash_table_contains (self->key_to_texture_id, key))
|
||||
{
|
||||
GskTextureKey *k;
|
||||
k = g_memdup (key, sizeof *key);
|
||||
|
||||
k = g_memdup (key, sizeof *key);
|
||||
|
||||
g_assert (!g_hash_table_contains (self->texture_id_to_key, GUINT_TO_POINTER (texture_id)));
|
||||
g_hash_table_insert (self->key_to_texture_id, k, GUINT_TO_POINTER (texture_id));
|
||||
g_hash_table_insert (self->texture_id_to_key, GUINT_TO_POINTER (texture_id), k);
|
||||
}
|
||||
g_hash_table_insert (self->key_to_texture_id, k, GUINT_TO_POINTER (texture_id));
|
||||
g_hash_table_insert (self->texture_id_to_key, GUINT_TO_POINTER (texture_id), k);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -770,8 +761,7 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
|
||||
GdkGLContext *texture_context = gdk_gl_texture_get_context (gl_texture);
|
||||
|
||||
if (gdk_gl_context_is_shared (context, texture_context) &&
|
||||
(!ensure_mipmap || gdk_gl_texture_has_mipmap (gl_texture)) &&
|
||||
gdk_memory_format_alpha (gdk_texture_get_format (texture)) != GDK_MEMORY_ALPHA_STRAIGHT)
|
||||
(!ensure_mipmap || gdk_gl_texture_has_mipmap (gl_texture)))
|
||||
{
|
||||
/* A GL texture from the same GL context is a simple task... */
|
||||
return gdk_gl_texture_get_id (gl_texture);
|
||||
|
||||
@@ -97,7 +97,6 @@ struct _GskGLDriver
|
||||
GskGLCommandQueue *command_queue;
|
||||
|
||||
GskGLGlyphLibrary *glyphs_library;
|
||||
GskGLGlyphyLibrary *glyphy_library;
|
||||
GskGLIconLibrary *icons_library;
|
||||
GskGLShadowLibrary *shadows_library;
|
||||
|
||||
|
||||
@@ -1,544 +0,0 @@
|
||||
/* gskglglyphylibrary.c
|
||||
*
|
||||
* Copyright 2020 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
/* Some of the glyphy cache is based upon the original glyphy code.
|
||||
* It's license is provided below.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2012 Google, Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gdk/gdkglcontextprivate.h>
|
||||
#include <gdk/gdkmemoryformatprivate.h>
|
||||
#include <gdk/gdkprofilerprivate.h>
|
||||
|
||||
#include "gskglcommandqueueprivate.h"
|
||||
#include "gskgldriverprivate.h"
|
||||
#include "gskglglyphylibraryprivate.h"
|
||||
#include "gskdebugprivate.h"
|
||||
|
||||
#include "gskpathprivate.h"
|
||||
|
||||
#include <glyphy.h>
|
||||
|
||||
#define TOLERANCE (1/2048.)
|
||||
#define MIN_FONT_SIZE 14
|
||||
#define GRID_SIZE 20 /* Per EM */
|
||||
#define ENLIGHTEN_MAX .01 /* Per EM */
|
||||
#define EMBOLDEN_MAX .024 /* Per EM */
|
||||
|
||||
/* We split the atlas into cells of size 64x8, so the minimum number of
|
||||
* bytes we store per glyph is 2048, and an atlas of size 2048x1024 can
|
||||
* hold at most 4096 glyphs. We need 5 and 7 bits to store the position
|
||||
* of a glyph in the atlas.
|
||||
*
|
||||
* We allocate each glyph a column of as many vertically adjacent cells
|
||||
* as it needs.
|
||||
*/
|
||||
#define ITEM_W 64
|
||||
#define ITEM_H_QUANTUM 8
|
||||
|
||||
G_DEFINE_TYPE (GskGLGlyphyLibrary, gsk_gl_glyphy_library, GSK_TYPE_GL_TEXTURE_LIBRARY)
|
||||
|
||||
GskGLGlyphyLibrary *
|
||||
gsk_gl_glyphy_library_new (GskGLDriver *driver)
|
||||
{
|
||||
g_return_val_if_fail (GSK_IS_GL_DRIVER (driver), NULL);
|
||||
|
||||
return g_object_new (GSK_TYPE_GL_GLYPHY_LIBRARY,
|
||||
"driver", driver,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static guint
|
||||
gsk_gl_glyphy_key_hash (gconstpointer data)
|
||||
{
|
||||
const GskGLGlyphyKey *key = data;
|
||||
|
||||
/* malloc()'d pointers already guarantee 3 bits from the LSB on 64-bit and
|
||||
* 2 bits from the LSB on 32-bit. Shift by enough to give us 256 entries
|
||||
* in our front cache for the glyph since languages will naturally cluster
|
||||
* for us.
|
||||
*/
|
||||
|
||||
return (key->font << 8) ^ key->glyph;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_gl_glyphy_key_equal (gconstpointer v1,
|
||||
gconstpointer v2)
|
||||
{
|
||||
return memcmp (v1, v2, sizeof (GskGLGlyphyKey)) == 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_glyphy_key_free (gpointer data)
|
||||
{
|
||||
GskGLGlyphyKey *key = data;
|
||||
|
||||
g_slice_free (GskGLGlyphyKey, key);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_glyphy_value_free (gpointer data)
|
||||
{
|
||||
g_slice_free (GskGLGlyphyValue, data);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_glyphy_library_clear_cache (GskGLTextureLibrary *library)
|
||||
{
|
||||
GskGLGlyphyLibrary *self = (GskGLGlyphyLibrary *)library;
|
||||
|
||||
g_assert (GSK_IS_GL_GLYPHY_LIBRARY (self));
|
||||
|
||||
memset (self->front, 0, sizeof self->front);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_glyphy_library_init_atlas (GskGLTextureLibrary *library,
|
||||
GskGLTextureAtlas *atlas)
|
||||
{
|
||||
g_assert (GSK_IS_GL_GLYPHY_LIBRARY (library));
|
||||
g_assert (atlas != NULL);
|
||||
|
||||
atlas->cursor_x = 0;
|
||||
atlas->cursor_y = 0;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_gl_glyphy_library_allocate (GskGLTextureLibrary *library,
|
||||
GskGLTextureAtlas *atlas,
|
||||
int width,
|
||||
int height,
|
||||
int *out_x,
|
||||
int *out_y)
|
||||
{
|
||||
GskGLGlyphyLibrary *self = (GskGLGlyphyLibrary *)library;
|
||||
int cursor_save_x;
|
||||
int cursor_save_y;
|
||||
|
||||
g_assert (GSK_IS_GL_GLYPHY_LIBRARY (self));
|
||||
g_assert (atlas != NULL);
|
||||
|
||||
cursor_save_x = atlas->cursor_x;
|
||||
cursor_save_y = atlas->cursor_y;
|
||||
|
||||
if ((height & (self->item_h_q-1)) != 0)
|
||||
height = (height + self->item_h_q - 1) & ~(self->item_h_q - 1);
|
||||
|
||||
/* Require allocations in columns of 64 and rows of 8 */
|
||||
g_assert (width == self->item_w);
|
||||
g_assert ((height % self->item_h_q) == 0);
|
||||
|
||||
if (atlas->cursor_y + height > atlas->height)
|
||||
{
|
||||
/* Go to next column */
|
||||
atlas->cursor_x += self->item_w;
|
||||
atlas->cursor_y = 0;
|
||||
}
|
||||
|
||||
if (atlas->cursor_x + width <= atlas->width &&
|
||||
atlas->cursor_y + height <= atlas->height)
|
||||
{
|
||||
*out_x = atlas->cursor_x;
|
||||
*out_y = atlas->cursor_y;
|
||||
atlas->cursor_y += height;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
atlas->cursor_x = cursor_save_x;
|
||||
atlas->cursor_y = cursor_save_y;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_glyphy_library_finalize (GObject *object)
|
||||
{
|
||||
GskGLGlyphyLibrary *self = (GskGLGlyphyLibrary *)object;
|
||||
|
||||
g_clear_pointer (&self->acc, glyphy_arc_accumulator_destroy);
|
||||
g_clear_pointer (&self->acc_endpoints, g_array_unref);
|
||||
|
||||
G_OBJECT_CLASS (gsk_gl_glyphy_library_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
GQuark quark_glyphy_font_key;
|
||||
|
||||
static void
|
||||
gsk_gl_glyphy_library_class_init (GskGLGlyphyLibraryClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GskGLTextureLibraryClass *library_class = GSK_GL_TEXTURE_LIBRARY_CLASS (klass);
|
||||
|
||||
quark_glyphy_font_key = g_quark_from_static_string ("glyphy-font-key");
|
||||
|
||||
object_class->finalize = gsk_gl_glyphy_library_finalize;
|
||||
|
||||
library_class->allocate = gsk_gl_glyphy_library_allocate;
|
||||
library_class->clear_cache = gsk_gl_glyphy_library_clear_cache;
|
||||
library_class->init_atlas = gsk_gl_glyphy_library_init_atlas;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_glyphy_library_init (GskGLGlyphyLibrary *self)
|
||||
{
|
||||
GskGLTextureLibrary *tl = (GskGLTextureLibrary *)self;
|
||||
|
||||
tl->max_entry_size = 0;
|
||||
tl->max_frame_age = 512;
|
||||
tl->atlas_width = 2048;
|
||||
tl->atlas_height = 1024;
|
||||
gsk_gl_texture_library_set_funcs (tl,
|
||||
gsk_gl_glyphy_key_hash,
|
||||
gsk_gl_glyphy_key_equal,
|
||||
gsk_gl_glyphy_key_free,
|
||||
gsk_gl_glyphy_value_free);
|
||||
|
||||
self->acc = glyphy_arc_accumulator_create ();
|
||||
self->acc_endpoints = g_array_new (FALSE, FALSE, sizeof (glyphy_arc_endpoint_t));
|
||||
self->item_w = ITEM_W;
|
||||
self->item_h_q = ITEM_H_QUANTUM;
|
||||
}
|
||||
|
||||
static glyphy_bool_t
|
||||
accumulate_endpoint (glyphy_arc_endpoint_t *endpoint,
|
||||
GArray *endpoints)
|
||||
{
|
||||
g_array_append_vals (endpoints, endpoint, 1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
move_to (hb_draw_funcs_t *dfuncs,
|
||||
GskPathBuilder *builder,
|
||||
hb_draw_state_t *st,
|
||||
float x,
|
||||
float y,
|
||||
void *data)
|
||||
{
|
||||
gsk_path_builder_move_to (builder, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
line_to (hb_draw_funcs_t *dfuncs,
|
||||
GskPathBuilder *builder,
|
||||
hb_draw_state_t *st,
|
||||
float x,
|
||||
float y,
|
||||
void *data)
|
||||
{
|
||||
gsk_path_builder_line_to (builder, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
cubic_to (hb_draw_funcs_t *dfuncs,
|
||||
GskPathBuilder *builder,
|
||||
hb_draw_state_t *st,
|
||||
float x1,
|
||||
float y1,
|
||||
float x2,
|
||||
float y2,
|
||||
float x3,
|
||||
float y3,
|
||||
void *data)
|
||||
{
|
||||
gsk_path_builder_cubic_to (builder, x1, y1, x2, y2, x3, y3);
|
||||
}
|
||||
|
||||
static void
|
||||
close_path (hb_draw_funcs_t *dfuncs,
|
||||
GskPathBuilder *builder,
|
||||
hb_draw_state_t *st,
|
||||
void *data)
|
||||
{
|
||||
gsk_path_builder_close (builder);
|
||||
}
|
||||
|
||||
static hb_draw_funcs_t *
|
||||
gsk_path_get_draw_funcs (void)
|
||||
{
|
||||
static hb_draw_funcs_t *funcs = NULL;
|
||||
|
||||
if (!funcs)
|
||||
{
|
||||
funcs = hb_draw_funcs_create ();
|
||||
|
||||
hb_draw_funcs_set_move_to_func (funcs, (hb_draw_move_to_func_t) move_to, NULL, NULL);
|
||||
hb_draw_funcs_set_line_to_func (funcs, (hb_draw_line_to_func_t) line_to, NULL, NULL);
|
||||
hb_draw_funcs_set_cubic_to_func (funcs, (hb_draw_cubic_to_func_t) cubic_to, NULL, NULL);
|
||||
hb_draw_funcs_set_close_path_func (funcs, (hb_draw_close_path_func_t) close_path, NULL, NULL);
|
||||
|
||||
hb_draw_funcs_make_immutable (funcs);
|
||||
}
|
||||
|
||||
return funcs;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
acc_callback (GskPathOperation op,
|
||||
const graphene_point_t *pts,
|
||||
gsize n_pts,
|
||||
float weight,
|
||||
gpointer user_data)
|
||||
{
|
||||
glyphy_arc_accumulator_t *acc = user_data;
|
||||
glyphy_point_t p0, p1, p2, p3;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case GSK_PATH_MOVE:
|
||||
p0.x = pts[0].x; p0.y = pts[0].y;
|
||||
glyphy_arc_accumulator_move_to (acc, &p0);
|
||||
break;
|
||||
case GSK_PATH_CLOSE:
|
||||
glyphy_arc_accumulator_close_path (acc);
|
||||
break;
|
||||
case GSK_PATH_LINE:
|
||||
p1.x = pts[1].x; p1.y = pts[1].y;
|
||||
glyphy_arc_accumulator_line_to (acc, &p1);
|
||||
break;
|
||||
case GSK_PATH_QUAD:
|
||||
p1.x = pts[1].x; p1.y = pts[1].y;
|
||||
p2.x = pts[2].x; p2.y = pts[2].y;
|
||||
/* This glyphy api is mis-named */
|
||||
glyphy_arc_accumulator_conic_to (acc, &p1, &p2);
|
||||
break;
|
||||
case GSK_PATH_CUBIC:
|
||||
p1.x = pts[1].x; p1.y = pts[1].y;
|
||||
p2.x = pts[2].x; p2.y = pts[2].y;
|
||||
p3.x = pts[3].x; p3.y = pts[3].y;
|
||||
glyphy_arc_accumulator_cubic_to (acc, &p1, &p2, &p3);
|
||||
break;
|
||||
case GSK_PATH_CONIC:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
encode_glyph (GskGLGlyphyLibrary *self,
|
||||
hb_font_t *font,
|
||||
unsigned int glyph_index,
|
||||
double tolerance_per_em,
|
||||
glyphy_rgba_t *buffer,
|
||||
guint buffer_len,
|
||||
guint *output_len,
|
||||
guint *nominal_width,
|
||||
guint *nominal_height,
|
||||
glyphy_extents_t *extents)
|
||||
{
|
||||
hb_face_t *face = hb_font_get_face (font);
|
||||
guint upem = hb_face_get_upem (face);
|
||||
double tolerance = upem * tolerance_per_em;
|
||||
double faraway = (double)upem / (MIN_FONT_SIZE * M_SQRT2);
|
||||
double unit_size = (double) upem / GRID_SIZE;
|
||||
double enlighten_max = (double) upem * ENLIGHTEN_MAX;
|
||||
double embolden_max = (double) upem * EMBOLDEN_MAX;
|
||||
double avg_fetch_achieved;
|
||||
GskPathBuilder *builder;
|
||||
GskPath *path, *simplified;
|
||||
|
||||
self->acc_endpoints->len = 0;
|
||||
|
||||
glyphy_arc_accumulator_reset (self->acc);
|
||||
glyphy_arc_accumulator_set_tolerance (self->acc, tolerance);
|
||||
glyphy_arc_accumulator_set_callback (self->acc,
|
||||
(glyphy_arc_endpoint_accumulator_callback_t)accumulate_endpoint,
|
||||
self->acc_endpoints);
|
||||
|
||||
builder = gsk_path_builder_new ();
|
||||
#if HB_VERSION_ATLEAST (7, 0, 0)
|
||||
hb_font_draw_glyph (font, glyph_index, gsk_path_get_draw_funcs (), builder);
|
||||
#else
|
||||
hb_font_get_glyph_shape (font, glyph_index, gsk_path_get_draw_funcs (), builder);
|
||||
#endif
|
||||
path = gsk_path_builder_free_to_path (builder);
|
||||
simplified = gsk_path_op (GSK_PATH_OP_SIMPLIFY, GSK_FILL_RULE_WINDING, path, NULL);
|
||||
gsk_path_foreach (simplified, -1, acc_callback, self->acc);
|
||||
gsk_path_unref (simplified);
|
||||
gsk_path_unref (path);
|
||||
|
||||
if (!glyphy_arc_accumulator_successful (self->acc))
|
||||
return FALSE;
|
||||
|
||||
g_assert (glyphy_arc_accumulator_get_error (self->acc) <= tolerance);
|
||||
|
||||
if (self->acc_endpoints->len > 0)
|
||||
glyphy_outline_winding_from_even_odd ((gpointer)self->acc_endpoints->data,
|
||||
self->acc_endpoints->len,
|
||||
FALSE);
|
||||
|
||||
if (!glyphy_arc_list_encode_blob2 ((gpointer)self->acc_endpoints->data,
|
||||
self->acc_endpoints->len,
|
||||
buffer,
|
||||
buffer_len,
|
||||
faraway,
|
||||
unit_size,
|
||||
enlighten_max,
|
||||
embolden_max,
|
||||
&avg_fetch_achieved,
|
||||
output_len,
|
||||
nominal_width,
|
||||
nominal_height,
|
||||
extents))
|
||||
return FALSE;
|
||||
|
||||
glyphy_extents_scale (extents, 1./upem, 1./upem);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline hb_font_t *
|
||||
get_nominal_size_hb_font (PangoFont *font)
|
||||
{
|
||||
hb_font_t *hbfont;
|
||||
const float *coords;
|
||||
unsigned int length;
|
||||
|
||||
hbfont = (hb_font_t *) g_object_get_data ((GObject *)font, "glyph-nominal-size-font");
|
||||
if (hbfont == NULL)
|
||||
{
|
||||
hbfont = hb_font_create (hb_font_get_face (pango_font_get_hb_font (font)));
|
||||
coords = hb_font_get_var_coords_design (pango_font_get_hb_font (font), &length);
|
||||
if (length > 0)
|
||||
hb_font_set_var_coords_design (hbfont, coords, length);
|
||||
|
||||
g_object_set_data_full ((GObject *)font, "glyphy-nominal-size-font",
|
||||
hbfont, (GDestroyNotify)hb_font_destroy);
|
||||
}
|
||||
|
||||
return hbfont;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_gl_glyphy_library_add (GskGLGlyphyLibrary *self,
|
||||
GskGLGlyphyKey *key,
|
||||
PangoFont *font,
|
||||
const GskGLGlyphyValue **out_value)
|
||||
{
|
||||
static glyphy_rgba_t buffer[4096 * 16];
|
||||
GskGLTextureLibrary *tl = (GskGLTextureLibrary *)self;
|
||||
GskGLGlyphyValue *value;
|
||||
glyphy_extents_t extents;
|
||||
hb_font_t *hbfont;
|
||||
guint packed_x;
|
||||
guint packed_y;
|
||||
guint nominal_w, nominal_h;
|
||||
guint output_len = 0;
|
||||
guint texture_id;
|
||||
guint width, height;
|
||||
|
||||
g_assert (GSK_IS_GL_GLYPHY_LIBRARY (self));
|
||||
g_assert (key != NULL);
|
||||
g_assert (font != NULL);
|
||||
g_assert (out_value != NULL);
|
||||
|
||||
hbfont = get_nominal_size_hb_font (font);
|
||||
|
||||
/* Convert the glyph to a list of arcs */
|
||||
if (!encode_glyph (self, hbfont, key->glyph, TOLERANCE,
|
||||
buffer, sizeof buffer, &output_len,
|
||||
&nominal_w, &nominal_h, &extents))
|
||||
return FALSE;
|
||||
|
||||
/* Allocate space for list within atlas */
|
||||
width = self->item_w;
|
||||
height = (output_len + width - 1) / width;
|
||||
GSK_DEBUG (GLYPH_CACHE, "font %u glyph %u: %u bytes (%u x %u)", key->font, key->glyph, output_len * 4, width, height);
|
||||
|
||||
value = gsk_gl_texture_library_pack (tl, key, sizeof *value,
|
||||
width, height, 0,
|
||||
&packed_x, &packed_y);
|
||||
|
||||
g_assert (packed_x % ITEM_W == 0);
|
||||
g_assert (packed_y % ITEM_H_QUANTUM == 0);
|
||||
|
||||
/* Make sure we found space to pack */
|
||||
texture_id = GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (value);
|
||||
if (texture_id == 0)
|
||||
return FALSE;
|
||||
|
||||
if (!glyphy_extents_is_empty (&extents))
|
||||
{
|
||||
/* Connect the texture for data upload */
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
glBindTexture (GL_TEXTURE_2D, texture_id);
|
||||
|
||||
g_assert (width > 0);
|
||||
g_assert (height > 0);
|
||||
|
||||
/* Upload the arc list */
|
||||
if (width * height == output_len)
|
||||
{
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x, packed_y,
|
||||
width, height,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x, packed_y,
|
||||
width, height - 1,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
buffer);
|
||||
/* Upload the last row separately */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x, packed_y + height - 1,
|
||||
output_len - (width * (height - 1)), 1,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
buffer + (width * (height - 1)));
|
||||
}
|
||||
}
|
||||
|
||||
value->extents.min_x = extents.min_x;
|
||||
value->extents.min_y = extents.min_y;
|
||||
value->extents.max_x = extents.max_x;
|
||||
value->extents.max_y = extents.max_y;
|
||||
value->nominal_w = nominal_w;
|
||||
value->nominal_h = nominal_h;
|
||||
value->atlas_x = packed_x / self->item_w;
|
||||
value->atlas_y = packed_y / self->item_h_q;
|
||||
|
||||
*out_value = value;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
/* gskglglyphylibraryprivate.h
|
||||
*
|
||||
* Copyright 2020-2022 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef __GSK_GL_GLYPHY_LIBRARY_PRIVATE_H__
|
||||
#define __GSK_GL_GLYPHY_LIBRARY_PRIVATE_H__
|
||||
|
||||
#include <glyphy.h>
|
||||
#include <pango/pango.h>
|
||||
|
||||
#include "gskgltexturelibraryprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_GL_GLYPHY_LIBRARY (gsk_gl_glyphy_library_get_type())
|
||||
|
||||
typedef guint FontKey;
|
||||
|
||||
extern GQuark quark_glyphy_font_key;
|
||||
|
||||
static inline FontKey
|
||||
gsk_gl_glyphy_library_get_font_key (PangoFont *font)
|
||||
{
|
||||
FontKey key;
|
||||
|
||||
key = (FontKey) GPOINTER_TO_UINT (g_object_get_qdata ((GObject *)font, quark_glyphy_font_key));
|
||||
if (key == 0)
|
||||
{
|
||||
PangoFontDescription *desc = pango_font_describe (font);
|
||||
pango_font_description_set_size (desc, 10 * PANGO_SCALE);
|
||||
key = (FontKey) pango_font_description_hash (desc);
|
||||
pango_font_description_free (desc);
|
||||
g_object_set_qdata ((GObject *)font, quark_glyphy_font_key, GUINT_TO_POINTER (key));
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
static inline float
|
||||
gsk_gl_glyphy_library_get_font_scale (PangoFont *font)
|
||||
{
|
||||
hb_font_t *hbfont;
|
||||
int x_scale, y_scale;
|
||||
|
||||
hbfont = pango_font_get_hb_font (font);
|
||||
hb_font_get_scale (hbfont, &x_scale, &y_scale);
|
||||
|
||||
return MAX (x_scale, y_scale) / 1000.0;
|
||||
}
|
||||
|
||||
|
||||
typedef struct _GskGLGlyphyKey
|
||||
{
|
||||
FontKey font;
|
||||
PangoGlyph glyph;
|
||||
} GskGLGlyphyKey;
|
||||
|
||||
typedef struct _GskGLGlyphyValue
|
||||
{
|
||||
GskGLTextureAtlasEntry entry;
|
||||
struct {
|
||||
float min_x;
|
||||
float min_y;
|
||||
float max_x;
|
||||
float max_y;
|
||||
} extents;
|
||||
guint nominal_w;
|
||||
guint nominal_h;
|
||||
guint atlas_x;
|
||||
guint atlas_y;
|
||||
} GskGLGlyphyValue;
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskGLGlyphyLibrary, gsk_gl_glyphy_library, GSK, GL_GLYPHY_LIBRARY, GskGLTextureLibrary)
|
||||
|
||||
struct _GskGLGlyphyLibrary
|
||||
{
|
||||
GskGLTextureLibrary parent_instance;
|
||||
glyphy_arc_accumulator_t *acc;
|
||||
GArray *acc_endpoints;
|
||||
guint item_w;
|
||||
guint item_h_q;
|
||||
struct {
|
||||
GskGLGlyphyKey key;
|
||||
const GskGLGlyphyValue *value;
|
||||
} front[256];
|
||||
};
|
||||
|
||||
GskGLGlyphyLibrary *gsk_gl_glyphy_library_new (GskGLDriver *driver);
|
||||
gboolean gsk_gl_glyphy_library_add (GskGLGlyphyLibrary *self,
|
||||
GskGLGlyphyKey *key,
|
||||
PangoFont *font,
|
||||
const GskGLGlyphyValue **out_value);
|
||||
|
||||
static inline guint
|
||||
gsk_gl_glyphy_library_lookup_or_add (GskGLGlyphyLibrary *self,
|
||||
const GskGLGlyphyKey *key,
|
||||
PangoFont *font,
|
||||
const GskGLGlyphyValue **out_value)
|
||||
{
|
||||
GskGLTextureAtlasEntry *entry;
|
||||
guint front_index = key->glyph & 0xFF;
|
||||
|
||||
if (memcmp (key, &self->front[front_index], sizeof *key) == 0)
|
||||
{
|
||||
*out_value = self->front[front_index].value;
|
||||
}
|
||||
else if (gsk_gl_texture_library_lookup ((GskGLTextureLibrary *)self, key, &entry))
|
||||
{
|
||||
*out_value = (GskGLGlyphyValue *)entry;
|
||||
self->front[front_index].key = *key;
|
||||
self->front[front_index].value = *out_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
GskGLGlyphyKey *k = g_slice_copy (sizeof *key, key);
|
||||
gsk_gl_glyphy_library_add (self, k, font, out_value);
|
||||
self->front[front_index].key = *key;
|
||||
self->front[front_index].value = *out_value;
|
||||
}
|
||||
|
||||
return GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (*out_value);
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_GL_GLYPHY_LIBRARY_PRIVATE_H__ */
|
||||
@@ -87,21 +87,3 @@ GSK_GL_DEFINE_PROGRAM (unblurred_outset_shadow,
|
||||
GSK_GL_ADD_UNIFORM (1, UNBLURRED_OUTSET_SHADOW_SPREAD, u_spread)
|
||||
GSK_GL_ADD_UNIFORM (2, UNBLURRED_OUTSET_SHADOW_OFFSET, u_offset)
|
||||
GSK_GL_ADD_UNIFORM (3, UNBLURRED_OUTSET_SHADOW_OUTLINE_RECT, u_outline_rect))
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (glyphy,
|
||||
GSK_GL_SHADER_JOINED (VERTEX,
|
||||
GSK_GL_SHADER_RESOURCE ("glyphy.vs.glsl"),
|
||||
NULL)
|
||||
GSK_GL_SHADER_JOINED (FRAGMENT,
|
||||
GSK_GL_SHADER_RESOURCE ("glyphy.atlas.glsl"),
|
||||
GSK_GL_SHADER_STRING (glyphy_common_shader_source ()),
|
||||
GSK_GL_SHADER_STRING ("#define GLYPHY_SDF_PSEUDO_DISTANCE 1\n"),
|
||||
GSK_GL_SHADER_STRING (glyphy_sdf_shader_source ()),
|
||||
GSK_GL_SHADER_RESOURCE ("glyphy.fs.glsl"),
|
||||
NULL),
|
||||
GSK_GL_ADD_UNIFORM (0, GLYPHY_CONTRAST, u_contrast)
|
||||
GSK_GL_ADD_UNIFORM (1, GLYPHY_GAMMA_ADJUST, u_gamma_adjust)
|
||||
GSK_GL_ADD_UNIFORM (2, GLYPHY_OUTLINE_THICKNESS, u_outline_thickness)
|
||||
GSK_GL_ADD_UNIFORM (3, GLYPHY_OUTLINE, u_outline)
|
||||
GSK_GL_ADD_UNIFORM (4, GLYPHY_BOLDNESS, u_boldness)
|
||||
GSK_GL_ADD_UNIFORM (6, GLYPHY_ATLAS_INFO, u_atlas_info))
|
||||
|
||||
@@ -150,13 +150,6 @@ gsk_gl_renderer_realize (GskRenderer *renderer,
|
||||
gsk_gl_command_queue_set_profiler (self->command_queue,
|
||||
gsk_renderer_get_profiler (renderer));
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (gsk_renderer_get_debug_flags (renderer) & GSK_DEBUG_NO_GLYPHY)
|
||||
GSK_RENDERER_DEBUG (renderer, RENDERER, "GL Renderer will use cairo for glyph rendering");
|
||||
else
|
||||
GSK_RENDERER_DEBUG (renderer, RENDERER, "GL Renderer will use glyphy for glyph rendering");
|
||||
#endif
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
failure:
|
||||
@@ -303,7 +296,7 @@ gsk_gl_renderer_render (GskRenderer *renderer,
|
||||
viewport.size.height = gdk_surface_get_height (surface) * scale;
|
||||
|
||||
gdk_draw_context_begin_frame_full (GDK_DRAW_CONTEXT (self->context),
|
||||
gsk_render_node_get_preferred_depth (root),
|
||||
gsk_render_node_prefers_high_depth (root),
|
||||
update_area);
|
||||
|
||||
gdk_gl_context_make_current (self->context);
|
||||
@@ -314,15 +307,10 @@ gsk_gl_renderer_render (GskRenderer *renderer,
|
||||
|
||||
gsk_gl_driver_begin_frame (self->driver, self->command_queue);
|
||||
job = gsk_gl_render_job_new (self->driver, &viewport, scale, render_region, 0, clear_framebuffer);
|
||||
|
||||
if ((gsk_renderer_get_debug_flags (renderer) & GSK_DEBUG_NO_GLYPHY) == 0)
|
||||
gsk_gl_render_job_set_use_glyphy (job, TRUE);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), FALLBACK))
|
||||
gsk_gl_render_job_set_debug_fallback (job, TRUE);
|
||||
#endif
|
||||
|
||||
gsk_gl_render_job_render (job, root);
|
||||
gsk_gl_driver_end_frame (self->driver);
|
||||
gsk_gl_render_job_free (job);
|
||||
@@ -385,7 +373,7 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
|
||||
return texture;
|
||||
}
|
||||
|
||||
if (gsk_render_node_get_preferred_depth (root) != GDK_MEMORY_U8 &&
|
||||
if (gsk_render_node_prefers_high_depth (root) &&
|
||||
gdk_gl_context_check_version (self->context, "3.0", "3.0"))
|
||||
format = GL_RGBA32F;
|
||||
else
|
||||
|
||||
@@ -34,14 +34,10 @@
|
||||
#include <gsk/gskroundedrectprivate.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_PANGOFT
|
||||
#include <pango/pangofc-font.h>
|
||||
#endif
|
||||
|
||||
#include "gskglcommandqueueprivate.h"
|
||||
#include "gskgldriverprivate.h"
|
||||
#include "gskglglyphlibraryprivate.h"
|
||||
#include "gskglglyphylibraryprivate.h"
|
||||
#include "gskgliconlibraryprivate.h"
|
||||
#include "gskglprogramprivate.h"
|
||||
#include "gskglrenderjobprivate.h"
|
||||
@@ -153,9 +149,6 @@ struct _GskGLRenderJob
|
||||
*/
|
||||
guint clear_framebuffer : 1;
|
||||
|
||||
/* Allow experimental glyph rendering with glyphy */
|
||||
guint use_glyphy : 1;
|
||||
|
||||
/* Format we want to use for intermediate textures, determined by
|
||||
* looking at the format of the framebuffer we are rendering on.
|
||||
*/
|
||||
@@ -201,7 +194,7 @@ static inline int
|
||||
get_target_format (GskGLRenderJob *job,
|
||||
const GskRenderNode *node)
|
||||
{
|
||||
if (gsk_render_node_get_preferred_depth (node) != GDK_MEMORY_U8)
|
||||
if (gsk_render_node_prefers_high_depth (node))
|
||||
return job->target_format;
|
||||
|
||||
return GL_RGBA8;
|
||||
@@ -810,8 +803,6 @@ gsk_gl_render_job_untransform_bounds (GskGLRenderJob *job,
|
||||
|
||||
out_rect->origin.x -= job->offset_x;
|
||||
out_rect->origin.y -= job->offset_y;
|
||||
|
||||
gsk_transform_unref (transform);
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -2966,10 +2957,10 @@ compute_phase_and_pos (float value, float *pos)
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_gl_render_job_visit_text_node_legacy (GskGLRenderJob *job,
|
||||
const GskRenderNode *node,
|
||||
const GdkRGBA *color,
|
||||
gboolean force_color)
|
||||
gsk_gl_render_job_visit_text_node (GskGLRenderJob *job,
|
||||
const GskRenderNode *node,
|
||||
const GdkRGBA *color,
|
||||
gboolean force_color)
|
||||
{
|
||||
const PangoFont *font = gsk_text_node_get_font (node);
|
||||
const PangoGlyphInfo *glyphs = gsk_text_node_get_glyphs (node, NULL);
|
||||
@@ -3105,263 +3096,6 @@ gsk_gl_render_job_visit_text_node_legacy (GskGLRenderJob *job,
|
||||
}
|
||||
}
|
||||
|
||||
/* Keep this in sync with glyph_vertex_transcode in glyphy.vs.glsl */
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float g16hi;
|
||||
float g16lo;
|
||||
} EncodedGlyph;
|
||||
|
||||
static inline unsigned int
|
||||
glyph_encode (guint atlas_x , /* 7 bits */
|
||||
guint atlas_y, /* 7 bits */
|
||||
guint corner_x, /* 1 bit */
|
||||
guint corner_y, /* 1 bit */
|
||||
guint nominal_w, /* 6 bits */
|
||||
guint nominal_h) /* 6 bits */
|
||||
{
|
||||
guint x, y;
|
||||
|
||||
g_assert (0 == (atlas_x & ~0x7F));
|
||||
g_assert (0 == (atlas_y & ~0x7F));
|
||||
g_assert (0 == (corner_x & ~1));
|
||||
g_assert (0 == (corner_y & ~1));
|
||||
g_assert (0 == (nominal_w & ~0x3F));
|
||||
g_assert (0 == (nominal_h & ~0x3F));
|
||||
|
||||
x = (((atlas_x << 6) | nominal_w) << 1) | corner_x;
|
||||
y = (((atlas_y << 6) | nominal_h) << 1) | corner_y;
|
||||
|
||||
return (x << 16) | y;
|
||||
}
|
||||
|
||||
static inline void
|
||||
encoded_glyph_init (EncodedGlyph *eg,
|
||||
float x,
|
||||
float y,
|
||||
guint corner_x,
|
||||
guint corner_y,
|
||||
const GskGLGlyphyValue *gi)
|
||||
{
|
||||
guint encoded = glyph_encode (gi->atlas_x, gi->atlas_y, corner_x, corner_y, gi->nominal_w, gi->nominal_h);
|
||||
|
||||
eg->x = x;
|
||||
eg->y = y;
|
||||
eg->g16hi = encoded >> 16;
|
||||
eg->g16lo = encoded & 0xFFFF;
|
||||
}
|
||||
|
||||
static inline void
|
||||
add_encoded_glyph (GskGLDrawVertex *vertices,
|
||||
const EncodedGlyph *eg,
|
||||
const guint16 c[4])
|
||||
{
|
||||
*vertices = (GskGLDrawVertex) { .position = { eg->x, eg->y}, .uv = { eg->g16hi, eg->g16lo}, .color = { c[0], c[1], c[2], c[3] } };
|
||||
}
|
||||
|
||||
static void
|
||||
get_synthetic_font_params (PangoFont *font,
|
||||
gboolean *embolden,
|
||||
PangoMatrix *matrix)
|
||||
{
|
||||
*embolden = FALSE;
|
||||
*matrix = (PangoMatrix) PANGO_MATRIX_INIT;
|
||||
|
||||
#ifdef HAVE_PANGOFT
|
||||
if (PANGO_IS_FC_FONT (font))
|
||||
{
|
||||
FcPattern *pattern = pango_fc_font_get_pattern (PANGO_FC_FONT (font));
|
||||
FcBool b;
|
||||
FcMatrix mat;
|
||||
FcMatrix *m;
|
||||
|
||||
if (FcPatternGetBool (pattern, FC_EMBOLDEN, 0, &b) == FcResultMatch)
|
||||
*embolden = b;
|
||||
|
||||
FcMatrixInit (&mat);
|
||||
for (int i = 0; FcPatternGetMatrix (pattern, FC_MATRIX, i, &m) == FcResultMatch; i++)
|
||||
FcMatrixMultiply (&mat, &mat, m);
|
||||
|
||||
matrix->xx = mat.xx;
|
||||
matrix->xy = mat.xy;
|
||||
matrix->yx = mat.yx;
|
||||
matrix->yy = mat.yy;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_gl_render_job_visit_text_node_glyphy (GskGLRenderJob *job,
|
||||
const GskRenderNode *node,
|
||||
const GdkRGBA *color)
|
||||
{
|
||||
const graphene_point_t *offset;
|
||||
const PangoGlyphInfo *glyphs;
|
||||
const PangoGlyphInfo *gi;
|
||||
GskGLGlyphyLibrary *library;
|
||||
GskGLCommandBatch *batch;
|
||||
PangoFont *font;
|
||||
GskGLDrawVertex *vertices;
|
||||
const guint16 *c;
|
||||
GskGLGlyphyKey lookup;
|
||||
guint16 cc[4];
|
||||
float x;
|
||||
float y;
|
||||
guint last_texture = 0;
|
||||
guint num_glyphs;
|
||||
guint used = 0;
|
||||
guint i;
|
||||
int x_position = 0;
|
||||
float font_scale;
|
||||
gboolean embolden;
|
||||
PangoMatrix matrix = PANGO_MATRIX_INIT;
|
||||
|
||||
#define GRID_SIZE 20
|
||||
|
||||
g_assert (!gsk_text_node_has_color_glyphs (node));
|
||||
|
||||
if (!(num_glyphs = gsk_text_node_get_num_glyphs (node)))
|
||||
return;
|
||||
|
||||
if (RGBA_IS_CLEAR (color))
|
||||
return;
|
||||
|
||||
font = (PangoFont *)gsk_text_node_get_font (node);
|
||||
get_synthetic_font_params (font, &embolden, &matrix);
|
||||
|
||||
glyphs = gsk_text_node_get_glyphs (node, NULL);
|
||||
library = job->driver->glyphy_library;
|
||||
offset = gsk_text_node_get_offset (node);
|
||||
x = offset->x + job->offset_x;
|
||||
y = offset->y + job->offset_y;
|
||||
|
||||
rgba_to_half (color, cc);
|
||||
c = cc;
|
||||
|
||||
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, glyphy));
|
||||
|
||||
batch = gsk_gl_command_queue_get_batch (job->command_queue);
|
||||
vertices = gsk_gl_command_queue_add_n_vertices (job->command_queue, num_glyphs);
|
||||
|
||||
lookup.font = gsk_gl_glyphy_library_get_font_key (font);
|
||||
font_scale = gsk_gl_glyphy_library_get_font_scale (font);
|
||||
|
||||
for (i = 0, gi = glyphs; i < num_glyphs; i++, gi++)
|
||||
{
|
||||
const GskGLGlyphyValue *glyph;
|
||||
float cx = 0, cy = 0;
|
||||
guint texture_id;
|
||||
|
||||
lookup.glyph = gi->glyph;
|
||||
texture_id = gsk_gl_glyphy_library_lookup_or_add (library, &lookup, font, &glyph);
|
||||
|
||||
if G_UNLIKELY (texture_id == 0)
|
||||
continue;
|
||||
|
||||
if G_UNLIKELY (last_texture != texture_id || batch->draw.vbo_count + GSK_GL_N_VERTICES > 0xffff)
|
||||
{
|
||||
if G_LIKELY (last_texture != 0)
|
||||
{
|
||||
guint vbo_offset = batch->draw.vbo_offset + batch->draw.vbo_count;
|
||||
|
||||
/* Since we have batched added our VBO vertices to avoid repeated
|
||||
* calls to the buffer, we need to manually tweak the vbo offset
|
||||
* of the new batch as otherwise it will point at the end of our
|
||||
* vbo array.
|
||||
*/
|
||||
gsk_gl_render_job_split_draw (job);
|
||||
batch = gsk_gl_command_queue_get_batch (job->command_queue);
|
||||
batch->draw.vbo_offset = vbo_offset;
|
||||
}
|
||||
|
||||
gsk_gl_program_set_uniform4i (job->current_program,
|
||||
UNIFORM_GLYPHY_ATLAS_INFO, 0,
|
||||
GSK_GL_TEXTURE_LIBRARY (library)->atlas_width,
|
||||
GSK_GL_TEXTURE_LIBRARY (library)->atlas_height,
|
||||
library->item_w,
|
||||
library->item_h_q);
|
||||
gsk_gl_program_set_uniform_texture (job->current_program,
|
||||
UNIFORM_SHARED_SOURCE, 0,
|
||||
GL_TEXTURE_2D,
|
||||
GL_TEXTURE0,
|
||||
texture_id);
|
||||
gsk_gl_program_set_uniform1f (job->current_program,
|
||||
UNIFORM_GLYPHY_GAMMA_ADJUST, 0,
|
||||
1.0);
|
||||
gsk_gl_program_set_uniform1f (job->current_program,
|
||||
UNIFORM_GLYPHY_CONTRAST, 0,
|
||||
1.0);
|
||||
|
||||
/* 0.0208 is the value used by freetype for synthetic emboldening */
|
||||
gsk_gl_program_set_uniform1f (job->current_program,
|
||||
UNIFORM_GLYPHY_BOLDNESS, 0,
|
||||
embolden ? 0.0208 * GRID_SIZE : 0.0);
|
||||
|
||||
#if 0
|
||||
gsk_gl_program_set_uniform1f (job->current_program,
|
||||
UNIFORM_GLYPHY_OUTLINE_THICKNESS, 0,
|
||||
1.0);
|
||||
gsk_gl_program_set_uniform1f (job->current_program,
|
||||
UNIFORM_GLYPHY_OUTLINE, 0,
|
||||
1.0);
|
||||
#endif
|
||||
|
||||
last_texture = texture_id;
|
||||
}
|
||||
|
||||
cx = (float)(x_position + gi->geometry.x_offset) / PANGO_SCALE;
|
||||
if G_UNLIKELY (gi->geometry.y_offset != 0)
|
||||
cy = (float)(gi->geometry.y_offset) / PANGO_SCALE;
|
||||
|
||||
x_position += gi->geometry.width;
|
||||
|
||||
EncodedGlyph encoded[4];
|
||||
#define ENCODE_CORNER(_cx, _cy) \
|
||||
G_STMT_START { \
|
||||
float _dx = _cx * (glyph->extents.max_x - glyph->extents.min_x); \
|
||||
float _dy = _cy * (glyph->extents.max_y - glyph->extents.min_y); \
|
||||
float _vx = x + cx + font_scale * (glyph->extents.min_x + matrix.xx * _dx + matrix.xy * _dy); \
|
||||
float _vy = y + cy - font_scale * (glyph->extents.min_y + matrix.yx * _dx + matrix.yy * _dy); \
|
||||
encoded_glyph_init (&encoded[_cx * 2 + _cy], _vx, _vy, _cx, _cy, glyph); \
|
||||
} G_STMT_END
|
||||
ENCODE_CORNER (0, 0);
|
||||
ENCODE_CORNER (0, 1);
|
||||
ENCODE_CORNER (1, 0);
|
||||
ENCODE_CORNER (1, 1);
|
||||
#undef ENCODE_CORNER
|
||||
|
||||
add_encoded_glyph (vertices++, &encoded[0], c);
|
||||
add_encoded_glyph (vertices++, &encoded[1], c);
|
||||
add_encoded_glyph (vertices++, &encoded[2], c);
|
||||
|
||||
add_encoded_glyph (vertices++, &encoded[1], c);
|
||||
add_encoded_glyph (vertices++, &encoded[2], c);
|
||||
add_encoded_glyph (vertices++, &encoded[3], c);
|
||||
|
||||
batch->draw.vbo_count += GSK_GL_N_VERTICES;
|
||||
used++;
|
||||
}
|
||||
|
||||
if (used != num_glyphs)
|
||||
gsk_gl_command_queue_retract_n_vertices (job->command_queue, num_glyphs - used);
|
||||
|
||||
gsk_gl_render_job_end_draw (job);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_gl_render_job_visit_text_node (GskGLRenderJob *job,
|
||||
const GskRenderNode *node,
|
||||
const GdkRGBA *color,
|
||||
gboolean force_color)
|
||||
{
|
||||
if (job->use_glyphy && !gsk_text_node_has_color_glyphs (node))
|
||||
gsk_gl_render_job_visit_text_node_glyphy (job, node, color);
|
||||
else
|
||||
gsk_gl_render_job_visit_text_node_legacy (job, node, color, force_color);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_gl_render_job_visit_shadow_node (GskGLRenderJob *job,
|
||||
const GskRenderNode *node)
|
||||
@@ -4727,15 +4461,6 @@ gsk_gl_render_job_set_debug_fallback (GskGLRenderJob *job,
|
||||
job->debug_fallback = !!debug_fallback;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gl_render_job_set_use_glyphy (GskGLRenderJob *job,
|
||||
gboolean use_glyphy)
|
||||
{
|
||||
g_return_if_fail (job != NULL);
|
||||
|
||||
job->use_glyphy = !!use_glyphy;
|
||||
}
|
||||
|
||||
static int
|
||||
get_framebuffer_format (GdkGLContext *context,
|
||||
guint framebuffer)
|
||||
|
||||
@@ -35,5 +35,4 @@ void gsk_gl_render_job_render_flipped (GskGLRenderJob *job
|
||||
GskRenderNode *root);
|
||||
void gsk_gl_render_job_set_debug_fallback (GskGLRenderJob *job,
|
||||
gboolean debug_fallback);
|
||||
void gsk_gl_render_job_set_use_glyphy (GskGLRenderJob *job,
|
||||
gboolean use_glyphy);
|
||||
|
||||
|
||||
@@ -204,7 +204,6 @@ gsk_gl_texture_library_dispose (GObject *object)
|
||||
|
||||
g_clear_pointer (&self->atlases, g_ptr_array_unref);
|
||||
g_clear_object (&self->driver);
|
||||
g_clear_pointer (&self->hash_table, g_hash_table_unref);
|
||||
|
||||
G_OBJECT_CLASS (gsk_gl_texture_library_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
@@ -36,14 +36,9 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GskGLTextureAtlas
|
||||
{
|
||||
/* Used by Glyph/Icons */
|
||||
struct stbrp_context context;
|
||||
struct stbrp_node *nodes;
|
||||
|
||||
/* Used by Glyphy */
|
||||
int cursor_x;
|
||||
int cursor_y;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
|
||||
@@ -53,6 +48,7 @@ typedef struct _GskGLTextureAtlas
|
||||
* But are now unused.
|
||||
*/
|
||||
int unused_pixels;
|
||||
|
||||
} GskGLTextureAtlas;
|
||||
|
||||
typedef struct _GskGLTextureAtlasEntry
|
||||
|
||||
@@ -36,7 +36,6 @@ typedef struct _GskGLCompiler GskGLCompiler;
|
||||
typedef struct _GskGLDrawVertex GskGLDrawVertex;
|
||||
typedef struct _GskGLRenderTarget GskGLRenderTarget;
|
||||
typedef struct _GskGLGlyphLibrary GskGLGlyphLibrary;
|
||||
typedef struct _GskGLGlyphyLibrary GskGLGlyphyLibrary;
|
||||
typedef struct _GskGLIconLibrary GskGLIconLibrary;
|
||||
typedef struct _GskGLProgram GskGLProgram;
|
||||
typedef struct _GskGLRenderJob GskGLRenderJob;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user