Compare commits
306 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 526b25747c | |||
| 9bbe101d5c | |||
| a2599c2bb9 | |||
| e2675306e1 | |||
| 7d1429cb91 | |||
| f13a018739 | |||
| 84b3b1fab5 | |||
| 048bb6db6f | |||
| 8c548d5579 | |||
| 09d5ec1b08 | |||
| 28bba484da | |||
| 191558cfa4 | |||
| cb0c1b3f08 | |||
| 91f200167e | |||
| 2b6fb005a8 | |||
| af6bec7539 | |||
| 38362c2803 | |||
| eb7c78aa48 | |||
| 7ab39b5461 | |||
| 0c44851848 | |||
| d72ed045df | |||
| 38eb182947 | |||
| 0eba21b2b5 | |||
| 21cba193ad | |||
| ee7c83e15a | |||
| 48dbbbc099 | |||
| 1c733857b3 | |||
| 85a6517d65 | |||
| d75147db0a | |||
| d3cf7088b3 | |||
| ffa7185397 | |||
| d7fe62817c | |||
| a034bdb17e | |||
| af20f7e9b5 | |||
| 15b7a4572b | |||
| 146bb70c2e | |||
| 494de142f6 | |||
| 5d979cde82 | |||
| f48b894468 | |||
| a6e47892be | |||
| 1e0c25d96a | |||
| f57eec5288 | |||
| e938befcbc | |||
| 2af8ac655b | |||
| cc3c0125a8 | |||
| 59f9be457f | |||
| d1ce514260 | |||
| ad5e72728f | |||
| 1bf24f7b19 | |||
| a3cedb0163 | |||
| 97bab27d82 | |||
| 6030da573d | |||
| 0128574ca1 | |||
| b27a169200 | |||
| bcd0704511 | |||
| 506566b6a4 | |||
| b67da38916 | |||
| 8519ab56f5 | |||
| 89d87e3482 | |||
| 04c9c6b428 | |||
| 9bd8ed0d82 | |||
| 40386c97eb | |||
| 6649cc6e5e | |||
| e69dc04a7f | |||
| c1361f7a5a | |||
| 351ffef704 | |||
| a1ddd3fead | |||
| 79f0f4ee8e | |||
| 7b8bfb4c80 | |||
| 7106cf6524 | |||
| e706e14fd9 | |||
| 3f1021048f | |||
| ddba7f8601 | |||
| 1660a0eaf1 | |||
| ffffb382e2 | |||
| 09453bc60b | |||
| f76b749e43 | |||
| 0aca2a03b4 | |||
| fd358990a2 | |||
| 01b91c1ba3 | |||
| cc02076b75 | |||
| b726a2d902 | |||
| 654ae5928a | |||
| 1c24514798 | |||
| 33f3ab9991 | |||
| 91511a80ac | |||
| a585457861 | |||
| 4a0ddac307 | |||
| f7d9ede82d | |||
| 65839f67f8 | |||
| df40db137b | |||
| 129bc27d53 | |||
| 274e2b221f | |||
| adc4009354 | |||
| f058a42bd3 | |||
| 3a8cb276e7 | |||
| eeaa73c12a | |||
| 3873861b27 | |||
| 8e455e333b | |||
| 3d10e6c3d1 | |||
| dcc7cf7114 | |||
| f1d0886087 | |||
| 951e4ee6b2 | |||
| f9e2c106bc | |||
| 53956e5389 | |||
| 3ab63fd03b | |||
| fb4927827b | |||
| cbbca38d88 | |||
| c64836e1c9 | |||
| 6b23fe3aa7 | |||
| 9defc7fc64 | |||
| 9d56f44cdf | |||
| 1b9da2bb17 | |||
| 2efc1729e2 | |||
| a66a0dde81 | |||
| 7062411bad | |||
| 9dbd137ec8 | |||
| 79fad9f221 | |||
| 8f9ee48aaa | |||
| 8eb9844a45 | |||
| b90132c917 | |||
| 23806b7788 | |||
| d266c0d105 | |||
| 581461c2b5 | |||
| f108f053d4 | |||
| df593ee651 | |||
| 4dcd011486 | |||
| 6fe7e373e2 | |||
| 0c3583b4bd | |||
| 5bd0179a88 | |||
| f116efd48e | |||
| 8057bee295 | |||
| ab330f1efc | |||
| e5dc66b10e | |||
| aa43d97a80 | |||
| eaf4fb68f3 | |||
| bfe193e6e2 | |||
| aa8dec3d27 | |||
| d2e7060150 | |||
| 08f3acb534 | |||
| 525f96f2f8 | |||
| b6b2682bd6 | |||
| 1832964188 | |||
| eb599653e6 | |||
| e1e88ce665 | |||
| 66d21689bc | |||
| 8186cb8bee | |||
| 9b8f28903b | |||
| 1cd42825c2 | |||
| 166444f115 | |||
| 3cd68c5de5 | |||
| 9e2357d5f3 | |||
| bd0c68f641 | |||
| c3a7d79154 | |||
| 25624083dd | |||
| 407b5246a6 | |||
| 6bedcf22bc | |||
| eeb9d6c398 | |||
| cf8d2374c5 | |||
| 9fa5378d83 | |||
| 90352d760d | |||
| c3c1763a9f | |||
| 9f7c9ce6ad | |||
| 1f155bf39a | |||
| 84014e3414 | |||
| 4ced1c90f1 | |||
| 54c3b947fc | |||
| 94007caf8d | |||
| 675c8b45b1 | |||
| ea59d174a0 | |||
| 32935d9fb0 | |||
| b390e1da4f | |||
| cccd1147e7 | |||
| d8db5f3217 | |||
| f5bb364bb5 | |||
| 82f57c6a93 | |||
| 20c41dce80 | |||
| a9de385ac5 | |||
| ead210c170 | |||
| 2ad471542a | |||
| d73cff5846 | |||
| 213376ee0a | |||
| 1cc100415f | |||
| d9ad7884e9 | |||
| f545d7a910 | |||
| 206eb647a4 | |||
| 00e637b480 | |||
| bfc8b7b7b6 | |||
| c44288c739 | |||
| 2fb5104731 | |||
| 0ae4d80766 | |||
| f5098e4fc5 | |||
| 28607f082c | |||
| f3968f2f1e | |||
| 88fa226223 | |||
| c4c496a31c | |||
| c1eac4a421 | |||
| b5d1323f49 | |||
| e297ac319d | |||
| bf852bea24 | |||
| a652507b7b | |||
| 4a2a76c231 | |||
| 8cb7369b7a | |||
| 588076d166 | |||
| 3a98b28ab7 | |||
| cfeedcc321 | |||
| d0aedbc9fc | |||
| 5557a528b6 | |||
| 5316eb0c35 | |||
| e6afe28de5 | |||
| eaf0353205 | |||
| f9f9bd3f5b | |||
| ca79688f52 | |||
| efa8f903c2 | |||
| f7d0b91267 | |||
| ed4f0de2b0 | |||
| 50b96dcdd5 | |||
| cf25f2c04b | |||
| ddf07ffe22 | |||
| 82f1eaacc9 | |||
| 4cdb07fa02 | |||
| bdd5393084 | |||
| 27b87ebec5 | |||
| 8c0df66d5f | |||
| e5238bf54f | |||
| e9abcde031 | |||
| d45281e6c7 | |||
| 3fd5ebffcb | |||
| 88a621fa13 | |||
| ce4b799f1e | |||
| 4dcacff312 | |||
| fd7667246d | |||
| b8cb15f28d | |||
| 51607ce93c | |||
| 66284cd245 | |||
| f9faecd5b7 | |||
| 92261b5022 | |||
| 91f5bfd211 | |||
| 63f20b173d | |||
| 25b3bd64af | |||
| fc4d36e50a | |||
| dbede0b115 | |||
| 1e40033852 | |||
| 478bf45320 | |||
| dac0b7d609 | |||
| d14987e819 | |||
| 3a0077f65f | |||
| 03882ef8e5 | |||
| 505e10f3ea | |||
| 1e01444de8 | |||
| 4404c43cd3 | |||
| 92a7c7cdc3 | |||
| 33db142eab | |||
| 68319afd23 | |||
| 25f4e597ee | |||
| db8339ca66 | |||
| 5ba02e3459 | |||
| 999509be61 | |||
| 5dca6dce91 | |||
| d3acfa8c2b | |||
| c1cc8c979b | |||
| eed74f6ea0 | |||
| e5a4b91997 | |||
| 885b34d382 | |||
| 3faf9d85bb | |||
| 4cd4c25c25 | |||
| bffa5dfddd | |||
| 2fe20878c3 | |||
| b28c3ef3d9 | |||
| ed5fb4bbfe | |||
| 2dd86aaa00 | |||
| eaf952d902 | |||
| 88cb6a46f2 | |||
| c76b4bdc77 | |||
| 62fe4eae16 | |||
| 99a40de8ad | |||
| b8376407a4 | |||
| a5643b0c83 | |||
| 828688d5cd | |||
| fc47b913b1 | |||
| 7d8b3357a5 | |||
| e0b98bc7de | |||
| 493b145496 | |||
| 1b2c11d7f5 | |||
| a56828237a | |||
| 56e2a7e8bb | |||
| f278f3610b | |||
| c111e633e9 | |||
| eea7cf30bb | |||
| 36bdcfaccb | |||
| 45bb820656 | |||
| 617deb8bb6 | |||
| 8efcd34dbe | |||
| a78b573f8b | |||
| 226f0e0567 | |||
| 4304a494ae | |||
| b71ff21530 | |||
| 6a7da77980 | |||
| c5f92340ee | |||
| 572a884e90 | |||
| 69bc9d0702 | |||
| 34ff9e359b | |||
| de705c2a2b | |||
| d1102f586c | |||
| ab65e8e178 | |||
| 4d741bac98 |
@@ -6,7 +6,7 @@ call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliar
|
||||
|
||||
:: FIXME: make warnings fatal
|
||||
pip3 install --upgrade --user meson==0.59 || goto :error
|
||||
meson -Dmedia-gstreamer=disabled _build || goto :error
|
||||
meson -Ddebug=false -Dmedia-gstreamer=disabled _build || goto :error
|
||||
ninja -C _build || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
@@ -15,9 +15,9 @@ pacman --noconfirm -Suy
|
||||
pacman --noconfirm -S --needed \
|
||||
base-devel \
|
||||
git \
|
||||
mingw-w64-$MSYS2_ARCH-toolchain \
|
||||
mingw-w64-$MSYS2_ARCH-cc \
|
||||
mingw-w64-$MSYS2_ARCH-ccache \
|
||||
mingw-w64-$MSYS2_ARCH-pkg-config \
|
||||
mingw-w64-$MSYS2_ARCH-pkgconf \
|
||||
mingw-w64-$MSYS2_ARCH-gobject-introspection \
|
||||
mingw-w64-$MSYS2_ARCH-meson \
|
||||
mingw-w64-$MSYS2_ARCH-adwaita-icon-theme \
|
||||
@@ -30,7 +30,7 @@ pacman --noconfirm -S --needed \
|
||||
mingw-w64-$MSYS2_ARCH-libepoxy \
|
||||
mingw-w64-$MSYS2_ARCH-pango \
|
||||
mingw-w64-$MSYS2_ARCH-fribidi \
|
||||
mingw-w64-$MSYS2_ARCH-gst-plugins-bad \
|
||||
mingw-w64-$MSYS2_ARCH-gst-plugins-bad-libs \
|
||||
mingw-w64-$MSYS2_ARCH-shared-mime-info \
|
||||
mingw-w64-$MSYS2_ARCH-python-gobject
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ do_cursors (GtkWidget *do_widget)
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/cursors/cursors.ui");
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_signal_connect (window, "destroy",
|
||||
@@ -34,9 +35,7 @@ do_cursors (GtkWidget *do_widget)
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
{
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
}
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
@@ -512,7 +512,7 @@ load_file (const char *demoname,
|
||||
|
||||
info_buffer = gtk_text_buffer_new (NULL);
|
||||
gtk_text_buffer_create_tag (info_buffer, "title",
|
||||
"font", "Sans 18",
|
||||
"size", 18 * 1024,
|
||||
"pixels-below-lines", 10,
|
||||
NULL);
|
||||
|
||||
@@ -1040,7 +1040,7 @@ out:
|
||||
g_signal_connect_swapped (G_OBJECT (demo), "destroy", G_CALLBACK (g_application_quit), app);
|
||||
}
|
||||
else
|
||||
gtk_widget_show (GTK_WIDGET (window));
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
|
||||
if (autoquit)
|
||||
g_timeout_add_seconds (1, auto_quit, app);
|
||||
|
||||
@@ -160,7 +160,7 @@ endif
|
||||
|
||||
ld = find_program('ld', required : false)
|
||||
|
||||
if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
|
||||
if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
|
||||
glib_compile_resources = find_program('glib-compile-resources')
|
||||
|
||||
# Create the resource blob
|
||||
|
||||
@@ -871,7 +871,7 @@ activate (GApplication *app)
|
||||
|
||||
update_ui ();
|
||||
|
||||
gtk_widget_show (main_window);
|
||||
gtk_window_present (GTK_WINDOW (main_window));
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -8,7 +8,7 @@ endif
|
||||
|
||||
ld = find_program('ld', required : false)
|
||||
|
||||
if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
|
||||
if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
|
||||
glib_compile_resources = find_program('glib-compile-resources')
|
||||
|
||||
# Create the resource blob
|
||||
|
||||
@@ -2360,7 +2360,7 @@ activate (GApplication *app)
|
||||
model = (GMenuModel *)gtk_builder_get_object (builder, "new_style_context_menu_model");
|
||||
set_up_context_popover (widget, model);
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (window));
|
||||
gtk_window_present (window);
|
||||
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ if get_option('gtk_doc')
|
||||
)
|
||||
endif
|
||||
|
||||
rst2man = find_program('rst2man', required: false)
|
||||
rst2man = find_program('rst2man', 'rst2man.py', required: false)
|
||||
if get_option('man-pages') and not rst2man.found()
|
||||
error('No rst2man found, but man pages were explicitly enabled')
|
||||
endif
|
||||
|
||||
@@ -372,7 +372,7 @@ library you are using:
|
||||
The `test` accessibility backend is recommended for test suites and remote
|
||||
continuous integration pipelines.
|
||||
|
||||
### `XDG_DTA_HOME`, `XDG_DATA_DIRS`
|
||||
### `XDG_DATA_HOME`, `XDG_DATA_DIRS`
|
||||
|
||||
GTK uses these environment variables to locate icon themes
|
||||
and MIME information. For more information, see the
|
||||
|
||||
@@ -576,7 +576,7 @@ gdk_content_deserialize_async (GInputStream *stream,
|
||||
/**
|
||||
* gdk_content_deserialize_finish:
|
||||
* @result: the `GAsyncResult`
|
||||
* @value: return location for the result of the operation
|
||||
* @value: (out): return location for the result of the operation
|
||||
* @error: return location for an error
|
||||
*
|
||||
* Finishes a content deserialization operation.
|
||||
|
||||
@@ -1721,8 +1721,6 @@ gdk_display_init_egl (GdkDisplay *self,
|
||||
|
||||
self->have_egl_buffer_age =
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_buffer_age");
|
||||
self->have_egl_swap_buffers_with_damage =
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_swap_buffers_with_damage");
|
||||
self->have_egl_no_config_context =
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_KHR_no_config_context");
|
||||
self->have_egl_pixel_format_float =
|
||||
|
||||
@@ -107,7 +107,6 @@ struct _GdkDisplay
|
||||
|
||||
/* egl info */
|
||||
guint have_egl_buffer_age : 1;
|
||||
guint have_egl_swap_buffers_with_damage : 1;
|
||||
guint have_egl_no_config_context : 1;
|
||||
guint have_egl_pixel_format_float : 1;
|
||||
guint have_egl_win32_libangle : 1;
|
||||
|
||||
+53
-5
@@ -597,7 +597,8 @@ _gdk_event_unqueue (GdkDisplay *display)
|
||||
|
||||
/*
|
||||
* If the last N events in the event queue are smooth scroll events
|
||||
* for the same surface and device, combine them into one.
|
||||
* for the same surface, the same device and the same scroll unit,
|
||||
* combine them into one.
|
||||
*
|
||||
* We give the remaining event a history with N items, and deltas
|
||||
* that are the sum over the history entries.
|
||||
@@ -611,6 +612,8 @@ gdk_event_queue_handle_scroll_compression (GdkDisplay *display)
|
||||
GdkEvent *last_event = NULL;
|
||||
GList *scrolls = NULL;
|
||||
GArray *history = NULL;
|
||||
GdkScrollUnit scroll_unit = GDK_SCROLL_UNIT_WHEEL;
|
||||
gboolean scroll_unit_defined = FALSE;
|
||||
GdkTimeCoord hist;
|
||||
|
||||
l = g_queue_peek_tail_link (&display->queued_events);
|
||||
@@ -618,6 +621,7 @@ gdk_event_queue_handle_scroll_compression (GdkDisplay *display)
|
||||
while (l)
|
||||
{
|
||||
GdkEvent *event = l->data;
|
||||
GdkScrollEvent *scroll_event = (GdkScrollEvent *) event;
|
||||
|
||||
if (event->flags & GDK_EVENT_PENDING)
|
||||
break;
|
||||
@@ -634,11 +638,17 @@ gdk_event_queue_handle_scroll_compression (GdkDisplay *display)
|
||||
device != event->device)
|
||||
break;
|
||||
|
||||
if (scroll_unit_defined &&
|
||||
scroll_unit != scroll_event->unit)
|
||||
break;
|
||||
|
||||
if (!last_event)
|
||||
last_event = event;
|
||||
|
||||
surface = event->surface;
|
||||
device = event->device;
|
||||
scroll_unit = scroll_event->unit;
|
||||
scroll_unit_defined = TRUE;
|
||||
scrolls = l;
|
||||
|
||||
l = l->prev;
|
||||
@@ -710,7 +720,8 @@ gdk_event_queue_handle_scroll_compression (GdkDisplay *display)
|
||||
gdk_event_get_modifier_state (old_event),
|
||||
dx,
|
||||
dy,
|
||||
gdk_scroll_event_is_stop (old_event));
|
||||
gdk_scroll_event_is_stop (old_event),
|
||||
scroll_unit);
|
||||
|
||||
((GdkScrollEvent *)event)->history = history;
|
||||
|
||||
@@ -746,15 +757,21 @@ gdk_motion_event_push_history (GdkEvent *event,
|
||||
|
||||
memset (&hist, 0, sizeof (GdkTimeCoord));
|
||||
hist.time = gdk_event_get_time (history_event);
|
||||
|
||||
if (tool)
|
||||
{
|
||||
hist.flags = gdk_device_tool_get_axes (tool);
|
||||
for (i = GDK_AXIS_X; i < GDK_AXIS_LAST; i++)
|
||||
gdk_event_get_axis (history_event, i, &hist.axes[i]);
|
||||
}
|
||||
else
|
||||
|
||||
/* GdkTimeCoord has no dedicated fields to record event position. For plain
|
||||
* pointer events, and for tools which don't report GDK_AXIS_X/GDK_AXIS_Y
|
||||
* on their own, we surface the position using the X and Y input axes.
|
||||
*/
|
||||
if (!(hist.flags & GDK_AXIS_FLAG_X) || !(hist.flags & GDK_AXIS_FLAG_Y))
|
||||
{
|
||||
hist.flags = GDK_AXIS_FLAG_X | GDK_AXIS_FLAG_Y;
|
||||
hist.flags |= GDK_AXIS_FLAG_X | GDK_AXIS_FLAG_Y;
|
||||
gdk_event_get_position (history_event, &hist.axes[GDK_AXIS_X], &hist.axes[GDK_AXIS_Y]);
|
||||
}
|
||||
|
||||
@@ -2334,7 +2351,8 @@ gdk_scroll_event_new (GdkSurface *surface,
|
||||
GdkModifierType state,
|
||||
double delta_x,
|
||||
double delta_y,
|
||||
gboolean is_stop)
|
||||
gboolean is_stop,
|
||||
GdkScrollUnit unit)
|
||||
{
|
||||
GdkScrollEvent *self = gdk_event_alloc (GDK_SCROLL, surface, device, time);
|
||||
|
||||
@@ -2344,6 +2362,7 @@ gdk_scroll_event_new (GdkSurface *surface,
|
||||
self->delta_x = delta_x;
|
||||
self->delta_y = delta_y;
|
||||
self->is_stop = is_stop;
|
||||
self->unit = unit;
|
||||
|
||||
return (GdkEvent *) self;
|
||||
}
|
||||
@@ -2363,6 +2382,7 @@ gdk_scroll_event_new_discrete (GdkSurface *surface,
|
||||
self->state = state;
|
||||
self->direction = direction;
|
||||
self->pointer_emulated = emulated;
|
||||
self->unit = GDK_SCROLL_UNIT_WHEEL;
|
||||
|
||||
return (GdkEvent *) self;
|
||||
}
|
||||
@@ -2396,6 +2416,9 @@ gdk_scroll_event_get_direction (GdkEvent *event)
|
||||
*
|
||||
* The deltas will be zero unless the scroll direction
|
||||
* is %GDK_SCROLL_SMOOTH.
|
||||
*
|
||||
* For the representation unit of these deltas, see
|
||||
* [method@Gdk.ScrollEvent.get_unit].
|
||||
*/
|
||||
void
|
||||
gdk_scroll_event_get_deltas (GdkEvent *event,
|
||||
@@ -2438,6 +2461,31 @@ gdk_scroll_event_is_stop (GdkEvent *event)
|
||||
return self->is_stop;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_scroll_event_get_unit:
|
||||
* @event: (type GdkScrollEvent): a scroll event.
|
||||
*
|
||||
* Extracts the scroll delta unit of a scroll event.
|
||||
*
|
||||
* The unit will always be %GDK_SCROLL_UNIT_WHEEL if the scroll direction is not
|
||||
* %GDK_SCROLL_SMOOTH.
|
||||
*
|
||||
* Returns: the scroll unit.
|
||||
*
|
||||
* Since: 4.8
|
||||
*/
|
||||
GdkScrollUnit
|
||||
gdk_scroll_event_get_unit (GdkEvent *event)
|
||||
{
|
||||
GdkScrollEvent *self = (GdkScrollEvent *) event;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_EVENT (event), GDK_SCROLL_UNIT_WHEEL);
|
||||
g_return_val_if_fail (GDK_IS_EVENT_TYPE (event, GDK_SCROLL),
|
||||
GDK_SCROLL_UNIT_WHEEL);
|
||||
|
||||
return self->unit;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ GdkTouchpadEvent */
|
||||
|
||||
@@ -265,6 +265,37 @@ typedef enum
|
||||
GDK_SCROLL_SMOOTH
|
||||
} GdkScrollDirection;
|
||||
|
||||
/**
|
||||
* GdkScrollUnit:
|
||||
* @GDK_SCROLL_UNIT_WHEEL: The delta is in number of wheel clicks.
|
||||
* @GDK_SCROLL_UNIT_SURFACE: The delta is in surface pixels to scroll directly
|
||||
* on screen.
|
||||
*
|
||||
* Specifies the unit of scroll deltas.
|
||||
*
|
||||
* When you get %GDK_SCROLL_UNIT_WHEEL, a delta of 1.0 means 1 wheel detent
|
||||
* click in the south direction, 2.0 means 2 wheel detent clicks in the south
|
||||
* direction... This is the same logic for negative values but in the north
|
||||
* direction.
|
||||
*
|
||||
* If you get %GDK_SCROLL_UNIT_SURFACE, are managing a scrollable view and get a
|
||||
* value of 123, you have to scroll 123 surface logical pixels right if it's
|
||||
* @delta_x or down if it's @delta_y. This is the same logic for negative values
|
||||
* but you have to scroll left instead of right if it's @delta_x and up instead
|
||||
* of down if it's @delta_y.
|
||||
*
|
||||
* 1 surface logical pixel is equal to 1 real screen pixel multiplied by the
|
||||
* final scale factor of your graphical interface (the product of the desktop
|
||||
* scale factor and eventually a custom scale factor in your app).
|
||||
*
|
||||
* Since: 4.8
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GDK_SCROLL_UNIT_WHEEL,
|
||||
GDK_SCROLL_UNIT_SURFACE
|
||||
} GdkScrollUnit;
|
||||
|
||||
/**
|
||||
* GdkNotifyType:
|
||||
* @GDK_NOTIFY_ANCESTOR: the surface is entered from an ancestor or
|
||||
@@ -395,6 +426,8 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gdk_scroll_event_get_deltas (GdkEvent *event,
|
||||
double *delta_x,
|
||||
double *delta_y);
|
||||
GDK_AVAILABLE_IN_4_8
|
||||
GdkScrollUnit gdk_scroll_event_get_unit (GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_scroll_event_is_stop (GdkEvent *event);
|
||||
|
||||
@@ -212,6 +212,7 @@ struct _GdkTouchEvent
|
||||
* @history: (element-type GdkTimeCoord): array of times and deltas
|
||||
* for other scroll events that were compressed before delivering the
|
||||
* current event
|
||||
* @unit: The scroll unit in which delta_x and delta_y are represented.
|
||||
*
|
||||
* Generated from button presses for the buttons 4 to 7. Wheel mice are
|
||||
* usually configured to generate button press events for buttons 4 and 5
|
||||
@@ -234,6 +235,7 @@ struct _GdkScrollEvent
|
||||
gboolean is_stop;
|
||||
GdkDeviceTool *tool;
|
||||
GArray *history; /* <GdkTimeCoord> */
|
||||
GdkScrollUnit unit;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -486,7 +488,8 @@ GdkEvent * gdk_scroll_event_new (GdkSurface *surface,
|
||||
GdkModifierType state,
|
||||
double delta_x,
|
||||
double delta_y,
|
||||
gboolean is_stop);
|
||||
gboolean is_stop,
|
||||
GdkScrollUnit unit);
|
||||
|
||||
GdkEvent * gdk_scroll_event_new_discrete (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
|
||||
+8
-2
@@ -117,6 +117,7 @@ typedef struct {
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
EGLContext egl_context;
|
||||
EGLBoolean (*eglSwapBuffersWithDamage) (EGLDisplay, EGLSurface, const EGLint *, EGLint);
|
||||
#endif
|
||||
} GdkGLContextPrivate;
|
||||
|
||||
@@ -420,6 +421,11 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
||||
|
||||
gdk_gl_context_set_is_legacy (context, legacy_bit);
|
||||
|
||||
if (epoxy_has_egl_extension (egl_display, "EGL_KHR_swap_buffers_with_damage"))
|
||||
priv->eglSwapBuffersWithDamage = (gpointer)epoxy_eglGetProcAddress ("eglSwapBuffersWithDamageKHR");
|
||||
else if (epoxy_has_egl_extension (egl_display, "EGL_EXT_swap_buffers_with_damage"))
|
||||
priv->eglSwapBuffersWithDamage = (gpointer)epoxy_eglGetProcAddress ("eglSwapBuffersWithDamageEXT");
|
||||
|
||||
gdk_profiler_end_mark (start_time, "realize GdkWaylandGLContext", NULL);
|
||||
|
||||
return api;
|
||||
@@ -608,7 +614,7 @@ gdk_gl_context_real_end_frame (GdkDrawContext *draw_context,
|
||||
|
||||
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "EGL", "swap buffers");
|
||||
|
||||
if (display->have_egl_swap_buffers_with_damage)
|
||||
if (priv->eglSwapBuffersWithDamage)
|
||||
{
|
||||
EGLint stack_rects[4 * 4]; /* 4 rects */
|
||||
EGLint *heap_rects = NULL;
|
||||
@@ -632,7 +638,7 @@ gdk_gl_context_real_end_frame (GdkDrawContext *draw_context,
|
||||
rects[j++] = rect.width * scale;
|
||||
rects[j++] = rect.height * scale;
|
||||
}
|
||||
eglSwapBuffersWithDamageEXT (gdk_display_get_egl_display (display), egl_surface, rects, n_rects);
|
||||
priv->eglSwapBuffersWithDamage (gdk_display_get_egl_display (display), egl_surface, rects, n_rects);
|
||||
g_free (heap_rects);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -365,6 +365,42 @@ gdk_gl_texture_determine_format (GdkGLTexture *self)
|
||||
texture->format = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED;
|
||||
break;
|
||||
|
||||
case GL_RGBA:
|
||||
{
|
||||
GLint red_size = 0;
|
||||
GLint green_size = 0;
|
||||
GLint blue_size = 0;
|
||||
GLint alpha_size = 0;
|
||||
GLint red_type = 0;
|
||||
GLint green_type = 0;
|
||||
GLint blue_type = 0;
|
||||
GLint alpha_type = 0;
|
||||
|
||||
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_RED_TYPE, &red_type);
|
||||
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_TYPE, &green_type);
|
||||
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_TYPE, &blue_type);
|
||||
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_TYPE, &alpha_type);
|
||||
|
||||
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &red_size);
|
||||
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &green_size);
|
||||
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &blue_size);
|
||||
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &alpha_size);
|
||||
|
||||
#define CHECK_RGBA(rt,gt,bt,at,rs,gs,bs,as) \
|
||||
(red_type == rt && green_type == gt && blue_type == bt && alpha_type == at && \
|
||||
red_size == rs && green_size == gs && blue_size == bs && alpha_size == as)
|
||||
|
||||
if (CHECK_RGBA (GL_UNSIGNED_NORMALIZED, GL_UNSIGNED_NORMALIZED, GL_UNSIGNED_NORMALIZED, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 8))
|
||||
{
|
||||
texture->format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
||||
break;
|
||||
}
|
||||
|
||||
#undef CHECK_RGBA
|
||||
}
|
||||
|
||||
G_GNUC_FALLTHROUGH;
|
||||
|
||||
default:
|
||||
g_warning ("Texture in unexpected format 0x%X (%d). File a bug about adding it to GTK", internal_format, internal_format);
|
||||
/* fallback to the dumbest possible format
|
||||
|
||||
+2
-6
@@ -19,7 +19,7 @@
|
||||
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#ifndef __GDKINTL_H__
|
||||
@@ -27,10 +27,6 @@
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
#define P_(String) dgettext(GETTEXT_PACKAGE "-properties",String)
|
||||
#else
|
||||
#define P_(String) (String)
|
||||
#endif
|
||||
#define P_(String) dgettext (GETTEXT_PACKAGE "-properties", String)
|
||||
|
||||
#endif
|
||||
|
||||
+86
-73
@@ -25,10 +25,6 @@
|
||||
|
||||
#include <epoxy/gl.h>
|
||||
|
||||
#ifdef __ARM_NEON
|
||||
#include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
typedef struct _GdkMemoryFormatDescription GdkMemoryFormatDescription;
|
||||
|
||||
#define TYPED_FUNCS(name, T, R, G, B, A, bpp, scale) \
|
||||
@@ -170,75 +166,54 @@ r32g32b32a32_float_from_float (guchar *dest,
|
||||
memcpy (dest, src, sizeof (float) * n * 4);
|
||||
}
|
||||
|
||||
// This one conversion is quite important, it converts from RGBA with straight
|
||||
// alpha (as found in PNG for instance) to BGRA with premultiplied alpha (the
|
||||
// sole cairo format available).
|
||||
static void
|
||||
r8g8b8a8_to_b8g8r8a8_premultiplied (guchar *dest,
|
||||
const guchar *src,
|
||||
gsize n)
|
||||
{
|
||||
#ifdef __ARM_NEON
|
||||
uint16x8_t one = vdupq_n_u16 (1);
|
||||
uint16x8_t half = vdupq_n_u16 (127);
|
||||
|
||||
for (gsize i = n / 8; i > 0; i--)
|
||||
{
|
||||
// Work on “just” 8 pixels at once, since we need the full 16-bytes of
|
||||
// the q registers for the multiplication.
|
||||
uint8x8x4_t rgba = vld4_u8 (src);
|
||||
uint8x8_t r8 = rgba.val[0];
|
||||
uint8x8_t g8 = rgba.val[1];
|
||||
uint8x8_t b8 = rgba.val[2];
|
||||
uint8x8_t a8 = rgba.val[3];
|
||||
|
||||
// This is the same algorithm as premultiply(), but on packed 16-bit
|
||||
// instead of float.
|
||||
uint16x8_t r16 = vmull_u8 (r8, a8);
|
||||
uint16x8_t g16 = vmull_u8 (g8, a8);
|
||||
uint16x8_t b16 = vmull_u8 (b8, a8);
|
||||
|
||||
r16 = vaddq_u16 (r16, half);
|
||||
g16 = vaddq_u16 (g16, half);
|
||||
b16 = vaddq_u16 (b16, half);
|
||||
|
||||
r16 = vsraq_n_u16 (r16, r16, 8);
|
||||
g16 = vsraq_n_u16 (g16, g16, 8);
|
||||
b16 = vsraq_n_u16 (b16, b16, 8);
|
||||
|
||||
r16 = vaddq_u16 (r16, one);
|
||||
g16 = vaddq_u16 (g16, one);
|
||||
b16 = vaddq_u16 (b16, one);
|
||||
|
||||
// Just like the other one, here we use BGRA instead of RGBA!
|
||||
rgba.val[0] = vshrn_n_u16 (b16, 8);
|
||||
rgba.val[1] = vshrn_n_u16 (g16, 8);
|
||||
rgba.val[2] = vshrn_n_u16 (r16, 8);
|
||||
|
||||
vst4_u8 (dest, rgba);
|
||||
src += 32;
|
||||
dest += 32;
|
||||
}
|
||||
|
||||
// We want the fallthrough here for the last (up to) seven bytes of the row.
|
||||
n = n % 8;
|
||||
#endif // __ARM_NEON
|
||||
|
||||
for (; n > 0; n--)
|
||||
{
|
||||
guchar a = src[3];
|
||||
guint16 r = (guint16)src[0] * a + 127;
|
||||
guint16 g = (guint16)src[1] * a + 127;
|
||||
guint16 b = (guint16)src[2] * a + 127;
|
||||
dest[0] = (b + (b >> 8) + 1) >> 8;
|
||||
dest[1] = (g + (g >> 8) + 1) >> 8;
|
||||
dest[2] = (r + (r >> 8) + 1) >> 8;
|
||||
dest[3] = a;
|
||||
dest += 4;
|
||||
src += 4;
|
||||
}
|
||||
#define PREMULTIPLY_FUNC(name, R1, G1, B1, A1, R2, G2, B2, A2) \
|
||||
static void \
|
||||
name (guchar *dest, \
|
||||
const guchar *src, \
|
||||
gsize n) \
|
||||
{ \
|
||||
for (; n > 0; n--) \
|
||||
{ \
|
||||
guchar a = src[A1]; \
|
||||
guint16 r = (guint16)src[R1] * a + 127; \
|
||||
guint16 g = (guint16)src[G1] * a + 127; \
|
||||
guint16 b = (guint16)src[B1] * a + 127; \
|
||||
dest[R2] = (r + (r >> 8) + 1) >> 8; \
|
||||
dest[G2] = (g + (g >> 8) + 1) >> 8; \
|
||||
dest[B2] = (b + (b >> 8) + 1) >> 8; \
|
||||
dest[A2] = a; \
|
||||
dest += 4; \
|
||||
src += 4; \
|
||||
} \
|
||||
}
|
||||
|
||||
PREMULTIPLY_FUNC(r8g8b8a8_to_r8g8b8a8_premultiplied, 0, 1, 2, 3, 0, 1, 2, 3)
|
||||
PREMULTIPLY_FUNC(r8g8b8a8_to_b8g8r8a8_premultiplied, 0, 1, 2, 3, 2, 1, 0, 3)
|
||||
PREMULTIPLY_FUNC(r8g8b8a8_to_a8r8g8b8_premultiplied, 0, 1, 2, 3, 1, 2, 3, 0)
|
||||
PREMULTIPLY_FUNC(r8g8b8a8_to_a8b8g8r8_premultiplied, 0, 1, 2, 3, 3, 2, 1, 0)
|
||||
|
||||
#define ADD_ALPHA_FUNC(name, R1, G1, B1, R2, G2, B2, A2) \
|
||||
static void \
|
||||
name (guchar *dest, \
|
||||
const guchar *src, \
|
||||
gsize n) \
|
||||
{ \
|
||||
for (; n > 0; n--) \
|
||||
{ \
|
||||
dest[R2] = src[R1]; \
|
||||
dest[G2] = src[G1]; \
|
||||
dest[B2] = src[B1]; \
|
||||
dest[A2] = 255; \
|
||||
dest += 4; \
|
||||
src += 3; \
|
||||
} \
|
||||
}
|
||||
|
||||
ADD_ALPHA_FUNC(r8g8b8_to_r8g8b8a8, 0, 1, 2, 0, 1, 2, 3)
|
||||
ADD_ALPHA_FUNC(r8g8b8_to_b8g8r8a8, 0, 1, 2, 2, 1, 0, 3)
|
||||
ADD_ALPHA_FUNC(r8g8b8_to_a8r8g8b8, 0, 1, 2, 1, 2, 3, 0)
|
||||
ADD_ALPHA_FUNC(r8g8b8_to_a8b8g8r8, 0, 1, 2, 3, 2, 1, 0)
|
||||
|
||||
struct _GdkMemoryFormatDescription
|
||||
{
|
||||
GdkMemoryAlpha alpha;
|
||||
@@ -548,15 +523,53 @@ gdk_memory_convert (guchar *dest_data,
|
||||
const GdkMemoryFormatDescription *src_desc = &memory_formats[src_format];
|
||||
float *tmp;
|
||||
gsize y;
|
||||
void (*func) (guchar *, const guchar *, gsize) = NULL;
|
||||
|
||||
g_assert (dest_format < GDK_MEMORY_N_FORMATS);
|
||||
g_assert (src_format < GDK_MEMORY_N_FORMATS);
|
||||
|
||||
if (src_format == GDK_MEMORY_R8G8B8A8 && dest_format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED)
|
||||
if (src_format == GDK_MEMORY_R8G8B8A8 && dest_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
|
||||
func = r8g8b8a8_to_r8g8b8a8_premultiplied;
|
||||
else if (src_format == GDK_MEMORY_B8G8R8A8 && dest_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
|
||||
func = r8g8b8a8_to_b8g8r8a8_premultiplied;
|
||||
else if (src_format == GDK_MEMORY_R8G8B8A8 && dest_format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED)
|
||||
func = r8g8b8a8_to_b8g8r8a8_premultiplied;
|
||||
else if (src_format == GDK_MEMORY_B8G8R8A8 && dest_format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED)
|
||||
func = r8g8b8a8_to_r8g8b8a8_premultiplied;
|
||||
else if (src_format == GDK_MEMORY_R8G8B8A8 && dest_format == GDK_MEMORY_A8R8G8B8_PREMULTIPLIED)
|
||||
func = r8g8b8a8_to_a8r8g8b8_premultiplied;
|
||||
else if (src_format == GDK_MEMORY_B8G8R8A8 && dest_format == GDK_MEMORY_A8R8G8B8_PREMULTIPLIED)
|
||||
func = r8g8b8a8_to_a8b8g8r8_premultiplied;
|
||||
else if (src_format == GDK_MEMORY_R8G8B8 && dest_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
|
||||
func = r8g8b8_to_r8g8b8a8;
|
||||
else if (src_format == GDK_MEMORY_B8G8R8 && dest_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
|
||||
func = r8g8b8_to_b8g8r8a8;
|
||||
else if (src_format == GDK_MEMORY_R8G8B8 && dest_format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED)
|
||||
func = r8g8b8_to_b8g8r8a8;
|
||||
else if (src_format == GDK_MEMORY_B8G8R8 && dest_format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED)
|
||||
func = r8g8b8_to_r8g8b8a8;
|
||||
else if (src_format == GDK_MEMORY_R8G8B8 && dest_format == GDK_MEMORY_A8R8G8B8_PREMULTIPLIED)
|
||||
func = r8g8b8_to_a8r8g8b8;
|
||||
else if (src_format == GDK_MEMORY_B8G8R8 && dest_format == GDK_MEMORY_A8R8G8B8_PREMULTIPLIED)
|
||||
func = r8g8b8_to_a8b8g8r8;
|
||||
else if (src_format == GDK_MEMORY_R8G8B8 && dest_format == GDK_MEMORY_R8G8B8A8)
|
||||
func = r8g8b8_to_r8g8b8a8;
|
||||
else if (src_format == GDK_MEMORY_B8G8R8 && dest_format == GDK_MEMORY_R8G8B8A8)
|
||||
func = r8g8b8_to_b8g8r8a8;
|
||||
else if (src_format == GDK_MEMORY_R8G8B8 && dest_format == GDK_MEMORY_B8G8R8A8)
|
||||
func = r8g8b8_to_b8g8r8a8;
|
||||
else if (src_format == GDK_MEMORY_B8G8R8 && dest_format == GDK_MEMORY_B8G8R8A8)
|
||||
func = r8g8b8_to_r8g8b8a8;
|
||||
else if (src_format == GDK_MEMORY_R8G8B8 && dest_format == GDK_MEMORY_A8R8G8B8)
|
||||
func = r8g8b8_to_a8r8g8b8;
|
||||
else if (src_format == GDK_MEMORY_B8G8R8 && dest_format == GDK_MEMORY_A8R8G8B8)
|
||||
func = r8g8b8_to_a8b8g8r8;
|
||||
|
||||
if (func != NULL)
|
||||
{
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
r8g8b8a8_to_b8g8r8a8_premultiplied (dest_data, src_data, width);
|
||||
func (dest_data, src_data, width);
|
||||
src_data += src_stride;
|
||||
dest_data += dest_stride;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1125,7 +1125,7 @@ gdk_surface_ensure_egl_surface (GdkSurface *self,
|
||||
gdk_display_get_egl_config_high_depth (display) != gdk_display_get_egl_config (display))
|
||||
{
|
||||
gdk_gl_context_clear_current_if_surface (self);
|
||||
eglDestroySurface (gdk_surface_get_display (self), priv->egl_surface);
|
||||
eglDestroySurface (gdk_display_get_egl_display (display), priv->egl_surface);
|
||||
priv->egl_surface = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,16 @@
|
||||
*/
|
||||
#define GDK_VERSION_4_6 (G_ENCODE_VERSION (4, 6))
|
||||
|
||||
/**
|
||||
* GDK_VERSION_4_8:
|
||||
*
|
||||
* A macro that evaluates to the 4.8 version of GDK, in a format
|
||||
* that can be used by the C pre-processor.
|
||||
*
|
||||
* Since: 4.8
|
||||
*/
|
||||
#define GDK_VERSION_4_8 (G_ENCODE_VERSION (4, 8))
|
||||
|
||||
|
||||
/* evaluates to the current stable version; for development cycles,
|
||||
* this means the next stable target, with a hard backstop to the
|
||||
@@ -249,4 +259,18 @@
|
||||
# define GDK_DEPRECATED_IN_4_6_FOR(f) _GDK_EXTERN
|
||||
#endif
|
||||
|
||||
#if GDK_VERSION_MAX_ALLOWED < GDK_VERSION_4_8
|
||||
# define GDK_AVAILABLE_IN_4_8 GDK_UNAVAILABLE(4, 8)
|
||||
#else
|
||||
# define GDK_AVAILABLE_IN_4_8 _GDK_EXTERN
|
||||
#endif
|
||||
|
||||
#if GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_4_8
|
||||
# define GDK_DEPRECATED_IN_4_8 GDK_DEPRECATED
|
||||
# define GDK_DEPRECATED_IN_4_8_FOR(f) GDK_DEPRECATED_FOR(f)
|
||||
#else
|
||||
# define GDK_DEPRECATED_IN_4_8 _GDK_EXTERN
|
||||
# define GDK_DEPRECATED_IN_4_8_FOR(f) _GDK_EXTERN
|
||||
#endif
|
||||
|
||||
#endif /* __GDK_VERSION_MACROS_H__ */
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#import "GdkMacosLayer.h"
|
||||
#import "GdkMacosView.h"
|
||||
#import "GdkMacosWindow.h"
|
||||
|
||||
@implementation GdkMacosView
|
||||
|
||||
@@ -56,6 +57,19 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
-(void)mouseDown:(NSEvent *)nsevent
|
||||
{
|
||||
if ([(GdkMacosWindow *)[self window] needsMouseDownQuirk])
|
||||
/* We should only hit this when we are trying to click through
|
||||
* the shadow of a window into another window. Just request
|
||||
* that the application not activate this window on mouseUp.
|
||||
* See gdkmacosdisplay-translate.c for the other half of this.
|
||||
*/
|
||||
[NSApp preventWindowOrdering];
|
||||
else
|
||||
[super mouseDown:nsevent];
|
||||
}
|
||||
|
||||
-(void)setFrame:(NSRect)rect
|
||||
{
|
||||
[super setFrame:rect];
|
||||
|
||||
@@ -171,6 +171,11 @@ typedef NSString *CALayerContentsGravity;
|
||||
return inMove;
|
||||
}
|
||||
|
||||
- (BOOL)inFullscreenTransition;
|
||||
{
|
||||
return inFullscreenTransition;
|
||||
}
|
||||
|
||||
-(void)checkSendEnterNotify
|
||||
{
|
||||
/* When a new window has been created, and the mouse is in the window
|
||||
@@ -253,7 +258,8 @@ typedef NSString *CALayerContentsGravity;
|
||||
|
||||
-(BOOL)canBecomeKeyWindow
|
||||
{
|
||||
return GDK_IS_TOPLEVEL (gdk_surface) || GDK_IS_POPUP (gdk_surface);
|
||||
return GDK_IS_TOPLEVEL (gdk_surface) ||
|
||||
(GDK_IS_POPUP (gdk_surface) && GDK_SURFACE (gdk_surface)->input_region != NULL);
|
||||
}
|
||||
|
||||
-(void)showAndMakeKey:(BOOL)makeKey
|
||||
@@ -261,9 +267,12 @@ typedef NSString *CALayerContentsGravity;
|
||||
inShowOrHide = YES;
|
||||
|
||||
if (makeKey && [self canBecomeKeyWindow])
|
||||
[self makeKeyAndOrderFront:nil];
|
||||
[self makeKeyAndOrderFront:self];
|
||||
else
|
||||
[self orderFront:nil];
|
||||
[self orderFront:self];
|
||||
|
||||
if (makeKey && [self canBecomeMainWindow])
|
||||
[self makeMainWindow];
|
||||
|
||||
inShowOrHide = NO;
|
||||
|
||||
@@ -373,9 +382,17 @@ typedef NSString *CALayerContentsGravity;
|
||||
_gdk_macos_surface_configure ([self gdkSurface]);
|
||||
}
|
||||
|
||||
- (void)windowDidResize:(NSNotification *)notification
|
||||
-(void)windowDidResize:(NSNotification *)notification
|
||||
{
|
||||
_gdk_macos_surface_configure ([self gdkSurface]);
|
||||
_gdk_macos_surface_configure (gdk_surface);
|
||||
|
||||
/* If we're using server-side decorations, this notification is coming
|
||||
* in from a display-side change. We need to request a layout in
|
||||
* addition to the configure event.
|
||||
*/
|
||||
if (GDK_IS_MACOS_TOPLEVEL_SURFACE (gdk_surface) &&
|
||||
GDK_MACOS_TOPLEVEL_SURFACE (gdk_surface)->decorated)
|
||||
gdk_surface_request_layout (GDK_SURFACE (gdk_surface));
|
||||
}
|
||||
|
||||
/* Used by gdkmacosdisplay-translate.c to decide if our sendEvent() handler
|
||||
@@ -668,7 +685,12 @@ typedef NSString *CALayerContentsGravity;
|
||||
is_opaque = (([self styleMask] & NSWindowStyleMaskTitled) != 0);
|
||||
|
||||
if (was_fullscreen != is_fullscreen)
|
||||
_gdk_macos_surface_update_fullscreen_state (gdk_surface);
|
||||
{
|
||||
if (was_fullscreen)
|
||||
[self setFrame:lastUnfullscreenFrame display:NO];
|
||||
|
||||
_gdk_macos_surface_update_fullscreen_state (gdk_surface);
|
||||
}
|
||||
|
||||
if (was_opaque != is_opaque)
|
||||
{
|
||||
@@ -742,32 +764,37 @@ typedef NSString *CALayerContentsGravity;
|
||||
|
||||
-(void)windowWillEnterFullScreen:(NSNotification *)aNotification
|
||||
{
|
||||
inFullscreenTransition = YES;
|
||||
lastUnfullscreenFrame = [self frame];
|
||||
}
|
||||
|
||||
-(void)windowDidEnterFullScreen:(NSNotification *)aNotification
|
||||
{
|
||||
inFullscreenTransition = NO;
|
||||
initialPositionKnown = NO;
|
||||
[self checkSendEnterNotify];
|
||||
}
|
||||
|
||||
-(void)windowWillExitFullScreen:(NSNotification *)aNotification
|
||||
{
|
||||
[self setFrame:lastUnfullscreenFrame display:NO];
|
||||
inFullscreenTransition = YES;
|
||||
}
|
||||
|
||||
-(void)windowDidExitFullScreen:(NSNotification *)aNotification
|
||||
{
|
||||
inFullscreenTransition = NO;
|
||||
initialPositionKnown = NO;
|
||||
[self checkSendEnterNotify];
|
||||
}
|
||||
|
||||
-(void)windowDidFailToEnterFullScreen:(NSNotification *)aNotification
|
||||
{
|
||||
inFullscreenTransition = NO;
|
||||
}
|
||||
|
||||
-(void)windowDidFailToExitFullScreen:(NSNotification *)aNotification
|
||||
{
|
||||
inFullscreenTransition = NO;
|
||||
}
|
||||
|
||||
-(void)windowDidChangeScreen:(NSNotification *)aNotification
|
||||
@@ -814,4 +841,10 @@ typedef NSString *CALayerContentsGravity;
|
||||
[(GdkMacosView *)[self contentView] swapBuffer:buffer withDamage:damage];
|
||||
}
|
||||
|
||||
-(BOOL)needsMouseDownQuirk
|
||||
{
|
||||
return GDK_IS_MACOS_TOPLEVEL_SURFACE (gdk_surface) &&
|
||||
!GDK_MACOS_TOPLEVEL_SURFACE (gdk_surface)->decorated;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
NSRect lastMaximizedFrame;
|
||||
NSRect lastUnfullscreenFrame;
|
||||
BOOL inMaximizeTransition;
|
||||
BOOL inFullscreenTransition;
|
||||
}
|
||||
|
||||
-(void)beginManualMove;
|
||||
@@ -69,5 +70,7 @@
|
||||
-(BOOL)trackManualResize;
|
||||
-(void)setDecorated:(BOOL)decorated;
|
||||
-(void)swapBuffer:(GdkMacosBuffer *)buffer withDamage:(const cairo_region_t *)damage;
|
||||
-(BOOL)needsMouseDownQuirk;
|
||||
-(BOOL)inFullscreenTransition;
|
||||
|
||||
@end
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
|
||||
#include "gdkdisplaylinksource.h"
|
||||
|
||||
#include "gdkdebug.h"
|
||||
#include "gdkmacoseventsource-private.h"
|
||||
#include "gdkmacosmonitor-private.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
static gint64 host_to_frame_clock_time (gint64 val);
|
||||
@@ -65,7 +67,7 @@ gdk_display_link_source_dispatch (GSource *source,
|
||||
|
||||
impl->needs_dispatch = FALSE;
|
||||
|
||||
if (callback != NULL)
|
||||
if (!impl->paused && callback != NULL)
|
||||
ret = callback (user_data);
|
||||
|
||||
return ret;
|
||||
@@ -76,7 +78,9 @@ gdk_display_link_source_finalize (GSource *source)
|
||||
{
|
||||
GdkDisplayLinkSource *impl = (GdkDisplayLinkSource *)source;
|
||||
|
||||
CVDisplayLinkStop (impl->display_link);
|
||||
if (!impl->paused)
|
||||
CVDisplayLinkStop (impl->display_link);
|
||||
|
||||
CVDisplayLinkRelease (impl->display_link);
|
||||
}
|
||||
|
||||
@@ -90,12 +94,18 @@ static GSourceFuncs gdk_display_link_source_funcs = {
|
||||
void
|
||||
gdk_display_link_source_pause (GdkDisplayLinkSource *source)
|
||||
{
|
||||
g_return_if_fail (source->paused == FALSE);
|
||||
|
||||
source->paused = TRUE;
|
||||
CVDisplayLinkStop (source->display_link);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_display_link_source_unpause (GdkDisplayLinkSource *source)
|
||||
{
|
||||
g_return_if_fail (source->paused == TRUE);
|
||||
|
||||
source->paused = FALSE;
|
||||
CVDisplayLinkStart (source->display_link);
|
||||
}
|
||||
|
||||
@@ -147,6 +157,7 @@ gdk_display_link_source_frame_cb (CVDisplayLinkRef display_link,
|
||||
|
||||
/**
|
||||
* gdk_display_link_source_new:
|
||||
* @display_id: the identifier of the monitor
|
||||
*
|
||||
* Creates a new `GSource` that will activate the dispatch function upon
|
||||
* notification from a CVDisplayLink that a new frame should be drawn.
|
||||
@@ -159,41 +170,61 @@ gdk_display_link_source_frame_cb (CVDisplayLinkRef display_link,
|
||||
* Returns: (transfer full): A newly created `GSource`
|
||||
*/
|
||||
GSource *
|
||||
gdk_display_link_source_new (void)
|
||||
gdk_display_link_source_new (CGDirectDisplayID display_id,
|
||||
CGDisplayModeRef mode)
|
||||
{
|
||||
GdkDisplayLinkSource *impl;
|
||||
GSource *source;
|
||||
CVReturn ret;
|
||||
double period;
|
||||
char *name;
|
||||
|
||||
source = g_source_new (&gdk_display_link_source_funcs, sizeof *impl);
|
||||
impl = (GdkDisplayLinkSource *)source;
|
||||
impl->display_id = display_id;
|
||||
impl->paused = TRUE;
|
||||
|
||||
/*
|
||||
* Create our link based on currently connected displays.
|
||||
* If there are multiple displays, this will be something that tries
|
||||
* to work for all of them. In the future, we may want to explore multiple
|
||||
* links based on the connected displays.
|
||||
/* Create DisplayLink for timing information for the display in
|
||||
* question so that we can produce graphics for that display at whatever
|
||||
* rate it can provide.
|
||||
*/
|
||||
ret = CVDisplayLinkCreateWithActiveCGDisplays (&impl->display_link);
|
||||
if (ret != kCVReturnSuccess)
|
||||
if (CVDisplayLinkCreateWithCGDisplay (display_id, &impl->display_link) != kCVReturnSuccess)
|
||||
{
|
||||
g_warning ("Failed to initialize CVDisplayLink!");
|
||||
return source;
|
||||
goto failure;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine our nominal period between frames.
|
||||
*/
|
||||
period = CVDisplayLinkGetActualOutputVideoRefreshPeriod (impl->display_link);
|
||||
if (period == 0.0)
|
||||
period = 1.0 / 60.0;
|
||||
impl->refresh_interval = period * 1000000L;
|
||||
impl->refresh_rate = 1.0 / period * 1000L;
|
||||
impl->refresh_rate = CGDisplayModeGetRefreshRate (mode) * 1000.0;
|
||||
|
||||
/*
|
||||
* Wire up our callback to be executed within the high-priority thread.
|
||||
*/
|
||||
if (impl->refresh_rate == 0)
|
||||
{
|
||||
const CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod (impl->display_link);
|
||||
if (!(time.flags & kCVTimeIsIndefinite))
|
||||
impl->refresh_rate = (double)time.timeScale / (double)time.timeValue * 1000.0;
|
||||
}
|
||||
|
||||
if (impl->refresh_rate != 0)
|
||||
{
|
||||
impl->refresh_interval = 1000000.0 / (double)impl->refresh_rate * 1000.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
double period = CVDisplayLinkGetActualOutputVideoRefreshPeriod (impl->display_link);
|
||||
|
||||
if (period == 0.0)
|
||||
period = 1.0 / 60.0;
|
||||
|
||||
impl->refresh_rate = 1.0 / period * 1000L;
|
||||
impl->refresh_interval = period * 1000000L;
|
||||
}
|
||||
|
||||
name = _gdk_macos_monitor_get_connector_name (display_id);
|
||||
GDK_NOTE (MISC,
|
||||
g_message ("Monitor \"%s\" discovered with Refresh Rate %d and Interval %"G_GINT64_FORMAT,
|
||||
name ? name : "unknown",
|
||||
impl->refresh_rate,
|
||||
impl->refresh_interval));
|
||||
g_free (name);
|
||||
|
||||
/* Wire up our callback to be executed within the high-priority thread. */
|
||||
CVDisplayLinkSetOutputCallback (impl->display_link,
|
||||
gdk_display_link_source_frame_cb,
|
||||
source);
|
||||
@@ -201,6 +232,10 @@ gdk_display_link_source_new (void)
|
||||
g_source_set_static_name (source, "[gdk] quartz frame clock");
|
||||
|
||||
return source;
|
||||
|
||||
failure:
|
||||
g_source_unref (source);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gint64
|
||||
|
||||
@@ -30,17 +30,20 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GSource source;
|
||||
GSource source;
|
||||
|
||||
CVDisplayLinkRef display_link;
|
||||
gint64 refresh_interval;
|
||||
guint refresh_rate;
|
||||
CGDirectDisplayID display_id;
|
||||
CVDisplayLinkRef display_link;
|
||||
gint64 refresh_interval;
|
||||
guint refresh_rate;
|
||||
guint paused : 1;
|
||||
|
||||
volatile gint64 presentation_time;
|
||||
volatile guint needs_dispatch;
|
||||
volatile gint64 presentation_time;
|
||||
volatile guint needs_dispatch;
|
||||
} GdkDisplayLinkSource;
|
||||
|
||||
GSource *gdk_display_link_source_new (void);
|
||||
GSource *gdk_display_link_source_new (CGDirectDisplayID display_id,
|
||||
CGDisplayModeRef mode);
|
||||
void gdk_display_link_source_pause (GdkDisplayLinkSource *source);
|
||||
void gdk_display_link_source_unpause (GdkDisplayLinkSource *source);
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ GdkMacosBuffer *_gdk_macos_buffer_new (int width
|
||||
IOSurfaceRef _gdk_macos_buffer_get_native (GdkMacosBuffer *self);
|
||||
void _gdk_macos_buffer_lock (GdkMacosBuffer *self);
|
||||
void _gdk_macos_buffer_unlock (GdkMacosBuffer *self);
|
||||
void _gdk_macos_buffer_read_lock (GdkMacosBuffer *self);
|
||||
void _gdk_macos_buffer_read_unlock (GdkMacosBuffer *self);
|
||||
guint _gdk_macos_buffer_get_width (GdkMacosBuffer *self);
|
||||
guint _gdk_macos_buffer_get_height (GdkMacosBuffer *self);
|
||||
guint _gdk_macos_buffer_get_stride (GdkMacosBuffer *self);
|
||||
|
||||
@@ -192,6 +192,45 @@ _gdk_macos_buffer_unlock (GdkMacosBuffer *self)
|
||||
IOSurfaceUnlock (self->surface, 0, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* _gdk_macos_buffer_lock_readonly:
|
||||
*
|
||||
* Like _gdk_macos_buffer_lock() but uses the read-only flag to
|
||||
* indicate we are not interested in retrieving the updates from
|
||||
* the GPU before modifying the CPU-side cache.
|
||||
*
|
||||
* Must be used with _gdk_macos_buffer_unlock_readonly().
|
||||
*/
|
||||
void
|
||||
_gdk_macos_buffer_read_lock (GdkMacosBuffer *self)
|
||||
{
|
||||
kern_return_t ret;
|
||||
|
||||
g_return_if_fail (GDK_IS_MACOS_BUFFER (self));
|
||||
g_return_if_fail (self->lock_count == 0);
|
||||
|
||||
self->lock_count++;
|
||||
|
||||
ret = IOSurfaceLock (self->surface, kIOSurfaceLockReadOnly, NULL);
|
||||
|
||||
g_return_if_fail (ret == KERN_SUCCESS);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_buffer_read_unlock (GdkMacosBuffer *self)
|
||||
{
|
||||
kern_return_t ret;
|
||||
|
||||
g_return_if_fail (GDK_IS_MACOS_BUFFER (self));
|
||||
g_return_if_fail (self->lock_count == 1);
|
||||
|
||||
self->lock_count--;
|
||||
|
||||
ret = IOSurfaceUnlock (self->surface, kIOSurfaceLockReadOnly, NULL);
|
||||
|
||||
g_return_if_fail (ret == KERN_SUCCESS);
|
||||
}
|
||||
|
||||
guint
|
||||
_gdk_macos_buffer_get_width (GdkMacosBuffer *self)
|
||||
{
|
||||
@@ -242,7 +281,7 @@ _gdk_macos_buffer_set_damage (GdkMacosBuffer *self,
|
||||
return;
|
||||
|
||||
g_clear_pointer (&self->damage, cairo_region_destroy);
|
||||
self->damage = cairo_region_reference (damage);
|
||||
self->damage = cairo_region_copy (damage);
|
||||
}
|
||||
|
||||
gpointer
|
||||
|
||||
@@ -42,19 +42,6 @@ struct _GdkMacosCairoContextClass
|
||||
|
||||
G_DEFINE_TYPE (GdkMacosCairoContext, _gdk_macos_cairo_context, GDK_TYPE_CAIRO_CONTEXT)
|
||||
|
||||
static const cairo_user_data_key_t buffer_key;
|
||||
|
||||
static void
|
||||
unlock_buffer (gpointer data)
|
||||
{
|
||||
GdkMacosBuffer *buffer = data;
|
||||
|
||||
g_assert (GDK_IS_MACOS_BUFFER (buffer));
|
||||
|
||||
_gdk_macos_buffer_unlock (buffer);
|
||||
g_clear_object (&buffer);
|
||||
}
|
||||
|
||||
static cairo_t *
|
||||
_gdk_macos_cairo_context_cairo_create (GdkCairoContext *cairo_context)
|
||||
{
|
||||
@@ -106,12 +93,9 @@ _gdk_macos_cairo_context_cairo_create (GdkCairoContext *cairo_context)
|
||||
stride);
|
||||
cairo_surface_set_device_scale (image_surface, scale, scale);
|
||||
|
||||
/* Lock the buffer so we can modify it safely */
|
||||
_gdk_macos_buffer_lock (buffer);
|
||||
cairo_surface_set_user_data (image_surface,
|
||||
&buffer_key,
|
||||
g_object_ref (buffer),
|
||||
unlock_buffer);
|
||||
/* The buffer should already be locked at this point, and will
|
||||
* be unlocked as part of end_frame.
|
||||
*/
|
||||
|
||||
if (!(cr = cairo_create (image_surface)))
|
||||
goto failure;
|
||||
@@ -158,6 +142,52 @@ failure:
|
||||
return cr;
|
||||
}
|
||||
|
||||
static void
|
||||
copy_surface_data (GdkMacosBuffer *from,
|
||||
GdkMacosBuffer *to,
|
||||
const cairo_region_t *region,
|
||||
int scale)
|
||||
{
|
||||
const guint8 *from_base;
|
||||
guint8 *to_base;
|
||||
guint from_stride;
|
||||
guint to_stride;
|
||||
guint n_rects;
|
||||
|
||||
g_assert (GDK_IS_MACOS_BUFFER (from));
|
||||
g_assert (GDK_IS_MACOS_BUFFER (to));
|
||||
g_assert (region != NULL);
|
||||
g_assert (!cairo_region_is_empty (region));
|
||||
|
||||
from_base = _gdk_macos_buffer_get_data (from);
|
||||
from_stride = _gdk_macos_buffer_get_stride (from);
|
||||
|
||||
to_base = _gdk_macos_buffer_get_data (to);
|
||||
to_stride = _gdk_macos_buffer_get_stride (to);
|
||||
|
||||
n_rects = cairo_region_num_rectangles (region);
|
||||
|
||||
for (guint i = 0; i < n_rects; i++)
|
||||
{
|
||||
cairo_rectangle_int_t rect;
|
||||
int y2;
|
||||
|
||||
cairo_region_get_rectangle (region, i, &rect);
|
||||
|
||||
rect.y *= scale;
|
||||
rect.height *= scale;
|
||||
rect.x *= scale;
|
||||
rect.width *= scale;
|
||||
|
||||
y2 = rect.y + rect.height;
|
||||
|
||||
for (int y = rect.y; y < y2; y++)
|
||||
memcpy (&to_base[y * to_stride + rect.x * 4],
|
||||
&from_base[y * from_stride + rect.x * 4],
|
||||
rect.width * 4);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_macos_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
||||
gboolean prefers_high_depth,
|
||||
@@ -165,34 +195,68 @@ _gdk_macos_cairo_context_begin_frame (GdkDrawContext *draw_context,
|
||||
{
|
||||
GdkMacosCairoContext *self = (GdkMacosCairoContext *)draw_context;
|
||||
GdkMacosBuffer *buffer;
|
||||
GdkSurface *surface;
|
||||
GdkMacosSurface *surface;
|
||||
|
||||
g_assert (GDK_IS_MACOS_CAIRO_CONTEXT (self));
|
||||
|
||||
[CATransaction begin];
|
||||
[CATransaction setDisableActions:YES];
|
||||
|
||||
surface = gdk_draw_context_get_surface (draw_context);
|
||||
buffer = _gdk_macos_surface_get_buffer (GDK_MACOS_SURFACE (surface));
|
||||
surface = GDK_MACOS_SURFACE (gdk_draw_context_get_surface (draw_context));
|
||||
buffer = _gdk_macos_surface_get_buffer (surface);
|
||||
|
||||
_gdk_macos_buffer_set_damage (buffer, region);
|
||||
_gdk_macos_buffer_set_flipped (buffer, FALSE);
|
||||
|
||||
_gdk_macos_buffer_lock (buffer);
|
||||
|
||||
/* If there is damage that was on the previous frame that is not on
|
||||
* this frame, we need to copy that rendered region over to the back
|
||||
* buffer so that when swapping buffers, we still have that content.
|
||||
* This is done with a read-only lock on the IOSurface to avoid
|
||||
* invalidating the buffer contents.
|
||||
*/
|
||||
if (surface->front != NULL)
|
||||
{
|
||||
const cairo_region_t *previous = _gdk_macos_buffer_get_damage (surface->front);
|
||||
|
||||
if (previous != NULL)
|
||||
{
|
||||
cairo_region_t *copy;
|
||||
|
||||
copy = cairo_region_copy (previous);
|
||||
cairo_region_subtract (copy, region);
|
||||
|
||||
if (!cairo_region_is_empty (copy))
|
||||
{
|
||||
int scale = gdk_surface_get_scale_factor (GDK_SURFACE (surface));
|
||||
|
||||
_gdk_macos_buffer_read_lock (surface->front);
|
||||
copy_surface_data (surface->front, buffer, copy, scale);
|
||||
_gdk_macos_buffer_read_unlock (surface->front);
|
||||
}
|
||||
|
||||
cairo_region_destroy (copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_macos_cairo_context_end_frame (GdkDrawContext *draw_context,
|
||||
cairo_region_t *painted)
|
||||
{
|
||||
GdkMacosCairoContext *self = (GdkMacosCairoContext *)draw_context;
|
||||
GdkMacosSurface *surface;
|
||||
GdkMacosBuffer *buffer;
|
||||
GdkSurface *surface;
|
||||
|
||||
g_assert (GDK_IS_MACOS_CAIRO_CONTEXT (draw_context));
|
||||
g_assert (GDK_IS_MACOS_CAIRO_CONTEXT (self));
|
||||
|
||||
surface = gdk_draw_context_get_surface (draw_context);
|
||||
buffer = _gdk_macos_surface_get_buffer (GDK_MACOS_SURFACE (surface));
|
||||
surface = GDK_MACOS_SURFACE (gdk_draw_context_get_surface (draw_context));
|
||||
buffer = _gdk_macos_surface_get_buffer (surface);
|
||||
|
||||
_gdk_macos_surface_swap_buffers (GDK_MACOS_SURFACE (surface), painted);
|
||||
_gdk_macos_buffer_set_damage (buffer, NULL);
|
||||
_gdk_macos_buffer_unlock (buffer);
|
||||
|
||||
_gdk_macos_surface_swap_buffers (surface, painted);
|
||||
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright © 2022 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
#include "gdkmacosdisplay-private.h"
|
||||
#include "gdkmacossurface-private.h"
|
||||
|
||||
static void
|
||||
gdk_macos_display_user_defaults_changed_cb (CFNotificationCenterRef center,
|
||||
void *observer,
|
||||
CFStringRef name,
|
||||
const void *object,
|
||||
CFDictionaryRef userInfo)
|
||||
{
|
||||
GdkMacosDisplay *self = observer;
|
||||
|
||||
g_assert (GDK_IS_MACOS_DISPLAY (self));
|
||||
|
||||
_gdk_macos_display_reload_settings (self);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_macos_display_monitors_changed_cb (CFNotificationCenterRef center,
|
||||
void *observer,
|
||||
CFStringRef name,
|
||||
const void *object,
|
||||
CFDictionaryRef userInfo)
|
||||
{
|
||||
GdkMacosDisplay *self = observer;
|
||||
|
||||
g_assert (GDK_IS_MACOS_DISPLAY (self));
|
||||
|
||||
_gdk_macos_display_reload_monitors (self);
|
||||
|
||||
/* Now we need to update all our surface positions since they
|
||||
* probably just changed origins.
|
||||
*/
|
||||
for (const GList *iter = _gdk_macos_display_get_surfaces (self);
|
||||
iter != NULL;
|
||||
iter = iter->next)
|
||||
{
|
||||
GdkMacosSurface *surface = iter->data;
|
||||
|
||||
g_assert (GDK_IS_MACOS_SURFACE (surface));
|
||||
|
||||
_gdk_macos_surface_monitor_changed (surface);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_gdk_macos_display_feedback_init (GdkMacosDisplay *self)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_MACOS_DISPLAY (self));
|
||||
|
||||
CFNotificationCenterAddObserver (CFNotificationCenterGetLocalCenter (),
|
||||
self,
|
||||
gdk_macos_display_monitors_changed_cb,
|
||||
CFSTR ("NSApplicationDidChangeScreenParametersNotification"),
|
||||
NULL,
|
||||
CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
|
||||
CFNotificationCenterAddObserver (CFNotificationCenterGetDistributedCenter (),
|
||||
self,
|
||||
gdk_macos_display_user_defaults_changed_cb,
|
||||
CFSTR ("NSUserDefaultsDidChangeNotification"),
|
||||
NULL,
|
||||
CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_display_feedback_destroy (GdkMacosDisplay *self)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_MACOS_DISPLAY (self));
|
||||
|
||||
CFNotificationCenterRemoveObserver (CFNotificationCenterGetDistributedCenter (),
|
||||
self,
|
||||
CFSTR ("NSApplicationDidChangeScreenParametersNotification"),
|
||||
NULL);
|
||||
|
||||
CFNotificationCenterRemoveObserver (CFNotificationCenterGetDistributedCenter (),
|
||||
self,
|
||||
CFSTR ("NSUserDefaultsDidChangeNotification"),
|
||||
NULL);
|
||||
|
||||
}
|
||||
@@ -43,6 +43,8 @@ G_BEGIN_DECLS
|
||||
#define GIC_FILTER_PASSTHRU 0
|
||||
#define GIC_FILTER_FILTERED 1
|
||||
|
||||
#define GDK_MACOS_EVENT_DROP (GdkEvent *)GSIZE_TO_POINTER(1)
|
||||
|
||||
struct _GdkMacosDisplay
|
||||
{
|
||||
GdkDisplay parent_instance;
|
||||
@@ -68,16 +70,6 @@ struct _GdkMacosDisplay
|
||||
*/
|
||||
GQueue sorted_surfaces;
|
||||
|
||||
/* Our CVDisplayLink based GSource which we use to freeze/thaw the
|
||||
* GdkFrameClock for the surface.
|
||||
*/
|
||||
GSource *frame_source;
|
||||
|
||||
/* A queue of surfaces which we know are awaiting frames to be drawn. This
|
||||
* uses the GdkMacosSurface.frame link.
|
||||
*/
|
||||
GQueue awaiting_frames;
|
||||
|
||||
/* The surface that is receiving keyboard events */
|
||||
GdkMacosSurface *keyboard_surface;
|
||||
|
||||
@@ -92,6 +84,14 @@ struct _GdkMacosDisplay
|
||||
int min_y;
|
||||
int max_x;
|
||||
int max_y;
|
||||
|
||||
/* A GSource to select a new main/key window */
|
||||
guint select_key_in_idle;
|
||||
|
||||
/* Note if we have a key window that is not a GdkMacosWindow
|
||||
* such as a NSPanel used for native dialogs.
|
||||
*/
|
||||
guint key_window_is_foregin : 1;
|
||||
};
|
||||
|
||||
struct _GdkMacosDisplayClass
|
||||
@@ -124,6 +124,8 @@ GdkMonitor *_gdk_macos_display_get_monitor_at_display_coords (GdkMacosDisp
|
||||
int y);
|
||||
GdkEvent *_gdk_macos_display_translate (GdkMacosDisplay *self,
|
||||
NSEvent *event);
|
||||
void _gdk_macos_display_feedback_init (GdkMacosDisplay *self);
|
||||
void _gdk_macos_display_feedback_destroy (GdkMacosDisplay *self);
|
||||
void _gdk_macos_display_break_all_grabs (GdkMacosDisplay *self,
|
||||
guint32 time);
|
||||
GdkModifierType _gdk_macos_display_get_current_keyboard_modifiers (GdkMacosDisplay *self);
|
||||
@@ -136,10 +138,6 @@ GdkMacosSurface *_gdk_macos_display_get_surface_at_display_coords (GdkMacosDisp
|
||||
void _gdk_macos_display_reload_monitors (GdkMacosDisplay *self);
|
||||
void _gdk_macos_display_surface_removed (GdkMacosDisplay *self,
|
||||
GdkMacosSurface *surface);
|
||||
void _gdk_macos_display_add_frame_callback (GdkMacosDisplay *self,
|
||||
GdkMacosSurface *surface);
|
||||
void _gdk_macos_display_remove_frame_callback (GdkMacosDisplay *self,
|
||||
GdkMacosSurface *surface);
|
||||
NSWindow *_gdk_macos_display_find_native_under_pointer (GdkMacosDisplay *self,
|
||||
int *x,
|
||||
int *y);
|
||||
@@ -155,7 +153,6 @@ void _gdk_macos_display_surface_resigned_key (GdkMacosDisp
|
||||
GdkMacosSurface *surface);
|
||||
void _gdk_macos_display_surface_became_key (GdkMacosDisplay *self,
|
||||
GdkMacosSurface *surface);
|
||||
int _gdk_macos_display_get_nominal_refresh_rate (GdkMacosDisplay *self);
|
||||
void _gdk_macos_display_clear_sorting (GdkMacosDisplay *self);
|
||||
const GList *_gdk_macos_display_get_surfaces (GdkMacosDisplay *self);
|
||||
void _gdk_macos_display_send_button_event (GdkMacosDisplay *self,
|
||||
|
||||
@@ -34,7 +34,7 @@ typedef struct
|
||||
const char *font_name;
|
||||
int xft_dpi;
|
||||
int double_click_time;
|
||||
int cursor_blink_timeout;
|
||||
int cursor_blink_time;
|
||||
guint enable_animations : 1;
|
||||
guint shell_shows_desktop : 1;
|
||||
guint shell_shows_menubar : 1;
|
||||
@@ -65,9 +65,9 @@ _gdk_macos_settings_load (GdkMacosSettings *settings)
|
||||
|
||||
ival = [defaults integerForKey:@"NSTextInsertionPointBlinkPeriod"];
|
||||
if (ival > 0)
|
||||
settings->cursor_blink_timeout = ival;
|
||||
settings->cursor_blink_time = ival;
|
||||
else
|
||||
settings->cursor_blink_timeout = 1000;
|
||||
settings->cursor_blink_time = 1000;
|
||||
|
||||
settings->primary_button_warps_slider =
|
||||
[[NSUserDefaults standardUserDefaults] boolForKey:@"AppleScrollerPagingBehavior"] == YES;
|
||||
@@ -124,9 +124,9 @@ _gdk_macos_display_get_setting (GdkMacosDisplay *self,
|
||||
g_value_set_int (value, current_settings.xft_dpi);
|
||||
ret = TRUE;
|
||||
}
|
||||
else if (strcmp (setting, "gtk-cursor-blink-timeout") == 0)
|
||||
else if (strcmp (setting, "gtk-cursor-blink-time") == 0)
|
||||
{
|
||||
g_value_set_int (value, current_settings.cursor_blink_timeout);
|
||||
g_value_set_int (value, current_settings.cursor_blink_time);
|
||||
ret = TRUE;
|
||||
}
|
||||
else if (strcmp (setting, "gtk-double-click-time") == 0)
|
||||
|
||||
@@ -612,6 +612,8 @@ fill_scroll_event (GdkMacosDisplay *self,
|
||||
GdkModifierType state;
|
||||
GdkDevice *pointer;
|
||||
GdkEvent *ret = NULL;
|
||||
NSEventPhase phase;
|
||||
NSEventPhase momentumPhase;
|
||||
GdkSeat *seat;
|
||||
double dx;
|
||||
double dy;
|
||||
@@ -619,11 +621,32 @@ fill_scroll_event (GdkMacosDisplay *self,
|
||||
g_assert (GDK_IS_MACOS_SURFACE (surface));
|
||||
g_assert (nsevent != NULL);
|
||||
|
||||
phase = [nsevent phase];
|
||||
momentumPhase = [nsevent momentumPhase];
|
||||
|
||||
/* Ignore kinetic scroll events from the display server as we already
|
||||
* handle those internally.
|
||||
*/
|
||||
if (phase == 0 && momentumPhase != 0)
|
||||
return GDK_MACOS_EVENT_DROP;
|
||||
|
||||
seat = gdk_display_get_default_seat (GDK_DISPLAY (self));
|
||||
pointer = gdk_seat_get_pointer (seat);
|
||||
state = _gdk_macos_display_get_current_mouse_modifiers (self) |
|
||||
_gdk_macos_display_get_current_keyboard_modifiers (self);
|
||||
|
||||
/* If we are starting a new phase, send a stop so any previous
|
||||
* scrolling immediately stops.
|
||||
*/
|
||||
if (phase == NSEventPhaseMayBegin)
|
||||
return gdk_scroll_event_new (GDK_SURFACE (surface),
|
||||
pointer,
|
||||
NULL,
|
||||
get_time_from_ns_event (nsevent),
|
||||
state,
|
||||
0.0, 0.0, TRUE,
|
||||
GDK_SCROLL_UNIT_SURFACE);
|
||||
|
||||
dx = [nsevent deltaX];
|
||||
dy = [nsevent deltaY];
|
||||
|
||||
@@ -643,7 +666,8 @@ fill_scroll_event (GdkMacosDisplay *self,
|
||||
state,
|
||||
-sx,
|
||||
-sy,
|
||||
FALSE);
|
||||
FALSE,
|
||||
GDK_SCROLL_UNIT_SURFACE);
|
||||
|
||||
/* Fall through for scroll emulation */
|
||||
}
|
||||
@@ -667,34 +691,33 @@ fill_scroll_event (GdkMacosDisplay *self,
|
||||
dy = 0.0;
|
||||
}
|
||||
|
||||
if (dx != 0.0 || dy != 0.0)
|
||||
if ((dx != 0.0 || dy != 0.0) && ![nsevent hasPreciseScrollingDeltas])
|
||||
{
|
||||
if ([nsevent hasPreciseScrollingDeltas])
|
||||
{
|
||||
GdkEvent *emulated;
|
||||
g_assert (ret == NULL);
|
||||
|
||||
emulated = gdk_scroll_event_new_discrete (GDK_SURFACE (surface),
|
||||
pointer,
|
||||
NULL,
|
||||
get_time_from_ns_event (nsevent),
|
||||
state,
|
||||
direction,
|
||||
TRUE);
|
||||
_gdk_event_queue_append (GDK_DISPLAY (self), emulated);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert (ret == NULL);
|
||||
ret = gdk_scroll_event_new_discrete (GDK_SURFACE (surface),
|
||||
pointer,
|
||||
NULL,
|
||||
get_time_from_ns_event (nsevent),
|
||||
state,
|
||||
direction,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
ret = gdk_scroll_event_new (GDK_SURFACE (surface),
|
||||
pointer,
|
||||
NULL,
|
||||
get_time_from_ns_event (nsevent),
|
||||
state,
|
||||
-dx * 32,
|
||||
-dy * 32,
|
||||
FALSE);
|
||||
}
|
||||
if (phase == NSEventPhaseEnded || phase == NSEventPhaseCancelled)
|
||||
{
|
||||
/* The user must have released their fingers in a touchpad
|
||||
* scroll, so try to send a scroll is_stop event.
|
||||
*/
|
||||
if (ret != NULL)
|
||||
_gdk_event_queue_append (GDK_DISPLAY (self), g_steal_pointer (&ret));
|
||||
ret = gdk_scroll_event_new (GDK_SURFACE (surface),
|
||||
pointer,
|
||||
NULL,
|
||||
get_time_from_ns_event (nsevent),
|
||||
state,
|
||||
0.0, 0.0, TRUE,
|
||||
GDK_SCROLL_UNIT_SURFACE);
|
||||
}
|
||||
|
||||
return g_steal_pointer (&ret);
|
||||
@@ -1066,6 +1089,7 @@ _gdk_macos_display_translate (GdkMacosDisplay *self,
|
||||
GdkMacosSurface *surface;
|
||||
GdkMacosWindow *window;
|
||||
NSEventType event_type;
|
||||
NSWindow *event_window;
|
||||
GdkEvent *ret = NULL;
|
||||
int x;
|
||||
int y;
|
||||
@@ -1108,6 +1132,15 @@ _gdk_macos_display_translate (GdkMacosDisplay *self,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* If the event was delivered to NSWindow that is foreign (or rather,
|
||||
* Cocoa native), then we should pass the event along to that window.
|
||||
*/
|
||||
if ((event_window = [nsevent window]) && !GDK_IS_MACOS_WINDOW (event_window))
|
||||
return NULL;
|
||||
|
||||
/* If we can't find a GdkSurface to deliver the event to, then we
|
||||
* should pass it along to the NSApp.
|
||||
*/
|
||||
if (!(surface = find_surface_for_ns_event (self, nsevent, &x, &y)))
|
||||
return NULL;
|
||||
|
||||
@@ -1139,15 +1172,31 @@ _gdk_macos_display_translate (GdkMacosDisplay *self,
|
||||
if (test_resize (nsevent, surface, x, y))
|
||||
return NULL;
|
||||
|
||||
if ((event_type == NSEventTypeRightMouseDown ||
|
||||
event_type == NSEventTypeOtherMouseDown ||
|
||||
event_type == NSEventTypeLeftMouseDown))
|
||||
if (event_type == NSEventTypeRightMouseDown ||
|
||||
event_type == NSEventTypeOtherMouseDown ||
|
||||
event_type == NSEventTypeLeftMouseDown)
|
||||
{
|
||||
if (![NSApp isActive])
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
|
||||
if (![window isKeyWindow])
|
||||
[window makeKeyWindow];
|
||||
{
|
||||
NSWindow *orig_window = [nsevent window];
|
||||
|
||||
/* To get NSApp to supress activating the window we might
|
||||
* have clicked through the shadow of, we need to dispatch
|
||||
* the event and handle it in GdkMacosView:mouseDown to call
|
||||
* [NSApp preventWindowOrdering]. Calling it here will not
|
||||
* do anything as the event is not registered.
|
||||
*/
|
||||
if (orig_window &&
|
||||
GDK_IS_MACOS_WINDOW (orig_window) &&
|
||||
[(GdkMacosWindow *)orig_window needsMouseDownQuirk])
|
||||
[NSApp sendEvent:nsevent];
|
||||
|
||||
[window showAndMakeKey:YES];
|
||||
_gdk_macos_display_clear_sorting (self);
|
||||
}
|
||||
}
|
||||
|
||||
switch ((int)event_type)
|
||||
@@ -1180,7 +1229,11 @@ _gdk_macos_display_translate (GdkMacosDisplay *self,
|
||||
GdkDevice *pointer = gdk_seat_get_pointer (seat);
|
||||
GdkDeviceGrabInfo *grab = _gdk_display_get_last_device_grab (GDK_DISPLAY (self), pointer);
|
||||
|
||||
if (grab == NULL)
|
||||
if ([(GdkMacosWindow *)window isInManualResizeOrMove])
|
||||
{
|
||||
ret = GDK_MACOS_EVENT_DROP;
|
||||
}
|
||||
else if (grab == NULL)
|
||||
{
|
||||
if (event_type == NSEventTypeMouseExited)
|
||||
[[NSCursor arrowCursor] set];
|
||||
|
||||
@@ -20,10 +20,13 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkmacosdisplay-private.h"
|
||||
#include "gdkmacosmonitor.h"
|
||||
#include "gdkmacosmonitor-private.h"
|
||||
#include "gdkmacossurface-private.h"
|
||||
#include "gdkmacostoplevelsurface-private.h"
|
||||
|
||||
#define WARP_OFFSET_X 15
|
||||
#define WARP_OFFSET_Y 15
|
||||
|
||||
static void
|
||||
_gdk_macos_display_position_toplevel_with_parent (GdkMacosDisplay *self,
|
||||
GdkMacosSurface *surface,
|
||||
@@ -33,52 +36,49 @@ _gdk_macos_display_position_toplevel_with_parent (GdkMacosDisplay *self,
|
||||
{
|
||||
GdkRectangle surface_rect;
|
||||
GdkRectangle parent_rect;
|
||||
GdkRectangle workarea;
|
||||
GdkMonitor *monitor;
|
||||
|
||||
g_assert (GDK_IS_MACOS_DISPLAY (self));
|
||||
g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (surface));
|
||||
g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (parent));
|
||||
|
||||
/* If x/y is set, we should place relative to parent */
|
||||
if (GDK_SURFACE (surface)->x != 0 || GDK_SURFACE (surface)->y != 0)
|
||||
{
|
||||
*x = parent->root_x + GDK_SURFACE (surface)->x;
|
||||
*y = parent->root_y + GDK_SURFACE (surface)->y;
|
||||
return;
|
||||
}
|
||||
monitor = _gdk_macos_surface_get_best_monitor (parent);
|
||||
|
||||
/* Try to center on top of the parent but also try to make the whole thing
|
||||
* visible in case that lands us under the topbar/panel/etc.
|
||||
*/
|
||||
surface_rect.x = surface->root_x + surface->shadow_left;
|
||||
surface_rect.y = surface->root_y + surface->shadow_top;
|
||||
parent_rect.x = parent->root_x + parent->shadow_left;
|
||||
parent_rect.y = parent->root_y + parent->shadow_top;
|
||||
parent_rect.width = GDK_SURFACE (parent)->width - parent->shadow_left - parent->shadow_right;
|
||||
parent_rect.height = GDK_SURFACE (parent)->height - parent->shadow_top - parent->shadow_bottom;
|
||||
|
||||
surface_rect.width = GDK_SURFACE (surface)->width - surface->shadow_left - surface->shadow_right;
|
||||
surface_rect.height = GDK_SURFACE (surface)->height - surface->shadow_top - surface->shadow_bottom;
|
||||
|
||||
parent_rect.x = parent->root_x + surface->shadow_left;
|
||||
parent_rect.y = parent->root_y + surface->shadow_top;
|
||||
parent_rect.width = GDK_SURFACE (parent)->width - surface->shadow_left - surface->shadow_right;
|
||||
parent_rect.height = GDK_SURFACE (parent)->height - surface->shadow_top - surface->shadow_bottom;
|
||||
|
||||
/* Try to place centered atop parent */
|
||||
surface_rect.x = parent_rect.x + ((parent_rect.width - surface_rect.width) / 2);
|
||||
surface_rect.y = parent_rect.y + ((parent_rect.height - surface_rect.height) / 2);
|
||||
|
||||
/* Now make sure that we don't overlap the top-bar */
|
||||
monitor = _gdk_macos_surface_get_best_monitor (parent);
|
||||
gdk_macos_monitor_get_workarea (monitor, &workarea);
|
||||
|
||||
if (surface_rect.x < workarea.x)
|
||||
surface_rect.x = workarea.x;
|
||||
|
||||
if (surface_rect.y < workarea.y)
|
||||
surface_rect.y = workarea.y;
|
||||
_gdk_macos_monitor_clamp (GDK_MACOS_MONITOR (monitor), &surface_rect);
|
||||
|
||||
*x = surface_rect.x - surface->shadow_left;
|
||||
*y = surface_rect.y - surface->shadow_top;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
has_surface_at_origin (const GList *surfaces,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
for (const GList *iter = surfaces; iter; iter = iter->next)
|
||||
{
|
||||
GdkMacosSurface *surface = iter->data;
|
||||
|
||||
if (surface->root_x == x && surface->root_y == y)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_macos_display_position_toplevel (GdkMacosDisplay *self,
|
||||
GdkMacosSurface *surface,
|
||||
@@ -87,6 +87,7 @@ _gdk_macos_display_position_toplevel (GdkMacosDisplay *self,
|
||||
{
|
||||
cairo_rectangle_int_t surface_rect;
|
||||
GdkRectangle workarea;
|
||||
const GList *surfaces;
|
||||
GdkMonitor *monitor;
|
||||
CGPoint mouse;
|
||||
|
||||
@@ -103,16 +104,29 @@ _gdk_macos_display_position_toplevel (GdkMacosDisplay *self,
|
||||
surface_rect.x = workarea.x + ((workarea.width - surface_rect.width) / 2);
|
||||
surface_rect.y = workarea.y + ((workarea.height - surface_rect.height) / 2);
|
||||
|
||||
if (surface_rect.x < workarea.x)
|
||||
surface_rect.x = workarea.x;
|
||||
|
||||
if (surface_rect.y < workarea.y)
|
||||
surface_rect.y = workarea.y;
|
||||
|
||||
/* TODO: If there is another window at this same position, perhaps we should move it */
|
||||
_gdk_macos_monitor_clamp (GDK_MACOS_MONITOR (surface->best_monitor), &surface_rect);
|
||||
|
||||
*x = surface_rect.x - surface->shadow_left;
|
||||
*y = surface_rect.y - surface->shadow_top;
|
||||
|
||||
/* Try to see if there are any other surfaces at this origin and if so,
|
||||
* adjust until we get something better.
|
||||
*/
|
||||
surfaces = _gdk_macos_display_get_surfaces (self);
|
||||
while (has_surface_at_origin (surfaces, *x, *y))
|
||||
{
|
||||
*x += WARP_OFFSET_X;
|
||||
*y += WARP_OFFSET_Y;
|
||||
|
||||
/* If we reached the bottom right, just bail and try the workspace origin */
|
||||
if (*x + surface->shadow_left + WARP_OFFSET_X > workarea.x + workarea.width ||
|
||||
*y + surface->shadow_top + WARP_OFFSET_Y > workarea.y + workarea.height)
|
||||
{
|
||||
*x = workarea.x - surface->shadow_left;
|
||||
*y = workarea.y - surface->shadow_top;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*<private>
|
||||
|
||||
+57
-207
@@ -156,51 +156,13 @@ gdk_macos_display_update_bounds (GdkMacosDisplay *self)
|
||||
self->width = self->max_x - self->min_x;
|
||||
self->height = self->max_y - self->min_y;
|
||||
|
||||
GDK_NOTE (MISC,
|
||||
g_message ("Displays reconfigured to bounds %d,%d %dx%d",
|
||||
self->min_x, self->min_y, self->width, self->height));
|
||||
|
||||
GDK_END_MACOS_ALLOC_POOL;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_macos_display_monitors_changed_cb (CFNotificationCenterRef center,
|
||||
void *observer,
|
||||
CFStringRef name,
|
||||
const void *object,
|
||||
CFDictionaryRef userInfo)
|
||||
{
|
||||
GdkMacosDisplay *self = observer;
|
||||
|
||||
g_assert (GDK_IS_MACOS_DISPLAY (self));
|
||||
|
||||
_gdk_macos_display_reload_monitors (self);
|
||||
|
||||
/* Now we need to update all our surface positions since they
|
||||
* probably just changed origins.
|
||||
*/
|
||||
for (const GList *iter = _gdk_macos_display_get_surfaces (self);
|
||||
iter != NULL;
|
||||
iter = iter->next)
|
||||
{
|
||||
GdkMacosSurface *surface = iter->data;
|
||||
|
||||
g_assert (GDK_IS_MACOS_SURFACE (surface));
|
||||
|
||||
_gdk_macos_surface_monitor_changed (surface);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_macos_display_user_defaults_changed_cb (CFNotificationCenterRef center,
|
||||
void *observer,
|
||||
CFStringRef name,
|
||||
const void *object,
|
||||
CFDictionaryRef userInfo)
|
||||
{
|
||||
GdkMacosDisplay *self = observer;
|
||||
|
||||
g_assert (GDK_IS_MACOS_DISPLAY (self));
|
||||
|
||||
_gdk_macos_display_reload_settings (self);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_display_reload_monitors (GdkMacosDisplay *self)
|
||||
{
|
||||
@@ -273,56 +235,6 @@ gdk_macos_display_load_seat (GdkMacosDisplay *self)
|
||||
g_object_unref (seat);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_macos_display_frame_cb (gpointer data)
|
||||
{
|
||||
GdkMacosDisplay *self = data;
|
||||
GdkDisplayLinkSource *source;
|
||||
gint64 presentation_time;
|
||||
gint64 now;
|
||||
GList *iter;
|
||||
|
||||
g_assert (GDK_IS_MACOS_DISPLAY (self));
|
||||
|
||||
source = (GdkDisplayLinkSource *)self->frame_source;
|
||||
|
||||
presentation_time = source->presentation_time;
|
||||
now = g_source_get_time ((GSource *)source);
|
||||
|
||||
iter = self->awaiting_frames.head;
|
||||
|
||||
while (iter != NULL)
|
||||
{
|
||||
GdkMacosSurface *surface = iter->data;
|
||||
|
||||
g_assert (GDK_IS_MACOS_SURFACE (surface));
|
||||
|
||||
iter = iter->next;
|
||||
|
||||
_gdk_macos_surface_publish_timings (surface,
|
||||
source->presentation_time,
|
||||
source->refresh_interval);
|
||||
|
||||
_gdk_macos_display_remove_frame_callback (self, surface);
|
||||
|
||||
if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (surface)))
|
||||
gdk_surface_thaw_updates (GDK_SURFACE (surface));
|
||||
}
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_macos_display_load_display_link (GdkMacosDisplay *self)
|
||||
{
|
||||
self->frame_source = gdk_display_link_source_new ();
|
||||
g_source_set_callback (self->frame_source,
|
||||
gdk_macos_display_frame_cb,
|
||||
self,
|
||||
NULL);
|
||||
g_source_attach (self->frame_source, NULL);
|
||||
}
|
||||
|
||||
static const char *
|
||||
gdk_macos_display_get_name (GdkDisplay *display)
|
||||
{
|
||||
@@ -398,11 +310,15 @@ gdk_macos_display_queue_events (GdkDisplay *display)
|
||||
|
||||
g_return_if_fail (GDK_IS_MACOS_DISPLAY (self));
|
||||
|
||||
if ((nsevent = _gdk_macos_event_source_get_pending ()))
|
||||
while ((nsevent = _gdk_macos_event_source_get_pending ()))
|
||||
{
|
||||
GdkEvent *event = _gdk_macos_display_translate (self, nsevent);
|
||||
|
||||
if (event != NULL)
|
||||
if (event == GDK_MACOS_EVENT_DROP)
|
||||
{
|
||||
[nsevent release];
|
||||
}
|
||||
else if (event != NULL)
|
||||
{
|
||||
push_nsevent (event, nsevent);
|
||||
_gdk_windowing_got_event (GDK_DISPLAY (self),
|
||||
@@ -426,7 +342,6 @@ _gdk_macos_display_surface_added (GdkMacosDisplay *self,
|
||||
g_assert (GDK_IS_MACOS_SURFACE (surface));
|
||||
g_assert (!queue_contains (&self->sorted_surfaces, &surface->sorted));
|
||||
g_assert (!queue_contains (&self->main_surfaces, &surface->main));
|
||||
g_assert (!queue_contains (&self->awaiting_frames, &surface->frame));
|
||||
g_assert (surface->sorted.data == surface);
|
||||
g_assert (surface->main.data == surface);
|
||||
g_assert (surface->frame.data == surface);
|
||||
@@ -453,9 +368,6 @@ _gdk_macos_display_surface_removed (GdkMacosDisplay *self,
|
||||
if (queue_contains (&self->main_surfaces, &surface->main))
|
||||
_gdk_macos_display_surface_resigned_main (self, surface);
|
||||
|
||||
if (queue_contains (&self->awaiting_frames, &surface->frame))
|
||||
g_queue_unlink (&self->awaiting_frames, &surface->frame);
|
||||
|
||||
g_return_if_fail (self->keyboard_surface != surface);
|
||||
}
|
||||
|
||||
@@ -501,6 +413,39 @@ _gdk_macos_display_surface_became_key (GdkMacosDisplay *self,
|
||||
gdk_surface_request_motion (GDK_SURFACE (surface));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
select_key_in_idle_cb (gpointer data)
|
||||
{
|
||||
GdkMacosDisplay *self = data;
|
||||
|
||||
g_assert (GDK_IS_MACOS_DISPLAY (self));
|
||||
|
||||
self->select_key_in_idle = 0;
|
||||
|
||||
/* Don't steal focus from NSPanel, etc */
|
||||
if (self->key_window_is_foregin)
|
||||
return G_SOURCE_REMOVE;
|
||||
|
||||
if (self->keyboard_surface == NULL)
|
||||
{
|
||||
const GList *surfaces = _gdk_macos_display_get_surfaces (self);
|
||||
|
||||
for (const GList *iter = surfaces; iter; iter = iter->next)
|
||||
{
|
||||
GdkMacosSurface *surface = iter->data;
|
||||
|
||||
if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (surface)) &&
|
||||
([surface->window styleMask] & NSWindowStyleMaskMiniaturizable) == 0)
|
||||
{
|
||||
[surface->window showAndMakeKey:YES];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_display_surface_resigned_key (GdkMacosDisplay *self,
|
||||
GdkMacosSurface *surface)
|
||||
@@ -545,6 +490,9 @@ _gdk_macos_display_surface_resigned_key (GdkMacosDisplay *self,
|
||||
}
|
||||
|
||||
_gdk_macos_display_clear_sorting (self);
|
||||
|
||||
if (self->select_key_in_idle == 0)
|
||||
self->select_key_in_idle = g_idle_add (select_key_in_idle_cb, self);
|
||||
}
|
||||
|
||||
/* Raises a transient window.
|
||||
@@ -583,8 +531,6 @@ void
|
||||
_gdk_macos_display_surface_resigned_main (GdkMacosDisplay *self,
|
||||
GdkMacosSurface *surface)
|
||||
{
|
||||
GdkMacosSurface *new_surface = NULL;
|
||||
|
||||
g_return_if_fail (GDK_IS_MACOS_DISPLAY (self));
|
||||
g_return_if_fail (GDK_IS_MACOS_SURFACE (surface));
|
||||
|
||||
@@ -592,40 +538,6 @@ _gdk_macos_display_surface_resigned_main (GdkMacosDisplay *self,
|
||||
g_queue_unlink (&self->main_surfaces, &surface->main);
|
||||
|
||||
_gdk_macos_display_clear_sorting (self);
|
||||
|
||||
if (GDK_SURFACE (surface)->transient_for &&
|
||||
gdk_surface_get_mapped (GDK_SURFACE (surface)->transient_for))
|
||||
{
|
||||
new_surface = GDK_MACOS_SURFACE (GDK_SURFACE (surface)->transient_for);
|
||||
}
|
||||
else
|
||||
{
|
||||
const GList *surfaces = _gdk_macos_display_get_surfaces (self);
|
||||
|
||||
for (const GList *iter = surfaces; iter; iter = iter->next)
|
||||
{
|
||||
GdkMacosSurface *item = iter->data;
|
||||
|
||||
g_assert (GDK_IS_MACOS_SURFACE (item));
|
||||
|
||||
if (item == surface)
|
||||
continue;
|
||||
|
||||
if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (item)))
|
||||
{
|
||||
new_surface = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (new_surface != NULL)
|
||||
{
|
||||
NSWindow *nswindow = _gdk_macos_surface_get_native (new_surface);
|
||||
[nswindow makeKeyAndOrderFront:nswindow];
|
||||
}
|
||||
|
||||
_gdk_macos_display_clear_sorting (self);
|
||||
}
|
||||
|
||||
static GdkSurface *
|
||||
@@ -686,20 +598,12 @@ gdk_macos_display_finalize (GObject *object)
|
||||
{
|
||||
GdkMacosDisplay *self = (GdkMacosDisplay *)object;
|
||||
|
||||
CFNotificationCenterRemoveObserver (CFNotificationCenterGetDistributedCenter (),
|
||||
self,
|
||||
CFSTR ("NSApplicationDidChangeScreenParametersNotification"),
|
||||
NULL);
|
||||
|
||||
CFNotificationCenterRemoveObserver (CFNotificationCenterGetDistributedCenter (),
|
||||
self,
|
||||
CFSTR ("NSUserDefaultsDidChangeNotification"),
|
||||
NULL);
|
||||
_gdk_macos_display_feedback_destroy (self);
|
||||
|
||||
g_clear_handle_id (&self->select_key_in_idle, g_source_remove);
|
||||
g_clear_pointer (&self->active_drags, g_hash_table_unref);
|
||||
g_clear_pointer (&self->active_drops, g_hash_table_unref);
|
||||
g_clear_object (&GDK_DISPLAY (self)->clipboard);
|
||||
g_clear_pointer (&self->frame_source, g_source_unref);
|
||||
g_clear_object (&self->monitors);
|
||||
g_clear_pointer (&self->name, g_free);
|
||||
|
||||
@@ -774,24 +678,10 @@ _gdk_macos_display_open (const char *display_name)
|
||||
|
||||
gdk_macos_display_load_seat (self);
|
||||
gdk_macos_display_load_clipboard (self);
|
||||
|
||||
/* Load CVDisplayLink before monitors to access refresh rates */
|
||||
gdk_macos_display_load_display_link (self);
|
||||
_gdk_macos_display_reload_monitors (self);
|
||||
|
||||
CFNotificationCenterAddObserver (CFNotificationCenterGetLocalCenter (),
|
||||
self,
|
||||
gdk_macos_display_monitors_changed_cb,
|
||||
CFSTR ("NSApplicationDidChangeScreenParametersNotification"),
|
||||
NULL,
|
||||
CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
|
||||
CFNotificationCenterAddObserver (CFNotificationCenterGetDistributedCenter (),
|
||||
self,
|
||||
gdk_macos_display_user_defaults_changed_cb,
|
||||
CFSTR ("NSUserDefaultsDidChangeNotification"),
|
||||
NULL,
|
||||
CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
/* Initialize feedback from display server */
|
||||
_gdk_macos_display_feedback_init (self);
|
||||
|
||||
if (event_source == NULL)
|
||||
{
|
||||
@@ -803,6 +693,8 @@ _gdk_macos_display_open (const char *display_name)
|
||||
|
||||
gdk_display_emit_opened (GDK_DISPLAY (self));
|
||||
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
|
||||
return GDK_DISPLAY (self);
|
||||
}
|
||||
|
||||
@@ -1033,42 +925,6 @@ _gdk_macos_display_get_surface_at_display_coords (GdkMacosDisplay *self,
|
||||
return _gdk_macos_display_get_surface_at_coords (self, x_gdk, y_gdk, surface_x, surface_y);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_display_add_frame_callback (GdkMacosDisplay *self,
|
||||
GdkMacosSurface *surface)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_MACOS_DISPLAY (self));
|
||||
g_return_if_fail (GDK_IS_MACOS_SURFACE (surface));
|
||||
|
||||
if (!queue_contains (&self->awaiting_frames, &surface->frame))
|
||||
{
|
||||
/* Processing frames is always head to tail, so push to the
|
||||
* head so that we don't possibly re-enter this right after
|
||||
* adding to the queue.
|
||||
*/
|
||||
g_queue_push_head_link (&self->awaiting_frames, &surface->frame);
|
||||
|
||||
if (self->awaiting_frames.length == 1)
|
||||
gdk_display_link_source_unpause ((GdkDisplayLinkSource *)self->frame_source);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_display_remove_frame_callback (GdkMacosDisplay *self,
|
||||
GdkMacosSurface *surface)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_MACOS_DISPLAY (self));
|
||||
g_return_if_fail (GDK_IS_MACOS_SURFACE (surface));
|
||||
|
||||
if (queue_contains (&self->awaiting_frames, &surface->frame))
|
||||
{
|
||||
g_queue_unlink (&self->awaiting_frames, &surface->frame);
|
||||
|
||||
if (self->awaiting_frames.length == 0)
|
||||
gdk_display_link_source_pause ((GdkDisplayLinkSource *)self->frame_source);
|
||||
}
|
||||
}
|
||||
|
||||
NSWindow *
|
||||
_gdk_macos_display_find_native_under_pointer (GdkMacosDisplay *self,
|
||||
int *x,
|
||||
@@ -1088,17 +944,6 @@ _gdk_macos_display_find_native_under_pointer (GdkMacosDisplay *self,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
_gdk_macos_display_get_nominal_refresh_rate (GdkMacosDisplay *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_MACOS_DISPLAY (self), 60 * 1000);
|
||||
|
||||
if (self->frame_source == NULL)
|
||||
return 60 * 1000;
|
||||
|
||||
return ((GdkDisplayLinkSource *)self->frame_source)->refresh_rate;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_display_clear_sorting (GdkMacosDisplay *self)
|
||||
{
|
||||
@@ -1120,11 +965,16 @@ _gdk_macos_display_get_surfaces (GdkMacosDisplay *self)
|
||||
NSArray *array = [NSApp orderedWindows];
|
||||
GQueue sorted = G_QUEUE_INIT;
|
||||
|
||||
self->key_window_is_foregin = FALSE;
|
||||
|
||||
for (id obj in array)
|
||||
{
|
||||
NSWindow *nswindow = (NSWindow *)obj;
|
||||
GdkMacosSurface *surface;
|
||||
|
||||
if ([nswindow isKeyWindow])
|
||||
self->key_window_is_foregin = !GDK_IS_MACOS_WINDOW (nswindow);
|
||||
|
||||
if (!GDK_IS_MACOS_WINDOW (nswindow))
|
||||
continue;
|
||||
|
||||
|
||||
@@ -38,8 +38,6 @@ struct _GdkMacosGLContext
|
||||
{
|
||||
GdkGLContext parent_instance;
|
||||
|
||||
cairo_region_t *damage;
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
CGLContextObj cgl_context;
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
@@ -469,6 +469,7 @@ gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
|
||||
buffer = _gdk_macos_surface_get_buffer (GDK_MACOS_SURFACE (surface));
|
||||
|
||||
_gdk_macos_buffer_set_flipped (buffer, TRUE);
|
||||
_gdk_macos_buffer_set_damage (buffer, region);
|
||||
|
||||
/* Create our render target and bind it */
|
||||
gdk_gl_context_make_current (GDK_GL_CONTEXT (self));
|
||||
@@ -476,9 +477,6 @@ gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
|
||||
|
||||
GDK_DRAW_CONTEXT_CLASS (gdk_macos_gl_context_parent_class)->begin_frame (context, prefers_high_depth, region);
|
||||
|
||||
g_clear_pointer (&self->damage, cairo_region_destroy);
|
||||
self->damage = g_steal_pointer (©);
|
||||
|
||||
gdk_gl_context_make_current (GDK_GL_CONTEXT (self));
|
||||
CHECK_GL (NULL, glBindFramebuffer (GL_FRAMEBUFFER, self->fbo));
|
||||
}
|
||||
@@ -531,8 +529,6 @@ gdk_macos_gl_context_surface_resized (GdkDrawContext *draw_context)
|
||||
|
||||
g_assert (GDK_IS_MACOS_GL_CONTEXT (self));
|
||||
|
||||
g_clear_pointer (&self->damage, cairo_region_destroy);
|
||||
|
||||
if (self->cgl_context != NULL)
|
||||
CGLUpdateContext (self->cgl_context);
|
||||
}
|
||||
@@ -587,9 +583,16 @@ static cairo_region_t *
|
||||
gdk_macos_gl_context_get_damage (GdkGLContext *context)
|
||||
{
|
||||
GdkMacosGLContext *self = (GdkMacosGLContext *)context;
|
||||
const cairo_region_t *damage;
|
||||
GdkMacosBuffer *buffer;
|
||||
GdkSurface *surface;
|
||||
|
||||
if (self->damage)
|
||||
return cairo_region_copy (self->damage);
|
||||
g_assert (GDK_IS_MACOS_GL_CONTEXT (self));
|
||||
|
||||
if ((surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context))) &&
|
||||
(buffer = GDK_MACOS_SURFACE (surface)->front) &&
|
||||
(damage = _gdk_macos_buffer_get_damage (buffer)))
|
||||
return cairo_region_copy (damage);
|
||||
|
||||
return GDK_GL_CONTEXT_CLASS (gdk_macos_gl_context_parent_class)->get_damage (context);
|
||||
}
|
||||
@@ -619,8 +622,6 @@ gdk_macos_gl_context_dispose (GObject *gobject)
|
||||
CGLDestroyContext (cgl_context);
|
||||
}
|
||||
|
||||
g_clear_pointer (&self->damage, cairo_region_destroy);
|
||||
|
||||
G_OBJECT_CLASS (gdk_macos_gl_context_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,16 +24,25 @@
|
||||
|
||||
#include "gdkmacosdisplay.h"
|
||||
#include "gdkmacosmonitor.h"
|
||||
#include "gdkmacossurface.h"
|
||||
|
||||
#include "gdkmonitorprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GdkMacosMonitor *_gdk_macos_monitor_new (GdkMacosDisplay *display,
|
||||
CGDirectDisplayID screen_id);
|
||||
CGDirectDisplayID _gdk_macos_monitor_get_screen_id (GdkMacosMonitor *self);
|
||||
gboolean _gdk_macos_monitor_reconfigure (GdkMacosMonitor *self);
|
||||
CGColorSpaceRef _gdk_macos_monitor_copy_colorspace (GdkMacosMonitor *self);
|
||||
char *_gdk_macos_monitor_get_localized_name (NSScreen *screen);
|
||||
char *_gdk_macos_monitor_get_connector_name (CGDirectDisplayID screen_id);
|
||||
GdkMacosMonitor *_gdk_macos_monitor_new (GdkMacosDisplay *display,
|
||||
CGDirectDisplayID screen_id);
|
||||
CGDirectDisplayID _gdk_macos_monitor_get_screen_id (GdkMacosMonitor *self);
|
||||
gboolean _gdk_macos_monitor_reconfigure (GdkMacosMonitor *self);
|
||||
CGColorSpaceRef _gdk_macos_monitor_copy_colorspace (GdkMacosMonitor *self);
|
||||
void _gdk_macos_monitor_add_frame_callback (GdkMacosMonitor *self,
|
||||
GdkMacosSurface *surface);
|
||||
void _gdk_macos_monitor_remove_frame_callback (GdkMacosMonitor *self,
|
||||
GdkMacosSurface *surface);
|
||||
void _gdk_macos_monitor_clamp (GdkMacosMonitor *self,
|
||||
GdkRectangle *area);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+166
-11
@@ -22,16 +22,21 @@
|
||||
#include <gdk/gdk.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "gdkdisplaylinksource.h"
|
||||
#include "gdkmacosdisplay-private.h"
|
||||
#include "gdkmacosmonitor-private.h"
|
||||
#include "gdkmacossurface-private.h"
|
||||
#include "gdkmacosutils-private.h"
|
||||
|
||||
struct _GdkMacosMonitor
|
||||
{
|
||||
GdkMonitor parent_instance;
|
||||
CGDirectDisplayID screen_id;
|
||||
NSRect workarea;
|
||||
guint has_opengl : 1;
|
||||
GdkMonitor parent_instance;
|
||||
CGDirectDisplayID screen_id;
|
||||
GdkDisplayLinkSource *display_link;
|
||||
NSRect workarea;
|
||||
GQueue awaiting_frames;
|
||||
guint has_opengl : 1;
|
||||
guint in_frame : 1;
|
||||
};
|
||||
|
||||
struct _GdkMacosMonitorClass
|
||||
@@ -75,9 +80,26 @@ gdk_macos_monitor_get_workarea (GdkMonitor *monitor,
|
||||
geometry->height = self->workarea.size.height;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_macos_monitor_dispose (GObject *object)
|
||||
{
|
||||
GdkMacosMonitor *self = (GdkMacosMonitor *)object;
|
||||
|
||||
if (self->display_link)
|
||||
{
|
||||
g_source_destroy ((GSource *)self->display_link);
|
||||
g_clear_pointer ((GSource **)&self->display_link, g_source_unref);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gdk_macos_monitor_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_macos_monitor_class_init (GdkMacosMonitorClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = gdk_macos_monitor_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -138,8 +160,8 @@ GetSubpixelLayout (CGDirectDisplayID screen_id)
|
||||
return GDK_SUBPIXEL_LAYOUT_UNKNOWN;
|
||||
}
|
||||
|
||||
static char *
|
||||
GetLocalizedName (NSScreen *screen)
|
||||
char *
|
||||
_gdk_macos_monitor_get_localized_name (NSScreen *screen)
|
||||
{
|
||||
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER
|
||||
GDK_BEGIN_MACOS_ALLOC_POOL;
|
||||
@@ -160,8 +182,8 @@ GetLocalizedName (NSScreen *screen)
|
||||
#endif
|
||||
}
|
||||
|
||||
static char *
|
||||
GetConnectorName (CGDirectDisplayID screen_id)
|
||||
char *
|
||||
_gdk_macos_monitor_get_connector_name (CGDirectDisplayID screen_id)
|
||||
{
|
||||
guint unit = CGDisplayUnitNumber (screen_id);
|
||||
return g_strdup_printf ("unit-%u", unit);
|
||||
@@ -188,6 +210,68 @@ find_screen (CGDirectDisplayID screen_id)
|
||||
return screen;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_macos_monitor_display_link_cb (GdkMacosMonitor *self)
|
||||
{
|
||||
gint64 presentation_time;
|
||||
gint64 refresh_interval;
|
||||
gint64 now;
|
||||
GList *iter;
|
||||
|
||||
g_assert (GDK_IS_MACOS_MONITOR (self));
|
||||
g_assert (!self->display_link->paused);
|
||||
|
||||
self->in_frame = TRUE;
|
||||
|
||||
presentation_time = self->display_link->presentation_time;
|
||||
refresh_interval = self->display_link->refresh_interval;
|
||||
now = g_source_get_time ((GSource *)self->display_link);
|
||||
|
||||
iter = self->awaiting_frames.head;
|
||||
|
||||
while (iter != NULL)
|
||||
{
|
||||
GdkMacosSurface *surface = iter->data;
|
||||
|
||||
g_assert (GDK_IS_MACOS_SURFACE (surface));
|
||||
|
||||
iter = iter->next;
|
||||
|
||||
g_queue_unlink (&self->awaiting_frames, &surface->frame);
|
||||
_gdk_macos_surface_frame_presented (surface, presentation_time, refresh_interval);
|
||||
}
|
||||
|
||||
if (self->awaiting_frames.length == 0 && !self->display_link->paused)
|
||||
gdk_display_link_source_pause (self->display_link);
|
||||
|
||||
self->in_frame = FALSE;
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_macos_monitor_reset_display_link (GdkMacosMonitor *self,
|
||||
CGDisplayModeRef mode)
|
||||
{
|
||||
GSource *source;
|
||||
|
||||
g_assert (GDK_IS_MACOS_MONITOR (self));
|
||||
|
||||
if (self->display_link)
|
||||
{
|
||||
g_source_destroy ((GSource *)self->display_link);
|
||||
g_clear_pointer ((GSource **)&self->display_link, g_source_unref);
|
||||
}
|
||||
|
||||
source = gdk_display_link_source_new (self->screen_id, mode);
|
||||
self->display_link = (GdkDisplayLinkSource *)source;
|
||||
g_source_set_callback (source,
|
||||
(GSourceFunc) gdk_macos_monitor_display_link_cb,
|
||||
self,
|
||||
NULL);
|
||||
g_source_attach (source, NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gdk_macos_monitor_reconfigure (GdkMacosMonitor *self)
|
||||
{
|
||||
@@ -222,8 +306,8 @@ _gdk_macos_monitor_reconfigure (GdkMacosMonitor *self)
|
||||
pixel_width = CGDisplayModeGetPixelWidth (mode);
|
||||
has_opengl = CGDisplayUsesOpenGLAcceleration (self->screen_id);
|
||||
subpixel_layout = GetSubpixelLayout (self->screen_id);
|
||||
name = GetLocalizedName (screen);
|
||||
connector = GetConnectorName (self->screen_id);
|
||||
name = _gdk_macos_monitor_get_localized_name (screen);
|
||||
connector = _gdk_macos_monitor_get_connector_name (self->screen_id);
|
||||
|
||||
if (width != 0 && pixel_width != 0)
|
||||
scale_factor = MAX (1, pixel_width / width);
|
||||
@@ -241,7 +325,7 @@ _gdk_macos_monitor_reconfigure (GdkMacosMonitor *self)
|
||||
* setting (which is also used by the frame clock).
|
||||
*/
|
||||
if (!(refresh_rate = CGDisplayModeGetRefreshRate (mode)))
|
||||
refresh_rate = _gdk_macos_display_get_nominal_refresh_rate (display);
|
||||
refresh_rate = 60 * 1000;
|
||||
|
||||
gdk_monitor_set_connector (GDK_MONITOR (self), connector);
|
||||
gdk_monitor_set_model (GDK_MONITOR (self), name);
|
||||
@@ -261,6 +345,9 @@ _gdk_macos_monitor_reconfigure (GdkMacosMonitor *self)
|
||||
*/
|
||||
self->has_opengl = !!has_opengl;
|
||||
|
||||
/* Create a new display link to receive feedback about when to render */
|
||||
_gdk_macos_monitor_reset_display_link (self, mode);
|
||||
|
||||
CGDisplayModeRelease (mode);
|
||||
g_free (name);
|
||||
g_free (connector);
|
||||
@@ -302,3 +389,71 @@ _gdk_macos_monitor_copy_colorspace (GdkMacosMonitor *self)
|
||||
|
||||
return CGDisplayCopyColorSpace (self->screen_id);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_monitor_add_frame_callback (GdkMacosMonitor *self,
|
||||
GdkMacosSurface *surface)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_MACOS_MONITOR (self));
|
||||
g_return_if_fail (GDK_IS_MACOS_SURFACE (surface));
|
||||
g_return_if_fail (surface->frame.data == (gpointer)surface);
|
||||
g_return_if_fail (surface->frame.prev == NULL);
|
||||
g_return_if_fail (surface->frame.next == NULL);
|
||||
g_return_if_fail (self->awaiting_frames.head != &surface->frame);
|
||||
g_return_if_fail (self->awaiting_frames.tail != &surface->frame);
|
||||
|
||||
/* Processing frames is always head to tail, so push to the
|
||||
* head so that we don't possibly re-enter this right after
|
||||
* adding to the queue.
|
||||
*/
|
||||
if (!queue_contains (&self->awaiting_frames, &surface->frame))
|
||||
{
|
||||
g_queue_push_head_link (&self->awaiting_frames, &surface->frame);
|
||||
|
||||
if (!self->in_frame && self->awaiting_frames.length == 1)
|
||||
gdk_display_link_source_unpause (self->display_link);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_monitor_remove_frame_callback (GdkMacosMonitor *self,
|
||||
GdkMacosSurface *surface)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_MACOS_MONITOR (self));
|
||||
g_return_if_fail (GDK_IS_MACOS_SURFACE (surface));
|
||||
g_return_if_fail (surface->frame.data == (gpointer)surface);
|
||||
|
||||
if (queue_contains (&self->awaiting_frames, &surface->frame))
|
||||
{
|
||||
g_queue_unlink (&self->awaiting_frames, &surface->frame);
|
||||
|
||||
if (!self->in_frame && self->awaiting_frames.length == 0)
|
||||
gdk_display_link_source_pause (self->display_link);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_monitor_clamp (GdkMacosMonitor *self,
|
||||
GdkRectangle *area)
|
||||
{
|
||||
GdkRectangle workarea;
|
||||
GdkRectangle geom;
|
||||
|
||||
g_return_if_fail (GDK_IS_MACOS_MONITOR (self));
|
||||
g_return_if_fail (area != NULL);
|
||||
|
||||
gdk_macos_monitor_get_workarea (GDK_MONITOR (self), &workarea);
|
||||
gdk_monitor_get_geometry (GDK_MONITOR (self), &geom);
|
||||
|
||||
if (area->x + area->width > workarea.x + workarea.width)
|
||||
area->x = workarea.x + workarea.width - area->width;
|
||||
|
||||
if (area->x < workarea.x)
|
||||
area->x = workarea.x;
|
||||
|
||||
if (area->y + area->height > workarea.y + workarea.height)
|
||||
area->y = workarea.y + workarea.height - area->height;
|
||||
|
||||
if (area->y < workarea.y)
|
||||
area->y = workarea.y;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ struct _GdkMacosPopupSurface
|
||||
{
|
||||
GdkMacosSurface parent_instance;
|
||||
GdkPopupLayout *layout;
|
||||
guint attached : 1;
|
||||
};
|
||||
|
||||
struct _GdkMacosPopupSurfaceClass
|
||||
@@ -87,6 +88,9 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self,
|
||||
|
||||
gdk_surface_get_origin (GDK_SURFACE (self)->parent, &x, &y);
|
||||
|
||||
GDK_SURFACE (self)->x = final_rect.x;
|
||||
GDK_SURFACE (self)->y = final_rect.y;
|
||||
|
||||
x += final_rect.x;
|
||||
y += final_rect.y;
|
||||
|
||||
@@ -135,6 +139,9 @@ gdk_macos_popup_surface_present (GdkPopup *popup,
|
||||
if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self)))
|
||||
return TRUE;
|
||||
|
||||
if (!self->attached && GDK_SURFACE (self)->parent != NULL)
|
||||
_gdk_macos_popup_surface_attach_to_parent (self);
|
||||
|
||||
if (GDK_SURFACE (self)->autohide)
|
||||
{
|
||||
GdkDisplay *display = gdk_surface_get_display (GDK_SURFACE (popup));
|
||||
@@ -200,6 +207,19 @@ enum {
|
||||
LAST_PROP,
|
||||
};
|
||||
|
||||
static void
|
||||
_gdk_macos_popup_surface_hide (GdkSurface *surface)
|
||||
{
|
||||
GdkMacosPopupSurface *self = (GdkMacosPopupSurface *)surface;
|
||||
|
||||
g_assert (GDK_IS_MACOS_POPUP_SURFACE (self));
|
||||
|
||||
if (self->attached)
|
||||
_gdk_macos_popup_surface_detach_from_parent (self);
|
||||
|
||||
GDK_SURFACE_CLASS (_gdk_macos_popup_surface_parent_class)->hide (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_macos_popup_surface_finalize (GObject *object)
|
||||
{
|
||||
@@ -267,12 +287,15 @@ static void
|
||||
_gdk_macos_popup_surface_class_init (GdkMacosPopupSurfaceClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GdkSurfaceClass *surface_class = GDK_SURFACE_CLASS (klass);
|
||||
|
||||
object_class->finalize = _gdk_macos_popup_surface_finalize;
|
||||
object_class->get_property = _gdk_macos_popup_surface_get_property;
|
||||
object_class->set_property = _gdk_macos_popup_surface_set_property;
|
||||
|
||||
gdk_popup_install_properties (object_class, 1);
|
||||
surface_class->hide = _gdk_macos_popup_surface_hide;
|
||||
|
||||
gdk_popup_install_properties (object_class, LAST_PROP);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -323,14 +346,8 @@ _gdk_macos_popup_surface_new (GdkMacosDisplay *display,
|
||||
[window setOpaque:NO];
|
||||
[window setBackgroundColor:[NSColor clearColor]];
|
||||
[window setDecorated:NO];
|
||||
|
||||
#if 0
|
||||
/* NOTE: We could set these to be popup level, but then
|
||||
* [NSApp orderedWindows] would not give us the windows
|
||||
* back with the stacking order applied.
|
||||
*/
|
||||
[window setExcludedFromWindowsMenu:YES];
|
||||
[window setLevel:NSPopUpMenuWindowLevel];
|
||||
#endif
|
||||
|
||||
self = g_object_new (GDK_TYPE_MACOS_POPUP_SURFACE,
|
||||
"display", display,
|
||||
@@ -361,6 +378,8 @@ _gdk_macos_popup_surface_attach_to_parent (GdkMacosPopupSurface *self)
|
||||
|
||||
[parent addChildWindow:window ordered:NSWindowAbove];
|
||||
|
||||
self->attached = TRUE;
|
||||
|
||||
_gdk_macos_display_clear_sorting (GDK_MACOS_DISPLAY (surface->display));
|
||||
}
|
||||
}
|
||||
@@ -382,6 +401,8 @@ _gdk_macos_popup_surface_detach_from_parent (GdkMacosPopupSurface *self)
|
||||
|
||||
[parent removeChildWindow:window];
|
||||
|
||||
self->attached = FALSE;
|
||||
|
||||
_gdk_macos_display_clear_sorting (GDK_MACOS_DISPLAY (surface->display));
|
||||
}
|
||||
}
|
||||
@@ -391,9 +412,7 @@ _gdk_macos_popup_surface_reposition (GdkMacosPopupSurface *self)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_MACOS_POPUP_SURFACE (self));
|
||||
|
||||
if (self->layout == NULL ||
|
||||
!gdk_surface_get_mapped (GDK_SURFACE (self)) ||
|
||||
GDK_SURFACE (self)->parent == NULL)
|
||||
if (self->layout == NULL || GDK_SURFACE (self)->parent == NULL)
|
||||
return;
|
||||
|
||||
gdk_macos_popup_surface_layout (self,
|
||||
|
||||
@@ -49,7 +49,7 @@ struct _GdkMacosSurface
|
||||
GdkMacosBuffer *buffer;
|
||||
GdkMacosBuffer *front;
|
||||
GPtrArray *monitors;
|
||||
cairo_region_t *opaque_region;
|
||||
GdkMonitor *best_monitor;
|
||||
char *title;
|
||||
|
||||
int root_x;
|
||||
@@ -75,6 +75,9 @@ struct _GdkMacosSurface
|
||||
guint geometry_dirty : 1;
|
||||
guint next_frame_set : 1;
|
||||
guint show_on_next_swap : 1;
|
||||
guint in_change_monitor : 1;
|
||||
guint in_frame : 1;
|
||||
guint awaiting_frame : 1;
|
||||
};
|
||||
|
||||
struct _GdkMacosSurfaceClass
|
||||
@@ -116,11 +119,11 @@ void _gdk_macos_surface_resize (GdkMacosSurface
|
||||
int width,
|
||||
int height);
|
||||
void _gdk_macos_surface_update_fullscreen_state (GdkMacosSurface *self);
|
||||
void _gdk_macos_surface_update_position (GdkMacosSurface *self);
|
||||
void _gdk_macos_surface_show (GdkMacosSurface *self);
|
||||
void _gdk_macos_surface_publish_timings (GdkMacosSurface *self,
|
||||
void _gdk_macos_surface_request_frame (GdkMacosSurface *self);
|
||||
void _gdk_macos_surface_frame_presented (GdkMacosSurface *self,
|
||||
gint64 predicted_presentation_time,
|
||||
gint64 refresh_interval);
|
||||
void _gdk_macos_surface_show (GdkMacosSurface *self);
|
||||
void _gdk_macos_surface_synthesize_null_key (GdkMacosSurface *self);
|
||||
void _gdk_macos_surface_move (GdkMacosSurface *self,
|
||||
int x,
|
||||
|
||||
+250
-123
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "gdkmacossurface-private.h"
|
||||
|
||||
#include "gdkdebug.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkdisplay.h"
|
||||
#include "gdkeventsprivate.h"
|
||||
@@ -63,16 +64,87 @@ window_is_fullscreen (GdkMacosSurface *self)
|
||||
return ([self->window styleMask] & NSWindowStyleMaskFullScreen) != 0;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_surface_request_frame (GdkMacosSurface *self)
|
||||
{
|
||||
g_assert (GDK_IS_MACOS_SURFACE (self));
|
||||
|
||||
if (self->awaiting_frame)
|
||||
return;
|
||||
|
||||
if (self->best_monitor != NULL)
|
||||
{
|
||||
self->awaiting_frame = TRUE;
|
||||
_gdk_macos_monitor_add_frame_callback (GDK_MACOS_MONITOR (self->best_monitor), self);
|
||||
gdk_surface_freeze_updates (GDK_SURFACE (self));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_macos_surface_cancel_frame (GdkMacosSurface *self)
|
||||
{
|
||||
g_assert (GDK_IS_MACOS_SURFACE (self));
|
||||
|
||||
if (!self->awaiting_frame)
|
||||
return;
|
||||
|
||||
if (self->best_monitor != NULL)
|
||||
{
|
||||
self->awaiting_frame = FALSE;
|
||||
_gdk_macos_monitor_remove_frame_callback (GDK_MACOS_MONITOR (self->best_monitor), self);
|
||||
gdk_surface_thaw_updates (GDK_SURFACE (self));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_surface_frame_presented (GdkMacosSurface *self,
|
||||
gint64 presentation_time,
|
||||
gint64 refresh_interval)
|
||||
{
|
||||
GdkFrameTimings *timings;
|
||||
GdkFrameClock *frame_clock;
|
||||
|
||||
g_return_if_fail (GDK_IS_MACOS_SURFACE (self));
|
||||
|
||||
self->awaiting_frame = FALSE;
|
||||
|
||||
if (GDK_SURFACE_DESTROYED (self))
|
||||
return;
|
||||
|
||||
frame_clock = gdk_surface_get_frame_clock (GDK_SURFACE (self));
|
||||
|
||||
if (self->pending_frame_counter)
|
||||
{
|
||||
timings = gdk_frame_clock_get_timings (frame_clock, self->pending_frame_counter);
|
||||
|
||||
if (timings != NULL)
|
||||
{
|
||||
timings->presentation_time = presentation_time - refresh_interval;
|
||||
timings->complete = TRUE;
|
||||
}
|
||||
|
||||
self->pending_frame_counter = 0;
|
||||
}
|
||||
|
||||
timings = gdk_frame_clock_get_current_timings (frame_clock);
|
||||
|
||||
if (timings != NULL)
|
||||
{
|
||||
timings->refresh_interval = refresh_interval;
|
||||
timings->predicted_presentation_time = presentation_time;
|
||||
}
|
||||
|
||||
if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self)))
|
||||
gdk_surface_thaw_updates (GDK_SURFACE (self));
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_surface_reposition_children (GdkMacosSurface *self)
|
||||
{
|
||||
g_assert (GDK_IS_MACOS_SURFACE (self));
|
||||
|
||||
if (GDK_SURFACE_DESTROYED (self))
|
||||
return;
|
||||
|
||||
if (!gdk_surface_get_mapped (GDK_SURFACE (self)))
|
||||
if (GDK_SURFACE_DESTROYED (self))
|
||||
return;
|
||||
|
||||
for (const GList *iter = GDK_SURFACE (self)->children;
|
||||
@@ -86,9 +158,6 @@ _gdk_macos_surface_reposition_children (GdkMacosSurface *self)
|
||||
if (GDK_IS_MACOS_POPUP_SURFACE (child))
|
||||
_gdk_macos_popup_surface_reposition (GDK_MACOS_POPUP_SURFACE (child));
|
||||
}
|
||||
|
||||
if (GDK_IS_POPUP (self) && self->did_initial_present)
|
||||
gdk_surface_request_layout (GDK_SURFACE (self));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -117,12 +186,6 @@ gdk_macos_surface_set_opaque_region (GdkSurface *surface,
|
||||
|
||||
g_assert (GDK_IS_MACOS_SURFACE (self));
|
||||
|
||||
if (region != self->opaque_region)
|
||||
{
|
||||
g_clear_pointer (&self->opaque_region, cairo_region_destroy);
|
||||
self->opaque_region = cairo_region_copy (region);
|
||||
}
|
||||
|
||||
if ((nsview = _gdk_macos_surface_get_view (GDK_MACOS_SURFACE (surface))))
|
||||
[(GdkMacosView *)nsview setOpaqueRegion:region];
|
||||
}
|
||||
@@ -139,9 +202,9 @@ gdk_macos_surface_hide (GdkSurface *surface)
|
||||
|
||||
self->show_on_next_swap = FALSE;
|
||||
|
||||
_gdk_macos_display_remove_frame_callback (GDK_MACOS_DISPLAY (surface->display), self);
|
||||
_gdk_macos_surface_cancel_frame (self);
|
||||
|
||||
was_mapped = GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self));
|
||||
was_mapped = GDK_SURFACE_IS_MAPPED (surface);
|
||||
was_key = [self->window isKeyWindow];
|
||||
|
||||
seat = gdk_display_get_default_seat (surface->display);
|
||||
@@ -156,17 +219,21 @@ gdk_macos_surface_hide (GdkSurface *surface)
|
||||
|
||||
if (was_key)
|
||||
{
|
||||
GdkSurface *parent;
|
||||
|
||||
if (GDK_IS_TOPLEVEL (surface))
|
||||
parent = surface->transient_for;
|
||||
else
|
||||
parent = surface->parent;
|
||||
|
||||
/* Return key input to the parent window if necessary */
|
||||
if (surface->parent != NULL && GDK_SURFACE_IS_MAPPED (surface->parent))
|
||||
if (parent != NULL && GDK_SURFACE_IS_MAPPED (parent))
|
||||
{
|
||||
GdkMacosWindow *parentWindow = GDK_MACOS_SURFACE (surface->parent)->window;
|
||||
GdkMacosWindow *parentWindow = GDK_MACOS_SURFACE (parent)->window;
|
||||
|
||||
[parentWindow showAndMakeKey:YES];
|
||||
}
|
||||
}
|
||||
|
||||
if (was_mapped)
|
||||
gdk_surface_freeze_updates (GDK_SURFACE (self));
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -210,6 +277,7 @@ gdk_macos_surface_begin_frame (GdkMacosSurface *self)
|
||||
{
|
||||
g_assert (GDK_IS_MACOS_SURFACE (self));
|
||||
|
||||
self->in_frame = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -230,11 +298,9 @@ gdk_macos_surface_end_frame (GdkMacosSurface *self)
|
||||
if ((timings = gdk_frame_clock_get_current_timings (frame_clock)))
|
||||
self->pending_frame_counter = timings->frame_counter;
|
||||
|
||||
if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self)))
|
||||
{
|
||||
_gdk_macos_display_add_frame_callback (GDK_MACOS_DISPLAY (display), self);
|
||||
gdk_surface_freeze_updates (GDK_SURFACE (self));
|
||||
}
|
||||
self->in_frame = FALSE;
|
||||
|
||||
_gdk_macos_surface_request_frame (self);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -408,6 +474,9 @@ gdk_macos_surface_destroy (GdkSurface *surface,
|
||||
GdkMacosWindow *window = g_steal_pointer (&self->window);
|
||||
GdkFrameClock *frame_clock;
|
||||
|
||||
_gdk_macos_surface_cancel_frame (self);
|
||||
g_clear_object (&self->best_monitor);
|
||||
|
||||
if ((frame_clock = gdk_surface_get_frame_clock (GDK_SURFACE (self))))
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (frame_clock,
|
||||
@@ -419,7 +488,6 @@ gdk_macos_surface_destroy (GdkSurface *surface,
|
||||
}
|
||||
|
||||
g_clear_pointer (&self->title, g_free);
|
||||
g_clear_pointer (&self->opaque_region, cairo_region_destroy);
|
||||
|
||||
if (window != NULL)
|
||||
[window close];
|
||||
@@ -528,6 +596,11 @@ gdk_macos_surface_class_init (GdkMacosSurfaceClass *klass)
|
||||
surface_class->set_input_region = gdk_macos_surface_set_input_region;
|
||||
surface_class->set_opaque_region = gdk_macos_surface_set_opaque_region;
|
||||
|
||||
/**
|
||||
* GdkMacosSurface:native: (attributes org.gtk.Property.get=gdk_macos_surface_get_native_window)
|
||||
*
|
||||
* The "native" property contains the underlying NSWindow.
|
||||
*/
|
||||
properties [PROP_NATIVE] =
|
||||
g_param_spec_pointer ("native",
|
||||
"Native",
|
||||
@@ -561,7 +634,7 @@ _gdk_macos_surface_new (GdkMacosDisplay *display,
|
||||
g_return_val_if_fail (GDK_IS_MACOS_DISPLAY (display), NULL);
|
||||
|
||||
if (parent != NULL)
|
||||
frame_clock = g_object_ref (gdk_surface_get_frame_clock (parent));
|
||||
frame_clock = g_object_ref (parent->frame_clock);
|
||||
else
|
||||
frame_clock = _gdk_frame_clock_idle_new ();
|
||||
|
||||
@@ -621,14 +694,16 @@ _gdk_macos_surface_get_shadow (GdkMacosSurface *self,
|
||||
gboolean
|
||||
_gdk_macos_surface_is_opaque (GdkMacosSurface *self)
|
||||
{
|
||||
GdkSurface *surface = (GdkSurface *)self;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_MACOS_SURFACE (self), FALSE);
|
||||
|
||||
if (self->opaque_region != NULL &&
|
||||
cairo_region_num_rectangles (self->opaque_region) == 1)
|
||||
if (surface->opaque_region != NULL &&
|
||||
cairo_region_num_rectangles (surface->opaque_region) == 1)
|
||||
{
|
||||
cairo_rectangle_int_t extents;
|
||||
|
||||
cairo_region_get_extents (self->opaque_region, &extents);
|
||||
cairo_region_get_extents (surface->opaque_region, &extents);
|
||||
|
||||
return (extents.x == 0 &&
|
||||
extents.y == 0 &&
|
||||
@@ -688,6 +763,27 @@ _gdk_macos_surface_get_native (GdkMacosSurface *self)
|
||||
return (NSWindow *)self->window;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_macos_surface_get_native_window: (attributes org.gtk.Method.get_property=native)
|
||||
* @self: a #GdkMacosSurface
|
||||
*
|
||||
* Gets the underlying NSWindow used by the surface.
|
||||
*
|
||||
* The NSWindow's contentView is an implementation detail and may change
|
||||
* between releases of GTK.
|
||||
*
|
||||
* Returns: (nullable): a #NSWindow or %NULL
|
||||
*
|
||||
* Since: 4.8
|
||||
*/
|
||||
gpointer
|
||||
gdk_macos_surface_get_native_window (GdkMacosSurface *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_MACOS_SURFACE (self), NULL);
|
||||
|
||||
return _gdk_macos_surface_get_native (self);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_surface_set_geometry_hints (GdkMacosSurface *self,
|
||||
const GdkGeometry *geometry,
|
||||
@@ -748,8 +844,9 @@ _gdk_macos_surface_update_fullscreen_state (GdkMacosSurface *self)
|
||||
void
|
||||
_gdk_macos_surface_configure (GdkMacosSurface *self)
|
||||
{
|
||||
GdkMacosDisplay *display;
|
||||
GdkSurface *surface = (GdkSurface *)self;
|
||||
GdkMacosDisplay *display;
|
||||
GdkMacosSurface *parent;
|
||||
NSRect frame_rect;
|
||||
NSRect content_rect;
|
||||
|
||||
@@ -758,6 +855,13 @@ _gdk_macos_surface_configure (GdkMacosSurface *self)
|
||||
if (GDK_SURFACE_DESTROYED (self))
|
||||
return;
|
||||
|
||||
if (surface->parent != NULL)
|
||||
parent = GDK_MACOS_SURFACE (surface->parent);
|
||||
else if (surface->transient_for != NULL)
|
||||
parent = GDK_MACOS_SURFACE (surface->transient_for);
|
||||
else
|
||||
parent = NULL;
|
||||
|
||||
display = GDK_MACOS_DISPLAY (GDK_SURFACE (self)->display);
|
||||
frame_rect = [self->window frame];
|
||||
content_rect = [self->window contentRectForFrameRect:frame_rect];
|
||||
@@ -767,18 +871,15 @@ _gdk_macos_surface_configure (GdkMacosSurface *self)
|
||||
content_rect.origin.y + content_rect.size.height,
|
||||
&self->root_x, &self->root_y);
|
||||
|
||||
if (self->did_initial_present)
|
||||
if (parent != NULL)
|
||||
{
|
||||
if (surface->parent != NULL)
|
||||
{
|
||||
surface->x = self->root_x - GDK_MACOS_SURFACE (surface->parent)->root_x;
|
||||
surface->y = self->root_y - GDK_MACOS_SURFACE (surface->parent)->root_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
surface->x = self->root_x;
|
||||
surface->y = self->root_y;
|
||||
}
|
||||
surface->x = self->root_x - parent->root_x;
|
||||
surface->y = self->root_y - parent->root_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
surface->x = self->root_x;
|
||||
surface->y = self->root_y;
|
||||
}
|
||||
|
||||
if (surface->width != content_rect.size.width ||
|
||||
@@ -791,48 +892,12 @@ _gdk_macos_surface_configure (GdkMacosSurface *self)
|
||||
g_clear_object (&self->front);
|
||||
|
||||
_gdk_surface_update_size (surface);
|
||||
gdk_surface_request_layout (surface);
|
||||
gdk_surface_invalidate_rect (surface, NULL);
|
||||
}
|
||||
|
||||
_gdk_macos_surface_reposition_children (self);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_surface_publish_timings (GdkMacosSurface *self,
|
||||
gint64 presentation_time,
|
||||
gint64 refresh_interval)
|
||||
{
|
||||
GdkFrameTimings *timings;
|
||||
GdkFrameClock *frame_clock;
|
||||
|
||||
g_return_if_fail (GDK_IS_MACOS_SURFACE (self));
|
||||
|
||||
if (!(frame_clock = gdk_surface_get_frame_clock (GDK_SURFACE (self))))
|
||||
return;
|
||||
|
||||
if (self->pending_frame_counter)
|
||||
{
|
||||
timings = gdk_frame_clock_get_timings (frame_clock, self->pending_frame_counter);
|
||||
|
||||
if (timings != NULL)
|
||||
{
|
||||
timings->presentation_time = presentation_time - refresh_interval;
|
||||
timings->complete = TRUE;
|
||||
}
|
||||
|
||||
self->pending_frame_counter = 0;
|
||||
}
|
||||
|
||||
timings = gdk_frame_clock_get_current_timings (frame_clock);
|
||||
|
||||
if (timings != NULL)
|
||||
{
|
||||
timings->refresh_interval = refresh_interval;
|
||||
timings->predicted_presentation_time = presentation_time;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_surface_show (GdkMacosSurface *self)
|
||||
{
|
||||
@@ -843,22 +908,17 @@ _gdk_macos_surface_show (GdkMacosSurface *self)
|
||||
if (GDK_SURFACE_DESTROYED (self))
|
||||
return;
|
||||
|
||||
_gdk_macos_display_clear_sorting (GDK_MACOS_DISPLAY (GDK_SURFACE (self)->display));
|
||||
self->show_on_next_swap = TRUE;
|
||||
|
||||
was_mapped = GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self));
|
||||
|
||||
if (!was_mapped)
|
||||
gdk_surface_set_is_mapped (GDK_SURFACE (self), TRUE);
|
||||
|
||||
_gdk_macos_display_clear_sorting (GDK_MACOS_DISPLAY (GDK_SURFACE (self)->display));
|
||||
|
||||
self->show_on_next_swap = TRUE;
|
||||
|
||||
if (!was_mapped)
|
||||
{
|
||||
if (gdk_surface_get_mapped (GDK_SURFACE (self)))
|
||||
{
|
||||
_gdk_macos_surface_configure (self);
|
||||
gdk_surface_thaw_updates (GDK_SURFACE (self));
|
||||
}
|
||||
gdk_surface_set_is_mapped (GDK_SURFACE (self), TRUE);
|
||||
gdk_surface_request_layout (GDK_SURFACE (self));
|
||||
gdk_surface_invalidate_rect (GDK_SURFACE (self), NULL);
|
||||
gdk_surface_thaw_updates (GDK_SURFACE (self));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -911,36 +971,59 @@ _gdk_macos_surface_move_resize (GdkMacosSurface *self,
|
||||
GdkDisplay *display;
|
||||
NSRect content_rect;
|
||||
NSRect frame_rect;
|
||||
gboolean ignore_move;
|
||||
gboolean ignore_size;
|
||||
GdkRectangle current;
|
||||
|
||||
g_return_if_fail (GDK_IS_MACOS_SURFACE (self));
|
||||
|
||||
if ((x == -1 || (x == self->root_x)) &&
|
||||
(y == -1 || (y == self->root_y)) &&
|
||||
(width == -1 || (width == surface->width)) &&
|
||||
(height == -1 || (height == surface->height)))
|
||||
/* Query for up-to-date values in case we're racing against
|
||||
* an incoming frame notify which could be queued behind whatever
|
||||
* we're processing right now.
|
||||
*/
|
||||
frame_rect = [self->window frame];
|
||||
content_rect = [self->window contentRectForFrameRect:frame_rect];
|
||||
_gdk_macos_display_from_display_coords (GDK_MACOS_DISPLAY (GDK_SURFACE (self)->display),
|
||||
content_rect.origin.x, content_rect.origin.y,
|
||||
¤t.x, ¤t.y);
|
||||
current.width = content_rect.size.width;
|
||||
current.height = content_rect.size.height;
|
||||
|
||||
/* Check if we can ignore the operation all together */
|
||||
ignore_move = (x == -1 || (x == current.x)) &&
|
||||
(y == -1 || (y == current.y));
|
||||
ignore_size = (width == -1 || (width == current.width)) &&
|
||||
(height == -1 || (height == current.height));
|
||||
|
||||
if (ignore_move && ignore_size)
|
||||
return;
|
||||
|
||||
display = gdk_surface_get_display (surface);
|
||||
|
||||
if (width == -1)
|
||||
width = surface->width;
|
||||
width = current.width;
|
||||
|
||||
if (height == -1)
|
||||
height = surface->height;
|
||||
height = current.height;
|
||||
|
||||
if (x == -1)
|
||||
x = self->root_x;
|
||||
x = current.x;
|
||||
|
||||
if (y == -1)
|
||||
y = self->root_y;
|
||||
y = current.y;
|
||||
|
||||
_gdk_macos_display_to_display_coords (GDK_MACOS_DISPLAY (display),
|
||||
x, y + height,
|
||||
&x, &y);
|
||||
|
||||
content_rect = NSMakeRect (x, y, width, height);
|
||||
if (!ignore_move)
|
||||
content_rect.origin = NSMakePoint (x, y);
|
||||
|
||||
if (!ignore_size)
|
||||
content_rect.size = NSMakeSize (width, height);
|
||||
|
||||
frame_rect = [self->window frameRectForContentRect:content_rect];
|
||||
[self->window setFrame:frame_rect display:YES];
|
||||
[self->window setFrame:frame_rect display:NO];
|
||||
}
|
||||
|
||||
void
|
||||
@@ -995,14 +1078,24 @@ void
|
||||
_gdk_macos_surface_monitor_changed (GdkMacosSurface *self)
|
||||
{
|
||||
GListModel *monitors;
|
||||
GdkMonitor *best = NULL;
|
||||
GdkRectangle rect;
|
||||
GdkRectangle intersect;
|
||||
GdkDisplay *display;
|
||||
GdkMonitor *monitor;
|
||||
guint n_monitors;
|
||||
int best_area = 0;
|
||||
|
||||
g_return_if_fail (GDK_IS_MACOS_SURFACE (self));
|
||||
|
||||
if (self->in_change_monitor)
|
||||
return;
|
||||
|
||||
self->in_change_monitor = TRUE;
|
||||
|
||||
_gdk_macos_surface_cancel_frame (self);
|
||||
_gdk_macos_surface_configure (self);
|
||||
|
||||
rect.x = self->root_x;
|
||||
rect.y = self->root_y;
|
||||
rect.width = GDK_SURFACE (self)->width;
|
||||
@@ -1042,29 +1135,10 @@ _gdk_macos_surface_monitor_changed (GdkMacosSurface *self)
|
||||
g_clear_object (&self->buffer);
|
||||
g_clear_object (&self->front);
|
||||
|
||||
_gdk_macos_surface_configure (self);
|
||||
|
||||
gdk_surface_invalidate_rect (GDK_SURFACE (self), NULL);
|
||||
}
|
||||
|
||||
GdkMonitor *
|
||||
_gdk_macos_surface_get_best_monitor (GdkMacosSurface *self)
|
||||
{
|
||||
GdkMonitor *best = NULL;
|
||||
GdkRectangle rect;
|
||||
int best_area = 0;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_MACOS_SURFACE (self), NULL);
|
||||
|
||||
rect.x = self->root_x;
|
||||
rect.y = self->root_y;
|
||||
rect.width = GDK_SURFACE (self)->width;
|
||||
rect.height = GDK_SURFACE (self)->height;
|
||||
|
||||
/* Determine the best-fit monitor */
|
||||
for (guint i = 0; i < self->monitors->len; i++)
|
||||
{
|
||||
GdkMonitor *monitor = g_ptr_array_index (self->monitors, i);
|
||||
GdkRectangle intersect;
|
||||
monitor = g_ptr_array_index (self->monitors, i);
|
||||
|
||||
if (gdk_rectangle_intersect (&monitor->geometry, &rect, &intersect))
|
||||
{
|
||||
@@ -1072,13 +1146,62 @@ _gdk_macos_surface_get_best_monitor (GdkMacosSurface *self)
|
||||
|
||||
if (area > best_area)
|
||||
{
|
||||
best = monitor;
|
||||
best_area = area;
|
||||
best = monitor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return best;
|
||||
if (g_set_object (&self->best_monitor, best))
|
||||
{
|
||||
GDK_NOTE (MISC,
|
||||
g_message ("Surface \"%s\" moved to monitor \"%s\"",
|
||||
self->title ? self->title : "unknown",
|
||||
gdk_monitor_get_connector (best)));
|
||||
|
||||
_gdk_macos_surface_configure (self);
|
||||
|
||||
if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self)))
|
||||
{
|
||||
_gdk_macos_surface_request_frame (self);
|
||||
gdk_surface_request_layout (GDK_SURFACE (self));
|
||||
}
|
||||
|
||||
for (const GList *iter = GDK_SURFACE (self)->children;
|
||||
iter != NULL;
|
||||
iter = iter->next)
|
||||
{
|
||||
GdkMacosSurface *child = iter->data;
|
||||
GdkRectangle area;
|
||||
|
||||
g_set_object (&child->best_monitor, best);
|
||||
|
||||
area.x = self->root_x + GDK_SURFACE (child)->x + child->shadow_left;
|
||||
area.y = self->root_y + GDK_SURFACE (child)->y + child->shadow_top;
|
||||
area.width = GDK_SURFACE (child)->width - child->shadow_left - child->shadow_right;
|
||||
area.height = GDK_SURFACE (child)->height - child->shadow_top - child->shadow_bottom;
|
||||
|
||||
_gdk_macos_monitor_clamp (GDK_MACOS_MONITOR (best), &area);
|
||||
|
||||
area.x -= child->shadow_left;
|
||||
area.y -= child->shadow_top;
|
||||
|
||||
_gdk_macos_surface_move (child, area.x, area.y);
|
||||
gdk_surface_invalidate_rect (GDK_SURFACE (child), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
gdk_surface_invalidate_rect (GDK_SURFACE (self), NULL);
|
||||
|
||||
self->in_change_monitor = FALSE;
|
||||
}
|
||||
|
||||
GdkMonitor *
|
||||
_gdk_macos_surface_get_best_monitor (GdkMacosSurface *self)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_MACOS_SURFACE (self), NULL);
|
||||
|
||||
return self->best_monitor;
|
||||
}
|
||||
|
||||
NSView *
|
||||
@@ -1154,11 +1277,15 @@ _gdk_macos_surface_get_buffer (GdkMacosSurface *self)
|
||||
static void
|
||||
_gdk_macos_surface_do_delayed_show (GdkMacosSurface *self)
|
||||
{
|
||||
GdkSurface *surface = (GdkSurface *)self;
|
||||
|
||||
g_assert (GDK_IS_MACOS_SURFACE (self));
|
||||
|
||||
self->show_on_next_swap = FALSE;
|
||||
[self->window showAndMakeKey:YES];
|
||||
gdk_surface_request_motion (GDK_SURFACE (self));
|
||||
|
||||
_gdk_macos_display_clear_sorting (GDK_MACOS_DISPLAY (surface->display));
|
||||
gdk_surface_request_motion (surface);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -36,7 +36,9 @@ typedef struct _GdkMacosSurfaceClass GdkMacosSurfaceClass;
|
||||
#define GDK_IS_MACOS_SURFACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MACOS_SURFACE))
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gdk_macos_surface_get_type (void);
|
||||
GType gdk_macos_surface_get_type (void);
|
||||
GDK_AVAILABLE_IN_4_8
|
||||
gpointer gdk_macos_surface_get_native_window (GdkMacosSurface *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -33,26 +33,26 @@
|
||||
static void
|
||||
_gdk_macos_toplevel_surface_fullscreen (GdkMacosToplevelSurface *self)
|
||||
{
|
||||
NSWindow *window;
|
||||
GdkMacosWindow *window;
|
||||
|
||||
g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (self));
|
||||
|
||||
window = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self));
|
||||
window = (GdkMacosWindow *)_gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self));
|
||||
|
||||
if (([window styleMask] & NSWindowStyleMaskFullScreen) == 0)
|
||||
if (![window inFullscreenTransition] && ([window styleMask] & NSWindowStyleMaskFullScreen) == 0)
|
||||
[window toggleFullScreen:window];
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_macos_toplevel_surface_unfullscreen (GdkMacosToplevelSurface *self)
|
||||
{
|
||||
NSWindow *window;
|
||||
GdkMacosWindow *window;
|
||||
|
||||
g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (self));
|
||||
|
||||
window = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self));
|
||||
window = (GdkMacosWindow *)_gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self));
|
||||
|
||||
if (([window styleMask] & NSWindowStyleMaskFullScreen) != 0)
|
||||
if (![window inFullscreenTransition] && ([window styleMask] & NSWindowStyleMaskFullScreen) != 0)
|
||||
[window toggleFullScreen:window];
|
||||
}
|
||||
|
||||
@@ -82,6 +82,19 @@ _gdk_macos_toplevel_surface_unmaximize (GdkMacosToplevelSurface *self)
|
||||
[window zoom:window];
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_macos_toplevel_surface_unminimize (GdkMacosToplevelSurface *self)
|
||||
{
|
||||
NSWindow *window;
|
||||
|
||||
g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (self));
|
||||
|
||||
window = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self));
|
||||
|
||||
if ([window isMiniaturized])
|
||||
[window deminiaturize:window];
|
||||
}
|
||||
|
||||
static void
|
||||
_gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
|
||||
GdkToplevelLayout *layout)
|
||||
@@ -174,6 +187,14 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
|
||||
|
||||
_gdk_macos_surface_set_geometry_hints (GDK_MACOS_SURFACE (self), &geometry, mask);
|
||||
gdk_surface_constrain_size (&geometry, mask, width, height, &width, &height);
|
||||
|
||||
GDK_NOTE (MISC,
|
||||
g_message ("Resizing \"%s\" to %dx%d",
|
||||
GDK_MACOS_SURFACE (self)->title ?
|
||||
GDK_MACOS_SURFACE (self)->title :
|
||||
"untitled",
|
||||
width, height));
|
||||
|
||||
_gdk_macos_surface_resize (GDK_MACOS_SURFACE (self), width, height);
|
||||
|
||||
/* Maximized state */
|
||||
@@ -194,6 +215,8 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
|
||||
_gdk_macos_toplevel_surface_unfullscreen (self);
|
||||
}
|
||||
|
||||
_gdk_macos_toplevel_surface_unminimize (self);
|
||||
|
||||
if (!GDK_MACOS_SURFACE (self)->did_initial_present)
|
||||
{
|
||||
int x = 0, y = 0;
|
||||
@@ -202,6 +225,13 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
|
||||
GDK_MACOS_SURFACE (self),
|
||||
&x, &y);
|
||||
|
||||
GDK_NOTE (MISC,
|
||||
g_message ("Placing new toplevel \"%s\" at %d,%d",
|
||||
GDK_MACOS_SURFACE (self)->title ?
|
||||
GDK_MACOS_SURFACE (self)->title :
|
||||
"untitled",
|
||||
x, y));
|
||||
|
||||
_gdk_macos_surface_move (GDK_MACOS_SURFACE (self), x, y);
|
||||
}
|
||||
|
||||
@@ -421,7 +451,8 @@ _gdk_macos_toplevel_surface_compute_size (GdkSurface *surface)
|
||||
GDK_TOPLEVEL_STATE_RIGHT_TILED |
|
||||
GDK_TOPLEVEL_STATE_BOTTOM_TILED |
|
||||
GDK_TOPLEVEL_STATE_LEFT_TILED |
|
||||
GDK_TOPLEVEL_STATE_MINIMIZED))
|
||||
GDK_TOPLEVEL_STATE_MINIMIZED) ||
|
||||
[macos_surface->window inLiveResize])
|
||||
return FALSE;
|
||||
|
||||
/* If we delayed a user resize until the beginning of the frame,
|
||||
@@ -632,10 +663,10 @@ _gdk_macos_toplevel_surface_new (GdkMacosDisplay *display,
|
||||
|
||||
GdkMacosWindow *window;
|
||||
GdkMacosSurface *self;
|
||||
NSScreen *screen;
|
||||
NSUInteger style_mask;
|
||||
NSRect content_rect;
|
||||
NSRect screen_rect;
|
||||
NSRect visible_frame;
|
||||
NSScreen *screen;
|
||||
int nx;
|
||||
int ny;
|
||||
|
||||
@@ -648,14 +679,17 @@ _gdk_macos_toplevel_surface_new (GdkMacosDisplay *display,
|
||||
NSWindowStyleMaskMiniaturizable |
|
||||
NSWindowStyleMaskResizable);
|
||||
|
||||
_gdk_macos_display_to_display_coords (display, x, y, &nx, &ny);
|
||||
if (parent != NULL)
|
||||
{
|
||||
x += GDK_MACOS_SURFACE (parent)->root_x;
|
||||
y += GDK_MACOS_SURFACE (parent)->root_y;
|
||||
}
|
||||
|
||||
_gdk_macos_display_to_display_coords (display, x, y + height, &nx, &ny);
|
||||
|
||||
screen = _gdk_macos_display_get_screen_at_display_coords (display, nx, ny);
|
||||
screen_rect = [screen visibleFrame];
|
||||
nx -= screen_rect.origin.x;
|
||||
ny -= screen_rect.origin.y;
|
||||
content_rect = NSMakeRect (nx, ny - height, width, height);
|
||||
|
||||
visible_frame = [screen visibleFrame];
|
||||
content_rect = NSMakeRect (nx - visible_frame.origin.x, ny - visible_frame.origin.y, width, height);
|
||||
window = [[GdkMacosWindow alloc] initWithContentRect:content_rect
|
||||
styleMask:style_mask
|
||||
backing:NSBackingStoreBuffered
|
||||
@@ -691,13 +725,21 @@ _gdk_macos_toplevel_surface_attach_to_parent (GdkMacosToplevelSurface *self)
|
||||
{
|
||||
NSWindow *parent = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (surface->transient_for));
|
||||
NSWindow *window = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self));
|
||||
int x, y;
|
||||
|
||||
[parent addChildWindow:window ordered:NSWindowAbove];
|
||||
|
||||
if (GDK_SURFACE (self)->modal_hint)
|
||||
[window setLevel:NSModalPanelWindowLevel];
|
||||
|
||||
surface->x = 0;
|
||||
surface->y = 0;
|
||||
|
||||
_gdk_macos_display_clear_sorting (GDK_MACOS_DISPLAY (surface->display));
|
||||
_gdk_macos_display_position_surface (GDK_MACOS_DISPLAY (surface->display),
|
||||
GDK_MACOS_SURFACE (surface),
|
||||
&x, &y);
|
||||
_gdk_macos_surface_move (GDK_MACOS_SURFACE (surface), x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ gdk_macos_sources = files([
|
||||
'gdkmacoscursor.c',
|
||||
'gdkmacosdevice.c',
|
||||
'gdkmacosdisplay.c',
|
||||
'gdkmacosdisplay-feedback.c',
|
||||
'gdkmacosdisplay-settings.c',
|
||||
'gdkmacosdisplay-translate.c',
|
||||
'gdkmacosdisplay-wm.c',
|
||||
|
||||
@@ -73,8 +73,9 @@ gdk_wayland_app_launch_context_get_startup_notify_id (GAppLaunchContext *context
|
||||
xdg_activation_token_v1_set_serial (token,
|
||||
_gdk_wayland_seat_get_last_implicit_grab_serial (seat, NULL),
|
||||
gdk_wayland_seat_get_wl_seat (GDK_SEAT (seat)));
|
||||
xdg_activation_token_v1_set_surface (token,
|
||||
gdk_wayland_surface_get_wl_surface (focus_surface));
|
||||
if (focus_surface)
|
||||
xdg_activation_token_v1_set_surface (token,
|
||||
gdk_wayland_surface_get_wl_surface (focus_surface));
|
||||
xdg_activation_token_v1_commit (token);
|
||||
|
||||
while (app_launch_data.token == NULL)
|
||||
|
||||
@@ -1416,7 +1416,8 @@ flush_smooth_scroll_event (GdkWaylandSeat *seat,
|
||||
seat->pointer_info.time,
|
||||
device_get_modifiers (seat->logical_pointer),
|
||||
delta_x, delta_y,
|
||||
is_stop);
|
||||
is_stop,
|
||||
GDK_SCROLL_UNIT_SURFACE);
|
||||
|
||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||
}
|
||||
@@ -1755,10 +1756,10 @@ pointer_handle_axis (void *data,
|
||||
switch (axis)
|
||||
{
|
||||
case WL_POINTER_AXIS_VERTICAL_SCROLL:
|
||||
pointer_frame->delta_y = wl_fixed_to_double (value) / 10.0;
|
||||
pointer_frame->delta_y = wl_fixed_to_double (value);
|
||||
break;
|
||||
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
|
||||
pointer_frame->delta_x = wl_fixed_to_double (value) / 10.0;
|
||||
pointer_frame->delta_x = wl_fixed_to_double (value);
|
||||
break;
|
||||
default:
|
||||
g_return_if_reached ();
|
||||
@@ -1768,7 +1769,7 @@ pointer_handle_axis (void *data,
|
||||
|
||||
GDK_SEAT_NOTE (seat, EVENTS,
|
||||
g_message ("scroll, axis %s, value %f, seat %p",
|
||||
get_axis_name (axis), wl_fixed_to_double (value) / 10.0,
|
||||
get_axis_name (axis), wl_fixed_to_double (value),
|
||||
seat));
|
||||
|
||||
if (display->seat_version < WL_POINTER_HAS_FRAME)
|
||||
@@ -3994,7 +3995,8 @@ tablet_tool_handle_wheel (void *data,
|
||||
tablet->pointer_info.time,
|
||||
device_get_modifiers (tablet->logical_device),
|
||||
0, clicks,
|
||||
FALSE);
|
||||
FALSE,
|
||||
GDK_SCROLL_UNIT_WHEEL);
|
||||
|
||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||
|
||||
|
||||
@@ -854,6 +854,10 @@ gdk_wayland_display_notify_startup_complete (GdkDisplay *display,
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
char *free_this = NULL;
|
||||
|
||||
/* Will be signaled with focus activation */
|
||||
if (display_wayland->xdg_activation)
|
||||
return;
|
||||
|
||||
if (startup_id == NULL)
|
||||
{
|
||||
startup_id = free_this = display_wayland->startup_notification_id;
|
||||
|
||||
@@ -3453,39 +3453,80 @@ gdk_wayland_surface_destroy (GdkSurface *surface,
|
||||
display->toplevels = g_list_remove (display->toplevels, surface);
|
||||
}
|
||||
|
||||
static void
|
||||
token_done (gpointer data,
|
||||
struct xdg_activation_token_v1 *provider,
|
||||
const char *token)
|
||||
{
|
||||
char **token_out = data;
|
||||
|
||||
*token_out = g_strdup (token);
|
||||
}
|
||||
|
||||
static const struct xdg_activation_token_v1_listener token_listener = {
|
||||
token_done,
|
||||
};
|
||||
|
||||
static void
|
||||
gdk_wayland_surface_focus (GdkSurface *surface,
|
||||
guint32 timestamp)
|
||||
{
|
||||
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
|
||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
gchar *startup_id = NULL;
|
||||
|
||||
if (!impl->display_server.gtk_surface)
|
||||
return;
|
||||
startup_id = g_steal_pointer (&display_wayland->startup_notification_id);
|
||||
|
||||
if (timestamp == GDK_CURRENT_TIME)
|
||||
if (display_wayland->xdg_activation)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland =
|
||||
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
|
||||
GdkWaylandSeat *seat =
|
||||
GDK_WAYLAND_SEAT (gdk_display_get_default_seat (display));
|
||||
|
||||
if (display_wayland->startup_notification_id)
|
||||
/* If the focus request does not have a startup ID associated, get a
|
||||
* new token to activate the window.
|
||||
*/
|
||||
if (!startup_id)
|
||||
{
|
||||
if (display_wayland->xdg_activation)
|
||||
{
|
||||
xdg_activation_v1_activate (display_wayland->xdg_activation,
|
||||
display_wayland->startup_notification_id,
|
||||
impl->display_server.wl_surface);
|
||||
}
|
||||
else if (display_wayland->gtk_shell_version >= 3)
|
||||
{
|
||||
gtk_surface1_request_focus (impl->display_server.gtk_surface,
|
||||
display_wayland->startup_notification_id);
|
||||
}
|
||||
struct xdg_activation_token_v1 *token;
|
||||
struct wl_event_queue *event_queue;
|
||||
|
||||
g_clear_pointer (&display_wayland->startup_notification_id, g_free);
|
||||
event_queue = wl_display_create_queue (display_wayland->wl_display);
|
||||
|
||||
token = xdg_activation_v1_get_activation_token (display_wayland->xdg_activation);
|
||||
wl_proxy_set_queue ((struct wl_proxy *) token, event_queue);
|
||||
|
||||
xdg_activation_token_v1_add_listener (token,
|
||||
&token_listener,
|
||||
&startup_id);
|
||||
xdg_activation_token_v1_set_serial (token,
|
||||
_gdk_wayland_seat_get_last_implicit_grab_serial (seat, NULL),
|
||||
gdk_wayland_seat_get_wl_seat (GDK_SEAT (seat)));
|
||||
xdg_activation_token_v1_set_surface (token,
|
||||
gdk_wayland_surface_get_wl_surface (surface));
|
||||
xdg_activation_token_v1_commit (token);
|
||||
|
||||
while (startup_id == NULL)
|
||||
wl_display_dispatch_queue (display_wayland->wl_display, event_queue);
|
||||
|
||||
xdg_activation_token_v1_destroy (token);
|
||||
wl_event_queue_destroy (event_queue);
|
||||
}
|
||||
|
||||
xdg_activation_v1_activate (display_wayland->xdg_activation,
|
||||
startup_id,
|
||||
impl->display_server.wl_surface);
|
||||
}
|
||||
else
|
||||
gtk_surface1_present (impl->display_server.gtk_surface, timestamp);
|
||||
else if (impl->display_server.gtk_surface)
|
||||
{
|
||||
if (timestamp != GDK_CURRENT_TIME)
|
||||
gtk_surface1_present (impl->display_server.gtk_surface, timestamp);
|
||||
else if (startup_id && display_wayland->gtk_shell_version >= 3)
|
||||
gtk_surface1_request_focus (impl->display_server.gtk_surface,
|
||||
startup_id);
|
||||
}
|
||||
|
||||
g_free (startup_id);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -142,9 +142,13 @@ gdk_win32_clipboard_claim_remote (GdkWin32Clipboard *cb)
|
||||
cb->sequence_number = -1;
|
||||
|
||||
formats = gdk_win32_clipboard_request_contentformats (cb);
|
||||
gdk_clipboard_claim_remote (GDK_CLIPBOARD (cb), formats);
|
||||
gdk_content_formats_unref (formats);
|
||||
cb->sequence_number = GetClipboardSequenceNumber ();
|
||||
|
||||
if (formats != NULL)
|
||||
{
|
||||
gdk_clipboard_claim_remote (GDK_CLIPBOARD (cb), formats);
|
||||
gdk_content_formats_unref (formats);
|
||||
cb->sequence_number = GetClipboardSequenceNumber ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -1219,11 +1219,10 @@ inner_clipboard_window_procedure (HWND hwnd,
|
||||
return DefWindowProcW (hwnd, message, wparam, lparam);
|
||||
}
|
||||
|
||||
SetLastError (0);
|
||||
hwnd_owner = GetClipboardOwner ();
|
||||
|
||||
if ((hwnd_owner == NULL) &&
|
||||
(GetLastError () != ERROR_SUCCESS))
|
||||
WIN32_API_FAILED ("GetClipboardOwner");
|
||||
if (hwnd_owner == NULL && GetLastError () != 0)
|
||||
WIN32_API_FAILED ("GetClipboardOwner");
|
||||
|
||||
hwnd_opener = GetOpenClipboardWindow ();
|
||||
|
||||
|
||||
+57
-69
@@ -873,6 +873,7 @@ _gdk_win32_append_event (GdkEvent *event)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GList *link;
|
||||
gulong serial;
|
||||
|
||||
display = gdk_display_get_default ();
|
||||
|
||||
@@ -880,8 +881,9 @@ _gdk_win32_append_event (GdkEvent *event)
|
||||
#if 1
|
||||
link = _gdk_event_queue_append (display, event);
|
||||
GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
|
||||
serial = _gdk_display_get_next_serial (display);
|
||||
/* event morphing, the passed in may not be valid afterwards */
|
||||
_gdk_windowing_got_event (display, link, event, 0);
|
||||
_gdk_windowing_got_event (display, link, event, serial);
|
||||
#else
|
||||
_gdk_event_queue_append (display, event);
|
||||
GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
|
||||
@@ -2242,6 +2244,10 @@ gdk_event_translate (MSG *msg,
|
||||
button = 5;
|
||||
|
||||
buttonup0:
|
||||
{
|
||||
gboolean release_implicit_grab = FALSE;
|
||||
GdkSurface *prev_surface = NULL;
|
||||
|
||||
GDK_NOTE (EVENTS,
|
||||
g_print (" (%d,%d)",
|
||||
GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
|
||||
@@ -2251,41 +2257,18 @@ gdk_event_translate (MSG *msg,
|
||||
g_set_object (&window, find_window_for_mouse_event (window, msg));
|
||||
|
||||
if (pointer_grab != NULL && pointer_grab->implicit)
|
||||
{
|
||||
int state = build_pointer_event_state (msg);
|
||||
{
|
||||
int state = build_pointer_event_state (msg);
|
||||
|
||||
/* We keep the implicit grab until no buttons at all are held down */
|
||||
if ((state & GDK_ANY_BUTTON_MASK & ~(GDK_BUTTON1_MASK << (button - 1))) == 0)
|
||||
{
|
||||
ReleaseCapture ();
|
||||
/* We keep the implicit grab until no buttons at all are held down */
|
||||
if ((state & GDK_ANY_BUTTON_MASK & ~(GDK_BUTTON1_MASK << (button - 1))) == 0)
|
||||
{
|
||||
release_implicit_grab = TRUE;
|
||||
prev_surface = pointer_grab->surface;
|
||||
}
|
||||
}
|
||||
|
||||
new_window = NULL;
|
||||
hwnd = WindowFromPoint (msg->pt);
|
||||
if (hwnd != NULL)
|
||||
{
|
||||
POINT client_pt = msg->pt;
|
||||
|
||||
ScreenToClient (hwnd, &client_pt);
|
||||
GetClientRect (hwnd, &rect);
|
||||
if (PtInRect (&rect, client_pt))
|
||||
new_window = gdk_win32_handle_table_lookup (hwnd);
|
||||
}
|
||||
|
||||
synthesize_crossing_events (display,
|
||||
_gdk_device_manager->system_pointer,
|
||||
pointer_grab->surface, new_window,
|
||||
GDK_CROSSING_UNGRAB,
|
||||
&msg->pt,
|
||||
0, /* TODO: Set right mask */
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
FALSE);
|
||||
g_set_object (&mouse_window, new_window);
|
||||
mouse_window_ignored_leave = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
generate_button_event (GDK_BUTTON_RELEASE, button,
|
||||
window, msg);
|
||||
generate_button_event (GDK_BUTTON_RELEASE, button, window, msg);
|
||||
|
||||
impl = GDK_WIN32_SURFACE (window);
|
||||
|
||||
@@ -2294,8 +2277,37 @@ gdk_event_translate (MSG *msg,
|
||||
impl->drag_move_resize_context.button == button)
|
||||
gdk_win32_surface_end_move_resize_drag (window);
|
||||
|
||||
if (release_implicit_grab)
|
||||
{
|
||||
ReleaseCapture ();
|
||||
|
||||
new_window = NULL;
|
||||
hwnd = WindowFromPoint (msg->pt);
|
||||
if (hwnd != NULL)
|
||||
{
|
||||
POINT client_pt = msg->pt;
|
||||
|
||||
ScreenToClient (hwnd, &client_pt);
|
||||
GetClientRect (hwnd, &rect);
|
||||
if (PtInRect (&rect, client_pt))
|
||||
new_window = gdk_win32_handle_table_lookup (hwnd);
|
||||
}
|
||||
|
||||
synthesize_crossing_events (display,
|
||||
_gdk_device_manager->system_pointer,
|
||||
prev_surface, new_window,
|
||||
GDK_CROSSING_UNGRAB,
|
||||
&msg->pt,
|
||||
0, /* TODO: Set right mask */
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
FALSE);
|
||||
g_set_object (&mouse_window, new_window);
|
||||
mouse_window_ignored_leave = NULL;
|
||||
}
|
||||
|
||||
return_val = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
GDK_NOTE (EVENTS,
|
||||
@@ -2320,60 +2332,35 @@ gdk_event_translate (MSG *msg,
|
||||
|
||||
pen_touch_input = FALSE;
|
||||
|
||||
new_window = window;
|
||||
g_set_object (&window, find_window_for_mouse_event (window, msg));
|
||||
|
||||
if (pointer_grab != NULL)
|
||||
{
|
||||
POINT pt;
|
||||
pt = msg->pt;
|
||||
|
||||
new_window = NULL;
|
||||
hwnd = WindowFromPoint (pt);
|
||||
if (hwnd != NULL)
|
||||
{
|
||||
POINT client_pt = pt;
|
||||
|
||||
ScreenToClient (hwnd, &client_pt);
|
||||
GetClientRect (hwnd, &rect);
|
||||
if (PtInRect (&rect, client_pt))
|
||||
new_window = gdk_win32_handle_table_lookup (hwnd);
|
||||
}
|
||||
|
||||
if (!pointer_grab->owner_events &&
|
||||
new_window != NULL &&
|
||||
new_window != pointer_grab->surface)
|
||||
new_window = NULL;
|
||||
}
|
||||
|
||||
if (mouse_window != new_window)
|
||||
if (mouse_window != window)
|
||||
{
|
||||
GDK_NOTE (EVENTS, g_print (" mouse_window %p -> %p",
|
||||
mouse_window ? GDK_SURFACE_HWND (mouse_window) : NULL,
|
||||
new_window ? GDK_SURFACE_HWND (new_window) : NULL));
|
||||
window ? GDK_SURFACE_HWND (window) : NULL));
|
||||
synthesize_crossing_events (display,
|
||||
_gdk_device_manager->system_pointer,
|
||||
mouse_window, new_window,
|
||||
mouse_window, window,
|
||||
GDK_CROSSING_NORMAL,
|
||||
&msg->pt,
|
||||
0, /* TODO: Set right mask */
|
||||
_gdk_win32_get_next_tick (msg->time),
|
||||
FALSE);
|
||||
g_set_object (&mouse_window, new_window);
|
||||
g_set_object (&mouse_window, window);
|
||||
mouse_window_ignored_leave = NULL;
|
||||
if (new_window != NULL)
|
||||
track_mouse_event (TME_LEAVE, GDK_SURFACE_HWND (new_window));
|
||||
if (window != NULL)
|
||||
track_mouse_event (TME_LEAVE, GDK_SURFACE_HWND (window));
|
||||
}
|
||||
else if (new_window != NULL &&
|
||||
new_window == mouse_window_ignored_leave)
|
||||
else if (window != NULL && window == mouse_window_ignored_leave)
|
||||
{
|
||||
/* If we ignored a leave event for this window and we're now getting
|
||||
input again we need to re-arm the mouse tracking, as that was
|
||||
cancelled by the mouseleave. */
|
||||
mouse_window_ignored_leave = NULL;
|
||||
track_mouse_event (TME_LEAVE, GDK_SURFACE_HWND (new_window));
|
||||
track_mouse_event (TME_LEAVE, GDK_SURFACE_HWND (window));
|
||||
}
|
||||
|
||||
g_set_object (&window, find_window_for_mouse_event (window, msg));
|
||||
impl = GDK_WIN32_SURFACE (window);
|
||||
|
||||
/* If we haven't moved, don't create any GDK event. Windows
|
||||
@@ -2742,7 +2729,8 @@ gdk_event_translate (MSG *msg,
|
||||
build_pointer_event_state (msg),
|
||||
delta_x,
|
||||
delta_y,
|
||||
FALSE);
|
||||
FALSE,
|
||||
GDK_SCROLL_UNIT_WHEEL);
|
||||
|
||||
/* Append the discrete version too */
|
||||
direction = 0;
|
||||
|
||||
+25
-24
@@ -229,14 +229,9 @@ fail1:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the file path of the keyboard layout dll.
|
||||
* The result is heap-allocated and should be freed with g_free().
|
||||
*/
|
||||
static char*
|
||||
get_keyboard_layout_file (const char *layout_name)
|
||||
_get_keyboard_layout_file (const char *layout_name)
|
||||
{
|
||||
char *final_layout_name = NULL;
|
||||
HKEY hkey = 0;
|
||||
DWORD var_type = REG_SZ;
|
||||
char *result = NULL;
|
||||
@@ -249,24 +244,8 @@ get_keyboard_layout_file (const char *layout_name)
|
||||
"Keyboard Layouts\\";
|
||||
char kbdKeyPath[sizeof (prefix) + KL_NAMELENGTH];
|
||||
|
||||
/* The user may have a keyboard substitute configured */
|
||||
final_layout_name = get_keyboard_layout_substituted_name (layout_name);
|
||||
if (final_layout_name != NULL)
|
||||
{
|
||||
g_debug ("Substituting keyboard layout name from '%s' to '%s'",
|
||||
layout_name, final_layout_name);
|
||||
g_snprintf (kbdKeyPath, sizeof (prefix) + KL_NAMELENGTH, "%s%s",
|
||||
prefix, final_layout_name);
|
||||
g_free (final_layout_name);
|
||||
final_layout_name = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_debug ("Could not get substitute keyboard layout name for '%s', "
|
||||
"will use '%s' directly", layout_name, layout_name);
|
||||
g_snprintf (kbdKeyPath, sizeof (prefix) + KL_NAMELENGTH, "%s%s",
|
||||
prefix, layout_name);
|
||||
}
|
||||
g_snprintf (kbdKeyPath, sizeof (prefix) + KL_NAMELENGTH, "%s%s",
|
||||
prefix, layout_name);
|
||||
|
||||
status = RegOpenKeyExA (HKEY_LOCAL_MACHINE, (LPCSTR) kbdKeyPath, 0,
|
||||
KEY_QUERY_VALUE, &hkey);
|
||||
@@ -326,6 +305,28 @@ fail1:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the file path of the keyboard layout dll.
|
||||
* The result is heap-allocated and should be freed with g_free().
|
||||
*/
|
||||
static char*
|
||||
get_keyboard_layout_file (const char *layout_name)
|
||||
{
|
||||
char *result = _get_keyboard_layout_file (layout_name);
|
||||
|
||||
/* If we could not retrieve a path, it may be that we need to perform layout
|
||||
* substitution
|
||||
*/
|
||||
if (result == NULL)
|
||||
{
|
||||
char *substituted = get_keyboard_layout_substituted_name (layout_name);
|
||||
result = _get_keyboard_layout_file (substituted);
|
||||
g_free (substituted);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
clear_keyboard_layout_info (gpointer data)
|
||||
{
|
||||
|
||||
@@ -4152,6 +4152,9 @@ gdk_win32_surface_fullscreen (GdkSurface *window)
|
||||
g_object_set_data (G_OBJECT (window), "fullscreen-info", fi);
|
||||
fi->style = GetWindowLong (GDK_SURFACE_HWND (window), GWL_STYLE);
|
||||
|
||||
impl->inhibit_configure = TRUE;
|
||||
impl->force_recompute_size = FALSE;
|
||||
|
||||
/* Send state change before configure event */
|
||||
gdk_synthesize_surface_state (window, 0, GDK_TOPLEVEL_STATE_FULLSCREEN);
|
||||
|
||||
@@ -4160,7 +4163,7 @@ gdk_win32_surface_fullscreen (GdkSurface *window)
|
||||
|
||||
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window), HWND_TOP,
|
||||
x, y, width, height,
|
||||
SWP_NOCOPYBITS | SWP_SHOWWINDOW));
|
||||
SWP_NOCOPYBITS | SWP_SHOWWINDOW | SWP_FRAMECHANGED));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4184,11 +4187,17 @@ gdk_win32_surface_unfullscreen (GdkSurface *window)
|
||||
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window), HWND_NOTOPMOST,
|
||||
fi->r.left, fi->r.top,
|
||||
fi->r.right - fi->r.left, fi->r.bottom - fi->r.top,
|
||||
SWP_NOCOPYBITS | SWP_SHOWWINDOW));
|
||||
SWP_NOCOPYBITS | SWP_SHOWWINDOW | SWP_FRAMECHANGED));
|
||||
|
||||
g_object_set_data (G_OBJECT (window), "fullscreen-info", NULL);
|
||||
g_free (fi);
|
||||
_gdk_win32_surface_update_style_bits (window);
|
||||
|
||||
if (impl->inhibit_configure)
|
||||
{
|
||||
impl->inhibit_configure = FALSE;
|
||||
impl->force_recompute_size = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -248,6 +248,10 @@ gdk_x11_clipboard_formats_from_atoms (GdkDisplay *display,
|
||||
const char *name;
|
||||
|
||||
name = gdk_x11_get_xatom_name_for_display (display , atoms[i]);
|
||||
if (!name)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (strchr (name, '/'))
|
||||
{
|
||||
gdk_content_formats_builder_add_mime_type (builder, name);
|
||||
|
||||
@@ -1778,7 +1778,8 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
state,
|
||||
delta_x,
|
||||
delta_y,
|
||||
delta_x == 0.0 && delta_y == 0.0);
|
||||
delta_x == 0.0 && delta_y == 0.0,
|
||||
GDK_SCROLL_UNIT_WHEEL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ snapshot_uniforms (GskGLUniformState *state,
|
||||
{
|
||||
const GskGLUniformMapping *mapping = &program->mappings[i];
|
||||
|
||||
if (!mapping->info.initial && mapping->location > -1)
|
||||
if (!mapping->info.initial && mapping->info.format && mapping->location > -1)
|
||||
{
|
||||
uniform[count].location = mapping->location;
|
||||
uniform[count].info = mapping->info;
|
||||
|
||||
+87
-111
@@ -44,9 +44,6 @@
|
||||
#include <gdk/gdkprofilerprivate.h>
|
||||
#include <gdk/gdktextureprivate.h>
|
||||
|
||||
#define ATLAS_SIZE 512
|
||||
#define MAX_OLD_RATIO 0.5
|
||||
|
||||
G_DEFINE_TYPE (GskGLDriver, gsk_gl_driver, G_TYPE_OBJECT)
|
||||
|
||||
static guint
|
||||
@@ -156,50 +153,6 @@ gsk_gl_driver_collect_unused_textures (GskGLDriver *self,
|
||||
return collected;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_texture_atlas_free (GskGLTextureAtlas *atlas)
|
||||
{
|
||||
if (atlas->texture_id != 0)
|
||||
{
|
||||
glDeleteTextures (1, &atlas->texture_id);
|
||||
atlas->texture_id = 0;
|
||||
}
|
||||
|
||||
g_clear_pointer (&atlas->nodes, g_free);
|
||||
g_slice_free (GskGLTextureAtlas, atlas);
|
||||
}
|
||||
|
||||
GskGLTextureAtlas *
|
||||
gsk_gl_driver_create_atlas (GskGLDriver *self)
|
||||
{
|
||||
GskGLTextureAtlas *atlas;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_GL_DRIVER (self), NULL);
|
||||
|
||||
atlas = g_slice_new0 (GskGLTextureAtlas);
|
||||
atlas->width = ATLAS_SIZE;
|
||||
atlas->height = ATLAS_SIZE;
|
||||
/* TODO: We might want to change the strategy about the amount of
|
||||
* nodes here? stb_rect_pack.h says width is optimal. */
|
||||
atlas->nodes = g_malloc0_n (atlas->width, sizeof (struct stbrp_node));
|
||||
stbrp_init_target (&atlas->context, atlas->width, atlas->height, atlas->nodes, atlas->width);
|
||||
atlas->texture_id = gsk_gl_command_queue_create_texture (self->command_queue,
|
||||
atlas->width,
|
||||
atlas->height,
|
||||
GL_RGBA8,
|
||||
GL_LINEAR,
|
||||
GL_LINEAR);
|
||||
|
||||
gdk_gl_context_label_object_printf (gdk_gl_context_get_current (),
|
||||
GL_TEXTURE, atlas->texture_id,
|
||||
"Texture atlas %d",
|
||||
atlas->texture_id);
|
||||
|
||||
g_ptr_array_add (self->atlases, atlas);
|
||||
|
||||
return atlas;
|
||||
}
|
||||
|
||||
static void
|
||||
remove_program (gpointer data)
|
||||
{
|
||||
@@ -226,6 +179,29 @@ gsk_gl_driver_shader_weak_cb (gpointer data,
|
||||
g_hash_table_remove (self->shader_cache, where_object_was);
|
||||
}
|
||||
|
||||
G_GNUC_NULL_TERMINATED static inline GBytes *
|
||||
join_sources (GBytes *first_bytes,
|
||||
...)
|
||||
{
|
||||
GByteArray *byte_array = g_byte_array_new ();
|
||||
GBytes *bytes = first_bytes;
|
||||
va_list args;
|
||||
|
||||
va_start (args, first_bytes);
|
||||
while (bytes != NULL)
|
||||
{
|
||||
gsize len;
|
||||
const guint8 *data = g_bytes_get_data (bytes, &len);
|
||||
if (len > 0)
|
||||
g_byte_array_append (byte_array, data, len);
|
||||
g_bytes_unref (bytes);
|
||||
bytes = va_arg (args, GBytes *);
|
||||
}
|
||||
va_end (args);
|
||||
|
||||
return g_byte_array_free_to_bytes (byte_array);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_driver_dispose (GObject *object)
|
||||
{
|
||||
@@ -235,6 +211,10 @@ gsk_gl_driver_dispose (GObject *object)
|
||||
g_assert (self->in_frame == FALSE);
|
||||
|
||||
#define GSK_GL_NO_UNIFORMS
|
||||
#define GSK_GL_SHADER_RESOURCE(name)
|
||||
#define GSK_GL_SHADER_STRING(str)
|
||||
#define GSK_GL_SHADER_SINGLE(name)
|
||||
#define GSK_GL_SHADER_JOINED(kind, ...)
|
||||
#define GSK_GL_ADD_UNIFORM(pos, KEY, name)
|
||||
#define GSK_GL_DEFINE_PROGRAM(name, resource, uniforms) \
|
||||
GSK_GL_DELETE_PROGRAM(name); \
|
||||
@@ -248,6 +228,10 @@ gsk_gl_driver_dispose (GObject *object)
|
||||
} G_STMT_END;
|
||||
# include "gskglprograms.defs"
|
||||
#undef GSK_GL_NO_UNIFORMS
|
||||
#undef GSK_GL_SHADER_RESOURCE
|
||||
#undef GSK_GL_SHADER_STRING
|
||||
#undef GSK_GL_SHADER_SINGLE
|
||||
#undef GSK_GL_SHADER_JOINED
|
||||
#undef GSK_GL_ADD_UNIFORM
|
||||
#undef GSK_GL_DEFINE_PROGRAM
|
||||
|
||||
@@ -289,11 +273,10 @@ gsk_gl_driver_dispose (GObject *object)
|
||||
g_assert (!self->texture_id_to_key || g_hash_table_size (self->texture_id_to_key) == 0);
|
||||
g_assert (!self->key_to_texture_id|| g_hash_table_size (self->key_to_texture_id) == 0);
|
||||
|
||||
g_clear_object (&self->glyphs);
|
||||
g_clear_object (&self->icons);
|
||||
g_clear_object (&self->shadows);
|
||||
g_clear_object (&self->glyphs_library);
|
||||
g_clear_object (&self->icons_library);
|
||||
g_clear_object (&self->shadows_library);
|
||||
|
||||
g_clear_pointer (&self->atlases, g_ptr_array_unref);
|
||||
g_clear_pointer (&self->autorelease_framebuffers, g_array_unref);
|
||||
g_clear_pointer (&self->key_to_texture_id, g_hash_table_unref);
|
||||
g_clear_pointer (&self->textures, g_hash_table_unref);
|
||||
@@ -330,7 +313,6 @@ gsk_gl_driver_init (GskGLDriver *self)
|
||||
self->shader_cache = g_hash_table_new_full (NULL, NULL, NULL, remove_program);
|
||||
self->texture_pool = g_array_new (FALSE, FALSE, sizeof (guint));
|
||||
self->render_targets = g_ptr_array_new ();
|
||||
self->atlases = g_ptr_array_new_with_free_func ((GDestroyNotify)gsk_gl_texture_atlas_free);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -348,14 +330,14 @@ gsk_gl_driver_load_programs (GskGLDriver *self,
|
||||
|
||||
/* Setup preambles that are shared by all shaders */
|
||||
gsk_gl_compiler_set_preamble_from_resource (compiler,
|
||||
GSK_GL_COMPILER_ALL,
|
||||
"/org/gtk/libgsk/gl/preamble.glsl");
|
||||
GSK_GL_COMPILER_ALL,
|
||||
"/org/gtk/libgsk/gl/preamble.glsl");
|
||||
gsk_gl_compiler_set_preamble_from_resource (compiler,
|
||||
GSK_GL_COMPILER_VERTEX,
|
||||
"/org/gtk/libgsk/gl/preamble.vs.glsl");
|
||||
GSK_GL_COMPILER_VERTEX,
|
||||
"/org/gtk/libgsk/gl/preamble.vs.glsl");
|
||||
gsk_gl_compiler_set_preamble_from_resource (compiler,
|
||||
GSK_GL_COMPILER_FRAGMENT,
|
||||
"/org/gtk/libgsk/gl/preamble.fs.glsl");
|
||||
GSK_GL_COMPILER_FRAGMENT,
|
||||
"/org/gtk/libgsk/gl/preamble.fs.glsl");
|
||||
|
||||
/* Setup attributes that are provided via VBO */
|
||||
gsk_gl_compiler_bind_attribute (compiler, "aPosition", 0);
|
||||
@@ -365,10 +347,28 @@ gsk_gl_driver_load_programs (GskGLDriver *self,
|
||||
|
||||
/* Use XMacros to register all of our programs and their uniforms */
|
||||
#define GSK_GL_NO_UNIFORMS
|
||||
#define GSK_GL_SHADER_RESOURCE(name) \
|
||||
g_resources_lookup_data("/org/gtk/libgsk/gl/" name, 0, NULL)
|
||||
#define GSK_GL_SHADER_STRING(str) \
|
||||
g_bytes_new_static(str, strlen(str))
|
||||
#define GSK_GL_SHADER_SINGLE(bytes) \
|
||||
G_STMT_START { \
|
||||
GBytes *b = bytes; \
|
||||
gsk_gl_compiler_set_source (compiler, GSK_GL_COMPILER_ALL, b); \
|
||||
g_bytes_unref (b); \
|
||||
} G_STMT_END;
|
||||
#define GSK_GL_SHADER_JOINED(kind, ...) \
|
||||
G_STMT_START { \
|
||||
GBytes *bytes = join_sources(__VA_ARGS__); \
|
||||
gsk_gl_compiler_set_source (compiler, GSK_GL_COMPILER_##kind, bytes); \
|
||||
g_bytes_unref (bytes); \
|
||||
} G_STMT_END;
|
||||
#define GSK_GL_ADD_UNIFORM(pos, KEY, name) \
|
||||
gsk_gl_program_add_uniform (program, #name, UNIFORM_##KEY);
|
||||
#define GSK_GL_DEFINE_PROGRAM(name, resource, uniforms) \
|
||||
gsk_gl_compiler_set_source_from_resource (compiler, GSK_GL_COMPILER_ALL, resource); \
|
||||
#define GSK_GL_DEFINE_PROGRAM(name, sources, uniforms) \
|
||||
gsk_gl_compiler_set_source (compiler, GSK_GL_COMPILER_VERTEX, NULL); \
|
||||
gsk_gl_compiler_set_source (compiler, GSK_GL_COMPILER_FRAGMENT, NULL); \
|
||||
sources \
|
||||
GSK_GL_COMPILE_PROGRAM(name ## _no_clip, uniforms, "#define NO_CLIP 1\n"); \
|
||||
GSK_GL_COMPILE_PROGRAM(name ## _rect_clip, uniforms, "#define RECT_CLIP 1\n"); \
|
||||
GSK_GL_COMPILE_PROGRAM(name, uniforms, "");
|
||||
@@ -401,6 +401,11 @@ gsk_gl_driver_load_programs (GskGLDriver *self,
|
||||
#undef GSK_GL_DEFINE_PROGRAM_CLIP
|
||||
#undef GSK_GL_DEFINE_PROGRAM
|
||||
#undef GSK_GL_ADD_UNIFORM
|
||||
#undef GSK_GL_SHADER_SINGLE
|
||||
#undef GSK_GL_SHADER_JOINED
|
||||
#undef GSK_GL_SHADER_RESOURCE
|
||||
#undef GSK_GL_SHADER_STRING
|
||||
#undef GSK_GL_NO_UNIFORMS
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
@@ -456,9 +461,9 @@ gsk_gl_driver_new (GskGLCommandQueue *command_queue,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
self->glyphs = gsk_gl_glyph_library_new (self);
|
||||
self->icons = gsk_gl_icon_library_new (self);
|
||||
self->shadows = gsk_gl_shadow_library_new (self);
|
||||
self->glyphs_library = gsk_gl_glyph_library_new (self);
|
||||
self->icons_library = gsk_gl_icon_library_new (self);
|
||||
self->shadows_library = gsk_gl_shadow_library_new (self);
|
||||
|
||||
gdk_profiler_end_mark (before, "create GskGLDriver", NULL);
|
||||
|
||||
@@ -518,37 +523,6 @@ failure:
|
||||
return g_steal_pointer (&driver);
|
||||
}
|
||||
|
||||
static GPtrArray *
|
||||
gsk_gl_driver_compact_atlases (GskGLDriver *self)
|
||||
{
|
||||
GPtrArray *removed = NULL;
|
||||
|
||||
g_assert (GSK_IS_GL_DRIVER (self));
|
||||
|
||||
for (guint i = self->atlases->len; i > 0; i--)
|
||||
{
|
||||
GskGLTextureAtlas *atlas = g_ptr_array_index (self->atlases, i - 1);
|
||||
|
||||
if (gsk_gl_texture_atlas_get_unused_ratio (atlas) > MAX_OLD_RATIO)
|
||||
{
|
||||
GSK_NOTE (GLYPH_CACHE,
|
||||
g_message ("Dropping atlas %d (%g.2%% old)", i,
|
||||
100.0 * gsk_gl_texture_atlas_get_unused_ratio (atlas)));
|
||||
if (removed == NULL)
|
||||
removed = g_ptr_array_new_with_free_func ((GDestroyNotify)gsk_gl_texture_atlas_free);
|
||||
g_ptr_array_add (removed, g_ptr_array_steal_index (self->atlases, i - 1));
|
||||
}
|
||||
}
|
||||
|
||||
GSK_NOTE (GLYPH_CACHE, {
|
||||
static guint timestamp;
|
||||
if (timestamp++ % 60 == 0)
|
||||
g_message ("%d atlases", self->atlases->len);
|
||||
});
|
||||
|
||||
return removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_gl_driver_begin_frame:
|
||||
* @self: a `GskGLDriver`
|
||||
@@ -565,7 +539,6 @@ gsk_gl_driver_begin_frame (GskGLDriver *self,
|
||||
GskGLCommandQueue *command_queue)
|
||||
{
|
||||
gint64 last_frame_id;
|
||||
GPtrArray *removed;
|
||||
|
||||
g_return_if_fail (GSK_IS_GL_DRIVER (self));
|
||||
g_return_if_fail (GSK_IS_GL_COMMAND_QUEUE (command_queue));
|
||||
@@ -580,19 +553,14 @@ gsk_gl_driver_begin_frame (GskGLDriver *self,
|
||||
|
||||
gsk_gl_command_queue_begin_frame (self->command_queue);
|
||||
|
||||
/* Compact atlases with too many freed pixels */
|
||||
removed = gsk_gl_driver_compact_atlases (self);
|
||||
|
||||
/* Mark unused pixel regions of the atlases */
|
||||
gsk_gl_texture_library_begin_frame (GSK_GL_TEXTURE_LIBRARY (self->icons),
|
||||
self->current_frame_id,
|
||||
removed);
|
||||
gsk_gl_texture_library_begin_frame (GSK_GL_TEXTURE_LIBRARY (self->glyphs),
|
||||
self->current_frame_id,
|
||||
removed);
|
||||
gsk_gl_texture_library_begin_frame (GSK_GL_TEXTURE_LIBRARY (self->icons_library),
|
||||
self->current_frame_id);
|
||||
gsk_gl_texture_library_begin_frame (GSK_GL_TEXTURE_LIBRARY (self->glyphs_library),
|
||||
self->current_frame_id);
|
||||
|
||||
/* Cleanup old shadows */
|
||||
gsk_gl_shadow_library_begin_frame (self->shadows);
|
||||
gsk_gl_shadow_library_begin_frame (self->shadows_library);
|
||||
|
||||
/* Remove all textures that are from a previous frame or are no
|
||||
* longer used by linked GdkTexture. We do this at the beginning
|
||||
@@ -600,9 +568,6 @@ gsk_gl_driver_begin_frame (GskGLDriver *self,
|
||||
* we block on any resources while delivering our frames.
|
||||
*/
|
||||
gsk_gl_driver_collect_unused_textures (self, last_frame_id - 1);
|
||||
|
||||
/* Now free atlas textures */
|
||||
g_clear_pointer (&removed, g_ptr_array_unref);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -831,7 +796,7 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
|
||||
* to upload data, map to a framebuffer, or other uses which may
|
||||
* modify the texture immediately.
|
||||
*
|
||||
* Typical examples for @format are GK_RGBA8, GL_RGBA16F or GL_RGBA32F.
|
||||
* Typical examples for @format are GL_RGBA8, GL_RGBA16F or GL_RGBA32F.
|
||||
*
|
||||
* Use gsk_gl_driver_release_texture() to release this texture back into
|
||||
* the pool so it may be reused later in the pipeline.
|
||||
@@ -1182,14 +1147,23 @@ void
|
||||
gsk_gl_driver_save_atlases_to_png (GskGLDriver *self,
|
||||
const char *directory)
|
||||
{
|
||||
GPtrArray *atlases;
|
||||
|
||||
g_return_if_fail (GSK_IS_GL_DRIVER (self));
|
||||
|
||||
if (directory == NULL)
|
||||
directory = ".";
|
||||
|
||||
for (guint i = 0; i < self->atlases->len; i++)
|
||||
#define copy_atlases(dst, library) \
|
||||
g_ptr_array_extend(dst, GSK_GL_TEXTURE_LIBRARY(library)->atlases, NULL, NULL)
|
||||
atlases = g_ptr_array_new ();
|
||||
copy_atlases (atlases, self->glyphs_library);
|
||||
copy_atlases (atlases, self->icons_library);
|
||||
#undef copy_atlases
|
||||
|
||||
for (guint i = 0; i < atlases->len; i++)
|
||||
{
|
||||
GskGLTextureAtlas *atlas = g_ptr_array_index (self->atlases, i);
|
||||
GskGLTextureAtlas *atlas = g_ptr_array_index (atlases, i);
|
||||
char *filename = g_strdup_printf ("%s%sframe-%d-atlas-%d.png",
|
||||
directory,
|
||||
G_DIR_SEPARATOR_S,
|
||||
@@ -1198,6 +1172,8 @@ gsk_gl_driver_save_atlases_to_png (GskGLDriver *self,
|
||||
write_atlas_to_png (self, atlas, filename);
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
g_ptr_array_unref (atlases);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -100,17 +100,15 @@ struct _GskGLDriver
|
||||
GskGLCommandQueue *shared_command_queue;
|
||||
GskGLCommandQueue *command_queue;
|
||||
|
||||
GskGLGlyphLibrary *glyphs;
|
||||
GskGLIconLibrary *icons;
|
||||
GskGLShadowLibrary *shadows;
|
||||
GskGLGlyphLibrary *glyphs_library;
|
||||
GskGLIconLibrary *icons_library;
|
||||
GskGLShadowLibrary *shadows_library;
|
||||
|
||||
GArray *texture_pool;
|
||||
GHashTable *textures;
|
||||
GHashTable *key_to_texture_id;
|
||||
GHashTable *texture_id_to_key;
|
||||
|
||||
GPtrArray *atlases;
|
||||
|
||||
GHashTable *shader_cache;
|
||||
|
||||
GArray *autorelease_framebuffers;
|
||||
@@ -184,7 +182,6 @@ void gsk_gl_driver_add_texture_slices (GskGLDriver *s
|
||||
GskGLProgram * gsk_gl_driver_lookup_shader (GskGLDriver *self,
|
||||
GskGLShader *shader,
|
||||
GError **error);
|
||||
GskGLTextureAtlas * gsk_gl_driver_create_atlas (GskGLDriver *self);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
void gsk_gl_driver_save_atlases_to_png (GskGLDriver *self,
|
||||
|
||||
@@ -84,15 +84,64 @@ gsk_gl_glyph_value_free (gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_glyph_library_begin_frame (GskGLTextureLibrary *library,
|
||||
gint64 frame_id,
|
||||
GPtrArray *removed_atlases)
|
||||
gsk_gl_glyph_library_clear_cache (GskGLTextureLibrary *library)
|
||||
{
|
||||
GskGLGlyphLibrary *self = (GskGLGlyphLibrary *)library;
|
||||
|
||||
g_assert (GSK_IS_GL_GLYPH_LIBRARY (self));
|
||||
|
||||
memset (self->front, 0, sizeof self->front);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_glyph_library_init_atlas (GskGLTextureLibrary *self,
|
||||
GskGLTextureAtlas *atlas)
|
||||
{
|
||||
gboolean packed G_GNUC_UNUSED;
|
||||
int x, y;
|
||||
guint gl_format;
|
||||
guint gl_type;
|
||||
guint8 pixel_data[4 * 3 * 3];
|
||||
|
||||
g_assert (GSK_IS_GL_GLYPH_LIBRARY (self));
|
||||
g_assert (atlas != NULL);
|
||||
|
||||
/* Insert a single pixel at 0,0 for use in coloring */
|
||||
|
||||
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
|
||||
"Initializing Atlas");
|
||||
|
||||
packed = gsk_gl_texture_library_allocate (self, atlas, 3, 3, &x, &y);
|
||||
g_assert (packed);
|
||||
g_assert (x == 0 && y == 0);
|
||||
|
||||
memset (pixel_data, 255, sizeof pixel_data);
|
||||
|
||||
if (gdk_gl_context_get_use_es (gdk_gl_context_get_current ()))
|
||||
{
|
||||
gl_format = GL_RGBA;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_format = GL_BGRA;
|
||||
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
|
||||
glBindTexture (GL_TEXTURE_2D, atlas->texture_id);
|
||||
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
0, 0,
|
||||
3, 3,
|
||||
gl_format, gl_type,
|
||||
pixel_data);
|
||||
|
||||
gdk_gl_context_pop_debug_group (gdk_gl_context_get_current ());
|
||||
|
||||
self->driver->command_queue->n_uploads++;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gsk_gl_glyph_library_finalize (GObject *object)
|
||||
{
|
||||
@@ -111,7 +160,8 @@ gsk_gl_glyph_library_class_init (GskGLGlyphLibraryClass *klass)
|
||||
|
||||
object_class->finalize = gsk_gl_glyph_library_finalize;
|
||||
|
||||
library_class->begin_frame = gsk_gl_glyph_library_begin_frame;
|
||||
library_class->clear_cache = gsk_gl_glyph_library_clear_cache;
|
||||
library_class->init_atlas = gsk_gl_glyph_library_init_atlas;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+16
-16
@@ -1,71 +1,71 @@
|
||||
GSK_GL_DEFINE_PROGRAM (blend,
|
||||
"/org/gtk/libgsk/gl/blend.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("blend.glsl")),
|
||||
GSK_GL_ADD_UNIFORM (1, BLEND_SOURCE2, u_source2)
|
||||
GSK_GL_ADD_UNIFORM (2, BLEND_MODE, u_mode))
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (blit,
|
||||
"/org/gtk/libgsk/gl/blit.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("blit.glsl")),
|
||||
GSK_GL_NO_UNIFORMS)
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (blur,
|
||||
"/org/gtk/libgsk/gl/blur.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("blur.glsl")),
|
||||
GSK_GL_ADD_UNIFORM (1, BLUR_RADIUS, u_blur_radius)
|
||||
GSK_GL_ADD_UNIFORM (2, BLUR_SIZE, u_blur_size)
|
||||
GSK_GL_ADD_UNIFORM (3, BLUR_DIR, u_blur_dir))
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (border,
|
||||
"/org/gtk/libgsk/gl/border.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("border.glsl")),
|
||||
GSK_GL_ADD_UNIFORM (1, BORDER_WIDTHS, u_widths)
|
||||
GSK_GL_ADD_UNIFORM (2, BORDER_OUTLINE_RECT, u_outline_rect))
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (color,
|
||||
"/org/gtk/libgsk/gl/color.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("color.glsl")),
|
||||
GSK_GL_NO_UNIFORMS)
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (coloring,
|
||||
"/org/gtk/libgsk/gl/coloring.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("coloring.glsl")),
|
||||
GSK_GL_NO_UNIFORMS)
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (color_matrix,
|
||||
"/org/gtk/libgsk/gl/color_matrix.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("color_matrix.glsl")),
|
||||
GSK_GL_ADD_UNIFORM (1, COLOR_MATRIX_COLOR_MATRIX, u_color_matrix)
|
||||
GSK_GL_ADD_UNIFORM (2, COLOR_MATRIX_COLOR_OFFSET, u_color_offset))
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (conic_gradient,
|
||||
"/org/gtk/libgsk/gl/conic_gradient.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("conic_gradient.glsl")),
|
||||
GSK_GL_ADD_UNIFORM (1, CONIC_GRADIENT_COLOR_STOPS, u_color_stops)
|
||||
GSK_GL_ADD_UNIFORM (2, CONIC_GRADIENT_NUM_COLOR_STOPS, u_num_color_stops)
|
||||
GSK_GL_ADD_UNIFORM (3, CONIC_GRADIENT_GEOMETRY, u_geometry))
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (cross_fade,
|
||||
"/org/gtk/libgsk/gl/cross_fade.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("cross_fade.glsl")),
|
||||
GSK_GL_ADD_UNIFORM (1, CROSS_FADE_PROGRESS, u_progress)
|
||||
GSK_GL_ADD_UNIFORM (2, CROSS_FADE_SOURCE2, u_source2))
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (filled_border,
|
||||
"/org/gtk/libgsk/gl/filled_border.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("filled_border.glsl")),
|
||||
GSK_GL_ADD_UNIFORM (1, FILLED_BORDER_WIDTHS, u_widths)
|
||||
GSK_GL_ADD_UNIFORM (2, FILLED_BORDER_OUTLINE_RECT, u_outline_rect))
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (inset_shadow,
|
||||
"/org/gtk/libgsk/gl/inset_shadow.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("inset_shadow.glsl")),
|
||||
GSK_GL_ADD_UNIFORM (1, INSET_SHADOW_SPREAD, u_spread)
|
||||
GSK_GL_ADD_UNIFORM (2, INSET_SHADOW_OFFSET, u_offset)
|
||||
GSK_GL_ADD_UNIFORM (3, INSET_SHADOW_OUTLINE_RECT, u_outline_rect))
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (linear_gradient,
|
||||
"/org/gtk/libgsk/gl/linear_gradient.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("linear_gradient.glsl")),
|
||||
GSK_GL_ADD_UNIFORM (1, LINEAR_GRADIENT_COLOR_STOPS, u_color_stops)
|
||||
GSK_GL_ADD_UNIFORM (2, LINEAR_GRADIENT_NUM_COLOR_STOPS, u_num_color_stops)
|
||||
GSK_GL_ADD_UNIFORM (3, LINEAR_GRADIENT_POINTS, u_points)
|
||||
GSK_GL_ADD_UNIFORM (4, LINEAR_GRADIENT_REPEAT, u_repeat))
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (outset_shadow,
|
||||
"/org/gtk/libgsk/gl/outset_shadow.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("outset_shadow.glsl")),
|
||||
GSK_GL_ADD_UNIFORM (1, OUTSET_SHADOW_OUTLINE_RECT, u_outline_rect))
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (radial_gradient,
|
||||
"/org/gtk/libgsk/gl/radial_gradient.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("radial_gradient.glsl")),
|
||||
GSK_GL_ADD_UNIFORM (1, RADIAL_GRADIENT_COLOR_STOPS, u_color_stops)
|
||||
GSK_GL_ADD_UNIFORM (2, RADIAL_GRADIENT_NUM_COLOR_STOPS, u_num_color_stops)
|
||||
GSK_GL_ADD_UNIFORM (3, RADIAL_GRADIENT_REPEAT, u_repeat)
|
||||
@@ -73,12 +73,12 @@ GSK_GL_DEFINE_PROGRAM (radial_gradient,
|
||||
GSK_GL_ADD_UNIFORM (5, RADIAL_GRADIENT_GEOMETRY, u_geometry))
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (repeat,
|
||||
"/org/gtk/libgsk/gl/repeat.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("repeat.glsl")),
|
||||
GSK_GL_ADD_UNIFORM (1, REPEAT_CHILD_BOUNDS, u_child_bounds)
|
||||
GSK_GL_ADD_UNIFORM (2, REPEAT_TEXTURE_RECT, u_texture_rect))
|
||||
|
||||
GSK_GL_DEFINE_PROGRAM (unblurred_outset_shadow,
|
||||
"/org/gtk/libgsk/gl/unblurred_outset_shadow.glsl",
|
||||
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("unblurred_outset_shadow.glsl")),
|
||||
GSK_GL_ADD_UNIFORM (1, UNBLURRED_OUTSET_SHADOW_SPREAD, u_spread)
|
||||
GSK_GL_ADD_UNIFORM (2, UNBLURRED_OUTSET_SHADOW_OFFSET, u_offset)
|
||||
GSK_GL_ADD_UNIFORM (3, UNBLURRED_OUTSET_SHADOW_OUTLINE_RECT, u_outline_rect))
|
||||
|
||||
+37
-3
@@ -306,10 +306,9 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
|
||||
GskGLRenderer *self = (GskGLRenderer *)renderer;
|
||||
GskGLRenderTarget *render_target;
|
||||
GskGLRenderJob *job;
|
||||
GdkTexture *texture = NULL;
|
||||
GdkTexture *texture;
|
||||
guint texture_id;
|
||||
int width;
|
||||
int height;
|
||||
int width, height, max_size;
|
||||
int format;
|
||||
|
||||
g_assert (GSK_IS_GL_RENDERER (renderer));
|
||||
@@ -317,6 +316,37 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
|
||||
|
||||
width = ceilf (viewport->size.width);
|
||||
height = ceilf (viewport->size.height);
|
||||
max_size = self->command_queue->max_texture_size;
|
||||
if (width > max_size || height > max_size)
|
||||
{
|
||||
gsize x, y, size, stride;
|
||||
GBytes *bytes;
|
||||
guchar *data;
|
||||
|
||||
stride = width * 4;
|
||||
size = stride * height;
|
||||
data = g_malloc_n (stride, height);
|
||||
|
||||
for (y = 0; y < height; y += max_size)
|
||||
{
|
||||
for (x = 0; x < width; x += max_size)
|
||||
{
|
||||
texture = gsk_gl_renderer_render_texture (renderer, root,
|
||||
&GRAPHENE_RECT_INIT (x, y,
|
||||
MIN (max_size, viewport->size.width - x),
|
||||
MIN (max_size, viewport->size.height - y)));
|
||||
gdk_texture_download (texture,
|
||||
data + stride * y + x * 4,
|
||||
stride);
|
||||
g_object_unref (texture);
|
||||
}
|
||||
}
|
||||
|
||||
bytes = g_bytes_new_take (data, size);
|
||||
texture = gdk_memory_texture_new (width, height, GDK_MEMORY_DEFAULT, bytes, stride);
|
||||
g_bytes_unref (bytes);
|
||||
return texture;
|
||||
}
|
||||
|
||||
format = gsk_render_node_prefers_high_depth (root) ? GL_RGBA32F : GL_RGBA8;
|
||||
|
||||
@@ -342,6 +372,10 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
|
||||
|
||||
gsk_gl_driver_after_frame (self->driver);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
return g_steal_pointer (&texture);
|
||||
}
|
||||
|
||||
+97
-113
@@ -2512,7 +2512,9 @@ gsk_gl_render_job_visit_blurred_outset_shadow_node (GskGLRenderJob *job,
|
||||
scaled_outline.corner[i].height *= scale_y;
|
||||
}
|
||||
|
||||
cached_tid = gsk_gl_shadow_library_lookup (job->driver->shadows, &scaled_outline, blur_radius);
|
||||
cached_tid = gsk_gl_shadow_library_lookup (job->driver->shadows_library,
|
||||
&scaled_outline,
|
||||
blur_radius);
|
||||
|
||||
if (cached_tid == 0)
|
||||
{
|
||||
@@ -2574,7 +2576,7 @@ gsk_gl_render_job_visit_blurred_outset_shadow_node (GskGLRenderJob *job,
|
||||
blur_radius * scale_x,
|
||||
blur_radius * scale_y);
|
||||
|
||||
gsk_gl_shadow_library_insert (job->driver->shadows,
|
||||
gsk_gl_shadow_library_insert (job->driver->shadows_library,
|
||||
&scaled_outline,
|
||||
blur_radius,
|
||||
blurred_texture_id);
|
||||
@@ -2858,58 +2860,6 @@ gsk_gl_render_job_visit_cross_fade_node (GskGLRenderJob *job,
|
||||
gsk_gl_render_job_end_draw (job);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_non_branching (const GskRenderNode *node)
|
||||
{
|
||||
switch ((int)gsk_render_node_get_node_type (node))
|
||||
{
|
||||
case GSK_COLOR_NODE:
|
||||
case GSK_LINEAR_GRADIENT_NODE:
|
||||
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
||||
case GSK_RADIAL_GRADIENT_NODE:
|
||||
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
|
||||
case GSK_CONIC_GRADIENT_NODE:
|
||||
case GSK_BORDER_NODE:
|
||||
case GSK_TEXTURE_NODE:
|
||||
case GSK_INSET_SHADOW_NODE:
|
||||
case GSK_OUTSET_SHADOW_NODE:
|
||||
case GSK_TEXT_NODE:
|
||||
case GSK_CAIRO_NODE:
|
||||
return TRUE;
|
||||
|
||||
case GSK_TRANSFORM_NODE:
|
||||
return is_non_branching (gsk_transform_node_get_child (node));
|
||||
|
||||
case GSK_OPACITY_NODE:
|
||||
return is_non_branching (gsk_opacity_node_get_child (node));
|
||||
|
||||
case GSK_COLOR_MATRIX_NODE:
|
||||
return is_non_branching (gsk_color_matrix_node_get_child (node));
|
||||
|
||||
case GSK_CLIP_NODE:
|
||||
return is_non_branching (gsk_clip_node_get_child (node));
|
||||
|
||||
case GSK_ROUNDED_CLIP_NODE:
|
||||
return is_non_branching (gsk_rounded_clip_node_get_child (node));
|
||||
|
||||
case GSK_SHADOW_NODE:
|
||||
return is_non_branching (gsk_shadow_node_get_child (node));
|
||||
|
||||
case GSK_BLUR_NODE:
|
||||
return is_non_branching (gsk_shadow_node_get_child (node));
|
||||
|
||||
case GSK_DEBUG_NODE:
|
||||
return is_non_branching (gsk_debug_node_get_child (node));
|
||||
|
||||
case GSK_CONTAINER_NODE:
|
||||
return gsk_container_node_get_n_children (node) == 1 &&
|
||||
is_non_branching (gsk_container_node_get_child (node, 0));
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_gl_render_job_visit_opacity_node (GskGLRenderJob *job,
|
||||
const GskRenderNode *node)
|
||||
@@ -2922,11 +2872,7 @@ gsk_gl_render_job_visit_opacity_node (GskGLRenderJob *job,
|
||||
{
|
||||
float prev_alpha = gsk_gl_render_job_set_alpha (job, new_alpha);
|
||||
|
||||
/* Handle a few easy cases without offscreen. We bail out
|
||||
* as soon as we see nodes with multiple children - in theory,
|
||||
* we would only need offscreens for overlapping children.
|
||||
*/
|
||||
if (is_non_branching (child))
|
||||
if (!gsk_render_node_use_offscreen_for_opacity (child))
|
||||
{
|
||||
gsk_gl_render_job_visit_node (job, child);
|
||||
gsk_gl_render_job_set_alpha (job, prev_alpha);
|
||||
@@ -2996,7 +2942,7 @@ gsk_gl_render_job_visit_text_node (GskGLRenderJob *job,
|
||||
guint num_glyphs = gsk_text_node_get_num_glyphs (node);
|
||||
float x = offset->x + job->offset_x;
|
||||
float y = offset->y + job->offset_y;
|
||||
GskGLGlyphLibrary *library = job->driver->glyphs;
|
||||
GskGLGlyphLibrary *library = job->driver->glyphs_library;
|
||||
GskGLCommandBatch *batch;
|
||||
int x_position = 0;
|
||||
GskGLGlyphKey lookup;
|
||||
@@ -3499,14 +3445,14 @@ gsk_gl_render_job_upload_texture (GskGLRenderJob *job,
|
||||
GdkTexture *texture,
|
||||
GskGLRenderOffscreen *offscreen)
|
||||
{
|
||||
if (gsk_gl_texture_library_can_cache ((GskGLTextureLibrary *)job->driver->icons,
|
||||
if (gsk_gl_texture_library_can_cache ((GskGLTextureLibrary *)job->driver->icons_library,
|
||||
texture->width,
|
||||
texture->height) &&
|
||||
!GDK_IS_GL_TEXTURE (texture))
|
||||
{
|
||||
const GskGLIconData *icon_data;
|
||||
|
||||
gsk_gl_icon_library_lookup_or_add (job->driver->icons, texture, &icon_data);
|
||||
gsk_gl_icon_library_lookup_or_add (job->driver->icons_library, texture, &icon_data);
|
||||
offscreen->texture_id = GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (icon_data);
|
||||
memcpy (&offscreen->area, &icon_data->entry.area, sizeof offscreen->area);
|
||||
}
|
||||
@@ -3869,7 +3815,6 @@ gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob *job,
|
||||
|
||||
filter = offscreen->linear_filter ? GL_LINEAR : GL_NEAREST;
|
||||
|
||||
/* Check if we've already cached the drawn texture. */
|
||||
key.pointer = node;
|
||||
key.pointer_is_child = TRUE; /* Don't conflict with the child using the cache too */
|
||||
key.parent_rect = *offscreen->bounds;
|
||||
@@ -3877,61 +3822,111 @@ gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob *job,
|
||||
key.scale_y = job->scale_y;
|
||||
key.filter = filter;
|
||||
|
||||
cached_id = gsk_gl_driver_lookup_texture (job->driver, &key);
|
||||
float offset_x = job->offset_x;
|
||||
float offset_y = job->offset_y;
|
||||
gboolean flipped_x = job->scale_x < 0;
|
||||
gboolean flipped_y = job->scale_y < 0;
|
||||
graphene_rect_t viewport;
|
||||
|
||||
if (cached_id != 0)
|
||||
if (flipped_x || flipped_y)
|
||||
{
|
||||
offscreen->texture_id = cached_id;
|
||||
init_full_texture_region (offscreen);
|
||||
/* We didn't render it offscreen, but hand out an offscreen texture id */
|
||||
offscreen->was_offscreen = TRUE;
|
||||
return TRUE;
|
||||
GskTransform *transform = gsk_transform_scale (NULL,
|
||||
flipped_x ? -1 : 1,
|
||||
flipped_y ? -1 : 1);
|
||||
gsk_gl_render_job_push_modelview (job, transform);
|
||||
}
|
||||
|
||||
float scaled_width;
|
||||
float scaled_height;
|
||||
float downscale_x = 1;
|
||||
float downscale_y = 1;
|
||||
gsk_gl_render_job_transform_bounds (job, offscreen->bounds, &viewport);
|
||||
|
||||
g_assert (job->command_queue->max_texture_size > 0);
|
||||
float aligned_x = floorf (viewport.origin.x);
|
||||
float padding_left = viewport.origin.x - aligned_x;
|
||||
float aligned_width = ceilf (viewport.size.width + padding_left);
|
||||
float padding_right = aligned_width - viewport.size.width - padding_left;
|
||||
|
||||
float aligned_y = floorf (viewport.origin.y);
|
||||
float padding_top = viewport.origin.y - aligned_y;
|
||||
float aligned_height = ceilf (viewport.size.height + padding_top);
|
||||
float padding_bottom = aligned_height - viewport.size.height - padding_top;
|
||||
|
||||
/* Tweak the scale factor so that the required texture doesn't
|
||||
* exceed the max texture limit. This will render with a lower
|
||||
* resolution, but this is better than clipping.
|
||||
*/
|
||||
{
|
||||
int max_texture_size = job->command_queue->max_texture_size;
|
||||
|
||||
scaled_width = ceilf (offscreen->bounds->size.width * fabs (job->scale_x));
|
||||
if (scaled_width > max_texture_size)
|
||||
{
|
||||
downscale_x = (float)max_texture_size / scaled_width;
|
||||
scaled_width = max_texture_size;
|
||||
}
|
||||
if (job->scale_x < 0)
|
||||
downscale_x = -downscale_x;
|
||||
g_assert (job->command_queue->max_texture_size > 0);
|
||||
|
||||
scaled_height = ceilf (offscreen->bounds->size.height * fabs (job->scale_y));
|
||||
if (scaled_height > max_texture_size)
|
||||
{
|
||||
downscale_y = (float)max_texture_size / scaled_height;
|
||||
scaled_height = max_texture_size;
|
||||
}
|
||||
if (job->scale_y < 0)
|
||||
downscale_y = -downscale_y;
|
||||
}
|
||||
float downscale_x = 1;
|
||||
float downscale_y = 1;
|
||||
int texture_width;
|
||||
int texture_height;
|
||||
int max_texture_size = job->command_queue->max_texture_size;
|
||||
|
||||
if (aligned_width > max_texture_size)
|
||||
downscale_x = (float)max_texture_size / viewport.size.width;
|
||||
|
||||
if (aligned_height > max_texture_size)
|
||||
downscale_y = (float)max_texture_size / viewport.size.height;
|
||||
|
||||
if (downscale_x != 1 || downscale_y != 1)
|
||||
{
|
||||
GskTransform *transform = gsk_transform_scale (NULL, downscale_x, downscale_y);
|
||||
gsk_gl_render_job_push_modelview (job, transform);
|
||||
gsk_gl_render_job_transform_bounds (job, offscreen->bounds, &viewport);
|
||||
}
|
||||
|
||||
if (downscale_x == 1)
|
||||
{
|
||||
viewport.origin.x = aligned_x;
|
||||
viewport.size.width = aligned_width;
|
||||
offscreen->area.x = padding_left / aligned_width;
|
||||
offscreen->area.x2 = 1.0f - (padding_right / aligned_width);
|
||||
texture_width = aligned_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
offscreen->area.x = 0;
|
||||
offscreen->area.x2 = 1;
|
||||
texture_width = max_texture_size;
|
||||
}
|
||||
|
||||
if (downscale_y == 1)
|
||||
{
|
||||
viewport.origin.y = aligned_y;
|
||||
viewport.size.height = aligned_height;
|
||||
offscreen->area.y = padding_bottom / aligned_height;
|
||||
offscreen->area.y2 = 1.0f - padding_top / aligned_height;
|
||||
texture_height = aligned_height;
|
||||
}
|
||||
else
|
||||
{
|
||||
offscreen->area.y = 0;
|
||||
offscreen->area.y2 = 1;
|
||||
texture_height = max_texture_size;
|
||||
}
|
||||
|
||||
/* Check if we've already cached the drawn texture. */
|
||||
cached_id = gsk_gl_driver_lookup_texture (job->driver, &key);
|
||||
|
||||
if (cached_id != 0)
|
||||
{
|
||||
if (downscale_x != 1 || downscale_y != 1)
|
||||
gsk_gl_render_job_pop_modelview (job);
|
||||
if (flipped_x || flipped_y)
|
||||
gsk_gl_render_job_pop_modelview (job);
|
||||
offscreen->texture_id = cached_id;
|
||||
/* We didn't render it offscreen, but hand out an offscreen texture id */
|
||||
offscreen->was_offscreen = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GskGLRenderTarget *render_target;
|
||||
graphene_matrix_t prev_projection;
|
||||
graphene_rect_t prev_viewport;
|
||||
graphene_rect_t viewport;
|
||||
float offset_x = job->offset_x;
|
||||
float offset_y = job->offset_y;
|
||||
float prev_alpha;
|
||||
guint prev_fbo;
|
||||
|
||||
if (!gsk_gl_driver_create_render_target (job->driver,
|
||||
scaled_width, scaled_height,
|
||||
texture_width, texture_height,
|
||||
get_target_format (job, node),
|
||||
filter, filter,
|
||||
&render_target))
|
||||
@@ -3953,19 +3948,6 @@ gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob *job,
|
||||
render_target->framebuffer_id);
|
||||
}
|
||||
|
||||
if (downscale_x != 1 || downscale_y != 1)
|
||||
{
|
||||
GskTransform *transform = gsk_transform_scale (NULL, downscale_x, downscale_y);
|
||||
gsk_gl_render_job_push_modelview (job, transform);
|
||||
gsk_transform_unref (transform);
|
||||
}
|
||||
|
||||
gsk_gl_render_job_transform_bounds (job, offscreen->bounds, &viewport);
|
||||
/* Code above will scale the size with the scale we use in the render ops,
|
||||
* but for the viewport size, we need our own size limited by the texture size */
|
||||
viewport.size.width = scaled_width;
|
||||
viewport.size.height = scaled_height;
|
||||
|
||||
gsk_gl_render_job_set_viewport (job, &viewport, &prev_viewport);
|
||||
gsk_gl_render_job_set_projection_from_rect (job, &job->viewport, &prev_projection);
|
||||
prev_alpha = gsk_gl_render_job_set_alpha (job, 1.0f);
|
||||
@@ -3983,6 +3965,10 @@ gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob *job,
|
||||
|
||||
if (downscale_x != 1 || downscale_y != 1)
|
||||
gsk_gl_render_job_pop_modelview (job);
|
||||
|
||||
if (flipped_x || flipped_y)
|
||||
gsk_gl_render_job_pop_modelview (job);
|
||||
|
||||
gsk_gl_render_job_set_viewport (job, &prev_viewport, NULL);
|
||||
gsk_gl_render_job_set_projection (job, &prev_projection);
|
||||
gsk_gl_render_job_set_alpha (job, prev_alpha);
|
||||
@@ -3996,8 +3982,6 @@ gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob *job,
|
||||
render_target,
|
||||
FALSE);
|
||||
|
||||
init_full_texture_region (offscreen);
|
||||
|
||||
if (!offscreen->do_not_cache)
|
||||
gsk_gl_driver_cache_texture (job->driver, &key, offscreen->texture_id);
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
|
||||
struct _GskGLShadowLibrary
|
||||
{
|
||||
GObject parent_instance;
|
||||
GObject parent_instance;
|
||||
GskGLDriver *driver;
|
||||
GArray *shadows;
|
||||
GArray *shadows;
|
||||
};
|
||||
|
||||
typedef struct _Shadow
|
||||
|
||||
+318
-158
@@ -27,7 +27,10 @@
|
||||
#include "gskgldriverprivate.h"
|
||||
#include "gskgltexturelibraryprivate.h"
|
||||
|
||||
#define MAX_FRAME_AGE 60
|
||||
#define DEFAULT_MAX_FRAME_AGE 60
|
||||
#define DEFAULT_ATLAS_WIDTH 512
|
||||
#define DEFAULT_ATLAS_HEIGHT 512
|
||||
#define MAX_OLD_RATIO 0.5
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (GskGLTextureLibrary, gsk_gl_texture_library, G_TYPE_OBJECT)
|
||||
|
||||
@@ -39,6 +42,149 @@ enum {
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
static void
|
||||
gsk_gl_texture_atlas_free (GskGLTextureAtlas *atlas)
|
||||
{
|
||||
if (atlas->texture_id != 0)
|
||||
{
|
||||
glDeleteTextures (1, &atlas->texture_id);
|
||||
atlas->texture_id = 0;
|
||||
}
|
||||
|
||||
g_clear_pointer (&atlas->nodes, g_free);
|
||||
g_slice_free (GskGLTextureAtlas, atlas);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_gl_texture_library_real_compact (GskGLTextureLibrary *self,
|
||||
gint64 frame_id)
|
||||
{
|
||||
GPtrArray *removed = NULL;
|
||||
gboolean ret = FALSE;
|
||||
gboolean periodic_scan;
|
||||
|
||||
g_assert (GSK_IS_GL_TEXTURE_LIBRARY (self));
|
||||
|
||||
periodic_scan = (self->max_frame_age > 0 &&
|
||||
(frame_id % self->max_frame_age) == 0);
|
||||
|
||||
for (guint i = self->atlases->len; i > 0; i--)
|
||||
{
|
||||
GskGLTextureAtlas *atlas = g_ptr_array_index (self->atlases, i - 1);
|
||||
|
||||
if (gsk_gl_texture_atlas_get_unused_ratio (atlas) > MAX_OLD_RATIO)
|
||||
{
|
||||
GSK_NOTE (GLYPH_CACHE,
|
||||
g_message ("Dropping atlas %d (%g.2%% old)", i,
|
||||
100.0 * gsk_gl_texture_atlas_get_unused_ratio (atlas)));
|
||||
if (removed == NULL)
|
||||
removed = g_ptr_array_new_with_free_func ((GDestroyNotify)gsk_gl_texture_atlas_free);
|
||||
g_ptr_array_add (removed, g_ptr_array_steal_index (self->atlases, i - 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (periodic_scan || removed != NULL)
|
||||
{
|
||||
GskGLTextureAtlasEntry *entry;
|
||||
GHashTableIter iter;
|
||||
guint dropped = 0;
|
||||
guint atlased = 0;
|
||||
|
||||
g_hash_table_iter_init (&iter, self->hash_table);
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&entry))
|
||||
{
|
||||
if (entry->is_atlased)
|
||||
{
|
||||
if (removed && g_ptr_array_find (removed, entry->atlas, NULL))
|
||||
{
|
||||
g_hash_table_iter_remove (&iter);
|
||||
dropped++;
|
||||
}
|
||||
else if (periodic_scan)
|
||||
{
|
||||
gsk_gl_texture_atlas_entry_mark_unused (entry);
|
||||
entry->accessed = FALSE;
|
||||
if (entry->is_atlased)
|
||||
atlased++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!entry->accessed)
|
||||
{
|
||||
gsk_gl_driver_release_texture (self->driver, entry->texture);
|
||||
g_hash_table_iter_remove (&iter);
|
||||
dropped++;
|
||||
}
|
||||
|
||||
if (periodic_scan)
|
||||
entry->accessed = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
GSK_NOTE (GLYPH_CACHE, g_message ("%s: Dropped %d individual items",
|
||||
G_OBJECT_TYPE_NAME (self),
|
||||
dropped);
|
||||
g_message ("%s: %d items cached (%d atlased, %d individually)",
|
||||
G_OBJECT_TYPE_NAME (self),
|
||||
g_hash_table_size (self->hash_table),
|
||||
atlased,
|
||||
g_hash_table_size (self->hash_table) - atlased));
|
||||
|
||||
if (dropped > 0)
|
||||
gsk_gl_texture_library_clear_cache (self);
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
g_clear_pointer (&removed, g_ptr_array_unref);
|
||||
}
|
||||
|
||||
GSK_NOTE (GLYPH_CACHE, {
|
||||
static gint64 last_message;
|
||||
gint64 now = g_get_monotonic_time ();
|
||||
if (now - last_message > G_USEC_PER_SEC)
|
||||
{
|
||||
last_message = now;
|
||||
g_message ("%s contains %d atlases",
|
||||
G_OBJECT_TYPE_NAME (self),
|
||||
self->atlases->len);
|
||||
}
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_gl_texture_library_real_allocate (GskGLTextureLibrary *self,
|
||||
GskGLTextureAtlas *atlas,
|
||||
int width,
|
||||
int height,
|
||||
int *out_x,
|
||||
int *out_y)
|
||||
{
|
||||
stbrp_rect rect;
|
||||
|
||||
g_assert (GSK_IS_GL_TEXTURE_LIBRARY (self));
|
||||
g_assert (atlas != NULL);
|
||||
g_assert (width > 0);
|
||||
g_assert (height > 0);
|
||||
g_assert (out_x != NULL);
|
||||
g_assert (out_y != NULL);
|
||||
|
||||
rect.w = width;
|
||||
rect.h = height;
|
||||
|
||||
stbrp_pack_rects (&atlas->context, &rect, 1);
|
||||
|
||||
if (rect.was_packed)
|
||||
{
|
||||
*out_x = rect.x;
|
||||
*out_y = rect.y;
|
||||
}
|
||||
|
||||
return rect.was_packed;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_texture_library_constructed (GObject *object)
|
||||
{
|
||||
@@ -52,6 +198,7 @@ gsk_gl_texture_library_dispose (GObject *object)
|
||||
{
|
||||
GskGLTextureLibrary *self = (GskGLTextureLibrary *)object;
|
||||
|
||||
g_clear_pointer (&self->atlases, g_ptr_array_unref);
|
||||
g_clear_object (&self->driver);
|
||||
|
||||
G_OBJECT_CLASS (gsk_gl_texture_library_parent_class)->dispose (object);
|
||||
@@ -105,6 +252,9 @@ gsk_gl_texture_library_class_init (GskGLTextureLibraryClass *klass)
|
||||
object_class->get_property = gsk_gl_texture_library_get_property;
|
||||
object_class->set_property = gsk_gl_texture_library_set_property;
|
||||
|
||||
klass->compact = gsk_gl_texture_library_real_compact;
|
||||
klass->allocate = gsk_gl_texture_library_real_allocate;
|
||||
|
||||
properties [PROP_DRIVER] =
|
||||
g_param_spec_object ("driver",
|
||||
"Driver",
|
||||
@@ -118,6 +268,10 @@ gsk_gl_texture_library_class_init (GskGLTextureLibraryClass *klass)
|
||||
static void
|
||||
gsk_gl_texture_library_init (GskGLTextureLibrary *self)
|
||||
{
|
||||
self->max_frame_age = DEFAULT_MAX_FRAME_AGE;
|
||||
self->atlas_width = DEFAULT_ATLAS_WIDTH;
|
||||
self->atlas_height = DEFAULT_ATLAS_HEIGHT;
|
||||
self->atlases = g_ptr_array_new_with_free_func ((GDestroyNotify)gsk_gl_texture_atlas_free);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -136,78 +290,14 @@ gsk_gl_texture_library_set_funcs (GskGLTextureLibrary *self,
|
||||
|
||||
void
|
||||
gsk_gl_texture_library_begin_frame (GskGLTextureLibrary *self,
|
||||
gint64 frame_id,
|
||||
GPtrArray *removed_atlases)
|
||||
gint64 frame_id)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
|
||||
g_return_if_fail (GSK_IS_GL_TEXTURE_LIBRARY (self));
|
||||
|
||||
gsk_gl_texture_library_compact (self, frame_id);
|
||||
|
||||
if (GSK_GL_TEXTURE_LIBRARY_GET_CLASS (self)->begin_frame)
|
||||
GSK_GL_TEXTURE_LIBRARY_GET_CLASS (self)->begin_frame (self, frame_id, removed_atlases);
|
||||
|
||||
if (removed_atlases != NULL)
|
||||
{
|
||||
GskGLTextureAtlasEntry *entry;
|
||||
guint dropped = 0;
|
||||
|
||||
g_hash_table_iter_init (&iter, self->hash_table);
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&entry))
|
||||
{
|
||||
if (entry->is_atlased)
|
||||
{
|
||||
for (guint i = 0; i < removed_atlases->len; i++)
|
||||
{
|
||||
GskGLTextureAtlas *atlas = g_ptr_array_index (removed_atlases, i);
|
||||
|
||||
if (atlas == entry->atlas)
|
||||
{
|
||||
g_hash_table_iter_remove (&iter);
|
||||
dropped++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GSK_NOTE (GLYPH_CACHE,
|
||||
if (dropped > 0)
|
||||
g_message ("%s: Dropped %d items",
|
||||
G_OBJECT_TYPE_NAME (self), dropped));
|
||||
}
|
||||
|
||||
if (frame_id % MAX_FRAME_AGE == 0)
|
||||
{
|
||||
GskGLTextureAtlasEntry *entry;
|
||||
int atlased = 0;
|
||||
int dropped = 0;
|
||||
|
||||
g_hash_table_iter_init (&iter, self->hash_table);
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&entry))
|
||||
{
|
||||
if (!entry->is_atlased && !entry->accessed)
|
||||
{
|
||||
gsk_gl_driver_release_texture (self->driver, entry->texture);
|
||||
g_hash_table_iter_remove (&iter);
|
||||
dropped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
gsk_gl_texture_atlas_entry_mark_unused (entry);
|
||||
entry->accessed = FALSE;
|
||||
if (entry->is_atlased)
|
||||
atlased++;
|
||||
}
|
||||
|
||||
GSK_NOTE (GLYPH_CACHE, g_message ("%s: Dropped %d individual items",
|
||||
G_OBJECT_TYPE_NAME (self),
|
||||
dropped);
|
||||
g_message ("%s: %d items cached (%d atlased, %d individually)",
|
||||
G_OBJECT_TYPE_NAME (self),
|
||||
g_hash_table_size (self->hash_table),
|
||||
atlased,
|
||||
g_hash_table_size (self->hash_table) - atlased));
|
||||
}
|
||||
GSK_GL_TEXTURE_LIBRARY_GET_CLASS (self)->begin_frame (self, frame_id);
|
||||
}
|
||||
|
||||
static GskGLTexture *
|
||||
@@ -234,90 +324,29 @@ gsk_gl_texture_library_pack_one (GskGLTextureLibrary *self,
|
||||
return texture;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
gsk_gl_texture_atlas_pack (GskGLTextureAtlas *self,
|
||||
int width,
|
||||
int height,
|
||||
int *out_x,
|
||||
int *out_y)
|
||||
{
|
||||
stbrp_rect rect;
|
||||
|
||||
rect.w = width;
|
||||
rect.h = height;
|
||||
|
||||
stbrp_pack_rects (&self->context, &rect, 1);
|
||||
|
||||
if (rect.was_packed)
|
||||
{
|
||||
*out_x = rect.x;
|
||||
*out_y = rect.y;
|
||||
}
|
||||
|
||||
return rect.was_packed;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_texture_atlas_initialize (GskGLDriver *driver,
|
||||
GskGLTextureAtlas *atlas)
|
||||
{
|
||||
/* Insert a single pixel at 0,0 for use in coloring */
|
||||
|
||||
gboolean packed G_GNUC_UNUSED;
|
||||
int x, y;
|
||||
guint gl_format;
|
||||
guint gl_type;
|
||||
guint8 pixel_data[4 * 3 * 3];
|
||||
|
||||
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
|
||||
"Initializing Atlas");
|
||||
|
||||
packed = gsk_gl_texture_atlas_pack (atlas, 3, 3, &x, &y);
|
||||
g_assert (packed);
|
||||
g_assert (x == 0 && y == 0);
|
||||
|
||||
memset (pixel_data, 255, sizeof pixel_data);
|
||||
|
||||
if (gdk_gl_context_get_use_es (gdk_gl_context_get_current ()))
|
||||
{
|
||||
gl_format = GL_RGBA;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_format = GL_BGRA;
|
||||
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
|
||||
glBindTexture (GL_TEXTURE_2D, atlas->texture_id);
|
||||
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
0, 0,
|
||||
3, 3,
|
||||
gl_format, gl_type,
|
||||
pixel_data);
|
||||
|
||||
gdk_gl_context_pop_debug_group (gdk_gl_context_get_current ());
|
||||
|
||||
driver->command_queue->n_uploads++;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_texture_atlases_pack (GskGLDriver *driver,
|
||||
int width,
|
||||
int height,
|
||||
GskGLTextureAtlas **out_atlas,
|
||||
int *out_x,
|
||||
int *out_y)
|
||||
gsk_gl_texture_library_pack_any_atlas (GskGLTextureLibrary *self,
|
||||
int width,
|
||||
int height,
|
||||
GskGLTextureAtlas **out_atlas,
|
||||
int *out_x,
|
||||
int *out_y)
|
||||
{
|
||||
GskGLTextureAtlas *atlas = NULL;
|
||||
int x, y;
|
||||
|
||||
for (guint i = 0; i < driver->atlases->len; i++)
|
||||
{
|
||||
atlas = g_ptr_array_index (driver->atlases, i);
|
||||
g_assert (GSK_IS_GL_TEXTURE_LIBRARY (self));
|
||||
g_assert (width > 0);
|
||||
g_assert (height > 0);
|
||||
g_assert (out_atlas != NULL);
|
||||
g_assert (out_x != NULL);
|
||||
g_assert (out_y != NULL);
|
||||
|
||||
if (gsk_gl_texture_atlas_pack (atlas, width, height, &x, &y))
|
||||
for (guint i = 0; i < self->atlases->len; i++)
|
||||
{
|
||||
atlas = g_ptr_array_index (self->atlases, i);
|
||||
|
||||
if (gsk_gl_texture_library_allocate (self, atlas, width, height, &x, &y))
|
||||
break;
|
||||
|
||||
atlas = NULL;
|
||||
@@ -326,12 +355,10 @@ gsk_gl_texture_atlases_pack (GskGLDriver *driver,
|
||||
if (atlas == NULL)
|
||||
{
|
||||
/* No atlas has enough space, so create a new one... */
|
||||
atlas = gsk_gl_driver_create_atlas (driver);
|
||||
|
||||
gsk_gl_texture_atlas_initialize (driver, atlas);
|
||||
atlas = gsk_gl_texture_library_acquire_atlas (self);
|
||||
|
||||
/* Pack it onto that one, which surely has enough space... */
|
||||
if (!gsk_gl_texture_atlas_pack (atlas, width, height, &x, &y))
|
||||
if (!gsk_gl_texture_library_allocate (self, atlas, width, height, &x, &y))
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
@@ -380,17 +407,19 @@ gsk_gl_texture_library_pack (GskGLTextureLibrary *self,
|
||||
*out_packed_x = 0;
|
||||
*out_packed_y = 0;
|
||||
}
|
||||
else if (width <= self->max_entry_size && height <= self->max_entry_size)
|
||||
else if (self->max_entry_size == 0 ||
|
||||
(width <= self->max_entry_size &&
|
||||
height <= self->max_entry_size))
|
||||
{
|
||||
int packed_x;
|
||||
int packed_y;
|
||||
|
||||
gsk_gl_texture_atlases_pack (self->driver,
|
||||
padding + width + padding,
|
||||
padding + height + padding,
|
||||
&atlas,
|
||||
&packed_x,
|
||||
&packed_y);
|
||||
gsk_gl_texture_library_pack_any_atlas (self,
|
||||
padding + width + padding,
|
||||
padding + height + padding,
|
||||
&atlas,
|
||||
&packed_x,
|
||||
&packed_y);
|
||||
|
||||
entry->atlas = atlas;
|
||||
entry->is_atlased = TRUE;
|
||||
@@ -424,3 +453,134 @@ gsk_gl_texture_library_pack (GskGLTextureLibrary *self,
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
/*
|
||||
* gsk_gl_texture_library_clear_cache:
|
||||
*
|
||||
* Clear the front cache if the texture library is using one. For
|
||||
* example the glyph cache would drop it's front cache to force
|
||||
* next lookups to fall through to the GHashTable key lookup.
|
||||
*/
|
||||
void
|
||||
gsk_gl_texture_library_clear_cache (GskGLTextureLibrary *self)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_GL_TEXTURE_LIBRARY (self));
|
||||
|
||||
if (GSK_GL_TEXTURE_LIBRARY_GET_CLASS (self)->clear_cache)
|
||||
GSK_GL_TEXTURE_LIBRARY_GET_CLASS (self)->clear_cache (self);
|
||||
}
|
||||
|
||||
/*
|
||||
* gsk_gl_texture_library_compact:
|
||||
*
|
||||
* Requests that the texture library compact it's altases. That
|
||||
* generally means to traverse them to look for unused pixels over
|
||||
* a certain threshold and release them if necessary.
|
||||
*
|
||||
* Returns: %TRUE if any compaction occurred.
|
||||
*/
|
||||
gboolean
|
||||
gsk_gl_texture_library_compact (GskGLTextureLibrary *self,
|
||||
gint64 frame_id)
|
||||
{
|
||||
g_return_val_if_fail (GSK_IS_GL_TEXTURE_LIBRARY (self), FALSE);
|
||||
|
||||
if (GSK_GL_TEXTURE_LIBRARY_GET_CLASS (self)->compact)
|
||||
return GSK_GL_TEXTURE_LIBRARY_GET_CLASS (self)->compact (self, frame_id);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gl_texture_library_reset (GskGLTextureLibrary *self)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_GL_TEXTURE_LIBRARY (self));
|
||||
|
||||
gsk_gl_texture_library_clear_cache (self);
|
||||
|
||||
g_hash_table_remove_all (self->hash_table);
|
||||
|
||||
if (self->atlases->len)
|
||||
g_ptr_array_remove_range (self->atlases, 0, self->atlases->len);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gl_texture_library_set_atlas_size (GskGLTextureLibrary *self,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_GL_TEXTURE_LIBRARY (self));
|
||||
|
||||
if (width <= 0)
|
||||
width = DEFAULT_ATLAS_WIDTH;
|
||||
|
||||
if (height <= 0)
|
||||
height = DEFAULT_ATLAS_HEIGHT;
|
||||
|
||||
self->atlas_height = height;
|
||||
self->atlas_width = width;
|
||||
|
||||
gsk_gl_texture_library_reset (self);
|
||||
}
|
||||
|
||||
/*
|
||||
* gsk_gl_texture_library_acquire_atlas:
|
||||
*
|
||||
* Allocates a new texture atlas based on the current size
|
||||
* and format requirements.
|
||||
*/
|
||||
GskGLTextureAtlas *
|
||||
gsk_gl_texture_library_acquire_atlas (GskGLTextureLibrary *self)
|
||||
{
|
||||
GskGLTextureAtlas *atlas;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_GL_TEXTURE_LIBRARY (self), NULL);
|
||||
g_return_val_if_fail (GSK_IS_GL_DRIVER (self->driver), NULL);
|
||||
g_return_val_if_fail (GSK_IS_GL_COMMAND_QUEUE (self->driver->command_queue), NULL);
|
||||
g_return_val_if_fail (self->atlas_width > 0, NULL);
|
||||
g_return_val_if_fail (self->atlas_height > 0, NULL);
|
||||
|
||||
atlas = g_slice_new0 (GskGLTextureAtlas);
|
||||
atlas->width = self->atlas_width;
|
||||
atlas->height = self->atlas_height;
|
||||
/* TODO: We might want to change the strategy about the amount of
|
||||
* nodes here? stb_rect_pack.h says width is optimal. */
|
||||
atlas->nodes = g_malloc0_n (atlas->width, sizeof (struct stbrp_node));
|
||||
stbrp_init_target (&atlas->context, atlas->width, atlas->height, atlas->nodes, atlas->width);
|
||||
atlas->texture_id = gsk_gl_command_queue_create_texture (self->driver->command_queue,
|
||||
atlas->width,
|
||||
atlas->height,
|
||||
GL_RGBA8,
|
||||
GL_LINEAR,
|
||||
GL_LINEAR);
|
||||
|
||||
gdk_gl_context_label_object_printf (gdk_gl_context_get_current (),
|
||||
GL_TEXTURE, atlas->texture_id,
|
||||
"Texture atlas %d",
|
||||
atlas->texture_id);
|
||||
|
||||
g_ptr_array_add (self->atlases, atlas);
|
||||
|
||||
if (GSK_GL_TEXTURE_LIBRARY_GET_CLASS (self)->init_atlas)
|
||||
GSK_GL_TEXTURE_LIBRARY_GET_CLASS (self)->init_atlas (self, atlas);
|
||||
|
||||
return atlas;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_gl_texture_library_allocate (GskGLTextureLibrary *self,
|
||||
GskGLTextureAtlas *atlas,
|
||||
int width,
|
||||
int height,
|
||||
int *out_x,
|
||||
int *out_y)
|
||||
{
|
||||
g_assert (GSK_IS_GL_TEXTURE_LIBRARY (self));
|
||||
g_assert (atlas != NULL);
|
||||
g_assert (width > 0);
|
||||
g_assert (height > 0);
|
||||
g_assert (out_x != NULL);
|
||||
g_assert (out_y != NULL);
|
||||
|
||||
return GSK_GL_TEXTURE_LIBRARY_GET_CLASS (self)->allocate (self, atlas, width, height, out_x, out_y);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@ typedef struct _GskGLTextureAtlas
|
||||
*/
|
||||
int unused_pixels;
|
||||
|
||||
void *user_data;
|
||||
} GskGLTextureAtlas;
|
||||
|
||||
typedef struct _GskGLTextureAtlasEntry
|
||||
@@ -89,40 +88,67 @@ typedef struct _GskGLTextureAtlasEntry
|
||||
|
||||
typedef struct _GskGLTextureLibrary
|
||||
{
|
||||
GObject parent_instance;
|
||||
GObject parent_instance;
|
||||
GskGLDriver *driver;
|
||||
GHashTable *hash_table;
|
||||
guint max_entry_size;
|
||||
GPtrArray *atlases;
|
||||
GHashTable *hash_table;
|
||||
guint max_entry_size;
|
||||
guint max_frame_age;
|
||||
guint atlas_width;
|
||||
guint atlas_height;
|
||||
} GskGLTextureLibrary;
|
||||
|
||||
typedef struct _GskGLTextureLibraryClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (*begin_frame) (GskGLTextureLibrary *library,
|
||||
gint64 frame_id,
|
||||
GPtrArray *removed_atlases);
|
||||
void (*begin_frame) (GskGLTextureLibrary *library,
|
||||
gint64 frame_id);
|
||||
gboolean (*compact) (GskGLTextureLibrary *library,
|
||||
gint64 frame_id);
|
||||
void (*clear_cache) (GskGLTextureLibrary *library);
|
||||
void (*init_atlas) (GskGLTextureLibrary *library,
|
||||
GskGLTextureAtlas *atlas);
|
||||
gboolean (*allocate) (GskGLTextureLibrary *library,
|
||||
GskGLTextureAtlas *atlas,
|
||||
int width,
|
||||
int height,
|
||||
int *out_x,
|
||||
int *out_y);
|
||||
} GskGLTextureLibraryClass;
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GskGLTextureLibrary, g_object_unref)
|
||||
|
||||
GType gsk_gl_texture_library_get_type (void) G_GNUC_CONST;
|
||||
void gsk_gl_texture_library_set_funcs (GskGLTextureLibrary *self,
|
||||
GHashFunc hash_func,
|
||||
GEqualFunc equal_func,
|
||||
GDestroyNotify key_destroy,
|
||||
GDestroyNotify value_destroy);
|
||||
void gsk_gl_texture_library_begin_frame (GskGLTextureLibrary *self,
|
||||
gint64 frame_id,
|
||||
GPtrArray *removed_atlases);
|
||||
gpointer gsk_gl_texture_library_pack (GskGLTextureLibrary *self,
|
||||
gpointer key,
|
||||
gsize valuelen,
|
||||
guint width,
|
||||
guint height,
|
||||
int padding,
|
||||
guint *out_packed_x,
|
||||
guint *out_packed_y);
|
||||
GType gsk_gl_texture_library_get_type (void) G_GNUC_CONST;
|
||||
gboolean gsk_gl_texture_library_compact (GskGLTextureLibrary *self,
|
||||
gint64 frame_id);
|
||||
void gsk_gl_texture_library_clear_cache (GskGLTextureLibrary *self);
|
||||
void gsk_gl_texture_library_reset (GskGLTextureLibrary *self);
|
||||
void gsk_gl_texture_library_set_atlas_size (GskGLTextureLibrary *self,
|
||||
int width,
|
||||
int height);
|
||||
GskGLTextureAtlas *gsk_gl_texture_library_acquire_atlas (GskGLTextureLibrary *self);
|
||||
void gsk_gl_texture_library_set_funcs (GskGLTextureLibrary *self,
|
||||
GHashFunc hash_func,
|
||||
GEqualFunc equal_func,
|
||||
GDestroyNotify key_destroy,
|
||||
GDestroyNotify value_destroy);
|
||||
void gsk_gl_texture_library_begin_frame (GskGLTextureLibrary *self,
|
||||
gint64 frame_id);
|
||||
gboolean gsk_gl_texture_library_allocate (GskGLTextureLibrary *self,
|
||||
GskGLTextureAtlas *atlas,
|
||||
int width,
|
||||
int height,
|
||||
int *out_x,
|
||||
int *out_y);
|
||||
gpointer gsk_gl_texture_library_pack (GskGLTextureLibrary *self,
|
||||
gpointer key,
|
||||
gsize valuelen,
|
||||
guint width,
|
||||
guint height,
|
||||
int padding,
|
||||
guint *out_packed_x,
|
||||
guint *out_packed_y);
|
||||
|
||||
static inline void
|
||||
gsk_gl_texture_atlas_mark_unused (GskGLTextureAtlas *self,
|
||||
|
||||
+37
-1
@@ -107,8 +107,44 @@ gsk_cairo_renderer_render_texture (GskRenderer *renderer,
|
||||
GdkTexture *texture;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
int width, height;
|
||||
/* limit from cairo's source code */
|
||||
#define MAX_IMAGE_SIZE 32767
|
||||
|
||||
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, ceil (viewport->size.width), ceil (viewport->size.height));
|
||||
width = ceil (viewport->size.width);
|
||||
height = ceil (viewport->size.height);
|
||||
if (width > MAX_IMAGE_SIZE || height > MAX_IMAGE_SIZE)
|
||||
{
|
||||
gsize x, y, size, stride;
|
||||
GBytes *bytes;
|
||||
guchar *data;
|
||||
|
||||
stride = width * 4;
|
||||
size = stride * height;
|
||||
data = g_malloc_n (stride, height);
|
||||
|
||||
for (y = 0; y < height; y += MAX_IMAGE_SIZE)
|
||||
{
|
||||
for (x = 0; x < width; x += MAX_IMAGE_SIZE)
|
||||
{
|
||||
texture = gsk_cairo_renderer_render_texture (renderer, root,
|
||||
&GRAPHENE_RECT_INIT (x, y,
|
||||
MIN (MAX_IMAGE_SIZE, viewport->size.width - x),
|
||||
MIN (MAX_IMAGE_SIZE, viewport->size.height - y)));
|
||||
gdk_texture_download (texture,
|
||||
data + stride * y + x * 4,
|
||||
stride);
|
||||
g_object_unref (texture);
|
||||
}
|
||||
}
|
||||
|
||||
bytes = g_bytes_new_take (data, size);
|
||||
texture = gdk_memory_texture_new (width, height, GDK_MEMORY_DEFAULT, bytes, stride);
|
||||
g_bytes_unref (bytes);
|
||||
return texture;
|
||||
}
|
||||
|
||||
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
|
||||
cr = cairo_create (surface);
|
||||
|
||||
cairo_translate (cr, - viewport->origin.x, - viewport->origin.y);
|
||||
|
||||
+16
-3
@@ -58,14 +58,14 @@ value_render_node_init (GValue *value)
|
||||
{
|
||||
value->data[0].v_pointer = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
value_render_node_free_value (GValue *value)
|
||||
{
|
||||
if (value->data[0].v_pointer != NULL)
|
||||
gsk_render_node_unref (value->data[0].v_pointer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
value_render_node_copy_value (const GValue *src,
|
||||
GValue *dst)
|
||||
@@ -75,7 +75,7 @@ value_render_node_copy_value (const GValue *src,
|
||||
else
|
||||
dst->data[0].v_pointer = NULL;
|
||||
}
|
||||
|
||||
|
||||
static gpointer
|
||||
value_render_node_peek_pointer (const GValue *value)
|
||||
{
|
||||
@@ -738,3 +738,16 @@ gsk_render_node_prefers_high_depth (const GskRenderNode *node)
|
||||
{
|
||||
return node->prefers_high_depth;
|
||||
}
|
||||
|
||||
/* Whether we need an offscreen to handle opacity correctly for this node.
|
||||
* We don't if there is only one drawing node inside (could be child
|
||||
* node, or grandchild, or...).
|
||||
*
|
||||
* For containers with multiple children, we can avoid the offscreen if
|
||||
* the children are known not to overlap.
|
||||
*/
|
||||
gboolean
|
||||
gsk_render_node_use_offscreen_for_opacity (const GskRenderNode *node)
|
||||
{
|
||||
return node->offscreen_for_opacity;
|
||||
}
|
||||
|
||||
+53
-6
@@ -139,6 +139,7 @@ gsk_color_node_new (const GdkRGBA *rgba,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_COLOR_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = FALSE;
|
||||
|
||||
self->color = *rgba;
|
||||
graphene_rect_init_from_rect (&node->bounds, bounds);
|
||||
@@ -284,6 +285,7 @@ gsk_linear_gradient_node_new (const graphene_rect_t *bounds,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_LINEAR_GRADIENT_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = FALSE;
|
||||
|
||||
graphene_rect_init_from_rect (&node->bounds, bounds);
|
||||
graphene_point_init_from_point (&self->start, start);
|
||||
@@ -336,6 +338,7 @@ gsk_repeating_linear_gradient_node_new (const graphene_rect_t *bounds,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_REPEATING_LINEAR_GRADIENT_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = FALSE;
|
||||
|
||||
graphene_rect_init_from_rect (&node->bounds, bounds);
|
||||
graphene_point_init_from_point (&self->start, start);
|
||||
@@ -584,6 +587,7 @@ gsk_radial_gradient_node_new (const graphene_rect_t *bounds,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_RADIAL_GRADIENT_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = FALSE;
|
||||
|
||||
graphene_rect_init_from_rect (&node->bounds, bounds);
|
||||
graphene_point_init_from_point (&self->center, center);
|
||||
@@ -652,6 +656,7 @@ gsk_repeating_radial_gradient_node_new (const graphene_rect_t *bounds,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_REPEATING_RADIAL_GRADIENT_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = FALSE;
|
||||
|
||||
graphene_rect_init_from_rect (&node->bounds, bounds);
|
||||
graphene_point_init_from_point (&self->center, center);
|
||||
@@ -1030,6 +1035,7 @@ gsk_conic_gradient_node_new (const graphene_rect_t *bounds,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_CONIC_GRADIENT_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = FALSE;
|
||||
|
||||
graphene_rect_init_from_rect (&node->bounds, bounds);
|
||||
graphene_point_init_from_point (&self->center, center);
|
||||
@@ -1413,6 +1419,7 @@ gsk_border_node_new (const GskRoundedRect *outline,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_BORDER_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = FALSE;
|
||||
|
||||
gsk_rounded_rect_init_copy (&self->outline, outline);
|
||||
memcpy (self->border_width, border_width, sizeof (self->border_width));
|
||||
@@ -1559,6 +1566,7 @@ gsk_texture_node_new (GdkTexture *texture,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_TEXTURE_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = FALSE;
|
||||
|
||||
self->texture = g_object_ref (texture);
|
||||
graphene_rect_init_from_rect (&node->bounds, bounds);
|
||||
@@ -2014,6 +2022,7 @@ gsk_inset_shadow_node_new (const GskRoundedRect *outline,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_INSET_SHADOW_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = FALSE;
|
||||
|
||||
gsk_rounded_rect_init_copy (&self->outline, outline);
|
||||
self->color = *color;
|
||||
@@ -2313,6 +2322,7 @@ gsk_outset_shadow_node_new (const GskRoundedRect *outline,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_OUTSET_SHADOW_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = FALSE;
|
||||
|
||||
gsk_rounded_rect_init_copy (&self->outline, outline);
|
||||
self->color = *color;
|
||||
@@ -2506,6 +2516,7 @@ gsk_cairo_node_new (const graphene_rect_t *bounds)
|
||||
|
||||
self = gsk_render_node_alloc (GSK_CAIRO_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = FALSE;
|
||||
|
||||
graphene_rect_init_from_rect (&node->bounds, bounds);
|
||||
|
||||
@@ -2576,6 +2587,7 @@ struct _GskContainerNode
|
||||
{
|
||||
GskRenderNode render_node;
|
||||
|
||||
gboolean disjoint;
|
||||
guint n_children;
|
||||
GskRenderNode **children;
|
||||
};
|
||||
@@ -2724,6 +2736,7 @@ gsk_container_node_new (GskRenderNode **children,
|
||||
self = gsk_render_node_alloc (GSK_CONTAINER_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
|
||||
self->disjoint = TRUE;
|
||||
self->n_children = n_children;
|
||||
|
||||
if (n_children == 0)
|
||||
@@ -2743,11 +2756,14 @@ gsk_container_node_new (GskRenderNode **children,
|
||||
for (guint i = 1; i < n_children; i++)
|
||||
{
|
||||
self->children[i] = gsk_render_node_ref (children[i]);
|
||||
self->disjoint &= !graphene_rect_intersection (&bounds, &(children[i]->bounds), NULL);
|
||||
graphene_rect_union (&bounds, &(children[i]->bounds), &bounds);
|
||||
node->prefers_high_depth |= gsk_render_node_prefers_high_depth (children[i]);
|
||||
node->offscreen_for_opacity |= children[i]->offscreen_for_opacity;
|
||||
}
|
||||
|
||||
graphene_rect_init_from_rect (&node->bounds, &bounds);
|
||||
node->offscreen_for_opacity |= !self->disjoint;
|
||||
}
|
||||
|
||||
return node;
|
||||
@@ -2801,6 +2817,24 @@ gsk_container_node_get_children (const GskRenderNode *node,
|
||||
return self->children;
|
||||
}
|
||||
|
||||
/*< private>
|
||||
* gsk_container_node_is_disjoint:
|
||||
* @node: a container `GskRenderNode`
|
||||
*
|
||||
* Returns `TRUE` if it is known that the child nodes are not
|
||||
* overlapping. There is no guarantee that they do overlap
|
||||
* if this function return FALSE.
|
||||
*
|
||||
* Returns: `TRUE` if children don't overlap
|
||||
*/
|
||||
gboolean
|
||||
gsk_container_node_is_disjoint (const GskRenderNode *node)
|
||||
{
|
||||
const GskContainerNode *self = (const GskContainerNode *) node;
|
||||
|
||||
return self->disjoint;
|
||||
}
|
||||
|
||||
/*** GSK_TRANSFORM_NODE ***/
|
||||
|
||||
/**
|
||||
@@ -2962,6 +2996,7 @@ gsk_transform_node_new (GskRenderNode *child,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_TRANSFORM_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = child->offscreen_for_opacity;
|
||||
|
||||
self->child = gsk_render_node_ref (child);
|
||||
self->transform = gsk_transform_ref (transform);
|
||||
@@ -3106,6 +3141,7 @@ gsk_opacity_node_new (GskRenderNode *child,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_OPACITY_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = child->offscreen_for_opacity;
|
||||
|
||||
self->child = gsk_render_node_ref (child);
|
||||
self->opacity = CLAMP (opacity, 0.0, 1.0);
|
||||
@@ -3309,6 +3345,7 @@ gsk_color_matrix_node_new (GskRenderNode *child,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_COLOR_MATRIX_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = child->offscreen_for_opacity;
|
||||
|
||||
self->child = gsk_render_node_ref (child);
|
||||
graphene_matrix_init_from_matrix (&self->color_matrix, color_matrix);
|
||||
@@ -3457,6 +3494,7 @@ gsk_repeat_node_new (const graphene_rect_t *bounds,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_REPEAT_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = TRUE;
|
||||
|
||||
graphene_rect_init_from_rect (&node->bounds, bounds);
|
||||
|
||||
@@ -3594,6 +3632,7 @@ gsk_clip_node_new (GskRenderNode *child,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_CLIP_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = child->offscreen_for_opacity;
|
||||
|
||||
self->child = gsk_render_node_ref (child);
|
||||
graphene_rect_normalize_r (clip, &self->clip);
|
||||
@@ -3727,6 +3766,7 @@ gsk_rounded_clip_node_new (GskRenderNode *child,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_ROUNDED_CLIP_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = child->offscreen_for_opacity;
|
||||
|
||||
self->child = gsk_render_node_ref (child);
|
||||
gsk_rounded_rect_init_copy (&self->clip, clip);
|
||||
@@ -3946,6 +3986,7 @@ gsk_shadow_node_new (GskRenderNode *child,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_SHADOW_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = child->offscreen_for_opacity;
|
||||
|
||||
self->child = gsk_render_node_ref (child);
|
||||
self->n_shadows = n_shadows;
|
||||
@@ -4142,6 +4183,7 @@ gsk_blend_node_new (GskRenderNode *bottom,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_BLEND_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = TRUE;
|
||||
|
||||
self->bottom = gsk_render_node_ref (bottom);
|
||||
self->top = gsk_render_node_ref (top);
|
||||
@@ -4292,6 +4334,7 @@ gsk_cross_fade_node_new (GskRenderNode *start,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_CROSS_FADE_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = TRUE;
|
||||
|
||||
self->start = gsk_render_node_ref (start);
|
||||
self->end = gsk_render_node_ref (end);
|
||||
@@ -4478,6 +4521,7 @@ gsk_text_node_new (PangoFont *font,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_TEXT_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = FALSE;
|
||||
|
||||
self->font = g_object_ref (font);
|
||||
self->color = *color;
|
||||
@@ -4884,6 +4928,7 @@ gsk_blur_node_new (GskRenderNode *child,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_BLUR_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = child->offscreen_for_opacity;
|
||||
|
||||
self->child = gsk_render_node_ref (child);
|
||||
self->radius = radius;
|
||||
@@ -5013,6 +5058,7 @@ gsk_debug_node_new (GskRenderNode *child,
|
||||
|
||||
self = gsk_render_node_alloc (GSK_DEBUG_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = child->offscreen_for_opacity;
|
||||
|
||||
self->child = gsk_render_node_ref (child);
|
||||
self->message = message;
|
||||
@@ -5130,10 +5176,10 @@ gsk_gl_shader_node_diff (GskRenderNode *node1,
|
||||
* @shader: the `GskGLShader`
|
||||
* @bounds: the rectangle to render the shader into
|
||||
* @args: Arguments for the uniforms
|
||||
* @children: (array length=n_children): array of child nodes, these will
|
||||
* be rendered to textures and used as input.
|
||||
* @children: (nullable) (array length=n_children): array of child nodes,
|
||||
* these will be rendered to textures and used as input.
|
||||
* @n_children: Length of @children (currenly the GL backend supports
|
||||
* up to 4 children)
|
||||
* up to 4 children)
|
||||
*
|
||||
* Creates a `GskRenderNode` that will render the given @shader into the
|
||||
* area given by @bounds.
|
||||
@@ -5167,13 +5213,14 @@ gsk_gl_shader_node_new (GskGLShader *shader,
|
||||
|
||||
g_return_val_if_fail (GSK_IS_GL_SHADER (shader), NULL);
|
||||
g_return_val_if_fail (bounds != NULL, NULL);
|
||||
g_return_val_if_fail ((args == NULL && gsk_gl_shader_get_n_uniforms (shader) == 0) ||
|
||||
(args != NULL && g_bytes_get_size (args) == gsk_gl_shader_get_args_size (shader)), NULL);
|
||||
g_return_val_if_fail (args != NULL, NULL);
|
||||
g_return_val_if_fail (g_bytes_get_size (args) == gsk_gl_shader_get_args_size (shader), NULL);
|
||||
g_return_val_if_fail ((children == NULL && n_children == 0) ||
|
||||
(children != NULL && n_children == gsk_gl_shader_get_n_textures (shader)), NULL);
|
||||
(n_children == gsk_gl_shader_get_n_textures (shader)), NULL);
|
||||
|
||||
self = gsk_render_node_alloc (GSK_GL_SHADER_NODE);
|
||||
node = (GskRenderNode *) self;
|
||||
node->offscreen_for_opacity = TRUE;
|
||||
|
||||
graphene_rect_init_from_rect (&node->bounds, bounds);
|
||||
self->shader = g_object_ref (shader);
|
||||
|
||||
@@ -29,6 +29,7 @@ struct _GskRenderNode
|
||||
graphene_rect_t bounds;
|
||||
|
||||
guint prefers_high_depth : 1;
|
||||
guint offscreen_for_opacity : 1;
|
||||
};
|
||||
|
||||
struct _GskRenderNodeClass
|
||||
@@ -113,6 +114,10 @@ void gsk_transform_node_get_translate (const GskRenderNode *no
|
||||
float *dy);
|
||||
gboolean gsk_render_node_prefers_high_depth (const GskRenderNode *node);
|
||||
|
||||
gboolean gsk_container_node_is_disjoint (const GskRenderNode *node);
|
||||
|
||||
gboolean gsk_render_node_use_offscreen_for_opacity (const GskRenderNode *node);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+1
-1
@@ -425,7 +425,7 @@ gtk_accessible_reset_property (GtkAccessible *self,
|
||||
* gtk_accessible_update_relation (accessible,
|
||||
* GTK_ACCESSIBLE_RELATION_CONTROLS,
|
||||
* ref1, NULL,
|
||||
* GTK_ACCESSIBLE_LABELLED_BY,
|
||||
* GTK_ACCESSIBLE_RELATION_LABELLED_BY,
|
||||
* ref1, ref2, ref3, NULL,
|
||||
* -1);
|
||||
* ```
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
*
|
||||
* `GtkApplication` will automatically load menus from the `GtkBuilder`
|
||||
* resource located at "gtk/menus.ui", relative to the application's
|
||||
* resource base path (see `g_application_set_resource_base_path()`).
|
||||
* resource base path (see [method@Gio.Application.set_resource_base_path]).
|
||||
* The menu with the ID "menubar" is taken as the application's
|
||||
* menubar. Additional menus (most interesting submenus) can be named
|
||||
* and accessed via [method@Gtk.Application.get_menu_by_id] which allows for
|
||||
@@ -83,8 +83,8 @@
|
||||
* resources. See [method@Gtk.IconTheme.add_resource_path] for more
|
||||
* information.
|
||||
*
|
||||
* If there is a resource located at "gtk/help-overlay.ui" which
|
||||
* defines a [class@Gtk.ShortcutsWindow] with ID "help_overlay" then
|
||||
* If there is a resource located at `gtk/help-overlay.ui` which
|
||||
* defines a [class@Gtk.ShortcutsWindow] with ID `help_overlay` then
|
||||
* `GtkApplication` associates an instance of this shortcuts window with
|
||||
* each [class@Gtk.ApplicationWindow] and sets up the keyboard accelerator
|
||||
* <kbd>Control</kbd>+<kbd>?</kbd> to open it. To create a menu item that
|
||||
|
||||
+22
-16
@@ -523,11 +523,26 @@ gtk_center_layout_allocate (GtkLayoutManager *layout_manager,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_center_layout_dispose (GObject *object)
|
||||
{
|
||||
GtkCenterLayout *self = GTK_CENTER_LAYOUT (object);
|
||||
|
||||
g_clear_object (&self->start_widget);
|
||||
g_clear_object (&self->center_widget);
|
||||
g_clear_object (&self->end_widget);
|
||||
|
||||
G_OBJECT_CLASS (gtk_center_layout_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_center_layout_class_init (GtkCenterLayoutClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkLayoutManagerClass *layout_class = GTK_LAYOUT_MANAGER_CLASS (klass);
|
||||
|
||||
object_class->dispose = gtk_center_layout_dispose;
|
||||
|
||||
layout_class->get_request_mode = gtk_center_layout_get_request_mode;
|
||||
layout_class->measure = gtk_center_layout_measure;
|
||||
layout_class->allocate = gtk_center_layout_allocate;
|
||||
@@ -641,11 +656,8 @@ gtk_center_layout_set_start_widget (GtkCenterLayout *self,
|
||||
g_return_if_fail (GTK_IS_CENTER_LAYOUT (self));
|
||||
g_return_if_fail (widget == NULL || GTK_IS_WIDGET (widget));
|
||||
|
||||
if (self->start_widget == widget)
|
||||
return;
|
||||
|
||||
self->start_widget = widget;
|
||||
gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (self));
|
||||
if (g_set_object (&self->start_widget, widget))
|
||||
gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (self));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -680,11 +692,8 @@ gtk_center_layout_set_center_widget (GtkCenterLayout *self,
|
||||
g_return_if_fail (GTK_IS_CENTER_LAYOUT (self));
|
||||
g_return_if_fail (widget == NULL || GTK_IS_WIDGET (widget));
|
||||
|
||||
if (self->center_widget == widget)
|
||||
return;
|
||||
|
||||
self->center_widget = widget;
|
||||
gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (self));
|
||||
if (g_set_object (&self->center_widget, widget))
|
||||
gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (self));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -706,7 +715,7 @@ gtk_center_layout_get_center_widget (GtkCenterLayout *self)
|
||||
/**
|
||||
* gtk_center_layout_set_end_widget:
|
||||
* @self: a `GtkCenterLayout`
|
||||
* @widget: (nullable) (transfer none): the new end widget
|
||||
* @widget: (nullable): the new end widget
|
||||
*
|
||||
* Sets the new end widget of @self.
|
||||
*
|
||||
@@ -719,11 +728,8 @@ gtk_center_layout_set_end_widget (GtkCenterLayout *self,
|
||||
g_return_if_fail (GTK_IS_CENTER_LAYOUT (self));
|
||||
g_return_if_fail (widget == NULL || GTK_IS_WIDGET (widget));
|
||||
|
||||
if (self->end_widget == widget)
|
||||
return;
|
||||
|
||||
self->end_widget = widget;
|
||||
gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (self));
|
||||
if (g_set_object (&self->end_widget, widget))
|
||||
gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (self));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+10
-3
@@ -69,11 +69,18 @@ gtk_css_calc_value_new_from_array (GtkCssValue **values,
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_css_value_number_free (GtkCssValue *value)
|
||||
gtk_css_value_number_free (GtkCssValue *number)
|
||||
{
|
||||
g_slice_free (GtkCssValue, value);
|
||||
if (number->type == TYPE_CALC)
|
||||
{
|
||||
const guint n_terms = number->calc.n_terms;
|
||||
|
||||
for (guint i = 0; i < n_terms; i++)
|
||||
_gtk_css_value_unref (number->calc.terms[i]);
|
||||
}
|
||||
|
||||
g_slice_free (GtkCssValue, number);
|
||||
}
|
||||
|
||||
static double
|
||||
|
||||
@@ -149,7 +149,8 @@ gtk_event_controller_focus_handle_crossing (GtkEventController *controller,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
if (crossing->type == GTK_CROSSING_FOCUS)
|
||||
if (crossing->type == GTK_CROSSING_FOCUS ||
|
||||
crossing->type == GTK_CROSSING_ACTIVE)
|
||||
update_focus (controller, crossing);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
|
||||
#define SCROLL_CAPTURE_THRESHOLD_MS 150
|
||||
#define HOLD_TIMEOUT_MS 50
|
||||
#define SURFACE_UNIT_DISCRETE_MAPPING 10
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -85,6 +86,8 @@ struct _GtkEventControllerScroll
|
||||
double cur_dx;
|
||||
double cur_dy;
|
||||
|
||||
GdkScrollUnit cur_unit;
|
||||
|
||||
guint hold_timeout_id;
|
||||
guint active : 1;
|
||||
};
|
||||
@@ -238,28 +241,26 @@ gtk_event_controller_scroll_get_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static void
|
||||
gtk_event_controller_scroll_begin (GtkEventController *controller)
|
||||
{
|
||||
GtkEventControllerScroll *scroll = GTK_EVENT_CONTROLLER_SCROLL (controller);
|
||||
|
||||
if (scroll->active)
|
||||
return FALSE;
|
||||
return;
|
||||
|
||||
g_signal_emit (controller, signals[SCROLL_BEGIN], 0);
|
||||
scroll_history_reset (scroll);
|
||||
scroll->active = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static void
|
||||
gtk_event_controller_scroll_end (GtkEventController *controller)
|
||||
{
|
||||
GtkEventControllerScroll *scroll = GTK_EVENT_CONTROLLER_SCROLL (controller);
|
||||
|
||||
if (!scroll->active)
|
||||
return FALSE;
|
||||
return;
|
||||
|
||||
g_signal_emit (controller, signals[SCROLL_END], 0);
|
||||
scroll->active = FALSE;
|
||||
@@ -271,8 +272,6 @@ gtk_event_controller_scroll_end (GtkEventController *controller)
|
||||
scroll_history_finish (scroll, &vel_x, &vel_y);
|
||||
g_signal_emit (controller, signals[DECELERATE], 0, vel_x, vel_y);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -295,30 +294,29 @@ gtk_event_controller_scroll_handle_hold_event (GtkEventController *controller,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkEventControllerScroll *scroll = GTK_EVENT_CONTROLLER_SCROLL (controller);
|
||||
gboolean handled = GDK_EVENT_PROPAGATE;
|
||||
GdkTouchpadGesturePhase phase;
|
||||
guint n_fingers = 0;
|
||||
|
||||
if (gdk_event_get_event_type (event) != GDK_TOUCHPAD_HOLD)
|
||||
return handled;
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
|
||||
n_fingers = gdk_touchpad_event_get_n_fingers (event);
|
||||
if (n_fingers != 1 && n_fingers != 2)
|
||||
return handled;
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
|
||||
if (scroll->hold_timeout_id != 0)
|
||||
return handled;
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
|
||||
phase = gdk_touchpad_event_get_gesture_phase (event);
|
||||
|
||||
switch (phase)
|
||||
{
|
||||
case GDK_TOUCHPAD_GESTURE_PHASE_BEGIN:
|
||||
handled = gtk_event_controller_scroll_begin (controller);
|
||||
gtk_event_controller_scroll_begin (controller);
|
||||
break;
|
||||
|
||||
case GDK_TOUCHPAD_GESTURE_PHASE_END:
|
||||
handled = gtk_event_controller_scroll_end (controller);
|
||||
gtk_event_controller_scroll_end (controller);
|
||||
break;
|
||||
|
||||
case GDK_TOUCHPAD_GESTURE_PHASE_CANCEL:
|
||||
@@ -336,7 +334,7 @@ gtk_event_controller_scroll_handle_hold_event (GtkEventController *controller,
|
||||
break;
|
||||
}
|
||||
|
||||
return handled;
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -350,6 +348,7 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
|
||||
double dx = 0, dy = 0;
|
||||
gboolean handled = GDK_EVENT_PROPAGATE;
|
||||
GdkEventType event_type;
|
||||
GdkScrollUnit scroll_unit;
|
||||
|
||||
event_type = gdk_event_get_event_type (event);
|
||||
|
||||
@@ -365,6 +364,8 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
|
||||
|
||||
g_clear_handle_id (&scroll->hold_timeout_id, g_source_remove);
|
||||
|
||||
scroll_unit = gdk_scroll_event_get_unit (event);
|
||||
|
||||
/* FIXME: Handle device changes */
|
||||
direction = gdk_scroll_event_get_direction (event);
|
||||
if (direction == GDK_SCROLL_SMOOTH)
|
||||
@@ -385,18 +386,31 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
|
||||
scroll->cur_dy += dy;
|
||||
dx = dy = 0;
|
||||
|
||||
if (ABS (scroll->cur_dx) >= 1)
|
||||
if (scroll_unit == GDK_SCROLL_UNIT_SURFACE)
|
||||
{
|
||||
steps = trunc (scroll->cur_dx);
|
||||
scroll->cur_dx -= steps;
|
||||
dx = steps;
|
||||
}
|
||||
dx = (int) scroll->cur_dx / SURFACE_UNIT_DISCRETE_MAPPING;
|
||||
scroll->cur_dx -= dx * SURFACE_UNIT_DISCRETE_MAPPING;
|
||||
|
||||
if (ABS (scroll->cur_dy) >= 1)
|
||||
dy = (int) scroll->cur_dy / SURFACE_UNIT_DISCRETE_MAPPING;
|
||||
scroll->cur_dy -= dy * SURFACE_UNIT_DISCRETE_MAPPING;
|
||||
|
||||
scroll_unit = GDK_SCROLL_UNIT_WHEEL;
|
||||
}
|
||||
else
|
||||
{
|
||||
steps = trunc (scroll->cur_dy);
|
||||
scroll->cur_dy -= steps;
|
||||
dy = steps;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -428,6 +442,8 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
|
||||
dx = 0;
|
||||
}
|
||||
|
||||
scroll->cur_unit = scroll_unit;
|
||||
|
||||
if (dx != 0 || dy != 0)
|
||||
g_signal_emit (controller, signals[SCROLL], 0, dx, dy, &handled);
|
||||
else if (direction == GDK_SCROLL_SMOOTH &&
|
||||
@@ -497,6 +513,9 @@ gtk_event_controller_scroll_class_init (GtkEventControllerScrollClass *klass)
|
||||
* Signals that the widget should scroll by the
|
||||
* amount specified by @dx and @dy.
|
||||
*
|
||||
* For the representation unit of the deltas, see
|
||||
* [method@Gtk.EventControllerScroll.get_unit].
|
||||
*
|
||||
* Returns: %TRUE if the scroll event was handled,
|
||||
* %FALSE otherwise.
|
||||
*/
|
||||
@@ -614,3 +633,26 @@ gtk_event_controller_scroll_get_flags (GtkEventControllerScroll *scroll)
|
||||
|
||||
return scroll->flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_scroll_get_unit:
|
||||
* @scroll: a `GtkEventControllerScroll`.
|
||||
*
|
||||
* Gets the scroll unit of the last
|
||||
* [signal@Gtk.EventControllerScroll::scroll] signal received.
|
||||
*
|
||||
* Always returns %GDK_SCROLL_UNIT_WHEEL if the
|
||||
* %GTK_EVENT_CONTROLLER_SCROLL_DISCRETE flag is set.
|
||||
*
|
||||
* Returns: the scroll unit.
|
||||
*
|
||||
* Since: 4.8
|
||||
*/
|
||||
GdkScrollUnit
|
||||
gtk_event_controller_scroll_get_unit (GtkEventControllerScroll *scroll)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_SCROLL (scroll),
|
||||
GDK_SCROLL_UNIT_WHEEL);
|
||||
|
||||
return scroll->cur_unit;
|
||||
}
|
||||
|
||||
@@ -71,6 +71,9 @@ GDK_AVAILABLE_IN_ALL
|
||||
GtkEventControllerScrollFlags
|
||||
gtk_event_controller_scroll_get_flags (GtkEventControllerScroll *scroll);
|
||||
|
||||
GDK_AVAILABLE_IN_4_8
|
||||
GdkScrollUnit gtk_event_controller_scroll_get_unit (GtkEventControllerScroll *scroll);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_EVENT_CONTROLLER_SCROLL_H__ */
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "gtkfilefilterprivate.h"
|
||||
|
||||
#include "macos/gdkmacos.h"
|
||||
#include "macos/gdkmacosdisplay-private.h"
|
||||
#include "macos/gdkmacossurface-private.h"
|
||||
|
||||
typedef struct {
|
||||
@@ -368,6 +369,9 @@ filechooser_quartz_launch (FileChooserQuartzData *data)
|
||||
[data->key_window makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
/* Need to clear our cached copy of ordered windows */
|
||||
_gdk_macos_display_clear_sorting (GDK_MACOS_DISPLAY (gdk_display_get_default ()));
|
||||
|
||||
if (!data->skip_response)
|
||||
{
|
||||
g_slist_free_full (self->custom_files, g_object_unref);
|
||||
|
||||
+4
-2
@@ -283,7 +283,8 @@ parser_start_element (GtkBuildableParseContext *context,
|
||||
}
|
||||
|
||||
if (strcmp (element_name, "mime-types") == 0 ||
|
||||
strcmp (element_name, "patterns") == 0)
|
||||
strcmp (element_name, "patterns") == 0 ||
|
||||
strcmp (element_name, "suffixes") == 0)
|
||||
{
|
||||
if (!_gtk_builder_check_parent (data->builder, context, "object", error))
|
||||
return;
|
||||
@@ -422,7 +423,8 @@ gtk_file_filter_buildable_custom_tag_end (GtkBuildable *buildable,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (strcmp (tagname, "mime-types") == 0 ||
|
||||
strcmp (tagname, "patterns") == 0)
|
||||
strcmp (tagname, "patterns") == 0 ||
|
||||
strcmp (tagname, "suffixes") == 0)
|
||||
{
|
||||
SubParserData *data = (SubParserData*)user_data;
|
||||
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
* GtkFilter:
|
||||
*
|
||||
* A `GtkFilter` object describes the filtering to be performed by a
|
||||
* `GtkFilterListModel`.
|
||||
* [class@Gtk.FilterListModel].
|
||||
*
|
||||
* The model will use the filter to determine if it should include items
|
||||
* or not by calling [method@Gtk.Filter.match] for each item and only
|
||||
|
||||
+13
-13
@@ -72,8 +72,8 @@ static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
|
||||
|
||||
static FlattenNode *
|
||||
gtk_flatten_list_model_get_nth (GtkRbTree *tree,
|
||||
guint position,
|
||||
guint *model_position)
|
||||
guint position,
|
||||
guint *model_position)
|
||||
{
|
||||
FlattenNode *node, *tmp;
|
||||
guint model_n_items;
|
||||
@@ -110,8 +110,8 @@ gtk_flatten_list_model_get_nth (GtkRbTree *tree,
|
||||
|
||||
static FlattenNode *
|
||||
gtk_flatten_list_model_get_nth_model (GtkRbTree *tree,
|
||||
guint position,
|
||||
guint *items_before)
|
||||
guint position,
|
||||
guint *items_before)
|
||||
{
|
||||
FlattenNode *node, *tmp;
|
||||
guint before;
|
||||
@@ -202,11 +202,11 @@ G_DEFINE_TYPE_WITH_CODE (GtkFlattenListModel, gtk_flatten_list_model, G_TYPE_OBJ
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, gtk_flatten_list_model_model_init))
|
||||
|
||||
static void
|
||||
gtk_flatten_list_model_items_changed_cb (GListModel *model,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added,
|
||||
gpointer _node)
|
||||
gtk_flatten_list_model_items_changed_cb (GListModel *model,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added,
|
||||
gpointer _node)
|
||||
{
|
||||
FlattenNode *node = _node, *parent, *left;
|
||||
GtkFlattenListModel *self = node->list;
|
||||
@@ -323,10 +323,10 @@ gtk_flatten_list_model_set_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_flatten_list_model_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gtk_flatten_list_model_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFlattenListModel *self = GTK_FLATTEN_LIST_MODEL (object);
|
||||
|
||||
|
||||
+1
-1
@@ -1291,7 +1291,7 @@ gtk_grid_view_set_factory (GtkGridView *self,
|
||||
GtkListItemFactory *factory)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_GRID_VIEW (self));
|
||||
g_return_if_fail (factory == NULL || GTK_LIST_ITEM_FACTORY (factory));
|
||||
g_return_if_fail (factory == NULL || GTK_IS_LIST_ITEM_FACTORY (factory));
|
||||
|
||||
if (factory == gtk_list_item_manager_get_factory (self->item_manager))
|
||||
return;
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@
|
||||
* maximize and close buttons, or the window icon.
|
||||
*
|
||||
* For these reasons, `GtkHeaderBar` is the natural choice for use as the
|
||||
* custom titlebar widget of a `GtkWindow (see [method@Gtk.Window.set_titlebar]),
|
||||
* custom titlebar widget of a `GtkWindow` (see [method@Gtk.Window.set_titlebar]),
|
||||
* as it gives features typical of titlebars while allowing the addition of
|
||||
* child widgets.
|
||||
*
|
||||
|
||||
+14
-14
@@ -274,7 +274,6 @@ gtk_im_context_simple_init_compose_table (void)
|
||||
char **lang = NULL;
|
||||
const char * const sys_langs[] = { "el_gr", "fi_fi", "pt_br", NULL };
|
||||
const char * const *sys_lang = NULL;
|
||||
char *x11_compose_file_dir = get_x11_compose_file_dir ();
|
||||
|
||||
path = g_build_filename (g_get_user_config_dir (), "gtk-4.0", "Compose", NULL);
|
||||
if (g_file_test (path, G_FILE_TEST_EXISTS))
|
||||
@@ -323,7 +322,9 @@ gtk_im_context_simple_init_compose_table (void)
|
||||
{
|
||||
if (g_ascii_strncasecmp (*lang, *sys_lang, strlen (*sys_lang)) == 0)
|
||||
{
|
||||
char *x11_compose_file_dir = get_x11_compose_file_dir ();
|
||||
path = g_build_filename (x11_compose_file_dir, *lang, "Compose", NULL);
|
||||
g_free (x11_compose_file_dir);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -336,7 +337,6 @@ gtk_im_context_simple_init_compose_table (void)
|
||||
g_clear_pointer (&path, g_free);
|
||||
}
|
||||
|
||||
g_free (x11_compose_file_dir);
|
||||
g_strfreev (langs);
|
||||
|
||||
if (path != NULL &&
|
||||
@@ -406,7 +406,7 @@ gtk_im_context_simple_finalize (GObject *obj)
|
||||
|
||||
/**
|
||||
* gtk_im_context_simple_new:
|
||||
*
|
||||
*
|
||||
* Creates a new `GtkIMContextSimple`.
|
||||
*
|
||||
* Returns: a new `GtkIMContextSimple`
|
||||
@@ -483,14 +483,14 @@ check_hex (GtkIMContextSimple *context_simple,
|
||||
priv->tentative_match_len = 0;
|
||||
|
||||
str = g_string_new (NULL);
|
||||
|
||||
|
||||
i = 0;
|
||||
while (i < n_compose)
|
||||
{
|
||||
gunichar ch;
|
||||
|
||||
|
||||
ch = gdk_keyval_to_unicode (priv->compose_buffer[i]);
|
||||
|
||||
|
||||
if (ch == 0)
|
||||
return FALSE;
|
||||
|
||||
@@ -500,7 +500,7 @@ check_hex (GtkIMContextSimple *context_simple,
|
||||
buf[g_unichar_to_utf8 (ch, buf)] = '\0';
|
||||
|
||||
g_string_append (str, buf);
|
||||
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
@@ -523,7 +523,7 @@ check_hex (GtkIMContextSimple *context_simple,
|
||||
g_string_append_unichar (priv->tentative_match, n);
|
||||
priv->tentative_match_len = n_compose;
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -665,7 +665,7 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
|
||||
FALSE,
|
||||
&translated,
|
||||
&translated);
|
||||
|
||||
|
||||
gtk_im_context_filter_keypress (context, tmp_event);
|
||||
gdk_event_unref (tmp_event);
|
||||
}
|
||||
@@ -725,7 +725,7 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
|
||||
g_signal_emit_by_name (context, "preedit-end");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
keyval = gdk_key_event_get_keyval (event);
|
||||
ch = gdk_keyval_to_unicode (keyval);
|
||||
if (ch != 0 && !g_unichar_iscntrl (ch))
|
||||
@@ -783,7 +783,7 @@ canonical_hex_keyval (GdkEvent *event)
|
||||
}
|
||||
|
||||
g_free (keyvals);
|
||||
|
||||
|
||||
if (keyval)
|
||||
return keyval;
|
||||
else
|
||||
@@ -954,7 +954,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
|
||||
if (!priv->in_hex_sequence)
|
||||
g_signal_emit_by_name (context_simple, "preedit-end");
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -991,7 +991,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
priv->compose_buffer[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Check for hex sequence start */
|
||||
if (!priv->in_hex_sequence && have_hex_mods && is_hex_start)
|
||||
{
|
||||
@@ -1002,7 +1002,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
|
||||
g_signal_emit_by_name (context_simple, "preedit-start");
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
+51
-22
@@ -48,6 +48,7 @@ struct _GtkIMContextWaylandGlobal
|
||||
gboolean focused;
|
||||
|
||||
guint serial;
|
||||
guint done_serial;
|
||||
};
|
||||
|
||||
struct _GtkIMContextWaylandClass
|
||||
@@ -70,6 +71,7 @@ struct _GtkIMContextWayland
|
||||
{
|
||||
GtkIMContextSimple parent_instance;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *controller_widget;
|
||||
|
||||
GtkGesture *gesture;
|
||||
double press_x;
|
||||
@@ -207,11 +209,11 @@ text_input_commit (void *data,
|
||||
}
|
||||
|
||||
static void
|
||||
text_input_commit_apply (GtkIMContextWaylandGlobal *global, gboolean valid)
|
||||
text_input_commit_apply (GtkIMContextWaylandGlobal *global)
|
||||
{
|
||||
GtkIMContextWayland *context;
|
||||
context = GTK_IM_CONTEXT_WAYLAND (global->current);
|
||||
if (context->pending_commit && valid)
|
||||
if (context->pending_commit)
|
||||
g_signal_emit_by_name (global->current, "commit", context->pending_commit);
|
||||
g_free (context->pending_commit);
|
||||
context->pending_commit = NULL;
|
||||
@@ -236,8 +238,7 @@ text_input_delete_surrounding_text (void *data,
|
||||
}
|
||||
|
||||
static void
|
||||
text_input_delete_surrounding_text_apply (GtkIMContextWaylandGlobal *global,
|
||||
gboolean valid)
|
||||
text_input_delete_surrounding_text_apply (GtkIMContextWaylandGlobal *global)
|
||||
{
|
||||
GtkIMContextWayland *context;
|
||||
gboolean retval;
|
||||
@@ -248,7 +249,7 @@ text_input_delete_surrounding_text_apply (GtkIMContextWaylandGlobal *global,
|
||||
|
||||
len = context->pending_surrounding_delete.after_length
|
||||
+ context->pending_surrounding_delete.before_length;
|
||||
if (len > 0 && valid)
|
||||
if (len > 0)
|
||||
g_signal_emit_by_name (global->current, "delete-surrounding",
|
||||
-context->pending_surrounding_delete.before_length,
|
||||
len, &retval);
|
||||
@@ -262,16 +263,16 @@ text_input_done (void *data,
|
||||
{
|
||||
GtkIMContextWaylandGlobal *global = data;
|
||||
gboolean result;
|
||||
gboolean valid;
|
||||
|
||||
|
||||
global->done_serial = serial;
|
||||
|
||||
if (!global->current)
|
||||
return;
|
||||
|
||||
valid = serial == global->serial;
|
||||
text_input_delete_surrounding_text_apply(global, valid);
|
||||
text_input_commit_apply(global, valid);
|
||||
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);
|
||||
text_input_preedit_apply (global);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -288,6 +289,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;
|
||||
@@ -357,11 +360,13 @@ notify_cursor_location (GtkIMContextWayland *context)
|
||||
{
|
||||
GtkIMContextWaylandGlobal *global;
|
||||
cairo_rectangle_int_t rect;
|
||||
double x, y;
|
||||
double x, y, sx, sy;
|
||||
|
||||
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,
|
||||
@@ -369,8 +374,11 @@ notify_cursor_location (GtkIMContextWayland *context)
|
||||
rect.x, rect.y,
|
||||
&x, &y);
|
||||
|
||||
rect.x = x;
|
||||
rect.y = y;
|
||||
gtk_native_get_surface_transform (gtk_widget_get_native (context->widget),
|
||||
&sx, &sy);
|
||||
|
||||
rect.x = x + sx;
|
||||
rect.y = y + sy;
|
||||
zwp_text_input_v3_set_cursor_rectangle (global->text_input,
|
||||
rect.x, rect.y,
|
||||
rect.width, rect.height);
|
||||
@@ -449,6 +457,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,
|
||||
@@ -546,16 +556,21 @@ gtk_im_context_wayland_set_client_widget (GtkIMContext *context,
|
||||
return;
|
||||
|
||||
if (context_wayland->widget)
|
||||
gtk_im_context_wayland_focus_out (context);
|
||||
|
||||
if (context_wayland->controller_widget)
|
||||
{
|
||||
gtk_im_context_wayland_focus_out (context);
|
||||
gtk_widget_remove_controller (context_wayland->widget, GTK_EVENT_CONTROLLER (context_wayland->gesture));
|
||||
gtk_widget_remove_controller (context_wayland->controller_widget,
|
||||
GTK_EVENT_CONTROLLER (context_wayland->gesture));
|
||||
context_wayland->gesture = NULL;
|
||||
g_clear_object (&context_wayland->controller_widget);
|
||||
}
|
||||
|
||||
g_set_object (&context_wayland->widget, widget);
|
||||
|
||||
if (widget)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
GtkGesture *gesture;
|
||||
|
||||
gesture = gtk_gesture_click_new ();
|
||||
@@ -566,7 +581,18 @@ gtk_im_context_wayland_set_client_widget (GtkIMContext *context,
|
||||
G_CALLBACK (pressed_cb), context);
|
||||
g_signal_connect (gesture, "released",
|
||||
G_CALLBACK (released_cb), context);
|
||||
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
parent = gtk_widget_get_parent (widget);
|
||||
|
||||
if (parent &&
|
||||
GTK_IS_EDITABLE (widget) &&
|
||||
GTK_IS_EDITABLE (parent))
|
||||
g_set_object (&context_wayland->controller_widget, parent);
|
||||
else
|
||||
g_set_object (&context_wayland->controller_widget, widget);
|
||||
|
||||
gtk_widget_add_controller (context_wayland->controller_widget,
|
||||
GTK_EVENT_CONTROLLER (gesture));
|
||||
context_wayland->gesture = gesture;
|
||||
}
|
||||
}
|
||||
@@ -884,17 +910,20 @@ gtk_im_context_wayland_set_surrounding (GtkIMContext *context,
|
||||
|
||||
context_wayland = GTK_IM_CONTEXT_WAYLAND (context);
|
||||
|
||||
if (context_wayland->surrounding.text && text &&
|
||||
(len < 0 || len == strlen (context_wayland->surrounding.text)) &&
|
||||
strncmp (context_wayland->surrounding.text, text, len) == 0 &&
|
||||
context_wayland->surrounding.cursor_idx == cursor_index &&
|
||||
context_wayland->surrounding.anchor_idx == selection_bound)
|
||||
return;
|
||||
|
||||
g_free (context_wayland->surrounding.text);
|
||||
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);
|
||||
/* State changes coming from reset don't have any other opportunity to get
|
||||
* committed. */
|
||||
if (context_wayland->surrounding_change !=
|
||||
ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_INPUT_METHOD)
|
||||
commit_state (context_wayland);
|
||||
commit_state (context_wayland);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
||||
@@ -314,6 +314,11 @@ gtk_im_multicontext_set_client_widget (GtkIMContext *context,
|
||||
GtkIMContext *delegate;
|
||||
GtkSettings *settings;
|
||||
|
||||
if (priv->client_widget == widget)
|
||||
return;
|
||||
|
||||
gtk_im_multicontext_set_delegate (self, NULL, TRUE);
|
||||
|
||||
if (priv->client_widget != NULL)
|
||||
{
|
||||
settings = gtk_widget_get_settings (priv->client_widget);
|
||||
@@ -332,11 +337,11 @@ gtk_im_multicontext_set_client_widget (GtkIMContext *context,
|
||||
g_signal_connect (settings, "notify::gtk-im-module",
|
||||
G_CALLBACK (im_module_setting_changed),
|
||||
self);
|
||||
}
|
||||
|
||||
delegate = gtk_im_multicontext_get_delegate (self);
|
||||
if (delegate)
|
||||
gtk_im_context_set_client_widget (delegate, widget);
|
||||
delegate = gtk_im_multicontext_get_delegate (self);
|
||||
if (delegate)
|
||||
gtk_im_context_set_client_widget (delegate, widget);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+1
-5
@@ -3,11 +3,7 @@
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
#define P_(String) g_dgettext(GETTEXT_PACKAGE "-properties",String)
|
||||
#else
|
||||
#define P_(String) (String)
|
||||
#endif
|
||||
#define P_(String) g_dgettext (GETTEXT_PACKAGE "-properties", String)
|
||||
|
||||
/* not really I18N-related, but also a string marker macro */
|
||||
#define I_(string) g_intern_static_string (string)
|
||||
|
||||
@@ -181,8 +181,6 @@ gtk_kinetic_scrolling_tick (GtkKineticScrolling *data,
|
||||
{
|
||||
case GTK_KINETIC_SCROLLING_PHASE_DECELERATING:
|
||||
{
|
||||
double last_position = data->position;
|
||||
double last_time = data->t;
|
||||
double exp_part;
|
||||
|
||||
data->t += time_delta;
|
||||
@@ -199,8 +197,7 @@ gtk_kinetic_scrolling_tick (GtkKineticScrolling *data,
|
||||
{
|
||||
gtk_kinetic_scrolling_init_overshoot(data, data->upper, data->position, data->velocity);
|
||||
}
|
||||
else if (fabs(data->velocity) < 1 ||
|
||||
(last_time != 0.0 && fabs(data->position - last_position) < 1))
|
||||
else if (fabs(data->velocity) < 0.1)
|
||||
{
|
||||
gtk_kinetic_scrolling_stop (data);
|
||||
}
|
||||
@@ -254,6 +251,5 @@ gtk_kinetic_scrolling_stop (GtkKineticScrolling *data)
|
||||
{
|
||||
data->phase = GTK_KINETIC_SCROLLING_PHASE_FINISHED;
|
||||
data->position = round (data->position);
|
||||
data->velocity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -2547,7 +2547,7 @@ gtk_label_class_init (GtkLabelClass *class)
|
||||
* The number of lines to which an ellipsized, wrapping label
|
||||
* should be limited.
|
||||
*
|
||||
* This property has no effect if the label is not wrapping or ellipsized.
|
||||
* This property has no effect if the label is not wrapping and ellipsized.
|
||||
* Set this property to -1 if you don't want to limit the number of lines.
|
||||
*/
|
||||
label_props[PROP_LINES] =
|
||||
@@ -4168,8 +4168,10 @@ gtk_label_ensure_layout (GtkLabel *self)
|
||||
pango_layout_set_ellipsize (self->layout, self->ellipsize);
|
||||
pango_layout_set_wrap (self->layout, self->wrap_mode);
|
||||
pango_layout_set_single_paragraph_mode (self->layout, self->single_line_mode);
|
||||
if (self->lines > 0)
|
||||
if (self->wrap && self->lines > 0)
|
||||
pango_layout_set_height (self->layout, - self->lines);
|
||||
else
|
||||
pango_layout_set_height (self->layout, -1);
|
||||
|
||||
if (self->ellipsize || self->wrap)
|
||||
pango_layout_set_width (self->layout, gtk_widget_get_width (GTK_WIDGET (self)) * PANGO_SCALE);
|
||||
@@ -5777,7 +5779,7 @@ _gtk_label_get_selection_bound (GtkLabel *self)
|
||||
* Sets the number of lines to which an ellipsized, wrapping label
|
||||
* should be limited.
|
||||
*
|
||||
* This has no effect if the label is not wrapping or ellipsized.
|
||||
* This has no effect if the label is not wrapping and ellipsized.
|
||||
* Set this to -1 if you don’t want to limit the number of lines.
|
||||
*/
|
||||
void
|
||||
|
||||
@@ -825,7 +825,7 @@ gtk_list_item_manager_set_factory (GtkListItemManager *self,
|
||||
GSList *l;
|
||||
|
||||
g_return_if_fail (GTK_IS_LIST_ITEM_MANAGER (self));
|
||||
g_return_if_fail (GTK_IS_LIST_ITEM_FACTORY (factory));
|
||||
g_return_if_fail (factory == NULL || GTK_IS_LIST_ITEM_FACTORY (factory));
|
||||
|
||||
if (self->factory == factory)
|
||||
return;
|
||||
|
||||
+1
-1
@@ -1032,7 +1032,7 @@ gtk_list_view_set_factory (GtkListView *self,
|
||||
GtkListItemFactory *factory)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_LIST_VIEW (self));
|
||||
g_return_if_fail (factory == NULL || GTK_LIST_ITEM_FACTORY (factory));
|
||||
g_return_if_fail (factory == NULL || GTK_IS_LIST_ITEM_FACTORY (factory));
|
||||
|
||||
if (factory == gtk_list_item_manager_get_factory (self->item_manager))
|
||||
return;
|
||||
|
||||
+20
-30
@@ -505,13 +505,11 @@ gettext_initialization (void)
|
||||
{
|
||||
setlocale_initialization ();
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
bindtextdomain (GETTEXT_PACKAGE, _gtk_get_localedir ());
|
||||
bindtextdomain (GETTEXT_PACKAGE "-properties", _gtk_get_localedir ());
|
||||
# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
|
||||
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
|
||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||
bind_textdomain_codeset (GETTEXT_PACKAGE "-properties", "UTF-8");
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -899,31 +897,11 @@ rewrite_event_for_surface (GdkEvent *event,
|
||||
GdkSurface *new_surface)
|
||||
{
|
||||
GdkEventType type;
|
||||
double x, y;
|
||||
double x = -G_MAXDOUBLE, y = -G_MAXDOUBLE;
|
||||
double dx, dy;
|
||||
|
||||
type = gdk_event_get_event_type (event);
|
||||
|
||||
switch ((guint) type)
|
||||
{
|
||||
case GDK_BUTTON_PRESS:
|
||||
case GDK_BUTTON_RELEASE:
|
||||
case GDK_MOTION_NOTIFY:
|
||||
case GDK_TOUCH_BEGIN:
|
||||
case GDK_TOUCH_UPDATE:
|
||||
case GDK_TOUCH_END:
|
||||
case GDK_TOUCH_CANCEL:
|
||||
case GDK_TOUCHPAD_SWIPE:
|
||||
case GDK_TOUCHPAD_PINCH:
|
||||
case GDK_TOUCHPAD_HOLD:
|
||||
gdk_event_get_position (event, &x, &y);
|
||||
gdk_surface_translate_coordinates (gdk_event_get_surface (event), new_surface, &x, &y);
|
||||
break;
|
||||
default:
|
||||
x = y = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
switch ((guint) type)
|
||||
{
|
||||
case GDK_BUTTON_PRESS:
|
||||
@@ -1033,8 +1011,7 @@ rewrite_event_for_grabs (GdkEvent *event)
|
||||
display = gdk_event_get_display (event);
|
||||
device = gdk_event_get_device (event);
|
||||
|
||||
if (!gdk_device_grab_info (display, device, &grab_surface, &owner_events) ||
|
||||
!owner_events)
|
||||
if (!gdk_device_grab_info (display, device, &grab_surface, &owner_events))
|
||||
return NULL;
|
||||
break;
|
||||
default:
|
||||
@@ -1044,11 +1021,24 @@ rewrite_event_for_grabs (GdkEvent *event)
|
||||
event_widget = gtk_get_event_widget (event);
|
||||
grab_widget = GTK_WIDGET (gtk_native_get_for_surface (grab_surface));
|
||||
|
||||
if (grab_widget &&
|
||||
gtk_main_get_window_group (grab_widget) != gtk_main_get_window_group (event_widget))
|
||||
return rewrite_event_for_surface (event, grab_surface);
|
||||
else
|
||||
if (!grab_widget)
|
||||
return NULL;
|
||||
|
||||
/* If owner_events was set, events in client surfaces get forwarded
|
||||
* as normal, but we consider other window groups foreign surfaces.
|
||||
*/
|
||||
if (owner_events &&
|
||||
gtk_main_get_window_group (grab_widget) == gtk_main_get_window_group (event_widget))
|
||||
return NULL;
|
||||
|
||||
/* If owner_events was not set, events only get sent to the grabbing
|
||||
* surface.
|
||||
*/
|
||||
if (!owner_events &&
|
||||
grab_surface == gtk_native_get_surface (gtk_widget_get_native (event_widget)))
|
||||
return NULL;
|
||||
|
||||
return rewrite_event_for_surface (event, grab_surface);
|
||||
}
|
||||
|
||||
static GdkEvent *
|
||||
|
||||
@@ -379,8 +379,8 @@ update_node_ordering (GtkModelButton *button)
|
||||
gtk_widget_insert_before (button->end_indicator, GTK_WIDGET (button), child);
|
||||
|
||||
child = gtk_widget_get_last_child (GTK_WIDGET (button));
|
||||
if (child != button->start_box)
|
||||
gtk_widget_insert_after (button->start_box, GTK_WIDGET (button), child);
|
||||
if (button->end_indicator && child != button->end_indicator)
|
||||
gtk_widget_insert_after (button->end_indicator, GTK_WIDGET (button), child);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -346,10 +346,10 @@ gtk_overlay_child_update_style_classes (GtkOverlay *overlay,
|
||||
gboolean is_left, is_right, is_top, is_bottom;
|
||||
gboolean has_left, has_right, has_top, has_bottom;
|
||||
|
||||
has_left = gtk_widget_has_css_class (widget, "left");
|
||||
has_right = gtk_widget_has_css_class (widget, "right");
|
||||
has_top = gtk_widget_has_css_class (widget, "top");
|
||||
has_bottom = gtk_widget_has_css_class (widget, "bottom");
|
||||
has_left = gtk_widget_has_css_class (child, "left");
|
||||
has_right = gtk_widget_has_css_class (child, "right");
|
||||
has_top = gtk_widget_has_css_class (child, "top");
|
||||
has_bottom = gtk_widget_has_css_class (child, "bottom");
|
||||
|
||||
is_left = is_right = is_top = is_bottom = FALSE;
|
||||
|
||||
@@ -372,24 +372,24 @@ gtk_overlay_child_update_style_classes (GtkOverlay *overlay,
|
||||
is_bottom = (child_allocation->y + child_allocation->height == height);
|
||||
|
||||
if (has_left && !is_left)
|
||||
gtk_widget_remove_css_class (widget, "left");
|
||||
gtk_widget_remove_css_class (child, "left");
|
||||
else if (!has_left && is_left)
|
||||
gtk_widget_add_css_class (widget, "left");
|
||||
gtk_widget_add_css_class (child, "left");
|
||||
|
||||
if (has_right && !is_right)
|
||||
gtk_widget_remove_css_class (widget, "right");
|
||||
gtk_widget_remove_css_class (child, "right");
|
||||
else if (!has_right && is_right)
|
||||
gtk_widget_add_css_class (widget, "right");
|
||||
gtk_widget_add_css_class (child, "right");
|
||||
|
||||
if (has_top && !is_top)
|
||||
gtk_widget_remove_css_class (widget, "top");
|
||||
gtk_widget_remove_css_class (child, "top");
|
||||
else if (!has_top && is_top)
|
||||
gtk_widget_add_css_class (widget, "top");
|
||||
gtk_widget_add_css_class (child, "top");
|
||||
|
||||
if (has_bottom && !is_bottom)
|
||||
gtk_widget_remove_css_class (widget, "bottom");
|
||||
gtk_widget_remove_css_class (child, "bottom");
|
||||
else if (!has_bottom && is_bottom)
|
||||
gtk_widget_add_css_class (widget, "bottom");
|
||||
gtk_widget_add_css_class (child, "bottom");
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -921,7 +921,8 @@ create_cloud_provider_account_row (GtkPlacesSidebar *sidebar,
|
||||
|
||||
g_free (tooltip);
|
||||
g_free (mount_uri);
|
||||
g_object_unref (end_icon);
|
||||
g_clear_object (&end_icon);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
|
||||
+11
-9
@@ -2202,25 +2202,27 @@ gtk_range_scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
||||
GtkRange *range)
|
||||
{
|
||||
GtkRangePrivate *priv = gtk_range_get_instance_private (range);
|
||||
double scroll_unit, delta;
|
||||
double delta;
|
||||
gboolean handled;
|
||||
GtkOrientation move_orientation;
|
||||
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
scroll_unit = 1;
|
||||
#else
|
||||
scroll_unit = gtk_adjustment_get_page_increment (priv->adjustment);
|
||||
#endif
|
||||
GdkScrollUnit scroll_unit;
|
||||
|
||||
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL && dx != 0)
|
||||
{
|
||||
move_orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||
delta = dx * scroll_unit;
|
||||
delta = dx;
|
||||
}
|
||||
else
|
||||
{
|
||||
move_orientation = GTK_ORIENTATION_VERTICAL;
|
||||
delta = dy * scroll_unit;
|
||||
delta = dy;
|
||||
}
|
||||
|
||||
scroll_unit = gtk_event_controller_scroll_get_unit (scroll);
|
||||
|
||||
if (scroll_unit == GDK_SCROLL_UNIT_WHEEL)
|
||||
{
|
||||
delta *= gtk_adjustment_get_page_increment (priv->adjustment);
|
||||
}
|
||||
|
||||
if (delta != 0 && should_invert_move (range, move_orientation))
|
||||
|
||||
+7
-8
@@ -29,13 +29,11 @@
|
||||
* All scrollable widgets should do the following.
|
||||
*
|
||||
* - When a parent widget sets the scrollable child widget’s adjustments,
|
||||
* the widget should populate the adjustments’
|
||||
* [property@Gtk.Adjustment:lower],
|
||||
* [property@Gtk.Adjustment:upper],
|
||||
* [property@Gtk.Adjustment:step-increment],
|
||||
* [property@Gtk.Adjustment:page-increment] and
|
||||
* [property@Gtk.Adjustment:page-size] properties and connect to the
|
||||
* [signal@Gtk.Adjustment::value-changed] signal.
|
||||
* the widget should connect to the [signal@Gtk.Adjustment::value-changed]
|
||||
* signal. The child widget should then populate the adjustments’ properties
|
||||
* as soon as possible, which usually means queueing an allocation right away
|
||||
* and populating the properties in the [vfunc@Gtk.Widget.size_allocate]
|
||||
* implementation.
|
||||
*
|
||||
* - Because its preferred size is the size for a fully expanded widget,
|
||||
* the scrollable widget must be able to cope with underallocations.
|
||||
@@ -43,7 +41,8 @@
|
||||
* [vfunc@Gtk.Widget.size_allocate] implementation.
|
||||
*
|
||||
* - When the parent allocates space to the scrollable child widget,
|
||||
* the widget should update the adjustments’ properties with new values.
|
||||
* the widget must ensure the adjustments’ property values are correct and up
|
||||
* to date, for example using [method@Gtk.Adjustment.configure].
|
||||
*
|
||||
* - When any of the adjustments emits the [signal@Gtk.Adjustment::value-changed]
|
||||
* signal, the scrollable widget should scroll its contents.
|
||||
|
||||
+88
-65
@@ -1052,9 +1052,15 @@ gtk_scrolled_window_decelerate (GtkScrolledWindow *scrolled_window,
|
||||
|
||||
if (priv->x_velocity != 0 || priv->y_velocity != 0 || overshoot)
|
||||
{
|
||||
gtk_scrolled_window_start_deceleration (scrolled_window);
|
||||
if (priv->deceleration_id == 0)
|
||||
gtk_scrolled_window_start_deceleration (scrolled_window);
|
||||
priv->x_velocity = priv->y_velocity = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_clear_pointer (&priv->hscrolling, gtk_kinetic_scrolling_free);
|
||||
g_clear_pointer (&priv->vscrolling, gtk_kinetic_scrolling_free);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1225,16 +1231,14 @@ check_update_scrollbar_proximity (GtkScrolledWindow *sw,
|
||||
}
|
||||
|
||||
static double
|
||||
get_scroll_unit (GtkScrolledWindow *sw,
|
||||
GtkOrientation orientation)
|
||||
get_wheel_detent_scroll_step (GtkScrolledWindow *sw,
|
||||
GtkOrientation orientation)
|
||||
{
|
||||
double scroll_unit;
|
||||
|
||||
#ifndef GDK_WINDOWING_MACOS
|
||||
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (sw);
|
||||
GtkScrollbar *scrollbar;
|
||||
GtkAdjustment *adj;
|
||||
double page_size;
|
||||
double scroll_step;
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
scrollbar = GTK_SCROLLBAR (priv->hscrollbar);
|
||||
@@ -1246,12 +1250,9 @@ get_scroll_unit (GtkScrolledWindow *sw,
|
||||
|
||||
adj = gtk_scrollbar_get_adjustment (scrollbar);
|
||||
page_size = gtk_adjustment_get_page_size (adj);
|
||||
scroll_unit = pow (page_size, 2.0 / 3.0);
|
||||
#else
|
||||
scroll_unit = 1;
|
||||
#endif
|
||||
scroll_step = pow (page_size, 2.0 / 3.0);
|
||||
|
||||
return scroll_unit;
|
||||
return scroll_step;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -1393,12 +1394,18 @@ scrolled_window_scroll (GtkScrolledWindow *scrolled_window,
|
||||
{
|
||||
GtkAdjustment *adj;
|
||||
double new_value;
|
||||
double scroll_unit;
|
||||
GdkScrollUnit scroll_unit;
|
||||
|
||||
adj = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
|
||||
scroll_unit = get_scroll_unit (scrolled_window, GTK_ORIENTATION_HORIZONTAL);
|
||||
scroll_unit = gtk_event_controller_scroll_get_unit (scroll);
|
||||
|
||||
new_value = priv->unclamped_hadj_value + delta_x * scroll_unit;
|
||||
if (scroll_unit == GDK_SCROLL_UNIT_WHEEL)
|
||||
{
|
||||
delta_x *= get_wheel_detent_scroll_step (scrolled_window,
|
||||
GTK_ORIENTATION_HORIZONTAL);
|
||||
}
|
||||
|
||||
new_value = priv->unclamped_hadj_value + delta_x;
|
||||
_gtk_scrolled_window_set_adjustment_value (scrolled_window, adj,
|
||||
new_value);
|
||||
}
|
||||
@@ -1408,12 +1415,18 @@ scrolled_window_scroll (GtkScrolledWindow *scrolled_window,
|
||||
{
|
||||
GtkAdjustment *adj;
|
||||
double new_value;
|
||||
double scroll_unit;
|
||||
GdkScrollUnit scroll_unit;
|
||||
|
||||
adj = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
|
||||
scroll_unit = get_scroll_unit (scrolled_window, GTK_ORIENTATION_VERTICAL);
|
||||
scroll_unit = gtk_event_controller_scroll_get_unit (scroll);
|
||||
|
||||
new_value = priv->unclamped_vadj_value + delta_y * scroll_unit;
|
||||
if (scroll_unit == GDK_SCROLL_UNIT_WHEEL)
|
||||
{
|
||||
delta_y *= get_wheel_detent_scroll_step (scrolled_window,
|
||||
GTK_ORIENTATION_VERTICAL);
|
||||
}
|
||||
|
||||
new_value = priv->unclamped_vadj_value + delta_y;
|
||||
_gtk_scrolled_window_set_adjustment_value (scrolled_window, adj,
|
||||
new_value);
|
||||
}
|
||||
@@ -1460,30 +1473,36 @@ scroll_controller_decelerate (GtkEventControllerScroll *scroll,
|
||||
double initial_vel_y,
|
||||
GtkScrolledWindow *scrolled_window)
|
||||
{
|
||||
double unit_x, unit_y;
|
||||
GdkScrollUnit scroll_unit;
|
||||
gboolean shifted;
|
||||
GdkModifierType state;
|
||||
|
||||
|
||||
scroll_unit = gtk_event_controller_scroll_get_unit (scroll);
|
||||
state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (scroll));
|
||||
|
||||
shifted = (state & GDK_SHIFT_MASK) != 0;
|
||||
|
||||
unit_x = get_scroll_unit (scrolled_window, GTK_ORIENTATION_HORIZONTAL);
|
||||
unit_y = get_scroll_unit (scrolled_window, GTK_ORIENTATION_VERTICAL);
|
||||
|
||||
if (shifted)
|
||||
{
|
||||
gtk_scrolled_window_decelerate (scrolled_window,
|
||||
initial_vel_y * unit_x,
|
||||
initial_vel_x * unit_y);
|
||||
double tmp;
|
||||
|
||||
tmp = initial_vel_x;
|
||||
initial_vel_x = initial_vel_y;
|
||||
initial_vel_y = tmp;
|
||||
}
|
||||
else
|
||||
|
||||
if (scroll_unit == GDK_SCROLL_UNIT_WHEEL)
|
||||
{
|
||||
gtk_scrolled_window_decelerate (scrolled_window,
|
||||
initial_vel_x * unit_x,
|
||||
initial_vel_y * unit_y);
|
||||
initial_vel_x *= get_wheel_detent_scroll_step (scrolled_window,
|
||||
GTK_ORIENTATION_HORIZONTAL);
|
||||
|
||||
initial_vel_y *= get_wheel_detent_scroll_step (scrolled_window,
|
||||
GTK_ORIENTATION_VERTICAL);
|
||||
}
|
||||
|
||||
gtk_scrolled_window_decelerate (scrolled_window,
|
||||
initial_vel_x,
|
||||
initial_vel_y);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3254,6 +3273,7 @@ scrolled_window_deceleration_cb (GtkWidget *widget,
|
||||
GtkAdjustment *hadjustment, *vadjustment;
|
||||
gint64 current_time;
|
||||
double position, elapsed;
|
||||
gboolean retval = G_SOURCE_REMOVE;
|
||||
|
||||
current_time = gdk_frame_clock_get_frame_time (frame_clock);
|
||||
elapsed = (current_time - priv->last_deceleration_time) / (double)G_TIME_SPAN_SECOND;
|
||||
@@ -3269,28 +3289,23 @@ scrolled_window_deceleration_cb (GtkWidget *widget,
|
||||
{
|
||||
priv->unclamped_hadj_value = position;
|
||||
gtk_adjustment_set_value (hadjustment, position);
|
||||
retval = G_SOURCE_CONTINUE;
|
||||
}
|
||||
else if (priv->hscrolling)
|
||||
g_clear_pointer (&priv->hscrolling, gtk_kinetic_scrolling_free);
|
||||
|
||||
if (priv->vscrolling &&
|
||||
gtk_kinetic_scrolling_tick (priv->vscrolling, elapsed, &position, NULL))
|
||||
{
|
||||
priv->unclamped_vadj_value = position;
|
||||
gtk_adjustment_set_value (vadjustment, position);
|
||||
}
|
||||
else if (priv->vscrolling)
|
||||
g_clear_pointer (&priv->vscrolling, gtk_kinetic_scrolling_free);
|
||||
|
||||
if (!priv->hscrolling && !priv->vscrolling)
|
||||
{
|
||||
gtk_scrolled_window_cancel_deceleration (scrolled_window);
|
||||
return G_SOURCE_REMOVE;
|
||||
retval = G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
gtk_scrolled_window_invalidate_overshoot (scrolled_window);
|
||||
if (retval == G_SOURCE_REMOVE)
|
||||
gtk_scrolled_window_cancel_deceleration (scrolled_window);
|
||||
else
|
||||
gtk_scrolled_window_invalidate_overshoot (scrolled_window);
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3354,19 +3369,23 @@ gtk_scrolled_window_start_deceleration (GtkScrolledWindow *scrolled_window)
|
||||
GtkAdjustment *hadjustment;
|
||||
|
||||
gtk_scrolled_window_accumulate_velocity (&priv->hscrolling, elapsed, &priv->x_velocity);
|
||||
g_clear_pointer (&priv->hscrolling, gtk_kinetic_scrolling_free);
|
||||
|
||||
hadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
|
||||
lower = gtk_adjustment_get_lower (hadjustment);
|
||||
upper = gtk_adjustment_get_upper (hadjustment);
|
||||
upper -= gtk_adjustment_get_page_size (hadjustment);
|
||||
priv->hscrolling =
|
||||
gtk_kinetic_scrolling_new (lower,
|
||||
upper,
|
||||
MAX_OVERSHOOT_DISTANCE,
|
||||
DECELERATION_FRICTION,
|
||||
OVERSHOOT_FRICTION,
|
||||
priv->unclamped_hadj_value,
|
||||
priv->x_velocity);
|
||||
if (priv->x_velocity != 0)
|
||||
{
|
||||
hadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
|
||||
lower = gtk_adjustment_get_lower (hadjustment);
|
||||
upper = gtk_adjustment_get_upper (hadjustment);
|
||||
upper -= gtk_adjustment_get_page_size (hadjustment);
|
||||
priv->hscrolling =
|
||||
gtk_kinetic_scrolling_new (lower,
|
||||
upper,
|
||||
MAX_OVERSHOOT_DISTANCE,
|
||||
DECELERATION_FRICTION,
|
||||
OVERSHOOT_FRICTION,
|
||||
priv->unclamped_hadj_value,
|
||||
priv->x_velocity);
|
||||
}
|
||||
}
|
||||
else
|
||||
g_clear_pointer (&priv->hscrolling, gtk_kinetic_scrolling_free);
|
||||
@@ -3377,19 +3396,23 @@ gtk_scrolled_window_start_deceleration (GtkScrolledWindow *scrolled_window)
|
||||
GtkAdjustment *vadjustment;
|
||||
|
||||
gtk_scrolled_window_accumulate_velocity (&priv->vscrolling, elapsed, &priv->y_velocity);
|
||||
g_clear_pointer (&priv->vscrolling, gtk_kinetic_scrolling_free);
|
||||
|
||||
vadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
|
||||
lower = gtk_adjustment_get_lower(vadjustment);
|
||||
upper = gtk_adjustment_get_upper(vadjustment);
|
||||
upper -= gtk_adjustment_get_page_size(vadjustment);
|
||||
priv->vscrolling =
|
||||
gtk_kinetic_scrolling_new (lower,
|
||||
upper,
|
||||
MAX_OVERSHOOT_DISTANCE,
|
||||
DECELERATION_FRICTION,
|
||||
OVERSHOOT_FRICTION,
|
||||
priv->unclamped_vadj_value,
|
||||
priv->y_velocity);
|
||||
if (priv->y_velocity != 0)
|
||||
{
|
||||
vadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
|
||||
lower = gtk_adjustment_get_lower(vadjustment);
|
||||
upper = gtk_adjustment_get_upper(vadjustment);
|
||||
upper -= gtk_adjustment_get_page_size(vadjustment);
|
||||
priv->vscrolling =
|
||||
gtk_kinetic_scrolling_new (lower,
|
||||
upper,
|
||||
MAX_OVERSHOOT_DISTANCE,
|
||||
DECELERATION_FRICTION,
|
||||
OVERSHOOT_FRICTION,
|
||||
priv->unclamped_vadj_value,
|
||||
priv->y_velocity);
|
||||
}
|
||||
}
|
||||
else
|
||||
g_clear_pointer (&priv->vscrolling, gtk_kinetic_scrolling_free);
|
||||
|
||||
+78
-6
@@ -106,6 +106,7 @@ enum {
|
||||
PROP_0,
|
||||
PROP_PLACEHOLDER_TEXT,
|
||||
PROP_ACTIVATES_DEFAULT,
|
||||
PROP_SEARCH_DELAY,
|
||||
NUM_PROPERTIES,
|
||||
};
|
||||
|
||||
@@ -122,6 +123,8 @@ struct _GtkSearchEntry
|
||||
GtkWidget *capture_widget;
|
||||
GtkEventController *capture_widget_controller;
|
||||
|
||||
guint search_delay;
|
||||
|
||||
GtkWidget *entry;
|
||||
GtkWidget *icon;
|
||||
|
||||
@@ -150,9 +153,6 @@ G_DEFINE_TYPE_WITH_CODE (GtkSearchEntry, gtk_search_entry, GTK_TYPE_WIDGET,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE,
|
||||
gtk_search_entry_editable_init))
|
||||
|
||||
/* 150 mseconds of delay */
|
||||
#define DELAYED_TIMEOUT_ID 150
|
||||
|
||||
static void
|
||||
text_changed (GtkSearchEntry *entry)
|
||||
{
|
||||
@@ -224,6 +224,10 @@ gtk_search_entry_set_property (GObject *object,
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_SEARCH_DELAY:
|
||||
gtk_search_entry_set_search_delay (entry, g_value_get_uint (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
@@ -250,6 +254,10 @@ gtk_search_entry_get_property (GObject *object,
|
||||
g_value_set_boolean (value, gtk_text_get_activates_default (GTK_TEXT (entry->entry)));
|
||||
break;
|
||||
|
||||
case PROP_SEARCH_DELAY:
|
||||
g_value_set_uint (value, entry->search_delay);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
@@ -315,6 +323,21 @@ gtk_search_entry_class_init (GtkSearchEntryClass *klass)
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkSearchEntry:search-delay:
|
||||
*
|
||||
* The delay in milliseconds from last keypress to the search
|
||||
* changed signal.
|
||||
*
|
||||
* Since: 4.8
|
||||
*/
|
||||
props[PROP_SEARCH_DELAY] =
|
||||
g_param_spec_uint ("search-delay",
|
||||
P_("Search delay"),
|
||||
P_("The delay from last keypress to the search-changed signal. If this is not set, it defaults to 150ms"),
|
||||
0, G_MAXUINT, 150,
|
||||
GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
g_object_class_install_properties (object_class, NUM_PROPERTIES, props);
|
||||
gtk_editable_install_properties (object_class, NUM_PROPERTIES);
|
||||
|
||||
@@ -339,8 +362,9 @@ gtk_search_entry_class_init (GtkSearchEntryClass *klass)
|
||||
* GtkSearchEntry::search-changed:
|
||||
* @entry: the entry on which the signal was emitted
|
||||
*
|
||||
* Emitted with a short delay of 150 milliseconds after the
|
||||
* last change to the entry text.
|
||||
* Emitted with a delay. The length of the delay can be
|
||||
* changed with the [property@Gtk.SearchEntry:search-delay]
|
||||
* property.
|
||||
*/
|
||||
signals[SEARCH_CHANGED] =
|
||||
g_signal_new (I_("search-changed"),
|
||||
@@ -526,7 +550,7 @@ reset_timeout (GtkSearchEntry *entry)
|
||||
{
|
||||
if (entry->delayed_changed_id > 0)
|
||||
g_source_remove (entry->delayed_changed_id);
|
||||
entry->delayed_changed_id = g_timeout_add (DELAYED_TIMEOUT_ID,
|
||||
entry->delayed_changed_id = g_timeout_add (entry->search_delay,
|
||||
gtk_search_entry_changed_timeout_cb,
|
||||
entry);
|
||||
gdk_source_set_static_name_by_id (entry->delayed_changed_id, "[gtk] gtk_search_entry_changed_timeout_cb");
|
||||
@@ -595,6 +619,8 @@ gtk_search_entry_init (GtkSearchEntry *entry)
|
||||
GtkWidget *icon;
|
||||
GtkGesture *press, *catchall;
|
||||
|
||||
entry->search_delay = 150;
|
||||
|
||||
/* The search icon is purely presentational */
|
||||
icon = g_object_new (GTK_TYPE_IMAGE,
|
||||
"accessible-role", GTK_ACCESSIBLE_ROLE_PRESENTATION,
|
||||
@@ -773,6 +799,52 @@ gtk_search_entry_get_key_capture_widget (GtkSearchEntry *entry)
|
||||
return entry->capture_widget;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_search_entry_set_search_delay:
|
||||
* @entry: a `GtkSearchEntry`
|
||||
* @delay: a delay in milliseconds
|
||||
*
|
||||
* Set the delay to be used between the last keypress and the
|
||||
* [signal@Gtk.SearchEntry::search-changed] signal being emitted.
|
||||
*
|
||||
* Since: 4.8
|
||||
*/
|
||||
void
|
||||
gtk_search_entry_set_search_delay (GtkSearchEntry *entry,
|
||||
guint delay)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_SEARCH_ENTRY (entry));
|
||||
|
||||
if (entry->search_delay == delay)
|
||||
return;
|
||||
|
||||
entry->search_delay = delay;
|
||||
|
||||
/* Apply the updated timeout */
|
||||
reset_timeout (entry);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_SEARCH_DELAY]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_search_entry_get_search_delay
|
||||
* @entry: a `GtkSearchEntry`
|
||||
*
|
||||
* Get the delay to be used between the last keypress and the
|
||||
* [signal@Gtk.SearchEntry::search-changed] signal being emitted.
|
||||
*
|
||||
* Returns: a delay in milliseconds.
|
||||
*
|
||||
* Since: 4.8
|
||||
*/
|
||||
guint
|
||||
gtk_search_entry_get_search_delay (GtkSearchEntry *entry)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SEARCH_ENTRY (entry), 0);
|
||||
|
||||
return entry->search_delay;
|
||||
}
|
||||
|
||||
GtkEventController *
|
||||
gtk_search_entry_get_key_controller (GtkSearchEntry *entry)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user