Compare commits

..

4 Commits

Author SHA1 Message Date
Matthias Clasen 0b30e9a63b gdk: Spread the errors
Call gdk_ensure_initialized() directly in gdk_display_open_default(),
gdk_display_open(), gdk_x11_display_open() and gdk_display_get_default(),
so we get the right function name in the error message. These functions
are likely candidates that people might call without ensuring that GDK is
initialized.
2024-10-21 12:55:07 -04:00
Matthias Clasen 1a7ab5dc9a gdk: No displays before init
Don't allow to create displays before gdk has been initialized.

Note that this error triggers in nautilus 47.0, but we consider
what it is doing unsupported and broken.

Related: #7035
2024-10-21 12:32:35 -04:00
Matthias Clasen 57b9435e13 print: Avoid calling gdk_display_get_default
Check if GTK has been initialized before trying to get a display
in a class_init function. The introspection property dumper code
will instantiate all types and run into the new introduced errors
if we try to get a display in class_init.
2024-10-21 12:32:35 -04:00
Matthias Clasen 212ba47646 tests: Cosmetics
Our test setups aready enforce GSETTINGS_BACKEND=memory, don't set
it again in code.
2024-10-21 12:32:25 -04:00
167 changed files with 8006 additions and 13748 deletions
+11 -10
View File
@@ -22,7 +22,7 @@ stages:
# Common variables
variables:
COMMON_MESON_FLAGS: "-Dwerror=true -Dcairo:werror=false -Dgi-docgen:werror=false -Dgraphene:werror=false -Dlibepoxy:werror=false -Dlibsass:werror=false -Dpango:werror=false -Dsassc:werror=false -Dgdk-pixbuf:werror=false -Dglib:werror=false -Dlibcloudproviders:werror=false -Dlibpng:werror=false -Dlibtiff:werror=false -Dsysprof:werror=false -Dwayland-protocols:werror=false -Dharfbuzz:werror=false -Dfreetype2:werror=false -Dfontconfig:werror=false -Dfribidi:werror=false -Dlibffi:werror=false -Dlibjpeg-turbo:werror=false -Dmutest:werror=false -Dpcre2:werror=false -Dpixman:werror=false -Dproxy-libintl:werror=false"
COMMON_MESON_FLAGS: "-Dwerror=true -Dcairo:werror=false -Dgi-docgen:werror=false -Dgraphene:werror=false -Dlibepoxy:werror=false -Dlibsass:werror=false -Dpango:werror=false -Dsassc:werror=false -Dgdk-pixbuf:werror=false -Dglib:werror=false -Dlibcloudproviders:werror=false -Dlibpng:werror=false -Dlibtiff:werror=false -Dsysprof:werror=false -Dwayland-protocols:werror=false -Dharfbuzz:werror=false -Dfreetype2:werror=false -Dfontconfig:werror=false -Dfribidi:werror=false -Dlibffi:werror=false -Dlibjpeg-turbo:werror=false -Dmutest:werror=false -Dpixman:werror=false -Dproxy-libintl:werror=false"
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-testsuite=true -Dintrospection=enabled"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
@@ -62,16 +62,18 @@ style-check-diff:
.build-fedora-default:
image: $FEDORA_IMAGE
artifacts:
name: "gtk-${CI_COMMIT_REF_NAME}"
when: always
reports:
junit:
- "${CI_PROJECT_DIR}/_build/meson-logs/testlog-x11.junit.xml"
- "${CI_PROJECT_DIR}/_build/meson-logs/testlog-wayland.junit.xml"
- "${CI_PROJECT_DIR}/_build/meson-logs/testlog-wayland_gl.junit.xml"
- "${CI_PROJECT_DIR}/_build/meson-logs/testlog-broadway.junit.xml"
- "${CI_PROJECT_DIR}/_build/report-x11.xml"
- "${CI_PROJECT_DIR}/_build/report-wayland.xml"
- "${CI_PROJECT_DIR}/_build/report-wayland_gl.xml"
- "${CI_PROJECT_DIR}/_build/report-broadway.xml"
name: "gtk-${CI_COMMIT_REF_NAME}"
paths:
- "${CI_PROJECT_DIR}/_build/meson-logs"
- "${CI_PROJECT_DIR}/_build/report*.xml"
- "${CI_PROJECT_DIR}/_build/report*.html"
- "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*/*.png"
- "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*/*.node"
- "${CI_PROJECT_DIR}/_build/testsuite/tools/output/*/*"
@@ -216,7 +218,7 @@ macos:
when: never
- if: $RUNNER == "macosintel"
variables:
SDKROOT: /opt/sdks/MacOSX10.15.6.sdk
SDKROOT: /opt/sdks/MacOSX10.13.4.sdk
NINJA_PKG: $CI_API_V4_URL/projects/30745/packages/generic/ninja_macos/v1.11.1.1+9/ninja-1.11.1.1-cp38-cp38-macosx_11_0_x86_64.whl
when: manual
allow_failure: true
@@ -240,7 +242,6 @@ macos:
PIPENV_CACHE_DIR: $PIP_CACHE_DIR
PYTHONPYCACHEPREFIX: $PIP_CACHE_DIR
before_script:
- ls /opt/sdks/
- .gitlab-ci/show-info-macos.sh
- python3 -m venv .venv
# Building the introspection feature requires pkg-config and bison.
@@ -264,7 +265,7 @@ macos:
paths:
- "${CI_PROJECT_DIR}/_build/meson-logs"
vs2019-x64:
vs2017-x64:
# TODO: Uncomment this when ready to merge.
# rules:
# - if: $CI_PROJECT_NAMESPACE == "GNOME"
@@ -273,7 +274,7 @@ vs2019-x64:
- win32-ps
needs: []
script:
- .gitlab-ci/test-msvc.bat ${COMMON_MESON_FLAGS}
- .gitlab-ci/test-msvc.bat
artifacts:
when: always
paths:
+8 -3
View File
@@ -11,9 +11,7 @@ multiplier=${MESON_TEST_TIMEOUT_MULTIPLIER:-1}
n_processes=${MESON_TEST_MAX_PROCESSES:-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:symbolize=1
export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0:detect_leaks=0:allocator_may_return_null=1
case "${setup}" in
x11*)
@@ -95,6 +93,13 @@ esac
cd ${builddir}
$srcdir/.gitlab-ci/meson-junit-report.py \
--project-name=gtk \
--backend="${setup}" \
--job-id="${CI_JOB_NAME}" \
--output="report-${setup}.xml" \
"meson-logs/testlog-${setup}.json"
$srcdir/.gitlab-ci/meson-html-report.py \
--project-name=gtk \
--backend="${setup}" \
+3 -2
View File
@@ -1,11 +1,12 @@
@echo on
:: vcvarsall.bat sets various env vars like PATH, INCLUDE, LIB, LIBPATH for the
:: specified build architecture
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
@echo on
:: FIXME: make warnings fatal
pip3 install --upgrade --user meson~=1.2 || goto :error
meson setup -Dbackend_max_links=1 -Ddebug=false -Dmedia-gstreamer=disabled -Dvulkan=disabled %~1 _build || goto :error
meson setup -Dbackend_max_links=1 -Ddebug=false -Dmedia-gstreamer=disabled -Dvulkan=disabled _build || goto :error
ninja -C _build || goto :error
goto :EOF
+1 -112
View File
@@ -1,117 +1,6 @@
Overview of Changes in 4.17.1, xx-xx-xxxx
Overview of Changes in 4.17.0, xx-xx-xxxx
=========================================
Overview of Changes in 4.17.0, 06-11-2024
=========================================
* GtkScrolledWindow
- Fix criticals in size allocation code
* GtkFileChooser
- Fix a crash in the portal code
* GtkFontChoser
- Make the dialog more shrinkable
* GtkPicture
- Avoid unnecessary resizes
* GtkVideo
- Make dmabufs work without GL
* GtkListBox:
- Add a tab-behavior property to influence keynav
* GtkEmojiChooser:
- Fix problems with insertion and selection
* GtkStringList:
- Add gtk_string_list_find
* GtkApplication:
- Respect GDK_DEBUG=no-portals
- Set default window icon from app ID
* GtkTextView:
- Vertical and horizontal positioning of the textview is now quantized
to the nearest device pixel. This should improve the perceived smoothness
of scrolling with fractional scaling and font hinting.
- Incorrect re-use of cached styling was fixed
- Fix some missing CSS invalidation
- Handle charsets in clipboard datatypes
* Printing:
- Avoid warnings for avahi errors
- Fix a segfault in the print dialog setup code
* Accessibility:
- Always realize non-widget accessibles, to help webkit
- Fix list view selection implementation
- Handle NULL values in more places
* Gstreamer:
- Make dmabufs works without GL
* Gdk:
- Add OKLAB and OKLCH color states
- GL: Drop support for GLES 2 and GL < 3.3
- GL: Use the ngl dmabuf downloader instead of the GL downloader
- Vulkan: Drop the GDK_VULKAN_DEVICE env var. Use MESA_VK_DEVICE_SELECT instead
- Vulkan: Use the swapchain maintenance extension to release swap images
- Forbid opening displays before gtk_init()
* Gsk:
- Many improvements to the dmabuf downloaders
- ngl: Avoid glBufferSubData for globals, speeding up llvmpipe
- Renderer selection will no longer consider the GL renderer
- Allow Vulkan software rendering as fallback
- Support gradient interpolation in different color states
* Wayland:
- Improve settings portal handling
- Improve fallback for cursor themes
- Make cursor theme changes apply immediately
- Use a viewporter for cursor image scaling
- Improve cursor size handling
- Use the system bell protocol if available
- Fix possible deadlock with high-priority sources triggering roundtrips
* Windows:
- Improve the backend code
- Fix some problems with WGL on NVidia
- Many testsuite fixes for Windows compatibility
- Make all pixbuf loaders builtin in the gdk-pixbuf subproject
- Add GDK_DISABLE=aerosnap to disable aerosnap
- Improve clipboard handling
- Fix behavior or gdk_display_open() on Windows
- Numerous papercut fixes
- Require Windows 10
* Macos:
- Fix crashes when dragging libadwaita TabView tabs
- Require macOS 10.15
* Tools and demos
- gtk4-demo: Make demos standalone
- gtk4-demo: Drop GL shader demos
- gtk4-demo: Improve scrolling benchmarks
- gtk4-builder-tool: Improve separator handling
- gtk4-image-tool: Better color state support
* Build:
- Don't set GSK_RENDERER in our flatpaks
- Require meson 1.2
* Translation updates
Belarusian
Brazilian Portuguese
British English
Galician
Lithuanian
Romanian
Slovenian
Swedish
Overview of Changes in 4.16.2, 09-25-2024
=========================================
-2
View File
@@ -579,8 +579,6 @@ released_cb (GtkGesture *gesture,
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
child = gtk_widget_pick (widget, x, y, 0);
if (!child)
return;
item = (CanvasItem *)gtk_widget_get_ancestor (child, canvas_item_get_type ());
if (!item)
return;
+4 -6
View File
@@ -12,13 +12,11 @@
static GtkWidget *window = NULL;
static gboolean
close_request_cb (GtkWidget *win, gpointer user_data)
static void
response_cb (GtkDialog *dialog, int response_id)
{
g_assert (window == win);
gtk_window_destroy ((GtkWindow *)window);
gtk_window_destroy (GTK_WINDOW (window));
window = NULL;
return TRUE;
}
static void
@@ -119,7 +117,7 @@ do_expander (GtkWidget *do_widget)
g_signal_connect (expander, "notify::expanded",
G_CALLBACK (expander_cb), window);
g_signal_connect (window, "close-request", G_CALLBACK (close_request_cb), NULL);
g_signal_connect (window, "response", G_CALLBACK (response_cb), NULL);
}
if (!gtk_widget_get_visible (window))
+1 -1
View File
@@ -811,7 +811,7 @@ tag_pair_equal (gconstpointer a, gconstpointer b)
}
static int
static GtkOrdering
script_sort (const void *item1,
const void *item2,
void *data)
+15 -15
View File
@@ -101,7 +101,7 @@ setup_centered_label (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
label = gtk_inscription_new ("");
label = gtk_label_new ("");
gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label);
}
@@ -110,8 +110,8 @@ setup_label (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
label = gtk_inscription_new ("");
gtk_inscription_set_xalign (GTK_INSCRIPTION (label), 0);
label = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label);
}
@@ -120,10 +120,10 @@ setup_ellipsizing_label (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
label = gtk_inscription_new ("");
gtk_inscription_set_xalign (GTK_INSCRIPTION (label), 0);
gtk_inscription_set_text_overflow (GTK_INSCRIPTION (label), GTK_INSCRIPTION_OVERFLOW_ELLIPSIZE_END);
gtk_inscription_set_nat_chars (GTK_INSCRIPTION (label), 20);
label = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gtk_label_set_width_chars (GTK_LABEL (label), 20);
gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label);
}
@@ -141,7 +141,7 @@ bind_codepoint (GtkSignalListItemFactory *factory,
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
g_snprintf (buffer, 10, "%#06x", codepoint);
gtk_inscription_set_text (GTK_INSCRIPTION (label), buffer);
gtk_label_set_label (GTK_LABEL (label), buffer);
}
static void
@@ -160,7 +160,7 @@ bind_char (GtkSignalListItemFactory *factory,
if (g_unichar_isprint (codepoint))
g_unichar_to_utf8 (codepoint, buffer);
gtk_inscription_set_text (GTK_INSCRIPTION (label), buffer);
gtk_label_set_label (GTK_LABEL (label), buffer);
}
static void
@@ -175,7 +175,7 @@ bind_name (GtkSignalListItemFactory *factory,
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
name = ucd_item_get_name (UCD_ITEM (item));
gtk_inscription_set_text (GTK_INSCRIPTION (label), name);
gtk_label_set_label (GTK_LABEL (label), name);
}
static void
@@ -190,7 +190,7 @@ bind_type (GtkSignalListItemFactory *factory,
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
gtk_inscription_set_text (GTK_INSCRIPTION (label), get_unicode_type_name (g_unichar_type (codepoint)));
gtk_label_set_label (GTK_LABEL (label), get_unicode_type_name (g_unichar_type (codepoint)));
}
static void
@@ -205,7 +205,7 @@ bind_break_type (GtkSignalListItemFactory *factory,
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
gtk_inscription_set_text (GTK_INSCRIPTION (label), get_break_type_name (g_unichar_break_type (codepoint)));
gtk_label_set_label (GTK_LABEL (label), get_break_type_name (g_unichar_break_type (codepoint)));
}
static void
@@ -220,7 +220,7 @@ bind_combining_class (GtkSignalListItemFactory *factory,
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
gtk_inscription_set_text (GTK_INSCRIPTION (label), get_combining_class_name (g_unichar_combining_class (codepoint)));
gtk_label_set_label (GTK_LABEL (label), get_combining_class_name (g_unichar_combining_class (codepoint)));
}
static void
@@ -237,7 +237,7 @@ bind_script (GtkSignalListItemFactory *factory,
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
script = g_unichar_get_script (codepoint);
gtk_inscription_set_text (GTK_INSCRIPTION (label), get_script_name (script));
gtk_label_set_label (GTK_LABEL (label), get_script_name (script));
}
static void
@@ -255,7 +255,7 @@ selection_changed (GObject *object,
if (g_unichar_isprint (codepoint))
g_unichar_to_utf8 (codepoint, buffer);
gtk_inscription_set_text (GTK_INSCRIPTION (label), buffer);
gtk_label_set_label (GTK_LABEL (label), buffer);
}
GtkWidget *
+2 -2
View File
@@ -1056,6 +1056,8 @@ command_line (GApplication *app,
window = gtk_application_get_windows (GTK_APPLICATION (app))->data;
gtk_window_set_icon_name (GTK_WINDOW (window), "org.gtk.Demo4");
if (name == NULL)
goto out;
@@ -1144,8 +1146,6 @@ main (int argc, char **argv)
};
int i;
gtk_init ();
app = gtk_application_new ("org.gtk.Demo4", G_APPLICATION_NON_UNIQUE|G_APPLICATION_HANDLES_COMMAND_LINE);
g_action_map_add_action_entries (G_ACTION_MAP (app),
+1 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="https://specifications.freedesktop.org/metainfo/1.0" type="desktop">
<component type="desktop">
<id>org.gtk.Demo4</id>
<launchable type="desktop-id">org.gtk.Demo4.desktop</launchable>
<metadata_license>CC0-1.0</metadata_license>
@@ -223,6 +223,8 @@ node_editor_application_activate (GApplication *app)
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (win), "devel");
gtk_window_set_icon_name (GTK_WINDOW (win), "org.gtk.gtk4.NodeEditor");
gtk_window_present (GTK_WINDOW (win));
}
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="https://specifications.freedesktop.org/metainfo/1.0" type="desktop">
<component type="desktop">
<id>org.gtk.gtk4.NodeEditor</id>
<launchable type="desktop-id">org.gtk.gtk4.NodeEditor.desktop</launchable>
<metadata_license>CC0-1.0</metadata_license>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="https://specifications.freedesktop.org/metainfo/1.0" type="desktop">
<component type="desktop">
<id>org.gtk.PrintEditor4</id>
<launchable type="desktop-id">org.gtk.PrintEditor4.desktop</launchable>
<metadata_license>CC0-1.0</metadata_license>
+1
View File
@@ -788,6 +788,7 @@ activate (GApplication *app)
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (main_window), "devel");
gtk_window_set_icon_name (GTK_WINDOW (main_window), "org.gtk.PrintEditor4");
gtk_window_set_default_size (GTK_WINDOW (main_window), 400, 600);
gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (main_window), TRUE);
update_title (GTK_WINDOW (main_window));
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="https://specifications.freedesktop.org/metainfo/1.0" type="desktop">
<component type="desktop">
<id>org.gtk.WidgetFactory4</id>
<launchable type="desktop-id">org.gtk.WidgetFactory4.desktop</launchable>
<metadata_license>CC0-1.0</metadata_license>
+1
View File
@@ -2232,6 +2232,7 @@ activate (GApplication *app)
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (window), "devel");
gtk_window_set_icon_name (window, "org.gtk.WidgetFactory4");
gtk_application_add_window (GTK_APPLICATION (app), window);
g_action_map_add_action_entries (G_ACTION_MAP (window),
win_entries, G_N_ELEMENTS (win_entries),
-3
View File
@@ -358,9 +358,6 @@ disable certain features.
`color-mgmt`
: Disable color management
`aerosnap`
: Disable Aerosnap support on Windows
### `GDK_GL_DISABLE`
This variable can be set to a list of values, which cause GDK to
-2
View File
@@ -717,8 +717,6 @@ main (int argc, char **argv)
int status;
const char *accels[] = { "F11", NULL };
gtk_init ();
bloat_pad = bloat_pad_new ();
gtk_application_set_accels_for_action (GTK_APPLICATION (bloat_pad),
+7
View File
@@ -257,6 +257,12 @@ gdk_broadway_display_flush (GdkDisplay *display)
_gdk_broadway_server_flush (broadway_display->server);
}
static gboolean
gdk_broadway_display_has_pending (GdkDisplay *display)
{
return FALSE;
}
static void
gdk_broadway_display_dispose (GObject *object)
{
@@ -479,6 +485,7 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
display_class->beep = gdk_broadway_display_beep;
display_class->sync = gdk_broadway_display_sync;
display_class->flush = gdk_broadway_display_flush;
display_class->has_pending = gdk_broadway_display_has_pending;
display_class->queue_events = _gdk_broadway_display_queue_events;
display_class->get_next_serial = gdk_broadway_display_get_next_serial;
-1
View File
@@ -158,7 +158,6 @@ static const GdkDebugKey gdk_feature_keys[] = {
{ "dmabuf", GDK_FEATURE_DMABUF, "Disable dmabuf support" },
{ "offload", GDK_FEATURE_OFFLOAD, "Disable graphics offload" },
{ "color-mgmt", GDK_FEATURE_COLOR_MANAGEMENT, "Disable color management" },
{ "aerosnap", GDK_FEATURE_AEROSNAP, "Disable Aerosnap support on Windows" },
};
-4
View File
@@ -2,8 +2,6 @@
#include "gdkcicpparams.h"
G_BEGIN_DECLS
typedef struct _GdkCicp GdkCicp;
struct _GdkCicp
@@ -84,5 +82,3 @@ gdk_cicp_equivalent (const GdkCicp *p1,
const GdkCicp * gdk_cicp_params_get_cicp (GdkCicpParams *self);
GdkCicpParams * gdk_cicp_params_new_for_cicp (const GdkCicp *cicp);
G_END_DECLS
+22
View File
@@ -0,0 +1,22 @@
/* gdkconfig.h
*
* This is a generated file. Please modify `configure.ac'
*/
#ifndef __GDKCONFIG_H__
#define __GDKCONFIG_H__
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <glib.h>
G_BEGIN_DECLS
#define GDK_WINDOWING_WIN32
G_END_DECLS
#endif /* __GDKCONFIG_H__ */
+23
View File
@@ -0,0 +1,23 @@
/* gdkconfig.h
*
* This is a generated file. Please modify `configure.ac'
*/
#ifndef __GDKCONFIG_H__
#define __GDKCONFIG_H__
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <glib.h>
G_BEGIN_DECLS
#define GDK_WINDOWING_WIN32
#define GDK_RENDERING_VULKAN
G_END_DECLS
#endif /* __GDKCONFIG_H__ */
+3 -3
View File
@@ -124,7 +124,7 @@ gdk_content_provider_new_for_value (const GValue *value)
content = g_object_new (GDK_TYPE_CONTENT_PROVIDER_VALUE, NULL);
g_value_init (&content->value, G_VALUE_TYPE (value));
g_value_copy (value, &content->value);
return GDK_CONTENT_PROVIDER (content);
}
@@ -409,7 +409,7 @@ gdk_content_provider_union_init (GdkContentProviderUnion *self)
* ```c
* gdk_content_provider_new_union ((GdkContentProvider *[2]) {
* gdk_content_provider_new_typed (G_TYPE_FILE, file),
* gdk_content_provider_new_typed (GDK_TYPE_TEXTURE, texture)
* gdk_content_provider_new_typed (G_TYPE_TEXTURE, texture)
* }, 2);
* ```
*
@@ -594,7 +594,7 @@ gdk_content_provider_new_for_bytes (const char *mime_type,
content = g_object_new (GDK_TYPE_CONTENT_PROVIDER_BYTES, NULL);
content->mime_type = g_intern_string (mime_type);
content->bytes = g_bytes_ref (bytes);
return GDK_CONTENT_PROVIDER (content);
}
-2
View File
@@ -64,7 +64,6 @@ typedef enum {
GDK_FEATURE_DMABUF = 1 << 7,
GDK_FEATURE_OFFLOAD = 1 << 8,
GDK_FEATURE_COLOR_MANAGEMENT = 1 << 9,
GDK_FEATURE_AEROSNAP = 1 << 10,
} GdkFeatures;
#define GDK_ALL_FEATURES ((1 << 10) - 1)
@@ -120,4 +119,3 @@ guint gdk_parse_debug_var (const char *variable,
const GdkDebugKey *keys,
guint nkeys);
G_END_DECLS
+5 -51
View File
@@ -438,10 +438,11 @@ gdk_display_dispose (GObject *object)
g_clear_pointer (&display->egl_dmabuf_formats, gdk_dmabuf_formats_unref);
g_clear_pointer (&display->egl_internal_formats, gdk_dmabuf_formats_unref);
#ifdef GDK_RENDERING_VULKAN
if (display->vk_instance)
gdk_display_destroy_vulkan_instance (display);
g_assert (display->vk_dmabuf_formats == NULL);
g_clear_error (&display->vulkan_error);
if (display->vk_dmabuf_formats)
{
gdk_display_unref_vulkan (display);
g_assert (display->vk_dmabuf_formats == NULL);
}
#endif
g_clear_object (&priv->gl_context);
@@ -1285,53 +1286,6 @@ gdk_display_get_keymap (GdkDisplay *display)
return GDK_DISPLAY_GET_CLASS (display)->get_keymap (display);
}
/*< private >
* gdk_display_prepare_vulkan:
* @self: a `GdkDisplay`
* @error: return location for a `GError`
*
* Checks that Vulkan is available for @self and ensures that it is
* properly initialized.
*
* When this fails, an @error will be set describing the error and this
* function returns %FALSE.
*
* Note that even if this function succeeds, creating a `GdkVulkanContext`
* may still fail.
*
* This function is idempotent. Calling it multiple times will just
* return the same value or error.
*
* You never need to call this function, GDK will call it automatically
* as needed.
*
* Returns: %TRUE if the display supports Vulkan
*/
gboolean
gdk_display_prepare_vulkan (GdkDisplay *self,
GError **error)
{
g_return_val_if_fail (GDK_IS_DISPLAY (self), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
#ifdef GDK_RENDERING_VULKAN
if (!self->vk_instance && !self->vulkan_error)
gdk_display_create_vulkan_instance (self, &self->vulkan_error);
if (self->vk_instance == NULL)
{
if (error)
*error = g_error_copy (self->vulkan_error);
}
return self->vk_instance != NULL;
#else
g_set_error (error, GDK_VULKAN_ERROR, GDK_VULKAN_ERROR_UNSUPPORTED,
"GTK was built without Vulkan support");
return FALSE;
#endif
}
/*<private>
* gdk_display_create_vulkan_context:
* @self: a `GdkDisplay`
+1 -2
View File
@@ -332,8 +332,7 @@ gdk_display_manager_get_default_display (GdkDisplayManager *manager)
GdkDisplay *
gdk_display_get_default (void)
{
if (!gdk_is_initialized ())
return NULL;
gdk_ensure_initialized ();
return gdk_display_manager_get_default_display (gdk_display_manager_get ());
}
+2 -9
View File
@@ -51,12 +51,6 @@ typedef enum {
GDK_VULKAN_FEATURE_SWAPCHAIN_MAINTENANCE = 1 << 5,
} GdkVulkanFeatures;
#define GDK_VULKAN_N_FEATURES 6
#ifdef GDK_RENDERING_VULKAN
extern const GdkDebugKey gdk_vulkan_feature_keys[];
#endif
/* Tracks information about the device grab on this display */
typedef struct
{
@@ -126,7 +120,7 @@ struct _GdkDisplay
GdkDmabufFormats *vk_dmabuf_formats;
GdkVulkanFeatures vulkan_features;
GError *vulkan_error;
guint vulkan_refcount;
#endif /* GDK_RENDERING_VULKAN */
/* egl info */
@@ -160,6 +154,7 @@ struct _GdkDisplayClass
void (*beep) (GdkDisplay *display);
void (*sync) (GdkDisplay *display);
void (*flush) (GdkDisplay *display);
gboolean (*has_pending) (GdkDisplay *display);
void (*queue_events) (GdkDisplay *display);
void (*make_default) (GdkDisplay *display);
@@ -239,8 +234,6 @@ void _gdk_display_unpause_events (GdkDisplay *display
void gdk_display_init_dmabuf (GdkDisplay *self);
gboolean gdk_display_prepare_vulkan (GdkDisplay *self,
GError **error);
gboolean gdk_display_has_vulkan_feature (GdkDisplay *self,
GdkVulkanFeatures feature);
GdkVulkanContext * gdk_display_create_vulkan_context (GdkDisplay *self,
+6 -6
View File
@@ -375,7 +375,7 @@ gdk_dmabuf_texture_builder_class_init (GdkDmabufTextureBuilderClass *klass)
/**
* GdkDmabufTextureBuilder:update-region:
*
* The update region for [property@Gdk.DmabufTextureBuilder:update-texture].
* The update region for [property@Gdk.GLTextureBuilder:update-texture].
*
* Since: 4.14
*/
@@ -496,7 +496,7 @@ gdk_dmabuf_texture_builder_get_width (GdkDmabufTextureBuilder *self)
*
* Sets the width of the texture.
*
* The width must be set before calling [method@Gdk.DmabufTextureBuilder.build].
* The width must be set before calling [method@Gdk.GLTextureBuilder.build].
*
* Since: 4.14
*/
@@ -540,7 +540,7 @@ gdk_dmabuf_texture_builder_get_height (GdkDmabufTextureBuilder *self)
*
* Sets the height of the texture.
*
* The height must be set before calling [method@Gdk.DmabufTextureBuilder.build].
* The height must be set before calling [method@Gdk.GLTextureBuilder.build].
*
* Since: 4.14
*/
@@ -588,7 +588,7 @@ gdk_dmabuf_texture_builder_get_fourcc (GdkDmabufTextureBuilder *self)
*
* The format is specified as a fourcc code.
*
* The format must be set before calling [method@Gdk.DmabufTextureBuilder.build].
* The format must be set before calling [method@Gdk.GLTextureBuilder.build].
*
* Since: 4.14
*/
@@ -807,7 +807,7 @@ gdk_dmabuf_texture_builder_get_stride (GdkDmabufTextureBuilder *self,
*
* Sets the stride for a plane.
*
* The stride must be set for all planes before calling [method@Gdk.DmabufTextureBuilder.build].
* The stride must be set for all planes before calling [method@Gdk.GLTextureBuilder.build].
*
* Since: 4.14
*/
@@ -876,7 +876,7 @@ gdk_dmabuf_texture_builder_set_offset (GdkDmabufTextureBuilder *self,
*
* Gets the color state previously set via gdk_dmabuf_texture_builder_set_color_state().
*
* Returns: (nullable) (transfer none): the color state
* Returns: (nullable): the color state
*
* Since: 4.16
*/
+6 -6
View File
@@ -87,12 +87,12 @@ typedef enum
/**
* GdkModifierType:
* @GDK_SHIFT_MASK: the Shift key.
* @GDK_LOCK_MASK: a Lock key (depending on the Windowing System configuration,
* this may either be <kbd>CapsLock</kbd> or <kbd>ShiftLock</kbd>).
* @GDK_LOCK_MASK: a Lock key (depending on the modifier mapping of the
* X server this may either be CapsLock or ShiftLock).
* @GDK_CONTROL_MASK: the Control key.
* @GDK_ALT_MASK: the fourth modifier key (it depends on the Windowing System
* configuration which key is interpreted as this modifier, but normally it
* is the <kbd>Alt</kbd> key).
* @GDK_ALT_MASK: the fourth modifier key (it depends on the modifier
* mapping of the X server which key is interpreted as this modifier, but
* normally it is the Alt key).
* @GDK_BUTTON1_MASK: the first mouse button.
* @GDK_BUTTON2_MASK: the second mouse button.
* @GDK_BUTTON3_MASK: the third mouse button.
@@ -109,7 +109,7 @@ typedef enum
* Apple, CapsLock or ShiftLock.
*
* Note that GDK may add internal values to events which include values outside
* of this enumeration. Your code should preserve and ignore them. You can use
* of this enumeration. Your code should preserve and ignore them. You can use
* %GDK_MODIFIER_MASK to remove all private values.
*/
typedef enum
+1 -1
View File
@@ -103,7 +103,7 @@
#define DEFAULT_ALLOWED_APIS GDK_GL_API_GL | GDK_GL_API_GLES
const GdkDebugKey gdk_gl_feature_keys[] = {
static const GdkDebugKey gdk_gl_feature_keys[] = {
{ "debug", GDK_GL_FEATURE_DEBUG, "GL_KHR_debug" },
{ "base-instance", GDK_GL_FEATURE_BASE_INSTANCE, "GL_ARB_base_instance" },
{ "buffer-storage", GDK_GL_FEATURE_BUFFER_STORAGE, "GL_EXT_buffer_storage" },
-5
View File
@@ -24,7 +24,6 @@
#include "gdkdrawcontextprivate.h"
#include "gdkglversionprivate.h"
#include "gdkdmabufprivate.h"
#include "gdkdebugprivate.h"
G_BEGIN_DECLS
@@ -34,10 +33,6 @@ typedef enum {
GDK_GL_FEATURE_BUFFER_STORAGE = 1 << 2,
} GdkGLFeatures;
#define GDK_GL_N_FEATURES 3
extern const GdkDebugKey gdk_gl_feature_keys[];
typedef enum {
GDK_GL_NONE = 0,
GDK_GL_EGL,
+1 -1
View File
@@ -647,7 +647,7 @@ gdk_gl_texture_builder_set_sync (GdkGLTextureBuilder *self,
*
* Gets the color state previously set via gdk_gl_texture_builder_set_color_state().
*
* Returns: (transfer none): the color state
* Returns: the color state
*
* Since: 4.16
*/
-5
View File
@@ -22,11 +22,6 @@
#include "gdkenums.h"
#include "gdktypes.h"
/* epoxy needs this, see https://github.com/anholt/libepoxy/issues/299 */
#ifdef GDK_WINDOWING_WIN32
#include <windows.h>
#endif
#include <epoxy/gl.h>
#ifdef GDK_RENDERING_VULKAN
-1
View File
@@ -2940,7 +2940,6 @@ check_autohide (GdkEvent *event)
{
event_surface = gdk_event_get_surface (event);
if (event_surface->autohide &&
evtype != GDK_TOUCH_BEGIN &&
!event_surface->has_pointer)
event_surface = NULL;
+69 -12
View File
@@ -35,7 +35,7 @@
#include <math.h>
#ifdef GDK_RENDERING_VULKAN
const GdkDebugKey gdk_vulkan_feature_keys[] = {
static const GdkDebugKey gdk_vulkan_feature_keys[] = {
{ "dmabuf", GDK_VULKAN_FEATURE_DMABUF, "Never import Dmabufs" },
{ "ycbcr", GDK_VULKAN_FEATURE_YCBCR, "Do not support Ycbcr textures (also disables dmabufs)" },
{ "semaphore-export", GDK_VULKAN_FEATURE_SEMAPHORE_EXPORT, "Disable sync of exported dmabufs" },
@@ -367,6 +367,7 @@ gdk_vulkan_context_dispose (GObject *gobject)
{
GdkVulkanContext *context = GDK_VULKAN_CONTEXT (gobject);
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
GdkDisplay *display;
VkDevice device;
guint i;
@@ -396,6 +397,11 @@ gdk_vulkan_context_dispose (GObject *gobject)
priv->surface = VK_NULL_HANDLE;
}
/* display will be unset in gdk_draw_context_dispose() */
display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
if (display && priv->vulkan_ref)
gdk_display_unref_vulkan (display);
G_OBJECT_CLASS (gdk_vulkan_context_parent_class)->dispose (gobject);
}
@@ -881,7 +887,8 @@ gdk_vulkan_context_real_init (GInitable *initable,
VkBool32 supported;
uint32_t i;
if (!gdk_display_prepare_vulkan (display, error))
priv->vulkan_ref = gdk_display_init_vulkan (display, error);
if (!priv->vulkan_ref)
return FALSE;
if (surface == NULL)
@@ -1661,7 +1668,7 @@ gdk_vulkan_debug_report (VkDebugReportFlagsEXT flags,
return VK_FALSE;
}
gboolean
static gboolean
gdk_display_create_vulkan_instance (GdkDisplay *display,
GError **error)
{
@@ -1671,8 +1678,6 @@ gdk_display_create_vulkan_instance (GdkDisplay *display,
gboolean have_debug_report = FALSE;
VkResult res;
g_assert (display->vk_instance == NULL);
if (!gdk_has_feature (GDK_FEATURE_VULKAN))
{
g_set_error_literal (error, GDK_VULKAN_ERROR, GDK_VULKAN_ERROR_NOT_AVAILABLE,
@@ -1799,16 +1804,66 @@ gdk_display_create_vulkan_instance (GdkDisplay *display,
return TRUE;
}
/*
* gdk_display_init_vulkan:
* @display: a display
* @error: A potential error message
*
* Initializes Vulkan and returns an error on failure.
*
* If Vulkan is already initialized, this function returns
* %TRUE and increases the refcount of the existing instance.
*
* You need to gdk_display_unref_vulkan() to close it again.
*
* Returns: %TRUE if Vulkan is initialized.
**/
gboolean
gdk_display_init_vulkan (GdkDisplay *display,
GError **error)
{
if (display->vulkan_refcount == 0)
{
if (!gdk_display_create_vulkan_instance (display, error))
return FALSE;
}
display->vulkan_refcount++;
return TRUE;
}
/*
* gdk_display_ref_vulkan:
* @display: a GdkDisplay
*
* Increases the refcount of an existing Vulkan instance.
*
* This function must not be called if Vulkan may not be initialized
* yet, call gdk_display_init_vulkan() in that case.
**/
void
gdk_display_destroy_vulkan_instance (GdkDisplay *display)
gdk_display_ref_vulkan (GdkDisplay *display)
{
g_assert (display->vulkan_refcount > 0);
display->vulkan_refcount++;
}
void
gdk_display_unref_vulkan (GdkDisplay *display)
{
GHashTableIter iter;
gpointer key, value;
g_assert (GDK_IS_DISPLAY (display));
g_assert (display->vk_instance != NULL);
g_return_if_fail (GDK_IS_DISPLAY (display));
g_return_if_fail (display->vulkan_refcount > 0);
GDK_DEBUG (VULKAN, "Destroy Vulkan instance");
display->vulkan_refcount--;
if (display->vulkan_refcount > 0)
return;
GDK_DEBUG (VULKAN, "Closing Vulkan instance");
display->vulkan_features = 0;
g_clear_pointer (&display->vk_dmabuf_formats, gdk_dmabuf_formats_unref);
g_hash_table_iter_init (&iter, display->vk_shader_modules);
@@ -1886,9 +1941,11 @@ gdk_vulkan_init_dmabuf (GdkDisplay *display)
return;
if (!gdk_has_feature (GDK_FEATURE_DMABUF) ||
!gdk_display_prepare_vulkan (display, NULL) ||
(display->vulkan_features & GDK_VULKAN_FEATURE_DMABUF) == 0)
return;
!gdk_display_init_vulkan (display, NULL) ||
((display->vulkan_features & GDK_VULKAN_FEATURE_DMABUF) == 0))
{
return;
}
vulkan_builder = gdk_dmabuf_formats_builder_new ();
+4 -2
View File
@@ -73,9 +73,10 @@ gdk_vulkan_handle_result (VkResult res,
#define GDK_VK_CHECK(func, ...) gdk_vulkan_handle_result (func (__VA_ARGS__), G_STRINGIFY (func))
gboolean gdk_display_create_vulkan_instance (GdkDisplay *display,
gboolean gdk_display_init_vulkan (GdkDisplay *display,
GError **error);
void gdk_display_destroy_vulkan_instance (GdkDisplay *display);
void gdk_display_ref_vulkan (GdkDisplay *display);
void gdk_display_unref_vulkan (GdkDisplay *display);
void gdk_vulkan_init_dmabuf (GdkDisplay *display);
@@ -116,3 +117,4 @@ gdk_display_ref_vulkan (GdkDisplay *display,
#endif /* !GDK_RENDERING_VULKAN */
G_END_DECLS
-10
View File
@@ -42,12 +42,6 @@
#define siglongjmp longjmp
#endif
#define JPEG_MEM_DEST_USES_SIZE_T \
(!(LIBJPEG_TURBO_VERSION_NUMBER) && \
(((JPEG_LIB_VERSION) > 90) || \
((JPEG_LIB_VERSION) == 90 && (JPEG_LIB_VERSION_MAJOR) > 9) || \
((JPEG_LIB_VERSION) == 90 && (JPEG_LIB_VERSION_MAJOR) == 9 && (JPEG_LIB_VERSION_MINOR) > 3)))
struct error_handler_data {
struct jpeg_error_mgr pub;
sigjmp_buf setjmp_buffer;
@@ -237,11 +231,7 @@ gdk_save_jpeg (GdkTexture *texture)
struct error_handler_data jerr;
struct jpeg_error_mgr err;
guchar *data = NULL;
#if JPEG_MEM_DEST_USES_SIZE_T
gsize size = 0;
#else
gulong size = 0;
#endif
guchar *input = NULL;
GdkTextureDownloader downloader;
GBytes *texbytes = NULL;
+4
View File
@@ -42,6 +42,10 @@
#include "gdkmonitorprivate.h"
#include "gdksurfaceprivate.h"
#ifndef AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER
typedef NSString *CALayerContentsGravity;
#endif
@implementation GdkMacosWindow
-(BOOL)windowShouldClose:(id)sender
+8
View File
@@ -270,6 +270,13 @@ gdk_macos_display_get_next_serial (GdkDisplay *display)
return ++serial;
}
static gboolean
gdk_macos_display_has_pending (GdkDisplay *display)
{
return _gdk_event_queue_find_first (display) ||
_gdk_macos_event_source_check_pending ();
}
static void
gdk_macos_display_notify_startup_complete (GdkDisplay *display,
const char *startup_notification_id)
@@ -604,6 +611,7 @@ gdk_macos_display_class_init (GdkMacosDisplayClass *klass)
display_class->get_next_serial = gdk_macos_display_get_next_serial;
display_class->get_name = gdk_macos_display_get_name;
display_class->get_setting = gdk_macos_display_get_setting;
display_class->has_pending = gdk_macos_display_has_pending;
display_class->init_gl = gdk_macos_display_init_gl;
display_class->notify_startup_complete = gdk_macos_display_notify_startup_complete;
display_class->queue_events = gdk_macos_display_queue_events;
+4
View File
@@ -163,6 +163,7 @@ GetSubpixelLayout (CGDirectDisplayID screen_id)
char *
_gdk_macos_monitor_get_localized_name (NSScreen *screen)
{
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER
GDK_BEGIN_MACOS_ALLOC_POOL;
NSString *str;
@@ -176,6 +177,9 @@ _gdk_macos_monitor_get_localized_name (NSScreen *screen)
GDK_END_MACOS_ALLOC_POOL;
return g_steal_pointer (&name);
#else
return NULL;
#endif
}
char *
+4
View File
@@ -26,6 +26,10 @@
G_BEGIN_DECLS
#ifndef AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER
typedef NSString *NSPasteboardType;
#endif
@interface GdkMacosPasteboardItemDataProvider : NSObject <NSPasteboardItemDataProvider>
{
GdkContentProvider *_contentProvider;
+5
View File
@@ -59,8 +59,13 @@ get_pasteboard_type (int type)
pasteboard_types[TYPE_PBOARD] = NSStringPboardType;
G_GNUC_END_IGNORE_DEPRECATIONS
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER
pasteboard_types[TYPE_URL] = NSPasteboardTypeURL;
pasteboard_types[TYPE_FILE_URL] = NSPasteboardTypeFileURL;
#else
pasteboard_types[TYPE_URL] = [[NSString alloc] initWithUTF8String:"public.url"];
pasteboard_types[TYPE_FILE_URL] = [[NSString alloc] initWithUTF8String:"public.file-url"];
#endif
g_once_init_leave (&initialized, TRUE);
}
+18
View File
@@ -43,13 +43,31 @@ static inline NSPoint
convert_nspoint_from_screen (NSWindow *window,
NSPoint point)
{
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER
return [window convertPointFromScreen:point];
#else
/* Apple documentation claims that convertPointFromScreen is available
* on 10.12+. However, that doesn't seem to be the case when using it.
* Instead, we'll just use it on modern 10.15 systems and fallback to
* converting using rects on older systems.
*/
return [window convertRectFromScreen:NSMakeRect (point.x, point.y, 0, 0)].origin;
#endif
}
static inline NSPoint
convert_nspoint_to_screen (NSWindow *window,
NSPoint point)
{
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER
return [window convertPointToScreen:point];
#else
/* Apple documentation claims that convertPointToScreen is available
* on 10.12+. However, that doesn't seem to be the case when using it.
* Instead, we'll just use it on modern 10.15 systems and fallback to
* converting using rects on older systems.
*/
return [window convertRectToScreen:NSMakeRect (point.x, point.y, 0, 0)].origin;
#endif
}
+15 -3
View File
@@ -630,7 +630,7 @@ _gdk_wayland_display_open (const char *display_name)
display = g_object_new (GDK_TYPE_WAYLAND_DISPLAY, NULL);
display_wayland = GDK_WAYLAND_DISPLAY (display);
display_wayland->wl_display = wl_display;
gdk_wayland_display_install_gsources (display_wayland);
display_wayland->event_source = _gdk_wayland_display_event_source_new (display);
init_settings (display);
@@ -731,7 +731,12 @@ gdk_wayland_display_dispose (GObject *object)
g_list_free_full (display_wayland->toplevels, destroy_toplevel);
gdk_wayland_display_uninstall_gsources (display_wayland);
if (display_wayland->event_source)
{
g_source_destroy (display_wayland->event_source);
g_source_unref (display_wayland->event_source);
display_wayland->event_source = NULL;
}
g_list_free_full (display_wayland->async_roundtrips, (GDestroyNotify) wl_callback_destroy);
@@ -896,6 +901,12 @@ gdk_wayland_display_make_default (GdkDisplay *display)
display_wayland->startup_notification_id = g_strdup (startup_id);
}
static gboolean
gdk_wayland_display_has_pending (GdkDisplay *display)
{
return FALSE;
}
static gulong
gdk_wayland_display_get_next_serial (GdkDisplay *display)
{
@@ -1062,6 +1073,7 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
display_class->sync = gdk_wayland_display_sync;
display_class->flush = gdk_wayland_display_flush;
display_class->make_default = gdk_wayland_display_make_default;
display_class->has_pending = gdk_wayland_display_has_pending;
display_class->queue_events = _gdk_wayland_display_queue_events;
display_class->get_app_launch_context = _gdk_wayland_display_get_app_launch_context;
display_class->get_next_serial = gdk_wayland_display_get_next_serial;
@@ -2032,7 +2044,7 @@ init_settings (GdkDisplay *display)
if (entry)
{
char *a = g_variant_print (v, FALSE);
g_debug ("Using portal setting for %s %s: %s", schema_str, key, a);
g_debug ("Using portal setting for %s %s: %s\n", schema_str, key, a);
g_free (a);
entry->valid = TRUE;
apply_portal_setting (entry, v, display);
-1
View File
@@ -148,7 +148,6 @@ struct _GdkWaylandDisplay
GHashTable *cursor_surface_cache;
GSource *event_source;
GSource *poll_source;
uint32_t server_decoration_mode;
+81 -173
View File
@@ -24,119 +24,44 @@
#include <unistd.h>
#include <errno.h>
typedef struct _GdkWaylandEventSource GdkWaylandEventSource;
typedef struct _GdkWaylandPollSource GdkWaylandPollSource;
struct _GdkWaylandEventSource
{
GSource source;
GdkWaylandDisplay *display;
};
struct _GdkWaylandPollSource
{
typedef struct _GdkWaylandEventSource {
GSource source;
GPollFD pfd;
GdkWaylandDisplay *display;
guint reading : 1;
guint can_dispatch : 1;
};
/* If we should try wl_display_dispatch_pending() before
* polling the Wayland fd
*/
static gboolean
gdk_wayland_display_can_dispatch (GdkWaylandDisplay *display_wayland)
{
GdkWaylandPollSource *poll_source = (GdkWaylandPollSource *) display_wayland->poll_source;
return poll_source->can_dispatch;
}
/* If we still have events to process and don't need to poll */
static gboolean
gdk_wayland_display_has_events_pending (GdkWaylandDisplay *display_wayland)
{
return gdk_wayland_display_can_dispatch (display_wayland) ||
_gdk_event_queue_find_first (GDK_DISPLAY (display_wayland)) != NULL;
}
uint32_t mask;
GdkDisplay *display;
gboolean reading;
} GdkWaylandEventSource;
static gboolean
gdk_wayland_event_source_prepare (GSource *base,
int *timeout)
gdk_event_source_prepare (GSource *base,
int *timeout)
{
GdkWaylandEventSource *source = (GdkWaylandEventSource *) base;
*timeout = -1;
return gdk_wayland_display_has_events_pending (source->display);
}
static gboolean
gdk_wayland_event_source_check (GSource *base)
{
GdkWaylandEventSource *source = (GdkWaylandEventSource *) base;
return gdk_wayland_display_has_events_pending (source->display);
}
static gboolean
gdk_wayland_event_source_dispatch (GSource *base,
GSourceFunc callback,
gpointer data)
{
GdkWaylandEventSource *source = (GdkWaylandEventSource *) base;
GdkEvent *event;
event = gdk_display_get_event (GDK_DISPLAY (source->display));
if (event)
{
_gdk_event_emit (event);
gdk_event_unref (event);
}
return G_SOURCE_CONTINUE;
}
static void
gdk_wayland_event_source_finalize (GSource *base)
{
}
static GSourceFuncs gdk_wayland_event_source_funcs = {
gdk_wayland_event_source_prepare,
gdk_wayland_event_source_check,
gdk_wayland_event_source_dispatch,
gdk_wayland_event_source_finalize
};
static gboolean
gdk_wayland_poll_source_prepare (GSource *base,
int *timeout)
{
GdkWaylandPollSource *source = (GdkWaylandPollSource *) base;
GdkWaylandDisplay *display = (GdkWaylandDisplay *) source->display;
GList *l;
*timeout = -1;
if (gdk_wayland_display_has_events_pending (source->display))
return FALSE;
if (source->display->event_pause_count > 0)
return _gdk_event_queue_find_first (source->display) != NULL;
/* We have to add/remove the GPollFD if we want to update our
* poll event mask dynamically. Instead, let's just flush all
* write on idle instead, which is what this amounts to.
*/
if (_gdk_event_queue_find_first (source->display) != NULL)
return TRUE;
/* wl_display_prepare_read() needs to be balanced with either
* wl_display_read_events() or wl_display_cancel_read()
* (in gdk_wayland_event_source_check() */
* (in gdk_event_source_check() */
if (source->reading)
return FALSE;
/* if prepare_read() returns non-zero, there are events to be dispatched */
if (wl_display_prepare_read (display->wl_display) != 0)
{
source->can_dispatch = TRUE;
return TRUE;
}
return TRUE;
/* We need to check whether there are pending events on the surface queues as well,
* but we also need to make sure to only have one active "read" in the end,
@@ -149,8 +74,6 @@ gdk_wayland_poll_source_prepare (GSource *base,
if (wl_display_prepare_read_queue (display->wl_display, queue) != 0)
{
source->can_dispatch = TRUE;
/* cancel the read from before the for loop */
wl_display_cancel_read (display->wl_display);
return TRUE;
}
@@ -169,19 +92,23 @@ gdk_wayland_poll_source_prepare (GSource *base,
}
static gboolean
gdk_wayland_poll_source_check (GSource *base)
gdk_event_source_check (GSource *base)
{
GdkWaylandPollSource *source = (GdkWaylandPollSource *) base;
GdkWaylandEventSource *source = (GdkWaylandEventSource *) base;
GdkWaylandDisplay *display_wayland = (GdkWaylandDisplay *) source->display;
if (source->display->event_pause_count > 0)
{
if (source->reading)
wl_display_cancel_read (display_wayland->wl_display);
source->reading = FALSE;
return _gdk_event_queue_find_first (source->display) != NULL;
}
/* read the events from the wayland fd into their respective queues if we have data */
if (source->reading)
{
if (source->pfd.revents & (G_IO_ERR | G_IO_HUP))
{
g_message ("Lost connection to Wayland compositor.");
_exit (1);
}
if (source->pfd.revents & G_IO_IN)
{
if (wl_display_read_events (display_wayland->wl_display) < 0)
@@ -189,40 +116,53 @@ gdk_wayland_poll_source_check (GSource *base)
g_message ("Error reading events from display: %s", g_strerror (errno));
_exit (1);
}
source->pfd.revents = 0;
source->can_dispatch = TRUE;
}
else
wl_display_cancel_read (display_wayland->wl_display);
source->reading = FALSE;
}
return FALSE;
return _gdk_event_queue_find_first (source->display) != NULL ||
source->pfd.revents;
}
static gboolean
gdk_wayland_poll_source_dispatch (GSource *base,
GSourceFunc callback,
gpointer data)
gdk_event_source_dispatch (GSource *base,
GSourceFunc callback,
gpointer data)
{
return G_SOURCE_CONTINUE;
GdkWaylandEventSource *source = (GdkWaylandEventSource *) base;
GdkDisplay *display = source->display;
GdkEvent *event;
event = gdk_display_get_event (display);
if (event)
{
_gdk_event_emit (event);
gdk_event_unref (event);
}
return TRUE;
}
static void
gdk_wayland_poll_source_finalize (GSource *base)
gdk_event_source_finalize (GSource *base)
{
GdkWaylandPollSource *source = (GdkWaylandPollSource *) base;
GdkWaylandEventSource *source = (GdkWaylandEventSource *) base;
GdkWaylandDisplay *display = (GdkWaylandDisplay *) source->display;
if (source->reading)
wl_display_cancel_read (source->display->wl_display);
wl_display_cancel_read (display->wl_display);
source->reading = FALSE;
}
static GSourceFuncs gdk_wayland_poll_source_funcs = {
gdk_wayland_poll_source_prepare,
gdk_wayland_poll_source_check,
gdk_wayland_poll_source_dispatch,
gdk_wayland_poll_source_finalize
static GSourceFuncs wl_glib_source_funcs = {
gdk_event_source_prepare,
gdk_event_source_check,
gdk_event_source_dispatch,
gdk_event_source_finalize
};
void
@@ -236,81 +176,45 @@ _gdk_wayland_display_deliver_event (GdkDisplay *display,
_gdk_display_get_next_serial (display));
}
void
gdk_wayland_display_install_gsources (GdkWaylandDisplay *display_wayland)
GSource *
_gdk_wayland_display_event_source_new (GdkDisplay *display)
{
GdkDisplay *display = GDK_DISPLAY (display_wayland);
GSource *source;
GdkWaylandEventSource *event_source;
GdkWaylandPollSource *poll_source;
GdkWaylandEventSource *wl_source;
GdkWaylandDisplay *display_wayland;
char *name;
/* SOURCE 1 */
source = g_source_new (&gdk_wayland_event_source_funcs,
source = g_source_new (&wl_glib_source_funcs,
sizeof (GdkWaylandEventSource));
display_wayland->event_source = source;
event_source = (GdkWaylandEventSource *) source;
name = g_strdup_printf ("GDK Wayland Event source (%s)",
gdk_display_get_name (display));
g_source_set_name (source, name);
g_free (name);
wl_source = (GdkWaylandEventSource *) source;
event_source->display = display_wayland;
display_wayland = GDK_WAYLAND_DISPLAY (display);
wl_source->display = display;
wl_source->pfd.fd = wl_display_get_fd (display_wayland->wl_display);
wl_source->pfd.events = G_IO_IN | G_IO_ERR | G_IO_HUP;
g_source_add_poll (source, &wl_source->pfd);
g_source_set_priority (source, GDK_PRIORITY_EVENTS);
g_source_set_can_recurse (source, TRUE);
g_source_attach (source, NULL);
/* SOURCE 2 */
source = g_source_new (&gdk_wayland_poll_source_funcs,
sizeof (GdkWaylandPollSource));
display_wayland->poll_source = source;
poll_source = (GdkWaylandPollSource *) source;
name = g_strdup_printf ("GDK Wayland Poll source (%s)",
gdk_display_get_name (display));
g_source_set_name (source, name);
g_free (name);
poll_source->display = display_wayland;
poll_source->pfd.fd = wl_display_get_fd (display_wayland->wl_display);
poll_source->pfd.events = G_IO_IN | G_IO_ERR | G_IO_HUP;
g_source_add_poll (source, &poll_source->pfd);
/* We must guarantee to ALWAYS be called and called FIRST after
* every poll - or rather: after every prepare().
* Any other source might call Wayland functions and in turn
* block while waiting for us.
* And GSource has no after_pool() vfunc, check() is not guaranteed
* to be called.
*/
g_source_set_priority (source, G_MININT);
g_source_attach (source, NULL);
}
void
gdk_wayland_display_uninstall_gsources (GdkWaylandDisplay *display_wayland)
{
if (display_wayland->event_source)
{
g_source_destroy (display_wayland->event_source);
g_source_unref (display_wayland->event_source);
display_wayland->event_source = NULL;
}
if (display_wayland->poll_source)
{
g_source_destroy (display_wayland->poll_source);
g_source_unref (display_wayland->poll_source);
display_wayland->poll_source = NULL;
}
return source;
}
void
_gdk_wayland_display_queue_events (GdkDisplay *display)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
GdkWaylandPollSource *poll_source;
GdkWaylandDisplay *display_wayland;
GdkWaylandEventSource *source;
GList *l;
display_wayland = GDK_WAYLAND_DISPLAY (display);
source = (GdkWaylandEventSource *) display_wayland->event_source;
if (wl_display_dispatch_pending (display_wayland->wl_display) < 0)
{
g_message ("Error %d (%s) dispatching to Wayland display.",
@@ -330,6 +234,10 @@ _gdk_wayland_display_queue_events (GdkDisplay *display)
}
}
poll_source = (GdkWaylandPollSource *) display_wayland->poll_source;
poll_source->can_dispatch = FALSE;
if (source->pfd.revents & (G_IO_ERR | G_IO_HUP))
{
g_message ("Lost connection to Wayland compositor.");
_exit (1);
}
source->pfd.revents = 0;
}
+1 -2
View File
@@ -183,8 +183,7 @@ void gdk_wayland_device_unset_touch_grab (GdkDevice *device,
GdkEventSequence *sequence);
void _gdk_wayland_display_deliver_event (GdkDisplay *display, GdkEvent *event);
void gdk_wayland_display_install_gsources (GdkWaylandDisplay *display_wayland);
void gdk_wayland_display_uninstall_gsources (GdkWaylandDisplay *display_wayland);
GSource *_gdk_wayland_display_event_source_new (GdkDisplay *display);
void _gdk_wayland_display_queue_events (GdkDisplay *display);
GdkAppLaunchContext *_gdk_wayland_display_get_app_launch_context (GdkDisplay *display);
-4
View File
@@ -928,10 +928,6 @@ preferred_changed (GdkWaylandColorSurface *color,
{
GdkWaylandSurface *self = GDK_WAYLAND_SURFACE (data);
GDK_DISPLAY_DEBUG (gdk_surface_get_display (GDK_SURFACE (self)), EVENTS,
"preferred color state, surface %p color state %s",
self, gdk_color_state_get_name (color_state));
gdk_surface_set_color_state (GDK_SURFACE (self), color_state);
self->color_state_changed = TRUE;
+35 -11
View File
@@ -62,13 +62,12 @@ gdk_win32_clipboard_request_contentformats (GdkWin32Clipboard *cb)
UINT w32_formats_len = 0;
UINT w32_formats_allocated;
gsize i;
GdkContentFormatsBuilder *builder;
GdkContentFormats *formats;
GArray *formatpairs;
GdkWin32Clipdrop *clipdrop = gdk_win32_clipboard_get_clipdrop (GDK_CLIPBOARD (cb));
DWORD error_code;
SetLastError (0);
success = GetUpdatedClipboardFormats (NULL, 0, &w32_formats_allocated);
success = clipdrop->GetUpdatedClipboardFormats (NULL, 0, &w32_formats_allocated);
error_code = GetLastError ();
if (!success && error_code != ERROR_INSUFFICIENT_BUFFER)
@@ -80,7 +79,7 @@ gdk_win32_clipboard_request_contentformats (GdkWin32Clipboard *cb)
w32_formats = g_new0 (UINT, w32_formats_allocated);
SetLastError (0);
success = GetUpdatedClipboardFormats (w32_formats, w32_formats_allocated, &w32_formats_len);
success = clipdrop->GetUpdatedClipboardFormats (w32_formats, w32_formats_allocated, &w32_formats_len);
error_code = GetLastError ();
if (!success)
@@ -90,21 +89,46 @@ gdk_win32_clipboard_request_contentformats (GdkWin32Clipboard *cb)
return NULL;
}
builder = gdk_content_formats_builder_new ();
formatpairs = g_array_sized_new (FALSE,
FALSE,
sizeof (GdkWin32ContentFormatPair),
MIN (w32_formats_len, w32_formats_allocated));
for (i = 0; i < MIN (w32_formats_len, w32_formats_allocated); i++)
gdk_win32_clipdrop_add_win32_format_to_pairs (clipdrop, w32_formats[i], NULL, builder);
gdk_win32_clipdrop_add_win32_format_to_pairs (clipdrop, w32_formats[i], formatpairs, NULL);
g_free (w32_formats);
formats = gdk_content_formats_builder_free_to_formats (builder);
GDK_NOTE (DND, {
char *s = gdk_content_formats_to_string (formats);
g_print ("... %s\n", s);
g_free (s);
g_print ("... ");
for (i = 0; i < formatpairs->len; i++)
{
const char *mime_type = (const char *) g_array_index (formatpairs, GdkWin32ContentFormatPair, i).contentformat;
g_print ("%s", mime_type);
if (i < formatpairs->len - 1)
g_print (", ");
}
g_print ("\n");
});
return formats;
if (formatpairs->len > 0)
{
GdkContentFormatsBuilder *builder = gdk_content_formats_builder_new ();
for (i = 0; i < formatpairs->len; i++)
gdk_content_formats_builder_add_mime_type (builder, g_array_index (formatpairs, GdkWin32ContentFormatPair, i).contentformat);
g_array_free (formatpairs, TRUE);
return gdk_content_formats_builder_free_to_formats (builder);
}
else
{
g_array_free (formatpairs, TRUE);
return NULL;
}
}
void
+173 -87
View File
@@ -267,6 +267,9 @@ Otherwise it's similar to how the clipboard works. Only the DnD server
#include <string.h>
#include <stdlib.h>
/* For C-style COM wrapper macros */
#define COBJMACROS
/* for CIDA */
#include <shlobj.h>
@@ -280,7 +283,6 @@ Otherwise it's similar to how the clipboard works. Only the DnD server
#include "gdkhdataoutputstream-win32.h"
#include "gdkwin32dnd.h"
#include "gdkwin32dnd-private.h"
#include "gdkwin32messagesourceprivate.h"
#include "gdkwin32.h"
#include "gdk/gdkdebugprivate.h"
@@ -406,6 +408,15 @@ struct _GdkWin32ClipboardThread
*/
HWND clipboard_opened_for;
/* We can't peek the queue or "unpop" queue items,
* so the items that we can't act upon (yet) got
* to be stored *somewhere*.
*/
GList *dequeued_items;
/* Wakeup timer id (1 if timer is set, 0 otherwise) */
UINT wakeup_timer;
/* The formats that the main thread claims to provide */
GArray *cached_advertisement; /* of GdkWin32ContentFormatPair */
@@ -413,6 +424,9 @@ struct _GdkWin32ClipboardThread
* Contains GdkWin32ClipboardThreadRender structs.
*/
GAsyncQueue *render_queue;
/* Set to TRUE when we're calling EmptyClipboard () */
gboolean ignore_destroy_clipboard;
};
typedef struct _GdkWin32ClipboardThreadResponse GdkWin32ClipboardThreadResponse;
@@ -453,6 +467,18 @@ _gdk_win32_format_uses_hdata (UINT w32format)
}
}
/* This function is called in the main thread */
static gboolean
clipboard_hwnd_created (gpointer user_data)
{
GdkWin32Clipdrop *clipdrop = gdk_win32_display_get_clipdrop (gdk_display_get_default ());
clipdrop->clipboard_hwnd = (HWND) user_data;
return G_SOURCE_REMOVE;
}
/* This function is called in the main thread */
static gboolean
clipboard_owner_changed (gpointer user_data)
@@ -709,8 +735,10 @@ process_advertise (GdkWin32Clipdrop *clipdrop,
return FALSE;
}
CLIPDROP_CB_THREAD_MEMBER (clipdrop, ignore_destroy_clipboard) = TRUE;
if (!EmptyClipboard ())
{
CLIPDROP_CB_THREAD_MEMBER (clipdrop, ignore_destroy_clipboard) = FALSE;
error_code = GetLastError ();
send_response (adv->parent.item_type,
adv->parent.opaque_task,
@@ -719,6 +747,8 @@ process_advertise (GdkWin32Clipdrop *clipdrop,
return FALSE;
}
CLIPDROP_CB_THREAD_MEMBER (clipdrop, ignore_destroy_clipboard) = FALSE;
if (adv->unset)
return FALSE;
@@ -916,6 +946,8 @@ process_retrieve (GdkWin32Clipdrop *clipdrop,
if (CLIPDROP_CB_THREAD_MEMBER (clipdrop, clipboard_opened_for) == INVALID_HANDLE_VALUE)
error_code = try_open_clipboard (clipdrop, CLIPDROP_CB_THREAD_MEMBER (clipdrop, clipboard_hwnd));
else
error_code = try_open_clipboard (clipdrop, CLIPDROP_CB_THREAD_MEMBER (clipdrop, clipboard_opened_for));
if (error_code == ERROR_ACCESS_DENIED)
return TRUE;
@@ -1001,14 +1033,38 @@ process_retrieve (GdkWin32Clipdrop *clipdrop,
}
static gboolean
process_clipboard_queue (gpointer data)
process_clipboard_queue (GdkWin32Clipdrop *clipdrop)
{
GdkWin32Clipdrop *clipdrop = data;
GdkWin32ClipboardThreadQueueItem *placeholder;
GList *p;
gboolean try_again;
GList *p_next;
for (p = CLIPDROP_CB_THREAD_MEMBER (clipdrop, dequeued_items), p_next = NULL; p; p = p_next)
{
placeholder = (GdkWin32ClipboardThreadQueueItem *) p->data;
p_next = p->next;
switch (placeholder->item_type)
{
case GDK_WIN32_CLIPBOARD_THREAD_QUEUE_ITEM_ADVERTISE:
try_again = process_advertise (clipdrop, (GdkWin32ClipboardThreadAdvertise *) placeholder);
break;
case GDK_WIN32_CLIPBOARD_THREAD_QUEUE_ITEM_RETRIEVE:
try_again = process_retrieve (clipdrop, (GdkWin32ClipboardThreadRetrieve *) placeholder);
break;
case GDK_WIN32_CLIPBOARD_THREAD_QUEUE_ITEM_STORE:
try_again = process_store (clipdrop, (GdkWin32ClipboardThreadStore *) placeholder);
break;
}
if (try_again)
return FALSE;
CLIPDROP_CB_THREAD_MEMBER (clipdrop, dequeued_items) = g_list_delete_link (CLIPDROP_CB_THREAD_MEMBER (clipdrop, dequeued_items), p);
free_queue_item (placeholder);
}
while ((placeholder = g_async_queue_try_pop (CLIPDROP_CB_THREAD_MEMBER (clipdrop, input_queue))) != NULL)
{
switch (placeholder->item_type)
@@ -1024,30 +1080,18 @@ process_clipboard_queue (gpointer data)
break;
}
if (try_again)
if (!try_again)
{
GSource *source;
g_async_queue_push_front (CLIPDROP_CB_THREAD_MEMBER (clipdrop, input_queue), placeholder);
source = g_timeout_source_new (1000);
g_source_set_priority (source, G_PRIORITY_DEFAULT);
g_source_set_callback (source, process_clipboard_queue, clipdrop, NULL);
g_source_attach (source, clipdrop->clipboard_main_context);
g_source_unref (source);
break;
free_queue_item (placeholder);
continue;
}
free_queue_item (placeholder);
CLIPDROP_CB_THREAD_MEMBER (clipdrop, dequeued_items) = g_list_append (CLIPDROP_CB_THREAD_MEMBER (clipdrop, dequeued_items), placeholder);
return FALSE;
}
if (CLIPDROP_CB_THREAD_MEMBER (clipdrop, clipboard_opened_for) != INVALID_HANDLE_VALUE)
{
API_CALL (CloseClipboard, ());
CLIPDROP_CB_THREAD_MEMBER (clipdrop, clipboard_opened_for) = INVALID_HANDLE_VALUE;
}
return G_SOURCE_REMOVE;
return TRUE;
}
static void
@@ -1069,9 +1113,9 @@ discard_render (GdkWin32ClipboardThreadRender *render,
static LRESULT
inner_clipboard_hwnd_procedure (HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam)
UINT message,
WPARAM wparam,
LPARAM lparam)
{
GdkWin32Clipdrop *clipdrop = NULL;
@@ -1087,6 +1131,49 @@ inner_clipboard_hwnd_procedure (HWND hwnd,
else
clipdrop = (GdkWin32Clipdrop *) GetWindowLongPtr (hwnd, GWLP_USERDATA);
if (message == clipdrop->thread_wakeup_message ||
message == WM_TIMER)
{
gboolean queue_is_empty = FALSE;
if (clipdrop->clipboard_thread_items == NULL)
{
g_warning ("Clipboard thread got an actionable message with no thread data");
return DefWindowProcW (hwnd, message, wparam, lparam);
}
queue_is_empty = process_clipboard_queue (clipdrop);
if (queue_is_empty && CLIPDROP_CB_THREAD_MEMBER (clipdrop, wakeup_timer))
{
API_CALL (KillTimer, (CLIPDROP_CB_THREAD_MEMBER (clipdrop, clipboard_hwnd), CLIPDROP_CB_THREAD_MEMBER (clipdrop, wakeup_timer)));
CLIPDROP_CB_THREAD_MEMBER (clipdrop, wakeup_timer) = 0;
}
/* Close the clipboard after each queue run, if it's open.
* It would be wrong to keep it open, even if we would
* need it again a second later.
* queue_is_empty == FALSE implies that the clipboard
* is closed already, but it's better to be sure.
*/
if (CLIPDROP_CB_THREAD_MEMBER (clipdrop, clipboard_opened_for) != INVALID_HANDLE_VALUE)
{
API_CALL (CloseClipboard, ());
CLIPDROP_CB_THREAD_MEMBER (clipdrop, clipboard_opened_for) = INVALID_HANDLE_VALUE;
}
if (queue_is_empty ||
CLIPDROP_CB_THREAD_MEMBER (clipdrop, wakeup_timer) != 0)
return 0;
if (SetTimer (CLIPDROP_CB_THREAD_MEMBER (clipdrop, clipboard_hwnd), 1, 1000, NULL))
CLIPDROP_CB_THREAD_MEMBER (clipdrop, wakeup_timer) = 1;
else
g_critical ("Failed to set a timer for the clipboard HWND 0x%p: %lu",
CLIPDROP_CB_THREAD_MEMBER (clipdrop, clipboard_hwnd),
GetLastError ());
}
switch (message)
{
case WM_DESTROY: /* unregister the clipboard listener */
@@ -1163,7 +1250,7 @@ inner_clipboard_hwnd_procedure (HWND hwnd,
CLIPDROP_CB_THREAD_MEMBER (clipdrop, cached_advertisement) = NULL;
}
process_clipboard_queue (clipdrop);
API_CALL (PostMessage, (CLIPDROP_CB_THREAD_MEMBER (clipdrop, clipboard_hwnd), clipdrop->thread_wakeup_message, 0, 0));
if (hwnd_owner != CLIPDROP_CB_THREAD_MEMBER (clipdrop, clipboard_hwnd))
g_idle_add_full (G_PRIORITY_DEFAULT, clipboard_owner_changed, NULL, NULL);
@@ -1302,11 +1389,11 @@ inner_clipboard_hwnd_procedure (HWND hwnd,
}
}
static LRESULT CALLBACK
clipboard_hwnd_procedure (HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam)
LRESULT CALLBACK
_clipboard_hwnd_procedure (HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam)
{
LRESULT retval;
@@ -1329,7 +1416,7 @@ register_clipboard_notification (GdkWin32Clipdrop *clipdrop)
ATOM klass;
wclass.lpszClassName = L"GdkClipboardNotification";
wclass.lpfnWndProc = clipboard_hwnd_procedure;
wclass.lpfnWndProc = _clipboard_hwnd_procedure;
wclass.hInstance = this_module ();
wclass.cbWndExtra = sizeof (GdkWin32ClipboardThread *);
@@ -1354,6 +1441,8 @@ register_clipboard_notification (GdkWin32Clipdrop *clipdrop)
goto failed;
}
g_idle_add_full (G_PRIORITY_DEFAULT, clipboard_hwnd_created, (gpointer) CLIPDROP_CB_THREAD_MEMBER (clipdrop, clipboard_hwnd), NULL);
return TRUE;
failed:
@@ -1365,43 +1454,37 @@ failed:
static gpointer
_gdk_win32_clipboard_thread_main (gpointer data)
{
GdkWin32Clipdrop *self = data;
MSG msg;
GAsyncQueue *queue = self->clipboard_open_thread_queue;
GAsyncQueue *render_queue = self->clipboard_render_queue;
guint message_source_id;
GMainLoop *loop;
g_assert (self->clipboard_thread_items == NULL);
g_assert (self->clipboard_main_context != NULL);
clipdrop_thread_items *items = (clipdrop_thread_items*) data;
GAsyncQueue *queue = items->queue;
GAsyncQueue *render_queue = (GAsyncQueue *) g_async_queue_pop (queue);
g_main_context_push_thread_default (self->clipboard_main_context);
message_source_id = gdk_win32_message_source_add (self->clipboard_main_context);
g_assert (items->clipdrop->clipboard_thread_items == NULL);
self->clipboard_thread_items = g_new0 (GdkWin32ClipboardThread, 1);
CLIPDROP_CB_THREAD_MEMBER (self, input_queue) = queue;
CLIPDROP_CB_THREAD_MEMBER (self, render_queue) = render_queue;
CLIPDROP_CB_THREAD_MEMBER (self, clipboard_opened_for) = INVALID_HANDLE_VALUE;
items->clipdrop->clipboard_thread_items = g_new0 (GdkWin32ClipboardThread, 1);
CLIPDROP_CB_THREAD_MEMBER (items->clipdrop, input_queue) = queue;
CLIPDROP_CB_THREAD_MEMBER (items->clipdrop, render_queue) = render_queue;
CLIPDROP_CB_THREAD_MEMBER (items->clipdrop, clipboard_opened_for) = INVALID_HANDLE_VALUE;
if (!register_clipboard_notification (self))
if (!register_clipboard_notification (items->clipdrop))
{
g_async_queue_unref (queue);
g_clear_pointer (&self->clipboard_thread_items, g_free);
g_clear_pointer (&items->clipdrop->clipboard_thread_items, g_free);
return NULL;
}
loop = g_main_loop_new (self->clipboard_main_context, TRUE);
g_main_loop_run (loop);
g_main_loop_unref (loop);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
/* Just in case, as this should only happen when we shut down */
DestroyWindow (CLIPDROP_CB_THREAD_MEMBER (self, clipboard_hwnd));
CloseHandle (CLIPDROP_CB_THREAD_MEMBER (self, clipboard_hwnd));
g_clear_pointer (&self->clipboard_thread_items, g_free);
g_source_remove (message_source_id);
g_main_context_pop_thread_default (self->clipboard_main_context);
DestroyWindow (CLIPDROP_CB_THREAD_MEMBER (items->clipdrop, clipboard_hwnd));
CloseHandle (CLIPDROP_CB_THREAD_MEMBER (items->clipdrop, clipboard_hwnd));
g_async_queue_unref (queue);
g_clear_pointer (&items->clipdrop->clipboard_thread_items, g_free);
return NULL;
}
@@ -1437,9 +1520,15 @@ gdk_win32_clipdrop_init (GdkWin32Clipdrop *win32_clipdrop)
int i;
GArray *comp;
GdkWin32ContentFormatPair fmt;
HMODULE user32;
clipdrop_thread_items cb_items, dnd_items;
win32_clipdrop->thread_wakeup_message = RegisterWindowMessage (L"GDK_WORKER_THREAD_WEAKEUP");
user32 = LoadLibrary (L"user32.dll");
win32_clipdrop->GetUpdatedClipboardFormats = (GetUpdatedClipboardFormatsFunc) GetProcAddress (user32, "GetUpdatedClipboardFormats");
FreeLibrary (user32);
atoms = g_array_sized_new (FALSE, TRUE, sizeof (const char *), GDK_WIN32_ATOM_INDEX_LAST);
g_array_set_size (atoms, GDK_WIN32_ATOM_INDEX_LAST);
cfs = g_array_sized_new (FALSE, TRUE, sizeof (UINT), GDK_WIN32_CF_INDEX_LAST);
@@ -1721,15 +1810,22 @@ gdk_win32_clipdrop_init (GdkWin32Clipdrop *win32_clipdrop)
win32_clipdrop->clipboard_open_thread_queue = g_async_queue_new ();
win32_clipdrop->clipboard_render_queue = g_async_queue_new ();
win32_clipdrop->clipboard_main_context = g_main_context_new ();
/* Out of sheer laziness, we just push the extra queue through the
* main queue, instead of allocating a struct with two queue
* pointers and then passing *that* to the thread.
*/
g_async_queue_push (win32_clipdrop->clipboard_open_thread_queue, g_async_queue_ref (win32_clipdrop->clipboard_render_queue));
cb_items.clipdrop = dnd_items.clipdrop = win32_clipdrop;
cb_items.queue = g_async_queue_ref (win32_clipdrop->clipboard_open_thread_queue);
win32_clipdrop->clipboard_open_thread = g_thread_new ("GDK Win32 Clipboard Thread",
_gdk_win32_clipboard_thread_main,
win32_clipdrop);
&cb_items);
win32_clipdrop->dnd_queue = g_async_queue_new ();
dnd_items.queue = g_async_queue_ref (win32_clipdrop->dnd_queue);
win32_clipdrop->dnd_thread = g_thread_new ("GDK Win32 DnD Thread",
_gdk_win32_dnd_thread_main,
win32_clipdrop);
&dnd_items);
win32_clipdrop->dnd_thread_id = GPOINTER_TO_UINT (g_async_queue_pop (win32_clipdrop->dnd_queue));
}
@@ -2674,29 +2770,6 @@ _gdk_win32_add_contentformat_to_pairs (GdkWin32Clipdrop *clip_drop,
return added_count;
}
static void
gdk_win32_clipdrop_run_in_clipboard_thread (GdkWin32Clipdrop *self,
GdkWin32ClipboardThreadQueueItem *item)
{
gboolean was_empty;
g_async_queue_lock (self->clipboard_open_thread_queue);
was_empty = g_async_queue_length_unlocked (self->clipboard_open_thread_queue) == 0;
g_async_queue_push_unlocked (self->clipboard_open_thread_queue, item);
g_async_queue_unlock (self->clipboard_open_thread_queue);
if (was_empty)
{
GSource *source;
source = g_idle_source_new ();
g_source_set_priority (source, G_PRIORITY_DEFAULT);
g_source_set_callback (source, process_clipboard_queue, self, NULL);
g_source_attach (source, self->clipboard_main_context);
g_source_unref (source);
}
}
void
_gdk_win32_advertise_clipboard_contentformats (GdkClipboard *cb,
GTask *task,
@@ -2708,6 +2781,8 @@ _gdk_win32_advertise_clipboard_contentformats (GdkClipboard *cb,
gsize mime_types_len;
gsize i;
g_assert (clipdrop->clipboard_hwnd != NULL);
adv->parent.item_type = GDK_WIN32_CLIPBOARD_THREAD_QUEUE_ITEM_ADVERTISE;
adv->parent.start_time = g_get_monotonic_time ();
adv->parent.end_time = adv->parent.start_time + CLIPBOARD_OPERATION_TIMEOUT;
@@ -2728,7 +2803,10 @@ _gdk_win32_advertise_clipboard_contentformats (GdkClipboard *cb,
_gdk_win32_add_contentformat_to_pairs (clipdrop, mime_types[i], adv->pairs);
}
gdk_win32_clipdrop_run_in_clipboard_thread (clipdrop, &adv->parent);
g_async_queue_push (clipdrop->clipboard_open_thread_queue, adv);
API_CALL (PostMessage, (clipdrop->clipboard_hwnd, clipdrop->thread_wakeup_message, 0, 0));
return;
}
void
@@ -2742,6 +2820,8 @@ _gdk_win32_retrieve_clipboard_contentformats (GdkClipboard *cb,
gsize mime_types_len;
gsize i;
g_assert (clipdrop->clipboard_hwnd != NULL);
retr->parent.item_type = GDK_WIN32_CLIPBOARD_THREAD_QUEUE_ITEM_RETRIEVE;
retr->parent.start_time = g_get_monotonic_time ();
retr->parent.end_time = retr->parent.start_time + CLIPBOARD_OPERATION_TIMEOUT;
@@ -2754,7 +2834,10 @@ _gdk_win32_retrieve_clipboard_contentformats (GdkClipboard *cb,
for (i = 0; i < mime_types_len; i++)
_gdk_win32_add_contentformat_to_pairs (clipdrop, mime_types[i], retr->pairs);
gdk_win32_clipdrop_run_in_clipboard_thread (clipdrop, &retr->parent);
g_async_queue_push (clipdrop->clipboard_open_thread_queue, retr);
API_CALL (PostMessage, (clipdrop->clipboard_hwnd, clipdrop->thread_wakeup_message, 0, 0));
return;
}
typedef struct _GdkWin32ClipboardHDataPrepAndStream GdkWin32ClipboardHDataPrepAndStream;
@@ -2832,7 +2915,8 @@ clipboard_store_hdata_ready (GObject *clipboard,
store->parent.opaque_task = prep->store_task;
store->elements = prep->elements;
gdk_win32_clipdrop_run_in_clipboard_thread (clipdrop, &store->parent);
g_async_queue_push (clipdrop->clipboard_open_thread_queue, store);
API_CALL (PostMessage, (clipdrop->clipboard_hwnd, clipdrop->thread_wakeup_message, 0, 0));
g_free (prep);
}
@@ -2849,6 +2933,8 @@ _gdk_win32_store_clipboard_contentformats (GdkClipboard *cb,
GdkWin32Clipdrop *clipdrop = gdk_win32_display_get_clipdrop (gdk_clipboard_get_display (cb));
GdkWin32ClipboardStorePrep *prep;
g_assert (clipdrop->clipboard_hwnd != NULL);
mime_types = gdk_content_formats_get_mime_types (contentformats, &n_mime_types);
pairs = g_array_sized_new (FALSE,
+30 -6
View File
@@ -113,6 +113,21 @@ typedef enum _GdkWin32CFIndex GdkWin32CFIndex;
typedef struct _GdkWin32Clipdrop GdkWin32Clipdrop;
typedef struct _GdkWin32ClipdropClass GdkWin32ClipdropClass;
/* this is shared with gdkdrag-win32.c as well */
struct _clipdrop_thread_items
{
GdkWin32Clipdrop *clipdrop;
GAsyncQueue *queue;
};
typedef struct _clipdrop_thread_items clipdrop_thread_items;
typedef BOOL (WINAPI * GetUpdatedClipboardFormatsFunc)(
_Out_ PUINT lpuiFormats,
_In_ UINT cFormats,
_Out_ PUINT pcFormatsOut
);
/* This object is just a sink to hold all the clipboard- and dnd-related data
* that otherwise would be in global variables.
*/
@@ -141,6 +156,14 @@ struct _GdkWin32Clipdrop
/* A format-keyed hash table of GArrays of GdkAtoms describing compatibility contentformats for a w32format */
GHashTable *compatibility_contentformats;
/* By all rights we should be able to just use this function
* normally, as our target platform is Vista-or-later.
* This pointer is manually retrieved only to allow
* GTK to be compiled with old MinGW versions, which
* don't have GetUpdatedClipboardFormats in the import libs.
*/
GetUpdatedClipboardFormatsFunc GetUpdatedClipboardFormats;
/* The thread that tries to open the clipboard and then
* do stuff with it. Since clipboard opening can
* fail, we split the code into a thread, and let
@@ -149,12 +172,6 @@ struct _GdkWin32Clipdrop
*/
GThread *clipboard_open_thread;
/* The main loop run in the clipboard thread.
* When we want to communicate with the thread, we just add
* tasks to it via this context.
*/
GMainContext *clipboard_main_context;
/* Our primary means of communicating with the thread.
* The communication is one-way only - the thread replies
* by just queueing functions to be called in the main
@@ -169,6 +186,13 @@ struct _GdkWin32Clipdrop
*/
GAsyncQueue *clipboard_render_queue;
/* Window handle for the clipboard surface that we
* receive from the clipboard thread. We use that
* to wake up the clipboard surface main loop by
* posting a message to it.
*/
HWND clipboard_hwnd;
/* The thread that calls DoDragDrop (), which would
* normally block our main thread, as it runs its own
* Windows message loop.
+18 -7
View File
@@ -527,16 +527,18 @@ _gdk_win32_display_open (const char *display_name)
GDK_NOTE (MISC, g_print ("gdk_display_open: %s\n", (display_name ? display_name : "NULL")));
if (display != NULL)
if (display_name == NULL || g_ascii_strcasecmp (display_name, gdk_display_get_name (display)) == 0)
{
GDK_NOTE (MISC, g_print ("... Display is already open\n"));
return NULL;
if (display != NULL)
{
GDK_NOTE (MISC, g_print ("... return existing gdkdisplay\n"));
return display;
}
}
if (display_name != NULL)
else
{
/* we don't really support multiple GdkDisplay's on Windows at this point */
GDK_NOTE (MISC, g_print ("... win32 does not support named displays, but given name was \"%s\"\n", display_name));
GDK_NOTE (MISC, g_print ("... return NULL\n"));
return NULL;
}
@@ -656,17 +658,25 @@ gdk_win32_display_get_name (GdkDisplay *display)
static void
gdk_win32_display_beep (GdkDisplay *display)
{
MessageBeep ((UINT)-1);
g_return_if_fail (display == gdk_display_get_default());
if (!MessageBeep (-1))
Beep(1000, 50);
}
static void
gdk_win32_display_flush (GdkDisplay * display)
{
g_return_if_fail (display == gdk_display_get_default());
GdiFlush ();
}
static void
gdk_win32_display_sync (GdkDisplay * display)
{
g_return_if_fail (display == gdk_display_get_default());
GdiFlush ();
}
static void
@@ -1355,6 +1365,7 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
display_class->beep = gdk_win32_display_beep;
display_class->sync = gdk_win32_display_sync;
display_class->flush = gdk_win32_display_flush;
display_class->has_pending = _gdk_win32_display_has_pending;
display_class->queue_events = _gdk_win32_display_queue_events;
//? display_class->get_app_launch_context = _gdk_win32_display_get_app_launch_context;
+1
View File
@@ -28,6 +28,7 @@
#include "gdkglversionprivate.h"
/* Used for active language or text service change notifications */
#define COBJMACROS
#include <msctf.h>
#ifdef HAVE_EGL
+7 -2
View File
@@ -192,6 +192,9 @@
#define INITGUID
#endif
/* For C-style COM wrapper macros */
#define COBJMACROS
#include "gdkdrag.h"
#include "gdkprivate-win32.h"
#include "gdkwin32.h"
@@ -634,8 +637,10 @@ do_drag_drop (GdkWin32DnDThreadDoDragDrop *ddd)
gpointer
_gdk_win32_dnd_thread_main (gpointer data)
{
GdkWin32Clipdrop *clipdrop = data;
GAsyncQueue *queue = clipdrop->dnd_queue;
clipdrop_thread_items *clipdrop_items = (clipdrop_thread_items *) data;
GAsyncQueue *queue = clipdrop_items->queue;
GdkWin32Clipdrop *clipdrop = clipdrop_items->clipdrop;
GdkWin32DnDThreadQueueItem *item;
MSG msg;
HRESULT hr;
+7 -2
View File
@@ -36,6 +36,9 @@
#define INITGUID
#endif
/* For C-style COM wrapper macros */
#define COBJMACROS
#include "gdkdropprivate.h"
#include "gdkdrag.h"
@@ -300,7 +303,8 @@ query_object_formats (GdkDisplay *display,
hr = IEnumFORMATETC_Next (pfmt, 1, &fmt, NULL);
}
gdk_win32_com_clear (&pfmt);
if (pfmt)
IEnumFORMATETC_Release (pfmt);
result_formats = gdk_content_formats_builder_free_to_formats (builder);
@@ -310,7 +314,8 @@ query_object_formats (GdkDisplay *display,
static void
set_data_object (LPDATAOBJECT *location, LPDATAOBJECT data_object)
{
gdk_win32_com_clear (location);
if (*location != NULL)
IDataObject_Release (*location);
*location = data_object;
+22 -22
View File
@@ -391,9 +391,6 @@ set_up_low_level_keyboard_hook (GdkDisplay *display)
{
HHOOK hook_handle;
if (!gdk_has_feature (GDK_FEATURE_AEROSNAP))
return;
if (GDK_WIN32_DISPLAY (display)->event_record->aerosnap_keyboard_hook != NULL)
return;
@@ -522,6 +519,14 @@ _gdk_events_init (GdkDisplay *display)
set_up_low_level_keyboard_hook (display);
}
gboolean
_gdk_win32_display_has_pending (GdkDisplay *display)
{
return (_gdk_event_queue_find_first (display) ||
(modal_win32_dialog == NULL &&
GetQueueStatus (QS_ALLINPUT) != 0));
}
#if 0 /* Unused, but might be useful to re-introduce in some debugging output? */
static char *
@@ -1775,19 +1780,19 @@ gdk_event_translate (MSG *msg,
{
/* XXX Handle WM_QUIT here ? */
if (msg->message == WM_QUIT)
{
GDK_NOTE (EVENTS, g_print (" %d", (int) msg->wParam));
exit (msg->wParam);
}
{
GDK_NOTE (EVENTS, g_print (" %d", (int) msg->wParam));
exit (msg->wParam);
}
else if (msg->message == WM_CREATE)
{
surface = (GdkSurface*) (((LPCREATESTRUCTW) msg->lParam)->lpCreateParams);
GDK_SURFACE_HWND (surface) = msg->hwnd;
}
{
surface = (UNALIGNED GdkSurface*) (((LPCREATESTRUCTW) msg->lParam)->lpCreateParams);
GDK_SURFACE_HWND (surface) = msg->hwnd;
}
else
{
GDK_NOTE (EVENTS, g_print (" (no GdkSurface)"));
}
{
GDK_NOTE (EVENTS, g_print (" (no GdkSurface)"));
}
return FALSE;
}
@@ -2297,8 +2302,8 @@ gdk_event_translate (MSG *msg,
*
*/
if (win32_display->tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINPOINTER &&
((msg->time - win32_display->device_manager->last_digitizer_time) < 200 ||
(win32_display->device_manager->last_digitizer_time - msg->time) < 200 ))
( (msg->time - win32_display->device_manager->last_digitizer_time) < 200 ||
-(msg->time - win32_display->device_manager->last_digitizer_time) < 200 ))
break;
win32_display->device_manager->pen_touch_input = FALSE;
@@ -3078,12 +3083,7 @@ gdk_event_translate (MSG *msg,
/* Call modal timer immediate so that we repaint faster after a resize. */
if (GDK_WIN32_DISPLAY (gdk_surface_get_display (surface))->display_surface_record->modal_operation_in_progress & GDK_WIN32_MODAL_OP_SIZEMOVE_MASK)
{
modal_timer_proc (msg->hwnd,
msg->message,
(UINT_PTR)surface,
msg->time);
}
modal_timer_proc (0,0,0,0);
/* Claim as handled, so that WM_SIZE and WM_MOVE are avoided */
return_val = TRUE;
-4
View File
@@ -21,10 +21,6 @@
#pragma once
#ifndef DONT_INCLUDE_LIBEPOXY
#ifdef GDK_WINDOWING_WIN32
/* epoxy needs this, see https://github.com/anholt/libepoxy/issues/299 */
#include <windows.h>
#endif
#include <epoxy/gl.h>
#include <epoxy/wgl.h>
+6 -4
View File
@@ -28,6 +28,7 @@
#endif
#define WINVER 0x0603
#define _WIN32_WINNT 0x0603
#define COBJMACROS
#include "config.h"
#include <gdk/gdk.h>
@@ -37,7 +38,6 @@
#include "gdkdevice-virtual.h"
#include "gdkdeviceprivate.h"
#include "gdkdisplay-win32.h"
#include "gdkprivate-win32.h"
#include "gdkeventsprivate.h"
#include "gdkseatdefaultprivate.h"
#include "gdkinput-dmanipulation.h"
@@ -360,7 +360,7 @@ reset_viewport (IDirectManipulationViewport *viewport)
HR_CHECK_GOTO (hr, failed);
failed:
gdk_win32_com_clear (&content);
IUnknown_Release (content);
}
static void
@@ -392,7 +392,8 @@ gdk_win32_display_close_dmanip_manager (GdkDisplay *display)
{
IDirectManipulationManager *manager = GDK_DISPLAY_GET_DMANIP_MANAGER (display);
gdk_win32_com_clear (&manager);
if (manager != NULL)
IUnknown_Release (manager);
g_clear_pointer (&GDK_WIN32_DISPLAY (display)->dmanip_items, g_free);
}
@@ -451,7 +452,8 @@ create_viewport (GdkSurface *surface,
return;
failed:
gdk_win32_com_clear (&handler);
if (handler)
IUnknown_Release (handler);
close_viewport (pViewport);
}
+11 -12
View File
@@ -254,15 +254,11 @@ _get_keyboard_layout_file (const char *layout_name)
status = RegOpenKeyExA (HKEY_LOCAL_MACHINE, (LPCSTR) kbdKeyPath, 0,
KEY_QUERY_VALUE, &hkey);
if (status == ERROR_FILE_NOT_FOUND)
{
return NULL;
}
else if (status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
{
g_warning("Could not open registry key '%s'. Error code: %d",
kbdKeyPath, (int)status);
return NULL;
goto fail1;
}
/* Get sizes */
@@ -272,14 +268,14 @@ _get_keyboard_layout_file (const char *layout_name)
{
g_warning("Could not query registry key '%s\\Layout File'. Error code: %d",
kbdKeyPath, (int)status);
goto fail_close_key;
goto fail2;
}
dir_len = GetSystemDirectoryA (0, 0); /* includes \0 */
if (dir_len == 0)
{
g_warning("GetSystemDirectoryA failed. Error: %d", (int)GetLastError());
goto fail_close_key;
goto fail2;
}
/* Allocate buffer */
@@ -288,7 +284,7 @@ _get_keyboard_layout_file (const char *layout_name)
/* Append system directory. The -1 is because dir_len includes \0 */
if (GetSystemDirectoryA (&result[0], dir_len) != dir_len - 1)
goto fail_free_result;
goto fail3;
/* Append directory separator */
result[dir_len - 1] = '\\';
@@ -297,17 +293,20 @@ _get_keyboard_layout_file (const char *layout_name)
status = RegQueryValueExA (hkey, "Layout File", 0, &var_type,
(LPBYTE) &result[dir_len], &file_name_len);
if (status != ERROR_SUCCESS)
goto fail_free_result;
{
goto fail3;
}
result[dir_len + file_name_len] = '\0';
RegCloseKey (hkey);
return result;
fail_free_result:
fail3:
g_free (result);
fail_close_key:
fail2:
RegCloseKey (hkey);
fail1:
return NULL;
}
+2 -23
View File
@@ -53,6 +53,8 @@
#define GDK_DEBUG_EVENTS_OR_INPUT (GDK_DEBUG_EVENTS|GDK_DEBUG_INPUT)
#define GDK_DEBUG_MISC_OR_EVENTS (GDK_DEBUG_MISC|GDK_DEBUG_EVENTS)
GdkWin32Screen *GDK_SURFACE_SCREEN(GObject *win);
/* Use this for hWndInsertAfter (2nd argument to SetWindowPos()) if
* SWP_NOZORDER flag is used. Otherwise it's unobvious why a particular
* argument is used. Using NULL is misleading, because
@@ -95,29 +97,6 @@ gboolean _gdk_modal_blocked (GdkSurface *surface);
gboolean gdk_win32_ensure_com (void);
gboolean gdk_win32_ensure_ole (void);
/*
* gdk_win32_com_clear:
* @com_ptr: pointer to a COM object pointer
*
* Clears a reference to a COM object.
*
* `com_ptr` must not be `NULL`.
*
* If the reference is `NULL` then this function does nothing.
* Otherwise, the reference count of the object is decreased
* and the pointer is set to NULL.
*
* Think of this function like g_clear_object() but for COM objects.
*/
#define gdk_win32_com_clear(com_ptr) \
G_STMT_START {\
if (*(com_ptr)) \
{ \
(*(com_ptr))->lpVtbl->Release (*(com_ptr)); \
*(com_ptr) = NULL; \
} \
}G_STMT_END
void _gdk_win32_print_dc (HDC hdc);
char *_gdk_win32_surface_state_to_string (GdkToplevelState state);
-123
View File
@@ -1,123 +0,0 @@
#include "config.h"
#include "gdkwin32messagesourceprivate.h"
#include "gdkevents.h"
#include <windows.h>
typedef struct _GdkWin32MessageSource GdkWin32MessageSource;
struct _GdkWin32MessageSource
{
GSource source;
GPollFD poll_fd;
} ;
static gboolean
gdk_win32_message_source_prepare (GSource *source,
int *timeout)
{
GdkWin32MessageSource *self = (GdkWin32MessageSource *) source;
gboolean retval;
*timeout = -1;
return GetQueueStatus (QS_ALLINPUT) != 0;
}
static gboolean
gdk_win32_message_source_check (GSource *source)
{
GdkWin32MessageSource *self = (GdkWin32MessageSource *) source;
self->poll_fd.revents = 0;
return GetQueueStatus (QS_ALLINPUT) != 0;
}
static gboolean
gdk_win32_message_source_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data)
{
MSG msg;
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return G_SOURCE_CONTINUE;
}
static void
gdk_win32_message_source_finalize (GSource *source)
{
#ifdef G_WITH_CYGWIN
close (self->poll_fd.fd);
#endif
}
static GSourceFuncs gdk_win32_message_source_funcs = {
gdk_win32_message_source_prepare,
gdk_win32_message_source_check,
gdk_win32_message_source_dispatch,
gdk_win32_message_source_finalize,
};
/*
* gdk_win32_message_source_new:
*
* Creates a new source for processing events of the Windows main loop.
*
* Returns: The new source
*/
GSource *
gdk_win32_message_source_new (void)
{
GdkWin32MessageSource *self;
GSource *source;
source = g_source_new (&gdk_win32_message_source_funcs, sizeof (GdkWin32MessageSource));
g_source_set_static_name (source, "GDK Win32 message source");
g_source_set_priority (source, GDK_PRIORITY_EVENTS);
self = (GdkWin32MessageSource *) source;
#ifdef G_WITH_CYGWIN
self->poll_fd.fd = open ("/dev/windows", O_RDONLY);
if (self->poll_fd.fd == -1)
g_error ("can't open \"/dev/windows\": %s", g_strerror (errno));
#else
self->poll_fd.fd = G_WIN32_MSG_HANDLE;
#endif
self->poll_fd.events = G_IO_IN;
g_source_add_poll (source, &self->poll_fd);
g_source_set_can_recurse (source, TRUE);
return source;
}
/*
* gdk_win32_message_source_add:
* @context: (nullable): The context to add the source to
*
* Adds a message source to the default main context.
*
* Returns: the ID (greater than 0) of the event source.
*/
guint
gdk_win32_message_source_add (GMainContext *context)
{
GSource *source;
guint id;
source = gdk_win32_message_source_new ();
id = g_source_attach (source, context);
g_source_unref (source);
return id;
}
-7
View File
@@ -1,7 +0,0 @@
#pragma once
#include <glib.h>
GSource * gdk_win32_message_source_new (void);
guint gdk_win32_message_source_add (GMainContext *context);
-1
View File
@@ -27,7 +27,6 @@
#include "gdkprivate-win32.h"
#include "gdkdisplay-win32.h"
#undef STRICT
#include <pango/pangowin32.h>
struct _GdkWin32ALPNSink
-1
View File
@@ -33,7 +33,6 @@ gdk_win32_sources = gdk_win32_public_sources + files([
'gdkvulkancontext-win32.c',
'gdkwin32cursor.h',
'gdkwin32display.h',
'gdkwin32messagesource.c',
'gdkwin32keys.h',
])
+7
View File
@@ -1852,6 +1852,12 @@ gdk_x11_display_flush (GdkDisplay *display)
XFlush (GDK_DISPLAY_XDISPLAY (display));
}
static gboolean
gdk_x11_display_has_pending (GdkDisplay *display)
{
return XPending (GDK_DISPLAY_XDISPLAY (display));
}
/**
* gdk_x11_display_get_default_group:
* @display: (type GdkX11Display): a `GdkDisplay`
@@ -3054,6 +3060,7 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
display_class->sync = gdk_x11_display_sync;
display_class->flush = gdk_x11_display_flush;
display_class->make_default = gdk_x11_display_make_default;
display_class->has_pending = gdk_x11_display_has_pending;
display_class->queue_events = _gdk_x11_display_queue_events;
display_class->get_app_launch_context = _gdk_x11_display_get_app_launch_context;
+4 -4
View File
@@ -1087,25 +1087,25 @@ gsk_gl_command_queue_execute (GskGLCommandQueue *self,
glEnableVertexAttribArray (0);
glVertexAttribPointer (0, 2, GL_FLOAT, GL_FALSE,
sizeof (GskGLDrawVertex),
GSIZE_TO_POINTER ((gsize) G_STRUCT_OFFSET (GskGLDrawVertex, position)));
(void *) G_STRUCT_OFFSET (GskGLDrawVertex, position));
/* 1 = texture coord location */
glEnableVertexAttribArray (1);
glVertexAttribPointer (1, 2, GL_FLOAT, GL_FALSE,
sizeof (GskGLDrawVertex),
GSIZE_TO_POINTER ((gsize) G_STRUCT_OFFSET (GskGLDrawVertex, uv)));
(void *) G_STRUCT_OFFSET (GskGLDrawVertex, uv));
/* 2 = color location */
glEnableVertexAttribArray (2);
glVertexAttribPointer (2, 4, GL_HALF_FLOAT, GL_FALSE,
sizeof (GskGLDrawVertex),
GSIZE_TO_POINTER ((gsize) G_STRUCT_OFFSET (GskGLDrawVertex, color)));
(void *) G_STRUCT_OFFSET (GskGLDrawVertex, color));
/* 3 = color2 location */
glEnableVertexAttribArray (3);
glVertexAttribPointer (3, 4, GL_HALF_FLOAT, GL_FALSE,
sizeof (GskGLDrawVertex),
GSIZE_TO_POINTER ((gsize) G_STRUCT_OFFSET (GskGLDrawVertex, color2)));
(void *) G_STRUCT_OFFSET (GskGLDrawVertex, color2));
/* Setup initial scissor clip */
if (scissor != NULL && cairo_region_num_rectangles (scissor) > 0)
+2 -6
View File
@@ -20,14 +20,10 @@
#pragma once
#include <gdk/gdk.h>
#include <gsk/gsk.h>
#ifdef GDK_WINDOWING_WIN32
/* epoxy needs this, see https://github.com/anholt/libepoxy/issues/299 */
#include <windows.h>
#endif
#include <epoxy/gl.h>
#include <graphene.h>
#include <gdk/gdk.h>
#include <gsk/gsk.h>
G_BEGIN_DECLS
+4 -4
View File
@@ -846,7 +846,7 @@ typedef struct
{
guint n_items;
guint n_stale;
} GskGpuCacheData;
} CacheData;
static void
print_cache_stats (GskGpuCache *self)
@@ -860,10 +860,10 @@ print_cache_stats (GskGpuCache *self)
for (cached = self->first_cached; cached != NULL; cached = cached->next)
{
GskGpuCacheData *cache_data = g_hash_table_lookup (classes, cached->class);
CacheData *cache_data = g_hash_table_lookup (classes, cached->class);
if (cache_data == NULL)
{
cache_data = g_new0 (GskGpuCacheData, 1);
cache_data = g_new0 (CacheData, 1);
g_hash_table_insert (classes, (gpointer) cached->class, cache_data);
}
cache_data->n_items++;
@@ -892,7 +892,7 @@ print_cache_stats (GskGpuCache *self)
while (g_hash_table_iter_next (&iter, &key, &value))
{
const GskGpuCachedClass *class = key;
const GskGpuCacheData *cache_data = value;
const CacheData *cache_data = value;
g_string_append_printf (message, "\n %s:%*s%5u (%u stale)", class->name, 12 - MIN (12, (int) strlen (class->name)), "", cache_data->n_items, cache_data->n_stale);
+1 -1
View File
@@ -665,7 +665,7 @@ void
gsk_gpu_upload_glyph_op (GskGpuFrame *frame,
GskGpuImage *image,
PangoFont *font,
PangoGlyph glyph,
const PangoGlyph glyph,
const cairo_rectangle_int_t *area,
const graphene_point_t *origin)
{
+3 -1
View File
@@ -343,6 +343,8 @@ gsk_vulkan_device_finalize (GObject *object)
g_clear_pointer (&self->allocators[i], gsk_vulkan_allocator_unref);
g_clear_pointer (&self->external_allocator, gsk_vulkan_allocator_unref);
gdk_display_unref_vulkan (display);
G_OBJECT_CLASS (gsk_vulkan_device_parent_class)->finalize (object);
}
@@ -420,7 +422,7 @@ gsk_vulkan_device_get_for_display (GdkDisplay *display,
if (self)
return GSK_GPU_DEVICE (g_object_ref (self));
if (!gdk_display_prepare_vulkan (display, error))
if (!gdk_display_init_vulkan (display, error))
return NULL;
self = g_object_new (GSK_TYPE_VULKAN_DEVICE, NULL);
+4 -10
View File
@@ -161,25 +161,19 @@ run (out vec2 pos)
float
bt709_eotf (float v)
{
const float a = 1.099;
const float d = 0.0812;
if (abs (v) < d)
if (abs (v) < 0.081)
return v / 4.5;
else
return sign (v) * pow ((abs (v) + (a - 1.0)) / a, 1.0 / 0.45);
return sign (v) * pow ((abs (v) + 0.099) / 1.099, 1.0/0.45);
}
float
bt709_oetf (float v)
{
const float a = 1.099;
const float b = 0.018;
if (abs (v) < b)
if (abs (v) < 0.081)
return v * 4.5;
else
return sign (v) * (a * pow (abs (v), 0.45) - (a - 1.0));
return 1.099 * sign (v) * (pow (abs (v), 0.45) - 0.099);
}
float
+23 -11
View File
@@ -53,12 +53,25 @@
#include <gdk/gdk.h>
#include "gdk/gdkdebugprivate.h"
#ifdef GDK_WINDOWING_X11
#include <gdk/x11/gdkx.h>
#endif
#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/wayland/gdkwayland.h>
#endif
#ifdef GDK_WINDOWING_BROADWAY
#include "broadway/gskbroadwayrenderer.h"
#endif
#ifdef GDK_WINDOWING_MACOS
#include <gdk/macos/gdkmacos.h>
#endif
#ifdef GDK_WINDOWING_WIN32
#include <gdk/win32/gdkwin32.h>
/* Remove these lines when OpenGL/ES 2.0 shader is ready */
#include "win32/gdkprivate-win32.h"
#include "win32/gdkdisplay-win32.h"
#endif
typedef struct
{
@@ -653,16 +666,7 @@ vulkan_supported_platform (GdkSurface *surface,
VkPhysicalDeviceProperties props;
GError *error = NULL;
#ifdef GDK_WINDOWING_WAYLAND
if (!GDK_IS_WAYLAND_DISPLAY (gdk_surface_get_display (surface)) && !as_fallback)
{
GSK_DEBUG (RENDERER, "Not using '%s': platform is not Wayland",
g_type_name (renderer_type));
return FALSE;
}
#endif
if (!gdk_display_prepare_vulkan (display, &error))
if (!gdk_display_init_vulkan (display, &error))
{
GSK_DEBUG (RENDERER, "Not using Vulkan%s: %s",
as_fallback ? " as fallback" : "",
@@ -694,7 +698,15 @@ vulkan_supported_platform (GdkSurface *surface,
}
#endif
return TRUE;
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY (gdk_surface_get_display (surface)))
return TRUE;
#endif
GSK_DEBUG (RENDERER, "Not using '%s': platform is not Wayland",
g_type_name (renderer_type));
return FALSE;
}
static GType
+50 -59
View File
@@ -55,10 +55,6 @@
#ifdef HAVE_PANGOFT
#include <pango/pangofc-fontmap.h>
#endif
#ifdef HAVE_PANGOWIN32
#undef STRICT
#include <pango/pangowin32.h>
#endif
#include <hb-subset.h>
@@ -1139,6 +1135,7 @@ create_ascii_glyphs (PangoFont *font)
}
#ifdef HAVE_PANGOFT
static void
delete_file (gpointer data)
{
@@ -1147,31 +1144,25 @@ delete_file (gpointer data)
g_remove (path);
g_free (path);
}
#endif
static void
ensure_fontmap (Context *context)
{
FcConfig *config;
GPtrArray *files;
if (context->fontmap)
return;
context->fontmap = pango_cairo_font_map_new ();
#ifdef HAVE_PANGOFT
if (PANGO_IS_FC_FONT_MAP (context->fontmap))
{
FcConfig *config;
GPtrArray *files;
config = FcConfigCreate ();
pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (context->fontmap), config);
FcConfigDestroy (config);
config = FcConfigCreate ();
pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (context->fontmap), config);
FcConfigDestroy (config);
files = g_ptr_array_new_with_free_func (delete_file);
files = g_ptr_array_new_with_free_func (delete_file);
g_object_set_data_full (G_OBJECT (context->fontmap), "font-files", files, (GDestroyNotify) g_ptr_array_unref);
}
#endif
g_object_set_data_full (G_OBJECT (context->fontmap), "font-files", files, (GDestroyNotify) g_ptr_array_unref);
}
static gboolean
@@ -1179,53 +1170,37 @@ add_font_from_file (Context *context,
const char *path,
GError **error)
{
FcConfig *config;
GPtrArray *files;
ensure_fontmap (context);
#ifdef HAVE_PANGOFT
if (PANGO_IS_FC_FONT_MAP (context->fontmap))
if (!PANGO_IS_FC_FONT_MAP (context->fontmap))
{
FcConfig *config;
GPtrArray *files;
config = pango_fc_font_map_get_config (PANGO_FC_FONT_MAP (context->fontmap));
if (!FcConfigAppFontAddFile (config, (FcChar8 *) path))
{
g_set_error (error,
GTK_CSS_PARSER_ERROR,
GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE,
"Failed to load font");
return FALSE;
}
files = (GPtrArray *) g_object_get_data (G_OBJECT (context->fontmap), "font-files");
g_ptr_array_add (files, g_strdup (path));
pango_fc_font_map_config_changed (PANGO_FC_FONT_MAP (context->fontmap));
return TRUE;
}
else
#endif
#ifdef HAVE_PANGOWIN32
if (g_type_is_a (G_OBJECT_TYPE (context->fontmap), g_type_from_name ("PangoWin32FontMap")))
{
gboolean result;
result = pango_win32_font_map_add_font_file (context->fontmap, path, error);
g_remove (path);
return result;
}
else
#endif
{
g_remove (path);
g_set_error (error,
GTK_CSS_PARSER_ERROR,
GTK_CSS_PARSER_ERROR_FAILED,
"Custom fonts are not implemented for %s", G_OBJECT_TYPE_NAME (context->fontmap));
return FALSE;
}
config = pango_fc_font_map_get_config (PANGO_FC_FONT_MAP (context->fontmap));
if (!FcConfigAppFontAddFile (config, (FcChar8 *) path))
{
g_set_error (error,
GTK_CSS_PARSER_ERROR,
GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE,
"Failed to load font");
return FALSE;
}
files = (GPtrArray *) g_object_get_data (G_OBJECT (context->fontmap), "font-files");
g_ptr_array_add (files, g_strdup (path));
pango_fc_font_map_config_changed (PANGO_FC_FONT_MAP (context->fontmap));
return TRUE;
}
static gboolean
@@ -1261,6 +1236,22 @@ add_font_from_bytes (Context *context,
return result;
}
#else /* !HAVE_PANGOFT */
static gboolean
add_font_from_bytes (Context *context,
GBytes *bytes,
GError **error)
{
g_set_error (error,
GTK_CSS_PARSER_ERROR,
GTK_CSS_PARSER_ERROR_FAILED,
"Not implemented");
return FALSE;
}
#endif
static gboolean
parse_font (GtkCssParser *parser,
Context *context,
@@ -2638,11 +2629,11 @@ unpack_glyphs (PangoFont *font,
}
else
{
PangoRectangle rect;
PangoRectangle ink_rect;
pango_font_get_glyph_extents (font, gi->glyph, NULL, &rect);
pango_font_get_glyph_extents (font, gi->glyph, &ink_rect, NULL);
gi->geometry.width = rect.width;
gi->geometry.width = ink_rect.width;
}
}
+5 -2
View File
@@ -146,8 +146,11 @@ collect_states (GtkAtSpiContext *self,
set_atspi_state (&states, ATSPI_STATE_VISIBLE);
set_atspi_state (&states, ATSPI_STATE_SHOWING);
if (gtk_accessible_get_platform_state (accessible, GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE))
set_atspi_state (&states, ATSPI_STATE_ACTIVE);
if (ctx->accessible_role == GTK_ACCESSIBLE_ROLE_APPLICATION)
{
if (gtk_accessible_get_platform_state (accessible, GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE))
set_atspi_state (&states, ATSPI_STATE_ACTIVE);
}
if (ctx->accessible_role == GTK_ACCESSIBLE_ROLE_TEXT_BOX ||
ctx->accessible_role == GTK_ACCESSIBLE_ROLE_SEARCH_BOX ||
+11 -1
View File
@@ -75,6 +75,16 @@ gtk_tree_rbnode_new (GtkTreeRBTree *tree,
static void
gtk_tree_rbnode_free (GtkTreeRBNode *node)
{
if (GTK_DEBUG_CHECK (TREE))
{
node->left = (gpointer) 0xdeadbeef;
node->right = (gpointer) 0xdeadbeef;
node->parent = (gpointer) 0xdeadbeef;
node->total_count = 56789;
node->offset = 56789;
node->count = 56789;
node->flags = 0;
}
g_slice_free (GtkTreeRBNode, node);
}
@@ -1168,7 +1178,7 @@ gtk_tree_rbtree_remove_node (GtkTreeRBTree *tree,
/* We need to clean up the validity of the tree.
*/
gtk_rbnode_adjust (tree, y, -1, -(int) y_total_count, -y_height);
gtk_rbnode_adjust (tree, y, -1, -y_total_count, -y_height);
if (GTK_TREE_RBNODE_GET_COLOR (y) == GTK_TREE_RBNODE_BLACK)
gtk_tree_rbtree_remove_node_fixup (tree, x, y->parent);
+2 -5
View File
@@ -334,10 +334,7 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
dbus->unique_name = g_dbus_connection_get_unique_name (dbus->session);
if (gdk_should_use_portal ())
{
g_debug ("Not using session manager");
goto out;
}
goto out;
dbus->cancellable = g_cancellable_new ();
@@ -512,7 +509,7 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
"gtk-shell-shows-menubar", FALSE,
NULL);
if (dbus->sm_proxy == NULL && dbus->session != NULL && gdk_should_use_portal ())
if (dbus->sm_proxy == NULL && dbus->session)
{
dbus->inhibit_proxy = gtk_application_get_proxy_if_service_present (dbus->session,
G_DBUS_PROXY_FLAGS_NONE,
+9 -6
View File
@@ -111,11 +111,13 @@ icon_loaded (GObject *object,
GdkPixbuf *pixbuf;
int scale = 1;
/* we need a run-time check for the backingScaleFactor selector because we
* may be compiling on a 10.7 framework, but targeting a 10.6 one
*/
if ([[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)])
scale = roundf ([[NSScreen mainScreen] backingScaleFactor]);
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
/* we need a run-time check for the backingScaleFactor selector because we
* may be compiling on a 10.7 framework, but targeting a 10.6 one
*/
if ([[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)])
scale = roundf ([[NSScreen mainScreen] backingScaleFactor]);
#endif
pixbuf = gtk_icon_load_symbolic_finish (icon, result, NULL, &error);
@@ -295,12 +297,13 @@ icon_loaded (GObject *object,
theme = gtk_icon_theme_get_for_display (gdk_display_get_default ());
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
/* we need a run-time check for the backingScaleFactor selector because we
* may be compiling on a 10.7 framework, but targeting a 10.6 one
*/
if ([[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)])
scale = roundf ([[NSScreen mainScreen] backingScaleFactor]);
#endif
icon = gtk_icon_theme_lookup_by_gicon (theme, icon, ICON_SIZE, scale, 0);
if (icon != NULL)
+16 -29
View File
@@ -88,10 +88,6 @@
* displays the shortcuts window, associate the item with the action
* `win.show-help-overlay`.
*
* `GtkApplication` will also automatically set the application id as the
* default window icon. Use [func@Gtk.Window.set_default_icon_name] or
* [property@Gtk.Window:icon-name] to override that behavior.
*
* ## A simple application
*
* [A simple example](https://gitlab.gnome.org/GNOME/gtk/tree/main/examples/bp/bloatpad.c)
@@ -248,23 +244,6 @@ gtk_application_load_resources (GtkApplication *application)
}
}
static void
gtk_application_set_window_icon (GtkApplication *application)
{
GtkIconTheme *default_theme;
const char *appid;
if (gtk_window_get_default_icon_name () != NULL)
return;
default_theme = gtk_icon_theme_get_for_display (gdk_display_get_default ());
appid = g_application_get_application_id (G_APPLICATION (application));
if (appid == NULL || !gtk_icon_theme_has_icon (default_theme, appid))
return;
gtk_window_set_default_icon_name (appid);
}
static void
gtk_application_startup (GApplication *g_application)
@@ -288,7 +267,6 @@ gtk_application_startup (GApplication *g_application)
gtk_application_impl_startup (priv->impl, priv->register_session);
gtk_application_load_resources (application);
gtk_application_set_window_icon (application);
gdk_profiler_end_mark (before, "Application startup", NULL);
}
@@ -327,6 +305,8 @@ static void
gtk_application_add_platform_data (GApplication *application,
GVariantBuilder *builder)
{
GdkDisplay *display;
/* This is slightly evil.
*
* We don't have an impl here because we're remote so we can't figure
@@ -334,14 +314,21 @@ gtk_application_add_platform_data (GApplication *application,
*
* So we do all the things... which currently is just one thing.
*/
const char *startup_id = gdk_get_startup_notification_id ();
if (startup_id && g_utf8_validate (startup_id, -1, NULL))
display = gdk_display_get_default ();
if (display)
{
g_variant_builder_add (builder, "{sv}", "activation-token",
g_variant_new_string (startup_id));
g_variant_builder_add (builder, "{sv}", "desktop-startup-id",
g_variant_new_string (startup_id));
const char *startup_id;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
startup_id = gdk_display_get_startup_notification_id (display);
G_GNUC_END_IGNORE_DEPRECATIONS
if (startup_id && g_utf8_validate (startup_id, -1, NULL))
{
g_variant_builder_add (builder, "{sv}", "activation-token",
g_variant_new_string (startup_id));
g_variant_builder_add (builder, "{sv}", "desktop-startup-id",
g_variant_new_string (startup_id));
}
}
}
+2 -4
View File
@@ -119,8 +119,7 @@ gtk_application_accels_set_accels_for_action (GtkApplicationAccels *accels,
for (i = 0; accelerators[i]; i++)
{
GtkShortcutTrigger *new_trigger;
guint key;
GdkModifierType modifier;
guint key, modifier;
if (!gtk_accelerator_parse (accelerators[i], &key, &modifier))
{
@@ -268,8 +267,7 @@ gtk_application_accels_get_actions_for_accel (GtkApplicationAccels *accels,
const char *accel)
{
GPtrArray *result;
guint key;
GdkModifierType modifiers;
guint key, modifiers;
guint i;
if (!gtk_accelerator_parse (accel, &key, &modifiers))
+1 -3
View File
@@ -913,13 +913,11 @@ parse_property (ParserData *data,
if (bind_flags_str)
{
guint flags;
if (!_gtk_builder_flags_from_string (G_TYPE_BINDING_FLAGS, bind_flags_str, &flags, error))
if (!_gtk_builder_flags_from_string (G_TYPE_BINDING_FLAGS, bind_flags_str, &bind_flags, error))
{
_gtk_builder_prefix_error (data->builder, &data->ctx, error);
return;
}
bind_flags = flags;
}
gtk_buildable_parse_context_get_position (&data->ctx, &line, &col);
+2 -8
View File
@@ -1203,7 +1203,7 @@ gtk_css_node_get_classes (GtkCssNode *cssnode)
return result;
}
gboolean
void
gtk_css_node_add_class (GtkCssNode *cssnode,
GQuark style_class)
{
@@ -1211,13 +1211,10 @@ gtk_css_node_add_class (GtkCssNode *cssnode,
{
gtk_css_node_invalidate (cssnode, GTK_CSS_CHANGE_CLASS);
g_object_notify_by_pspec (G_OBJECT (cssnode), cssnode_properties[PROP_CLASSES]);
return TRUE;
}
return FALSE;
}
gboolean
void
gtk_css_node_remove_class (GtkCssNode *cssnode,
GQuark style_class)
{
@@ -1225,10 +1222,7 @@ gtk_css_node_remove_class (GtkCssNode *cssnode,
{
gtk_css_node_invalidate (cssnode, GTK_CSS_CHANGE_CLASS);
g_object_notify_by_pspec (G_OBJECT (cssnode), cssnode_properties[PROP_CLASSES]);
return TRUE;
}
return FALSE;
}
gboolean
+2 -2
View File
@@ -128,9 +128,9 @@ GtkStateFlags gtk_css_node_get_state (GtkCssNode *
void gtk_css_node_set_classes (GtkCssNode *cssnode,
const char **classes);
char ** gtk_css_node_get_classes (GtkCssNode *cssnode);
gboolean gtk_css_node_add_class (GtkCssNode *cssnode,
void gtk_css_node_add_class (GtkCssNode *cssnode,
GQuark style_class);
gboolean gtk_css_node_remove_class (GtkCssNode *cssnode,
void gtk_css_node_remove_class (GtkCssNode *cssnode,
GQuark style_class);
gboolean gtk_css_node_has_class (GtkCssNode *cssnode,
GQuark style_class) G_GNUC_PURE;
+5 -2
View File
@@ -19,6 +19,8 @@
#include "config.h"
#define COBJMACROS
#include "gtkfilechoosernativeprivate.h"
#include "gtknativedialogprivate.h"
@@ -331,9 +333,10 @@ filechooser_win32_thread_data_free (FilechooserWin32ThreadData *data)
g_array_free (data->choices_selections, TRUE);
data->choices_selections = NULL;
}
g_clear_object (&data->shortcut_files);
g_object_unref (data->shortcut_files);
g_slist_free_full (data->files, g_object_unref);
g_clear_object (&data->self);
if (data->self)
g_object_unref (data->self);
g_free (data->accept_label);
g_free (data->cancel_label);
g_free (data->title);
+11 -11
View File
@@ -6959,7 +6959,7 @@ match_func (gpointer item, gpointer user_data)
return g_file_info_get_attribute_boolean (G_FILE_INFO (item), "filechooser::visible");
}
static int
static GtkOrdering
directory_sort_func (gconstpointer a,
gconstpointer b,
gpointer user_data)
@@ -6980,13 +6980,13 @@ directory_sort_func (gconstpointer a,
return GTK_ORDERING_EQUAL;
}
static int
static GtkOrdering
name_sort_func (gconstpointer a,
gconstpointer b,
gpointer user_data)
{
char *key_a, *key_b;
int result;
GtkOrdering result;
/* FIXME: use sortkeys for these */
key_a = g_utf8_collate_key_for_filename (g_file_info_get_display_name ((GFileInfo *)a), -1);
@@ -7026,7 +7026,7 @@ location_sort_func (gconstpointer a,
return result;
}
static int
static GtkOrdering
size_sort_func (gconstpointer a,
gconstpointer b,
gpointer user_data)
@@ -7044,14 +7044,14 @@ size_sort_func (gconstpointer a,
return GTK_ORDERING_EQUAL;
}
static int
static GtkOrdering
type_sort_func (gconstpointer a,
gconstpointer b,
gpointer user_data)
{
GtkFileChooserWidget *impl = user_data;
char *key_a, *key_b;
int result;
GtkOrdering result;
/* FIXME: use sortkeys for these */
key_a = get_type_information (impl, (GFileInfo *)a);
@@ -7065,7 +7065,7 @@ type_sort_func (gconstpointer a,
return result;
}
static int
static GtkOrdering
time_sort_func (gconstpointer a,
gconstpointer b,
gpointer user_data)
@@ -7094,12 +7094,12 @@ time_sort_func (gconstpointer a,
return GTK_ORDERING_EQUAL;
}
static int
static GtkOrdering
recent_sort_func (gconstpointer a,
gconstpointer b,
gpointer user_data)
{
int result;
GtkOrdering result;
result = time_sort_func (a, b, user_data);
@@ -7116,12 +7116,12 @@ recent_sort_func (gconstpointer a,
return result;
}
static int
static GtkOrdering
search_sort_func (gconstpointer a,
gconstpointer b,
gpointer user_data)
{
int result;
GtkOrdering result;
result = location_sort_func (a, b, user_data);
-1
View File
@@ -2190,7 +2190,6 @@ update_feature_example (GtkFontChooserWidget *fontchooser,
gtk_label_set_text (GTK_LABEL (item->example), text);
gtk_label_set_attributes (GTK_LABEL (item->example), attrs);
gtk_label_set_ellipsize (GTK_LABEL (item->example), PANGO_ELLIPSIZE_END);
g_free (text);
pango_attr_list_unref (attrs);
-8
View File
@@ -48,16 +48,8 @@ typedef struct _GtkIconTheme GtkIconTheme;
*
* Used to specify options for gtk_icon_theme_lookup_icon().
*/
/**
* GTK_ICON_LOOKUP_NONE:
*
* Perform a regular lookup.
*
* Since: 4.18
*/
typedef enum
{
GTK_ICON_LOOKUP_NONE GDK_AVAILABLE_ENUMERATOR_IN_4_18 = 0,
GTK_ICON_LOOKUP_FORCE_REGULAR = 1 << 0,
GTK_ICON_LOOKUP_FORCE_SYMBOLIC = 1 << 1,
GTK_ICON_LOOKUP_PRELOAD = 1 << 2,
-1
View File
@@ -40,7 +40,6 @@
#include "gtk/deprecated/gtkstylecontextprivate.h"
#include "gtkwidgetprivate.h"
#undef STRICT
#include <pango/pangowin32.h>
/* Determines what happens when focus is lost while preedit is in process. */
+22 -28
View File
@@ -70,20 +70,18 @@ struct _GtkKineticScrolling
double c2;
double equilibrium_position;
gint64 t;
double t;
double position;
double velocity;
};
static void gtk_kinetic_scrolling_init_overshoot (GtkKineticScrolling *data,
gint64 frame_time,
double equilibrium_position,
double initial_position,
double initial_velocity);
GtkKineticScrolling *
gtk_kinetic_scrolling_new (gint64 frame_time,
double lower,
gtk_kinetic_scrolling_new (double lower,
double upper,
double overshoot_width,
double decel_friction,
@@ -98,19 +96,16 @@ gtk_kinetic_scrolling_new (gint64 frame_time,
data->upper = upper;
data->decel_friction = decel_friction;
data->overshoot_friction = overshoot_friction;
data->overshoot_width = overshoot_width;
if (initial_position < lower)
if(initial_position < lower)
{
gtk_kinetic_scrolling_init_overshoot (data,
frame_time,
lower,
initial_position,
initial_velocity);
}
else if (initial_position > upper)
else if(initial_position > upper)
{
gtk_kinetic_scrolling_init_overshoot (data,
frame_time,
upper,
initial_position,
initial_velocity);
@@ -120,9 +115,9 @@ gtk_kinetic_scrolling_new (gint64 frame_time,
data->phase = GTK_KINETIC_SCROLLING_PHASE_DECELERATING;
data->c1 = initial_velocity / decel_friction + initial_position;
data->c2 = -initial_velocity / decel_friction;
data->t = 0;
data->position = initial_position;
data->velocity = initial_velocity;
data->t = frame_time;
}
return data;
@@ -165,7 +160,6 @@ gtk_kinetic_scrolling_free (GtkKineticScrolling *kinetic)
static void
gtk_kinetic_scrolling_init_overshoot (GtkKineticScrolling *data,
gint64 frame_time,
double equilibrium_position,
double initial_position,
double initial_velocity)
@@ -174,36 +168,36 @@ gtk_kinetic_scrolling_init_overshoot (GtkKineticScrolling *data,
data->equilibrium_position = equilibrium_position;
data->c1 = initial_position - equilibrium_position;
data->c2 = initial_velocity + data->overshoot_friction / 2 * data->c1;
data->t = frame_time;
data->t = 0;
}
gboolean
gtk_kinetic_scrolling_tick (GtkKineticScrolling *data,
gint64 frame_time,
double time_delta,
double *position,
double *velocity)
{
double t = (frame_time - data->t) / (double)G_USEC_PER_SEC;
switch (data->phase)
switch(data->phase)
{
case GTK_KINETIC_SCROLLING_PHASE_DECELERATING:
{
double exp_part;
exp_part = exp (-data->decel_friction * t);
data->t += time_delta;
exp_part = exp (-data->decel_friction * data->t);
data->position = data->c1 + data->c2 * exp_part;
data->velocity = -data->decel_friction * data->c2 * exp_part;
if (data->position < data->lower)
if(data->position < data->lower)
{
gtk_kinetic_scrolling_init_overshoot (data, frame_time, data->lower, data->position, data->velocity);
gtk_kinetic_scrolling_init_overshoot(data,data->lower,data->position,data->velocity);
}
else if (data->position > data->upper)
{
gtk_kinetic_scrolling_init_overshoot (data, frame_time, data->upper, data->position, data->velocity);
gtk_kinetic_scrolling_init_overshoot(data, data->upper, data->position, data->velocity);
}
else if (fabs (data->velocity) < 0.1)
else if (fabs(data->velocity) < 0.1)
{
gtk_kinetic_scrolling_stop (data);
}
@@ -212,23 +206,23 @@ gtk_kinetic_scrolling_tick (GtkKineticScrolling *data,
case GTK_KINETIC_SCROLLING_PHASE_OVERSHOOTING:
{
double half_overshoot_width = data->overshoot_width / 2.;
double exp_part, pos;
exp_part = exp (-data->overshoot_friction / 2 * t);
pos = exp_part * (data->c1 + data->c2 * t);
data->t += time_delta;
exp_part = exp(-data->overshoot_friction / 2 * data->t);
pos = exp_part * (data->c1 + data->c2 * data->t);
if (pos < data->lower - half_overshoot_width || pos > data->upper + half_overshoot_width)
if (pos < data->lower - 50 || pos > data->upper + 50)
{
pos = CLAMP (pos, data->lower - half_overshoot_width, data->upper + half_overshoot_width);
gtk_kinetic_scrolling_init_overshoot (data, frame_time, data->equilibrium_position, pos, 0);
pos = CLAMP (pos, data->lower - 50, data->upper + 50);
gtk_kinetic_scrolling_init_overshoot (data, data->equilibrium_position, pos, 0);
}
else
data->velocity = data->c2 * exp_part - data->overshoot_friction / 2 * pos;
data->position = pos + data->equilibrium_position;
if (fabs (pos) < 0.1)
if(fabs (pos) < 0.1)
{
data->phase = GTK_KINETIC_SCROLLING_PHASE_FINISHED;
data->position = data->equilibrium_position;
+2 -3
View File
@@ -31,8 +31,7 @@ typedef enum {
typedef struct _GtkKineticScrolling GtkKineticScrolling;
GtkKineticScrolling * gtk_kinetic_scrolling_new (gint64 frame_time,
double lower,
GtkKineticScrolling * gtk_kinetic_scrolling_new (double lower,
double upper,
double overshoot_width,
double decel_friction,
@@ -46,7 +45,7 @@ GtkKineticScrollingChange gtk_kinetic_scrolling_update_size (GtkKineticScrolling
double upper);
gboolean gtk_kinetic_scrolling_tick (GtkKineticScrolling *data,
gint64 frame_time,
double time_delta,
double *position,
double *velocity);
+4 -4
View File
@@ -2823,16 +2823,16 @@ gtk_label_class_init (GtkLabelClass *class)
add_move_binding (widget_class, GDK_KEY_KP_Left, GDK_ALT_MASK,
GTK_MOVEMENT_WORDS, -1);
add_move_binding (widget_class, GDK_KEY_Right, GDK_META_MASK,
add_move_binding (widget_class, GDK_KEY_Right, GDK_ALT_MASK,
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
add_move_binding (widget_class, GDK_KEY_Left, GDK_META_MASK,
add_move_binding (widget_class, GDK_KEY_Left, GDK_ALT_MASK,
GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
add_move_binding (widget_class, GDK_KEY_KP_Right, GDK_META_MASK,
add_move_binding (widget_class, GDK_KEY_KP_Right, GDK_ALT_MASK,
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
add_move_binding (widget_class, GDK_KEY_KP_Left, GDK_META_MASK,
add_move_binding (widget_class, GDK_KEY_KP_Left, GDK_ALT_MASK,
GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
add_move_binding (widget_class, GDK_KEY_Up, GDK_META_MASK,
+4 -5
View File
@@ -97,12 +97,11 @@ gtk_list_item_base_update (GtkListItemBase *self,
gtk_widget_set_state_flags (GTK_WIDGET (self), GTK_STATE_FLAG_SELECTED, FALSE);
else
gtk_widget_unset_state_flags (GTK_WIDGET (self), GTK_STATE_FLAG_SELECTED);
}
/* We're updating the a11y state at least once because of the side-effects, subsequent same state filtering is done on the a11y layer. */
gtk_accessible_update_state (GTK_ACCESSIBLE (self),
GTK_ACCESSIBLE_STATE_SELECTED, priv->selected,
-1);
gtk_accessible_update_state (GTK_ACCESSIBLE (self),
GTK_ACCESSIBLE_STATE_SELECTED, priv->selected,
-1);
}
}
guint
+6 -7
View File
@@ -629,19 +629,18 @@ gtk_init_check (void)
* gtk_init:
*
* Call this function before using any other GTK functions in your GUI
* applications.
*
* It will initialize everything needed to operate the toolkit. In particular,
* it will open the default display (see [func@Gdk.Display.get_default]).
* applications. It will initialize everything needed to operate the
* toolkit.
*
* If you are using `GtkApplication`, you usually don't have to call this
* function; the `GApplication::startup` handler does it for you. Though,
* if you are using GApplication methods that will be invoked before `startup`,
* such as `local_command_line`, you may need to initialize stuff explicitly.
*
* This function will terminate your program if it was unable to initialize
* the windowing system for some reason. If you want your program to fall back
* to a textual interface, call [func@Gtk.init_check] instead.
* This function will terminate your program if it was unable to
* initialize the windowing system for some reason. If you want
* your program to fall back to a textual interface, call
* [func@Gtk.init_check] instead.
*
* GTK calls `signal (SIGPIPE, SIG_IGN)` during initialization, to ignore
* SIGPIPE signals, since these are almost never wanted in graphical
+3 -3
View File
@@ -828,7 +828,7 @@ call_password_proxy_cb (GObject *source,
{
_GtkMountOperationHandler *proxy = _GTK_MOUNT_OPERATION_HANDLER (source);
GMountOperation *op = user_data;
guint result;
GMountOperationResult result;
GVariant *result_details;
GVariantIter iter;
const char *key;
@@ -983,7 +983,7 @@ call_question_proxy_cb (GObject *source,
{
_GtkMountOperationHandler *proxy = _GTK_MOUNT_OPERATION_HANDLER (source);
GMountOperation *op = user_data;
guint result;
GMountOperationResult result;
GVariant *result_details;
GVariantIter iter;
const char *key;
@@ -1566,7 +1566,7 @@ call_processes_proxy_cb (GObject *source,
{
_GtkMountOperationHandler *proxy = _GTK_MOUNT_OPERATION_HANDLER (source);
GMountOperation *op = user_data;
guint result;
GMountOperationResult result;
GVariant *result_details;
GVariantIter iter;
const char *key;
-1
View File
@@ -590,7 +590,6 @@ populate_servers (GtkPlacesView *view)
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_button_set_has_frame (GTK_BUTTON (button), FALSE);
gtk_widget_add_css_class (button, "sidebar-button");
gtk_widget_set_tooltip_text (button, _("Remove server"));
gtk_grid_attach (GTK_GRID (grid), button, 1, 0, 1, 2);
gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), grid);
+7 -7
View File
@@ -31,7 +31,7 @@ typedef struct {
double angle1;
double angle2;
gboolean negative;
} ArcPath;
} Arc;
static inline guint
mem_hash (gconstpointer v, int len)
@@ -49,14 +49,14 @@ mem_hash (gconstpointer v, int len)
}
static guint
arc_path_hash (ArcPath *arc)
arc_path_hash (Arc *arc)
{
return mem_hash ((gconstpointer)arc, sizeof (ArcPath));
return mem_hash ((gconstpointer)arc, sizeof (Arc));
}
static gboolean
arc_path_equal (ArcPath *arc1,
ArcPath *arc2)
arc_path_equal (Arc *arc1,
Arc *arc2)
{
return arc1->angle1 == arc2->angle1 &&
arc1->angle2 == arc2->angle2 &&
@@ -80,10 +80,10 @@ static void
append_arc (cairo_t *cr, double angle1, double angle2, gboolean negative)
{
static GHashTable *arc_path_cache;
ArcPath key;
Arc key;
cairo_path_t *arc;
memset (&key, 0, sizeof (ArcPath));
memset (&key, 0, sizeof (Arc));
key.angle1 = angle1;
key.angle2 = angle2;
key.negative = negative;
+12 -13
View File
@@ -3263,10 +3263,11 @@ scrolled_window_deceleration_cb (GtkWidget *widget,
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GtkAdjustment *hadjustment, *vadjustment;
gint64 current_time;
double position;
double position, elapsed;
gboolean retval = G_SOURCE_REMOVE;
current_time = gdk_frame_clock_get_frame_time (frame_clock);
elapsed = (current_time - priv->last_deceleration_time) / (double)G_TIME_SPAN_SECOND;
priv->last_deceleration_time = current_time;
hadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
@@ -3275,7 +3276,7 @@ scrolled_window_deceleration_cb (GtkWidget *widget,
gtk_scrolled_window_invalidate_overshoot (scrolled_window);
if (priv->hscrolling &&
gtk_kinetic_scrolling_tick (priv->hscrolling, current_time, &position, NULL))
gtk_kinetic_scrolling_tick (priv->hscrolling, elapsed, &position, NULL))
{
priv->unclamped_hadj_value = position;
gtk_adjustment_set_value (hadjustment, position);
@@ -3283,7 +3284,7 @@ scrolled_window_deceleration_cb (GtkWidget *widget,
}
if (priv->vscrolling &&
gtk_kinetic_scrolling_tick (priv->vscrolling, current_time, &position, NULL))
gtk_kinetic_scrolling_tick (priv->vscrolling, elapsed, &position, NULL))
{
priv->unclamped_vadj_value = position;
gtk_adjustment_set_value (vadjustment, position);
@@ -3319,15 +3320,13 @@ kinetic_scroll_stop_notify (GtkScrolledWindow *scrolled_window)
}
static void
gtk_scrolled_window_accumulate_velocity (GtkKineticScrolling **scrolling,
gint64 current_time,
double *velocity)
gtk_scrolled_window_accumulate_velocity (GtkKineticScrolling **scrolling, double elapsed, double *velocity)
{
if (!*scrolling)
return;
double last_velocity;
gtk_kinetic_scrolling_tick (*scrolling, current_time, NULL, &last_velocity);
gtk_kinetic_scrolling_tick (*scrolling, elapsed, NULL, &last_velocity);
if (((*velocity >= 0) == (last_velocity >= 0)) &&
(fabs (*velocity) >= fabs (last_velocity) * VELOCITY_ACCUMULATION_FLOOR))
{
@@ -3345,6 +3344,7 @@ gtk_scrolled_window_start_deceleration (GtkScrolledWindow *scrolled_window)
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
GdkFrameClock *frame_clock;
gint64 current_time;
double elapsed;
int overshoot_x, overshoot_y;
g_return_if_fail (priv->deceleration_id == 0);
@@ -3352,6 +3352,7 @@ gtk_scrolled_window_start_deceleration (GtkScrolledWindow *scrolled_window)
frame_clock = gtk_widget_get_frame_clock (GTK_WIDGET (scrolled_window));
current_time = gdk_frame_clock_get_frame_time (frame_clock);
elapsed = (current_time - priv->last_deceleration_time) / (double)G_TIME_SPAN_SECOND;
priv->last_deceleration_time = current_time;
_gtk_scrolled_window_get_overshoot (scrolled_window, &overshoot_x, &overshoot_y);
@@ -3361,7 +3362,7 @@ gtk_scrolled_window_start_deceleration (GtkScrolledWindow *scrolled_window)
double lower,upper;
GtkAdjustment *hadjustment;
gtk_scrolled_window_accumulate_velocity (&priv->hscrolling, current_time, &priv->x_velocity);
gtk_scrolled_window_accumulate_velocity (&priv->hscrolling, elapsed, &priv->x_velocity);
g_clear_pointer (&priv->hscrolling, gtk_kinetic_scrolling_free);
if (priv->x_velocity != 0 || overshoot_x != 0)
@@ -3371,8 +3372,7 @@ gtk_scrolled_window_start_deceleration (GtkScrolledWindow *scrolled_window)
upper = gtk_adjustment_get_upper (hadjustment);
upper -= gtk_adjustment_get_page_size (hadjustment);
priv->hscrolling =
gtk_kinetic_scrolling_new (current_time,
lower,
gtk_kinetic_scrolling_new (lower,
upper,
MAX_OVERSHOOT_DISTANCE,
DECELERATION_FRICTION,
@@ -3389,7 +3389,7 @@ gtk_scrolled_window_start_deceleration (GtkScrolledWindow *scrolled_window)
double lower,upper;
GtkAdjustment *vadjustment;
gtk_scrolled_window_accumulate_velocity (&priv->vscrolling, current_time, &priv->y_velocity);
gtk_scrolled_window_accumulate_velocity (&priv->vscrolling, elapsed, &priv->y_velocity);
g_clear_pointer (&priv->vscrolling, gtk_kinetic_scrolling_free);
if (priv->y_velocity != 0 || overshoot_y != 0)
@@ -3399,8 +3399,7 @@ gtk_scrolled_window_start_deceleration (GtkScrolledWindow *scrolled_window)
upper = gtk_adjustment_get_upper(vadjustment);
upper -= gtk_adjustment_get_page_size(vadjustment);
priv->vscrolling =
gtk_kinetic_scrolling_new (current_time,
lower,
gtk_kinetic_scrolling_new (lower,
upper,
MAX_OVERSHOOT_DISTANCE,
DECELERATION_FRICTION,
+1 -1
View File
@@ -714,7 +714,7 @@ gtk_shortcuts_section_reflow_groups (GtkShortcutsSection *self)
if (n_rows - height == 0)
break;
if (n_rows - n < 2 * height)
if (ABS (n_rows - n) < ABS ((n_rows - height) - (n + height)))
break;
n_rows -= height;
+4 -4
View File
@@ -264,7 +264,7 @@ enum {
/* Signals */
enum
{
INPUT_,
INPUT,
OUTPUT,
VALUE_CHANGED,
ACTIVATE,
@@ -499,7 +499,7 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
* Returns: %TRUE for a successful conversion, %FALSE if the input
* was not handled, and %GTK_INPUT_ERROR if the conversion failed.
*/
spinbutton_signals[INPUT_] =
spinbutton_signals[INPUT] =
g_signal_new (I_("input"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
@@ -508,7 +508,7 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
_gtk_marshal_INT__POINTER,
G_TYPE_INT, 1,
G_TYPE_POINTER);
g_signal_set_va_marshaller (spinbutton_signals[INPUT_],
g_signal_set_va_marshaller (spinbutton_signals[INPUT],
G_TYPE_FROM_CLASS (gobject_class),
_gtk_marshal_INT__POINTERv);
@@ -2541,7 +2541,7 @@ gtk_spin_button_update (GtkSpinButton *spin_button)
g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
return_val = FALSE;
g_signal_emit (spin_button, spinbutton_signals[INPUT_], 0, &val, &return_val);
g_signal_emit (spin_button, spinbutton_signals[INPUT], 0, &val, &return_val);
if (return_val == FALSE)
{
return_val = gtk_spin_button_default_input (spin_button, &val);
+6 -18
View File
@@ -291,7 +291,6 @@ struct _GtkTextPrivate
guint propagate_text_width : 1;
guint text_handles_enabled : 1;
guint enable_undo : 1;
guint emoji_chooser_open : 1;
};
struct _GtkTextPasswordHint
@@ -1445,16 +1444,16 @@ gtk_text_class_init (GtkTextClass *class)
add_move_binding (widget_class, GDK_KEY_KP_Left, GDK_ALT_MASK,
GTK_MOVEMENT_WORDS, -1);
add_move_binding (widget_class, GDK_KEY_Right, GDK_META_MASK,
add_move_binding (widget_class, GDK_KEY_Right, GDK_ALT_MASK,
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
add_move_binding (widget_class, GDK_KEY_Left, GDK_META_MASK,
add_move_binding (widget_class, GDK_KEY_Left, GDK_ALT_MASK,
GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
add_move_binding (widget_class, GDK_KEY_KP_Right, GDK_META_MASK,
add_move_binding (widget_class, GDK_KEY_KP_Right, GDK_ALT_MASK,
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
add_move_binding (widget_class, GDK_KEY_KP_Left, GDK_META_MASK,
add_move_binding (widget_class, GDK_KEY_KP_Left, GDK_ALT_MASK,
GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
add_move_binding (widget_class, GDK_KEY_Up, GDK_META_MASK,
@@ -3460,7 +3459,7 @@ gtk_text_grab_focus (GtkWidget *widget)
if (!GTK_WIDGET_CLASS (gtk_text_parent_class)->grab_focus (GTK_WIDGET (self)))
return FALSE;
if (priv->editable && !priv->in_click && !prev_focus_was_child && !priv->emoji_chooser_open)
if (priv->editable && !priv->in_click && !prev_focus_was_child)
{
g_object_get (gtk_widget_get_settings (widget),
"gtk-entry-select-on-focus",
@@ -7184,15 +7183,6 @@ gtk_text_get_tabs (GtkText *self)
return priv->tabs;
}
static void
emoji_chooser_closed (GtkWidget *chooser,
GtkText *text)
{
GtkTextPrivate *priv = gtk_text_get_instance_private (text);
priv->emoji_chooser_open = 1;
}
static void
emoji_picked (GtkEmojiChooser *chooser,
const char *text,
@@ -7218,7 +7208,6 @@ emoji_picked (GtkEmojiChooser *chooser,
static void
gtk_text_insert_emoji (GtkText *self)
{
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
GtkWidget *chooser;
if (gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_EMOJI_CHOOSER) != NULL)
@@ -7232,11 +7221,10 @@ gtk_text_insert_emoji (GtkText *self)
gtk_widget_set_parent (chooser, GTK_WIDGET (self));
g_signal_connect (chooser, "emoji-picked", G_CALLBACK (emoji_picked), self);
g_signal_connect_swapped (chooser, "hide", G_CALLBACK (emoji_chooser_closed), self);
g_signal_connect_swapped (chooser, "hide", G_CALLBACK (gtk_text_grab_focus_without_selecting), self);
}
gtk_popover_popup (GTK_POPOVER (chooser));
priv->emoji_chooser_open = 1;
}
static void

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