Compare commits

..

2 Commits

Author SHA1 Message Date
Matthias Clasen c6dbfc85e9 maplistmodel: Actually clear nodes
When we drop our weak ref, we better reset the pointer too.
2022-07-14 20:22:22 -04:00
Matthias Clasen 404f39551e maplistmodel: Improve test coverage 2022-07-14 20:20:26 -04:00
270 changed files with 37740 additions and 49547 deletions
+2 -42
View File
@@ -21,12 +21,12 @@ stages:
# Common variables
variables:
COMMON_MESON_FLAGS: "-Dwerror=true -Dglib:werror=false -Dpango:werror=false -Dgtk-doc:werror=false -Dwayland-protocols:werror=false -Dsysprof:werror=false -Dwayland:werror=false"
COMMON_MESON_FLAGS: "-Dwerror=true -Dglib:werror=false -Dpango:werror=false -Dgtk-doc:werror=false -Dwayland-protocols:werror=false -Dsysprof:werror=false"
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v38"
FLATPAK_IMAGE: "quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master"
FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"
.only-default:
only:
@@ -109,29 +109,6 @@ release-build:
- ninja -C _build
- .gitlab-ci/run-tests.sh _build x11
fedora-mingw64:
extends: .build-fedora-default
stage: build
needs: []
before_script:
- sudo dnf install -y
mingw64-filesystem
mingw64-gcc
mingw64-binutils
mingw64-cairo
mingw64-gdk-pixbuf
mingw64-gstreamer1-plugins-bad-free
mingw64-glib2
mingw64-libepoxy
mingw64-pango
# mingw64-graphene (rawhide)
script:
- .gitlab-ci/show-info-linux.sh
- meson subprojects update
- mkdir _build && cd _build
- mingw64-meson -Dintrospection=disabled -Dgraphene:introspection=disabled
- ninja
installed-tests:
extends: .build-fedora-default
stage: build
@@ -292,18 +269,6 @@ flatpak-main:icon-browser:
variables:
APPID: org.gtk.IconBrowser4
flatpak-manual:node-editor:
extends: .flatpak-manual
needs: []
variables:
APPID: org.gtk.gtk4.NodeEditor
flatpak-main:node-editor:
extends: .flatpak-main
needs: []
variables:
APPID: org.gtk.gtk4.NodeEditor
# Publish the demo apps to the GNOME Nightly repo
# https://wiki.gnome.org/Apps/Nightly
# https://gitlab.gnome.org/GNOME/Initiatives/-/wikis/DevOps-with-Flatpak
@@ -322,11 +287,6 @@ nightly icon-browser:
dependencies: ['flatpak-main:icon-browser']
needs: ['flatpak-main:icon-browser']
nightly node-editor:
extends: '.publish_nightly'
dependencies: ['flatpak-main:node-editor']
needs: ['flatpak-main:node-editor']
static-scan:
image: $FEDORA_IMAGE
stage: analysis
+1 -1
View File
@@ -16,7 +16,7 @@ flatpak-builder \
flatpak build ${builddir} meson \
--prefix=/app \
--libdir=/app/lib \
--buildtype=debugoptimized \
--buildtype=release \
-Dx11-backend=true \
-Dwayland-backend=true \
-Dbuild-tests=false \
+19
View File
@@ -38,6 +38,25 @@ mkdir -p _ccache
export CCACHE_BASEDIR="$(pwd)"
export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache"
# https://gitlab.gnome.org/GNOME/gtk/-/issues/2243
# https://gitlab.gnome.org/GNOME/gtk/-/issues/3002
if ! pkg-config --atleast-version=2.66.0 glib-2.0; then
git clone https://gitlab.gnome.org/GNOME/glib.git _glib
meson setup _glib_build _glib
meson compile -C _glib_build
meson install -C _glib_build
fi
pkg-config --modversion glib-2.0
if ! pkg-config --atleast-version=1.50.0 pango; then
git clone https://gitlab.gnome.org/GNOME/pango.git _pango
meson setup _pango_build _pango
meson compile -C _pango_build
meson install -C _pango_build
fi
pkg-config --modversion pango
# Build
ccache --zero-stats
ccache --show-stats
-148
View File
@@ -1,151 +1,3 @@
Overview of Changes in 4.8.0, 06-09-2022
========================================
* GtkTreeView:
- Fix a problem with scrolling animations
- Fix some event handling problems
- Drop unreachable code
* GtkText:
- Respect the no-emoji input hint fully
* GtkEmojiChooser:
- Fix arrow key navigation
* GtkFontChooser:
- Improve the handling of OpenType font features
* GtkTreeListModel:
- Fix handling of collapsed child nodes
* GtkInscription:
- Fix accessible name
* Theme:
- Fix placeholder text in HighContrast
* Increase the memory limit for the jpeg loader to 300M
* Miscellaneous memory leak fixes
* Wayland:
- Refator handling of text protocol client updates
* Windows:
- Support high-resolution scroll wheel events
- Generate GdkWin32.gir
- Implement color picking
* Translation updates
Abkhazian
Basque
Brazilian Portuguese
Bulgarian
Catalan
Chinese (China)
Croatian
Czech
Danish
Dutch
Galician
Georgian
German
Hungarian
Icelandic
Indonesian
Korean
Latvian
Lithuanian
Persian
Polish
Portuguese
Russian
Serbian
Spanish
Swedish
Turkish
Ukrainian
Overview of Changes in 4.7.2, 10-08-2022
========================================
* GtkTextView:
- Fix child positioning with gutters
* GtkText:
- Update placeholder visibility when necessary
* GtkPicture:
- Add a content-fit property
* GtkPopover:
- Fix a size allocation problem with the arrow
* GtkTreeView:
- Fix a problem with DND
* GtkTreePopover:
- Support scrolling
* GtkGridView:
- Fix issues with rubberband selection
* GtkLabel:
- Add a tabs property
* GtkSnapshot:
- Make GtkSnapshot work from bindings
* GtkScrolledWindow:
- Scroll at a reasonable speed
* GtkPaned:
- Avoid an infinite loop
* GtkWindow:
- Improve generation and handling of crossing events
* CSS:
- Fix handling of certain transform values
* Media support:
- Add audio support to the ffmpeg backend
- Avoid oom with pathological jpeg images
* GDK:
- Fix handling of touchpad hold events
- Add support for hi-resolution scroll events
* X11:
- Fix preferred action for DND
* Windows:
- Fix DND
* List models:
- Fix items-changed emission
- Add more list model tests
* Demos:
- Add a winning sound to game demos
- Make app icons work uninstalled
* Translation updates:
Abkhazian
Basque
Catalan
Georgian
German
Indonesian
Occitan
Persian
Portuguese
Russian
Spanish
Ukrainian
Overview of Changes in 4.7.1, 12-07-2022
========================================
@@ -1,138 +0,0 @@
{
"app-id" : "org.gtk.gtk4.NodeEditor",
"runtime" : "org.gnome.Platform",
"runtime-version" : "master",
"sdk" : "org.gnome.Sdk",
"command" : "gtk4-node-editor",
"tags" : [
"devel",
"development",
"nightly"
],
"desktop-file-name-prefix" : "(Development) ",
"finish-args" : [
"--device=dri",
"--share=ipc",
"--socket=fallback-x11",
"--socket=wayland",
"--talk-name=org.gtk.vfs",
"--talk-name=org.gtk.vfs.*"
],
"cleanup" : [
"/include",
"/lib/pkgconfig",
"/share/pkgconfig",
"/share/aclocal",
"/man",
"/share/man",
"/share/gtk-doc",
"*.la",
".a",
"/lib/girepository-1.0",
"/share/gir-1.0",
"/share/doc"
],
"modules" : [
{
"name" : "wayland",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"-Ddocumentation=false"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.freedesktop.org/wayland/wayland.git",
"branch" : "main"
}
]
},
{
"name" : "graphene",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dtests=false"
],
"sources" : [
{
"type" : "git",
"url" : "https://github.com/ebassi/graphene.git"
}
]
},
{
"name" : "libsass",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib"
],
"sources" : [
{
"type" : "git",
"url" : "https://github.com/lazka/libsass.git",
"branch" : "meson"
}
]
},
{
"name" : "sassc",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib"
],
"sources" : [
{
"type" : "git",
"url" : "https://github.com/lazka/sassc.git",
"branch" : "meson"
}
]
},
{
"name" : "pango",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/pango.git",
"branch" : "main"
}
]
},
{
"name" : "gtk",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dvulkan=disabled",
"-Dbuildtype=debugoptimized",
"-Dprofile=devel"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/gtk.git",
"branch" : "main"
}
]
}
],
"build-options" : {
"env" : {
"DBUS_SESSION_BUS_ADDRESS" : "''",
"GSK_RENDERER" : "opengl",
"GDK_DEBUG" : "vulkan-disable",
"G_ENABLE_DEBUG" : "true"
}
}
}
-2
View File
@@ -428,8 +428,6 @@
<file>icons/16x16/emotes/face-laugh-symbolic.symbolic.png</file>
<file>icons/16x16/status/battery-caution-charging-symbolic.symbolic.png</file>
<file>icons/16x16/categories/applications-other.png</file>
<file>icons/48x48/status/starred.png</file>
<file alias="icons/scalable/apps/org.gtk.Demo4.svg">data/scalable/apps/org.gtk.Demo4.svg</file>
</gresource>
<gresource prefix="/org/gtk/Demo4/gtk">
<file preprocess="xml-stripblanks">help-overlay.ui</file>
+65
View File
@@ -0,0 +1,65 @@
--- demos/gtk-demo/font_features.c
+++ demos/gtk-demo/font_features.c
@@ -434,7 +434,7 @@ static void
update_display (void)
{
GString *s;
- const char *text;
+ char *text;
gboolean has_feature;
GtkTreeIter iter;
GtkTreeModel *model;
@@ -452,8 +452,12 @@ update_display (void)
gboolean do_waterfall;
GString *waterfall;
char *palette;
+ GtkTextBuffer *buffer;
+ GtkTextIter start_iter, end_iter;
- text = gtk_editable_get_text (GTK_EDITABLE (demo->the_entry));
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (demo->the_entry));
+ gtk_text_buffer_get_bounds (buffer, &start_iter, &end_iter);
+ text = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE);
text_len = strlen (text);
do_waterfall = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (demo->waterfall_toggle));
@@ -631,6 +635,8 @@ update_display (void)
pango2_font_description_free (desc);
g_free (features);
pango2_attr_list_unref (attrs);
+
+ g_free (text);
}
static Pango2Font *
@@ -1603,8 +1609,12 @@ font_features_toggle_edit (void)
{
if (strcmp (gtk_stack_get_visible_child_name (GTK_STACK (demo->stack)), "entry") != 0)
{
+ GtkTextBuffer *buffer;
+ GtkTextIter start, end;
g_free (demo->text);
- demo->text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (demo->the_entry)));
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (demo->the_entry));
+ gtk_text_buffer_get_bounds (buffer, &start, &end);
+ demo->text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
gtk_stack_set_visible_child_name (GTK_STACK (demo->stack), "entry");
gtk_widget_grab_focus (demo->the_entry);
gtk_adjustment_set_value (gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (demo->swin)), 0);
@@ -1632,7 +1642,7 @@ entry_key_press (GtkEventController *controller,
{
if (keyval == GDK_KEY_Escape)
{
- gtk_editable_set_text (GTK_EDITABLE (entry), demo->text);
+ gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (demo->the_entry)), demo->text, -1);
return GDK_EVENT_STOP;
}
@@ -1701,7 +1711,6 @@ do_font_features (GtkWidget *do_widget)
basic_value_changed (demo->line_height_adjustment, demo->line_height_entry);
controller = gtk_event_controller_key_new ();
- g_object_set_data_full (G_OBJECT (demo->the_entry), "controller", g_object_ref (controller), g_object_unref);
g_signal_connect (controller, "key-pressed", G_CALLBACK (entry_key_press), demo->the_entry);
gtk_widget_add_controller (demo->the_entry, controller);
-1
View File
@@ -223,7 +223,6 @@ static void
destroy_gear (struct gear *g)
{
g_free (g->strips);
g_free (g->vertices);
g_free (g);
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

+1 -28
View File
@@ -5,7 +5,6 @@
* small sliding puzzle game.
*/
#include "config.h"
#include <gtk/gtk.h>
/* Include the header for the puzzle piece */
@@ -25,30 +24,6 @@ static guint height = 3;
static guint pos_x;
static guint pos_y;
static void
ended (GObject *object)
{
g_object_unref (object);
}
static void
celebrate (gboolean win)
{
char *path;
GtkMediaStream *stream;
if (win)
path = g_build_filename (GTK_DATADIR, "sounds", "freedesktop", "stereo", "complete.oga", NULL);
else
path = g_build_filename (GTK_DATADIR, "sounds", "freedesktop", "stereo", "dialog-error.oga", NULL);
stream = gtk_media_file_new_for_filename (path);
gtk_media_stream_set_volume (stream, 1.0);
gtk_media_stream_play (stream);
g_signal_connect (stream, "notify::ended", G_CALLBACK (ended), NULL);
g_free (path);
}
static gboolean
move_puzzle (GtkWidget *grid,
int dx,
@@ -182,8 +157,6 @@ check_solved (GtkWidget *grid)
picture = gtk_grid_get_child_at (GTK_GRID (grid), pos_x, pos_y);
gtk_picture_set_paintable (GTK_PICTURE (picture), piece);
celebrate (TRUE);
return TRUE;
}
@@ -357,7 +330,7 @@ start_puzzle (GdkPaintable *paintable)
x, y,
width, height);
picture = gtk_picture_new_for_paintable (piece);
gtk_picture_set_content_fit (GTK_PICTURE (picture), GTK_CONTENT_FIT_FILL);
gtk_picture_set_keep_aspect_ratio (GTK_PICTURE (picture), FALSE);
gtk_grid_attach (GTK_GRID (grid),
picture,
x, y,
+1
View File
@@ -216,6 +216,7 @@
<child>
<object class="GtkPicture" id="picture">
<property name="can-shrink">0</property>
<property name="keep-aspect-ratio">1</property>
<property name="halign">center</property>
<property name="valign">center</property>
<child>
+17 -19
View File
@@ -13,8 +13,6 @@ Each node has its own `<node-name>` and supports a custom set of properties, eac
When serializing and the value of a property equals the default value, this value will not be serialized. Serialization aims to produce an output as small as possible.
To embed newlines in strings, use \A. To break a long string into multiple lines, escape the newline with a \.
# Nodes
### container
@@ -137,23 +135,6 @@ Creates a node like `gsk_cross_fade_node_new()` with the given properties.
Creates a node like `gsk_debug_node_new()` with the given properties.
### glshader
| property | syntax | default | printed |
| ---------- | ------------------ | ---------------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| sourcecode | `<string>` | "" | always |
| args | `<uniform values>` | none | non-default |
| child1 | `<node>` | none | non-default |
| child2 | `<node>` | none | non-default |
| child3 | `<node>` | none | non-default |
| child4 | `<node>` | none | non-default |
Creates a GLShader node. The `sourcecode` must be a GLSL fragment shader.
The `args` must match the uniforms of simple types declared in that shader,
in order and comma-separated. The `child` properties must match the sampler
uniforms in the shader.
### inset-shadow
| property | syntax | default | printed |
@@ -305,3 +286,20 @@ representation for this texture is `url("data:image/png;base64,iVBORw0KGgoAAAANS
| transform| `<transform>` | none | non-default |
Creates a node like `gsk_transform_node_new()` with the given properties.
### glshader
| property | syntax | default | printed |
| ---------- | ------------------ | ---------------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| sourcecode | `<string>` | "" | always |
| args | `<uniform values>` | none | non-default |
| child1 | `<node>` | none | non-default |
| child2 | `<node>` | none | non-default |
| child3 | `<node>` | none | non-default |
| child4 | `<node>` | none | non-default |
Creates a GLShader node. The `sourcecode` must be a GLSL fragment shader.
The `args` must match the uniforms of simple types declared in that shader,
in order and comma-separated. The `child` properties must match the sampler
uniforms in the shader.
@@ -111,8 +111,6 @@
<file>icons/scalable/status/weather-showers-symbolic.svg</file>
<file>icons/scalable/status/weather-snow-symbolic.svg</file>
<file alias='icons/scalable/apps/org.gtk.WidgetFactory4.svg'>data/scalable/apps/org.gtk.WidgetFactory4.svg</file>
</gresource>
<gresource prefix="/org/gtk/WidgetFactory4">
<file>gtk-logo.webm</file>
-1
View File
@@ -1265,7 +1265,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="child">
<object class="GtkPicture">
<property name="file">resource:///org/gtk/WidgetFactory4/sunset.jpg</property>
<property name="content-fit">cover</property>
<child>
<object class="GtkDragSource">
<signal name="prepare" handler="on_picture_drag_prepare" swapped="no"/>
-14
View File
@@ -339,20 +339,6 @@ using and the GDK backend supports them:
`vulkan`
: Selects the Vulkan renderer
Note that on Windows, if one is running Nahimic 3 on a system with
nVidia graphics, one needs to stop the "Nahimic service" or insert
the GTK application into the Nahimic blacklist, as noted in
https://www.nvidia.com/en-us/geforce/forums/game-ready-drivers/13/297952/nahimic-and-nvidia-drivers-conflict/2334568/, or use the cairo renderer (at the cost of being unable to use
OpenGL features), or use GDK_DEBUG=gl-gles if you know that GLES
support is enabled for the build.
This is a known issue, as the above link indicates, and affects quite
a number of applications--sadly, since this issue lies within the
nVidia graphics driver and/or the Nahimic 3 code, we are not able
to rememdy this on the GTK side; the best bet before trying the above
workarounds is to try to update your graphics drivers and Nahimic
installation.
### `GTK_CSD`
The default value of this environment variable is `1`. If changed
-4
View File
@@ -47,10 +47,6 @@
#include <stdio.h>
#include <string.h>
#if !GLIB_CHECK_VERSION (2, 67, 3)
# define g_memdup2(mem,size) g_memdup((mem), (size))
#endif
/* Forward declarations */
static void gdk_broadway_surface_finalize (GObject *object);
-4
View File
@@ -59,8 +59,4 @@ void gdk_source_set_static_name_by_id (guint tag,
#define g_source_set_static_name(source, name) g_source_set_name ((source), (name))
#endif
#ifndef I_
#define I_(string) g_intern_static_string (string)
#endif
#endif /* __GDK__PRIVATE_H__ */
+1 -2
View File
@@ -29,7 +29,6 @@
#include "gdkintl.h"
#include "gdkpipeiostreamprivate.h"
#include "gdktexture.h"
#include "gdk-private.h"
#include <gobject/gvaluecollector.h>
@@ -409,7 +408,7 @@ gdk_clipboard_class_init (GdkClipboardClass *class)
* Emitted when the clipboard changes ownership.
*/
signals[CHANGED] =
g_signal_new (I_("changed"),
g_signal_new ("changed",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdkClipboardClass, changed),
+4 -50
View File
@@ -184,7 +184,7 @@ gdk_content_formats_new_for_gtype (GType type)
* @string: the string to parse
*
* Parses the given @string into `GdkContentFormats` and
* returns the formats.
* returns the formats.
*
* Strings printed via [method@Gdk.ContentFormats.to_string]
* can be read in again successfully using this function.
@@ -540,7 +540,7 @@ gdk_content_formats_get_gtypes (const GdkContentFormats *formats,
if (n_gtypes)
*n_gtypes = formats->n_gtypes;
return formats->gtypes;
}
@@ -567,7 +567,7 @@ gdk_content_formats_get_mime_types (const GdkContentFormats *formats,
if (n_mime_types)
*n_mime_types = formats->n_mime_types;
return formats->mime_types;
}
@@ -663,7 +663,7 @@ gdk_content_formats_builder_unref (GdkContentFormatsBuilder *builder)
if (builder->ref_count > 0)
return;
gdk_content_formats_builder_clear (builder);
g_slice_free (GdkContentFormatsBuilder, builder);
}
@@ -862,50 +862,4 @@ gdk_file_list_get_files (GdkFileList *file_list)
return g_slist_copy ((GSList *) file_list);
}
/**
* gdk_file_list_new_from_list:
* @files: (element-type GFile): a list of files
*
* Creates a new files list container from a singly linked list of
* `GFile` instances.
*
* This function is meant to be used by language bindings
*
* Returns: (transfer full): the newly created files list
*
* Since: 4.8
*/
GdkFileList *
gdk_file_list_new_from_list (GSList *files)
{
return gdk_file_list_copy (files);
}
/**
* gdk_file_list_new_from_array:
* @files: (array length=n_files): the files to add to the list
* @n_files: the number of files in the array
*
* Creates a new `GdkFileList` for the given array of files.
*
* This function is meant to be used by language bindings.
*
* Returns: (transfer full): the newly create files list
*
* Since: 4.8
*/
GdkFileList *
gdk_file_list_new_from_array (GFile **files,
gsize n_files)
{
if (files == NULL || n_files == 0)
return NULL;
GSList *res = NULL;
for (gssize i = n_files - 1; i >= 0; i--)
res = g_slist_prepend (res, g_object_ref (files[i]));
return (GdkFileList *) res;
}
/* }}} */
-5
View File
@@ -122,11 +122,6 @@ typedef struct _GdkFileList GdkFileList;
GDK_AVAILABLE_IN_4_6
GSList * gdk_file_list_get_files (GdkFileList *file_list);
GDK_AVAILABLE_IN_4_8
GdkFileList * gdk_file_list_new_from_list (GSList *files);
GDK_AVAILABLE_IN_4_8
GdkFileList * gdk_file_list_new_from_array (GFile **files,
gsize n_files);
G_END_DECLS
+1 -2
View File
@@ -23,7 +23,6 @@
#include "gdkclipboard.h"
#include "gdkcontentformats.h"
#include "gdkintl.h"
#include "gdk-private.h"
/**
* GdkContentProvider:
@@ -198,7 +197,7 @@ gdk_content_provider_class_init (GdkContentProviderClass *class)
* Emitted whenever the content provided by this provider has changed.
*/
signals[CONTENT_CHANGED] =
g_signal_new (I_("content-changed"),
g_signal_new ("content-changed",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdkContentProviderClass, content_changed),
-67
View File
@@ -2368,75 +2368,10 @@ gdk_scroll_event_new_discrete (GdkSurface *surface,
GdkScrollDirection direction)
{
GdkScrollEvent *self = gdk_event_alloc (GDK_SCROLL, surface, device, time);
double delta_x = 0, delta_y = 0;
switch (direction)
{
case GDK_SCROLL_UP:
delta_y = -1;
break;
case GDK_SCROLL_DOWN:
delta_y = 1;
break;
case GDK_SCROLL_LEFT:
delta_x = -1;
break;
case GDK_SCROLL_RIGHT:
delta_x = 1;
break;
case GDK_SCROLL_SMOOTH:
default:
g_assert_not_reached ();
break;
}
self->tool = tool != NULL ? g_object_ref (tool) : NULL;
self->state = state;
self->direction = direction;
self->delta_x = delta_x;
self->delta_y = delta_y;
self->unit = GDK_SCROLL_UNIT_WHEEL;
return (GdkEvent *) self;
}
/*< private >
* gtk_scroll_event_new_value120:
* @surface: the `GdkSurface` of the event
* @device: the `GdkDevice` of the event
* @tool: (nullable): the tool that generated to event
* @time: the event serial
* @state: Flags to indicate the state of modifier keys and mouse buttons
* in events.
* @direction: scroll direction.
* @delta_x: delta on the X axis in the 120.0 scale
* @delta_x: delta on the Y axis in the 120.0 scale
*
* Creates a new discrete GdkScrollEvent for high resolution mouse wheels.
*
* Both axes send data in fractions of 120 where each multiple of 120
* amounts to one logical scroll event. Fractions of 120 indicate a wheel
* movement less than one detent.
*
* Returns: the newly created scroll event
*/
GdkEvent *
gdk_scroll_event_new_value120 (GdkSurface *surface,
GdkDevice *device,
GdkDeviceTool *tool,
guint32 time,
GdkModifierType state,
GdkScrollDirection direction,
double delta_x,
double delta_y)
{
GdkScrollEvent *self = gdk_event_alloc (GDK_SCROLL, surface, device, time);
self->tool = tool != NULL ? g_object_ref (tool) : NULL;
self->state = state;
self->direction = direction;
self->delta_x = delta_x / 120.0;
self->delta_y = delta_y / 120.0;
self->unit = GDK_SCROLL_UNIT_WHEEL;
return (GdkEvent *) self;
@@ -2676,7 +2611,6 @@ gdk_touchpad_event_new_pinch (GdkSurface *surface,
GdkEvent *
gdk_touchpad_event_new_hold (GdkSurface *surface,
GdkEventSequence *sequence,
GdkDevice *device,
guint32 time,
GdkModifierType state,
@@ -2689,7 +2623,6 @@ gdk_touchpad_event_new_hold (GdkSurface *surface,
self->state = state;
self->phase = phase;
self->sequence = sequence;
self->x = x;
self->y = y;
self->n_fingers = n_fingers;
-10
View File
@@ -495,15 +495,6 @@ GdkEvent * gdk_scroll_event_new_discrete (GdkSurface *surface,
GdkModifierType state,
GdkScrollDirection direction);
GdkEvent * gdk_scroll_event_new_value120 (GdkSurface *surface,
GdkDevice *device,
GdkDeviceTool *tool,
guint32 time,
GdkModifierType state,
GdkScrollDirection direction,
double delta_x,
double delta_y);
GdkEvent * gdk_touch_event_new (GdkEventType type,
GdkEventSequence *sequence,
GdkSurface *surface,
@@ -542,7 +533,6 @@ GdkEvent * gdk_touchpad_event_new_pinch (GdkSurface *surface,
double angle_delta);
GdkEvent * gdk_touchpad_event_new_hold (GdkSurface *surface,
GdkEventSequence *sequence,
GdkDevice *device,
guint32 time,
GdkModifierType state,
+1 -1
View File
@@ -50,7 +50,7 @@ typedef struct _GdkFrameClockClass GdkFrameClockClass;
* @GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS: corresponds to GdkFrameClock::flush-events. Should not be handled by applications.
* @GDK_FRAME_CLOCK_PHASE_BEFORE_PAINT: corresponds to GdkFrameClock::before-paint. Should not be handled by applications.
* @GDK_FRAME_CLOCK_PHASE_UPDATE: corresponds to GdkFrameClock::update.
* @GDK_FRAME_CLOCK_PHASE_LAYOUT: corresponds to GdkFrameClock::layout. Should not be handled by applications.
* @GDK_FRAME_CLOCK_PHASE_LAYOUT: corresponds to GdkFrameClock::layout. Should not be handled by applicatiosn.
* @GDK_FRAME_CLOCK_PHASE_PAINT: corresponds to GdkFrameClock::paint.
* @GDK_FRAME_CLOCK_PHASE_RESUME_EVENTS: corresponds to GdkFrameClock::resume-events. Should not be handled by applications.
* @GDK_FRAME_CLOCK_PHASE_AFTER_PAINT: corresponds to GdkFrameClock::after-paint. Should not be handled by applications.
+16
View File
@@ -199,6 +199,22 @@ gdk_keymap_init (GdkKeymap *keymap)
keymap->cache = g_hash_table_new (g_direct_hash, g_direct_equal);
}
/*< private >
* gdk_keymap_get_display:
* @keymap: a `GdkKeymap`
*
* Retrieves the `GdkDisplay` associated to the @keymap.
*
* Returns: (transfer none): a `GdkDisplay`
*/
GdkDisplay *
gdk_keymap_get_display (GdkKeymap *keymap)
{
g_return_val_if_fail (GDK_IS_KEYMAP (keymap), NULL);
return keymap->display;
}
/* Other key-handling stuff
*/
+2
View File
@@ -89,6 +89,8 @@ struct _GdkKeymap
GType gdk_keymap_get_type (void) G_GNUC_CONST;
GdkDisplay * gdk_keymap_get_display (GdkKeymap *keymap);
guint gdk_keymap_lookup_key (GdkKeymap *keymap,
const GdkKeymapKey *key);
gboolean gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
+2 -3
View File
@@ -22,7 +22,6 @@
#include "gdkpaintable.h"
#include "gdksnapshotprivate.h"
#include "gdk-private.h"
/* HACK: So we don't need to include any (not-yet-created) GSK or GTK headers */
void gtk_snapshot_push_debug (GdkSnapshot *snapshot,
@@ -171,7 +170,7 @@ gdk_paintable_default_init (GdkPaintableInterface *iface)
* the icon theme for an icon changing.
*/
signals[INVALIDATE_CONTENTS] =
g_signal_new (I_("invalidate-contents"),
g_signal_new ("invalidate-contents",
GDK_TYPE_PAINTABLE,
G_SIGNAL_RUN_LAST,
0,
@@ -195,7 +194,7 @@ gdk_paintable_default_init (GdkPaintableInterface *iface)
* the contents of a toplevel surface being resized.
*/
signals[INVALIDATE_SIZE] =
g_signal_new (I_("invalidate-size"),
g_signal_new ("invalidate-size",
GDK_TYPE_PAINTABLE,
G_SIGNAL_RUN_LAST,
0,
-2
View File
@@ -75,8 +75,6 @@ gdk_io_pipe_unref (GdkIOPipe *pipe)
g_cond_clear (&pipe->cond);
g_mutex_clear (&pipe->mutex);
g_slice_free (GdkIOPipe, pipe);
}
static void
+1 -2
View File
@@ -24,7 +24,6 @@
#include "gdkdisplay.h"
#include "gdkenumtypes.h"
#include "gdkintl.h"
#include "gdk-private.h"
#include <graphene-gobject.h>
#include <math.h>
@@ -248,7 +247,7 @@ gdk_toplevel_default_init (GdkToplevelInterface *iface)
* will result in an arbitrary size being used as a result.
*/
signals[COMPUTE_SIZE] =
g_signal_new (I_("compute-size"),
g_signal_new ("compute-size",
GDK_TYPE_TOPLEVEL,
G_SIGNAL_RUN_LAST,
0,
-5
View File
@@ -161,8 +161,6 @@ gdk_load_jpeg (GBytes *input_bytes,
jpeg_create_decompress (&info);
info.mem->max_memory_to_use = 300 * 1024 * 1024;
jpeg_mem_src (&info,
g_bytes_get_data (input_bytes, NULL),
g_bytes_get_size (input_bytes));
@@ -274,7 +272,6 @@ gdk_save_jpeg (GdkTexture *texture)
info.err = jpeg_std_error (&err);
jpeg_create_compress (&info);
info.image_width = width;
info.image_height = height;
info.input_components = 3;
@@ -283,8 +280,6 @@ gdk_save_jpeg (GdkTexture *texture)
jpeg_set_defaults (&info);
jpeg_set_quality (&info, 75, TRUE);
info.mem->max_memory_to_use = 300 * 1024 * 1024;
jpeg_mem_dest (&info, &data, &size);
memtex = gdk_memory_texture_from_texture (texture,
+1 -2
View File
@@ -184,8 +184,7 @@ gdk_load_png (GBytes *bytes,
if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb (png);
if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
if (color_type == PNG_COLOR_TYPE_GRAY)
png_set_expand_gray_1_2_4_to_8 (png);
if (png_get_valid (png, info, PNG_INFO_tRNS))
+1 -3
View File
@@ -215,7 +215,7 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
cairo_surface_t *surface;
struct wl_buffer *buffer;
texture = g_object_ref (gdk_cursor_get_texture (cursor));
texture = gdk_cursor_get_texture (cursor);
from_texture:
surface = g_hash_table_lookup (display->cursor_surface_cache, cursor);
@@ -245,8 +245,6 @@ from_texture:
buffer = _gdk_wayland_shm_surface_get_wl_buffer (surface);
wl_buffer_add_listener (buffer, &buffer_listener, surface);
g_object_unref (texture);
return buffer;
}
+84 -93
View File
@@ -112,7 +112,7 @@ struct _GdkWaylandPointerFrameData
/* Specific to the scroll event */
double delta_x, delta_y;
int32_t value120_x, value120_y;
int32_t discrete_x, discrete_y;
gint8 is_scroll_stop;
enum wl_pointer_axis_source source;
};
@@ -1383,54 +1383,20 @@ static GdkDevice * get_scroll_device (GdkWaylandSeat *seat,
static void
flush_discrete_scroll_event (GdkWaylandSeat *seat,
gint value120_x,
gint value120_y)
GdkScrollDirection direction)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
GdkEvent *event = NULL;
GdkEvent *event;
GdkDevice *source;
GdkScrollDirection direction;
if (value120_x > 0)
direction = GDK_SCROLL_LEFT;
else if (value120_x < 0)
direction = GDK_SCROLL_RIGHT;
else if (value120_y > 0)
direction = GDK_SCROLL_DOWN;
else
direction = GDK_SCROLL_UP;
source = get_scroll_device (seat, seat->pointer_info.frame.source);
event = gdk_scroll_event_new_discrete (seat->pointer_info.focus,
source,
NULL,
seat->pointer_info.time,
device_get_modifiers (seat->logical_pointer),
direction);
if (display_wayland->seat_version >= WL_POINTER_AXIS_VALUE120_SINCE_VERSION)
{
event = gdk_scroll_event_new_value120 (seat->pointer_info.focus,
source,
NULL,
seat->pointer_info.time,
device_get_modifiers (seat->logical_pointer),
direction,
value120_x,
value120_y);
}
else
{
gint discrete_x = value120_x / 120;
gint discrete_y = value120_y / 120;
if (discrete_x != 0 || discrete_y != 0)
{
event = gdk_scroll_event_new_discrete (seat->pointer_info.focus,
source,
NULL,
seat->pointer_info.time,
device_get_modifiers (seat->logical_pointer),
direction);
}
}
if (event)
_gdk_wayland_display_deliver_event (seat->display, event);
_gdk_wayland_display_deliver_event (seat->display, event);
}
static void
@@ -1461,13 +1427,22 @@ flush_scroll_event (GdkWaylandSeat *seat,
{
gboolean is_stop = FALSE;
if (pointer_frame->value120_x || pointer_frame->value120_y)
if (pointer_frame->discrete_x || pointer_frame->discrete_y)
{
flush_discrete_scroll_event (seat,
pointer_frame->value120_x,
pointer_frame->value120_y);
pointer_frame->value120_x = 0;
pointer_frame->value120_y = 0;
GdkScrollDirection direction;
if (pointer_frame->discrete_x > 0)
direction = GDK_SCROLL_LEFT;
else if (pointer_frame->discrete_x < 0)
direction = GDK_SCROLL_RIGHT;
else if (pointer_frame->discrete_y > 0)
direction = GDK_SCROLL_DOWN;
else
direction = GDK_SCROLL_UP;
flush_discrete_scroll_event (seat, direction);
pointer_frame->discrete_x = 0;
pointer_frame->discrete_y = 0;
}
else if (pointer_frame->is_scroll_stop ||
pointer_frame->delta_x != 0 ||
@@ -1487,8 +1462,8 @@ flush_scroll_event (GdkWaylandSeat *seat,
is_stop);
}
pointer_frame->value120_x = 0;
pointer_frame->value120_y = 0;
pointer_frame->discrete_x = 0;
pointer_frame->discrete_y = 0;
pointer_frame->delta_x = 0;
pointer_frame->delta_y = 0;
pointer_frame->is_scroll_stop = FALSE;
@@ -1539,6 +1514,8 @@ pointer_handle_enter (void *data,
if (!GDK_IS_SURFACE (wl_surface_get_user_data (surface)))
return;
_gdk_wayland_display_update_serial (display_wayland, serial);
seat->pointer_info.focus = wl_surface_get_user_data (surface);
g_object_ref (seat->pointer_info.focus);
@@ -1580,9 +1557,16 @@ pointer_handle_leave (void *data,
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
GdkDeviceGrabInfo *grab;
if (!surface)
return;
if (!GDK_IS_SURFACE (wl_surface_get_user_data (surface)))
return;
if (!seat->pointer_info.focus)
return;
_gdk_wayland_display_update_serial (display_wayland, serial);
grab = _gdk_display_get_last_device_grab (seat->display,
seat->logical_pointer);
@@ -1682,6 +1666,8 @@ pointer_handle_button (void *data,
if (!seat->pointer_info.focus)
return;
_gdk_wayland_display_update_serial (display, serial);
switch (button)
{
case BTN_LEFT:
@@ -1887,10 +1873,10 @@ pointer_handle_axis_discrete (void *data,
switch (axis)
{
case WL_POINTER_AXIS_VERTICAL_SCROLL:
pointer_frame->value120_y = value * 120;
pointer_frame->discrete_y = value;
break;
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
pointer_frame->value120_x = value * 120;
pointer_frame->discrete_x = value;
break;
default:
g_return_if_reached ();
@@ -1901,35 +1887,6 @@ pointer_handle_axis_discrete (void *data,
get_axis_name (axis), value, seat));
}
static void
pointer_handle_axis_value120 (void *data,
struct wl_pointer *pointer,
uint32_t axis,
int32_t value)
{
GdkWaylandSeat *seat = data;
GdkWaylandPointerFrameData *pointer_frame = &seat->pointer_info.frame;
if (!seat->pointer_info.focus)
return;
switch (axis)
{
case WL_POINTER_AXIS_VERTICAL_SCROLL:
pointer_frame->value120_y = value;
break;
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
pointer_frame->value120_x = value;
break;
default:
g_return_if_reached ();
}
GDK_SEAT_NOTE (seat, EVENTS,
g_message ("value120 scroll, axis %s, value %d, seat %p",
get_axis_name (axis), value, seat));
}
static int
get_active_layout (GdkKeymap *keymap)
{
@@ -2029,6 +1986,7 @@ keyboard_handle_enter (void *data,
{
GdkWaylandSeat *seat = data;
GdkEvent *event;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
if (!surface)
return;
@@ -2036,6 +1994,8 @@ keyboard_handle_enter (void *data,
if (!GDK_IS_SURFACE (wl_surface_get_user_data (surface)))
return;
_gdk_wayland_display_update_serial (display, serial);
seat->keyboard_focus = wl_surface_get_user_data (surface);
g_object_ref (seat->keyboard_focus);
seat->repeat_key = 0;
@@ -2061,6 +2021,7 @@ keyboard_handle_leave (void *data,
{
GdkWaylandSeat *seat = data;
GdkEvent *event;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
if (!seat->keyboard_focus)
return;
@@ -2071,6 +2032,8 @@ keyboard_handle_leave (void *data,
*/
stop_key_repeat (seat);
_gdk_wayland_display_update_serial (display, serial);
event = gdk_focus_event_new (seat->keyboard_focus,
seat->logical_keyboard,
FALSE);
@@ -2309,6 +2272,7 @@ keyboard_handle_key (void *data,
uint32_t state_w)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
if (!seat->keyboard_focus)
return;
@@ -2316,6 +2280,7 @@ keyboard_handle_key (void *data,
seat->keyboard_time = time;
seat->keyboard_key_serial = serial;
seat->repeat_count = 0;
_gdk_wayland_display_update_serial (display, serial);
deliver_key_event (data, time, key + 8, state_w, FALSE);
}
@@ -2505,9 +2470,12 @@ touch_handle_down (void *data,
wl_fixed_t y)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
GdkWaylandTouchData *touch;
GdkEvent *event;
_gdk_wayland_display_update_serial (display, serial);
if (!wl_surface)
return;
@@ -2551,9 +2519,12 @@ touch_handle_up (void *data,
int32_t id)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
GdkWaylandTouchData *touch;
GdkEvent *event;
_gdk_wayland_display_update_serial (display, serial);
touch = gdk_wayland_seat_get_touch (seat, id);
if (!touch)
return;
@@ -2733,6 +2704,9 @@ gesture_swipe_begin (void *data,
uint32_t fingers)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
_gdk_wayland_display_update_serial (display, serial);
emit_gesture_swipe_event (seat,
GDK_TOUCHPAD_GESTURE_PHASE_BEGIN,
@@ -2765,8 +2739,11 @@ gesture_swipe_end (void *data,
int32_t cancelled)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
GdkTouchpadGesturePhase phase;
_gdk_wayland_display_update_serial (display, serial);
phase = (cancelled) ?
GDK_TOUCHPAD_GESTURE_PHASE_CANCEL :
GDK_TOUCHPAD_GESTURE_PHASE_END;
@@ -2829,7 +2806,9 @@ gesture_pinch_begin (void *data,
uint32_t fingers)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
_gdk_wayland_display_update_serial (display, serial);
emit_gesture_pinch_event (seat,
GDK_TOUCHPAD_GESTURE_PHASE_BEGIN,
time, fingers, 0, 0, 1, 0);
@@ -2864,8 +2843,11 @@ gesture_pinch_end (void *data,
int32_t cancelled)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
GdkTouchpadGesturePhase phase;
_gdk_wayland_display_update_serial (display, serial);
phase = (cancelled) ?
GDK_TOUCHPAD_GESTURE_PHASE_CANCEL :
GDK_TOUCHPAD_GESTURE_PHASE_END;
@@ -2888,11 +2870,7 @@ emit_gesture_hold_event (GdkWaylandSeat *seat,
seat->pointer_info.time = _time;
if (phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN)
seat->pointer_info.touchpad_event_sequence++;
event = gdk_touchpad_event_new_hold (seat->pointer_info.focus,
GDK_SLOT_TO_EVENT_SEQUENCE (seat->pointer_info.touchpad_event_sequence),
seat->logical_pointer,
_time,
device_get_modifiers (seat->logical_pointer),
@@ -2923,6 +2901,9 @@ gesture_hold_begin (void *data,
uint32_t fingers)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
_gdk_wayland_display_update_serial (display, serial);
emit_gesture_hold_event (seat,
GDK_TOUCHPAD_GESTURE_PHASE_BEGIN,
@@ -2938,8 +2919,11 @@ gesture_hold_end (void *data,
int32_t cancelled)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
GdkTouchpadGesturePhase phase;
_gdk_wayland_display_update_serial (display, serial);
phase = (cancelled) ?
GDK_TOUCHPAD_GESTURE_PHASE_CANCEL :
GDK_TOUCHPAD_GESTURE_PHASE_END;
@@ -3124,7 +3108,6 @@ static const struct wl_pointer_listener pointer_listener = {
pointer_handle_axis_source,
pointer_handle_axis_stop,
pointer_handle_axis_discrete,
pointer_handle_axis_value120,
};
static const struct wl_keyboard_listener keyboard_listener = {
@@ -3647,6 +3630,8 @@ tablet_tool_handle_proximity_in (void *data,
{
GdkWaylandTabletToolData *tool = data;
GdkWaylandTabletData *tablet = zwp_tablet_v2_get_user_data (wp_tablet);
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
GdkSurface *surface;
GdkEvent *event;
@@ -3663,6 +3648,7 @@ tablet_tool_handle_proximity_in (void *data,
tool->current_tablet = tablet;
tablet->current_tool = tool;
_gdk_wayland_display_update_serial (display_wayland, serial);
tablet->pointer_info.enter_serial = serial;
tablet->pointer_info.focus = g_object_ref (surface);
@@ -3683,9 +3669,9 @@ tablet_tool_handle_proximity_in (void *data,
gdk_wayland_surface_get_wl_output (surface));
pointer_surface_update_scale (tablet->logical_device);
GDK_SEAT_NOTE (tablet->seat, EVENTS,
GDK_SEAT_NOTE (seat, EVENTS,
g_message ("proximity in, seat %p surface %p tool %d",
tablet->seat, tablet->pointer_info.focus,
seat, tablet->pointer_info.focus,
gdk_device_tool_get_tool_type (tool->tool)));
}
@@ -3762,10 +3748,13 @@ tablet_tool_handle_down (void *data,
{
GdkWaylandTabletToolData *tool = data;
GdkWaylandTabletData *tablet = tool->current_tablet;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tool->seat);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
if (!tablet || !tablet->pointer_info.focus)
return;
_gdk_wayland_display_update_serial (display_wayland, serial);
tablet->pointer_info.press_serial = serial;
tablet_create_button_event_frame (tablet, GDK_BUTTON_PRESS, GDK_BUTTON_PRIMARY);
@@ -5316,13 +5305,15 @@ gdk_wayland_device_set_selection (GdkDevice *gdk_device,
struct wl_data_source *source)
{
GdkWaylandSeat *seat;
guint32 serial;
GdkWaylandDisplay *display_wayland;
g_return_if_fail (GDK_IS_WAYLAND_DEVICE (gdk_device));
seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (gdk_device));
serial = _gdk_wayland_seat_get_implicit_grab_serial (GDK_SEAT (seat), NULL);
wl_data_device_set_selection (seat->data_device, source, serial);
display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
wl_data_device_set_selection (seat->data_device, source,
_gdk_wayland_display_get_serial (display_wayland));
}
/**
+18 -1
View File
@@ -145,6 +145,10 @@ zxdg_shell_v6_ping (void *data,
struct zxdg_shell_v6 *xdg_shell,
uint32_t serial)
{
GdkWaylandDisplay *display_wayland = data;
_gdk_wayland_display_update_serial (display_wayland, serial);
GDK_DISPLAY_NOTE (GDK_DISPLAY (data), EVENTS,
g_message ("ping, shell %p, serial %u\n", xdg_shell, serial));
@@ -232,7 +236,7 @@ _gdk_wayland_display_add_seat (GdkWaylandDisplay *display_wayland,
{
struct wl_seat *seat;
display_wayland->seat_version = MIN (version, 8);
display_wayland->seat_version = MIN (version, 7);
seat = wl_registry_bind (display_wayland->wl_registry,
id, &wl_seat_interface,
display_wayland->seat_version);
@@ -1120,6 +1124,19 @@ _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland)
}
guint32
_gdk_wayland_display_get_serial (GdkWaylandDisplay *display_wayland)
{
return display_wayland->serial;
}
void
_gdk_wayland_display_update_serial (GdkWaylandDisplay *display_wayland,
guint32 serial)
{
display_wayland->serial = serial;
}
/**
* gdk_wayland_display_get_wl_display: (skip)
* @display: (type GdkWaylandDisplay): a `GdkDisplay`
+3
View File
@@ -84,6 +84,9 @@ struct _GdkWaylandDisplay
/* Startup notification */
char *startup_notification_id;
/* Most recent serial */
guint32 serial;
uint32_t xdg_wm_base_id;
int xdg_wm_base_version;
uint32_t zxdg_shell_v6_id;
+2 -2
View File
@@ -393,8 +393,8 @@ _gdk_wayland_surface_drag_begin (GdkSurface *surface,
wl_data_device_start_drag (gdk_wayland_device_get_data_device (device),
drag_wayland->data_source,
gdk_wayland_surface_get_wl_surface (surface),
drag_wayland->dnd_wl_surface,
_gdk_wayland_seat_get_implicit_grab_serial (seat, NULL));
drag_wayland->dnd_wl_surface,
_gdk_wayland_display_get_serial (display_wayland));
cursor = gdk_drag_get_cursor (drag, gdk_drag_get_selected_action (drag));
gdk_drag_set_cursor (drag, cursor);
+1 -5
View File
@@ -263,8 +263,6 @@ gdk_wayland_primary_claim (GdkClipboard *clipboard,
GdkWaylandDisplay *wdisplay = GDK_WAYLAND_DISPLAY (gdk_clipboard_get_display (clipboard));
const char * const *mime_types;
gsize i, n_mime_types;
GdkSeat *seat;
guint32 serial;
gdk_wayland_primary_discard_offer (cb);
gdk_wayland_primary_discard_source (cb);
@@ -278,11 +276,9 @@ gdk_wayland_primary_claim (GdkClipboard *clipboard,
zwp_primary_selection_source_v1_offer (cb->source, mime_types[i]);
}
seat = gdk_display_get_default_seat (GDK_DISPLAY (wdisplay));
serial = _gdk_wayland_seat_get_implicit_grab_serial (seat, NULL);
zwp_primary_selection_device_v1_set_selection (cb->primary_data_device,
cb->source,
serial);
_gdk_wayland_display_get_serial (wdisplay));
}
return GDK_CLIPBOARD_CLASS (gdk_wayland_primary_parent_class)->claim (clipboard, formats, local, content);
+4
View File
@@ -170,6 +170,10 @@ GdkMonitor *gdk_wayland_display_get_monitor_for_output (GdkDisplay *displa
void _gdk_wayland_surface_set_grab_seat (GdkSurface *surface,
GdkSeat *seat);
guint32 _gdk_wayland_display_get_serial (GdkWaylandDisplay *display_wayland);
void _gdk_wayland_display_update_serial (GdkWaylandDisplay *display_wayland,
guint32 serial);
cairo_surface_t * _gdk_wayland_display_create_shm_surface (GdkWaylandDisplay *display,
int width,
int height,
+2 -2
View File
@@ -105,7 +105,7 @@ gdk_device_win32_query_state (GdkDevice *device,
hwndc = ChildWindowFromPoint (hwnd, point);
if (hwndc && hwndc != hwnd)
*child_window = gdk_win32_handle_table_lookup_ (hwndc);
*child_window = gdk_win32_handle_table_lookup (hwndc);
else
*child_window = NULL; /* Direct child unknown to gdk */
}
@@ -183,7 +183,7 @@ _gdk_device_win32_surface_at_position (GdkDevice *device,
if (!PtInRect (&rect, client_pt))
hwnd = NULL;
window = gdk_win32_handle_table_lookup_ (hwnd);
window = gdk_win32_handle_table_lookup (hwnd);
if (window && (win_x || win_y))
{
+2 -2
View File
@@ -96,7 +96,7 @@ gdk_device_winpointer_query_state (GdkDevice *device,
hwndc = ChildWindowFromPoint (hwnd, point);
if (hwndc && hwndc != hwnd)
*child_window = gdk_win32_handle_table_lookup_ (hwndc);
*child_window = gdk_win32_handle_table_lookup (hwndc);
else
*child_window = NULL; /* Direct child unknown to gdk */
}
@@ -160,7 +160,7 @@ gdk_device_winpointer_surface_at_position (GdkDevice *device,
if (!PtInRect (&rect, client_pt))
hwnd = NULL;
surface = gdk_win32_handle_table_lookup_ (hwnd);
surface = gdk_win32_handle_table_lookup (hwnd);
if (surface && (win_x || win_y))
{
+1 -1
View File
@@ -104,7 +104,7 @@ gdk_device_wintab_query_state (GdkDevice *device,
hwndc = ChildWindowFromPoint (hwnd, point);
if (hwndc && hwndc != hwnd)
*child_window = gdk_win32_handle_table_lookup_ (hwndc);
*child_window = gdk_win32_handle_table_lookup (hwndc);
else
*child_window = NULL; /* Direct child unknown to gdk */
}
+4 -6
View File
@@ -51,8 +51,8 @@ static int debug_indent = 0;
/**
* gdk_win32_display_add_filter:
* @display: a `GdkWin32Display`
* @function: (scope notified): filter callback
* @data: (closure): data to pass to filter callback
* @function: filter callback
* @data: data to pass to filter callback
*
* Adds an event filter to @window, allowing you to intercept messages
* before they reach GDK. This is a low-level operation and makes it
@@ -136,8 +136,8 @@ _gdk_win32_message_filter_unref (GdkWin32Display *display,
/**
* gdk_win32_display_remove_filter:
* @display: A `GdkWin32Display`
* @function: (scope notified): previously-added filter function
* @data: (closure): user data for previously-added filter function
* @function: previously-added filter function
* @data: user data for previously-added filter function
*
* Remove a filter previously added with gdk_win32_display_add_filter().
*/
@@ -1247,8 +1247,6 @@ gdk_win32_display_init_gl (GdkDisplay *display,
* Retrieves the EGL display connection object for the given GDK display.
*
* Returns: (nullable): the EGL display
*
* Since: 4.4
*/
gpointer
gdk_win32_display_get_egl_display (GdkDisplay *display)
+11 -23
View File
@@ -142,6 +142,8 @@ struct _drop_target_context
static void
gdk_win32_drop_init (GdkWin32Drop *drop)
{
drop->droptarget_w32format_contentformat_map = g_array_new (FALSE, FALSE, sizeof (GdkWin32ContentFormatPair));
GDK_NOTE (DND, g_print ("gdk_win32_drop_init %p\n", drop));
}
@@ -412,13 +414,9 @@ set_source_actions_helper (GdkDrop *drop,
DWORD grfKeyState)
{
GdkDragAction user_action;
GdkWin32Drop *drop_win32;
user_action = get_user_action (grfKeyState);
drop_win32 = GDK_WIN32_DROP (drop);
drop_win32->actions = actions;
if (user_action != 0)
gdk_drop_set_actions (drop, user_action);
else
@@ -473,7 +471,6 @@ idroptarget_dragenter (LPDROPTARGET This,
GdkDragAction source_actions;
GdkDragAction dest_actions;
GdkContentFormats *formats;
GArray *droptarget_w32format_contentformat_map;
GDK_NOTE (DND, g_print ("idroptarget_dragenter %p @ %ld : %ld"
" for dest window 0x%p"
@@ -494,8 +491,7 @@ idroptarget_dragenter (LPDROPTARGET This,
display = gdk_surface_get_display (ctx->surface);
droptarget_w32format_contentformat_map = g_array_new (FALSE, FALSE, sizeof (GdkWin32ContentFormatPair));
formats = query_object_formats (pDataObj, droptarget_w32format_contentformat_map);
formats = query_object_formats (pDataObj, NULL);
drop = gdk_drop_new (display,
gdk_seat_get_pointer (gdk_display_get_default_seat (display)),
drag,
@@ -503,7 +499,7 @@ idroptarget_dragenter (LPDROPTARGET This,
ctx->surface,
GDK_DRAG_PROTO_OLE2);
drop_win32 = GDK_WIN32_DROP (drop);
drop_win32->droptarget_w32format_contentformat_map = droptarget_w32format_contentformat_map;
g_array_set_size (drop_win32->droptarget_w32format_contentformat_map, 0);
gdk_content_formats_unref (formats);
ctx->drop = drop;
@@ -524,7 +520,7 @@ idroptarget_dragenter (LPDROPTARGET This,
drop_win32->last_key_state = grfKeyState;
drop_win32->last_x = pt_x;
drop_win32->last_y = pt_y;
dest_actions = filter_actions (gdk_drop_get_actions (drop), source_actions);
dest_actions = filter_actions (drop_win32->actions, source_actions);
*pdwEffect_and_dwOKEffects = drop_effect_for_actions (dest_actions);
GDK_NOTE (DND, g_print ("idroptarget_dragenter returns S_OK with actions %s"
@@ -558,7 +554,9 @@ idroptarget_dragover (LPDROPTARGET This,
GdkDragAction source_actions;
GdkDragAction dest_actions;
source_actions = actions_for_drop_effects (*pdwEffect_and_dwOKEffects);
source_actions = set_source_actions_helper (ctx->drop,
actions_for_drop_effects (*pdwEffect_and_dwOKEffects),
grfKeyState);
GDK_NOTE (DND, g_print ("idroptarget_dragover %p @ %d : %d"
" (raw %ld : %ld)"
@@ -571,8 +569,7 @@ idroptarget_dragover (LPDROPTARGET This,
if (pt_x != drop_win32->last_x ||
pt_y != drop_win32->last_y ||
grfKeyState != drop_win32->last_key_state ||
source_actions != drop_win32->actions)
grfKeyState != drop_win32->last_key_state)
{
double x = 0.0;
double y = 0.0;
@@ -581,15 +578,13 @@ idroptarget_dragover (LPDROPTARGET This,
x /= drop_win32->scale;
y /= drop_win32->scale;
set_source_actions_helper (ctx->drop, source_actions, grfKeyState);
gdk_drop_emit_motion_event (ctx->drop, TRUE, x, y, GDK_CURRENT_TIME);
drop_win32->last_key_state = grfKeyState;
drop_win32->last_x = pt_x;
drop_win32->last_y = pt_y;
}
dest_actions = filter_actions (gdk_drop_get_actions (ctx->drop), source_actions);
dest_actions = filter_actions (drop_win32->actions, source_actions);
*pdwEffect_and_dwOKEffects = drop_effect_for_actions (dest_actions);
GDK_NOTE (DND, g_print ("idroptarget_dragover returns S_OK with actions %s"
@@ -650,12 +645,8 @@ idroptarget_drop (LPDROPTARGET This,
x /= drop_win32->scale;
y /= drop_win32->scale;
gdk_drop_emit_motion_event (ctx->drop, TRUE, x, y, GDK_CURRENT_TIME);
gdk_drop_emit_drop_event (ctx->drop, TRUE, x, y, GDK_CURRENT_TIME);
gdk_drop_emit_leave_event (ctx->drop, TRUE, GDK_CURRENT_TIME);
while (!drop_win32->drop_finished)
g_main_context_iteration (NULL, FALSE);
@@ -833,10 +824,7 @@ gdk_win32_drop_status (GdkDrop *drop,
_gdk_win32_drag_action_to_string (gdk_drop_get_actions (drop)),
_gdk_win32_drag_action_to_string (preferred)));
if (preferred != 0)
actions = preferred;
gdk_drop_set_actions (drop, drop_win32->actions & actions);
drop_win32->actions = actions;
}
static void
+33 -50
View File
@@ -388,7 +388,7 @@ low_level_keyboard_proc (int code,
if (kbd_focus_owner == NULL)
break;
gdk_kbd_focus_owner = gdk_win32_handle_table_lookup_ (kbd_focus_owner);
gdk_kbd_focus_owner = gdk_win32_handle_table_lookup (kbd_focus_owner);
if (gdk_kbd_focus_owner == NULL)
break;
@@ -618,7 +618,7 @@ find_window_for_mouse_event (GdkSurface* reported_window,
ScreenToClient (hwnd, &client_pt);
GetClientRect (hwnd, &rect);
if (PtInRect (&rect, client_pt))
event_surface = gdk_win32_handle_table_lookup_ (hwnd);
event_surface = gdk_win32_handle_table_lookup (hwnd);
}
if (event_surface == NULL)
event_surface = grab->surface;
@@ -1433,42 +1433,35 @@ handle_nchittest (HWND hwnd,
gint16 screen_y,
int *ret_valp)
{
RECT rect;
GdkWin32Surface *impl;
RECT client_rect;
POINT client_pt;
if (window == NULL)
if (window == NULL || window->input_region == NULL)
return FALSE;
/* If the window has no particular input pass-through region,
* then we can simply let DefWindowProc() handle the message */
if (window->input_region == NULL)
/* If the window has decorations, DefWindowProc() will take
* care of NCHITTEST.
*/
if (!_gdk_win32_surface_lacks_wm_decorations (window))
return FALSE;
if (!GetClientRect (hwnd, &client_rect))
return FALSE;
client_pt.x = screen_x;
client_pt.y = screen_y;
if (!ScreenToClient (hwnd, &client_pt))
return FALSE;
/* Check whether the point lies within the client area */
if (!PtInRect (&client_rect, client_pt))
if (!GetWindowRect (hwnd, &rect))
return FALSE;
impl = GDK_WIN32_SURFACE (window);
rect.left = screen_x - rect.left;
rect.top = screen_y - rect.top;
/* If the point lies inside the input region, return HTCLIENT,
* otherwise return HTTRANSPARENT. */
/* If it's inside the rect, return FALSE and let DefWindowProc() handle it */
if (cairo_region_contains_point (window->input_region,
client_pt.x / impl->surface_scale,
client_pt.y / impl->surface_scale))
*ret_valp = HTCLIENT;
else
*ret_valp = HTTRANSPARENT;
rect.left / impl->surface_scale,
rect.top / impl->surface_scale))
return FALSE;
/* We handled the message, no need to call DefWindowProc() */
/* Otherwise override DefWindowProc() and tell WM that the point is not
* within the window
*/
*ret_valp = HTNOWHERE;
return TRUE;
}
@@ -1782,7 +1775,7 @@ gdk_event_translate (MSG *msg,
return TRUE;
}
window = gdk_win32_handle_table_lookup_ (msg->hwnd);
window = gdk_win32_handle_table_lookup (msg->hwnd);
if (window == NULL)
{
@@ -2297,7 +2290,7 @@ gdk_event_translate (MSG *msg,
ScreenToClient (hwnd, &client_pt);
GetClientRect (hwnd, &rect);
if (PtInRect (&rect, client_pt))
new_window = gdk_win32_handle_table_lookup_ (hwnd);
new_window = gdk_win32_handle_table_lookup (hwnd);
}
synthesize_crossing_events (display,
@@ -2438,7 +2431,7 @@ gdk_event_translate (MSG *msg,
ScreenToClient (hwnd, &client_pt);
GetClientRect (hwnd, &rect);
if (PtInRect (&rect, client_pt))
new_window = gdk_win32_handle_table_lookup_ (hwnd);
new_window = gdk_win32_handle_table_lookup (hwnd);
}
if (!ignore_leave)
@@ -2676,7 +2669,6 @@ gdk_event_translate (MSG *msg,
{
int16_t scroll_x = 0;
int16_t scroll_y = 0;
GdkScrollDirection direction;
char classname[64];
@@ -2716,7 +2708,7 @@ gdk_event_translate (MSG *msg,
msg->hwnd = hwnd;
g_set_object (&window, gdk_win32_handle_table_lookup_ (hwnd));
g_set_object (&window, gdk_win32_handle_table_lookup (hwnd));
if (!window)
break;
@@ -2728,24 +2720,15 @@ gdk_event_translate (MSG *msg,
_gdk_device_virtual_set_active (_gdk_device_manager->core_pointer,
_gdk_device_manager->system_pointer);
direction = 0;
if (msg->message == WM_MOUSEWHEEL)
direction = (((short) HIWORD (msg->wParam)) > 0)
? GDK_SCROLL_UP
: GDK_SCROLL_DOWN;
else if (msg->message == WM_MOUSEHWHEEL)
direction = (((short) HIWORD (msg->wParam)) > 0)
? GDK_SCROLL_RIGHT
: GDK_SCROLL_LEFT;
event = gdk_scroll_event_new_value120 (window,
device_manager_win32->core_pointer,
NULL,
_gdk_win32_get_next_tick (msg->time),
build_pointer_event_state (msg),
direction,
(double) scroll_x,
(double) -scroll_y);
event = gdk_scroll_event_new (window,
device_manager_win32->core_pointer,
NULL,
_gdk_win32_get_next_tick (msg->time),
build_pointer_event_state (msg),
(double) scroll_x / (double) WHEEL_DELTA,
(double) -scroll_y / (double) WHEEL_DELTA,
FALSE,
GDK_SCROLL_UNIT_WHEEL);
_gdk_win32_append_event (event);
@@ -3246,7 +3229,7 @@ gdk_event_translate (MSG *msg,
{
if (msg->lParam != 0)
{
GdkSurface *other_surface = gdk_win32_handle_table_lookup_ ((HWND) msg->lParam);
GdkSurface *other_surface = gdk_win32_handle_table_lookup ((HWND) msg->lParam);
if (other_surface != NULL &&
(GDK_IS_POPUP (other_surface) || GDK_IS_DRAG_SURFACE (other_surface)))
{
-8
View File
@@ -441,12 +441,4 @@ typedef enum _GdkWin32ProcessorCheckType
gboolean _gdk_win32_check_processor (GdkWin32ProcessorCheckType check_type);
GdkPixbuf *gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
double *x_hot,
double *y_hot);
HICON gdk_win32_pixbuf_to_hicon_libgtk_only (GdkPixbuf *pixbuf);
void gdk_win32_set_modal_dialog_libgtk_only (HWND window);
gpointer gdk_win32_handle_table_lookup_ (HWND handle);
#endif /* __GDK_PRIVATE_WIN32_H__ */
-20
View File
@@ -31,7 +31,6 @@
#include "gdkdisplayprivate.h"
#include "gdkprivate-win32.h"
#include "gdkdisplay-win32.h"
#include "gdkwin32.h"
static char *
@@ -163,25 +162,6 @@ _gdk_win32_get_setting (const char *name,
g_value_set_int (value, 1);
return TRUE;
}
else if (strcmp ("gtk-xft-dpi", name) == 0)
{
GdkWin32Display *display = GDK_WIN32_DISPLAY (_gdk_display);
if (display->dpi_aware_type == PROCESS_SYSTEM_DPI_AWARE &&
!display->has_fixed_scale)
{
int dpi = GetDeviceCaps (GetDC (NULL), LOGPIXELSX);
if (dpi >= 96)
{
int xft_dpi = 1024 * dpi / display->surface_scale;
g_value_set_int (value, xft_dpi);
GDK_NOTE(MISC, g_print ("gdk_screen_get_setting(\"%s\") : %d\n", name, xft_dpi));
return TRUE;
}
}
return FALSE;
}
else if (strcmp ("gtk-xft-hintstyle", name) == 0)
{
g_value_set_static_string (value, "hintfull");
+21 -60
View File
@@ -1180,11 +1180,6 @@ gdk_win32_surface_layout_popup (GdkSurface *surface,
monitor = gdk_surface_get_layout_monitor (surface, layout,
gdk_win32_monitor_get_workarea);
if (!monitor)
{
GdkDisplay *display = gdk_surface_get_display (surface);
monitor = gdk_win32_display_get_primary_monitor (display);
}
gdk_win32_monitor_get_workarea (monitor, &bounds);
gdk_popup_layout_get_shadow_width (layout,
@@ -1310,27 +1305,19 @@ gdk_win32_surface_raise (GdkSurface *window)
}
}
/**
* gdk_win32_surface_set_urgency_hint:
* @surface: (type GdkWin32Surface): a native `GdkSurface`.
* @urgent: if %TRUE, flashes both the window and the taskbar button
* continuously.
*
* Flashes the specified @surface.
*/
void
gdk_win32_surface_set_urgency_hint (GdkSurface *surface,
gdk_win32_surface_set_urgency_hint (GdkSurface *window,
gboolean urgent)
{
FLASHWINFO flashwinfo;
g_return_if_fail (GDK_IS_WIN32_SURFACE (surface));
g_return_if_fail (GDK_IS_SURFACE (window));
if (GDK_SURFACE_DESTROYED (surface))
if (GDK_SURFACE_DESTROYED (window))
return;
flashwinfo.cbSize = sizeof (flashwinfo);
flashwinfo.hwnd = GDK_SURFACE_HWND (surface);
flashwinfo.hwnd = GDK_SURFACE_HWND (window);
if (urgent)
flashwinfo.dwFlags = FLASHW_ALL | FLASHW_TIMER;
else
@@ -4246,34 +4233,19 @@ gdk_win32_surface_focus (GdkSurface *window,
SetFocus (GDK_SURFACE_HWND (window));
}
/**
* gdk_win32_surface_lookup_for_display:
* @display: a %GdkDisplay
* @anid: a HWND window handle
*
* Returns: (nullable): the %GdkSurface associated with the given @anid, or %NULL.
*/
GdkSurface *
gdk_win32_surface_lookup_for_display (GdkDisplay *display,
HWND anid)
{
g_return_val_if_fail (display == gdk_display_get_default (), NULL);
return (GdkSurface*) gdk_win32_handle_table_lookup_ (anid);
return (GdkSurface*) gdk_win32_handle_table_lookup (anid);
}
/**
* gdk_win32_surface_is_win32:
* @surface: a `GdkSurface`
*
* Returns: %TRUE if the @surface is a win32 implemented surface.
*
* Deprecated: 4.8: Use `GDK_IS_WIN32_SURFACE` instead.
*/
gboolean
gdk_win32_surface_is_win32 (GdkSurface *surface)
gdk_win32_surface_is_win32 (GdkSurface *window)
{
return GDK_IS_WIN32_SURFACE (surface);
return GDK_IS_WIN32_SURFACE (window);
}
static gboolean
@@ -4307,19 +4279,11 @@ gdk_win32_surface_show_window_menu (GdkSurface *surface,
return TRUE;
}
/**
* gdk_win32_surface_get_impl_hwnd:
* @surface: a `GdkSurface`
*
* Returns: the associated @surface HWND handle.
*
* Deprecated: 4.8: Use gdk_win32_surface_get_handle() instead.
*/
HWND
gdk_win32_surface_get_impl_hwnd (GdkSurface *surface)
gdk_win32_surface_get_impl_hwnd (GdkSurface *window)
{
if (GDK_IS_WIN32_SURFACE (surface))
return GDK_SURFACE_HWND (surface);
if (GDK_IS_WIN32_SURFACE (window))
return GDK_SURFACE_HWND (window);
return NULL;
}
@@ -4485,8 +4449,9 @@ static void
gdk_win32_surface_set_input_region (GdkSurface *window,
cairo_region_t *input_region)
{
/* Input region support is implemented by handling the
* WM_NCHITTEST message. */
/* Partial input shape support is implemented by handling the
* NC_NCHITTEST message
*/
}
static void
@@ -4649,20 +4614,16 @@ gdk_win32_surface_class_init (GdkWin32SurfaceClass *klass)
impl_class->compute_size = _gdk_win32_surface_compute_size;
}
/**
* gdk_win32_surface_get_handle:
* @surface: (type GdkWin32Surface): a native `GdkSurface`.
*
* Returns the HWND handle belonging to @surface.
*
* Returns: the associated HWND handle.
*/
HWND
gdk_win32_surface_get_handle (GdkSurface *surface)
HGDIOBJ
gdk_win32_surface_get_handle (GdkSurface *window)
{
g_return_val_if_fail (GDK_IS_WIN32_SURFACE (surface), NULL);
if (!GDK_IS_WIN32_SURFACE (window))
{
g_warning (G_STRLOC " window is not a native Win32 window");
return NULL;
}
return GDK_SURFACE_HWND (surface);
return GDK_SURFACE_HWND (window);
}
#define LAST_PROP 1
+1 -7
View File
@@ -70,7 +70,7 @@ gdk_win32_handle_table_remove (HANDLE handle)
}
gpointer
gdk_win32_handle_table_lookup_ (HWND handle)
gdk_win32_handle_table_lookup (HWND handle)
{
gpointer data = NULL;
@@ -79,9 +79,3 @@ gdk_win32_handle_table_lookup_ (HWND handle)
return data;
}
gpointer
gdk_win32_handle_table_lookup (HWND handle)
{
return gdk_win32_handle_table_lookup_ (handle);
}
+6
View File
@@ -61,6 +61,12 @@ typedef struct _GdkWin32KeymapClass GdkWin32KeymapClass;
GType gdk_win32_keymap_get_type (void);
GdkWin32KeymapMatch gdk_win32_keymap_check_compose (GdkWin32Keymap *keymap,
guint16 *compose_buffer,
gsize compose_buffer_len,
guint16 *output,
gsize *output_len);
G_END_DECLS
#endif /* __GDK_WIN32_KEYMAP_H__ */
+22 -7
View File
@@ -68,22 +68,37 @@ G_BEGIN_DECLS
#define XBUTTON2 2
#endif
GDK_DEPRECATED_IN_4_8_FOR(GDK_IS_WIN32_SURFACE)
gboolean gdk_win32_surface_is_win32 (GdkSurface *surface);
GDK_DEPRECATED_IN_4_8_FOR(gdk_win32_surface_get_handle)
HWND gdk_win32_surface_get_impl_hwnd (GdkSurface *surface);
/* Return true if the GdkSurface is a win32 implemented window */
GDK_AVAILABLE_IN_ALL
gboolean gdk_win32_surface_is_win32 (GdkSurface *window);
GDK_AVAILABLE_IN_ALL
HWND gdk_win32_surface_get_impl_hwnd (GdkSurface *window);
GDK_DEPRECATED_IN_4_8
/* Return the Gdk* for a particular HANDLE */
GDK_AVAILABLE_IN_ALL
gpointer gdk_win32_handle_table_lookup (HWND handle);
/* Translate from window to Windows handle */
GDK_AVAILABLE_IN_ALL
HWND gdk_win32_surface_get_handle (GdkSurface *surface);
HGDIOBJ gdk_win32_surface_get_handle (GdkSurface *window);
GDK_AVAILABLE_IN_ALL
GdkSurface * gdk_win32_surface_lookup_for_display (GdkDisplay *display,
HWND anid);
#if defined (INSIDE_GDK_WIN32) || defined (GTK_COMPILATION) || defined (GTK_COMPILATION)
/* For internal GTK use only */
GDK_AVAILABLE_IN_ALL
GdkPixbuf *gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
double *x_hot,
double *y_hot);
GDK_AVAILABLE_IN_ALL
HICON gdk_win32_pixbuf_to_hicon_libgtk_only (GdkPixbuf *pixbuf);
GDK_AVAILABLE_IN_ALL
void gdk_win32_set_modal_dialog_libgtk_only (HWND window);
#endif
G_END_DECLS
#endif /* __GDK_WIN32_MISC_H__ */
+13 -16
View File
@@ -1,19 +1,6 @@
gdk_win32_public_sources = files([
'gdkcursor-win32.c',
'gdkdisplay-win32.c',
'gdkdisplaymanager-win32.c',
'gdkdrag-win32.c',
'gdkglcontext-win32.c',
'gdkglcontext-win32-wgl.c',
'gdkwin32id.c',
'gdksurface-win32.c',
'gdkevents-win32.c',
'gdkmonitor-win32.c',
'gdkscreen-win32.c',
])
gdk_win32_sources = gdk_win32_public_sources + files([
gdk_win32_sources = files([
'gdkcairocontext-win32.c',
'gdkcursor-win32.c',
'gdkclipboard-win32.c',
'gdkclipdrop-win32.c',
'gdkdevicemanager-win32.c',
@@ -21,7 +8,13 @@ gdk_win32_sources = gdk_win32_public_sources + files([
'gdkdevice-win32.c',
'gdkdevice-winpointer.c',
'gdkdevice-wintab.c',
'gdkdisplay-win32.c',
'gdkdisplaymanager-win32.c',
'gdkdrag-win32.c',
'gdkdrop-win32.c',
'gdkevents-win32.c',
'gdkglcontext-win32.c',
'gdkglcontext-win32-wgl.c',
'gdkglobals-win32.c',
'gdkhdataoutputstream-win32.c',
'gdkinput-dmanipulation.c',
@@ -31,11 +24,14 @@ gdk_win32_sources = gdk_win32_public_sources + files([
'gdkkeys-win32-impl-wow64.c',
'gdkwin32langnotification.c',
'gdkmain-win32.c',
'gdkmonitor-win32.c',
'gdkproperty-win32.c',
'gdkscreen-win32.c',
'gdkvulkancontext-win32.c',
'gdkwin32cursor.h',
'gdkwin32display.h',
'gdkwin32keys.h',
'gdkwin32id.c',
'gdksurface-win32.c',
])
gdk_win32_public_headers = files([
@@ -44,6 +40,7 @@ gdk_win32_public_headers = files([
'gdkwin32displaymanager.h',
'gdkwin32dnd.h',
'gdkwin32glcontext.h',
'gdkwin32keys.h',
'gdkwin32misc.h',
'gdkwin32monitor.h',
'gdkwin32screen.h',
+2 -2
View File
@@ -358,10 +358,10 @@ gdk_x11_clipboard_request_targets_got_stream (GObject *source,
g_error_free (error);
return;
}
else if (g_strcmp0 (type, "ATOM") != 0 || format != 32)
else if (!g_str_equal (type, "ATOM") || format != 32)
{
GDK_DISPLAY_NOTE (display, CLIPBOARD, g_printerr ("%s: Wrong reply type to TARGETS: type %s != ATOM or format %d != 32\n",
cb->selection, type ? type : "NULL", format));
cb->selection, type, format));
g_input_stream_close (stream, NULL, NULL);
g_object_unref (stream);
g_object_unref (cb);
+11 -21
View File
@@ -1729,7 +1729,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
&xev->valuators, &delta_x, &delta_y))
{
GdkModifierType state;
GdkScrollDirection direction;
GDK_DISPLAY_NOTE (display, EVENTS,
g_message ("smooth scroll: \n\tdevice: %u\n\tsource device: %u\n\twindow %ld\n\tdeltas: %f %f",
@@ -1738,19 +1737,21 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
if (delta_x > 0)
direction = GDK_SCROLL_RIGHT;
else if (delta_x < 0)
direction = GDK_SCROLL_LEFT;
else if (delta_y > 0)
direction = GDK_SCROLL_DOWN;
else
direction = GDK_SCROLL_UP;
if (gdk_device_get_source (source_device) != GDK_SOURCE_TOUCHPAD &&
((delta_x == 0.0 && ABS (delta_y) == 1.0) ||
(ABS (delta_x) == 1.0 && delta_y == 0.0)))
{
GdkScrollDirection direction;
if (delta_x > 0)
direction = GDK_SCROLL_RIGHT;
else if (delta_x < 0)
direction = GDK_SCROLL_LEFT;
else if (delta_y > 0)
direction = GDK_SCROLL_DOWN;
else
direction = GDK_SCROLL_UP;
event = gdk_scroll_event_new_discrete (surface,
device,
NULL,
@@ -1758,17 +1759,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
state,
direction);
}
else if (gdk_device_get_source (source_device) == GDK_SOURCE_MOUSE)
{
event = gdk_scroll_event_new_value120 (surface,
device,
NULL,
xev->time,
state,
direction,
delta_x * 120.0,
delta_y * 120.0);
}
else
{
event = gdk_scroll_event_new (surface,
+16 -12
View File
@@ -361,9 +361,9 @@ gdk_x11_drop_update_actions (GdkX11Drop *drop_x11)
if (!drop_x11->xdnd_have_actions)
actions = drop_x11->suggested_action;
else if (drop_x11->suggested_action & GDK_ACTION_ASK)
actions = drop_x11->xdnd_actions | GDK_ACTION_ASK;
else
actions = drop_x11->xdnd_actions & GDK_ACTION_ALL;
else
actions = drop_x11->suggested_action;
gdk_drop_set_actions (GDK_DROP (drop_x11), actions);
}
@@ -769,18 +769,22 @@ gdk_x11_drop_status (GdkDrop *drop,
possible_actions = actions & gdk_drop_get_actions (drop);
if (preferred & possible_actions)
suggested_action = preferred;
else if (drop_x11->suggested_action & possible_actions)
if (drop_x11->suggested_action != 0)
suggested_action = drop_x11->suggested_action;
else if (possible_actions & GDK_ACTION_COPY)
suggested_action = GDK_ACTION_COPY;
else if (possible_actions & GDK_ACTION_MOVE)
suggested_action = GDK_ACTION_MOVE;
else if (possible_actions & GDK_ACTION_ASK)
suggested_action = GDK_ACTION_ASK;
else
suggested_action = 0;
suggested_action = preferred & possible_actions;
if (suggested_action == 0 && possible_actions != 0)
{
if (possible_actions & GDK_ACTION_COPY)
suggested_action = GDK_ACTION_COPY;
else if (possible_actions & GDK_ACTION_MOVE)
suggested_action = GDK_ACTION_MOVE;
else if (possible_actions & GDK_ACTION_ASK)
suggested_action = GDK_ACTION_ASK;
else
suggested_action = 0;
}
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndStatus");
+1 -6
View File
@@ -176,12 +176,7 @@ gsk_gl_driver_shader_weak_cb (gpointer data,
g_assert (GSK_IS_GL_DRIVER (self));
if (self->shader_cache != NULL)
{
if (self->command_queue != NULL)
gsk_gl_command_queue_make_current (self->command_queue);
g_hash_table_remove (self->shader_cache, where_object_was);
}
g_hash_table_remove (self->shader_cache, where_object_was);
}
G_GNUC_NULL_TERMINATED static inline GBytes *
-7
View File
@@ -162,7 +162,6 @@ uniform_type_from_glsl (const char *str)
return GSK_GL_UNIFORM_TYPE_NONE;
}
#ifdef G_ENABLE_DEBUG
static const char *
uniform_type_name (GskGLUniformType type)
{
@@ -195,7 +194,6 @@ uniform_type_name (GskGLUniformType type)
return NULL;
}
}
#endif
static int
uniform_type_size (GskGLUniformType type)
@@ -399,7 +397,6 @@ gsk_gl_shader_constructed (GObject *object)
shader->n_textures = max_texture_seen;
#ifdef G_ENABLE_DEBUG
if (GSK_DEBUG_CHECK(SHADERS))
{
GString *s;
@@ -417,7 +414,6 @@ gsk_gl_shader_constructed (GObject *object)
s->str);
g_string_free (s, TRUE);
}
#endif
}
#define SPACE_RE "[ \\t]+" // Don't use \s, we don't want to match newlines
@@ -635,7 +631,6 @@ gsk_gl_shader_get_uniform_name (GskGLShader *shader,
int idx)
{
g_return_val_if_fail (GSK_IS_GL_SHADER (shader), NULL);
g_return_val_if_fail (0 <= idx && idx < shader->uniforms->len, NULL);
return g_array_index (shader->uniforms, GskGLUniform, idx).name;
}
@@ -680,7 +675,6 @@ gsk_gl_shader_get_uniform_type (GskGLShader *shader,
int idx)
{
g_return_val_if_fail (GSK_IS_GL_SHADER (shader), 0);
g_return_val_if_fail (0 <= idx && idx < shader->uniforms->len, 0);
return g_array_index (shader->uniforms, GskGLUniform, idx).type;
}
@@ -699,7 +693,6 @@ gsk_gl_shader_get_uniform_offset (GskGLShader *shader,
int idx)
{
g_return_val_if_fail (GSK_IS_GL_SHADER (shader), 0);
g_return_val_if_fail (0 <= idx && idx < shader->uniforms->len, 0);
return g_array_index (shader->uniforms, GskGLUniform, idx).offset;
}
+20
View File
@@ -15,3 +15,23 @@ gsk_ensure_resources (void)
g_once (&register_resources_once, register_resources, NULL);
}
int
pango_glyph_string_num_glyphs (PangoGlyphString *glyphs)
{
int i, count;
count = 0;
for (i = 0; i < glyphs->num_glyphs; i++)
{
PangoGlyphInfo *gi = &glyphs->glyphs[i];
if (gi->glyph != PANGO_GLYPH_EMPTY)
{
if (!(gi->glyph & PANGO_GLYPH_UNKNOWN_FLAG))
count++;
}
}
return count;
}
+2
View File
@@ -8,6 +8,8 @@ G_BEGIN_DECLS
void gsk_ensure_resources (void);
int pango_glyph_string_num_glyphs (PangoGlyphString *glyphs) G_GNUC_PURE;
typedef struct _GskVulkanRender GskVulkanRender;
typedef struct _GskVulkanRenderPass GskVulkanRenderPass;
+1 -1
View File
@@ -3752,7 +3752,7 @@ gsk_rounded_clip_node_diff (GskRenderNode *node1,
* Creates a `GskRenderNode` that will clip the @child to the area
* given by @clip.
*
* Returns: (transfer full) (type GskRoundedClipNode): A new `GskRenderNode`
* Returns: (transfer none) (type GskRoundedClipNode): A new `GskRenderNode`
*/
GskRenderNode *
gsk_rounded_clip_node_new (GskRenderNode *child,
+22 -22
View File
@@ -982,7 +982,7 @@ parse_color_node (GtkCssParser *parser)
{ "color", parse_color, NULL, &color },
};
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
return gsk_color_node_new (&color, &bounds);
}
@@ -1003,7 +1003,7 @@ parse_linear_gradient_node_internal (GtkCssParser *parser,
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (stops == NULL)
{
GskColorStop from = { 0.0, GDK_RGBA("AAFF00") };
@@ -1058,7 +1058,7 @@ parse_radial_gradient_node_internal (GtkCssParser *parser,
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (stops == NULL)
{
GskColorStop from = { 0.0, GDK_RGBA("AAFF00") };
@@ -1108,7 +1108,7 @@ parse_conic_gradient_node (GtkCssParser *parser)
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (stops == NULL)
{
GskColorStop from = { 0.0, GDK_RGBA("AAFF00") };
@@ -1142,7 +1142,7 @@ parse_inset_shadow_node (GtkCssParser *parser)
{ "blur", parse_double, NULL, &blur }
};
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
return gsk_inset_shadow_node_new (&outline, &color, dx, dy, spread, blur);
}
@@ -1325,7 +1325,7 @@ parse_glshader_node (GtkCssParser *parser)
GBytes *args = NULL;
int len, i;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
for (len = 0; len < 4; len++)
{
@@ -1362,7 +1362,7 @@ parse_border_node (GtkCssParser *parser)
{ "colors", parse_colors4, NULL, &colors }
};
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
return gsk_border_node_new (&outline, widths, colors);
}
@@ -1378,7 +1378,7 @@ parse_texture_node (GtkCssParser *parser)
};
GskRenderNode *node;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (texture == NULL)
texture = create_default_texture ();
@@ -1402,7 +1402,7 @@ parse_cairo_node (GtkCssParser *parser)
};
GskRenderNode *node;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
node = gsk_cairo_node_new (&bounds);
@@ -1447,7 +1447,7 @@ parse_outset_shadow_node (GtkCssParser *parser)
{ "blur", parse_double, NULL, &blur }
};
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
return gsk_outset_shadow_node_new (&outline, &color, dx, dy, spread, blur);
}
@@ -1463,7 +1463,7 @@ parse_transform_node (GtkCssParser *parser)
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
child = create_default_render_node ();
@@ -1490,7 +1490,7 @@ parse_opacity_node (GtkCssParser *parser)
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
child = create_default_render_node ();
@@ -1517,7 +1517,7 @@ parse_color_matrix_node (GtkCssParser *parser)
graphene_vec4_init (&offset, 0, 0, 0, 0);
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
child = create_default_render_node ();
@@ -1544,7 +1544,7 @@ parse_cross_fade_node (GtkCssParser *parser)
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (start == NULL)
start = gsk_color_node_new (&GDK_RGBA("AAFF00"), &GRAPHENE_RECT_INIT (0, 0, 50, 50));
if (end == NULL)
@@ -1571,7 +1571,7 @@ parse_blend_node (GtkCssParser *parser)
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (bottom == NULL)
bottom = gsk_color_node_new (&GDK_RGBA("AAFF00"), &GRAPHENE_RECT_INIT (0, 0, 50, 50));
if (top == NULL)
@@ -1599,7 +1599,7 @@ parse_repeat_node (GtkCssParser *parser)
GskRenderNode *result;
guint parse_result;
parse_result = parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_result = parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
child = create_default_render_node ();
@@ -1663,7 +1663,7 @@ parse_text_node (GtkCssParser *parser)
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (font == NULL)
{
@@ -1721,7 +1721,7 @@ parse_blur_node (GtkCssParser *parser)
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
child = create_default_render_node ();
@@ -1743,7 +1743,7 @@ parse_clip_node (GtkCssParser *parser)
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
child = create_default_render_node ();
@@ -1768,7 +1768,7 @@ parse_rounded_clip_node (GtkCssParser *parser)
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
child = create_default_render_node ();
@@ -1790,7 +1790,7 @@ parse_shadow_node (GtkCssParser *parser)
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
child = create_default_render_node ();
@@ -1819,7 +1819,7 @@ parse_debug_node (GtkCssParser *parser)
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (child == NULL)
child = create_default_render_node ();
-8
View File
@@ -285,14 +285,6 @@
...
fun:g_intern_static_string
}
{
glib GQuark
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
...
fun:g_intern_string
}
# Threads
{
+124 -1
View File
@@ -18,7 +18,130 @@
#include "config.h"
#include "gtkatspipangoprivate.h"
#include "gtkpango.h"
const char *
pango_style_to_string (PangoStyle style)
{
switch (style)
{
case PANGO_STYLE_NORMAL:
return "normal";
case PANGO_STYLE_OBLIQUE:
return "oblique";
case PANGO_STYLE_ITALIC:
return "italic";
default:
g_assert_not_reached ();
}
}
const char *
pango_variant_to_string (PangoVariant variant)
{
switch (variant)
{
case PANGO_VARIANT_NORMAL:
return "normal";
case PANGO_VARIANT_SMALL_CAPS:
return "small_caps";
case PANGO_VARIANT_ALL_SMALL_CAPS:
return "all_small_caps";
case PANGO_VARIANT_PETITE_CAPS:
return "petite_caps";
case PANGO_VARIANT_ALL_PETITE_CAPS:
return "all_petite_caps";
case PANGO_VARIANT_UNICASE:
return "unicase";
case PANGO_VARIANT_TITLE_CAPS:
return "title_caps";
default:
g_assert_not_reached ();
}
}
const char *
pango_stretch_to_string (PangoStretch stretch)
{
switch (stretch)
{
case PANGO_STRETCH_ULTRA_CONDENSED:
return "ultra_condensed";
case PANGO_STRETCH_EXTRA_CONDENSED:
return "extra_condensed";
case PANGO_STRETCH_CONDENSED:
return "condensed";
case PANGO_STRETCH_SEMI_CONDENSED:
return "semi_condensed";
case PANGO_STRETCH_NORMAL:
return "normal";
case PANGO_STRETCH_SEMI_EXPANDED:
return "semi_expanded";
case PANGO_STRETCH_EXPANDED:
return "expanded";
case PANGO_STRETCH_EXTRA_EXPANDED:
return "extra_expanded";
case PANGO_STRETCH_ULTRA_EXPANDED:
return "ultra_expanded";
default:
g_assert_not_reached ();
}
}
const char *
pango_underline_to_string (PangoUnderline value)
{
switch (value)
{
case PANGO_UNDERLINE_NONE:
return "none";
case PANGO_UNDERLINE_SINGLE:
case PANGO_UNDERLINE_SINGLE_LINE:
return "single";
case PANGO_UNDERLINE_DOUBLE:
case PANGO_UNDERLINE_DOUBLE_LINE:
return "double";
case PANGO_UNDERLINE_LOW:
return "low";
case PANGO_UNDERLINE_ERROR:
case PANGO_UNDERLINE_ERROR_LINE:
return "error";
default:
g_assert_not_reached ();
}
}
const char *
pango_wrap_mode_to_string (PangoWrapMode mode)
{
/* Keep these in sync with gtk_wrap_mode_to_string() */
switch (mode)
{
case PANGO_WRAP_WORD:
return "word";
case PANGO_WRAP_CHAR:
return "char";
case PANGO_WRAP_WORD_CHAR:
return "word-char";
default:
g_assert_not_reached ();
}
}
static const char *
pango_align_to_string (PangoAlignment align)
{
switch (align)
{
case PANGO_ALIGN_LEFT:
return "left";
case PANGO_ALIGN_CENTER:
return "center";
case PANGO_ALIGN_RIGHT:
return "right";
default:
g_assert_not_reached ();
}
}
void
gtk_pango_get_font_attributes (PangoFontDescription *font,
+6
View File
@@ -22,6 +22,12 @@
G_BEGIN_DECLS
const char *pango_wrap_mode_to_string (PangoWrapMode mode);
const char *pango_underline_to_string (PangoUnderline underline);
const char *pango_stretch_to_string (PangoStretch stretch);
const char *pango_style_to_string (PangoStyle style);
const char *pango_variant_to_string (PangoVariant variant);
void gtk_pango_get_font_attributes (PangoFontDescription *font,
GVariantBuilder *builder);
void gtk_pango_get_default_attributes (PangoLayout *layout,
+1 -3
View File
@@ -106,7 +106,6 @@ gtk_at_spi_root_dispose (GObject *gobject)
g_clear_object (&self->cache);
g_clear_object (&self->connection);
g_clear_pointer (&self->queued_contexts, g_list_free);
G_OBJECT_CLASS (gtk_at_spi_root_parent_class)->dispose (gobject);
}
@@ -518,8 +517,7 @@ on_registration_reply (GObject *gobject,
/* Drain the list of queued GtkAtSpiContexts, and add them to the cache */
if (self->queued_contexts != NULL)
{
self->queued_contexts = g_list_reverse (self->queued_contexts);
for (GList *l = self->queued_contexts; l != NULL; l = l->next)
for (GList *l = g_list_reverse (self->queued_contexts); l != NULL; l = l->next)
{
if (data->register_func != NULL)
data->register_func (self, l->data);
+1 -1
View File
@@ -864,7 +864,7 @@ notebook_handle_method (GDBusConnection *connection,
for (child = gtk_widget_get_first_child (widget);
child;
child = gtk_widget_get_next_sibling (child))
child = gtk_widget_get_next_sibling (widget))
{
/* skip actions */
if (gtk_accessible_get_accessible_role (GTK_ACCESSIBLE (child)) != GTK_ACCESSIBLE_ROLE_TAB)
+3 -5
View File
@@ -32,15 +32,13 @@
#include "gtkatcontextprivate.h"
#include "gtkdebug.h"
#include "gtkeditable.h"
#include "gtkentryprivate.h"
#include "gtkinscriptionprivate.h"
#include "gtklabelprivate.h"
#include "gtkpango.h"
#include "gtkpasswordentryprivate.h"
#include "gtkentryprivate.h"
#include "gtksearchentryprivate.h"
#include "gtkpasswordentryprivate.h"
#include "gtkspinbuttonprivate.h"
#include "gtktextbufferprivate.h"
#include "gtktextviewprivate.h"
#include "gtktextview.h"
#include <gio/gio.h>
+553 -2
View File
@@ -19,9 +19,62 @@
#include "config.h"
#include "gtkatspitextbufferprivate.h"
#include "gtkatspipangoprivate.h"
#include "gtktextbufferprivate.h"
#include "gtktextviewprivate.h"
#include "gtkpango.h"
static const char *
gtk_justification_to_string (GtkJustification just)
{
switch (just)
{
case GTK_JUSTIFY_LEFT:
return "left";
case GTK_JUSTIFY_RIGHT:
return "right";
case GTK_JUSTIFY_CENTER:
return "center";
case GTK_JUSTIFY_FILL:
return "fill";
default:
g_assert_not_reached ();
}
}
static const char *
gtk_text_direction_to_string (GtkTextDirection direction)
{
switch (direction)
{
case GTK_TEXT_DIR_NONE:
return "none";
case GTK_TEXT_DIR_LTR:
return "ltr";
case GTK_TEXT_DIR_RTL:
return "rtl";
default:
g_assert_not_reached ();
}
}
static const char *
gtk_wrap_mode_to_string (GtkWrapMode wrap_mode)
{
/* Keep these in sync with pango_wrap_mode_to_string(); note that
* here we have an extra case for NONE.
*/
switch (wrap_mode)
{
case GTK_WRAP_NONE:
return "none";
case GTK_WRAP_CHAR:
return "char";
case GTK_WRAP_WORD:
return "word";
case GTK_WRAP_WORD_CHAR:
return "word-char";
default:
g_assert_not_reached ();
}
}
void
gtk_text_view_add_default_attributes (GtkTextView *view,
@@ -108,6 +161,504 @@ gtk_text_view_add_default_attributes (GtkTextView *view,
gtk_text_attributes_unref (text_attrs);
}
void
gtk_text_buffer_get_run_attributes (GtkTextBuffer *buffer,
GVariantBuilder *builder,
int offset,
int *start_offset,
int *end_offset)
{
GtkTextIter iter;
GSList *tags, *temp_tags;
double scale = 1;
gboolean val_set = FALSE;
gtk_text_buffer_get_iter_at_offset (buffer, &iter, offset);
gtk_text_iter_forward_to_tag_toggle (&iter, NULL);
*end_offset = gtk_text_iter_get_offset (&iter);
gtk_text_iter_backward_to_tag_toggle (&iter, NULL);
*start_offset = gtk_text_iter_get_offset (&iter);
gtk_text_buffer_get_iter_at_offset (buffer, &iter, offset);
tags = gtk_text_iter_get_tags (&iter);
tags = g_slist_reverse (tags);
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
PangoStyle style;
g_object_get (tag,
"style-set", &val_set,
"style", &style,
NULL);
if (val_set)
g_variant_builder_add (builder, "{ss}", "style", pango_style_to_string (style));
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
PangoVariant variant;
g_object_get (tag,
"variant-set", &val_set,
"variant", &variant,
NULL);
if (val_set)
g_variant_builder_add (builder, "{ss}", "variant", pango_variant_to_string (variant));
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
PangoStretch stretch;
g_object_get (tag,
"stretch-set", &val_set,
"stretch", &stretch,
NULL);
if (val_set)
g_variant_builder_add (builder, "{ss}", "stretch", pango_stretch_to_string (stretch));
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
GtkJustification justification;
g_object_get (tag,
"justification-set", &val_set,
"justification", &justification,
NULL);
if (val_set)
g_variant_builder_add (builder, "{ss}", "justification", gtk_justification_to_string (justification));
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
GtkTextDirection direction;
g_object_get (tag, "direction", &direction, NULL);
if (direction != GTK_TEXT_DIR_NONE)
{
val_set = TRUE;
g_variant_builder_add (builder, "{ss}", "direction", gtk_text_direction_to_string (direction));
}
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
GtkWrapMode wrap_mode;
g_object_get (tag,
"wrap-mode-set", &val_set,
"wrap-mode", &wrap_mode,
NULL);
if (val_set)
g_variant_builder_add (builder, "{ss}", "wrap-mode", gtk_wrap_mode_to_string (wrap_mode));
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
g_object_get (tag, "foreground-set", &val_set, NULL);
if (val_set)
{
GdkRGBA *rgba;
char *value;
g_object_get (tag, "foreground", &rgba, NULL);
value = g_strdup_printf ("%u,%u,%u",
(guint) rgba->red * 65535,
(guint) rgba->green * 65535,
(guint) rgba->blue * 65535);
gdk_rgba_free (rgba);
g_variant_builder_add (builder, "{ss}", "fg-color", value);
g_free (value);
}
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
g_object_get (tag, "background-set", &val_set, NULL);
if (val_set)
{
GdkRGBA *rgba;
char *value;
g_object_get (tag, "background-rgba", &rgba, NULL);
value = g_strdup_printf ("%u,%u,%u",
(guint) rgba->red * 65535,
(guint) rgba->green * 65535,
(guint) rgba->blue * 65535);
gdk_rgba_free (rgba);
g_variant_builder_add (builder, "{ss}", "bg-color", value);
g_free (value);
}
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
g_object_get (tag, "family-set", &val_set, NULL);
if (val_set)
{
char *value;
g_object_get (tag, "family", &value, NULL);
g_variant_builder_add (builder, "{ss}", "family-name", value);
g_free (value);
}
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
g_object_get (tag, "language-set", &val_set, NULL);
if (val_set)
{
char *value;
g_object_get (tag, "language", &value, NULL);
g_variant_builder_add (builder, "{ss}", "language", value);
g_free (value);
}
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
int weight;
g_object_get (tag,
"weight-set", &val_set,
"weight", &weight,
NULL);
if (val_set)
{
char *value;
value = g_strdup_printf ("%d", weight);
g_variant_builder_add (builder, "{ss}", "weight", value);
g_free (value);
}
temp_tags = temp_tags->next;
}
val_set = FALSE;
/* scale is special as the effective value is the product
* of all specified values
*/
temp_tags = tags;
while (temp_tags)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
gboolean scale_set;
g_object_get (tag, "scale-set", &scale_set, NULL);
if (scale_set)
{
double font_scale;
g_object_get (tag, "scale", &font_scale, NULL);
val_set = TRUE;
scale *= font_scale;
}
temp_tags = temp_tags->next;
}
if (val_set)
{
char *value = g_strdup_printf ("%g", scale);
g_variant_builder_add (builder, "{ss}", "scale", value);
g_free (value);
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
int size;
g_object_get (tag,
"size-set", &val_set,
"size", &size,
NULL);
if (val_set)
{
char *value = g_strdup_printf ("%i", size);
g_variant_builder_add (builder, "{ss}", "size", value);
g_free (value);
}
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
gboolean strikethrough;
g_object_get (tag,
"strikethrough-set", &val_set,
"strikethrough", &strikethrough,
NULL);
if (val_set)
g_variant_builder_add (builder, "{ss}", "strikethrough", strikethrough ? "true" : "false");
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
PangoUnderline underline;
g_object_get (tag,
"underline-set", &val_set,
"underline", &underline,
NULL);
if (val_set)
g_variant_builder_add (builder, "{ss}", "underline",
pango_underline_to_string (underline));
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
int rise;
g_object_get (tag,
"rise-set", &val_set,
"rise", &rise,
NULL);
if (val_set)
{
char *value = g_strdup_printf ("%i", rise);
g_variant_builder_add (builder, "{ss}", "rise", value);
g_free (value);
}
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
gboolean bg_full_height;
g_object_get (tag,
"background-full-height-set", &val_set,
"background-full-height", &bg_full_height,
NULL);
if (val_set)
g_variant_builder_add (builder, "{ss}", "bg-full-height", bg_full_height ? "true" : "false");
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
int pixels;
g_object_get (tag,
"pixels-inside-wrap-set", &val_set,
"pixels-inside-wrap", &pixels,
NULL);
if (val_set)
{
char *value = g_strdup_printf ("%i", pixels);
g_variant_builder_add (builder, "{ss}", "pixels-inside-wrap", value);
g_free (value);
}
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
int pixels;
g_object_get (tag,
"pixels-below-lines-set", &val_set,
"pixels-below-lines", &pixels,
NULL);
if (val_set)
{
char *value = g_strdup_printf ("%i", pixels);
g_variant_builder_add (builder, "{ss}", "pixels-below-lines", value);
g_free (value);
}
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
int pixels;
g_object_get (tag,
"pixels-above-lines-set", &val_set,
"pixels-above-lines", &pixels,
NULL);
if (val_set)
{
char *value = g_strdup_printf ("%i", pixels);
g_variant_builder_add (builder, "{ss}", "pixels-above-lines", value);
g_free (value);
}
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
gboolean editable;
g_object_get (tag,
"editable-set", &val_set,
"editable", &editable,
NULL);
if (val_set)
g_variant_builder_add (builder, "{ss}", "editable", editable ? "true" : "false");
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
gboolean invisible;
g_object_get (tag,
"invisible-set", &val_set,
"invisible", &invisible,
NULL);
if (val_set)
g_variant_builder_add (builder, "{ss}", "invisible", invisible ? "true" : "false");
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
int indent;
g_object_get (tag,
"indent-set", &val_set,
"indent", &indent,
NULL);
if (val_set)
{
char *value = g_strdup_printf ("%i", indent);
g_variant_builder_add (builder, "{ss}", "indent", value);
g_free (value);
}
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
int margin;
g_object_get (tag,
"right-margin-set", &val_set,
"right-margin", &margin,
NULL);
if (val_set)
{
char *value = g_strdup_printf ("%i", margin);
g_variant_builder_add (builder, "{ss}", "right-margin", value);
g_free (value);
}
temp_tags = temp_tags->next;
}
val_set = FALSE;
temp_tags = tags;
while (temp_tags && !val_set)
{
GtkTextTag *tag = GTK_TEXT_TAG (temp_tags->data);
int margin;
g_object_get (tag,
"left-margin-set", &val_set,
"left-margin", &margin,
NULL);
if (val_set)
{
char *value = g_strdup_printf ("%i", margin);
g_variant_builder_add (builder, "{ss}", "left-margin", value);
g_free (value);
}
temp_tags = temp_tags->next;
}
val_set = FALSE;
g_slist_free (tags);
}
char *
gtk_text_view_get_text_before (GtkTextView *view,
int offset,
+5
View File
@@ -25,6 +25,11 @@ G_BEGIN_DECLS
void gtk_text_view_add_default_attributes (GtkTextView *view,
GVariantBuilder *builder);
void gtk_text_buffer_get_run_attributes (GtkTextBuffer *buffer,
GVariantBuilder *builder,
int offset,
int *start_offset,
int *end_offset);
char *gtk_text_view_get_text_before (GtkTextView *view,
int offset,
+1 -12
View File
@@ -152,24 +152,13 @@ gtk_css_data_url_parse (const char *url,
gsize read;
gsize written;
gpointer data;
GError *local_error = NULL;
data = g_convert_with_fallback (bdata, bsize,
"UTF-8", charset,
(char *) "*",
&read, &written, &local_error);
&read, &written, NULL);
g_free (bdata);
if (local_error)
{
g_propagate_error (error, local_error);
g_free (charset);
g_free (data);
g_free (mimetype);
return NULL;
}
bdata = data;
bsize = written;
}
+4 -17
View File
@@ -1353,8 +1353,8 @@ gtk_builder_add_objects_from_file (GtkBuilder *builder,
* Main private entry point for building composite components
* from template XML.
*
* Most likely you do not need to call this function in applications as
* templates are handled by `GtkWidget`.
* This is exported purely to let `gtk-builder-tool` validate
* templates, applications have no need to call this function.
*
* Returns: A positive value on success, 0 if an error occurred
*/
@@ -1367,7 +1367,6 @@ gtk_builder_extend_with_template (GtkBuilder *builder,
GError **error)
{
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
const char *name;
GError *tmp_error;
char *filename;
@@ -1385,15 +1384,8 @@ gtk_builder_extend_with_template (GtkBuilder *builder,
priv->resource_prefix = NULL;
priv->template_type = template_type;
/* We specifically allow this function to be called multiple times with
* the same @template_type as that is used in applications like Builder
* to implement UI merging.
*/
name = g_type_name (template_type);
if (gtk_builder_get_object (builder, name) != object)
gtk_builder_expose_object (builder, name, object);
filename = g_strconcat ("<", name, " template>", NULL);
filename = g_strconcat ("<", g_type_name (template_type), " template>", NULL);
gtk_builder_expose_object (builder, g_type_name (template_type), object);
_gtk_builder_parser_parse_buffer (builder, filename,
buffer, length,
NULL,
@@ -1780,11 +1772,6 @@ gtk_builder_get_translation_domain (GtkBuilder *builder)
*
* Add @object to the @builder object pool so it can be
* referenced just like any other object built by builder.
*
* Only a single object may be added using @name. However,
* it is not an error to expose the same object under multiple
* names. `gtk_builder_get_object()` may be used to determine
* if an object has already been added with @name.
*/
void
gtk_builder_expose_object (GtkBuilder *builder,
+2 -13
View File
@@ -21,11 +21,6 @@
#include "gtkcolorpickerportalprivate.h"
#include "gtkcolorpickershellprivate.h"
#include "gtkcolorpickerkwinprivate.h"
#ifdef G_OS_WIN32
#include "gtkcolorpickerwin32private.h"
#endif
#include <gio/gio.h>
@@ -56,19 +51,13 @@ gtk_color_picker_pick_finish (GtkColorPicker *picker,
GtkColorPicker *
gtk_color_picker_new (void)
{
GtkColorPicker *picker = NULL;
GtkColorPicker *picker;
#if defined (G_OS_UNIX)
if (!picker)
picker = gtk_color_picker_portal_new ();
picker = gtk_color_picker_portal_new ();
if (!picker)
picker = gtk_color_picker_shell_new ();
if (!picker)
picker = gtk_color_picker_kwin_new ();
#elif defined (G_OS_WIN32)
if (!picker)
picker = gtk_color_picker_win32_new ();
#endif
if (!picker)
g_debug ("No suitable GtkColorPicker implementation");
-246
View File
@@ -1,246 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2022 the GTK team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkcolorpickerwin32private.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
GList *pickers;
HHOOK hook;
static void remove_hook (void);
extern IMAGE_DOS_HEADER __ImageBase;
#define this_hmodule ((HMODULE)&__ImageBase)
struct _GtkColorPickerWin32
{
GObject parent_instance;
GTask *task;
POINT point;
};
struct _GtkColorPickerWin32Class
{
GObjectClass parent_class;
};
static GInitableIface *initable_parent_iface;
static void gtk_color_picker_win32_initable_iface_init (GInitableIface *iface);
static void gtk_color_picker_win32_iface_init (GtkColorPickerInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkColorPickerWin32, gtk_color_picker_win32, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, gtk_color_picker_win32_initable_iface_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_COLOR_PICKER, gtk_color_picker_win32_iface_init))
static gboolean
gtk_color_picker_win32_initable_init (GInitable *initable,
GCancellable *cancellable,
GError **error)
{
return TRUE;
}
static void
gtk_color_picker_win32_initable_iface_init (GInitableIface *iface)
{
initable_parent_iface = g_type_interface_peek_parent (iface);
iface->init = gtk_color_picker_win32_initable_init;
}
static void
gtk_color_picker_win32_init (GtkColorPickerWin32 *picker)
{
}
static void
gtk_color_picker_win32_class_init (GtkColorPickerWin32Class *class)
{
}
GtkColorPicker *
gtk_color_picker_win32_new (void)
{
return GTK_COLOR_PICKER (g_initable_new (GTK_TYPE_COLOR_PICKER_WIN32, NULL, NULL, NULL));
}
static void
on_task_completed (GObject *object,
GParamSpec *pspec,
gpointer user_data)
{
gpointer source = g_task_get_source_object (G_TASK (object));
GtkColorPickerWin32 *picker = GTK_COLOR_PICKER_WIN32 (source);
g_clear_object (&picker->task);
}
static void
pick_color (GTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
{
GtkColorPickerWin32 *picker = GTK_COLOR_PICKER_WIN32 (source_object);
GdkRGBA rgba = (GdkRGBA) { 1.0, 1.0, 1.0, 1.0 };
HDC hdc = GetDC(HWND_DESKTOP);
if (hdc)
{
COLORREF color = GetPixel(hdc, picker->point.x, picker->point.y);
rgba = (GdkRGBA){
(double) GetRValue (color) / 255.0,
(double) GetGValue (color) / 255.0,
(double) GetBValue (color) / 255.0,
1.0,
};
ReleaseDC (HWND_DESKTOP, hdc);
}
g_task_return_pointer (task,
gdk_rgba_copy (&rgba),
(GDestroyNotify) gdk_rgba_free);
}
static void
picked (GtkColorPickerWin32 *picker)
{
g_task_run_in_thread (picker->task, pick_color);
}
static LRESULT CALLBACK
mouse_proc (int nCode,
WPARAM wParam,
LPARAM lParam)
{
if (nCode == HC_ACTION)
{
MSLLHOOKSTRUCT *info = (MSLLHOOKSTRUCT*) lParam;
switch (wParam)
{
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_XBUTTONDOWN:
{
GtkColorPickerWin32 *picker = GTK_COLOR_PICKER_WIN32 (pickers->data);
if (!pickers)
break;
/* A low-level mouse hook always receives screen points in
* per-monitor DPI aware screen coordinates, regardless of
* the DPI awareness setting of the application. */
picker->point = info->pt;
picked (picker);
pickers = g_list_delete_link (pickers, pickers);
/* It's safe to remove a hook from within its callback */
if (!pickers)
remove_hook ();
return 1;
}
break;
default:
break;
}
}
return CallNextHookEx(NULL, nCode, wParam, lParam);
}
static gboolean
ensure_mouse_hook (void)
{
if (!hook)
{
hook = SetWindowsHookEx (WH_MOUSE_LL, mouse_proc, this_hmodule, 0);
if (!hook)
{
g_warning ("SetWindowsHookEx failed with error code "
"%"G_GUINT32_FORMAT, (unsigned) GetLastError ());
return FALSE;
}
}
return TRUE;
}
static void
remove_hook (void)
{
if (hook)
{
UnhookWindowsHookEx (hook);
hook = NULL;
}
}
static void
gtk_color_picker_win32_pick (GtkColorPicker *cp,
GAsyncReadyCallback callback,
gpointer user_data)
{
GtkColorPickerWin32 *picker = GTK_COLOR_PICKER_WIN32 (cp);
if (picker->task)
return;
picker->task = g_task_new (picker, NULL, callback, user_data);
g_task_set_name (picker->task, "GtkColorPicker");
g_signal_connect (picker->task, "notify::completed",
G_CALLBACK (on_task_completed),
NULL);
if (!ensure_mouse_hook ())
{
g_task_return_new_error (picker->task,
G_IO_ERROR,
G_IO_ERROR_FAILED,
"Cannot capture the mouse pointer");
return;
}
pickers = g_list_prepend (pickers, cp);
}
static GdkRGBA *
gtk_color_picker_win32_pick_finish (GtkColorPicker *cp,
GAsyncResult *res,
GError **error)
{
g_return_val_if_fail (g_task_is_valid (res, cp), NULL);
return g_task_propagate_pointer (G_TASK (res), error);
}
static void
gtk_color_picker_win32_iface_init (GtkColorPickerInterface *iface)
{
iface->pick = gtk_color_picker_win32_pick;
iface->pick_finish = gtk_color_picker_win32_pick_finish;
}
-41
View File
@@ -1,41 +0,0 @@
/*
* GTK - The GIMP Toolkit
* Copyright (C) 2022 the GTK team
* All rights reserved.
*
* This Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_COLOR_PICKER_WIN32_H__
#define __GTK_COLOR_PICKER_WIN32_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/gtkcolorpickerprivate.h>
G_BEGIN_DECLS
#define GTK_TYPE_COLOR_PICKER_WIN32 gtk_color_picker_win32_get_type ()
G_DECLARE_FINAL_TYPE (GtkColorPickerWin32, gtk_color_picker_win32, GTK, COLOR_PICKER_WIN32, GObject)
GDK_AVAILABLE_IN_ALL
GtkColorPicker * gtk_color_picker_win32_new (void);
G_END_DECLS
#endif /* __GTK_COLOR_PICKER_WIN32_H__ */
+2 -7
View File
@@ -28,7 +28,6 @@
static GtkCssValue * gtk_css_calc_value_new (guint n_terms);
static GtkCssValue * gtk_css_calc_value_new_sum (GtkCssValue *a,
GtkCssValue *b);
static gsize gtk_css_value_calc_get_size (gsize n_terms);
enum {
TYPE_CALC = 0,
@@ -79,13 +78,9 @@ gtk_css_value_number_free (GtkCssValue *number)
for (guint i = 0; i < n_terms; i++)
_gtk_css_value_unref (number->calc.terms[i]);
}
g_slice_free1 (gtk_css_value_calc_get_size (n_terms), number);
}
else
{
g_slice_free (GtkCssValue, number);
}
g_slice_free (GtkCssValue, number);
}
static double
-1
View File
@@ -287,7 +287,6 @@ gtk_css_transform_compute (GtkCssTransform *dest,
switch (src->type)
{
case GTK_CSS_TRANSFORM_MATRIX:
memcpy (dest, src, sizeof (GtkCssTransform));
return TRUE;
case GTK_CSS_TRANSFORM_TRANSLATE:
dest->translate.x = _gtk_css_value_compute (src->translate.x, property_id, provider, style, parent_style);
+16 -16
View File
@@ -208,21 +208,6 @@ gtk_drop_target_end_drop (GtkDropTarget *self)
g_object_thaw_notify (G_OBJECT (self));
}
static GdkDragAction
make_action_unique (GdkDragAction actions)
{
if (actions & GDK_ACTION_COPY)
return GDK_ACTION_COPY;
if (actions & GDK_ACTION_MOVE)
return GDK_ACTION_MOVE;
if (actions & GDK_ACTION_LINK)
return GDK_ACTION_LINK;
return 0;
}
static void
gtk_drop_target_do_drop (GtkDropTarget *self)
{
@@ -234,7 +219,7 @@ gtk_drop_target_do_drop (GtkDropTarget *self)
g_signal_emit (self, signals[DROP], 0, &self->value, self->coords.x, self->coords.y, &success);
if (success)
gdk_drop_finish (self->drop, make_action_unique (self->actions & gdk_drop_get_actions (self->drop)));
gdk_drop_finish (self->drop, gdk_drop_get_actions (self->drop));
else
gdk_drop_finish (self->drop, 0);
@@ -363,6 +348,21 @@ gtk_drop_target_accept (GtkDropTarget *self,
return gdk_content_formats_match_gtype (self->formats, gdk_drop_get_formats (drop)) != G_TYPE_INVALID;
}
static GdkDragAction
make_action_unique (GdkDragAction actions)
{
if (actions & GDK_ACTION_COPY)
return GDK_ACTION_COPY;
if (actions & GDK_ACTION_MOVE)
return GDK_ACTION_MOVE;
if (actions & GDK_ACTION_LINK)
return GDK_ACTION_LINK;
return 0;
}
static GdkDragAction
gtk_drop_target_enter (GtkDropTarget *self,
double x,
+53 -111
View File
@@ -1042,34 +1042,6 @@ gtk_emoji_chooser_show (GtkWidget *widget)
gtk_editable_set_text (GTK_EDITABLE (chooser->search_entry), "");
}
static EmojiSection *
find_section (GtkEmojiChooser *chooser,
GtkWidget *box)
{
if (box == chooser->recent.box)
return &chooser->recent;
else if (box == chooser->people.box)
return &chooser->people;
else if (box == chooser->body.box)
return &chooser->body;
else if (box == chooser->nature.box)
return &chooser->nature;
else if (box == chooser->food.box)
return &chooser->food;
else if (box == chooser->travel.box)
return &chooser->travel;
else if (box == chooser->activities.box)
return &chooser->activities;
else if (box == chooser->objects.box)
return &chooser->objects;
else if (box == chooser->symbols.box)
return &chooser->symbols;
else if (box == chooser->flags.box)
return &chooser->flags;
else
return NULL;
}
static EmojiSection *
find_next_section (GtkEmojiChooser *chooser,
GtkWidget *box,
@@ -1141,111 +1113,81 @@ keynav_failed (GtkWidget *box,
GtkWidget *focus;
GtkWidget *child;
GtkWidget *sibling;
GtkAllocation alloc;
int i;
int column;
int n_columns = 7;
int child_x;
focus = gtk_root_get_focus (gtk_widget_get_root (box));
if (focus == NULL)
return FALSE;
child = gtk_widget_get_ancestor (focus, GTK_TYPE_EMOJI_CHOOSER_CHILD);
column = 0;
child_x = G_MAXINT;
for (sibling = gtk_widget_get_first_child (box);
sibling;
sibling = gtk_widget_get_next_sibling (sibling))
/* determine the number of columns */
child_x = -1;
for (i = 0; i < 20; i++)
{
if (!gtk_widget_get_child_visible (sibling))
continue;
GtkAllocation alloc;
gtk_widget_get_allocation (sibling, &alloc);
if (alloc.x < child_x)
column = 0;
gtk_widget_get_allocation (GTK_WIDGET (gtk_flow_box_get_child_at_index (GTK_FLOW_BOX (box), i)),
&alloc);
if (alloc.x > child_x)
child_x = alloc.x;
else
column++;
child_x = alloc.x;
if (sibling == child)
break;
{
n_columns = i;
break;
}
}
n_columns = MAX (n_columns, 1);
child = gtk_widget_get_ancestor (focus, GTK_TYPE_EMOJI_CHOOSER_CHILD);
i = 0;
for (sibling = gtk_widget_get_first_child (box);
sibling != child;
sibling = gtk_widget_get_next_sibling (sibling))
i++;
column = i % n_columns;
if (direction == GTK_DIR_DOWN)
{
next = find_section (chooser, box);
while (TRUE)
{
next = find_next_section (chooser, box, TRUE);
if (next == NULL)
return FALSE;
i = 0;
for (sibling = gtk_widget_get_first_child (next->box);
sibling;
sibling = gtk_widget_get_next_sibling (sibling), i++)
{
next = find_next_section (chooser, next->box, TRUE);
if (next == NULL)
return FALSE;
i = 0;
child_x = G_MAXINT;
for (sibling = gtk_widget_get_first_child (next->box);
sibling;
sibling = gtk_widget_get_next_sibling (sibling))
if (i == column)
{
if (!gtk_widget_get_child_visible (sibling))
continue;
gtk_widget_get_allocation (sibling, &alloc);
if (alloc.x < child_x)
i = 0;
else
i++;
child_x = alloc.x;
if (i == column)
{
gtk_widget_grab_focus (sibling);
return TRUE;
}
gtk_widget_grab_focus (sibling);
return TRUE;
}
}
}
else if (direction == GTK_DIR_UP)
{
next = find_section (chooser, box);
while (TRUE)
next = find_next_section (chooser, box, FALSE);
if (next == NULL)
return FALSE;
i = 0;
child = NULL;
for (sibling = gtk_widget_get_first_child (next->box);
sibling;
sibling = gtk_widget_get_next_sibling (sibling), i++)
{
next = find_next_section (chooser, next->box, FALSE);
if (next == NULL)
return FALSE;
i = 0;
child_x = G_MAXINT;
child = NULL;
for (sibling = gtk_widget_get_first_child (next->box);
sibling;
sibling = gtk_widget_get_next_sibling (sibling))
{
if (!gtk_widget_get_child_visible (sibling))
continue;
gtk_widget_get_allocation (sibling, &alloc);
if (alloc.x < child_x)
i = 0;
else
i++;
child_x = alloc.x;
if (i == column)
child = sibling;
}
if (child)
{
gtk_widget_grab_focus (child);
return TRUE;
}
if ((i % n_columns) == column)
child = sibling;
}
if (child)
{
gtk_widget_grab_focus (child);
return TRUE;
}
}
+2 -2
View File
@@ -2050,12 +2050,12 @@ connect_completion_signals (GtkEntryCompletion *completion)
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
controller = completion->entry_key_controller = gtk_event_controller_key_new ();
gtk_event_controller_set_static_name (controller, "gtk-entry-completion");
gtk_event_controller_set_name (controller, "gtk-entry-completion");
g_signal_connect (controller, "key-pressed",
G_CALLBACK (gtk_entry_completion_key_pressed), completion);
gtk_widget_add_controller (GTK_WIDGET (text), controller);
controller = completion->entry_focus_controller = gtk_event_controller_focus_new ();
gtk_event_controller_set_static_name (controller, "gtk-entry-completion");
gtk_event_controller_set_name (controller, "gtk-entry-completion");
g_signal_connect_swapped (controller, "leave", G_CALLBACK (text_focus_out), completion);
gtk_widget_add_controller (GTK_WIDGET (text), controller);
-29
View File
@@ -110,35 +110,6 @@ typedef enum
GTK_BASELINE_POSITION_BOTTOM
} GtkBaselinePosition;
/**
* GtkContentFit:
* @GTK_CONTENT_FIT_FILL: Make the content fill the entire allocation,
* without taking its aspect ratio in consideration. The resulting
* content will appear as stretched if its aspect ratio is different
* from the allocation aspect ratio.
* @GTK_CONTENT_FIT_CONTAIN: Scale the content to fit the allocation,
* while taking its aspect ratio in consideration. The resulting
* content will appear as letterboxed if its aspect ratio is different
* from the allocation aspect ratio.
* @GTK_CONTENT_FIT_COVER: Cover the entire allocation, while taking
* the content aspect ratio in consideration. The resulting content
* will appear as clipped if its aspect ratio is different from the
* allocation aspect ratio.
* @GTK_CONTENT_FIT_SCALE_DOWN: The content is scaled down to fit the
* allocation, if needed, otherwise its original size is used.
*
* Controls how a content should be made to fit inside an allocation.
*
* Since: 4.8
*/
typedef enum
{
GTK_CONTENT_FIT_FILL,
GTK_CONTENT_FIT_CONTAIN,
GTK_CONTENT_FIT_COVER,
GTK_CONTENT_FIT_SCALE_DOWN,
} GtkContentFit;
/**
* GtkDeleteType:
* @GTK_DELETE_CHARS: Delete characters.
+3 -30
View File
@@ -66,7 +66,6 @@ struct _GtkEventControllerPrivate
char *name;
GtkWidget *target;
GdkEvent *event;
unsigned int name_is_static : 1;
};
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkEventController, gtk_event_controller, G_TYPE_OBJECT)
@@ -174,9 +173,8 @@ gtk_event_controller_finalize (GObject *object)
{
GtkEventController *self = GTK_EVENT_CONTROLLER (object);
GtkEventControllerPrivate *priv = gtk_event_controller_get_instance_private (self);
if (!priv->name_is_static)
g_free (priv->name);
g_free (priv->name);
G_OBJECT_CLASS (gtk_event_controller_parent_class)->finalize (object);
}
@@ -573,33 +571,8 @@ gtk_event_controller_set_name (GtkEventController *controller,
g_return_if_fail (GTK_IS_EVENT_CONTROLLER (controller));
if (!priv->name_is_static)
g_free (priv->name);
g_free (priv->name);
priv->name = g_strdup (name);
priv->name_is_static = FALSE;
}
/**
* gtk_event_controller_set_static_name:
* @controller: a `GtkEventController`
* @name: (nullable): a name for @controller, must be a static string
*
* Sets a name on the controller that can be used for debugging.
*
* Since: 4.8
*/
void
gtk_event_controller_set_static_name (GtkEventController *controller,
const char *name)
{
GtkEventControllerPrivate *priv = gtk_event_controller_get_instance_private (controller);
g_return_if_fail (GTK_IS_EVENT_CONTROLLER (controller));
if (!priv->name_is_static)
g_free (priv->name);
priv->name = (char *)name;
priv->name_is_static = TRUE;
}
GtkWidget *
-3
View File
@@ -68,9 +68,6 @@ const char * gtk_event_controller_get_name (GtkEventControll
GDK_AVAILABLE_IN_ALL
void gtk_event_controller_set_name (GtkEventController *controller,
const char *name);
GDK_AVAILABLE_IN_4_8
void gtk_event_controller_set_static_name (GtkEventController *controller,
const char *name);
GDK_AVAILABLE_IN_ALL
GdkEvent * gtk_event_controller_get_current_event (GtkEventController *controller);
+1 -1
View File
@@ -28,7 +28,7 @@
* events in this case leave from the old active window's focus
* location to the new active window's one.
* @GTK_CROSSING_POINTER: The pointer moved from one widget to another
* @GTK_CROSSING_DROP: An active drag moved from one widget to another
* @GTK_CROSSING_POINTER: An active drag moved from one widget to another
*
* We emit various kinds of crossing events when the target widget
* for keyboard or pointer events changes.
+19 -53
View File
@@ -85,8 +85,6 @@ struct _GtkEventControllerScroll
/* For discrete event coalescing */
double cur_dx;
double cur_dy;
double last_cur_dx;
double last_cur_dy;
GdkScrollUnit cur_unit;
@@ -339,17 +337,6 @@ gtk_event_controller_scroll_handle_hold_event (GtkEventController *controller,
return GDK_EVENT_PROPAGATE;
}
static gboolean
should_reset_discrete_acc (double current_delta,
double last_delta)
{
if (last_delta == 0)
return TRUE;
return (current_delta < 0 && last_delta > 0) ||
(current_delta > 0 && last_delta < 0);
}
static gboolean
gtk_event_controller_scroll_handle_event (GtkEventController *controller,
GdkEvent *event,
@@ -429,51 +416,30 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
}
else
{
gdk_scroll_event_get_deltas (event, &dx, &dy);
switch (direction)
{
case GDK_SCROLL_UP:
dy -= 1;
break;
case GDK_SCROLL_DOWN:
dy += 1;
break;
case GDK_SCROLL_LEFT:
dx -= 1;
break;
case GDK_SCROLL_RIGHT:
dx += 1;
break;
case GDK_SCROLL_SMOOTH:
default:
g_assert_not_reached ();
break;
}
if ((scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_VERTICAL) == 0)
dy = 0;
if ((scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_HORIZONTAL) == 0)
dx = 0;
if (scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_DISCRETE)
{
int steps;
if (dx != 0)
{
if (should_reset_discrete_acc (dx, scroll->last_cur_dx))
scroll->cur_dx = 0;
scroll->last_cur_dx = dx;
}
if (dy != 0)
{
if (should_reset_discrete_acc (dy, scroll->last_cur_dy))
scroll->cur_dy = 0;
scroll->last_cur_dy = dy;
}
scroll->cur_dx += dx;
scroll->cur_dy += dy;
dx = dy = 0;
if (ABS (scroll->cur_dx) >= 1)
{
steps = trunc (scroll->cur_dx);
scroll->cur_dx -= steps;
dx = steps;
}
if (ABS (scroll->cur_dy) >= 1)
{
steps = trunc (scroll->cur_dy);
scroll->cur_dy -= steps;
dy = steps;
}
}
}
scroll->cur_unit = scroll_unit;
-8
View File
@@ -7761,14 +7761,6 @@ captured_key (GtkEventControllerKey *controller,
if (keyval == GDK_KEY_slash)
return GDK_EVENT_PROPAGATE;
if (impl->location_entry)
{
GtkWidget *focus = gtk_root_get_focus (gtk_widget_get_root (GTK_WIDGET (impl)));
if (focus && gtk_widget_is_ancestor (focus, impl->location_entry))
return GDK_EVENT_PROPAGATE;
}
handled = gtk_event_controller_key_forward (controller, GTK_WIDGET (impl->search_entry));
if (handled == GDK_EVENT_STOP)
operation_mode_set (impl, OPERATION_MODE_SEARCH);
-1
View File
@@ -181,7 +181,6 @@ setup_tweak_button (GtkFontChooserDialog *dialog)
gtk_widget_set_focus_on_click (button, FALSE);
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_button_set_icon_name (GTK_BUTTON (button), "emblem-system-symbolic");
gtk_widget_set_tooltip_text (button, _("Change Font Features"));
header = gtk_dialog_get_header_bar (GTK_DIALOG (dialog));
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
+113 -395
View File
@@ -62,7 +62,6 @@
#include "gtklistview.h"
#include "gtksortlistmodel.h"
#include "gtkstringsorter.h"
#include "gtkdropdown.h"
#include <hb-ot.h>
@@ -1883,114 +1882,76 @@ find_affected_text (GtkFontChooserWidget *fontchooser,
{
unsigned int lookup_indexes[32];
unsigned int lookup_count = 32;
unsigned int count;
int count;
int n_chars = 0;
count = hb_ot_layout_feature_get_characters (hb_face,
HB_OT_TAG_GSUB,
feature_index,
0,
NULL, NULL);
count = hb_ot_layout_feature_get_lookups (hb_face,
HB_OT_TAG_GSUB,
feature_index,
0,
&lookup_count,
lookup_indexes);
if (count > 0)
{
hb_codepoint_t *ch;
hb_set_t *glyphs_before = NULL;
hb_set_t *glyphs_after = NULL;
hb_set_t *glyphs_output = NULL;
hb_set_t *glyphs_input;
hb_codepoint_t gid;
char buf[5] = { 0, };
ch = g_alloca (sizeof (hb_codepoint_t) * count);
hb_ot_layout_feature_get_characters (hb_face,
HB_OT_TAG_GSUB,
feature_index,
0,
&count,
ch);
hb_tag_to_string (feature_tag, buf);
for (unsigned int i = 0; i < MIN (count, max_chars); i++)
g_string_append_unichar (chars, ch[i]);
}
else
{
count = hb_ot_layout_feature_get_lookups (hb_face,
HB_OT_TAG_GSUB,
feature_index,
0,
&lookup_count,
lookup_indexes);
if (count > 0)
glyphs_input = hb_set_create ();
for (int i = 0; i < count; i++)
{
hb_set_t *glyphs_before = NULL;
hb_set_t *glyphs_after = NULL;
hb_set_t *glyphs_output = NULL;
hb_set_t *glyphs_input;
hb_codepoint_t gid;
char buf[5] = { 0, };
hb_tag_to_string (feature_tag, buf);
glyphs_input = hb_set_create ();
for (int i = 0; i < count; i++)
{
hb_ot_layout_lookup_collect_glyphs (hb_face,
HB_OT_TAG_GSUB,
lookup_indexes[i],
glyphs_before,
glyphs_input,
glyphs_after,
glyphs_output);
}
if (!fontchooser->glyphmap)
{
fontchooser->glyphmap = hb_map_create ();
for (hb_codepoint_t ch = 0; ch < 0xffff; ch++)
{
hb_codepoint_t glyph = 0;
if (hb_font_get_nominal_glyph (hb_font, ch, &glyph) &&
!hb_map_has (fontchooser->glyphmap, glyph))
hb_map_set (fontchooser->glyphmap, glyph, ch);
}
}
gid = HB_SET_VALUE_INVALID;
while (hb_set_next (glyphs_input, &gid))
{
hb_codepoint_t ch;
if (n_chars == max_chars)
{
g_string_append (chars, "");
break;
}
ch = hb_map_get (fontchooser->glyphmap, gid);
if (ch != HB_MAP_VALUE_INVALID)
{
g_string_append_unichar (chars, (gunichar)ch);
n_chars++;
}
}
hb_set_destroy (glyphs_input);
hb_ot_layout_lookup_collect_glyphs (hb_face,
HB_OT_TAG_GSUB,
lookup_indexes[i],
glyphs_before,
glyphs_input,
glyphs_after,
glyphs_output);
}
if (!fontchooser->glyphmap)
{
fontchooser->glyphmap = hb_map_create ();
for (hb_codepoint_t ch = 0; ch < 0xffff; ch++)
{
hb_codepoint_t glyph = 0;
if (hb_font_get_nominal_glyph (hb_font, ch, &glyph) &&
!hb_map_has (fontchooser->glyphmap, glyph))
hb_map_set (fontchooser->glyphmap, glyph, ch);
}
}
gid = HB_SET_VALUE_INVALID;
while (hb_set_next (glyphs_input, &gid))
{
hb_codepoint_t ch;
if (n_chars == max_chars)
{
g_string_append (chars, "");
break;
}
ch = hb_map_get (fontchooser->glyphmap, gid);
if (ch != HB_MAP_VALUE_INVALID)
{
g_string_append_unichar (chars, (gunichar)ch);
n_chars++;
}
}
hb_set_destroy (glyphs_input);
}
}
return g_string_free (chars, FALSE);
}
static char *
get_name (hb_face_t *hb_face,
hb_ot_name_id_t id)
{
unsigned int len;
char *name;
len = hb_ot_name_get_utf8 (hb_face, id, HB_LANGUAGE_INVALID, NULL, NULL);
len++;
name = g_new (char, len);
hb_ot_name_get_utf8 (hb_face, id, HB_LANGUAGE_INVALID, &len, name);
return name;
}
static void
update_feature_label (GtkFontChooserWidget *fontchooser,
FeatureItem *item,
@@ -2000,15 +1961,14 @@ update_feature_label (GtkFontChooserWidget *fontchooser,
{
hb_face_t *hb_face;
unsigned int script_index, lang_index, feature_index;
hb_ot_name_id_t label_id, first_param_id;
unsigned int num_params;
const char *feat[] = { "salt", "swsh", "nalt", NULL };
hb_ot_name_id_t id;
unsigned int len;
char *label;
hb_face = hb_font_get_face (hb_font);
if (!g_strv_contains (feat, item->name) &&
(!(g_str_has_prefix (item->name, "ss") || g_str_has_prefix (item->name, "cv")) ||
!g_ascii_isdigit (item->name[2]) || !g_ascii_isdigit (item->name[3])))
if (!(g_str_has_prefix (item->name, "ss") || g_str_has_prefix (item->name, "cv")) ||
!g_ascii_isdigit (item->name[2]) || !g_ascii_isdigit (item->name[3]))
return;
hb_ot_layout_table_find_script (hb_face, HB_OT_TAG_GSUB, script_tag, &script_index);
@@ -2017,106 +1977,23 @@ update_feature_label (GtkFontChooserWidget *fontchooser,
hb_ot_layout_script_find_language (hb_face, HB_OT_TAG_GSUB, script_index, lang_tag, &lang_index);
G_GNUC_END_IGNORE_DEPRECATIONS
if (hb_ot_layout_language_find_feature (hb_face, HB_OT_TAG_GSUB, script_index, lang_index, item->tag, &feature_index))
if (hb_ot_layout_language_find_feature (hb_face, HB_OT_TAG_GSUB, script_index, lang_index, item->tag, &feature_index) &&
hb_ot_layout_feature_get_name_ids (hb_face, HB_OT_TAG_GSUB, feature_index, &id, NULL, NULL, NULL, NULL))
{
char *label;
len = hb_ot_name_get_utf8 (hb_face, id, HB_LANGUAGE_INVALID, NULL, NULL);
len++;
label = g_new (char, len);
hb_ot_name_get_utf8 (hb_face, id, HB_LANGUAGE_INVALID, &len, label);
if (!hb_ot_layout_feature_get_name_ids (hb_face, HB_OT_TAG_GSUB, feature_index, &label_id, NULL, NULL, &num_params, &first_param_id))
{
label_id = HB_OT_NAME_ID_INVALID;
num_params = 0;
}
if (label_id != HB_OT_NAME_ID_INVALID)
label = get_name (hb_face, label_id);
else
label = get_feature_display_name (item->tag);
if (GTK_IS_CHECK_BUTTON (item->feat))
gtk_check_button_set_label (GTK_CHECK_BUTTON (item->feat), label);
else
{
GtkWidget *l = gtk_widget_get_prev_sibling (item->feat);
gtk_label_set_label (GTK_LABEL (l), label);
}
char *s = g_strdup_printf ("%s (%s)", label, item->name);
gtk_check_button_set_label (GTK_CHECK_BUTTON (item->feat), s);
g_free (s);
g_free (label);
if (GTK_IS_DROP_DOWN (item->feat))
{
unsigned int n_lookups;
GtkStringList *strings;
unsigned int *lookups;
unsigned int n_alternates;
n_lookups = hb_ot_layout_feature_get_lookups (hb_face,
HB_OT_TAG_GSUB,
feature_index,
0,
NULL, NULL);
lookups = g_alloca (sizeof (unsigned int) * n_lookups);
hb_ot_layout_feature_get_lookups (hb_face,
HB_OT_TAG_GSUB,
feature_index,
0,
&n_lookups,
lookups);
n_alternates = 0;
for (unsigned int l = 0; l < n_lookups; l++)
{
hb_set_t *glyphs;
hb_codepoint_t glyph_index;
unsigned int lookup = lookups[l];
glyphs = hb_set_create ();
hb_ot_layout_lookup_collect_glyphs (hb_face,
HB_OT_TAG_GSUB,
lookup,
NULL,
glyphs,
NULL, NULL);
glyph_index = HB_SET_VALUE_INVALID;
while (hb_set_next (glyphs, &glyph_index))
n_alternates = MAX (n_alternates,
hb_ot_layout_lookup_get_glyph_alternates (hb_face,
lookup,
glyph_index,
0, NULL, NULL));
hb_set_destroy (glyphs);
}
strings = gtk_string_list_new (NULL);
gtk_string_list_append (strings, C_("Font feature value", "Default"));
for (unsigned int i = 0; i < num_params; i++)
{
char *name;
name = get_name (hb_face, first_param_id + i);
gtk_string_list_append (strings, name);
g_free (name);
}
for (int i = num_params; i < n_alternates; i++)
{
char buf[64];
g_snprintf (buf, sizeof (buf), "%d", i + 1);
gtk_string_list_append (strings, buf);
}
if (g_list_model_get_n_items (G_LIST_MODEL (strings)) == 1)
gtk_string_list_append (strings, C_("Font feature value", "Enable"));
gtk_drop_down_set_model (GTK_DROP_DOWN (item->feat), G_LIST_MODEL (strings));
g_object_unref (strings);
}
}
else
{
char *label = get_feature_display_name (item->tag);
label = get_feature_display_name (item->tag);
gtk_check_button_set_label (GTK_CHECK_BUTTON (item->feat), label);
g_free (label);
}
@@ -2131,29 +2008,17 @@ update_feature_example (GtkFontChooserWidget *fontchooser,
PangoFontDescription *font_desc)
{
const char *letter_case[] = { "smcp", "c2sc", "pcap", "c2pc", "unic", "cpsp", "case", NULL };
const char *number_case[] = { "xxnc", "lnum", "onum", NULL };
const char *number_spacing[] = { "xxns", "pnum", "tnum", NULL };
const char *fraction[] = { "xxnf", "frac", "afrc", NULL };
const char *number_case[] = { "xxxx", "lnum", "onum", NULL };
const char *number_spacing[] = { "xxxx", "pnum", "tnum", NULL };
const char *number_formatting[] = { "zero", "nalt", "frac", NULL };
const char *char_variants[] = {
"zero", "nalt",
"swsh", "cswh", "calt", "falt", "hist", "salt", "jalt", "titl", "rand",
"ss01", "ss02", "ss03", "ss04", "ss05", "ss06", "ss07", "ss08", "ss09", "ss10",
"ss11", "ss12", "ss13", "ss14", "ss15", "ss16", "ss17", "ss18", "ss19", "ss20",
"cv01", "cv02", "cv03", "cv04", "cv05", "cv06", "cv07", "cv08", "cv09", "cv10",
"cv11", "cv12", "cv13", "cv14", "cv15", "cv16", "cv17", "cv18", "cv19", "cv20",
"cv21", "cv22", "cv23", "cv24", "cv25", "cv26", "cv27", "cv28", "cv29", "cv30",
"cv31", "cv32", "cv33", "cv34", "cv35", "cv36", "cv37", "cv38", "cv39", "cv40",
"cv41", "cv42", "cv43", "cv44", "cv45", "cv46", "cv47", "cv48", "cv49", "cv50",
"cv51", "cv52", "cv53", "cv54", "cv55", "cv56", "cv57", "cv58", "cv59", "cv60",
"cv61", "cv62", "cv63", "cv64", "cv65", "cv66", "cv67", "cv68", "cv69", "cv70",
"cv71", "cv72", "cv73", "cv74", "cv75", "cv76", "cv77", "cv78", "cv79", "cv80",
"cv81", "cv82", "cv83", "cv84", "cv85", "cv86", "cv87", "cv88", "cv89", "cv90",
"cv91", "cv92", "cv93", "cv94", "cv95", "cv96", "cv97", "cv98", "cv99",
NULL };
if (g_strv_contains (number_case, item->name) ||
g_strv_contains (number_spacing, item->name) ||
g_strv_contains (fraction, item->name))
g_strv_contains (number_spacing, item->name))
{
PangoAttrList *attrs;
PangoAttribute *attr;
@@ -2170,15 +2035,13 @@ update_feature_example (GtkFontChooserWidget *fontchooser,
attr = pango_attr_font_features_new (str);
pango_attr_list_insert (attrs, attr);
if (g_strv_contains (fraction, item->name))
gtk_label_set_text (GTK_LABEL (item->example), "1/2 2/3 7/8");
else
gtk_label_set_text (GTK_LABEL (item->example), "0123456789");
gtk_label_set_text (GTK_LABEL (item->example), "0123456789");
gtk_label_set_attributes (GTK_LABEL (item->example), attrs);
pango_attr_list_unref (attrs);
}
else if (g_strv_contains (letter_case, item->name) ||
g_strv_contains (number_formatting, item->name) ||
g_strv_contains (char_variants, item->name))
{
char *input = NULL;
@@ -2190,6 +2053,10 @@ update_feature_example (GtkFontChooserWidget *fontchooser,
input = g_strdup ("AaBbCc…");
else if (strcmp (item->name, "zero") == 0)
input = g_strdup ("0");
else if (strcmp (item->name, "frac") == 0)
input = g_strdup ("1/2 2/3 7/8");
else if (strcmp (item->name, "nalt") == 0)
input = find_affected_text (fontchooser, item->tag, hb_font, script_tag, lang_tag, 3);
else
input = find_affected_text (fontchooser, item->tag, hb_font, script_tag, lang_tag, 10);
@@ -2200,7 +2067,7 @@ update_feature_example (GtkFontChooserWidget *fontchooser,
PangoFontDescription *desc;
char *str;
text = g_strconcat (input, " ", input, NULL);
text = g_strconcat (input, " ", input, NULL);
attrs = pango_attr_list_new ();
@@ -2213,17 +2080,9 @@ update_feature_example (GtkFontChooserWidget *fontchooser,
attr->start_index = 0;
attr->end_index = strlen (input);
pango_attr_list_insert (attrs, attr);
attr = pango_attr_fallback_new (FALSE);
attr->start_index = 0;
attr->end_index = strlen (input);
pango_attr_list_insert (attrs, attr);
str = g_strconcat (item->name, " 1", NULL);
attr = pango_attr_font_features_new (str);
attr->start_index = strlen (input) + strlen (" ");
attr->end_index = attr->start_index + strlen (input);
pango_attr_list_insert (attrs, attr);
attr = pango_attr_fallback_new (FALSE);
attr->start_index = strlen (input) + strlen ("");
attr->start_index = strlen (input) + strlen (" ");
attr->end_index = attr->start_index + strlen (input);
pango_attr_list_insert (attrs, attr);
@@ -2250,10 +2109,9 @@ font_feature_toggled_cb (GtkCheckButton *check_button,
}
static void
add_check_group (GtkFontChooserWidget *fontchooser,
const char *title,
const char **tags,
unsigned int n_tags)
add_check_group (GtkFontChooserWidget *fontchooser,
const char *title,
const char **tags)
{
GtkWidget *label;
GtkWidget *group;
@@ -2273,7 +2131,7 @@ add_check_group (GtkFontChooserWidget *fontchooser,
pango_attr_list_unref (attrs);
gtk_box_append (GTK_BOX (group), label);
for (i = 0; i < n_tags; i++)
for (i = 0; tags[i]; i++)
{
hb_tag_t tag;
GtkWidget *feat;
@@ -2321,90 +2179,9 @@ add_check_group (GtkFontChooserWidget *fontchooser,
}
static void
font_enum_feature_changed_cb (GObject *object,
GParamSpec *pspec,
gpointer data)
{
GtkFontChooserWidget *fontchooser = data;
update_font_features (fontchooser);
}
static void
add_enum_group (GtkFontChooserWidget *fontchooser,
const char *title,
const char **tags,
unsigned int n_tags)
{
GtkWidget *label;
GtkWidget *group;
PangoAttrList *attrs;
int i;
group = gtk_grid_new ();
gtk_grid_set_row_spacing (GTK_GRID (group), 6);
gtk_grid_set_column_spacing (GTK_GRID (group), 12);
if (title)
{
label = gtk_label_new (title);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_widget_set_halign (label, GTK_ALIGN_START);
g_object_set (label, "margin-top", 10, "margin-bottom", 10, NULL);
attrs = pango_attr_list_new ();
pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
gtk_label_set_attributes (GTK_LABEL (label), attrs);
pango_attr_list_unref (attrs);
gtk_grid_attach (GTK_GRID (group), label, 0, -1, 3, 1);
}
for (i = 0; i < n_tags; i++)
{
hb_tag_t tag;
GtkWidget *feat;
FeatureItem *item;
GtkWidget *example;
char *name;
tag = hb_tag_from_string (tags[i], -1);
name = get_feature_display_name (tag);
label = gtk_label_new (name);
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_grid_attach (GTK_GRID (group), label, 0, i, 1, 1);
g_free (name);
feat = gtk_drop_down_new (NULL, NULL);
gtk_grid_attach (GTK_GRID (group), feat, 1, i, 1, 1);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), feat);
g_signal_connect (feat, "notify::selected", G_CALLBACK (font_enum_feature_changed_cb), fontchooser);
example = gtk_label_new ("");
gtk_label_set_selectable (GTK_LABEL (example), TRUE);
gtk_widget_set_halign (example, GTK_ALIGN_START);
gtk_grid_attach (GTK_GRID (group), example, 2, i, 1, 1);
item = g_new (FeatureItem, 1);
item->name = tags[i];
item->tag = tag;
item->top = NULL;
item->feat = feat;
item->example = example;
fontchooser->feature_items = g_list_prepend (fontchooser->feature_items, item);
}
gtk_box_append (GTK_BOX (fontchooser->feature_box), group);
}
static void
add_radio_group (GtkFontChooserWidget *fontchooser,
const char *title,
const char **tags,
unsigned int n_tags)
add_radio_group (GtkFontChooserWidget *fontchooser,
const char *title,
const char **tags)
{
GtkWidget *label;
GtkWidget *group;
@@ -2425,7 +2202,7 @@ add_radio_group (GtkFontChooserWidget *fontchooser,
pango_attr_list_unref (attrs);
gtk_box_append (GTK_BOX (group), label);
for (i = 0; i < n_tags; i++)
for (i = 0; tags[i]; i++)
{
hb_tag_t tag;
GtkWidget *feat;
@@ -2472,40 +2249,23 @@ add_radio_group (GtkFontChooserWidget *fontchooser,
static void
gtk_font_chooser_widget_populate_features (GtkFontChooserWidget *fontchooser)
{
const char *ligatures[] = { "liga", "dlig", "hlig", "clig" };
const char *letter_case[] = { "smcp", "c2sc", "pcap", "c2pc", "unic", "cpsp", "case" };
const char *number_case[] = { "xxnc", "lnum", "onum" };
const char *number_spacing[] = { "xxns", "pnum", "tnum" };
const char *fractions[] = { "xxnf", "frac", "afrc" };
const char *style_variants[] = {
"zero", "cswh", "calt", "falt", "hist", "jalt", "titl", "rand",
const char *ligatures[] = { "liga", "dlig", "hlig", "clig", NULL };
const char *letter_case[] = { "smcp", "c2sc", "pcap", "c2pc", "unic", "cpsp", "case", NULL };
const char *number_case[] = { "xxxx", "lnum", "onum", NULL };
const char *number_spacing[] = { "xxxx", "pnum", "tnum", NULL };
const char *number_formatting[] = { "zero", "nalt", "frac", NULL };
const char *char_variants[] = {
"swsh", "cswh", "calt", "falt", "hist", "salt", "jalt", "titl", "rand",
"ss01", "ss02", "ss03", "ss04", "ss05", "ss06", "ss07", "ss08", "ss09", "ss10",
"ss11", "ss12", "ss13", "ss14", "ss15", "ss16", "ss17", "ss18", "ss19", "ss20",
};
const char *style_variants2[] = {
"swsh", "salt", "nalt"
};
const char *char_variants[] = {
"cv01", "cv02", "cv03", "cv04", "cv05", "cv06", "cv07", "cv08", "cv09", "cv10",
"cv11", "cv12", "cv13", "cv14", "cv15", "cv16", "cv17", "cv18", "cv19", "cv20",
"cv21", "cv22", "cv23", "cv24", "cv25", "cv26", "cv27", "cv28", "cv29", "cv30",
"cv31", "cv32", "cv33", "cv34", "cv35", "cv36", "cv37", "cv38", "cv39", "cv40",
"cv41", "cv42", "cv43", "cv44", "cv45", "cv46", "cv47", "cv48", "cv49", "cv50",
"cv51", "cv52", "cv53", "cv54", "cv55", "cv56", "cv57", "cv58", "cv59", "cv60",
"cv61", "cv62", "cv63", "cv64", "cv65", "cv66", "cv67", "cv68", "cv69", "cv70",
"cv71", "cv72", "cv73", "cv74", "cv75", "cv76", "cv77", "cv78", "cv79", "cv80",
"cv81", "cv82", "cv83", "cv84", "cv85", "cv86", "cv87", "cv88", "cv89", "cv90",
"cv91", "cv92", "cv93", "cv94", "cv95", "cv96", "cv97", "cv98", "cv99",
};
NULL };
add_check_group (fontchooser, _("Ligatures"), ligatures, G_N_ELEMENTS (ligatures));
add_check_group (fontchooser, _("Letter Case"), letter_case, G_N_ELEMENTS (letter_case));
add_radio_group (fontchooser, _("Number Case"), number_case, G_N_ELEMENTS (number_case));
add_radio_group (fontchooser, _("Number Spacing"), number_spacing, G_N_ELEMENTS (number_spacing));
add_radio_group (fontchooser, _("Fractions"), fractions, G_N_ELEMENTS (fractions));
add_check_group (fontchooser, _("Style Variations"), style_variants, G_N_ELEMENTS (style_variants));
add_enum_group (fontchooser, NULL, style_variants2, G_N_ELEMENTS (style_variants2));
add_enum_group (fontchooser, _("Character Variations"), char_variants, G_N_ELEMENTS (char_variants));
add_check_group (fontchooser, _("Ligatures"), ligatures);
add_check_group (fontchooser, _("Letter Case"), letter_case);
add_radio_group (fontchooser, _("Number Case"), number_case);
add_radio_group (fontchooser, _("Number Spacing"), number_spacing);
add_check_group (fontchooser, _("Number Formatting"), number_formatting);
add_check_group (fontchooser, _("Character Variants"), char_variants);
update_font_features (fontchooser);
}
@@ -2526,18 +2286,8 @@ gtk_font_chooser_widget_update_font_features (GtkFontChooserWidget *fontchooser)
for (l = fontchooser->feature_items; l; l = l->next)
{
FeatureItem *item = l->data;
if (item->top)
{
gtk_widget_hide (item->top);
gtk_widget_hide (gtk_widget_get_parent (item->top));
}
else
{
gtk_widget_hide (gtk_widget_get_parent (item->feat));
gtk_widget_hide (item->feat);
gtk_widget_hide (gtk_widget_get_prev_sibling (item->feat));
gtk_widget_hide (item->example);
}
gtk_widget_hide (item->top);
gtk_widget_hide (gtk_widget_get_parent (item->top));
}
if ((fontchooser->level & GTK_FONT_CHOOSER_LEVEL_FEATURES) == 0)
@@ -2554,14 +2304,13 @@ gtk_font_chooser_widget_update_font_features (GtkFontChooserWidget *fontchooser)
hb_tag_t features[80];
unsigned int count;
unsigned int n_features;
hb_tag_t *feat;
hb_face = hb_font_get_face (hb_font);
find_language_and_script (fontchooser, hb_face, &lang_tag, &script_tag);
n_features = 0;
for (i = 0; i < G_N_ELEMENTS (table); i++)
for (i = 0; i < 2; i++)
{
hb_ot_layout_table_find_script (hb_face, table[i], script_tag, &script_index);
@@ -2569,15 +2318,14 @@ gtk_font_chooser_widget_update_font_features (GtkFontChooserWidget *fontchooser)
hb_ot_layout_script_find_language (hb_face, table[i], script_index, lang_tag, &lang_index);
G_GNUC_END_IGNORE_DEPRECATIONS
feat = features + n_features;
count = G_N_ELEMENTS (features) - n_features;
count = G_N_ELEMENTS (features);
hb_ot_layout_language_get_feature_tags (hb_face,
table[i],
script_index,
lang_index,
n_features,
&count,
feat);
features);
n_features += count;
}
@@ -2586,29 +2334,12 @@ gtk_font_chooser_widget_update_font_features (GtkFontChooserWidget *fontchooser)
for (l = fontchooser->feature_items; l; l = l->next)
{
FeatureItem *item = l->data;
if (strncmp (item->name, "xx", 2) == 0)
{
update_feature_example (fontchooser, item, hb_font, script_tag, lang_tag, fontchooser->font_desc);
continue;
}
if (item->tag != features[j])
continue;
has_feature = TRUE;
if (item->top)
{
gtk_widget_show (item->top);
gtk_widget_show (gtk_widget_get_parent (item->top));
}
else
{
gtk_widget_show (gtk_widget_get_parent (item->feat));
gtk_widget_show (item->feat);
gtk_widget_show (gtk_widget_get_prev_sibling (item->feat));
gtk_widget_show (item->example);
}
gtk_widget_show (item->top);
gtk_widget_show (gtk_widget_get_parent (item->top));
update_feature_label (fontchooser, item, hb_font, script_tag, lang_tag);
update_feature_example (fontchooser, item, hb_font, script_tag, lang_tag, fontchooser->font_desc);
@@ -2659,7 +2390,7 @@ update_font_features (GtkFontChooserWidget *fontchooser)
if (GTK_IS_CHECK_BUTTON (item->feat) && g_object_get_data (G_OBJECT (item->feat), "default"))
{
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (item->feat)) &&
strncmp (item->name, "xx", 2) != 0)
strcmp (item->name, "xxxx") != 0)
{
hb_feature_to_string (&(hb_feature_t) { item->tag, 1, 0, -1 }, buf, sizeof (buf));
if (s->len > 0)
@@ -2680,19 +2411,6 @@ update_font_features (GtkFontChooserWidget *fontchooser)
g_string_append_c (s, ',');
g_string_append (s, buf);
}
else if (GTK_IS_DROP_DOWN (item->feat))
{
guint value;
value = gtk_drop_down_get_selected (GTK_DROP_DOWN (item->feat));
if (value == 0 || value == GTK_INVALID_LIST_POSITION)
continue;
hb_feature_to_string (&(hb_feature_t) { item->tag, value, 0, -1 }, buf, sizeof (buf));
if (s->len > 0)
g_string_append_c (s, ',');
g_string_append (s, buf);
}
}
if (g_strcmp0 (fontchooser->font_features, s->str) != 0)
+39 -2
View File
@@ -162,6 +162,7 @@ struct _GtkGesturePrivate
GdkDevice *device;
GList *group_link;
guint n_points;
guint hold_timeout_id;
guint recognized : 1;
guint touchpad : 1;
};
@@ -174,6 +175,8 @@ static guint signals[N_SIGNALS] = { 0 };
gdk_event_get_event_type (e) == GDK_TOUCHPAD_PINCH || \
gdk_event_get_event_type (e) == GDK_TOUCHPAD_HOLD)
#define HOLD_TIMEOUT_MS 50
GList * _gtk_gesture_get_group_link (GtkGesture *gesture);
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkGesture, gtk_gesture, GTK_TYPE_EVENT_CONTROLLER)
@@ -222,6 +225,7 @@ gtk_gesture_finalize (GObject *object)
gtk_gesture_ungroup (gesture);
g_list_free (priv->group_link);
g_clear_handle_id (&priv->hold_timeout_id, g_source_remove);
g_hash_table_destroy (priv->points);
@@ -579,6 +583,22 @@ _gtk_gesture_cancel_all (GtkGesture *gesture)
_gtk_gesture_check_empty (gesture);
}
static gboolean
gtk_gesture_hold_timeout (gpointer user_data)
{
GtkGesture *gesture;
GtkGesturePrivate *priv;
gesture = user_data;
priv = gtk_gesture_get_instance_private (gesture);
if (priv->touchpad)
_gtk_gesture_cancel_sequence (gesture, priv->last_sequence);
priv->hold_timeout_id = 0;
return G_SOURCE_REMOVE;
}
static gboolean
gesture_within_surface (GtkGesture *gesture,
GdkSurface *surface)
@@ -644,6 +664,10 @@ gtk_gesture_handle_event (GtkEventController *controller,
(event_type == GDK_TOUCHPAD_PINCH && phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN) ||
(event_type == GDK_TOUCHPAD_HOLD && phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN))
{
if ((event_type == GDK_TOUCHPAD_PINCH || event_type == GDK_TOUCHPAD_SWIPE) &&
_gtk_gesture_has_matching_touchpoints (gesture))
g_clear_handle_id (&priv->hold_timeout_id, g_source_remove);
if (_gtk_gesture_update_point (gesture, event, target, x, y, TRUE))
{
gboolean triggered_recognition;
@@ -714,12 +738,20 @@ gtk_gesture_handle_event (GtkEventController *controller,
_gtk_gesture_cancel_sequence (gesture, sequence);
}
else if ((event_type == GDK_TOUCHPAD_SWIPE && phase == GDK_TOUCHPAD_GESTURE_PHASE_CANCEL) ||
(event_type == GDK_TOUCHPAD_PINCH && phase == GDK_TOUCHPAD_GESTURE_PHASE_CANCEL) ||
(event_type == GDK_TOUCHPAD_HOLD && phase == GDK_TOUCHPAD_GESTURE_PHASE_CANCEL))
(event_type == GDK_TOUCHPAD_PINCH && phase == GDK_TOUCHPAD_GESTURE_PHASE_CANCEL))
{
if (priv->touchpad)
_gtk_gesture_cancel_sequence (gesture, sequence);
}
else if (event_type == GDK_TOUCHPAD_HOLD && phase == GDK_TOUCHPAD_GESTURE_PHASE_CANCEL)
{
if (priv->hold_timeout_id == 0)
{
priv->hold_timeout_id = g_timeout_add (HOLD_TIMEOUT_MS,
gtk_gesture_hold_timeout,
gesture);
}
}
else if (event_type == GDK_GRAB_BROKEN)
{
GdkSurface *surface;
@@ -745,6 +777,10 @@ gtk_gesture_handle_event (GtkEventController *controller,
static void
gtk_gesture_reset (GtkEventController *controller)
{
GtkGesture *gesture = GTK_GESTURE (controller);
GtkGesturePrivate *priv = gtk_gesture_get_instance_private (gesture);
g_clear_handle_id (&priv->hold_timeout_id, g_source_remove);
_gtk_gesture_cancel_all (GTK_GESTURE (controller));
}
@@ -913,6 +949,7 @@ gtk_gesture_init (GtkGesture *gesture)
priv->points = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) free_point_data);
priv->group_link = g_list_prepend (NULL, gesture);
priv->hold_timeout_id = 0;
}
/**
+2 -3
View File
@@ -173,7 +173,8 @@ gtk_gesture_rotate_filter_event (GtkEventController *controller,
GdkEvent *event)
{
/* Let 2-finger touchpad pinch and hold events go through */
if (gdk_event_get_event_type (event) == GDK_TOUCHPAD_PINCH)
if (gdk_event_get_event_type (event) == GDK_TOUCHPAD_PINCH ||
gdk_event_get_event_type (event) == GDK_TOUCHPAD_HOLD)
{
guint n_fingers;
@@ -184,8 +185,6 @@ gtk_gesture_rotate_filter_event (GtkEventController *controller,
else
return TRUE;
}
else if (gdk_event_get_event_type (event) == GDK_TOUCHPAD_HOLD)
return TRUE;
return GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_rotate_parent_class)->filter_event (controller, event);
}
+2 -3
View File
@@ -150,7 +150,8 @@ gtk_gesture_zoom_filter_event (GtkEventController *controller,
GdkEvent *event)
{
/* Let 2-finger touchpad pinch and hold events go through */
if (gdk_event_get_event_type (event) == GDK_TOUCHPAD_PINCH)
if (gdk_event_get_event_type (event) == GDK_TOUCHPAD_PINCH ||
gdk_event_get_event_type (event) == GDK_TOUCHPAD_HOLD)
{
guint n_fingers;
@@ -161,8 +162,6 @@ gtk_gesture_zoom_filter_event (GtkEventController *controller,
else
return TRUE;
}
else if (gdk_event_get_event_type (event) == GDK_TOUCHPAD_HOLD)
return TRUE;
return GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_zoom_parent_class)->filter_event (controller, event);
}
+17 -21
View File
@@ -204,7 +204,7 @@ cell_augment (GtkRbTree *tree,
* index of the returned row
* @offset: (out caller-allocates) (optional): stores the offset
* in pixels between y and top of cell.
* @size: (out caller-allocates) (optional): stores the height
* @offset: (out caller-allocates) (optional): stores the height
* of the cell
*
* Gets the Cell that occupies the leftmost position in the row at offset
@@ -413,19 +413,6 @@ gtk_grid_view_get_allocation_across (GtkListBase *base,
return TRUE;
}
static int
gtk_grid_view_compute_total_height (GtkGridView *self)
{
Cell *cell;
CellAugment *aug;
cell = gtk_list_item_manager_get_root (self->item_manager);
if (cell == NULL)
return 0;
aug = gtk_list_item_manager_get_item_augment (self->item_manager, cell);
return aug->size;
}
static gboolean
gtk_grid_view_get_position_from_allocation (GtkListBase *base,
int across,
@@ -441,7 +428,6 @@ gtk_grid_view_get_position_from_allocation (GtkListBase *base,
return FALSE;
n_items = gtk_list_base_get_n_items (base);
along = CLAMP (along, 0, gtk_grid_view_compute_total_height (self) - 1);
if (!gtk_grid_view_get_cell_at_y (self,
along,
&pos,
@@ -481,19 +467,16 @@ gtk_grid_view_get_items_in_rect (GtkListBase *base,
result = gtk_bitset_new_empty ();
if (rect->y >= gtk_grid_view_compute_total_height (self))
return result;
n_items = gtk_list_base_get_n_items (base);
if (n_items == 0)
return result;
first_column = fmax (floor (rect->x / self->column_width), 0);
last_column = fmin (floor ((rect->x + rect->width) / self->column_width), self->n_columns - 1);
first_column = floor (rect->x / self->column_width);
last_column = floor ((rect->x + rect->width) / self->column_width);
if (!gtk_grid_view_get_cell_at_y (self, rect->y, &first_row, NULL, NULL))
first_row = rect->y < 0 ? 0 : n_items - 1;
if (!gtk_grid_view_get_cell_at_y (self, rect->y + rect->height, &last_row, NULL, NULL))
last_row = rect->y + rect->height < 0 ? 0 : n_items - 1;
last_row = rect->y < 0 ? 0 : n_items - 1;
gtk_bitset_add_rectangle (result,
first_row + first_column,
@@ -739,6 +722,19 @@ cell_set_size (Cell *cell,
gtk_rb_tree_node_mark_dirty (cell);
}
static int
gtk_grid_view_compute_total_height (GtkGridView *self)
{
Cell *cell;
CellAugment *aug;
cell = gtk_list_item_manager_get_root (self->item_manager);
if (cell == NULL)
return 0;
aug = gtk_list_item_manager_get_item_augment (self->item_manager, cell);
return aug->size;
}
static void
gtk_grid_view_size_allocate (GtkWidget *widget,
int width,
-1
View File
@@ -36,7 +36,6 @@
#include <windows.h>
#include <shellapi.h>
#include "win32/gdkwin32.h"
#include "win32/gdkprivate-win32.h"
#endif /* G_OS_WIN32 */
#include "gtkiconthemeprivate.h"
+29 -30
View File
@@ -5692,35 +5692,8 @@ drag_scroll_timeout (gpointer data)
return TRUE;
}
static GdkDragAction
gtk_icon_view_get_action (GtkWidget *widget,
GdkDrop *drop)
{
GtkIconView *iconview = GTK_ICON_VIEW (widget);
GdkDrag *drag = gdk_drop_get_drag (drop);
GdkDragAction actions;
actions = gdk_drop_get_actions (drop);
if (drag == iconview->priv->drag &&
actions & GDK_ACTION_MOVE)
return GDK_ACTION_MOVE;
if (actions & GDK_ACTION_COPY)
return GDK_ACTION_COPY;
if (actions & GDK_ACTION_MOVE)
return GDK_ACTION_MOVE;
if (actions & GDK_ACTION_LINK)
return GDK_ACTION_LINK;
return 0;
}
static gboolean
set_destination (GtkIconView *icon_view,
GdkDrop *drop,
GtkDropTargetAsync *dest,
int x,
int y,
@@ -5807,7 +5780,7 @@ set_destination (GtkIconView *icon_view,
out:
if (can_drop)
{
*suggested_action = gtk_icon_view_get_action (widget, drop);
*suggested_action = GDK_ACTION_ALL;
gtk_icon_view_set_drag_dest_item (GTK_ICON_VIEW (widget),
path, pos);
@@ -6047,7 +6020,7 @@ gtk_icon_view_drag_motion (GtkDropTargetAsync *dest,
gboolean empty;
GdkDragAction result;
if (!set_destination (icon_view, drop, dest, x, y, &suggested_action, &target))
if (!set_destination (icon_view, dest, x, y, &suggested_action, &target))
return 0;
gtk_icon_view_get_drag_dest_item (icon_view, &path, &pos);
@@ -6112,7 +6085,7 @@ gtk_icon_view_drag_drop (GtkDropTargetAsync *dest,
if (!check_model_dnd (model, GTK_TYPE_TREE_DRAG_DEST, "drop"))
return FALSE;
if (!set_destination (icon_view, drop, dest, x, y, &suggested_action, &target))
if (!set_destination (icon_view, dest, x, y, &suggested_action, &target))
return FALSE;
path = get_logical_destination (icon_view, &drop_append_mode);
@@ -6142,6 +6115,32 @@ gtk_icon_view_drag_drop (GtkDropTargetAsync *dest,
return FALSE;
}
static GdkDragAction
gtk_icon_view_get_action (GtkWidget *widget,
GdkDrop *drop)
{
GtkIconView *iconview = GTK_ICON_VIEW (widget);
GdkDrag *drag = gdk_drop_get_drag (drop);
GdkDragAction actions;
actions = gdk_drop_get_actions (drop);
if (drag == iconview->priv->drag &&
actions & GDK_ACTION_MOVE)
return GDK_ACTION_MOVE;
if (actions & GDK_ACTION_COPY)
return GDK_ACTION_COPY;
if (actions & GDK_ACTION_MOVE)
return GDK_ACTION_MOVE;
if (actions & GDK_ACTION_LINK)
return GDK_ACTION_LINK;
return 0;
}
static void
gtk_icon_view_drag_data_received (GObject *source,
GAsyncResult *result,
+10 -13
View File
@@ -256,7 +256,7 @@ gtk_im_context_ime_set_client_widget (GtkIMContext *context,
if (surface != NULL)
{
HWND hwnd = gdk_win32_surface_get_handle (surface);
HWND hwnd = gdk_win32_surface_get_impl_hwnd (surface);
HIMC himc = ImmGetContext (hwnd);
if (himc)
{
@@ -418,7 +418,7 @@ gtk_im_context_ime_reset (GtkIMContext *context)
if (!context_ime->client_surface)
return;
hwnd = gdk_win32_surface_get_handle (context_ime->client_surface);
hwnd = gdk_win32_surface_get_impl_hwnd (context_ime->client_surface);
himc = ImmGetContext (hwnd);
if (!himc)
return;
@@ -453,7 +453,7 @@ get_utf8_preedit_string (GtkIMContextIME *context_ime,
if (!context_ime->client_surface)
return g_strdup ("");
hwnd = gdk_win32_surface_get_handle (context_ime->client_surface);
hwnd = gdk_win32_surface_get_impl_hwnd (context_ime->client_surface);
himc = ImmGetContext (hwnd);
if (!himc)
return g_strdup ("");
@@ -512,7 +512,7 @@ get_pango_attr_list (GtkIMContextIME *context_ime, const char *utf8str)
if (!context_ime->client_surface)
return attrs;
hwnd = gdk_win32_surface_get_handle (context_ime->client_surface);
hwnd = gdk_win32_surface_get_impl_hwnd (context_ime->client_surface);
himc = ImmGetContext (hwnd);
if (!himc)
return attrs;
@@ -655,7 +655,7 @@ gtk_im_context_ime_focus_in (GtkIMContext *context)
return;
}
hwnd = gdk_win32_surface_get_handle (toplevel);
hwnd = gdk_win32_surface_get_impl_hwnd (toplevel);
himc = ImmGetContext (hwnd);
if (!himc)
return;
@@ -741,9 +741,6 @@ gtk_im_context_ime_focus_out (GtkIMContext *context)
case GTK_WIN32_IME_FOCUS_BEHAVIOR_FOLLOW:
break;
default:
g_assert_not_reached ();
}
/* remove event filter */
@@ -783,7 +780,7 @@ gtk_im_context_ime_set_cursor_location (GtkIMContext *context,
if (!context_ime->client_surface)
return;
hwnd = gdk_win32_surface_get_handle (context_ime->client_surface);
hwnd = gdk_win32_surface_get_impl_hwnd (context_ime->client_surface);
himc = ImmGetContext (hwnd);
if (!himc)
return;
@@ -814,7 +811,7 @@ gtk_im_context_ime_set_use_preedit (GtkIMContext *context,
HWND hwnd;
HIMC himc;
hwnd = gdk_win32_surface_get_handle (context_ime->client_surface);
hwnd = gdk_win32_surface_get_impl_hwnd (context_ime->client_surface);
himc = ImmGetContext (hwnd);
if (!himc)
return;
@@ -847,7 +844,7 @@ gtk_im_context_ime_set_preedit_font (GtkIMContext *context)
if (!(context_ime->client_widget && context_ime->client_surface))
return;
hwnd = gdk_win32_surface_get_handle (context_ime->client_surface);
hwnd = gdk_win32_surface_get_impl_hwnd (context_ime->client_surface);
himc = ImmGetContext (hwnd);
if (!himc)
return;
@@ -958,10 +955,10 @@ gtk_im_context_ime_message_filter (GdkWin32Display *display,
return retval;
toplevel = context_ime->client_surface;
if (gdk_win32_surface_get_handle (toplevel) != msg->hwnd)
if (gdk_win32_surface_get_impl_hwnd (toplevel) != msg->hwnd)
return retval;
hwnd = gdk_win32_surface_get_handle (context_ime->client_surface);
hwnd = gdk_win32_surface_get_impl_hwnd (context_ime->client_surface);
himc = ImmGetContext (hwnd);
if (!himc)
return retval;
+25 -35
View File
@@ -98,11 +98,6 @@ struct _GtkIMContextWayland
static void gtk_im_context_wayland_focus_out (GtkIMContext *context);
static void commit_state (GtkIMContextWayland *context);
static void notify_surrounding_text (GtkIMContextWayland *context);
static void notify_cursor_location (GtkIMContextWayland *context);
static void notify_content_type (GtkIMContextWayland *context);
G_DEFINE_TYPE_WITH_CODE (GtkIMContextWayland, gtk_im_context_wayland, GTK_TYPE_IM_CONTEXT_SIMPLE,
gtk_im_module_ensure_extension_point ();
g_io_extension_point_implement (GTK_IM_MODULE_EXTENSION_POINT_NAME,
@@ -133,8 +128,7 @@ gtk_im_context_wayland_get_global (GtkIMContextWayland *self)
}
static void
notify_im_change (GtkIMContextWayland *context,
enum zwp_text_input_v3_change_cause cause)
notify_external_change (GtkIMContextWayland *context)
{
GtkIMContextWaylandGlobal *global;
gboolean result;
@@ -143,13 +137,9 @@ notify_im_change (GtkIMContextWayland *context,
if (global == NULL)
return;
context->surrounding_change = cause;
context->surrounding_change = ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_OTHER;
g_signal_emit_by_name (global->current, "retrieve-surrounding", &result);
notify_surrounding_text (context);
notify_content_type (context);
notify_cursor_location (context);
commit_state (context);
}
static void
@@ -275,25 +265,17 @@ text_input_done (void *data,
uint32_t serial)
{
GtkIMContextWaylandGlobal *global = data;
GtkIMContextWayland *context;
gboolean update_im;
gboolean result;
global->done_serial = serial;
if (!global->current)
return;
context = GTK_IM_CONTEXT_WAYLAND (global->current);
update_im = (context->pending_commit != NULL ||
g_strcmp0 (context->pending_preedit.text,
context->current_preedit.text) != 0);
text_input_delete_surrounding_text_apply (global);
text_input_commit_apply (global);
g_signal_emit_by_name (global->current, "retrieve-surrounding", &result);
text_input_preedit_apply (global);
if (update_im && global->serial == serial)
notify_im_change (context, ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_INPUT_METHOD);
}
static void
@@ -310,6 +292,8 @@ notify_surrounding_text (GtkIMContextWayland *context)
global = gtk_im_context_wayland_get_global (context);
if (global == NULL)
return;
if (global->done_serial != global->serial)
return;
len = strlen (context->surrounding.text);
cursor = context->surrounding.cursor_idx;
@@ -384,6 +368,8 @@ notify_cursor_location (GtkIMContextWayland *context)
global = gtk_im_context_wayland_get_global (context);
if (global == NULL)
return;
if (global->done_serial != global->serial)
return;
rect = context->cursor_rect;
gtk_widget_translate_coordinates (context->widget,
@@ -474,6 +460,8 @@ notify_content_type (GtkIMContextWayland *context)
global = gtk_im_context_wayland_get_global (context);
if (global == NULL)
return;
if (global->done_serial != global->serial)
return;
g_object_get (context,
"input-hints", &hints,
@@ -539,6 +527,7 @@ released_cb (GtkGestureClick *gesture,
{
GtkIMContextWaylandGlobal *global;
GtkInputHints hints;
gboolean result;
global = gtk_im_context_wayland_get_global (context);
if (global == NULL)
@@ -555,8 +544,8 @@ released_cb (GtkGestureClick *gesture,
x, y))
{
zwp_text_input_v3_enable (global->text_input);
notify_im_change (GTK_IM_CONTEXT_WAYLAND (context),
ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_OTHER);
g_signal_emit_by_name (global->current, "retrieve-surrounding", &result);
commit_state (context);
}
}
@@ -588,7 +577,7 @@ gtk_im_context_wayland_set_client_widget (GtkIMContext *context,
GtkGesture *gesture;
gesture = gtk_gesture_click_new ();
gtk_event_controller_set_static_name (GTK_EVENT_CONTROLLER (gesture), "wayland-im-context-click");
gtk_event_controller_set_name (GTK_EVENT_CONTROLLER (gesture), "wayland-im-context-click");
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
GTK_PHASE_CAPTURE);
g_signal_connect (gesture, "pressed",
@@ -688,9 +677,12 @@ static void
enable (GtkIMContextWayland *context_wayland,
GtkIMContextWaylandGlobal *global)
{
gboolean result;
zwp_text_input_v3_enable (global->text_input);
notify_im_change (context_wayland,
ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_OTHER);
g_signal_emit_by_name (global->current, "retrieve-surrounding", &result);
notify_content_type (context_wayland);
notify_cursor_location (context_wayland);
commit_state (context_wayland);
}
static void
@@ -700,12 +692,6 @@ disable (GtkIMContextWayland *context_wayland,
zwp_text_input_v3_disable (global->text_input);
commit_state (context_wayland);
/* The commit above will still count in the .done event accounting,
* we should account for it, lest the serial gets out of sync after
* a future focus_in/enable.
*/
global->done_serial++;
/* after disable, incoming state changes won't take effect anyway */
if (context_wayland->current_preedit.text)
{
@@ -868,8 +854,7 @@ gtk_im_context_wayland_focus_out (GtkIMContext *context)
static void
gtk_im_context_wayland_reset (GtkIMContext *context)
{
notify_im_change (GTK_IM_CONTEXT_WAYLAND (context),
ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_OTHER);
notify_external_change (GTK_IM_CONTEXT_WAYLAND (context));
GTK_IM_CONTEXT_CLASS (gtk_im_context_wayland_parent_class)->reset (context);
}
@@ -904,6 +889,8 @@ gtk_im_context_wayland_set_cursor_location (GtkIMContext *context,
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (context_wayland->gesture));
context_wayland->cursor_rect = *rect;
notify_cursor_location (context_wayland);
commit_state (context_wayland);
}
static void
@@ -937,6 +924,9 @@ gtk_im_context_wayland_set_surrounding (GtkIMContext *context,
context_wayland->surrounding.text = g_strndup (text, len);
context_wayland->surrounding.cursor_idx = cursor_index;
context_wayland->surrounding.anchor_idx = selection_bound;
notify_surrounding_text (context_wayland);
commit_state (context_wayland);
}
static gboolean
+9 -15
View File
@@ -33,16 +33,16 @@
*
* `GtkInscription` is a widget to show text in a predefined area.
*
* You likely want to use `GtkLabel` instead as this widget is intended only
* for a small subset of use cases. The main scenario envisaged is inside lists
* You likely want to use `GtkLabel` instead as this widget is intended only for
* a small subset of use cases. The main use case is usage inside lists
* such as `GtkColumnView`.
*
* While a `GtkLabel` sizes itself depending on the text that is displayed,
* `GtkInscription` is given a size and inscribes the given text into that
* space as well as it can.
* While a `GtkLabel` sizes itself according to the text that is displayed,
* `GtkInscription` is given a size and inscribes the given text into that space
* as good as it can.
*
* Users of this widget should take care to plan behaviour for the common case
* where the text doesn't fit exactly in the allocated space, .
* As it is a common occurrence that text doesn't fit, users of this widget should
* plan for that case.
*
* Since: 4.8
*/
@@ -282,7 +282,7 @@ gtk_inscription_css_changed (GtkWidget *widget,
{
gtk_inscription_update_layout_attributes (self,
gtk_css_style_get_pango_attributes (gtk_css_style_change_get_new_style (change)));
gtk_widget_queue_draw (widget);
}
}
@@ -344,9 +344,9 @@ get_line_pixels (GtkInscription *self,
int ascent, descent;
metrics = gtk_inscription_get_font_metrics (self);
ascent = pango_font_metrics_get_ascent (metrics);
descent = pango_font_metrics_get_descent (metrics);
pango_font_metrics_unref (metrics);
if (baseline)
*baseline = ascent;
@@ -490,7 +490,6 @@ gtk_inscription_allocate (GtkWidget *widget,
}
}
}
pango_layout_iter_free (iter);
}
break;
@@ -795,11 +794,6 @@ gtk_inscription_set_text (GtkInscription *self,
g_free (self->text);
self->text = g_strdup (text);
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
GTK_ACCESSIBLE_PROPERTY_LABEL, self->text,
-1);
pango_layout_set_text (self->layout,
self->text ? self->text : "",
-1);
-75
View File
@@ -256,7 +256,6 @@ struct _GtkLabel
PangoAttrList *attrs;
PangoAttrList *markup_attrs;
PangoLayout *layout;
PangoTabArray *tabs;
GtkWidget *popup_menu;
GMenuModel *extra_menu;
@@ -395,7 +394,6 @@ enum {
PROP_XALIGN,
PROP_YALIGN,
PROP_EXTRA_MENU,
PROP_TABS,
NUM_PROPERTIES
};
@@ -522,9 +520,6 @@ gtk_label_set_property (GObject *object,
case PROP_EXTRA_MENU:
gtk_label_set_extra_menu (self, g_value_get_object (value));
break;
case PROP_TABS:
gtk_label_set_tabs (self, g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -598,9 +593,6 @@ gtk_label_get_property (GObject *object,
case PROP_EXTRA_MENU:
g_value_set_object (value, gtk_label_get_extra_menu (self));
break;
case PROP_TABS:
g_value_set_boxed (value, self->tabs);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -631,7 +623,6 @@ gtk_label_init (GtkLabel *self)
self->layout = NULL;
self->text = g_strdup ("");
self->attrs = NULL;
self->tabs = NULL;
self->mnemonic_widget = NULL;
@@ -1558,8 +1549,6 @@ gtk_label_finalize (GObject *object)
g_clear_pointer (&self->popup_menu, gtk_widget_unparent);
g_clear_object (&self->extra_menu);
g_clear_pointer (&self->tabs, pango_tab_array_free);
G_OBJECT_CLASS (gtk_label_parent_class)->finalize (object);
}
@@ -2559,18 +2548,6 @@ gtk_label_class_init (GtkLabelClass *class)
G_TYPE_MENU_MODEL,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkLabel:tabs: (attributes org.gtk.Property.get=gtk_label_get_tabs org.gtk.Property.set=gtk_label_set_tabs)
*
* Custom tabs for this label.
*
* Since: 4.8
*/
label_props[PROP_TABS] =
g_param_spec_boxed ("tabs", NULL, NULL,
PANGO_TYPE_TAB_ARRAY,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, label_props);
/**
@@ -4178,8 +4155,6 @@ gtk_label_ensure_layout (GtkLabel *self)
if (self->ellipsize || self->wrap)
pango_layout_set_width (self->layout, gtk_widget_get_width (GTK_WIDGET (self)) * PANGO_SCALE);
pango_layout_set_tabs (self->layout, self->tabs);
}
/**
@@ -5947,53 +5922,3 @@ gtk_label_get_extra_menu (GtkLabel *self)
return self->extra_menu;
}
/**
* gtk_label_set_tabs: (attributes org.gtk.Method.set_property=tabs)
* @self: a `GtkLabel`
* @tabs: (nullable): tabs as a `PangoTabArray`
*
* Sets the default tab stops for paragraphs in @self.
*
* Since: 4.8
*/
void
gtk_label_set_tabs (GtkLabel *self,
PangoTabArray *tabs)
{
g_return_if_fail (GTK_IS_LABEL (self));
if (self->tabs == tabs)
return;
if (self->tabs)
pango_tab_array_free (self->tabs);
self->tabs = pango_tab_array_copy (tabs);
gtk_label_clear_layout (self);
g_object_notify_by_pspec (G_OBJECT (self), label_props[PROP_TABS]);
gtk_widget_queue_resize (GTK_WIDGET (self));
}
/**
* gtk_label_get_tabs: (attributes org.gtk.Method.get_property=tabs)
* @self: a `GtkLabel`
*
* Gets the tabs for @self.
*
* The returned array will be %NULL if standard (8-space) tabs are used.
* Free the return value with [method@Pango.TabArray.free].
*
* Returns: (nullable) (transfer full): copy of default tab array,
* or %NULL if standard tabs are used; must be freed with
* [method@Pango.TabArray.free].
*
* Since: 4.8
*/
PangoTabArray *
gtk_label_get_tabs (GtkLabel *self)
{
g_return_val_if_fail (GTK_IS_LABEL (self), NULL);
return self->tabs ? pango_tab_array_copy (self->tabs) : NULL;
}
-8
View File
@@ -177,14 +177,6 @@ void gtk_label_set_extra_menu (GtkLabel *self,
GDK_AVAILABLE_IN_ALL
GMenuModel * gtk_label_get_extra_menu (GtkLabel *self);
GDK_AVAILABLE_IN_4_8
void gtk_label_set_tabs (GtkLabel *self,
PangoTabArray *tabs);
GDK_AVAILABLE_IN_4_8
PangoTabArray * gtk_label_get_tabs (GtkLabel *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkLabel, g_object_unref)
+15 -18
View File
@@ -1583,28 +1583,25 @@ gtk_list_base_stop_rubberband (GtkListBase *self,
return;
rubberband_selection = gtk_list_base_get_items_in_rect (self, &rect);
if (gtk_bitset_is_empty (rubberband_selection))
{
gtk_bitset_unref (rubberband_selection);
return;
}
if (modify && extend) /* Ctrl + Shift */
{
if (gtk_bitset_is_empty (rubberband_selection))
{
selected = gtk_bitset_ref (rubberband_selection);
mask = gtk_bitset_ref (rubberband_selection);
}
else
{
GtkBitset *current;
guint min = gtk_bitset_get_minimum (rubberband_selection);
guint max = gtk_bitset_get_maximum (rubberband_selection);
/* toggle the rubberband, keep the rest */
current = gtk_selection_model_get_selection_in_range (model, min, max - min + 1);
selected = gtk_bitset_copy (current);
gtk_bitset_unref (current);
gtk_bitset_intersect (selected, rubberband_selection);
gtk_bitset_difference (selected, rubberband_selection);
GtkBitset *current;
guint min = gtk_bitset_get_minimum (rubberband_selection);
guint max = gtk_bitset_get_maximum (rubberband_selection);
/* toggle the rubberband, keep the rest */
current = gtk_selection_model_get_selection_in_range (model, min, max - min + 1);
selected = gtk_bitset_copy (current);
gtk_bitset_unref (current);
gtk_bitset_intersect (selected, rubberband_selection);
gtk_bitset_difference (selected, rubberband_selection);
mask = gtk_bitset_ref (rubberband_selection);
}
mask = gtk_bitset_ref (rubberband_selection);
}
else if (modify) /* Ctrl */
{
+1 -3
View File
@@ -209,16 +209,14 @@ static void
gtk_list_item_widget_teardown_factory (GtkListItemWidget *self)
{
GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self);
GtkListItem *list_item = priv->list_item;
gtk_list_item_factory_teardown (priv->factory,
G_OBJECT (list_item),
G_OBJECT (priv->list_item),
priv->item != NULL,
gtk_list_item_widget_teardown_func,
self);
g_assert (priv->list_item == NULL);
g_object_unref (list_item);
}
static void
+1 -6
View File
@@ -377,9 +377,6 @@ gtk_list_view_get_items_in_rect (GtkListBase *base,
result = gtk_bitset_new_empty ();
if (rect->y >= gtk_list_view_get_list_height (self))
return result;
n_items = gtk_list_base_get_n_items (base);
if (n_items == 0)
return result;
@@ -393,7 +390,7 @@ gtk_list_view_get_items_in_rect (GtkListBase *base,
if (row)
last = gtk_list_item_manager_get_item_position (self->item_manager, row);
else
last = rect->y + rect->height < 0 ? 0 : n_items - 1;
last = rect->y < 0 ? 0 : n_items - 1;
gtk_bitset_add_range_closed (result, first, last);
return result;
@@ -428,8 +425,6 @@ gtk_list_view_get_position_from_allocation (GtkListBase *base,
if (across >= self->list_width)
return FALSE;
along = CLAMP (along, 0, gtk_list_view_get_list_height (self) - 1);
row = gtk_list_view_get_row_at_y (self, along, &remaining);
if (row == NULL)
return FALSE;

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