Compare commits
267 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cb7202ac6f | |||
| ef632da8b6 | |||
| 0967f6f3fc | |||
| ce7956cd50 | |||
| d29b378fa0 | |||
| 1129febd7d | |||
| 47928b9e14 | |||
| 01f17836ac | |||
| 7e919aaaa5 | |||
| 03a6420c37 | |||
| 375fbd4e47 | |||
| 813957a92f | |||
| 36ed4c2a29 | |||
| 8e78b53378 | |||
| 76ed6cf9d8 | |||
| a8c6f222ed | |||
| c5afea0c6b | |||
| efa42a6932 | |||
| 5d1b2f627c | |||
| 8f6f980e49 | |||
| 25b3b90920 | |||
| 71762d3b28 | |||
| f15224926a | |||
| 1570c41efa | |||
| 5e0f2d7d20 | |||
| 88743ab975 | |||
| 6f15447633 | |||
| 85f6995511 | |||
| 4d59a00074 | |||
| 2dbb1509d8 | |||
| 101c927c40 | |||
| 6d3eb18578 | |||
| d301695ba1 | |||
| ca8008e2c9 | |||
| 0d7b4ecb14 | |||
| 9a541d9b91 | |||
| cdfde6673d | |||
| 7ef95734af | |||
| de17e3b525 | |||
| f8a971a7df | |||
| e1a7629a85 | |||
| 7d3b8b0d09 | |||
| fff2fabd7a | |||
| 73b45ec77e | |||
| 8f95a5980e | |||
| 87d33470ed | |||
| 002e48c469 | |||
| f33549da91 | |||
| f3f32b47cc | |||
| 2c5f2a2bcb | |||
| b6d990af25 | |||
| 16171a232a | |||
| 031b5cad46 | |||
| 984274497d | |||
| 0cc0714312 | |||
| 766e2b1e63 | |||
| c8be597b7f | |||
| 4497ac7d75 | |||
| af21583d4d | |||
| 791da76ae1 | |||
| d398c00d20 | |||
| cb247276f5 | |||
| c6141dffd2 | |||
| 755d8f8332 | |||
| 32de29bb68 | |||
| 540cb58169 | |||
| a1a6e6a36a | |||
| 798ad9f62a | |||
| ad6255a841 | |||
| 6adaf7c33d | |||
| 95a4eff6ba | |||
| 9675c99043 | |||
| 76d0e1e398 | |||
| 14408b7485 | |||
| 2a11baf6ea | |||
| 51d40ca023 | |||
| 5d9d73b090 | |||
| 5f7e093168 | |||
| 0f70e6d70a | |||
| 259be23ff2 | |||
| 337eedb513 | |||
| 185354555c | |||
| 29905d1ce6 | |||
| 73dd73c859 | |||
| cfb0df14cc | |||
| b343abfa51 | |||
| 5df4d27752 | |||
| bbf5d142b3 | |||
| 1fbbaef49e | |||
| d88268c142 | |||
| 49ae68c2c7 | |||
| 1d72e3e193 | |||
| 77c3ef48cf | |||
| 20deda2bd6 | |||
| 447b166ed3 | |||
| 1b230324ba | |||
| 806c659efe | |||
| 51873ebe37 | |||
| 827219e214 | |||
| 5c9b25c66e | |||
| 37e4ae2fbd | |||
| 14f86ae24d | |||
| 849ffebc21 | |||
| 7dabc2a42c | |||
| bef8a3a0e9 | |||
| 31d2638088 | |||
| 40019517cf | |||
| 7a8f5ca970 | |||
| 4063c3dc31 | |||
| 96d0368290 | |||
| 9a0ec5b1e0 | |||
| 7b5a0a829a | |||
| 1030d9e5b1 | |||
| 0750b4fd28 | |||
| 1d4ce5a544 | |||
| 4b2d63167e | |||
| 6fe0a8c6b3 | |||
| 04eb7eef29 | |||
| 480a2c2770 | |||
| f699fff6e0 | |||
| 4bc145549d | |||
| cf7fa931d3 | |||
| 392b4d9ac5 | |||
| 3f126c7fc8 | |||
| 960717b273 | |||
| 5386cf89f2 | |||
| b7d948af69 | |||
| 446b2e25d3 | |||
| 17b1e7bae9 | |||
| 9dc679370c | |||
| 033cf4bfb7 | |||
| bf5f27c6d5 | |||
| 7a1073c3ae | |||
| e2fd33f78a | |||
| 89f25d1484 | |||
| 3c8b3cbf41 | |||
| 410d4bca83 | |||
| 168523264c | |||
| 435f143e2e | |||
| 98ccb67277 | |||
| 2d83bb1b91 | |||
| 298b6ee81a | |||
| 5ce3520a2a | |||
| 9cc3e2c8ef | |||
| 034f89b17f | |||
| 1ea09a327a | |||
| bc2f484ae9 | |||
| 228f813c43 | |||
| 17386b5cf7 | |||
| 288086b899 | |||
| d148f26658 | |||
| 7ca6440f4d | |||
| 1172810768 | |||
| 9c827cbff4 | |||
| da3aaf39b9 | |||
| a8926c9d87 | |||
| 443f8ddf6b | |||
| 6a7de806dd | |||
| 19873e549a | |||
| 05ca6bc189 | |||
| cbb1e74bb5 | |||
| 6afb6bb9d2 | |||
| 60afd056e0 | |||
| 4456b06853 | |||
| 2f72353e0e | |||
| 88af7b44aa | |||
| a7cd1918a8 | |||
| bcfd1bbd24 | |||
| 1a5e60be7c | |||
| 3ce3867403 | |||
| 00a61f92b6 | |||
| 986daa8225 | |||
| e72ca43a32 | |||
| f432c937cc | |||
| 1dd15b5237 | |||
| 5cdbbc6e61 | |||
| 0e2ac0ebf2 | |||
| c73cb2c154 | |||
| a756caa106 | |||
| da22ba3b86 | |||
| 7a0a92f2b6 | |||
| d927c3bee0 | |||
| 59c2efbcd6 | |||
| 94af080fb6 | |||
| 40841ec3be | |||
| f69bb2fb2b | |||
| db0b9f61ae | |||
| 63ab523146 | |||
| b94c3166bf | |||
| 7030e08f9c | |||
| 2cc6a3ee5c | |||
| 3dd188fe7e | |||
| d41603d82a | |||
| f7aff03c72 | |||
| a0b8e32462 | |||
| 50f76eb8cc | |||
| 9959ea98cd | |||
| 8ca3ac1970 | |||
| 27ba2411f0 | |||
| a6920855ea | |||
| c85e2401fa | |||
| 6fdcafc94a | |||
| 9bab218314 | |||
| 2854635850 | |||
| a976aa9740 | |||
| 074eb2a19d | |||
| 96812450fa | |||
| 93c688cd93 | |||
| 53afc4a9d9 | |||
| c96077590b | |||
| 6e47d0bf4a | |||
| 50b79ae0ab | |||
| 6b4709ea3c | |||
| f3a83abb54 | |||
| 33166b7357 | |||
| bb31ce1168 | |||
| dbf32933bf | |||
| af8fe182c8 | |||
| 731f0d4d01 | |||
| e42373df89 | |||
| da8050979e | |||
| 4dd1ff6dd2 | |||
| 8c403c43f0 | |||
| 2feb5c93ca | |||
| 9924a92e70 | |||
| 6c8988e445 | |||
| 9fb3b84253 | |||
| 3439862634 | |||
| 93c5455796 | |||
| e665667bff | |||
| 3ca59b8701 | |||
| fba0b359d4 | |||
| e1b6496af7 | |||
| 14620423e8 | |||
| 55a1f8ccfd | |||
| 19afe454df | |||
| 7d842cb7fc | |||
| 3137d326c5 | |||
| 12464731f1 | |||
| 269a9d8528 | |||
| c892d2767a | |||
| c8e082f296 | |||
| 51981d562b | |||
| 51b77a425a | |||
| ae3163b5e0 | |||
| af93646b3e | |||
| 64f5afe608 | |||
| fb98f939a5 | |||
| 7733f646d6 | |||
| fd69f1cd79 | |||
| ca94ff10ce | |||
| 9c3de51412 | |||
| d9dcfffce3 | |||
| dfd1372a9b | |||
| f3c670ab0c | |||
| 8aa4b5150e | |||
| ecaa16c367 | |||
| 2f8284a386 | |||
| 73cad1e784 | |||
| 0abd01e288 | |||
| b80942ec88 | |||
| 165dab8265 | |||
| 73d736d800 | |||
| 88b4076fe5 | |||
| 36396093e6 | |||
| bada3dbac6 | |||
| 9178423844 |
+1
-1
@@ -44,7 +44,7 @@ msys2-mingw32:
|
||||
<<: *mingw-defaults
|
||||
|
||||
.flatpak-defaults: &flatpak-defaults
|
||||
image: registry.gitlab.com/alatiera/gnome-nightly-oci/gnome-master:latest
|
||||
image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master
|
||||
stage: flatpak
|
||||
artifacts:
|
||||
paths:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
FROM fedora:28
|
||||
|
||||
RUN dnf -y install \
|
||||
hicolor-icon-theme \
|
||||
adwaita-icon-theme \
|
||||
atk-devel \
|
||||
at-spi2-atk-devel \
|
||||
|
||||
@@ -87,14 +87,14 @@ find_toplevel_at_pointer (GdkDisplay *display)
|
||||
return widget ? gtk_widget_get_toplevel (widget) : NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
release_event_cb (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gboolean *clicked)
|
||||
static void
|
||||
released_cb (GtkGestureMultiPress *gesture,
|
||||
guint n_press,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gboolean *clicked)
|
||||
{
|
||||
if (gdk_event_get_event_type (event) == GDK_BUTTON_RELEASE)
|
||||
*clicked = TRUE;
|
||||
return TRUE;
|
||||
*clicked = TRUE;
|
||||
}
|
||||
|
||||
/* Asks the user to click on a window, then waits for them click
|
||||
@@ -132,10 +132,12 @@ query_for_toplevel (GdkDisplay *display,
|
||||
GDK_SEAT_CAPABILITY_ALL_POINTING,
|
||||
FALSE, cursor, NULL, NULL, NULL) == GDK_GRAB_SUCCESS)
|
||||
{
|
||||
GtkGesture *gesture = gtk_gesture_multi_press_new ();
|
||||
gboolean clicked = FALSE;
|
||||
|
||||
g_signal_connect (popup, "event",
|
||||
G_CALLBACK (release_event_cb), &clicked);
|
||||
g_signal_connect (gesture, "released",
|
||||
G_CALLBACK (released_cb), &clicked);
|
||||
gtk_widget_add_controller (popup, GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
/* Process events until clicked is set by our button release event handler.
|
||||
* We pass in may_block=TRUE since we want to wait if there
|
||||
@@ -144,6 +146,8 @@ query_for_toplevel (GdkDisplay *display,
|
||||
while (!clicked)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
|
||||
gdk_seat_ungrab (gdk_device_get_seat (device));
|
||||
|
||||
toplevel = find_toplevel_at_pointer (display);
|
||||
if (toplevel == popup)
|
||||
toplevel = NULL;
|
||||
|
||||
@@ -120,7 +120,7 @@ get_image_paintable (GtkImage *image)
|
||||
|
||||
static void
|
||||
drag_begin (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
GdkDrag *drag,
|
||||
gpointer data)
|
||||
{
|
||||
GdkPaintable *paintable;
|
||||
@@ -128,14 +128,14 @@ drag_begin (GtkWidget *widget,
|
||||
paintable = get_image_paintable (GTK_IMAGE (widget));
|
||||
if (paintable)
|
||||
{
|
||||
gtk_drag_set_icon_paintable (context, paintable, -2, -2);
|
||||
gtk_drag_set_icon_paintable (drag, paintable, -2, -2);
|
||||
g_object_unref (paintable);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
drag_data_get (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
GdkDrag *drag,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
gpointer data)
|
||||
|
||||
@@ -161,7 +161,6 @@
|
||||
<file>editable_cells.c</file>
|
||||
<file>entry_buffer.c</file>
|
||||
<file>entry_completion.c</file>
|
||||
<file>event_axes.c</file>
|
||||
<file>expander.c</file>
|
||||
<file>filtermodel.c</file>
|
||||
<file>fishbowl.c</file>
|
||||
|
||||
@@ -1,666 +0,0 @@
|
||||
/* Touch and Drawing Tablets
|
||||
*
|
||||
* Demonstrates advanced handling of event information from exotic
|
||||
* input devices.
|
||||
*
|
||||
* On one hand, this snippet demonstrates management of drawing tablets,
|
||||
* those contain additional information for the pointer other than
|
||||
* X/Y coordinates. Tablet pads events are mapped to actions, which
|
||||
* are both defined and interpreted by the application.
|
||||
*
|
||||
* Input axes are dependent on hardware devices, on linux/unix you
|
||||
* can see the device axes through xinput list <device>. Each time
|
||||
* a different hardware device is used to move the pointer, the
|
||||
* master device will be updated to match the axes it provides,
|
||||
* these changes can be tracked through GdkDevice::changed, or
|
||||
* checking gdk_event_get_source_device().
|
||||
*
|
||||
* On the other hand, this demo handles basic multitouch events,
|
||||
* each event coming from an specific touchpoint will contain a
|
||||
* GdkEventSequence that's unique for its lifetime, so multiple
|
||||
* touchpoints can be tracked.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
typedef struct {
|
||||
GdkDevice *last_source;
|
||||
GdkDeviceTool *last_tool;
|
||||
gdouble *axes;
|
||||
GdkRGBA color;
|
||||
gdouble x;
|
||||
gdouble y;
|
||||
} AxesInfo;
|
||||
|
||||
typedef struct {
|
||||
GHashTable *pointer_info; /* GdkDevice -> AxesInfo */
|
||||
GHashTable *touch_info; /* GdkEventSequence -> AxesInfo */
|
||||
} EventData;
|
||||
|
||||
const gchar *colors[] = {
|
||||
"black",
|
||||
"orchid",
|
||||
"fuchsia",
|
||||
"indigo",
|
||||
"thistle",
|
||||
"sienna",
|
||||
"azure",
|
||||
"plum",
|
||||
"lime",
|
||||
"navy",
|
||||
"maroon",
|
||||
"burlywood"
|
||||
};
|
||||
|
||||
static GtkPadActionEntry pad_actions[] = {
|
||||
{ GTK_PAD_ACTION_BUTTON, 1, -1, N_("Nuclear strike"), "pad.nuke" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 2, -1, N_("Release siberian methane reserves"), "pad.heat" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 3, -1, N_("Release solar flare"), "pad.fry" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 4, -1, N_("De-stabilize Oort cloud"), "pad.fall" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 5, -1, N_("Ignite WR-104"), "pad.burst" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 6, -1, N_("Lart whoever asks about this button"), "pad.lart" },
|
||||
{ GTK_PAD_ACTION_RING, -1, -1, N_("Earth axial tilt"), "pad.tilt" },
|
||||
{ GTK_PAD_ACTION_STRIP, -1, -1, N_("Extent of weak nuclear force"), "pad.dissolve" },
|
||||
};
|
||||
|
||||
static const gchar *pad_action_results[] = {
|
||||
"☢",
|
||||
"♨",
|
||||
"☼",
|
||||
"☄",
|
||||
"⚡",
|
||||
"💫",
|
||||
"◑",
|
||||
"⚛"
|
||||
};
|
||||
|
||||
static guint cur_color = 0;
|
||||
static guint pad_action_timeout_id = 0;
|
||||
|
||||
static AxesInfo *
|
||||
axes_info_new (void)
|
||||
{
|
||||
AxesInfo *info;
|
||||
|
||||
info = g_new0 (AxesInfo, 1);
|
||||
gdk_rgba_parse (&info->color, colors[cur_color]);
|
||||
|
||||
cur_color = (cur_color + 1) % G_N_ELEMENTS (colors);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static EventData *
|
||||
event_data_new (void)
|
||||
{
|
||||
EventData *data;
|
||||
|
||||
data = g_new0 (EventData, 1);
|
||||
data->pointer_info = g_hash_table_new_full (NULL, NULL, NULL,
|
||||
(GDestroyNotify) g_free);
|
||||
data->touch_info = g_hash_table_new_full (NULL, NULL, NULL,
|
||||
(GDestroyNotify) g_free);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static void
|
||||
event_data_free (EventData *data)
|
||||
{
|
||||
g_hash_table_destroy (data->pointer_info);
|
||||
g_hash_table_destroy (data->touch_info);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
static void
|
||||
update_axes_from_event (GdkEvent *event,
|
||||
EventData *data)
|
||||
{
|
||||
GdkDevice *device, *source_device;
|
||||
GdkEventSequence *sequence;
|
||||
GdkDeviceTool *tool;
|
||||
GdkEventType type;
|
||||
gdouble x, y;
|
||||
AxesInfo *info;
|
||||
|
||||
device = gdk_event_get_device (event);
|
||||
source_device = gdk_event_get_source_device (event);
|
||||
sequence = gdk_event_get_event_sequence (event);
|
||||
tool = gdk_event_get_device_tool (event);
|
||||
type = gdk_event_get_event_type (event);
|
||||
|
||||
if (type == GDK_TOUCH_END ||
|
||||
type == GDK_TOUCH_CANCEL)
|
||||
{
|
||||
g_hash_table_remove (data->touch_info, sequence);
|
||||
return;
|
||||
}
|
||||
else if (type == GDK_LEAVE_NOTIFY)
|
||||
{
|
||||
g_hash_table_remove (data->pointer_info, device);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!source_device)
|
||||
return;
|
||||
|
||||
if (!sequence)
|
||||
{
|
||||
info = g_hash_table_lookup (data->pointer_info, device);
|
||||
|
||||
if (!info)
|
||||
{
|
||||
info = axes_info_new ();
|
||||
g_hash_table_insert (data->pointer_info, device, info);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
info = g_hash_table_lookup (data->touch_info, sequence);
|
||||
|
||||
if (!info)
|
||||
{
|
||||
info = axes_info_new ();
|
||||
g_hash_table_insert (data->touch_info, sequence, info);
|
||||
}
|
||||
}
|
||||
|
||||
if (info->last_source != source_device)
|
||||
info->last_source = source_device;
|
||||
|
||||
if (info->last_tool != tool)
|
||||
info->last_tool = tool;
|
||||
|
||||
g_clear_pointer (&info->axes, g_free);
|
||||
|
||||
if (type == GDK_TOUCH_BEGIN ||
|
||||
type == GDK_TOUCH_UPDATE)
|
||||
{
|
||||
gboolean emulating_pointer;
|
||||
|
||||
gdk_event_get_touch_emulating_pointer (event, &emulating_pointer);
|
||||
if (sequence && emulating_pointer)
|
||||
g_hash_table_remove (data->pointer_info, device);
|
||||
}
|
||||
if (type == GDK_MOTION_NOTIFY ||
|
||||
type == GDK_BUTTON_PRESS ||
|
||||
type == GDK_BUTTON_RELEASE)
|
||||
{
|
||||
gdouble *axes;
|
||||
guint n_axes;
|
||||
|
||||
gdk_event_get_axes (event, &axes, &n_axes);
|
||||
info->axes = g_memdup (axes, sizeof (double) * n_axes);
|
||||
}
|
||||
|
||||
if (gdk_event_get_coords (event, &x, &y))
|
||||
{
|
||||
info->x = x;
|
||||
info->y = y;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
event_cb (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
update_axes_from_event (event, user_data);
|
||||
gtk_widget_queue_draw (widget);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
render_arrow (cairo_t *cr,
|
||||
gdouble x_diff,
|
||||
gdouble y_diff,
|
||||
const gchar *label)
|
||||
{
|
||||
cairo_save (cr);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
cairo_new_path (cr);
|
||||
cairo_move_to (cr, 0, 0);
|
||||
cairo_line_to (cr, x_diff, y_diff);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_move_to (cr, x_diff, y_diff);
|
||||
cairo_show_text (cr, label);
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_axes_info (cairo_t *cr,
|
||||
AxesInfo *info,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
gdouble pressure, tilt_x, tilt_y, distance, wheel, rotation, slider;
|
||||
GdkAxisFlags axes = gdk_device_get_axes (info->last_source);
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
cairo_set_line_width (cr, 1);
|
||||
gdk_cairo_set_source_rgba (cr, &info->color);
|
||||
|
||||
cairo_move_to (cr, 0, info->y);
|
||||
cairo_line_to (cr, width, info->y);
|
||||
cairo_move_to (cr, info->x, 0);
|
||||
cairo_line_to (cr, info->x, height);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_translate (cr, info->x, info->y);
|
||||
|
||||
if (!info->axes)
|
||||
{
|
||||
cairo_restore (cr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (axes & GDK_AXIS_FLAG_PRESSURE)
|
||||
{
|
||||
cairo_pattern_t *pattern;
|
||||
|
||||
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_PRESSURE,
|
||||
&pressure);
|
||||
|
||||
pattern = cairo_pattern_create_radial (0, 0, 0, 0, 0, 100);
|
||||
cairo_pattern_add_color_stop_rgba (pattern, pressure, 1, 0, 0, pressure);
|
||||
cairo_pattern_add_color_stop_rgba (pattern, 1, 0, 0, 1, 0);
|
||||
|
||||
cairo_set_source (cr, pattern);
|
||||
|
||||
cairo_arc (cr, 0, 0, 100, 0, 2 * G_PI);
|
||||
cairo_fill (cr);
|
||||
|
||||
cairo_pattern_destroy (pattern);
|
||||
}
|
||||
|
||||
if (axes & GDK_AXIS_FLAG_XTILT &&
|
||||
axes & GDK_AXIS_FLAG_YTILT)
|
||||
{
|
||||
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_XTILT,
|
||||
&tilt_x);
|
||||
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_YTILT,
|
||||
&tilt_y);
|
||||
|
||||
render_arrow (cr, tilt_x * 100, tilt_y * 100, "Tilt");
|
||||
}
|
||||
|
||||
if (axes & GDK_AXIS_FLAG_DISTANCE)
|
||||
{
|
||||
double dashes[] = { 5.0, 5.0 };
|
||||
cairo_text_extents_t extents;
|
||||
|
||||
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_DISTANCE,
|
||||
&distance);
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
cairo_move_to (cr, distance * 100, 0);
|
||||
|
||||
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
|
||||
cairo_set_dash (cr, dashes, 2, 0.0);
|
||||
cairo_arc (cr, 0, 0, distance * 100, 0, 2 * G_PI);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_move_to (cr, 0, -distance * 100);
|
||||
cairo_text_extents (cr, "Distance", &extents);
|
||||
cairo_rel_move_to (cr, -extents.width / 2, 0);
|
||||
cairo_show_text (cr, "Distance");
|
||||
|
||||
cairo_move_to (cr, 0, 0);
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
if (axes & GDK_AXIS_FLAG_WHEEL)
|
||||
{
|
||||
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_WHEEL,
|
||||
&wheel);
|
||||
|
||||
cairo_save (cr);
|
||||
cairo_set_line_width (cr, 10);
|
||||
cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
|
||||
|
||||
cairo_new_sub_path (cr);
|
||||
cairo_arc (cr, 0, 0, 100, 0, wheel * 2 * G_PI);
|
||||
cairo_stroke (cr);
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
if (axes & GDK_AXIS_FLAG_ROTATION)
|
||||
{
|
||||
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_ROTATION,
|
||||
&rotation);
|
||||
rotation *= 2 * G_PI;
|
||||
|
||||
cairo_save (cr);
|
||||
cairo_rotate (cr, - G_PI / 2);
|
||||
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
|
||||
cairo_set_line_width (cr, 5);
|
||||
|
||||
cairo_new_sub_path (cr);
|
||||
cairo_arc (cr, 0, 0, 100, 0, rotation);
|
||||
cairo_stroke (cr);
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
if (axes & GDK_AXIS_FLAG_SLIDER)
|
||||
{
|
||||
cairo_pattern_t *pattern, *mask;
|
||||
|
||||
gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_SLIDER,
|
||||
&slider);
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
cairo_move_to (cr, 0, -10);
|
||||
cairo_rel_line_to (cr, 0, -50);
|
||||
cairo_rel_line_to (cr, 10, 0);
|
||||
cairo_rel_line_to (cr, -5, 50);
|
||||
cairo_close_path (cr);
|
||||
|
||||
cairo_clip_preserve (cr);
|
||||
|
||||
pattern = cairo_pattern_create_linear (0, -10, 0, -60);
|
||||
cairo_pattern_add_color_stop_rgb (pattern, 0, 0, 1, 0);
|
||||
cairo_pattern_add_color_stop_rgb (pattern, 1, 1, 0, 0);
|
||||
cairo_set_source (cr, pattern);
|
||||
cairo_pattern_destroy (pattern);
|
||||
|
||||
mask = cairo_pattern_create_linear (0, -10, 0, -60);
|
||||
cairo_pattern_add_color_stop_rgba (mask, 0, 0, 0, 0, 1);
|
||||
cairo_pattern_add_color_stop_rgba (mask, slider, 0, 0, 0, 1);
|
||||
cairo_pattern_add_color_stop_rgba (mask, slider, 0, 0, 0, 0);
|
||||
cairo_pattern_add_color_stop_rgba (mask, 1, 0, 0, 0, 0);
|
||||
cairo_mask (cr, mask);
|
||||
cairo_pattern_destroy (mask);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
tool_type_to_string (GdkDeviceToolType tool_type)
|
||||
{
|
||||
switch (tool_type)
|
||||
{
|
||||
case GDK_DEVICE_TOOL_TYPE_PEN:
|
||||
return "Pen";
|
||||
case GDK_DEVICE_TOOL_TYPE_ERASER:
|
||||
return "Eraser";
|
||||
case GDK_DEVICE_TOOL_TYPE_BRUSH:
|
||||
return "Brush";
|
||||
case GDK_DEVICE_TOOL_TYPE_PENCIL:
|
||||
return "Pencil";
|
||||
case GDK_DEVICE_TOOL_TYPE_AIRBRUSH:
|
||||
return "Airbrush";
|
||||
case GDK_DEVICE_TOOL_TYPE_MOUSE:
|
||||
return "Mouse";
|
||||
case GDK_DEVICE_TOOL_TYPE_LENS:
|
||||
return "Lens cursor";
|
||||
case GDK_DEVICE_TOOL_TYPE_UNKNOWN:
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_device_info (GtkWidget *widget,
|
||||
cairo_t *cr,
|
||||
GdkEventSequence *sequence,
|
||||
gint *y,
|
||||
AxesInfo *info)
|
||||
{
|
||||
PangoLayout *layout;
|
||||
GString *string;
|
||||
gint height;
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
string = g_string_new (NULL);
|
||||
g_string_append_printf (string, "Source: %s",
|
||||
gdk_device_get_name (info->last_source));
|
||||
|
||||
if (sequence)
|
||||
g_string_append_printf (string, "\nSequence: %d",
|
||||
GPOINTER_TO_UINT (sequence));
|
||||
|
||||
if (info->last_tool)
|
||||
{
|
||||
const gchar *tool_type;
|
||||
guint64 serial;
|
||||
|
||||
tool_type = tool_type_to_string (gdk_device_tool_get_tool_type (info->last_tool));
|
||||
serial = gdk_device_tool_get_serial (info->last_tool);
|
||||
g_string_append_printf (string, "\nTool: %s", tool_type);
|
||||
|
||||
if (serial != 0)
|
||||
g_string_append_printf (string, ", Serial: %" G_GINT64_MODIFIER "x", serial);
|
||||
}
|
||||
|
||||
cairo_move_to (cr, 10, *y);
|
||||
layout = gtk_widget_create_pango_layout (widget, string->str);
|
||||
pango_cairo_show_layout (cr, layout);
|
||||
cairo_stroke (cr);
|
||||
|
||||
pango_layout_get_pixel_size (layout, NULL, &height);
|
||||
|
||||
gdk_cairo_set_source_rgba (cr, &info->color);
|
||||
cairo_set_line_width (cr, 10);
|
||||
cairo_move_to (cr, 0, *y);
|
||||
|
||||
*y = *y + height;
|
||||
cairo_line_to (cr, 0, *y);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_restore (cr);
|
||||
|
||||
g_object_unref (layout);
|
||||
g_string_free (string, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_cb (GtkDrawingArea *da,
|
||||
cairo_t *cr,
|
||||
int width,
|
||||
int height,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (da);
|
||||
EventData *data = user_data;
|
||||
AxesInfo *info;
|
||||
GHashTableIter iter;
|
||||
gpointer key, value;
|
||||
gint y = 0;
|
||||
|
||||
/* Draw Abs info */
|
||||
g_hash_table_iter_init (&iter, data->pointer_info);
|
||||
|
||||
while (g_hash_table_iter_next (&iter, NULL, &value))
|
||||
{
|
||||
info = value;
|
||||
draw_axes_info (cr, info, width, height);
|
||||
}
|
||||
|
||||
g_hash_table_iter_init (&iter, data->touch_info);
|
||||
|
||||
while (g_hash_table_iter_next (&iter, NULL, &value))
|
||||
{
|
||||
info = value;
|
||||
draw_axes_info (cr, info, width, height);
|
||||
}
|
||||
|
||||
/* Draw name, color legend and misc data */
|
||||
g_hash_table_iter_init (&iter, data->pointer_info);
|
||||
|
||||
while (g_hash_table_iter_next (&iter, NULL, &value))
|
||||
{
|
||||
info = value;
|
||||
draw_device_info (widget, cr, NULL, &y, info);
|
||||
}
|
||||
|
||||
g_hash_table_iter_init (&iter, data->touch_info);
|
||||
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
{
|
||||
info = value;
|
||||
draw_device_info (widget, cr, key, &y, info);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_label_text (GtkWidget *label,
|
||||
const gchar *text)
|
||||
{
|
||||
gchar *markup = NULL;
|
||||
|
||||
if (text)
|
||||
markup = g_strdup_printf ("<span font='48.0'>%s</span>", text);
|
||||
gtk_label_set_markup (GTK_LABEL (label), markup);
|
||||
g_free (markup);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
reset_label_text_timeout_cb (gpointer user_data)
|
||||
{
|
||||
GtkWidget *label = user_data;
|
||||
|
||||
update_label_text (label, NULL);
|
||||
pad_action_timeout_id = 0;
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
update_label_and_timeout (GtkWidget *label,
|
||||
const gchar *text)
|
||||
{
|
||||
if (pad_action_timeout_id)
|
||||
g_source_remove (pad_action_timeout_id);
|
||||
|
||||
update_label_text (label, text);
|
||||
pad_action_timeout_id = g_timeout_add (200, reset_label_text_timeout_cb, label);
|
||||
}
|
||||
|
||||
static void
|
||||
on_action_activate (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *label = user_data;
|
||||
const gchar *result;
|
||||
gchar *str;
|
||||
|
||||
result = g_object_get_data (G_OBJECT (action), "action-result");
|
||||
|
||||
if (!parameter)
|
||||
update_label_and_timeout (label, result);
|
||||
else
|
||||
{
|
||||
str = g_strdup_printf ("%s %.2f", result, g_variant_get_double (parameter));
|
||||
update_label_and_timeout (label, str);
|
||||
g_free (str);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
init_pad_controller (GtkWidget *window,
|
||||
GtkWidget *label)
|
||||
{
|
||||
GtkPadController *pad_controller;
|
||||
GSimpleActionGroup *action_group;
|
||||
GSimpleAction *action;
|
||||
gint i;
|
||||
|
||||
action_group = g_simple_action_group_new ();
|
||||
pad_controller = gtk_pad_controller_new (G_ACTION_GROUP (action_group),
|
||||
NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (pad_actions); i++)
|
||||
{
|
||||
if (pad_actions[i].type == GTK_PAD_ACTION_BUTTON)
|
||||
{
|
||||
action = g_simple_action_new (pad_actions[i].action_name, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
action = g_simple_action_new_stateful (pad_actions[i].action_name,
|
||||
G_VARIANT_TYPE_DOUBLE, NULL);
|
||||
}
|
||||
|
||||
g_signal_connect (action, "activate",
|
||||
G_CALLBACK (on_action_activate), label);
|
||||
g_object_set_data (G_OBJECT (action), "action-result",
|
||||
(gpointer) pad_action_results[i]);
|
||||
g_action_map_add_action (G_ACTION_MAP (action_group), G_ACTION (action));
|
||||
g_object_unref (action);
|
||||
}
|
||||
|
||||
gtk_pad_controller_set_action_entries (pad_controller, pad_actions,
|
||||
G_N_ELEMENTS (pad_actions));
|
||||
gtk_widget_add_controller (window, GTK_EVENT_CONTROLLER (pad_controller));
|
||||
|
||||
g_object_unref (action_group);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_event_axes (GtkWidget *toplevel)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
EventData *event_data;
|
||||
GtkWidget *label;
|
||||
GtkWidget *overlay;
|
||||
GtkWidget *da;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Touch and Drawing Tablets");
|
||||
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
|
||||
gtk_widget_set_support_multidevice (window, TRUE);
|
||||
|
||||
event_data = event_data_new ();
|
||||
g_object_set_data_full (G_OBJECT (window), "gtk-demo-event-data",
|
||||
event_data, (GDestroyNotify) event_data_free);
|
||||
|
||||
da = gtk_drawing_area_new ();
|
||||
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (da), 400);
|
||||
gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (da), 400);
|
||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), draw_cb, event_data, NULL);
|
||||
gtk_widget_set_can_focus (da, TRUE);
|
||||
gtk_widget_grab_focus (da);
|
||||
|
||||
g_signal_connect (da, "event",
|
||||
G_CALLBACK (event_cb), event_data);
|
||||
|
||||
label = gtk_label_new ("");
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_START);
|
||||
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
|
||||
|
||||
overlay = gtk_overlay_new ();
|
||||
gtk_container_add (GTK_CONTAINER (window), overlay);
|
||||
gtk_container_add (GTK_CONTAINER (overlay), da);
|
||||
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), label);
|
||||
|
||||
init_pad_controller (da, label);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return window;
|
||||
}
|
||||
+29
-34
@@ -135,55 +135,42 @@ static void set_cursor_if_appropriate (GtkTextView *text_view,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
/* Links can also be activated by clicking or tapping.
|
||||
*/
|
||||
static gboolean
|
||||
event_cb (GtkWidget *text_view,
|
||||
GdkEvent *ev)
|
||||
static void
|
||||
released_cb (GtkGestureMultiPress *gesture,
|
||||
guint n_press,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
GtkWidget *text_view)
|
||||
{
|
||||
GtkTextIter start, end, iter;
|
||||
GtkTextBuffer *buffer;
|
||||
gdouble ex, ey;
|
||||
int x, y;
|
||||
GdkEventType type;
|
||||
int tx, ty;
|
||||
|
||||
type = gdk_event_get_event_type (ev);
|
||||
if (gtk_gesture_single_get_button (GTK_GESTURE_SINGLE (gesture)) > 1)
|
||||
return;
|
||||
|
||||
gdk_event_get_coords (ev, &ex, &ey);
|
||||
gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
|
||||
GTK_TEXT_WINDOW_WIDGET,
|
||||
ex, ey, &x, &y);
|
||||
|
||||
if (type == GDK_BUTTON_RELEASE)
|
||||
{
|
||||
guint button;
|
||||
|
||||
gdk_event_get_button (ev, &button);
|
||||
if (button != GDK_BUTTON_PRIMARY)
|
||||
return FALSE;
|
||||
}
|
||||
else if (type == GDK_MOTION_NOTIFY)
|
||||
{
|
||||
set_cursor_if_appropriate (GTK_TEXT_VIEW (text_view), x, y);
|
||||
return FALSE;
|
||||
}
|
||||
else if (type == GDK_TOUCH_END)
|
||||
{
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
x, y, &tx, &ty);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
|
||||
|
||||
/* we shouldn't follow a link if the user has selected something */
|
||||
gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
|
||||
if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
|
||||
return FALSE;
|
||||
return;
|
||||
|
||||
if (gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y))
|
||||
follow_if_link (text_view, &iter);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
static void
|
||||
motion_cb (GtkEventControllerMotion *controller,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
GtkTextView *text_view)
|
||||
{
|
||||
set_cursor_if_appropriate (text_view, x, y);
|
||||
}
|
||||
|
||||
static gboolean hovering_over_link = FALSE;
|
||||
@@ -259,8 +246,16 @@ do_hypertext (GtkWidget *do_widget)
|
||||
controller = gtk_event_controller_key_new ();
|
||||
g_signal_connect (controller, "key-pressed", G_CALLBACK (key_pressed), view);
|
||||
gtk_widget_add_controller (view, controller);
|
||||
g_signal_connect (view, "event",
|
||||
G_CALLBACK (event_cb), NULL);
|
||||
|
||||
controller = GTK_EVENT_CONTROLLER (gtk_gesture_multi_press_new ());
|
||||
g_signal_connect (controller, "released",
|
||||
G_CALLBACK (released_cb), view);
|
||||
gtk_widget_add_controller (view, controller);
|
||||
|
||||
controller = gtk_event_controller_motion_new ();
|
||||
g_signal_connect (controller, "motion",
|
||||
G_CALLBACK (motion_cb), view);
|
||||
gtk_widget_add_controller (view, controller);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="extra_buttons_box">
|
||||
<property name="visible">0</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="reply-button">
|
||||
|
||||
@@ -22,7 +22,6 @@ demos = files([
|
||||
'editable_cells.c',
|
||||
'entry_buffer.c',
|
||||
'entry_completion.c',
|
||||
'event_axes.c',
|
||||
'expander.c',
|
||||
'filtermodel.c',
|
||||
'fishbowl.c',
|
||||
|
||||
+133
-5
@@ -3,14 +3,24 @@
|
||||
* Demonstrates practical handling of drawing tablets in a real world
|
||||
* usecase.
|
||||
*/
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
enum {
|
||||
COLOR_SET,
|
||||
N_SIGNALS
|
||||
};
|
||||
|
||||
static guint area_signals[N_SIGNALS] = { 0, };
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
GdkRGBA draw_color;
|
||||
GtkPadController *pad_controller;
|
||||
gdouble brush_size;
|
||||
} DrawingArea;
|
||||
|
||||
typedef struct
|
||||
@@ -18,8 +28,30 @@ typedef struct
|
||||
GtkWidgetClass parent_class;
|
||||
} DrawingAreaClass;
|
||||
|
||||
static GtkPadActionEntry pad_actions[] = {
|
||||
{ GTK_PAD_ACTION_BUTTON, 1, -1, N_("Black"), "pad.black" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 2, -1, N_("Pink"), "pad.pink" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 3, -1, N_("Green"), "pad.green" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 4, -1, N_("Red"), "pad.red" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 5, -1, N_("Purple"), "pad.purple" },
|
||||
{ GTK_PAD_ACTION_BUTTON, 6, -1, N_("Orange"), "pad.orange" },
|
||||
{ GTK_PAD_ACTION_STRIP, -1, -1, N_("Brush size"), "pad.brush_size" },
|
||||
};
|
||||
|
||||
static const gchar *pad_colors[] = {
|
||||
"black",
|
||||
"pink",
|
||||
"green",
|
||||
"red",
|
||||
"purple",
|
||||
"orange"
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (DrawingArea, drawing_area, GTK_TYPE_WIDGET)
|
||||
|
||||
static void drawing_area_set_color (DrawingArea *area,
|
||||
GdkRGBA *color);
|
||||
|
||||
static void
|
||||
drawing_area_ensure_surface (DrawingArea *area,
|
||||
gint width,
|
||||
@@ -115,6 +147,82 @@ drawing_area_snapshot (GtkWidget *widget,
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
on_pad_button_activate (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
DrawingArea *area)
|
||||
{
|
||||
const gchar *color = g_object_get_data (G_OBJECT (action), "color");
|
||||
GdkRGBA rgba;
|
||||
|
||||
gdk_rgba_parse (&rgba, color);
|
||||
drawing_area_set_color (area, &rgba);
|
||||
}
|
||||
|
||||
static void
|
||||
on_pad_knob_change (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
DrawingArea *area)
|
||||
{
|
||||
gdouble value = g_variant_get_double (parameter);
|
||||
|
||||
area->brush_size = value;
|
||||
}
|
||||
|
||||
static void
|
||||
drawing_area_hierarchy_changed (GtkWidget *widget,
|
||||
GtkWidget *previous_toplevel)
|
||||
{
|
||||
DrawingArea *area = (DrawingArea *) widget;
|
||||
GSimpleActionGroup *action_group;
|
||||
GSimpleAction *action;
|
||||
GtkWidget *toplevel;
|
||||
gint i;
|
||||
|
||||
if (previous_toplevel && area->pad_controller)
|
||||
{
|
||||
gtk_widget_remove_controller (previous_toplevel,
|
||||
GTK_EVENT_CONTROLLER (area->pad_controller));
|
||||
area->pad_controller = NULL;
|
||||
}
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (area));
|
||||
if (!GTK_IS_WINDOW (toplevel))
|
||||
return;
|
||||
|
||||
action_group = g_simple_action_group_new ();
|
||||
area->pad_controller = gtk_pad_controller_new (G_ACTION_GROUP (action_group),
|
||||
NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (pad_actions); i++)
|
||||
{
|
||||
if (pad_actions[i].type == GTK_PAD_ACTION_BUTTON)
|
||||
{
|
||||
action = g_simple_action_new (pad_actions[i].action_name, NULL);
|
||||
g_object_set_data (G_OBJECT (action), "color",
|
||||
(gpointer) pad_colors[i]);
|
||||
g_signal_connect (action, "activate",
|
||||
G_CALLBACK (on_pad_button_activate), area);
|
||||
}
|
||||
else
|
||||
{
|
||||
action = g_simple_action_new_stateful (pad_actions[i].action_name,
|
||||
G_VARIANT_TYPE_DOUBLE, NULL);
|
||||
g_signal_connect (action, "activate",
|
||||
G_CALLBACK (on_pad_knob_change), area);
|
||||
}
|
||||
|
||||
g_action_map_add_action (G_ACTION_MAP (action_group), G_ACTION (action));
|
||||
g_object_unref (action);
|
||||
}
|
||||
|
||||
gtk_pad_controller_set_action_entries (area->pad_controller, pad_actions,
|
||||
G_N_ELEMENTS (pad_actions));
|
||||
|
||||
gtk_widget_add_controller (toplevel,
|
||||
GTK_EVENT_CONTROLLER (area->pad_controller));
|
||||
}
|
||||
|
||||
static void
|
||||
drawing_area_class_init (DrawingAreaClass *klass)
|
||||
{
|
||||
@@ -124,6 +232,14 @@ drawing_area_class_init (DrawingAreaClass *klass)
|
||||
widget_class->snapshot = drawing_area_snapshot;
|
||||
widget_class->map = drawing_area_map;
|
||||
widget_class->unmap = drawing_area_unmap;
|
||||
widget_class->hierarchy_changed = drawing_area_hierarchy_changed;
|
||||
|
||||
area_signals[COLOR_SET] =
|
||||
g_signal_new ("color-set",
|
||||
G_TYPE_FROM_CLASS (widget_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
0, NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1, GDK_TYPE_RGBA);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -135,12 +251,12 @@ drawing_area_apply_stroke (DrawingArea *area,
|
||||
{
|
||||
if (gdk_device_tool_get_tool_type (tool) == GDK_DEVICE_TOOL_TYPE_ERASER)
|
||||
{
|
||||
cairo_set_line_width (area->cr, 10 * pressure);
|
||||
cairo_set_line_width (area->cr, 10 * pressure * area->brush_size);
|
||||
cairo_set_operator (area->cr, CAIRO_OPERATOR_DEST_OUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
cairo_set_line_width (area->cr, 4 * pressure);
|
||||
cairo_set_line_width (area->cr, 4 * pressure * area->brush_size);
|
||||
cairo_set_operator (area->cr, CAIRO_OPERATOR_SATURATE);
|
||||
}
|
||||
|
||||
@@ -148,8 +264,6 @@ drawing_area_apply_stroke (DrawingArea *area,
|
||||
area->draw_color.green, area->draw_color.blue,
|
||||
area->draw_color.alpha * pressure);
|
||||
|
||||
//cairo_set_source_rgba (area->cr, 0, 0, 0, pressure);
|
||||
|
||||
cairo_line_to (area->cr, x, y);
|
||||
cairo_stroke (area->cr);
|
||||
cairo_move_to (area->cr, x, y);
|
||||
@@ -225,11 +339,15 @@ drawing_area_new (void)
|
||||
return g_object_new (drawing_area_get_type (), NULL);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
drawing_area_set_color (DrawingArea *area,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
if (gdk_rgba_equal (&area->draw_color, color))
|
||||
return;
|
||||
|
||||
area->draw_color = *color;
|
||||
g_signal_emit (area, area_signals[COLOR_SET], 0, &area->draw_color);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -242,6 +360,14 @@ color_button_color_set (GtkColorButton *button,
|
||||
drawing_area_set_color (draw_area, &color);
|
||||
}
|
||||
|
||||
static void
|
||||
drawing_area_color_set (DrawingArea *area,
|
||||
GdkRGBA *color,
|
||||
GtkColorButton *button)
|
||||
{
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), color);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_paint (GtkWidget *toplevel)
|
||||
{
|
||||
@@ -263,6 +389,8 @@ do_paint (GtkWidget *toplevel)
|
||||
colorbutton = gtk_color_button_new ();
|
||||
g_signal_connect (colorbutton, "color-set",
|
||||
G_CALLBACK (color_button_color_set), draw_area);
|
||||
g_signal_connect (draw_area, "color-set",
|
||||
G_CALLBACK (drawing_area_color_set), colorbutton);
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (colorbutton),
|
||||
&(GdkRGBA) { 0, 0, 0, 1 });
|
||||
|
||||
|
||||
@@ -26,17 +26,6 @@ changed_cb (GtkEditable *editable)
|
||||
g_message ("changed: %s", text);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
window_event_cb (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GtkSearchBar *bar)
|
||||
{
|
||||
if (gdk_event_get_event_type (event) == GDK_KEY_PRESS)
|
||||
return gtk_search_bar_handle_event (bar, event);
|
||||
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
static void
|
||||
search_changed (GtkSearchEntry *entry,
|
||||
GtkLabel *label)
|
||||
@@ -102,7 +91,7 @@ do_search_entry2 (GtkWidget *do_widget)
|
||||
gtk_box_pack_start (GTK_BOX (vbox), searchbar);
|
||||
|
||||
/* Hook the search bar to key presses */
|
||||
g_signal_connect (window, "event", G_CALLBACK (window_event_cb), searchbar);
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (searchbar), window);
|
||||
|
||||
/* Help */
|
||||
label = gtk_label_new ("Start Typing to search");
|
||||
|
||||
@@ -295,6 +295,7 @@ start_puzzle (GdkPaintable *puzzle)
|
||||
grid = gtk_grid_new ();
|
||||
gtk_widget_set_can_focus (grid, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (frame), grid);
|
||||
gtk_aspect_frame_set (GTK_ASPECT_FRAME (frame), 0.5, 0.5, (float) gdk_paintable_get_intrinsic_aspect_ratio (puzzle), FALSE);
|
||||
|
||||
/* Add a key event controller so people can use the arrow
|
||||
* keys to move the puzzle */
|
||||
|
||||
@@ -376,7 +376,7 @@ search_mode_toggled (GObject *searchbar, GParamSpec *pspec, IconBrowserWindow *w
|
||||
|
||||
static void
|
||||
get_image_data (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
GdkDrag *drag,
|
||||
GtkSelectionData *selection,
|
||||
guint target_info,
|
||||
gpointer data)
|
||||
@@ -398,7 +398,7 @@ get_image_data (GtkWidget *widget,
|
||||
|
||||
static void
|
||||
get_scalable_image_data (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
GdkDrag *drag,
|
||||
GtkSelectionData *selection,
|
||||
guint target_info,
|
||||
gpointer data)
|
||||
|
||||
@@ -966,8 +966,8 @@ background_loaded_cb (GObject *source,
|
||||
return;
|
||||
}
|
||||
|
||||
child = gtk_image_new_from_pixbuf (pixbuf);
|
||||
gtk_widget_show (child);
|
||||
child = gtk_picture_new_for_pixbuf (pixbuf);
|
||||
gtk_widget_set_size_request (child, 110, 70);
|
||||
gtk_flow_box_insert (GTK_FLOW_BOX (bd->flowbox), child, -1);
|
||||
child = gtk_widget_get_parent (child);
|
||||
g_object_set_data_full (G_OBJECT (child), "filename", bd->filename, g_free);
|
||||
@@ -995,8 +995,7 @@ populate_flowbox (GtkWidget *flowbox)
|
||||
|
||||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 110, 70);
|
||||
gdk_pixbuf_fill (pixbuf, 0xffffffff);
|
||||
child = gtk_image_new_from_pixbuf (pixbuf);
|
||||
gtk_widget_show (child);
|
||||
child = gtk_picture_new_for_pixbuf (pixbuf);
|
||||
gtk_flow_box_insert (GTK_FLOW_BOX (flowbox), child, -1);
|
||||
|
||||
location = "/usr/share/backgrounds/gnome";
|
||||
@@ -1081,7 +1080,7 @@ set_accel (GtkApplication *app, GtkWidget *widget)
|
||||
typedef struct
|
||||
{
|
||||
GtkTextView tv;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture;
|
||||
} MyTextView;
|
||||
|
||||
typedef GtkTextViewClass MyTextViewClass;
|
||||
@@ -1094,18 +1093,23 @@ my_text_view_init (MyTextView *tv)
|
||||
}
|
||||
|
||||
static void
|
||||
my_tv_draw_layer (GtkTextView *widget,
|
||||
GtkTextViewLayer layer,
|
||||
cairo_t *cr)
|
||||
my_tv_snapshot_layer (GtkTextView *widget,
|
||||
GtkTextViewLayer layer,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
MyTextView *tv = (MyTextView *)widget;
|
||||
|
||||
if (layer == GTK_TEXT_VIEW_LAYER_BELOW_TEXT && tv->pixbuf)
|
||||
if (layer == GTK_TEXT_VIEW_LAYER_BELOW_TEXT && tv->texture)
|
||||
{
|
||||
cairo_save (cr);
|
||||
gdk_cairo_set_source_pixbuf (cr, tv->pixbuf, 0.0, 0.0);
|
||||
cairo_paint_with_alpha (cr, 0.333);
|
||||
cairo_restore (cr);
|
||||
gtk_snapshot_push_opacity (snapshot, 0.333);
|
||||
gtk_snapshot_append_texture (snapshot,
|
||||
tv->texture,
|
||||
&GRAPHENE_RECT_INIT(
|
||||
0, 0,
|
||||
gdk_texture_get_width (tv->texture),
|
||||
gdk_texture_get_height (tv->texture)
|
||||
));
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1114,7 +1118,7 @@ my_tv_finalize (GObject *object)
|
||||
{
|
||||
MyTextView *tv = (MyTextView *)object;
|
||||
|
||||
g_clear_object (&tv->pixbuf);
|
||||
g_clear_object (&tv->texture);
|
||||
|
||||
G_OBJECT_CLASS (my_text_view_parent_class)->finalize (object);
|
||||
}
|
||||
@@ -1126,20 +1130,24 @@ my_text_view_class_init (MyTextViewClass *class)
|
||||
GObjectClass *o_class = G_OBJECT_CLASS (class);
|
||||
|
||||
o_class->finalize = my_tv_finalize;
|
||||
tv_class->draw_layer = my_tv_draw_layer;
|
||||
tv_class->snapshot_layer = my_tv_snapshot_layer;
|
||||
}
|
||||
|
||||
static void
|
||||
my_text_view_set_background (MyTextView *tv, const gchar *filename)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GFile *file;
|
||||
|
||||
g_clear_object (&tv->pixbuf);
|
||||
g_clear_object (&tv->texture);
|
||||
|
||||
if (filename == NULL)
|
||||
return;
|
||||
|
||||
tv->pixbuf = gdk_pixbuf_new_from_file (filename, &error);
|
||||
file = g_file_new_for_path (filename);
|
||||
tv->texture = gdk_texture_new_from_file (file, &error);
|
||||
g_object_unref (file);
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
|
||||
@@ -2226,6 +2226,9 @@ microphone-sensitivity-medium-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Save the current document</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorToolItem"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton">
|
||||
<property name="label" translatable="yes">Search</property>
|
||||
@@ -3580,4 +3583,4 @@ bad things might happen.</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
</interface>
|
||||
@@ -193,7 +193,6 @@ gdk_surface_is_visible
|
||||
gdk_surface_is_viewable
|
||||
gdk_surface_is_input_only
|
||||
gdk_surface_get_state
|
||||
gdk_surface_withdraw
|
||||
gdk_surface_iconify
|
||||
gdk_surface_deiconify
|
||||
gdk_surface_stick
|
||||
@@ -656,7 +655,6 @@ gdk_event_get_key_is_modifier
|
||||
gdk_event_get_pad_axis_value
|
||||
gdk_event_get_pad_button
|
||||
gdk_event_get_pad_group_mode
|
||||
gdk_event_get_string
|
||||
gdk_event_get_touch_emulating_pointer
|
||||
gdk_event_get_touchpad_angle_delta
|
||||
gdk_event_get_touchpad_deltas
|
||||
@@ -774,38 +772,60 @@ gdk_cursor_get_type
|
||||
<SECTION>
|
||||
<TITLE>Drag and Drop</TITLE>
|
||||
<FILE>dnd</FILE>
|
||||
GdkDragContext
|
||||
GdkDrag
|
||||
GdkDrop
|
||||
GdkDragCancelReason
|
||||
gdk_drag_drop_done
|
||||
gdk_drag_begin
|
||||
GdkDragAction
|
||||
GDK_ACTION_ALL
|
||||
|
||||
gdk_drag_context_get_display
|
||||
gdk_drag_context_get_actions
|
||||
gdk_drag_context_get_suggested_action
|
||||
gdk_drag_context_get_selected_action
|
||||
gdk_drag_context_get_formats
|
||||
gdk_drag_context_get_device
|
||||
gdk_drag_context_get_drag_surface
|
||||
gdk_drag_context_set_hotspot
|
||||
gdk_drag_get_display
|
||||
gdk_drag_get_actions
|
||||
gdk_drag_get_suggested_action
|
||||
gdk_drag_get_selected_action
|
||||
gdk_drag_get_formats
|
||||
gdk_drag_get_device
|
||||
gdk_drag_get_drag_surface
|
||||
gdk_drag_set_hotspot
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_drag_action_is_unique
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_drop_get_display
|
||||
gdk_drop_get_device
|
||||
gdk_drop_get_surface
|
||||
gdk_drop_get_formats
|
||||
gdk_drop_get_actions
|
||||
gdk_drop_get_drag
|
||||
gdk_drop_status
|
||||
gdk_drop_finish
|
||||
gdk_drop_read_async
|
||||
gdk_drop_read_finish
|
||||
gdk_drop_read_value_async
|
||||
gdk_drop_read_value_finish
|
||||
gdk_drop_read_text_async
|
||||
gdk_drop_read_text_finish
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GDK_DRAG_CONTEXT
|
||||
GDK_TYPE_DRAG_CONTEXT
|
||||
GDK_IS_DRAG_CONTEXT
|
||||
GDK_DRAG_CONTEXT_CLASS
|
||||
GDK_DRAG_CONTEXT_GET_CLASS
|
||||
GDK_IS_DRAG_CONTEXT_CLASS
|
||||
GDK_DRAG
|
||||
GDK_TYPE_DRAG
|
||||
GDK_IS_DRAG
|
||||
GDK_DRAG_CLASS
|
||||
GDK_DRAG_GET_CLASS
|
||||
GDK_IS_DRAG_CLASS
|
||||
GDK_TYPE_DRAG_ACTION
|
||||
GDK_TYPE_DRAG_PROTOCOL
|
||||
GDK_TYPE_DROP
|
||||
GDK_DROP
|
||||
GDK_IS_DROP
|
||||
|
||||
<SUBSECTION Private>
|
||||
GdkDragContextClass
|
||||
gdk_drag_context_get_type
|
||||
GdkDragClass
|
||||
gdk_drag_get_type
|
||||
GdkDropClass
|
||||
gdk_drop_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
@@ -1244,6 +1264,7 @@ gdk_clipboard_get_type
|
||||
<SECTION>
|
||||
<FILE>gdkcontentprovider</FILE>
|
||||
GdkContentProvider
|
||||
GdkContentProviderClass
|
||||
gdk_content_provider_new_for_value
|
||||
gdk_content_provider_new_for_bytes
|
||||
gdk_content_provider_ref_formats
|
||||
@@ -1259,7 +1280,6 @@ GDK_CONTENT_PROVIDER_CLASS
|
||||
GDK_CONTENT_PROVIDER_GET_CLASS
|
||||
GDK_IS_CONTENT_PROVIDER
|
||||
GDK_IS_CONTENT_PROVIDER_CLASS
|
||||
GdkContentProviderClass
|
||||
gdk_content_provider_get_type
|
||||
</SECTION>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ gdk_app_launch_context_get_type
|
||||
gdk_clipboard_get_type
|
||||
gdk_content_deserializer_get_type
|
||||
gdk_content_formats_get_type
|
||||
gdk_content_provider_get_type
|
||||
gdk_content_serializer_get_type
|
||||
gdk_cursor_get_type
|
||||
gdk_device_get_type
|
||||
@@ -9,7 +10,8 @@ gdk_device_pad_get_type
|
||||
gdk_device_tool_get_type
|
||||
gdk_display_get_type
|
||||
gdk_display_manager_get_type
|
||||
gdk_drag_context_get_type
|
||||
gdk_drag_get_type
|
||||
gdk_drop_get_type
|
||||
gdk_event_get_type
|
||||
gdk_frame_clock_get_type
|
||||
gdk_gl_context_get_type
|
||||
|
||||
@@ -385,7 +385,6 @@
|
||||
<xi:include href="osx.sgml" />
|
||||
<xi:include href="broadway.xml" />
|
||||
<xi:include href="wayland.xml" />
|
||||
<xi:include href="mir.xml" />
|
||||
</part>
|
||||
|
||||
<xi:include href="glossary.xml" />
|
||||
|
||||
@@ -679,8 +679,6 @@ gtk_combo_box_get_active_id
|
||||
gtk_combo_box_set_active_id
|
||||
gtk_combo_box_get_model
|
||||
gtk_combo_box_set_model
|
||||
gtk_combo_box_popup_for_device
|
||||
gtk_combo_box_popup
|
||||
gtk_combo_box_popdown
|
||||
gtk_combo_box_get_popup_accessible
|
||||
gtk_combo_box_get_row_separator_func
|
||||
@@ -1724,8 +1722,6 @@ gtk_menu_attach
|
||||
gtk_menu_popup_at_rect
|
||||
gtk_menu_popup_at_widget
|
||||
gtk_menu_popup_at_pointer
|
||||
gtk_menu_popup_for_device
|
||||
gtk_menu_popup
|
||||
gtk_menu_set_accel_group
|
||||
gtk_menu_get_accel_group
|
||||
gtk_menu_set_accel_path
|
||||
@@ -4907,12 +4903,10 @@ gtk_render_check
|
||||
gtk_render_expander
|
||||
gtk_render_focus
|
||||
gtk_render_frame
|
||||
gtk_render_frame_gap
|
||||
gtk_render_handle
|
||||
gtk_render_layout
|
||||
gtk_render_line
|
||||
gtk_render_option
|
||||
gtk_render_slider
|
||||
gtk_render_activity
|
||||
gtk_render_icon
|
||||
gtk_render_insertion_cursor
|
||||
@@ -4936,7 +4930,6 @@ gtk_border_get_type
|
||||
<FILE>gtkcssprovider</FILE>
|
||||
<TITLE>GtkCssProvider</TITLE>
|
||||
GtkCssProvider
|
||||
gtk_css_provider_get_default
|
||||
gtk_css_provider_get_named
|
||||
gtk_css_provider_load_from_data
|
||||
gtk_css_provider_load_from_file
|
||||
@@ -5013,6 +5006,7 @@ gtk_selection_data_get_type
|
||||
<TITLE>Drag and Drop</TITLE>
|
||||
GtkDestDefaults
|
||||
GtkDragResult
|
||||
|
||||
<SUBSECTION Destination Side>
|
||||
gtk_drag_dest_set
|
||||
gtk_drag_dest_unset
|
||||
@@ -5028,8 +5022,9 @@ gtk_drag_get_data
|
||||
gtk_drag_get_source_widget
|
||||
gtk_drag_highlight
|
||||
gtk_drag_unhighlight
|
||||
|
||||
<SUBSECTION Source Side>
|
||||
gtk_drag_begin_with_coordinates
|
||||
gtk_drag_begin
|
||||
gtk_drag_cancel
|
||||
gtk_drag_set_icon_widget
|
||||
gtk_drag_set_icon_paintable
|
||||
@@ -6463,7 +6458,7 @@ gtk_gesture_single_get_type
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkeventcontrollerscroll</FILE>
|
||||
<TITLE>GtkEventControlerScroll</TITLE>
|
||||
<TITLE>GtkEventControllerScroll</TITLE>
|
||||
GtkEventControllerScroll
|
||||
GtkEventControllerScrollFlags
|
||||
gtk_event_controller_scroll_new
|
||||
@@ -6484,7 +6479,7 @@ gtk_event_controller_scroll_get_type
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkeventcontrollermotion</FILE>
|
||||
<TITLE>GtkEventControlerMotion</TITLE>
|
||||
<TITLE>GtkEventControllerMotion</TITLE>
|
||||
GtkEventControllerMotion
|
||||
gtk_event_controller_motion_new
|
||||
|
||||
@@ -6502,7 +6497,7 @@ gtk_event_controller_motion_get_type
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkeventcontrollerkey</FILE>
|
||||
<TITLE>GtkEventControlerKey</TITLE>
|
||||
<TITLE>GtkEventControllerKey</TITLE>
|
||||
GtkEventControllerKey
|
||||
gtk_event_controller_key_new
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ gtk_page_setup_get_type
|
||||
@DISABLE_ON_W32@gtk_page_setup_unix_dialog_get_type
|
||||
gtk_paned_get_type
|
||||
gtk_paper_size_get_type
|
||||
gtk_picture_get_type
|
||||
gtk_popover_get_type
|
||||
gtk_popover_menu_get_type
|
||||
@DISABLE_ON_W32@gtk_printer_get_type
|
||||
|
||||
@@ -355,7 +355,6 @@ content_files = [
|
||||
'input-handling.xml',
|
||||
'migrating-2to4.xml',
|
||||
'migrating-3to4.xml',
|
||||
'mir.xml',
|
||||
'osx.sgml',
|
||||
'other_software.sgml',
|
||||
'overview.xml',
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
|
||||
<para>
|
||||
The steps outlined in the following sections assume that your
|
||||
application is working with GTK+ 3.22, which is the final stable
|
||||
application is working with GTK+ 3.24, which is the final stable
|
||||
release of GTK+ 3.x. It includes all the necessary APIs and tools
|
||||
to help you port your application to GTK+ 4. If you are still using
|
||||
an older version of GTK+ 3.x, you should first get your application
|
||||
to build and work with the latest minor release in the 3.22 series.
|
||||
to build and work with the latest minor release in the 3.24 series.
|
||||
</para>
|
||||
|
||||
<section>
|
||||
@@ -34,7 +34,7 @@
|
||||
widgets have been deprecated. These deprecations are clearly spelled
|
||||
out in the API reference, with hints about the recommended replacements.
|
||||
The API reference for GTK+ 3 also includes an
|
||||
<ulink url="https://developer.gnome.org/gtk3/3.22/api-index-deprecated.html">index</ulink> of all deprecated symbols.
|
||||
<ulink url="https://developer.gnome.org/gtk3/3.24/api-index-deprecated.html">index</ulink> of all deprecated symbols.
|
||||
</para>
|
||||
<para>
|
||||
To verify that your program does not use any deprecated symbols,
|
||||
@@ -79,13 +79,13 @@
|
||||
<title>Review your window creation flags</title>
|
||||
<para>
|
||||
GTK+ 4 removes the GDK_WA_CURSOR flag. Instead, just use
|
||||
gdk_surface_set_cursor() to set a cursor on the window after
|
||||
gdk_window_set_cursor() to set a cursor on the window after
|
||||
creating it.
|
||||
</para>
|
||||
<para>
|
||||
GTK+ 4 also removes the GDK_WA_VISUAL flag, and always uses
|
||||
an RGBA visual for windows. To prepare your code for this,
|
||||
use gdk_surface_set_visual (gdk_screen_get_rgba_visual ()) after
|
||||
use gdk_window_set_visual (gdk_screen_get_rgba_visual ()) after
|
||||
creating your window.
|
||||
</para>
|
||||
<para>
|
||||
@@ -169,6 +169,14 @@
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Stop using GtkWidget event signals</title>
|
||||
<para>
|
||||
Event controllers and #GtkGestures replace event signals in GTK+ 4. They
|
||||
have been backported to GTK+ 3.x so you can prepare for this change.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
<section>
|
||||
@@ -311,6 +319,15 @@
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Adapt to GtkWidget's size allocation changes</title>
|
||||
<para>
|
||||
The #GtkWidget::size-allocate signal now takes the baseline as an
|
||||
argument, so you no longer need to call gtk_widget_get_allocated_baseline()
|
||||
to get it.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Switch to GtkWidget's children APIs</title>
|
||||
<para>
|
||||
@@ -432,8 +449,7 @@
|
||||
<title>GtkWidget event signals are removed</title>
|
||||
<para>
|
||||
Event controllers and #GtkGestures have already been introduced in GTK+ 3 to handle
|
||||
input for many cases. In GTK+ 4, even more are available, such as #GtkEventControllerScroll
|
||||
and GtkEventControllerMotion, and the traditional widget signals for handling input,
|
||||
input for many cases. In GTK+ 4, the traditional widget signals for handling input,
|
||||
such as #GtkWidget::motion-event or #GtkWidget::event have been removed.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
||||
]>
|
||||
<refentry id="gtk-mir">
|
||||
<refmeta>
|
||||
<refentrytitle>Using GTK+ with Mir</refentrytitle>
|
||||
<manvolnum>3</manvolnum>
|
||||
<refmiscinfo>GTK Library</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>Using GTK+ with Mir</refname>
|
||||
<refpurpose>
|
||||
Mir-specific aspects of using GTK+
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1>
|
||||
<title>Using GTK+ with Mir</title>
|
||||
|
||||
<para>
|
||||
The GDK Mir backend provides support for running GTK+ applications
|
||||
under Mir based display servers. To run your application in this way,
|
||||
select the Mir backend by setting <literal>GDK_BACKEND=mir</literal>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Currently, the Mir backend does not use any additional commandline
|
||||
options or environment variables.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
@@ -435,11 +435,6 @@ nevertheless.
|
||||
<listitem><para>Selects the Wayland backend for connecting to Wayland display servers</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>mir</term>
|
||||
<listitem><para>Selects the Mir backend for connecting to Mir display servers</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
Since 3.10, this environment variable can contain a comma-separated list
|
||||
of backend names, which are tried in order. The list may also contain
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkdndprivate.h"
|
||||
#include "gdkdragprivate.h"
|
||||
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkproperty.h"
|
||||
@@ -34,56 +34,56 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define GDK_TYPE_BROADWAY_DRAG_CONTEXT (gdk_broadway_drag_context_get_type ())
|
||||
#define GDK_BROADWAY_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_DRAG_CONTEXT, GdkBroadwayDragContext))
|
||||
#define GDK_BROADWAY_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_DRAG_CONTEXT, GdkBroadwayDragContextClass))
|
||||
#define GDK_IS_BROADWAY_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_DRAG_CONTEXT))
|
||||
#define GDK_IS_BROADWAY_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_DRAG_CONTEXT))
|
||||
#define GDK_BROADWAY_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_DRAG_CONTEXT, GdkBroadwayDragContextClass))
|
||||
#define GDK_TYPE_BROADWAY_DRAG (gdk_broadway_drag_get_type ())
|
||||
#define GDK_BROADWAY_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_DRAG, GdkBroadwayDrag))
|
||||
#define GDK_BROADWAY_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_DRAG, GdkBroadwayDragClass))
|
||||
#define GDK_IS_BROADWAY_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_DRAG))
|
||||
#define GDK_IS_BROADWAY_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_DRAG))
|
||||
#define GDK_BROADWAY_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_DRAG, GdkBroadwayDragClass))
|
||||
|
||||
#ifdef GDK_COMPILATION
|
||||
typedef struct _GdkBroadwayDragContext GdkBroadwayDragContext;
|
||||
typedef struct _GdkBroadwayDrag GdkBroadwayDrag;
|
||||
#else
|
||||
typedef GdkDragContext GdkBroadwayDragContext;
|
||||
typedef GdkDrag GdkBroadwayDrag;
|
||||
#endif
|
||||
typedef struct _GdkBroadwayDragContextClass GdkBroadwayDragContextClass;
|
||||
typedef struct _GdkBroadwayDragClass GdkBroadwayDragClass;
|
||||
|
||||
GType gdk_broadway_drag_context_get_type (void);
|
||||
GType gdk_broadway_drag_get_type (void);
|
||||
|
||||
struct _GdkBroadwayDragContext {
|
||||
GdkDragContext context;
|
||||
struct _GdkBroadwayDrag {
|
||||
GdkDrag context;
|
||||
};
|
||||
|
||||
struct _GdkBroadwayDragContextClass
|
||||
struct _GdkBroadwayDragClass
|
||||
{
|
||||
GdkDragContextClass parent_class;
|
||||
GdkDragClass parent_class;
|
||||
};
|
||||
|
||||
static void gdk_broadway_drag_context_finalize (GObject *object);
|
||||
static void gdk_broadway_drag_finalize (GObject *object);
|
||||
|
||||
static GList *contexts;
|
||||
|
||||
G_DEFINE_TYPE (GdkBroadwayDragContext, gdk_broadway_drag_context, GDK_TYPE_DRAG_CONTEXT)
|
||||
G_DEFINE_TYPE (GdkBroadwayDrag, gdk_broadway_drag, GDK_TYPE_DRAG)
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_context_init (GdkBroadwayDragContext *dragcontext)
|
||||
gdk_broadway_drag_init (GdkBroadwayDrag *dragcontext)
|
||||
{
|
||||
contexts = g_list_prepend (contexts, dragcontext);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_context_finalize (GObject *object)
|
||||
gdk_broadway_drag_finalize (GObject *object)
|
||||
{
|
||||
GdkDragContext *context = GDK_DRAG_CONTEXT (object);
|
||||
GdkDrag *context = GDK_DRAG (object);
|
||||
|
||||
contexts = g_list_remove (contexts, context);
|
||||
|
||||
G_OBJECT_CLASS (gdk_broadway_drag_context_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (gdk_broadway_drag_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/* Drag Contexts */
|
||||
|
||||
GdkDragContext *
|
||||
GdkDrag *
|
||||
_gdk_broadway_surface_drag_begin (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider *content,
|
||||
@@ -91,12 +91,12 @@ _gdk_broadway_surface_drag_begin (GdkSurface *surface,
|
||||
gint dx,
|
||||
gint dy)
|
||||
{
|
||||
GdkDragContext *new_context;
|
||||
GdkDrag *new_context;
|
||||
|
||||
g_return_val_if_fail (surface != NULL, NULL);
|
||||
g_return_val_if_fail (GDK_SURFACE_IS_BROADWAY (surface), NULL);
|
||||
|
||||
new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG_CONTEXT,
|
||||
new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG,
|
||||
"device", device,
|
||||
"content", content,
|
||||
NULL);
|
||||
@@ -104,20 +104,6 @@ _gdk_broadway_surface_drag_begin (GdkSurface *surface,
|
||||
return new_context;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_context_drag_drop (GdkDragContext *context,
|
||||
guint32 time)
|
||||
{
|
||||
g_return_if_fail (context != NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_context_drag_abort (GdkDragContext *context,
|
||||
guint32 time)
|
||||
{
|
||||
g_return_if_fail (context != NULL);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_broadway_surface_register_dnd (GdkSurface *surface)
|
||||
{
|
||||
@@ -129,13 +115,9 @@ _gdk_broadway_display_init_dnd (GdkDisplay *display)
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_context_class_init (GdkBroadwayDragContextClass *klass)
|
||||
gdk_broadway_drag_class_init (GdkBroadwayDragClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GdkDragContextClass *context_class = GDK_DRAG_CONTEXT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gdk_broadway_drag_context_finalize;
|
||||
|
||||
context_class->drag_abort = gdk_broadway_drag_context_drag_abort;
|
||||
context_class->drag_drop = gdk_broadway_drag_context_drag_drop;
|
||||
object_class->finalize = gdk_broadway_drag_finalize;
|
||||
}
|
||||
|
||||
@@ -285,7 +285,6 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message)
|
||||
event->key.state = message->key.state;
|
||||
event->key.hardware_keycode = message->key.key;
|
||||
gdk_event_set_scancode (event, message->key.key);
|
||||
event->key.length = 0;
|
||||
gdk_event_set_device (event, gdk_seat_get_keyboard (seat));
|
||||
|
||||
node = _gdk_event_queue_append (display, event);
|
||||
|
||||
@@ -46,7 +46,7 @@ void gdk_broadway_surface_set_nodes (GdkSurface *surface,
|
||||
GPtrArray *node_textures);
|
||||
|
||||
void _gdk_broadway_surface_register_dnd (GdkSurface *surface);
|
||||
GdkDragContext * _gdk_broadway_surface_drag_begin (GdkSurface *surface,
|
||||
GdkDrag * _gdk_broadway_surface_drag_begin (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider *content,
|
||||
GdkDragAction actions,
|
||||
|
||||
@@ -322,10 +322,7 @@ gdk_surface_broadway_show (GdkSurface *surface,
|
||||
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
||||
impl->visible = TRUE;
|
||||
|
||||
_gdk_make_event (GDK_SURFACE (surface), GDK_MAP, NULL, FALSE);
|
||||
|
||||
if (surface->parent)
|
||||
_gdk_make_event (GDK_SURFACE (surface), GDK_MAP, NULL, FALSE);
|
||||
/* FIXME: update state ? */
|
||||
|
||||
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
||||
if (_gdk_broadway_server_surface_show (broadway_display->server, impl->id))
|
||||
@@ -342,10 +339,7 @@ gdk_surface_broadway_hide (GdkSurface *surface)
|
||||
impl = GDK_SURFACE_IMPL_BROADWAY (surface->impl);
|
||||
impl->visible = FALSE;
|
||||
|
||||
_gdk_make_event (GDK_SURFACE (surface), GDK_UNMAP, NULL, FALSE);
|
||||
|
||||
if (surface->parent)
|
||||
_gdk_make_event (GDK_SURFACE (surface), GDK_UNMAP, NULL, FALSE);
|
||||
/* FIXME: update state ? */
|
||||
|
||||
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
|
||||
|
||||
|
||||
+12
-12
@@ -43,8 +43,19 @@ clienthtml_h = custom_target('clienthtml.h',
|
||||
],
|
||||
)
|
||||
|
||||
broadwayjs_h = custom_target('broadwayjs.h',
|
||||
input : ['broadway.js'],
|
||||
output : 'broadwayjs.h',
|
||||
command : [
|
||||
gen_c_array,
|
||||
'--array-name=broadway_js',
|
||||
'--output=@OUTPUT@',
|
||||
'@INPUT0@',
|
||||
],
|
||||
)
|
||||
|
||||
libgdk_broadway = static_library('gdk-broadway',
|
||||
clienthtml_h,
|
||||
clienthtml_h, broadwayjs_h,
|
||||
gdk_broadway_sources, gdkconfig, gdkenum_h,
|
||||
include_directories: [confinc, gdkinc],
|
||||
c_args: [
|
||||
@@ -58,17 +69,6 @@ libgdk_broadway = static_library('gdk-broadway',
|
||||
|
||||
broadwayd_syslib = os_win32 ? find_library('ws2_32') : shmlib
|
||||
|
||||
broadwayjs_h = custom_target('broadwayjs.h',
|
||||
input : ['broadway.js'],
|
||||
output : 'broadwayjs.h',
|
||||
command : [
|
||||
gen_c_array,
|
||||
'--array-name=broadway_js',
|
||||
'--output=@OUTPUT@',
|
||||
'@INPUT0@',
|
||||
],
|
||||
)
|
||||
|
||||
executable('gtk4-broadwayd',
|
||||
clienthtml_h, broadwayjs_h,
|
||||
'broadwayd.c', 'broadway-server.c', 'broadway-output.c',
|
||||
|
||||
@@ -23,11 +23,12 @@
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkAppLaunchContext, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkClipboard, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkContentProvider, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkCursor, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDevice, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDisplay, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDisplayManager, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDragContext, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDrag, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDrawContext, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkFrameClock, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkGLContext, g_object_unref)
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <gdk/gdkdevicetool.h>
|
||||
#include <gdk/gdkdisplay.h>
|
||||
#include <gdk/gdkdisplaymanager.h>
|
||||
#include <gdk/gdkdnd.h>
|
||||
#include <gdk/gdkdrag.h>
|
||||
#include <gdk/gdkdrawcontext.h>
|
||||
#include <gdk/gdkdrop.h>
|
||||
#include <gdk/gdkenumtypes.h>
|
||||
|
||||
@@ -716,8 +716,7 @@ file_uri_deserializer_finish (GObject *source,
|
||||
return;
|
||||
}
|
||||
|
||||
str = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (
|
||||
g_filter_output_stream_get_base_stream (G_FILTER_OUTPUT_STREAM (stream))));
|
||||
str = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (stream));
|
||||
uris = g_uri_list_extract_uris (str);
|
||||
g_free (str);
|
||||
|
||||
@@ -738,6 +737,8 @@ file_uri_deserializer_finish (GObject *source,
|
||||
g_value_take_boxed (value, g_slist_reverse (l));
|
||||
}
|
||||
g_strfreev (uris);
|
||||
|
||||
gdk_content_deserializer_return_success (deserializer);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+1
-18
@@ -61,12 +61,7 @@
|
||||
* the commonly available names that are shared with the CSS specification.
|
||||
* Other names may be available, depending on the platform in use.
|
||||
* Another option to create a cursor is to use gdk_cursor_new_from_texture()
|
||||
* and provide an image to use for the cursor. Depending on the #GdkDisplay
|
||||
* in use, the type of supported images may be limited. See
|
||||
* gdk_display_supports_cursor_alpha(),
|
||||
* gdk_display_supports_cursor_color(),
|
||||
* gdk_display_get_default_cursor_size() and
|
||||
* gdk_display_get_maximal_cursor_size() for the limitations that might apply.
|
||||
* and provide an image to use for the cursor.
|
||||
*
|
||||
* To ease work with unsupported cursors, a fallback cursor can be provided.
|
||||
* If a #GdkSurface cannot use a cursor because of the reasons mentioned above,
|
||||
@@ -346,18 +341,6 @@ gdk_cursor_new_from_name (const gchar *name,
|
||||
*
|
||||
* Creates a new cursor from a #GdkTexture.
|
||||
*
|
||||
* Not all GDK backends support RGBA cursors. If they are not
|
||||
* supported, a monochrome approximation will be displayed.
|
||||
* The functions gdk_display_supports_cursor_alpha() and
|
||||
* gdk_display_supports_cursor_color() can be used to determine
|
||||
* whether RGBA cursors are supported;
|
||||
* gdk_display_get_default_cursor_size() and
|
||||
* gdk_display_get_maximal_cursor_size() give information about
|
||||
* cursor sizes.
|
||||
*
|
||||
* On the X backend, support for RGBA cursors requires a
|
||||
* sufficently new version of the X Render extension.
|
||||
*
|
||||
* Returns: a new #GdkCursor.
|
||||
*/
|
||||
GdkCursor *
|
||||
|
||||
+1
-1
@@ -1282,7 +1282,7 @@ gdk_display_notify_startup_complete (GdkDisplay *display,
|
||||
|
||||
/**
|
||||
* gdk_display_get_startup_notification_id:
|
||||
* @display: (type GdkX11Display): a #GdkDisplay
|
||||
* @display: a #GdkDisplay
|
||||
*
|
||||
* Gets the startup notification ID for a Wayland display, or %NULL
|
||||
* if no ID has been defined.
|
||||
|
||||
-100
@@ -1,100 +0,0 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
#ifndef __GDK_DND_H__
|
||||
#define __GDK_DND_H__
|
||||
|
||||
#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkdevice.h>
|
||||
#include <gdk/gdkevents.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_DRAG_CONTEXT (gdk_drag_context_get_type ())
|
||||
#define GDK_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAG_CONTEXT, GdkDragContext))
|
||||
#define GDK_IS_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAG_CONTEXT))
|
||||
|
||||
/**
|
||||
* GdkDragCancelReason:
|
||||
* @GDK_DRAG_CANCEL_NO_TARGET: There is no suitable drop target.
|
||||
* @GDK_DRAG_CANCEL_USER_CANCELLED: Drag cancelled by the user
|
||||
* @GDK_DRAG_CANCEL_ERROR: Unspecified error.
|
||||
*
|
||||
* Used in #GdkDragContext to the reason of a cancelled DND operation.
|
||||
*/
|
||||
typedef enum {
|
||||
GDK_DRAG_CANCEL_NO_TARGET,
|
||||
GDK_DRAG_CANCEL_USER_CANCELLED,
|
||||
GDK_DRAG_CANCEL_ERROR
|
||||
} GdkDragCancelReason;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gdk_drag_context_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDisplay * gdk_drag_context_get_display (GdkDragContext *context);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDevice * gdk_drag_context_get_device (GdkDragContext *context);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkContentFormats *gdk_drag_context_get_formats (GdkDragContext *context);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDragAction gdk_drag_context_get_actions (GdkDragContext *context);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDragAction gdk_drag_context_get_suggested_action (GdkDragContext *context);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDragAction gdk_drag_context_get_selected_action (GdkDragContext *context);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_drag_action_is_unique (GdkDragAction action);
|
||||
|
||||
/* Source side */
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDragContext * gdk_drag_begin (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider *content,
|
||||
GdkDragAction actions,
|
||||
gint dx,
|
||||
gint dy);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_drag_drop_done (GdkDragContext *context,
|
||||
gboolean success);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSurface *gdk_drag_context_get_drag_surface (GdkDragContext *context);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_drag_context_set_hotspot (GdkDragContext *context,
|
||||
gint hot_x,
|
||||
gint hot_y);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_DND_H__ */
|
||||
@@ -1,105 +0,0 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 2010, 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 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/>.
|
||||
*/
|
||||
|
||||
#ifndef __GDK_DND_PRIVATE_H__
|
||||
#define __GDK_DND_PRIVATE_H__
|
||||
|
||||
#include "gdkdnd.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define GDK_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAG_CONTEXT, GdkDragContextClass))
|
||||
#define GDK_IS_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DRAG_CONTEXT))
|
||||
#define GDK_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DRAG_CONTEXT, GdkDragContextClass))
|
||||
|
||||
typedef struct _GdkDragContextClass GdkDragContextClass;
|
||||
|
||||
|
||||
struct _GdkDragContextClass {
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (*drag_abort) (GdkDragContext *context,
|
||||
guint32 time_);
|
||||
void (*drag_drop) (GdkDragContext *context,
|
||||
guint32 time_);
|
||||
GdkSurface* (*get_drag_surface) (GdkDragContext *context);
|
||||
void (*set_hotspot) (GdkDragContext *context,
|
||||
gint hot_x,
|
||||
gint hot_y);
|
||||
void (*drop_done) (GdkDragContext *context,
|
||||
gboolean success);
|
||||
|
||||
void (*set_cursor) (GdkDragContext *context,
|
||||
GdkCursor *cursor);
|
||||
void (*cancel) (GdkDragContext *context,
|
||||
GdkDragCancelReason reason);
|
||||
void (*drop_performed) (GdkDragContext *context,
|
||||
guint32 time);
|
||||
void (*dnd_finished) (GdkDragContext *context);
|
||||
|
||||
gboolean (*handle_event) (GdkDragContext *context,
|
||||
const GdkEvent *event);
|
||||
void (*action_changed) (GdkDragContext *context,
|
||||
GdkDragAction action);
|
||||
};
|
||||
|
||||
struct _GdkDragContext {
|
||||
GObject parent_instance;
|
||||
|
||||
/*< private >*/
|
||||
GdkSurface *source_surface;
|
||||
GdkSurface *drag_surface;
|
||||
|
||||
GdkContentProvider *content;
|
||||
GdkDragAction action;
|
||||
|
||||
guint drop_done : 1; /* Whether gdk_drag_drop_done() was performed */
|
||||
};
|
||||
|
||||
void gdk_drag_context_set_cursor (GdkDragContext *context,
|
||||
GdkCursor *cursor);
|
||||
void gdk_drag_context_set_actions (GdkDragContext *context,
|
||||
GdkDragAction actions,
|
||||
GdkDragAction suggested_action);
|
||||
|
||||
void gdk_drag_context_cancel (GdkDragContext *context,
|
||||
GdkDragCancelReason reason);
|
||||
gboolean gdk_drag_context_handle_source_event (GdkEvent *event);
|
||||
GdkCursor * gdk_drag_get_cursor (GdkDragContext *context,
|
||||
GdkDragAction action);
|
||||
|
||||
void gdk_drag_abort (GdkDragContext *context,
|
||||
guint32 time_);
|
||||
void gdk_drag_drop (GdkDragContext *context,
|
||||
guint32 time_);
|
||||
|
||||
void gdk_drag_context_write_async (GdkDragContext *context,
|
||||
const char *mime_type,
|
||||
GOutputStream *stream,
|
||||
int io_priority,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean gdk_drag_context_write_finish (GdkDragContext *context,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
+275
-251
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkdndprivate.h"
|
||||
#include "gdkdragprivate.h"
|
||||
#include "gdkdisplay.h"
|
||||
#include "gdksurface.h"
|
||||
#include "gdkintl.h"
|
||||
@@ -35,17 +35,6 @@
|
||||
#include "gdkenumtypes.h"
|
||||
#include "gdkeventsprivate.h"
|
||||
|
||||
typedef struct _GdkDragContextPrivate GdkDragContextPrivate;
|
||||
|
||||
struct _GdkDragContextPrivate
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GdkDevice *device;
|
||||
GdkContentFormats *formats;
|
||||
GdkDragAction actions;
|
||||
GdkDragAction suggested_action;
|
||||
};
|
||||
|
||||
static struct {
|
||||
GdkDragAction action;
|
||||
const gchar *name;
|
||||
@@ -64,6 +53,9 @@ enum {
|
||||
PROP_DEVICE,
|
||||
PROP_DISPLAY,
|
||||
PROP_FORMATS,
|
||||
PROP_SELECTED_ACTION,
|
||||
PROP_ACTIONS,
|
||||
PROP_SURFACE,
|
||||
N_PROPERTIES
|
||||
};
|
||||
|
||||
@@ -71,15 +63,30 @@ enum {
|
||||
CANCEL,
|
||||
DROP_PERFORMED,
|
||||
DND_FINISHED,
|
||||
ACTION_CHANGED,
|
||||
N_SIGNALS
|
||||
};
|
||||
|
||||
typedef struct _GdkDragPrivate GdkDragPrivate;
|
||||
|
||||
struct _GdkDragPrivate {
|
||||
GdkSurface *surface;
|
||||
|
||||
GdkDisplay *display;
|
||||
GdkDevice *device;
|
||||
GdkContentFormats *formats;
|
||||
GdkContentProvider *content;
|
||||
|
||||
GdkDragAction actions;
|
||||
GdkDragAction selected_action;
|
||||
|
||||
guint drop_done : 1; /* Whether gdk_drag_drop_done() was performed */
|
||||
};
|
||||
|
||||
static GParamSpec *properties[N_PROPERTIES] = { NULL, };
|
||||
static guint signals[N_SIGNALS] = { 0 };
|
||||
static GList *contexts = NULL;
|
||||
static GList *drags = NULL;
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT)
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDrag, gdk_drag, G_TYPE_OBJECT)
|
||||
|
||||
/**
|
||||
* SECTION:dnd
|
||||
@@ -87,153 +94,139 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDragContext, gdk_drag_context, G_TYPE_OB
|
||||
* @short_description: Functions for controlling drag and drop handling
|
||||
*
|
||||
* These functions provide a low level interface for drag and drop.
|
||||
* The X backend of GDK supports both the Xdnd and Motif drag and drop
|
||||
* protocols transparently, the Win32 backend supports the WM_DROPFILES
|
||||
* protocol.
|
||||
*
|
||||
* The GdkDrag object represents the source side of an ongoing DND operation.
|
||||
* It is created when a drag is started, and stays alive for duration of
|
||||
* the DND operation.
|
||||
*
|
||||
* The GdkDrop object represents the target side of an ongoing DND operation.
|
||||
*
|
||||
* GTK+ provides a higher level abstraction based on top of these functions,
|
||||
* and so they are not normally needed in GTK+ applications.
|
||||
* See the [Drag and Drop][gtk3-Drag-and-Drop] section of
|
||||
* the GTK+ documentation for more information.
|
||||
* and so they are not normally needed in GTK+ applications. See the
|
||||
* [Drag and Drop][gtk4-Drag-and-Drop] section of the GTK+ documentation
|
||||
* for more information.
|
||||
*/
|
||||
|
||||
/**
|
||||
* GdkDragContext:
|
||||
* GdkDrag:
|
||||
*
|
||||
* The GdkDragContext struct contains only private fields and
|
||||
* The GdkDrag struct contains only private fields and
|
||||
* should not be accessed directly.
|
||||
*/
|
||||
|
||||
/**
|
||||
* gdk_drag_context_get_display:
|
||||
* @context: a #GdkDragContext
|
||||
* gdk_drag_get_display:
|
||||
* @drag: a #GdkDrag
|
||||
*
|
||||
* Gets the #GdkDisplay that the drag context was created for.
|
||||
* Gets the #GdkDisplay that the drag object was created for.
|
||||
*
|
||||
* Returns: (transfer none): a #GdkDisplay
|
||||
**/
|
||||
GdkDisplay *
|
||||
gdk_drag_context_get_display (GdkDragContext *context)
|
||||
gdk_drag_get_display (GdkDrag *drag)
|
||||
{
|
||||
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
|
||||
|
||||
return priv->display;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drag_context_get_formats:
|
||||
* @context: a #GdkDragContext
|
||||
* gdk_drag_get_formats:
|
||||
* @drag: a #GdkDrag
|
||||
*
|
||||
* Retrieves the formats supported by this context.
|
||||
* Retrieves the formats supported by this GdkDrag object.
|
||||
*
|
||||
* Returns: (transfer none): a #GdkContentFormats
|
||||
**/
|
||||
GdkContentFormats *
|
||||
gdk_drag_context_get_formats (GdkDragContext *context)
|
||||
gdk_drag_get_formats (GdkDrag *drag)
|
||||
{
|
||||
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
|
||||
|
||||
return priv->formats;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drag_context_get_actions:
|
||||
* @context: a #GdkDragContext
|
||||
* gdk_drag_get_actions:
|
||||
* @drag: a #GdkDrag
|
||||
*
|
||||
* Determines the bitmask of actions proposed by the source if
|
||||
* gdk_drag_context_get_suggested_action() returns %GDK_ACTION_ASK.
|
||||
* Determines the bitmask of possible actions proposed by the source.
|
||||
*
|
||||
* Returns: the #GdkDragAction flags
|
||||
**/
|
||||
GdkDragAction
|
||||
gdk_drag_context_get_actions (GdkDragContext *context)
|
||||
gdk_drag_get_actions (GdkDrag *drag)
|
||||
{
|
||||
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
|
||||
g_return_val_if_fail (GDK_IS_DRAG (drag), 0);
|
||||
|
||||
return priv->actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drag_context_get_suggested_action:
|
||||
* @context: a #GdkDragContext
|
||||
*
|
||||
* Determines the suggested drag action of the context.
|
||||
*
|
||||
* Returns: a #GdkDragAction value
|
||||
**/
|
||||
GdkDragAction
|
||||
gdk_drag_context_get_suggested_action (GdkDragContext *context)
|
||||
{
|
||||
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
|
||||
|
||||
return priv->suggested_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drag_context_get_selected_action:
|
||||
* @context: a #GdkDragContext
|
||||
* gdk_drag_get_selected_action:
|
||||
* @drag: a #GdkDrag
|
||||
*
|
||||
* Determines the action chosen by the drag destination.
|
||||
*
|
||||
* Returns: a #GdkDragAction value
|
||||
**/
|
||||
GdkDragAction
|
||||
gdk_drag_context_get_selected_action (GdkDragContext *context)
|
||||
gdk_drag_get_selected_action (GdkDrag *drag)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
return context->action;
|
||||
g_return_val_if_fail (GDK_IS_DRAG (drag), 0);
|
||||
|
||||
return priv->selected_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drag_context_get_device:
|
||||
* @context: a #GdkDragContext
|
||||
* gdk_drag_get_device:
|
||||
* @drag: a #GdkDrag
|
||||
*
|
||||
* Returns the #GdkDevice associated to the drag context.
|
||||
* Returns the #GdkDevice associated to the GdkDrag object.
|
||||
*
|
||||
* Returns: (transfer none): The #GdkDevice associated to @context.
|
||||
* Returns: (transfer none): The #GdkDevice associated to @drag.
|
||||
**/
|
||||
GdkDevice *
|
||||
gdk_drag_context_get_device (GdkDragContext *context)
|
||||
gdk_drag_get_device (GdkDrag *drag)
|
||||
{
|
||||
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
|
||||
|
||||
return priv->device;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_drag_context_init (GdkDragContext *context)
|
||||
gdk_drag_init (GdkDrag *drag)
|
||||
{
|
||||
contexts = g_list_prepend (contexts, context);
|
||||
drags = g_list_prepend (drags, drag);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_drag_context_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gdk_drag_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GdkDragContext *context = GDK_DRAG_CONTEXT (gobject);
|
||||
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
|
||||
GdkDrag *drag = GDK_DRAG (gobject);
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CONTENT:
|
||||
context->content = g_value_dup_object (value);
|
||||
if (context->content)
|
||||
priv->content = g_value_dup_object (value);
|
||||
if (priv->content)
|
||||
{
|
||||
g_assert (priv->formats == NULL);
|
||||
priv->formats = gdk_content_provider_ref_formats (context->content);
|
||||
priv->formats = gdk_content_provider_ref_formats (priv->content);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -260,6 +253,25 @@ gdk_drag_context_set_property (GObject *gobject,
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_SELECTED_ACTION:
|
||||
{
|
||||
GdkDragAction action = g_value_get_flags (value);
|
||||
gdk_drag_set_selected_action (drag, action);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_ACTIONS:
|
||||
{
|
||||
GdkDragAction actions = g_value_get_flags (value);
|
||||
gdk_drag_set_actions (drag, actions);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_SURFACE:
|
||||
priv->surface = g_value_dup_object (value);
|
||||
g_assert (priv->surface != NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
@@ -267,18 +279,18 @@ gdk_drag_context_set_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_drag_context_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gdk_drag_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GdkDragContext *context = GDK_DRAG_CONTEXT (gobject);
|
||||
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
|
||||
GdkDrag *drag = GDK_DRAG (gobject);
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CONTENT:
|
||||
g_value_set_object (value, context->content);
|
||||
g_value_set_object (value, priv->content);
|
||||
break;
|
||||
|
||||
case PROP_DEVICE:
|
||||
@@ -293,6 +305,18 @@ gdk_drag_context_get_property (GObject *gobject,
|
||||
g_value_set_boxed (value, priv->formats);
|
||||
break;
|
||||
|
||||
case PROP_SELECTED_ACTION:
|
||||
g_value_set_flags (value, priv->selected_action);
|
||||
break;
|
||||
|
||||
case PROP_ACTIONS:
|
||||
g_value_set_flags (value, priv->actions);
|
||||
break;
|
||||
|
||||
case PROP_SURFACE:
|
||||
g_value_set_object (value, priv->surface);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
@@ -300,36 +324,34 @@ gdk_drag_context_get_property (GObject *gobject,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_drag_context_finalize (GObject *object)
|
||||
gdk_drag_finalize (GObject *object)
|
||||
{
|
||||
GdkDragContext *context = GDK_DRAG_CONTEXT (object);
|
||||
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
|
||||
GdkDrag *drag = GDK_DRAG (object);
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
contexts = g_list_remove (contexts, context);
|
||||
drags = g_list_remove (drags, drag);
|
||||
|
||||
g_clear_object (&context->content);
|
||||
g_clear_object (&priv->content);
|
||||
g_clear_pointer (&priv->formats, gdk_content_formats_unref);
|
||||
|
||||
if (context->source_surface)
|
||||
g_object_unref (context->source_surface);
|
||||
g_clear_object (&priv->surface);
|
||||
|
||||
G_OBJECT_CLASS (gdk_drag_context_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (gdk_drag_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_drag_context_class_init (GdkDragContextClass *klass)
|
||||
gdk_drag_class_init (GdkDragClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->get_property = gdk_drag_context_get_property;
|
||||
object_class->set_property = gdk_drag_context_set_property;
|
||||
object_class->finalize = gdk_drag_context_finalize;
|
||||
object_class->get_property = gdk_drag_get_property;
|
||||
object_class->set_property = gdk_drag_set_property;
|
||||
object_class->finalize = gdk_drag_finalize;
|
||||
|
||||
/**
|
||||
* GdkDragContext:content:
|
||||
* GdkDrag:content:
|
||||
*
|
||||
* The #GdkContentProvider or %NULL if the context is not a source-side
|
||||
* context.
|
||||
* The #GdkContentProvider.
|
||||
*/
|
||||
properties[PROP_CONTENT] =
|
||||
g_param_spec_object ("content",
|
||||
@@ -342,7 +364,7 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
|
||||
G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GdkDragContext:device:
|
||||
* GdkDrag:device:
|
||||
*
|
||||
* The #GdkDevice that is performing the drag.
|
||||
*/
|
||||
@@ -357,9 +379,9 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
|
||||
G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GdkDragContext:display:
|
||||
* GdkDrag:display:
|
||||
*
|
||||
* The #GdkDisplay that the drag context belongs to.
|
||||
* The #GdkDisplay that the drag belongs to.
|
||||
*/
|
||||
properties[PROP_DISPLAY] =
|
||||
g_param_spec_object ("display",
|
||||
@@ -371,9 +393,9 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
|
||||
G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GdkDragContext:formats:
|
||||
* GdkDrag:formats:
|
||||
*
|
||||
* The possible formats that the context can provide its data in.
|
||||
* The possible formats that the drag can provide its data in.
|
||||
*/
|
||||
properties[PROP_FORMATS] =
|
||||
g_param_spec_boxed ("formats",
|
||||
@@ -385,113 +407,91 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
|
||||
G_PARAM_STATIC_STRINGS |
|
||||
G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
properties[PROP_SELECTED_ACTION] =
|
||||
g_param_spec_flags ("selected-action",
|
||||
"Selected action",
|
||||
"The currently selected action",
|
||||
GDK_TYPE_DRAG_ACTION,
|
||||
0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS |
|
||||
G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
properties[PROP_ACTIONS] =
|
||||
g_param_spec_flags ("actions",
|
||||
"Actions",
|
||||
"The possible actions",
|
||||
GDK_TYPE_DRAG_ACTION,
|
||||
0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS |
|
||||
G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
properties[PROP_SURFACE] =
|
||||
g_param_spec_object ("surface",
|
||||
"Surface",
|
||||
"The surface where the drag originates",
|
||||
GDK_TYPE_SURFACE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS |
|
||||
G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GdkDragContext::cancel:
|
||||
* @context: The object on which the signal is emitted
|
||||
* @reason: The reason the context was cancelled
|
||||
* GdkDrag::cancel:
|
||||
* @drag: The object on which the signal is emitted
|
||||
* @reason: The reason the drag was cancelled
|
||||
*
|
||||
* The drag and drop operation was cancelled.
|
||||
* The drag operation was cancelled.
|
||||
*/
|
||||
signals[CANCEL] =
|
||||
g_signal_new (g_intern_static_string ("cancel"),
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GdkDragContextClass, cancel),
|
||||
G_STRUCT_OFFSET (GdkDragClass, cancel),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__ENUM,
|
||||
G_TYPE_NONE, 1, GDK_TYPE_DRAG_CANCEL_REASON);
|
||||
|
||||
/**
|
||||
* GdkDragContext::drop-performed:
|
||||
* @context: The object on which the signal is emitted
|
||||
* GdkDrag::drop-performed:
|
||||
* @drag: The object on which the signal is emitted
|
||||
*
|
||||
* The drag and drop operation was performed on an accepting client.
|
||||
* The drag operation was performed on an accepting client.
|
||||
*/
|
||||
signals[DROP_PERFORMED] =
|
||||
g_signal_new (g_intern_static_string ("drop-performed"),
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GdkDragContextClass, drop_performed),
|
||||
G_STRUCT_OFFSET (GdkDragClass, drop_performed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
/**
|
||||
* GdkDragContext::dnd-finished:
|
||||
* @context: The object on which the signal is emitted
|
||||
* GdkDrag::dnd-finished:
|
||||
* @drag: The object on which the signal is emitted
|
||||
*
|
||||
* The drag and drop operation was finished, the drag destination
|
||||
* finished reading all data. The drag source can now free all
|
||||
* miscellaneous data.
|
||||
* The drag operation was finished, the destination
|
||||
* finished reading all data. The drag object can now
|
||||
* free all miscellaneous data.
|
||||
*/
|
||||
signals[DND_FINISHED] =
|
||||
g_signal_new (g_intern_static_string ("dnd-finished"),
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GdkDragContextClass, dnd_finished),
|
||||
G_STRUCT_OFFSET (GdkDragClass, dnd_finished),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
/**
|
||||
* GdkDragContext::action-changed:
|
||||
* @context: The object on which the signal is emitted
|
||||
* @action: The action currently chosen
|
||||
*
|
||||
* A new action is being chosen for the drag and drop operation.
|
||||
*/
|
||||
signals[ACTION_CHANGED] =
|
||||
g_signal_new (g_intern_static_string ("action-changed"),
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GdkDragContextClass, action_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__FLAGS,
|
||||
G_TYPE_NONE, 1, GDK_TYPE_DRAG_ACTION);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
|
||||
}
|
||||
|
||||
/*
|
||||
* gdk_drag_abort:
|
||||
* @context: a #GdkDragContext
|
||||
* @time_: the timestamp for this operation
|
||||
*
|
||||
* Aborts a drag without dropping.
|
||||
*
|
||||
* This function is called by the drag source.
|
||||
*/
|
||||
void
|
||||
gdk_drag_abort (GdkDragContext *context,
|
||||
guint32 time_)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
||||
|
||||
GDK_DRAG_CONTEXT_GET_CLASS (context)->drag_abort (context, time_);
|
||||
}
|
||||
|
||||
/*
|
||||
* gdk_drag_drop:
|
||||
* @context: a #GdkDragContext
|
||||
* @time_: the timestamp for this operation
|
||||
*
|
||||
* Drops on the current destination.
|
||||
*
|
||||
* This function is called by the drag source.
|
||||
*/
|
||||
void
|
||||
gdk_drag_drop (GdkDragContext *context,
|
||||
guint32 time_)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
||||
|
||||
GDK_DRAG_CONTEXT_GET_CLASS (context)->drag_drop (context, time_);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_drag_context_write_done (GObject *content,
|
||||
GAsyncResult *result,
|
||||
gpointer task)
|
||||
gdk_drag_write_done (GObject *content,
|
||||
GAsyncResult *result,
|
||||
gpointer task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
@@ -504,9 +504,9 @@ gdk_drag_context_write_done (GObject *content,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_drag_context_write_serialize_done (GObject *content,
|
||||
GAsyncResult *result,
|
||||
gpointer task)
|
||||
gdk_drag_write_serialize_done (GObject *content,
|
||||
GAsyncResult *result,
|
||||
gpointer task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
@@ -519,39 +519,40 @@ gdk_drag_context_write_serialize_done (GObject *content,
|
||||
}
|
||||
|
||||
void
|
||||
gdk_drag_context_write_async (GdkDragContext *context,
|
||||
const char *mime_type,
|
||||
GOutputStream *stream,
|
||||
int io_priority,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
gdk_drag_write_async (GdkDrag *drag,
|
||||
const char *mime_type,
|
||||
GOutputStream *stream,
|
||||
int io_priority,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
GdkContentFormats *formats, *mime_formats;
|
||||
GTask *task;
|
||||
GType gtype;
|
||||
|
||||
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
||||
g_return_if_fail (context->content);
|
||||
g_return_if_fail (GDK_IS_DRAG (drag));
|
||||
g_return_if_fail (priv->content);
|
||||
g_return_if_fail (mime_type != NULL);
|
||||
g_return_if_fail (mime_type == g_intern_string (mime_type));
|
||||
g_return_if_fail (G_IS_OUTPUT_STREAM (stream));
|
||||
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
|
||||
g_return_if_fail (callback != NULL);
|
||||
|
||||
task = g_task_new (context, cancellable, callback, user_data);
|
||||
task = g_task_new (drag, cancellable, callback, user_data);
|
||||
g_task_set_priority (task, io_priority);
|
||||
g_task_set_source_tag (task, gdk_drag_context_write_async);
|
||||
g_task_set_source_tag (task, gdk_drag_write_async);
|
||||
|
||||
formats = gdk_content_provider_ref_formats (context->content);
|
||||
formats = gdk_content_provider_ref_formats (priv->content);
|
||||
if (gdk_content_formats_contain_mime_type (formats, mime_type))
|
||||
{
|
||||
gdk_content_provider_write_mime_type_async (context->content,
|
||||
gdk_content_provider_write_mime_type_async (priv->content,
|
||||
mime_type,
|
||||
stream,
|
||||
io_priority,
|
||||
cancellable,
|
||||
gdk_drag_context_write_done,
|
||||
gdk_drag_write_done,
|
||||
task);
|
||||
gdk_content_formats_unref (formats);
|
||||
return;
|
||||
@@ -568,14 +569,14 @@ gdk_drag_context_write_async (GdkDragContext *context,
|
||||
g_assert (gtype != G_TYPE_INVALID);
|
||||
|
||||
g_value_init (&value, gtype);
|
||||
if (gdk_content_provider_get_value (context->content, &value, &error))
|
||||
if (gdk_content_provider_get_value (priv->content, &value, &error))
|
||||
{
|
||||
gdk_content_serialize_async (stream,
|
||||
mime_type,
|
||||
&value,
|
||||
io_priority,
|
||||
cancellable,
|
||||
gdk_drag_context_write_serialize_done,
|
||||
gdk_drag_write_serialize_done,
|
||||
g_object_ref (task));
|
||||
}
|
||||
else
|
||||
@@ -597,54 +598,75 @@ gdk_drag_context_write_async (GdkDragContext *context,
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_drag_context_write_finish (GdkDragContext *context,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
gdk_drag_write_finish (GdkDrag *drag,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (g_task_is_valid (result, context), FALSE);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gdk_drag_context_write_async, FALSE);
|
||||
g_return_val_if_fail (g_task_is_valid (result, drag), FALSE);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gdk_drag_write_async, FALSE);
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_drag_context_set_actions (GdkDragContext *context,
|
||||
GdkDragAction actions,
|
||||
GdkDragAction suggested_action)
|
||||
gdk_drag_set_actions (GdkDrag *drag,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
if (priv->actions == actions)
|
||||
return;
|
||||
|
||||
priv->actions = actions;
|
||||
priv->suggested_action = suggested_action;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (drag), properties[PROP_ACTIONS]);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_drag_set_selected_action (GdkDrag *drag,
|
||||
GdkDragAction action)
|
||||
{
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
GdkCursor *cursor;
|
||||
|
||||
if (priv->selected_action == action)
|
||||
return;
|
||||
|
||||
priv->selected_action = action;
|
||||
|
||||
cursor = gdk_drag_get_cursor (drag, action);
|
||||
gdk_drag_set_cursor (drag, cursor);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (drag), properties[PROP_SELECTED_ACTION]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drag_context_get_drag_surface:
|
||||
* @context: a #GdkDragContext
|
||||
* gdk_drag_get_drag_surface:
|
||||
* @drag: a #GdkDrag
|
||||
*
|
||||
* Returns the surface on which the drag icon should be rendered
|
||||
* during the drag operation. Note that the surface may not be
|
||||
* available until the drag operation has begun. GDK will move
|
||||
* the surface in accordance with the ongoing drag operation.
|
||||
* The surface is owned by @context and will be destroyed when
|
||||
* The surface is owned by @drag and will be destroyed when
|
||||
* the drag operation is over.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the drag surface, or %NULL
|
||||
*/
|
||||
GdkSurface *
|
||||
gdk_drag_context_get_drag_surface (GdkDragContext *context)
|
||||
gdk_drag_get_drag_surface (GdkDrag *drag)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
|
||||
|
||||
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->get_drag_surface)
|
||||
return GDK_DRAG_CONTEXT_GET_CLASS (context)->get_drag_surface (context);
|
||||
if (GDK_DRAG_GET_CLASS (drag)->get_drag_surface)
|
||||
return GDK_DRAG_GET_CLASS (drag)->get_drag_surface (drag);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drag_context_set_hotspot:
|
||||
* @context: a #GdkDragContext
|
||||
* gdk_drag_set_hotspot:
|
||||
* @drag: a #GdkDrag
|
||||
* @hot_x: x coordinate of the drag surface hotspot
|
||||
* @hot_y: y coordinate of the drag surface hotspot
|
||||
*
|
||||
@@ -653,19 +675,19 @@ gdk_drag_context_get_drag_surface (GdkDragContext *context)
|
||||
* top left corner of the drag surface.
|
||||
*/
|
||||
void
|
||||
gdk_drag_context_set_hotspot (GdkDragContext *context,
|
||||
gint hot_x,
|
||||
gint hot_y)
|
||||
gdk_drag_set_hotspot (GdkDrag *drag,
|
||||
gint hot_x,
|
||||
gint hot_y)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
||||
g_return_if_fail (GDK_IS_DRAG (drag));
|
||||
|
||||
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->set_hotspot)
|
||||
GDK_DRAG_CONTEXT_GET_CLASS (context)->set_hotspot (context, hot_x, hot_y);
|
||||
if (GDK_DRAG_GET_CLASS (drag)->set_hotspot)
|
||||
GDK_DRAG_GET_CLASS (drag)->set_hotspot (drag, hot_x, hot_y);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drag_drop_done:
|
||||
* @context: a #GdkDragContext
|
||||
* @drag: a #GdkDrag
|
||||
* @success: whether the drag was ultimatively successful
|
||||
*
|
||||
* Inform GDK if the drop ended successfully. Passing %FALSE
|
||||
@@ -673,60 +695,62 @@ gdk_drag_context_set_hotspot (GdkDragContext *context,
|
||||
*
|
||||
* This function is called by the drag source, and should
|
||||
* be the last call before dropping the reference to the
|
||||
* @context.
|
||||
* @drag.
|
||||
*
|
||||
* The #GdkDragContext will only take the first gdk_drag_drop_done()
|
||||
* The #GdkDrag will only take the first gdk_drag_drop_done()
|
||||
* call as effective, if this function is called multiple times,
|
||||
* all subsequent calls will be ignored.
|
||||
*/
|
||||
void
|
||||
gdk_drag_drop_done (GdkDragContext *context,
|
||||
gboolean success)
|
||||
gdk_drag_drop_done (GdkDrag *drag,
|
||||
gboolean success)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
if (context->drop_done)
|
||||
g_return_if_fail (GDK_IS_DRAG (drag));
|
||||
|
||||
if (priv->drop_done)
|
||||
return;
|
||||
|
||||
context->drop_done = TRUE;
|
||||
priv->drop_done = TRUE;
|
||||
|
||||
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->drop_done)
|
||||
GDK_DRAG_CONTEXT_GET_CLASS (context)->drop_done (context, success);
|
||||
if (GDK_DRAG_GET_CLASS (drag)->drop_done)
|
||||
GDK_DRAG_GET_CLASS (drag)->drop_done (drag, success);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_drag_context_set_cursor (GdkDragContext *context,
|
||||
GdkCursor *cursor)
|
||||
gdk_drag_set_cursor (GdkDrag *drag,
|
||||
GdkCursor *cursor)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
||||
g_return_if_fail (GDK_IS_DRAG (drag));
|
||||
|
||||
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->set_cursor)
|
||||
GDK_DRAG_CONTEXT_GET_CLASS (context)->set_cursor (context, cursor);
|
||||
if (GDK_DRAG_GET_CLASS (drag)->set_cursor)
|
||||
GDK_DRAG_GET_CLASS (drag)->set_cursor (drag, cursor);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_drag_context_cancel (GdkDragContext *context,
|
||||
GdkDragCancelReason reason)
|
||||
gdk_drag_cancel (GdkDrag *drag,
|
||||
GdkDragCancelReason reason)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
||||
g_return_if_fail (GDK_IS_DRAG (drag));
|
||||
|
||||
g_signal_emit (context, signals[CANCEL], 0, reason);
|
||||
g_signal_emit (drag, signals[CANCEL], 0, reason);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_drag_context_handle_source_event (GdkEvent *event)
|
||||
gdk_drag_handle_source_event (GdkEvent *event)
|
||||
{
|
||||
GdkDragContext *context;
|
||||
GdkDrag *drag;
|
||||
GList *l;
|
||||
|
||||
for (l = contexts; l; l = l->next)
|
||||
for (l = drags; l; l = l->next)
|
||||
{
|
||||
context = l->data;
|
||||
drag = l->data;
|
||||
|
||||
if (!GDK_DRAG_CONTEXT_GET_CLASS (context)->handle_event)
|
||||
if (!GDK_DRAG_GET_CLASS (drag)->handle_event)
|
||||
continue;
|
||||
|
||||
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->handle_event (context, event))
|
||||
if (GDK_DRAG_GET_CLASS (drag)->handle_event (drag, event))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -734,8 +758,8 @@ gdk_drag_context_handle_source_event (GdkEvent *event)
|
||||
}
|
||||
|
||||
GdkCursor *
|
||||
gdk_drag_get_cursor (GdkDragContext *context,
|
||||
GdkDragAction action)
|
||||
gdk_drag_get_cursor (GdkDrag *drag,
|
||||
GdkDragAction action)
|
||||
{
|
||||
gint i;
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
#ifndef __GDK_DND_H__
|
||||
#define __GDK_DND_H__
|
||||
|
||||
#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkdevice.h>
|
||||
#include <gdk/gdkevents.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_DRAG (gdk_drag_get_type ())
|
||||
#define GDK_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAG, GdkDrag))
|
||||
#define GDK_IS_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAG))
|
||||
|
||||
/**
|
||||
* GdkDragCancelReason:
|
||||
* @GDK_DRAG_CANCEL_NO_TARGET: There is no suitable drop target.
|
||||
* @GDK_DRAG_CANCEL_USER_CANCELLED: Drag cancelled by the user
|
||||
* @GDK_DRAG_CANCEL_ERROR: Unspecified error.
|
||||
*
|
||||
* Used in #GdkDrag to the reason of a cancelled DND operation.
|
||||
*/
|
||||
typedef enum {
|
||||
GDK_DRAG_CANCEL_NO_TARGET,
|
||||
GDK_DRAG_CANCEL_USER_CANCELLED,
|
||||
GDK_DRAG_CANCEL_ERROR
|
||||
} GdkDragCancelReason;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gdk_drag_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDisplay * gdk_drag_get_display (GdkDrag *drag);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDevice * gdk_drag_get_device (GdkDrag *drag);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkContentFormats *gdk_drag_get_formats (GdkDrag *drag);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDragAction gdk_drag_get_actions (GdkDrag *drag);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDragAction gdk_drag_get_selected_action (GdkDrag *drag);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_drag_action_is_unique (GdkDragAction action);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDrag * gdk_drag_begin (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider *content,
|
||||
GdkDragAction actions,
|
||||
gint dx,
|
||||
gint dy);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_drag_drop_done (GdkDrag *drag,
|
||||
gboolean success);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkSurface *gdk_drag_get_drag_surface (GdkDrag *drag);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_drag_set_hotspot (GdkDrag *drag,
|
||||
gint hot_x,
|
||||
gint hot_y);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_DND_H__ */
|
||||
@@ -0,0 +1,86 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 2010, 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 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/>.
|
||||
*/
|
||||
|
||||
#ifndef __GDK_DND_PRIVATE_H__
|
||||
#define __GDK_DND_PRIVATE_H__
|
||||
|
||||
#include "gdkdrag.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define GDK_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAG, GdkDragClass))
|
||||
#define GDK_IS_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DRAG))
|
||||
#define GDK_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DRAG, GdkDragClass))
|
||||
|
||||
typedef struct _GdkDragClass GdkDragClass;
|
||||
|
||||
|
||||
struct _GdkDragClass {
|
||||
GObjectClass parent_class;
|
||||
|
||||
GdkSurface* (*get_drag_surface) (GdkDrag *drag);
|
||||
void (*set_hotspot) (GdkDrag *drag,
|
||||
gint hot_x,
|
||||
gint hot_y);
|
||||
void (*drop_done) (GdkDrag *drag,
|
||||
gboolean success);
|
||||
|
||||
void (*set_cursor) (GdkDrag *drag,
|
||||
GdkCursor *cursor);
|
||||
void (*cancel) (GdkDrag *drag,
|
||||
GdkDragCancelReason reason);
|
||||
void (*drop_performed) (GdkDrag *drag,
|
||||
guint32 time);
|
||||
void (*dnd_finished) (GdkDrag *drag);
|
||||
|
||||
gboolean (*handle_event) (GdkDrag *drag,
|
||||
const GdkEvent *event);
|
||||
};
|
||||
|
||||
struct _GdkDrag {
|
||||
GObject parent_instance;
|
||||
};
|
||||
|
||||
void gdk_drag_set_cursor (GdkDrag *drag,
|
||||
GdkCursor *cursor);
|
||||
void gdk_drag_set_actions (GdkDrag *drag,
|
||||
GdkDragAction actions);
|
||||
void gdk_drag_set_selected_action (GdkDrag *drag,
|
||||
GdkDragAction action);
|
||||
|
||||
void gdk_drag_cancel (GdkDrag *drag,
|
||||
GdkDragCancelReason reason);
|
||||
gboolean gdk_drag_handle_source_event (GdkEvent *event);
|
||||
GdkCursor * gdk_drag_get_cursor (GdkDrag *drag,
|
||||
GdkDragAction action);
|
||||
|
||||
void gdk_drag_write_async (GdkDrag *drag,
|
||||
const char *mime_type,
|
||||
GOutputStream *stream,
|
||||
int io_priority,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean gdk_drag_write_finish (GdkDrag *drag,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
+18
-7
@@ -38,7 +38,7 @@ typedef struct _GdkDropPrivate GdkDropPrivate;
|
||||
|
||||
struct _GdkDropPrivate {
|
||||
GdkDevice *device;
|
||||
GdkDragContext *drag;
|
||||
GdkDrag *drag;
|
||||
GdkContentFormats *formats;
|
||||
GdkSurface *surface;
|
||||
GdkDragAction actions;
|
||||
@@ -78,7 +78,7 @@ gdk_drop_read_local_write_done (GObject *drag,
|
||||
gpointer stream)
|
||||
{
|
||||
/* we don't care about the error, we just want to clean up */
|
||||
gdk_drag_context_write_finish (GDK_DRAG_CONTEXT (drag), result, NULL);
|
||||
gdk_drag_write_finish (GDK_DRAG (drag), result, NULL);
|
||||
|
||||
/* XXX: Do we need to close_async() here? */
|
||||
g_output_stream_close (stream, NULL, NULL);
|
||||
@@ -98,6 +98,7 @@ gdk_drop_read_local_async (GdkDrop *self,
|
||||
GdkContentFormats *content_formats;
|
||||
const char *mime_type;
|
||||
GTask *task;
|
||||
GdkContentProvider *content;
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_priority (task, io_priority);
|
||||
@@ -111,7 +112,9 @@ gdk_drop_read_local_async (GdkDrop *self,
|
||||
return;
|
||||
}
|
||||
|
||||
content_formats = gdk_content_provider_ref_formats (priv->drag->content);
|
||||
g_object_get (priv->drag, "content", &content, NULL);
|
||||
content_formats = gdk_content_provider_ref_formats (content);
|
||||
g_object_unref (content);
|
||||
content_formats = gdk_content_formats_union_serialize_mime_types (content_formats);
|
||||
mime_type = gdk_content_formats_match_mime_type (content_formats, formats);
|
||||
|
||||
@@ -122,7 +125,7 @@ gdk_drop_read_local_async (GdkDrop *self,
|
||||
|
||||
stream = gdk_pipe_io_stream_new ();
|
||||
output_stream = g_io_stream_get_output_stream (stream);
|
||||
gdk_drag_context_write_async (priv->drag,
|
||||
gdk_drag_write_async (priv->drag,
|
||||
mime_type,
|
||||
output_stream,
|
||||
io_priority,
|
||||
@@ -321,7 +324,7 @@ gdk_drop_class_init (GdkDropClass *klass)
|
||||
g_param_spec_object ("drag",
|
||||
"Drag",
|
||||
"The drag that initiated this drop",
|
||||
GDK_TYPE_DRAG_CONTEXT,
|
||||
GDK_TYPE_DRAG,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS |
|
||||
@@ -492,7 +495,7 @@ gdk_drop_set_actions (GdkDrop *self,
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the corresponding #GdkDrag
|
||||
**/
|
||||
GdkDragContext *
|
||||
GdkDrag *
|
||||
gdk_drop_get_drag (GdkDrop *self)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
@@ -724,8 +727,16 @@ gdk_drop_read_value_internal (GdkDrop *self,
|
||||
if (priv->drag)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GdkContentProvider *content;
|
||||
gboolean res;
|
||||
|
||||
if (gdk_content_provider_get_value (priv->drag->content, value, &error))
|
||||
g_object_get (priv->drag, "content", &content, NULL);
|
||||
|
||||
res = gdk_content_provider_get_value (content, value, &error);
|
||||
|
||||
g_object_unref (content);
|
||||
|
||||
if (res)
|
||||
{
|
||||
g_task_return_pointer (task, value, NULL);
|
||||
g_object_unref (task);
|
||||
|
||||
+3
-3
@@ -50,7 +50,7 @@ GdkContentFormats * gdk_drop_get_formats (GdkDrop
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDragAction gdk_drop_get_actions (GdkDrop *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDragContext * gdk_drop_get_drag (GdkDrop *self);
|
||||
GdkDrag * gdk_drop_get_drag (GdkDrop *self);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_drop_status (GdkDrop *self,
|
||||
@@ -83,12 +83,12 @@ const GValue * gdk_drop_read_value_finish (GdkDrop
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_drop_read_text_async (GdkDrop *drop,
|
||||
void gdk_drop_read_text_async (GdkDrop *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
char * gdk_drop_read_text_finish (GdkDrop *drop,
|
||||
char * gdk_drop_read_text_finish (GdkDrop *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
|
||||
+5
-59
@@ -28,7 +28,7 @@
|
||||
#include "gdkeventsprivate.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkdndprivate.h"
|
||||
#include "gdkdragprivate.h"
|
||||
#include "gdkdropprivate.h"
|
||||
#include "gdk-private.h"
|
||||
|
||||
@@ -165,7 +165,10 @@ gdk_event_class_init (GdkEventClass *klass)
|
||||
void
|
||||
_gdk_event_emit (GdkEvent *event)
|
||||
{
|
||||
if (gdk_drag_context_handle_source_event (event))
|
||||
if (gdk_drag_handle_source_event (event))
|
||||
return;
|
||||
|
||||
if (gdk_surface_handle_event (event))
|
||||
return;
|
||||
|
||||
if (_gdk_event_func)
|
||||
@@ -628,11 +631,6 @@ gdk_event_copy (const GdkEvent *event)
|
||||
|
||||
switch ((guint) event->any.type)
|
||||
{
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
new_event->key.string = g_strdup (event->key.string);
|
||||
break;
|
||||
|
||||
case GDK_ENTER_NOTIFY:
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
if (event->crossing.child_surface != NULL)
|
||||
@@ -646,11 +644,6 @@ gdk_event_copy (const GdkEvent *event)
|
||||
g_object_ref (event->dnd.drop);
|
||||
break;
|
||||
|
||||
case GDK_EXPOSE:
|
||||
if (event->expose.region)
|
||||
new_event->expose.region = cairo_region_copy (event->expose.region);
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
case GDK_BUTTON_RELEASE:
|
||||
if (event->button.axes)
|
||||
@@ -700,11 +693,6 @@ gdk_event_finalize (GObject *object)
|
||||
|
||||
switch ((guint) event->any.type)
|
||||
{
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
g_free (event->key.string);
|
||||
break;
|
||||
|
||||
case GDK_ENTER_NOTIFY:
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
g_clear_object (&event->crossing.child_surface);
|
||||
@@ -730,11 +718,6 @@ gdk_event_finalize (GObject *object)
|
||||
g_free (event->touch.axes);
|
||||
break;
|
||||
|
||||
case GDK_EXPOSE:
|
||||
if (event->expose.region)
|
||||
cairo_region_destroy (event->expose.region);
|
||||
break;
|
||||
|
||||
case GDK_MOTION_NOTIFY:
|
||||
g_clear_object (&event->motion.tool);
|
||||
g_free (event->motion.axes);
|
||||
@@ -832,9 +815,6 @@ gdk_event_get_time (const GdkEvent *event)
|
||||
case GDK_NOTHING:
|
||||
case GDK_DELETE:
|
||||
case GDK_DESTROY:
|
||||
case GDK_EXPOSE:
|
||||
case GDK_MAP:
|
||||
case GDK_UNMAP:
|
||||
case GDK_GRAB_BROKEN:
|
||||
case GDK_EVENT_LAST:
|
||||
default:
|
||||
@@ -908,9 +888,6 @@ gdk_event_get_state (const GdkEvent *event,
|
||||
case GDK_NOTHING:
|
||||
case GDK_DELETE:
|
||||
case GDK_DESTROY:
|
||||
case GDK_EXPOSE:
|
||||
case GDK_MAP:
|
||||
case GDK_UNMAP:
|
||||
case GDK_GRAB_BROKEN:
|
||||
case GDK_PAD_BUTTON_PRESS:
|
||||
case GDK_PAD_BUTTON_RELEASE:
|
||||
@@ -1306,37 +1283,6 @@ gdk_event_get_key_group (const GdkEvent *event,
|
||||
return fetched;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_string:
|
||||
* @event: a #GdkEvent
|
||||
* @string: (out) (transfer none): return location for the string
|
||||
*
|
||||
* Extracts a string from an event. The string is an
|
||||
* approximation of the keyval in a key event.
|
||||
*
|
||||
* Returns: %TRUE on success, otherwise %FALSE
|
||||
**/
|
||||
gboolean
|
||||
gdk_event_get_string (const GdkEvent *event,
|
||||
const char **string)
|
||||
{
|
||||
gboolean fetched = TRUE;
|
||||
|
||||
switch ((guint) event->any.type)
|
||||
{
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
*string = event->key.string;
|
||||
break;
|
||||
default:
|
||||
*string = NULL;
|
||||
fetched = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return fetched;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_key_is_modifier:
|
||||
* @event: a #GdkEvent
|
||||
|
||||
+1
-12
@@ -31,7 +31,7 @@
|
||||
|
||||
#include <gdk/gdkversionmacros.h>
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkdnd.h>
|
||||
#include <gdk/gdkdrag.h>
|
||||
#include <gdk/gdkdevice.h>
|
||||
#include <gdk/gdkdevicetool.h>
|
||||
|
||||
@@ -104,7 +104,6 @@ G_BEGIN_DECLS
|
||||
|
||||
|
||||
typedef struct _GdkEventAny GdkEventAny;
|
||||
typedef struct _GdkEventExpose GdkEventExpose;
|
||||
typedef struct _GdkEventMotion GdkEventMotion;
|
||||
typedef struct _GdkEventButton GdkEventButton;
|
||||
typedef struct _GdkEventTouch GdkEventTouch;
|
||||
@@ -145,8 +144,6 @@ typedef void (*GdkEventFunc) (GdkEvent *event,
|
||||
* hidden or destroyed, usually when the user clicks on a special icon in the
|
||||
* title bar.
|
||||
* @GDK_DESTROY: the surface has been destroyed.
|
||||
* @GDK_EXPOSE: all or part of the surface has become visible and needs to be
|
||||
* redrawn.
|
||||
* @GDK_MOTION_NOTIFY: the pointer (usually a mouse) has moved.
|
||||
* @GDK_BUTTON_PRESS: a mouse button has been pressed.
|
||||
* @GDK_BUTTON_RELEASE: a mouse button has been released.
|
||||
@@ -157,8 +154,6 @@ typedef void (*GdkEventFunc) (GdkEvent *event,
|
||||
* @GDK_FOCUS_CHANGE: the keyboard focus has entered or left the surface.
|
||||
* @GDK_CONFIGURE: the size, position or stacking order of the surface has changed.
|
||||
* Note that GTK+ discards these events for %GDK_SURFACE_CHILD surfaces.
|
||||
* @GDK_MAP: the surface has been mapped.
|
||||
* @GDK_UNMAP: the surface has been unmapped.
|
||||
* @GDK_PROXIMITY_IN: an input device has moved into contact with a sensing
|
||||
* surface (e.g. a touchscreen or graphics tablet).
|
||||
* @GDK_PROXIMITY_OUT: an input device has moved out of contact with a sensing
|
||||
@@ -206,7 +201,6 @@ typedef enum
|
||||
GDK_NOTHING,
|
||||
GDK_DELETE,
|
||||
GDK_DESTROY,
|
||||
GDK_EXPOSE,
|
||||
GDK_MOTION_NOTIFY,
|
||||
GDK_BUTTON_PRESS,
|
||||
GDK_BUTTON_RELEASE,
|
||||
@@ -216,8 +210,6 @@ typedef enum
|
||||
GDK_LEAVE_NOTIFY,
|
||||
GDK_FOCUS_CHANGE,
|
||||
GDK_CONFIGURE,
|
||||
GDK_MAP,
|
||||
GDK_UNMAP,
|
||||
GDK_PROXIMITY_IN,
|
||||
GDK_PROXIMITY_OUT,
|
||||
GDK_DRAG_ENTER,
|
||||
@@ -411,9 +403,6 @@ gboolean gdk_event_get_key_is_modifier (const GdkEvent *event,
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_key_group (const GdkEvent *event,
|
||||
guint *group);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_string (const GdkEvent *event,
|
||||
const char **string);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_scroll_direction (const GdkEvent *event,
|
||||
|
||||
+1
-34
@@ -26,7 +26,7 @@
|
||||
#define __GDK_EVENTS_PRIVATE_H__
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkdnd.h>
|
||||
#include <gdk/gdkdrag.h>
|
||||
#include <gdk/gdkdevice.h>
|
||||
#include <gdk/gdkdevicetool.h>
|
||||
|
||||
@@ -63,23 +63,6 @@ struct _GdkEventAny
|
||||
GdkDisplay *display;
|
||||
};
|
||||
|
||||
/*
|
||||
* GdkEventExpose:
|
||||
* @type: the type of the event (%GDK_EXPOSE)
|
||||
* @surface: the surface which received the event.
|
||||
* @send_event: %TRUE if the event was sent explicitly.
|
||||
* @area: bounding box of @region.
|
||||
* @region: the region that needs to be redrawn.
|
||||
*
|
||||
* Generated when all or part of a surface becomes visible and needs to be
|
||||
* redrawn.
|
||||
*/
|
||||
struct _GdkEventExpose
|
||||
{
|
||||
GdkEventAny any;
|
||||
cairo_region_t *region;
|
||||
};
|
||||
|
||||
/*
|
||||
* GdkEventMotion:
|
||||
* @type: the type of the event.
|
||||
@@ -261,18 +244,6 @@ struct _GdkEventScroll
|
||||
* @keyval: the key that was pressed or released. See the
|
||||
* `gdk/gdkkeysyms.h` header file for a
|
||||
* complete list of GDK key codes.
|
||||
* @length: the length of @string.
|
||||
* @string: a string containing an approximation of the text that
|
||||
* would result from this keypress. The only correct way to handle text
|
||||
* input of text is using input methods (see #GtkIMContext), so this
|
||||
* field is deprecated and should never be used.
|
||||
* (gdk_unicode_to_keyval() provides a non-deprecated way of getting
|
||||
* an approximate translation for a key.) The string is encoded in the
|
||||
* encoding of the current locale (Note: this for backwards compatibility:
|
||||
* strings in GTK+ and GDK are typically in UTF-8.) and NUL-terminated.
|
||||
* In some cases, the translation of the key code will be a single
|
||||
* NUL byte, in which case looking at @length is necessary to distinguish
|
||||
* it from the an empty translation.
|
||||
* @hardware_keycode: the raw code of the key that was pressed or released.
|
||||
* @group: the keyboard group.
|
||||
* @is_modifier: a flag that indicates if @hardware_keycode is mapped to a
|
||||
@@ -286,8 +257,6 @@ struct _GdkEventKey
|
||||
guint32 time;
|
||||
guint state;
|
||||
guint keyval;
|
||||
gint length;
|
||||
gchar *string;
|
||||
guint16 hardware_keycode;
|
||||
guint16 key_scancode;
|
||||
guint8 group;
|
||||
@@ -593,7 +562,6 @@ struct _GdkEventPadGroupMode {
|
||||
* GdkEvent:
|
||||
* @type: the #GdkEventType
|
||||
* @any: a #GdkEventAny
|
||||
* @expose: a #GdkEventExpose
|
||||
* @motion: a #GdkEventMotion
|
||||
* @button: a #GdkEventButton
|
||||
* @touch: a #GdkEventTouch
|
||||
@@ -645,7 +613,6 @@ struct _GdkEventPadGroupMode {
|
||||
union _GdkEvent
|
||||
{
|
||||
GdkEventAny any;
|
||||
GdkEventExpose expose;
|
||||
GdkEventMotion motion;
|
||||
GdkEventButton button;
|
||||
GdkEventTouch touch;
|
||||
|
||||
+3
-1
@@ -32,7 +32,7 @@
|
||||
#include "gdkdisplay.h"
|
||||
#include "gdkeventsprivate.h"
|
||||
#include "gdkenumtypes.h"
|
||||
#include "gdkdndprivate.h"
|
||||
#include "gdkdragprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -291,6 +291,8 @@ GdkGLContext * gdk_surface_get_paint_gl_context (GdkSurface *surface,
|
||||
void gdk_surface_get_unscaled_size (GdkSurface *surface,
|
||||
int *unscaled_width,
|
||||
int *unscaled_height);
|
||||
gboolean gdk_surface_handle_event (GdkEvent *event);
|
||||
|
||||
|
||||
/*****************************************
|
||||
* Interfaces provided by windowing code *
|
||||
|
||||
+2
-2
@@ -643,8 +643,8 @@ gdk_paintable_new_empty (int intrinsic_width,
|
||||
{
|
||||
GdkEmptyPaintable *result;
|
||||
|
||||
g_return_val_if_fail (intrinsic_width < 0, NULL);
|
||||
g_return_val_if_fail (intrinsic_height < 0, NULL);
|
||||
g_return_val_if_fail (intrinsic_width >= 0, NULL);
|
||||
g_return_val_if_fail (intrinsic_height >= 0, NULL);
|
||||
|
||||
result = g_object_new (GDK_TYPE_EMPTY_PAINTABLE, NULL);
|
||||
|
||||
|
||||
+73
-79
@@ -97,6 +97,8 @@
|
||||
|
||||
enum {
|
||||
MOVED_TO_RECT,
|
||||
SIZE_CHANGED,
|
||||
RENDER,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
@@ -105,6 +107,7 @@ enum {
|
||||
PROP_CURSOR,
|
||||
PROP_DISPLAY,
|
||||
PROP_STATE,
|
||||
PROP_MAPPED,
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
@@ -271,6 +274,13 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
|
||||
GDK_TYPE_SURFACE_STATE, GDK_SURFACE_STATE_WITHDRAWN,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
properties[PROP_MAPPED] =
|
||||
g_param_spec_boolean ("mapped",
|
||||
P_("Mapped"),
|
||||
P_("Mapped"),
|
||||
FALSE,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, LAST_PROP, properties);
|
||||
|
||||
/**
|
||||
@@ -310,6 +320,31 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
|
||||
G_TYPE_POINTER,
|
||||
G_TYPE_BOOLEAN,
|
||||
G_TYPE_BOOLEAN);
|
||||
|
||||
signals[SIZE_CHANGED] =
|
||||
g_signal_new (g_intern_static_string ("size-changed"),
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
G_TYPE_NONE,
|
||||
2,
|
||||
G_TYPE_INT,
|
||||
G_TYPE_INT);
|
||||
|
||||
signals[RENDER] =
|
||||
g_signal_new (g_intern_static_string ("render"),
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
g_signal_accumulator_true_handled,
|
||||
NULL,
|
||||
NULL,
|
||||
G_TYPE_BOOLEAN,
|
||||
1,
|
||||
CAIRO_GOBJECT_TYPE_REGION);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -416,6 +451,10 @@ gdk_surface_get_property (GObject *object,
|
||||
g_value_set_flags (value, surface->state);
|
||||
break;
|
||||
|
||||
case PROP_MAPPED:
|
||||
g_value_set_boolean (value, GDK_SURFACE_IS_MAPPED (surface));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -946,6 +985,7 @@ _gdk_surface_destroy_hierarchy (GdkSurface *surface,
|
||||
surface_remove_from_pointer_info (surface, display);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_STATE]);
|
||||
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_MAPPED]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1617,20 +1657,13 @@ static void
|
||||
gdk_surface_process_updates_recurse (GdkSurface *surface,
|
||||
cairo_region_t *expose_region)
|
||||
{
|
||||
GdkEvent *event;
|
||||
gboolean handled;
|
||||
|
||||
if (surface->destroyed)
|
||||
return;
|
||||
|
||||
/* Paint the surface before the children, clipped to the surface region */
|
||||
|
||||
event = gdk_event_new (GDK_EXPOSE);
|
||||
event->any.surface = g_object_ref (surface);
|
||||
event->any.send_event = FALSE;
|
||||
event->expose.region = cairo_region_reference (expose_region);
|
||||
|
||||
_gdk_event_emit (event);
|
||||
g_object_unref (event);
|
||||
g_signal_emit (surface, signals[RENDER], 0, expose_region, &handled);
|
||||
}
|
||||
|
||||
/* Process and remove any invalid area on the native surface by creating
|
||||
@@ -2250,6 +2283,7 @@ gdk_surface_show_internal (GdkSurface *surface, gboolean raise)
|
||||
{
|
||||
surface->state = 0;
|
||||
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_STATE]);
|
||||
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_MAPPED]);
|
||||
}
|
||||
|
||||
did_show = _gdk_surface_update_viewable (surface);
|
||||
@@ -2265,14 +2299,6 @@ gdk_surface_show_internal (GdkSurface *surface, gboolean raise)
|
||||
impl_class->show (surface, !did_show ? was_mapped : TRUE);
|
||||
}
|
||||
|
||||
if (!was_mapped && !gdk_surface_has_impl (surface))
|
||||
{
|
||||
_gdk_make_event (surface, GDK_MAP, NULL, FALSE);
|
||||
|
||||
if (surface->parent)
|
||||
_gdk_make_event (surface, GDK_MAP, NULL, FALSE);
|
||||
}
|
||||
|
||||
if (!was_mapped || did_raise)
|
||||
{
|
||||
recompute_visible_regions (surface, FALSE);
|
||||
@@ -2308,7 +2334,7 @@ gdk_surface_show_unraised (GdkSurface *surface)
|
||||
* other surfaces with the same parent surface appear below @surface.
|
||||
* This is true whether or not the surfaces are visible.
|
||||
*
|
||||
* If @surface is a toplevel, the surface manager may choose to deny the
|
||||
* If @surface is a toplevel, the window manager may choose to deny the
|
||||
* request to move the surface in the Z-order, gdk_surface_raise() only
|
||||
* requests the restack, does not guarantee it.
|
||||
*/
|
||||
@@ -2529,6 +2555,7 @@ gdk_surface_hide (GdkSurface *surface)
|
||||
{
|
||||
surface->state = GDK_SURFACE_STATE_WITHDRAWN;
|
||||
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_STATE]);
|
||||
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_MAPPED]);
|
||||
}
|
||||
|
||||
if (was_mapped)
|
||||
@@ -2575,62 +2602,11 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
recompute_visible_regions (surface, FALSE);
|
||||
|
||||
if (was_mapped && !gdk_surface_has_impl (surface))
|
||||
{
|
||||
_gdk_make_event (surface, GDK_UNMAP, NULL, FALSE);
|
||||
|
||||
if (surface->parent)
|
||||
_gdk_make_event (surface, GDK_UNMAP, NULL, FALSE);
|
||||
}
|
||||
|
||||
/* Invalidate the rect */
|
||||
if (was_mapped)
|
||||
gdk_surface_invalidate_in_parent (surface);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_surface_withdraw:
|
||||
* @surface: a toplevel #GdkSurface
|
||||
*
|
||||
* Withdraws a surface (unmaps it and asks the surface manager to forget about it).
|
||||
* This function is not really useful as gdk_surface_hide() automatically
|
||||
* withdraws toplevel surfaces before hiding them.
|
||||
**/
|
||||
void
|
||||
gdk_surface_withdraw (GdkSurface *surface)
|
||||
{
|
||||
GdkSurfaceImplClass *impl_class;
|
||||
gboolean was_mapped;
|
||||
GdkGLContext *current_context;
|
||||
|
||||
g_return_if_fail (GDK_IS_SURFACE (surface));
|
||||
|
||||
if (surface->destroyed)
|
||||
return;
|
||||
|
||||
was_mapped = GDK_SURFACE_IS_MAPPED (surface);
|
||||
|
||||
if (gdk_surface_has_impl (surface))
|
||||
{
|
||||
impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
|
||||
impl_class->withdraw (surface);
|
||||
|
||||
if (was_mapped)
|
||||
{
|
||||
_gdk_make_event (surface, GDK_UNMAP, NULL, FALSE);
|
||||
|
||||
if (surface->parent)
|
||||
_gdk_make_event (surface, GDK_UNMAP, NULL, FALSE);
|
||||
}
|
||||
|
||||
current_context = gdk_gl_context_get_current ();
|
||||
if (current_context != NULL && gdk_gl_context_get_surface (current_context) == surface)
|
||||
gdk_gl_context_clear_current ();
|
||||
|
||||
recompute_visible_regions (surface, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_surface_move_resize_toplevel (GdkSurface *surface,
|
||||
gboolean with_move,
|
||||
@@ -2917,7 +2893,7 @@ gdk_surface_get_cursor (GdkSurface *surface)
|
||||
*
|
||||
* Note that @cursor must be for the same display as @surface.
|
||||
*
|
||||
* Use gdk_cursor_new_for_display() or gdk_cursor_new_from_texture() to
|
||||
* Use gdk_cursor_new_from_name() or gdk_cursor_new_from_texture() to
|
||||
* create the cursor. To make the cursor invisible, use %GDK_BLANK_CURSOR.
|
||||
* Passing %NULL for the @cursor argument to gdk_surface_set_cursor() means
|
||||
* that @surface will use the cursor of its parent surface. Most surfaces
|
||||
@@ -3004,7 +2980,7 @@ gdk_surface_get_device_cursor (GdkSurface *surface,
|
||||
* @cursor: a #GdkCursor
|
||||
*
|
||||
* Sets a specific #GdkCursor for a given device when it gets inside @surface.
|
||||
* Use gdk_cursor_new_for_display() or gdk_cursor_new_from_texture() to create
|
||||
* Use gdk_cursor_new_fromm_name() or gdk_cursor_new_from_texture() to create
|
||||
* the cursor. To make the cursor invisible, use %GDK_BLANK_CURSOR. Passing
|
||||
* %NULL for the @cursor argument to gdk_surface_set_cursor() means that
|
||||
* @surface will use the cursor of its parent surface. Most surfaces should
|
||||
@@ -3445,7 +3421,7 @@ gdk_surface_merge_child_input_shapes (GdkSurface *surface)
|
||||
* gdk_surface_get_modal_hint:
|
||||
* @surface: A toplevel #GdkSurface.
|
||||
*
|
||||
* Determines whether or not the surface manager is hinted that @surface
|
||||
* Determines whether or not the window manager is hinted that @surface
|
||||
* has modal behaviour.
|
||||
*
|
||||
* Returns: whether or not the surface has the modal hint set.
|
||||
@@ -3909,11 +3885,8 @@ _gdk_make_event (GdkSurface *surface,
|
||||
|
||||
case GDK_FOCUS_CHANGE:
|
||||
case GDK_CONFIGURE:
|
||||
case GDK_MAP:
|
||||
case GDK_UNMAP:
|
||||
case GDK_DELETE:
|
||||
case GDK_DESTROY:
|
||||
case GDK_EXPOSE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -4427,7 +4400,7 @@ gdk_surface_set_transient_for (GdkSurface *surface,
|
||||
* @x: (out): return location for X position of surface frame
|
||||
* @y: (out): return location for Y position of surface frame
|
||||
*
|
||||
* Obtains the top-left corner of the surface manager frame in root
|
||||
* Obtains the top-left corner of the window manager frame in root
|
||||
* surface coordinates.
|
||||
*
|
||||
**/
|
||||
@@ -5140,10 +5113,10 @@ gdk_surface_register_dnd (GdkSurface *surface)
|
||||
*
|
||||
* This function is called by the drag source.
|
||||
*
|
||||
* Returns: (transfer full) (nullable): a newly created #GdkDragContext or
|
||||
* Returns: (transfer full) (nullable): a newly created #GdkDrag or
|
||||
* %NULL on error.
|
||||
*/
|
||||
GdkDragContext *
|
||||
GdkDrag *
|
||||
gdk_drag_begin (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider *content,
|
||||
@@ -5467,6 +5440,7 @@ void
|
||||
gdk_surface_set_state (GdkSurface *surface,
|
||||
GdkSurfaceState new_state)
|
||||
{
|
||||
gboolean was_mapped, mapped;
|
||||
g_return_if_fail (GDK_IS_SURFACE (surface));
|
||||
|
||||
if (new_state == surface->state)
|
||||
@@ -5477,8 +5451,12 @@ gdk_surface_set_state (GdkSurface *surface,
|
||||
* inconsistent state to the user.
|
||||
*/
|
||||
|
||||
was_mapped = GDK_SURFACE_IS_MAPPED (surface);
|
||||
|
||||
surface->state = new_state;
|
||||
|
||||
mapped = GDK_SURFACE_IS_MAPPED (surface);
|
||||
|
||||
_gdk_surface_update_viewable (surface);
|
||||
|
||||
/* We only really send the event to toplevels, since
|
||||
@@ -5490,12 +5468,15 @@ gdk_surface_set_state (GdkSurface *surface,
|
||||
{
|
||||
case GDK_SURFACE_TOPLEVEL:
|
||||
case GDK_SURFACE_TEMP: /* ? */
|
||||
g_object_notify (G_OBJECT (surface), "state");
|
||||
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_STATE]);
|
||||
break;
|
||||
case GDK_SURFACE_CHILD:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (was_mapped != mapped)
|
||||
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_MAPPED]);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -5505,3 +5486,16 @@ gdk_synthesize_surface_state (GdkSurface *surface,
|
||||
{
|
||||
gdk_surface_set_state (surface, (surface->state | set_flags) & ~unset_flags);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_surface_handle_event (GdkEvent *event)
|
||||
{
|
||||
if (gdk_event_get_event_type (event) == GDK_CONFIGURE)
|
||||
{
|
||||
g_signal_emit (gdk_event_get_surface (event), signals[SIZE_CHANGED], 0,
|
||||
event->configure.width, event->configure.height);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -460,8 +460,6 @@ void gdk_surface_show (GdkSurface *surface);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_hide (GdkSurface *surface);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_withdraw (GdkSurface *surface);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_show_unraised (GdkSurface *surface);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_move (GdkSurface *surface,
|
||||
|
||||
@@ -193,7 +193,7 @@ struct _GdkSurfaceImplClass
|
||||
gdouble opacity);
|
||||
void (* destroy_notify) (GdkSurface *surface);
|
||||
void (* register_dnd) (GdkSurface *surface);
|
||||
GdkDragContext * (*drag_begin) (GdkSurface *surface,
|
||||
GdkDrag * (*drag_begin) (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider*content,
|
||||
GdkDragAction actions,
|
||||
|
||||
+2
-2
@@ -123,7 +123,7 @@ typedef struct _GdkContentProvider GdkContentProvider;
|
||||
typedef struct _GdkCursor GdkCursor;
|
||||
typedef struct _GdkTexture GdkTexture;
|
||||
typedef struct _GdkDevice GdkDevice;
|
||||
typedef struct _GdkDragContext GdkDragContext;
|
||||
typedef struct _GdkDrag GdkDrag;
|
||||
typedef struct _GdkDrop GdkDrop;
|
||||
|
||||
typedef struct _GdkClipboard GdkClipboard;
|
||||
@@ -571,7 +571,7 @@ typedef enum
|
||||
* useful if source and destination agree on what it means.
|
||||
* @GDK_ACTION_ASK: Ask the user what to do with the data.
|
||||
*
|
||||
* Used in #GdkDragContext to indicate what the destination
|
||||
* Used in #GdkDrag to indicate what the destination
|
||||
* should do with the dropped data.
|
||||
*/
|
||||
typedef enum
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ gdk_public_sources = files([
|
||||
'gdkdevicetool.c',
|
||||
'gdkdisplay.c',
|
||||
'gdkdisplaymanager.c',
|
||||
'gdkdnd.c',
|
||||
'gdkdrag.c',
|
||||
'gdkdrawcontext.c',
|
||||
'gdkdrop.c',
|
||||
'gdkevents.c',
|
||||
@@ -65,7 +65,7 @@ gdk_public_headers = files([
|
||||
'gdkdevicetool.h',
|
||||
'gdkdisplay.h',
|
||||
'gdkdisplaymanager.h',
|
||||
'gdkdnd.h',
|
||||
'gdkdrag.h',
|
||||
'gdkdrawcontext.h',
|
||||
'gdkdrop.h',
|
||||
'gdkevents.h',
|
||||
|
||||
@@ -1113,8 +1113,6 @@ fill_key_event (GdkSurface *window,
|
||||
{
|
||||
GdkEventPrivate *priv;
|
||||
GdkQuartzDeviceManagerCore *device_manager;
|
||||
gchar buf[7];
|
||||
gunichar c = 0;
|
||||
|
||||
priv = (GdkEventPrivate *) event;
|
||||
priv->windowing_data = [nsevent retain];
|
||||
@@ -1189,44 +1187,6 @@ fill_key_event (GdkSurface *window,
|
||||
gdk_keymap_add_virtual_modifiers (gdk_display_get_keymap (_gdk_display),
|
||||
&event->key.state);
|
||||
|
||||
event->key.string = NULL;
|
||||
|
||||
/* Fill in ->string since apps depend on it, taken from the x11 backend. */
|
||||
if (event->key.keyval != GDK_KEY_VoidSymbol)
|
||||
c = gdk_keyval_to_unicode (event->key.keyval);
|
||||
|
||||
if (c)
|
||||
{
|
||||
gsize bytes_written;
|
||||
gint len;
|
||||
|
||||
len = g_unichar_to_utf8 (c, buf);
|
||||
buf[len] = '\0';
|
||||
|
||||
event->key.string = g_locale_from_utf8 (buf, len,
|
||||
NULL, &bytes_written,
|
||||
NULL);
|
||||
if (event->key.string)
|
||||
event->key.length = bytes_written;
|
||||
}
|
||||
else if (event->key.keyval == GDK_KEY_Escape)
|
||||
{
|
||||
event->key.length = 1;
|
||||
event->key.string = g_strdup ("\033");
|
||||
}
|
||||
else if (event->key.keyval == GDK_KEY_Return ||
|
||||
event->key.keyval == GDK_KEY_KP_Enter)
|
||||
{
|
||||
event->key.length = 1;
|
||||
event->key.string = g_strdup ("\r");
|
||||
}
|
||||
|
||||
if (!event->key.string)
|
||||
{
|
||||
event->key.length = 0;
|
||||
event->key.string = g_strdup ("");
|
||||
}
|
||||
|
||||
GDK_NOTE(EVENTS,
|
||||
g_message ("key %s:\t\twindow: %p key: %12s %d",
|
||||
type == GDK_KEY_PRESS ? "press" : "release",
|
||||
|
||||
@@ -52,13 +52,13 @@ static void
|
||||
gdk_wayland_clipboard_discard_offer (GdkWaylandClipboard *cb)
|
||||
{
|
||||
g_clear_pointer (&cb->offer_formats, gdk_content_formats_unref);
|
||||
g_clear_pointer (&cb->offer, (GDestroyNotify) wl_data_offer_destroy);
|
||||
g_clear_pointer (&cb->offer, wl_data_offer_destroy);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_clipboard_discard_source (GdkWaylandClipboard *cb)
|
||||
{
|
||||
g_clear_pointer (&cb->source, (GDestroyNotify) wl_data_source_destroy);
|
||||
g_clear_pointer (&cb->source, wl_data_source_destroy);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -247,12 +247,9 @@ struct _GdkWaylandSeat
|
||||
GdkClipboard *clipboard;
|
||||
GdkClipboard *primary_clipboard;
|
||||
struct wl_data_device *data_device;
|
||||
GdkDragContext *drag;
|
||||
GdkDrag *drag;
|
||||
GdkDrop *drop;
|
||||
|
||||
/* Source/dest for non-local dnd */
|
||||
GdkSurface *foreign_dnd_surface;
|
||||
|
||||
/* Some tracking on gesture events */
|
||||
guint gesture_n_fingers;
|
||||
gdouble gesture_scale;
|
||||
@@ -1090,7 +1087,7 @@ gdk_wayland_seat_discard_pending_offer (GdkWaylandSeat *seat)
|
||||
gdk_content_formats_unref (ignore);
|
||||
seat->pending_builder = NULL;
|
||||
}
|
||||
g_clear_pointer (&seat->pending_offer, (GDestroyNotify) wl_data_offer_destroy);
|
||||
g_clear_pointer (&seat->pending_offer, wl_data_offer_destroy);
|
||||
seat->pending_source_actions = 0;
|
||||
seat->pending_action = 0;
|
||||
}
|
||||
@@ -2012,73 +2009,6 @@ keyboard_handle_leave (void *data,
|
||||
|
||||
static gboolean keyboard_repeat (gpointer data);
|
||||
|
||||
static void
|
||||
translate_keyboard_string (GdkEventKey *event)
|
||||
{
|
||||
gunichar c = 0;
|
||||
gchar buf[7];
|
||||
|
||||
/* Fill in event->string crudely, since various programs
|
||||
* depend on it.
|
||||
*/
|
||||
event->string = NULL;
|
||||
|
||||
if (event->keyval != GDK_KEY_VoidSymbol)
|
||||
c = gdk_keyval_to_unicode (event->keyval);
|
||||
|
||||
if (c)
|
||||
{
|
||||
gsize bytes_written;
|
||||
gint len;
|
||||
|
||||
/* Apply the control key - Taken from Xlib */
|
||||
if (event->state & GDK_CONTROL_MASK)
|
||||
{
|
||||
if ((c >= '@' && c < '\177') || c == ' ')
|
||||
c &= 0x1F;
|
||||
else if (c == '2')
|
||||
{
|
||||
event->string = g_memdup ("\0\0", 2);
|
||||
event->length = 1;
|
||||
buf[0] = '\0';
|
||||
return;
|
||||
}
|
||||
else if (c >= '3' && c <= '7')
|
||||
c -= ('3' - '\033');
|
||||
else if (c == '8')
|
||||
c = '\177';
|
||||
else if (c == '/')
|
||||
c = '_' & 0x1F;
|
||||
}
|
||||
|
||||
len = g_unichar_to_utf8 (c, buf);
|
||||
buf[len] = '\0';
|
||||
|
||||
event->string = g_locale_from_utf8 (buf, len,
|
||||
NULL, &bytes_written,
|
||||
NULL);
|
||||
if (event->string)
|
||||
event->length = bytes_written;
|
||||
}
|
||||
else if (event->keyval == GDK_KEY_Escape)
|
||||
{
|
||||
event->length = 1;
|
||||
event->string = g_strdup ("\033");
|
||||
}
|
||||
else if (event->keyval == GDK_KEY_Return ||
|
||||
event->keyval == GDK_KEY_KP_Enter)
|
||||
{
|
||||
event->length = 1;
|
||||
event->string = g_strdup ("\r");
|
||||
}
|
||||
|
||||
if (!event->string)
|
||||
{
|
||||
event->length = 0;
|
||||
event->string = g_strdup ("");
|
||||
}
|
||||
}
|
||||
|
||||
static GSettings *
|
||||
get_keyboard_settings (GdkWaylandSeat *seat)
|
||||
{
|
||||
@@ -2194,17 +2124,15 @@ deliver_key_event (GdkWaylandSeat *seat,
|
||||
event->key.keyval = sym;
|
||||
event->key.is_modifier = _gdk_wayland_keymap_key_is_modifier (keymap, key);
|
||||
|
||||
translate_keyboard_string (&event->key);
|
||||
|
||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||
|
||||
GDK_DISPLAY_NOTE (seat->display, EVENTS,
|
||||
g_message ("keyboard %s event%s, code %d, sym %d, "
|
||||
"string %s, mods 0x%x",
|
||||
"mods 0x%x",
|
||||
(state ? "press" : "release"),
|
||||
(from_key_repeat ? " (repeat)" : ""),
|
||||
event->key.hardware_keycode, event->key.keyval,
|
||||
event->key.string, event->key.state));
|
||||
event->key.state));
|
||||
|
||||
if (!xkb_keymap_key_repeats (xkb_keymap, key))
|
||||
return;
|
||||
@@ -4516,6 +4444,12 @@ pointer_surface_update_scale (GdkDevice *device)
|
||||
gdk_wayland_device_update_surface_cursor (device);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_wayland_seat_update_cursor_scale (GdkWaylandSeat *seat)
|
||||
{
|
||||
pointer_surface_update_scale (seat->master_pointer);
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_surface_enter (void *data,
|
||||
struct wl_surface *wl_surface,
|
||||
@@ -4556,12 +4490,6 @@ static const struct wl_surface_listener pointer_surface_listener = {
|
||||
pointer_surface_leave
|
||||
};
|
||||
|
||||
static GdkSurface *
|
||||
create_foreign_dnd_surface (GdkDisplay *display)
|
||||
{
|
||||
return gdk_surface_new_popup (display, &(GdkRectangle) { 0, 0, 1, 1 });
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_pointer_data_finalize (GdkWaylandPointerData *pointer)
|
||||
{
|
||||
@@ -4596,7 +4524,6 @@ gdk_wayland_seat_finalize (GObject *object)
|
||||
g_clear_object (&seat->clipboard);
|
||||
g_clear_object (&seat->primary_clipboard);
|
||||
g_hash_table_destroy (seat->touches);
|
||||
gdk_surface_destroy (seat->foreign_dnd_surface);
|
||||
zwp_tablet_seat_v2_destroy (seat->wp_tablet_seat);
|
||||
stop_key_repeat (seat);
|
||||
|
||||
@@ -4938,7 +4865,6 @@ _gdk_wayland_display_create_seat (GdkWaylandDisplay *display_wayland,
|
||||
seat->keymap = _gdk_wayland_keymap_new (display);
|
||||
seat->display = display;
|
||||
seat->touches = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) g_free);
|
||||
seat->foreign_dnd_surface = create_foreign_dnd_surface (display);
|
||||
seat->wl_seat = wl_seat;
|
||||
|
||||
wl_seat_add_listener (seat->wl_seat, &seat_listener, seat);
|
||||
@@ -5133,12 +5059,12 @@ gdk_wayland_seat_set_global_cursor (GdkSeat *seat,
|
||||
}
|
||||
|
||||
void
|
||||
gdk_wayland_seat_set_drag (GdkSeat *seat,
|
||||
GdkDragContext *context)
|
||||
gdk_wayland_seat_set_drag (GdkSeat *seat,
|
||||
GdkDrag *drag)
|
||||
{
|
||||
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
|
||||
|
||||
g_set_object (&wayland_seat->drag, context);
|
||||
g_set_object (&wayland_seat->drag, drag);
|
||||
}
|
||||
|
||||
struct wl_data_device *
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "gdkdisplay.h"
|
||||
#include "gdkdisplay-wayland.h"
|
||||
#include "gdkmonitor-wayland.h"
|
||||
#include "gdkseat-wayland.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkkeysprivate.h"
|
||||
@@ -1883,9 +1884,20 @@ transform_to_string (int transform)
|
||||
static void
|
||||
update_scale (GdkDisplay *display)
|
||||
{
|
||||
GList *seats;
|
||||
GList *l;
|
||||
|
||||
g_list_foreach (gdk_wayland_display_get_toplevel_surfaces (display),
|
||||
(GFunc)gdk_wayland_surface_update_scale,
|
||||
NULL);
|
||||
seats = gdk_display_list_seats (display);
|
||||
for (l = seats; l; l = l->next)
|
||||
{
|
||||
GdkSeat *seat = l->data;
|
||||
|
||||
gdk_wayland_seat_update_cursor_scale (GDK_WAYLAND_SEAT (seat));
|
||||
}
|
||||
g_list_free (seats);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -1,440 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2010 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkdndprivate.h"
|
||||
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkproperty.h"
|
||||
#include "gdkprivate-wayland.h"
|
||||
#include "gdkcontentformats.h"
|
||||
#include "gdkdisplay-wayland.h"
|
||||
#include "gdkintl.h"
|
||||
#include "gdkseat-wayland.h"
|
||||
|
||||
#include "gdkdeviceprivate.h"
|
||||
|
||||
#include <glib-unix.h>
|
||||
#include <gio/gunixinputstream.h>
|
||||
#include <gio/gunixoutputstream.h>
|
||||
#include <string.h>
|
||||
|
||||
#define GDK_TYPE_WAYLAND_DRAG_CONTEXT (gdk_wayland_drag_context_get_type ())
|
||||
#define GDK_WAYLAND_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_DRAG_CONTEXT, GdkWaylandDragContext))
|
||||
#define GDK_WAYLAND_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_DRAG_CONTEXT, GdkWaylandDragContextClass))
|
||||
#define GDK_IS_WAYLAND_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DRAG_CONTEXT))
|
||||
#define GDK_IS_WAYLAND_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_DRAG_CONTEXT))
|
||||
#define GDK_WAYLAND_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_DRAG_CONTEXT, GdkWaylandDragContextClass))
|
||||
|
||||
typedef struct _GdkWaylandDragContext GdkWaylandDragContext;
|
||||
typedef struct _GdkWaylandDragContextClass GdkWaylandDragContextClass;
|
||||
|
||||
struct _GdkWaylandDragContext
|
||||
{
|
||||
GdkDragContext context;
|
||||
GdkSurface *dnd_surface;
|
||||
struct wl_surface *dnd_wl_surface;
|
||||
struct wl_data_source *data_source;
|
||||
struct wl_data_offer *offer;
|
||||
GdkDragAction selected_action;
|
||||
uint32_t serial;
|
||||
gint hot_x;
|
||||
gint hot_y;
|
||||
};
|
||||
|
||||
struct _GdkWaylandDragContextClass
|
||||
{
|
||||
GdkDragContextClass parent_class;
|
||||
};
|
||||
|
||||
static GList *contexts;
|
||||
|
||||
GType gdk_wayland_drag_context_get_type (void);
|
||||
|
||||
G_DEFINE_TYPE (GdkWaylandDragContext, gdk_wayland_drag_context, GDK_TYPE_DRAG_CONTEXT)
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_finalize (GObject *object)
|
||||
{
|
||||
GdkWaylandDragContext *wayland_context = GDK_WAYLAND_DRAG_CONTEXT (object);
|
||||
GdkDragContext *context = GDK_DRAG_CONTEXT (object);
|
||||
GdkSurface *dnd_surface;
|
||||
|
||||
contexts = g_list_remove (contexts, context);
|
||||
|
||||
gdk_drag_context_set_cursor (context, NULL);
|
||||
|
||||
g_clear_pointer (&wayland_context->data_source, (GDestroyNotify) wl_data_source_destroy);
|
||||
g_clear_pointer (&wayland_context->offer, (GDestroyNotify) wl_data_offer_destroy);
|
||||
|
||||
dnd_surface = wayland_context->dnd_surface;
|
||||
|
||||
G_OBJECT_CLASS (gdk_wayland_drag_context_parent_class)->finalize (object);
|
||||
|
||||
if (dnd_surface)
|
||||
gdk_surface_destroy (dnd_surface);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
gdk_to_wl_actions (GdkDragAction action)
|
||||
{
|
||||
uint32_t dnd_actions = 0;
|
||||
|
||||
if (action & (GDK_ACTION_COPY | GDK_ACTION_LINK))
|
||||
dnd_actions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
|
||||
if (action & GDK_ACTION_MOVE)
|
||||
dnd_actions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
|
||||
if (action & GDK_ACTION_ASK)
|
||||
dnd_actions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
|
||||
|
||||
return dnd_actions;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_drag_abort (GdkDragContext *context,
|
||||
guint32 time)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_drag_drop (GdkDragContext *context,
|
||||
guint32 time)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_init (GdkWaylandDragContext *context_wayland)
|
||||
{
|
||||
GdkDragContext *context;
|
||||
|
||||
context = GDK_DRAG_CONTEXT (context_wayland);
|
||||
contexts = g_list_prepend (contexts, context);
|
||||
|
||||
context->action = GDK_ACTION_COPY;
|
||||
}
|
||||
|
||||
static GdkSurface *
|
||||
gdk_wayland_drag_context_get_drag_surface (GdkDragContext *context)
|
||||
{
|
||||
return GDK_WAYLAND_DRAG_CONTEXT (context)->dnd_surface;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_set_hotspot (GdkDragContext *context,
|
||||
gint hot_x,
|
||||
gint hot_y)
|
||||
{
|
||||
GdkWaylandDragContext *context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context);
|
||||
gint prev_hot_x = context_wayland->hot_x;
|
||||
gint prev_hot_y = context_wayland->hot_y;
|
||||
const GdkRectangle damage_rect = { .width = 1, .height = 1 };
|
||||
|
||||
context_wayland->hot_x = hot_x;
|
||||
context_wayland->hot_y = hot_y;
|
||||
|
||||
if (prev_hot_x == hot_x && prev_hot_y == hot_y)
|
||||
return;
|
||||
|
||||
_gdk_wayland_surface_offset_next_wl_buffer (context_wayland->dnd_surface,
|
||||
-hot_x, -hot_y);
|
||||
gdk_surface_invalidate_rect (context_wayland->dnd_surface, &damage_rect);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_set_cursor (GdkDragContext *context,
|
||||
GdkCursor *cursor)
|
||||
{
|
||||
GdkDevice *device = gdk_drag_context_get_device (context);
|
||||
|
||||
gdk_wayland_seat_set_global_cursor (gdk_device_get_seat (device), cursor);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_action_changed (GdkDragContext *context,
|
||||
GdkDragAction action)
|
||||
{
|
||||
GdkCursor *cursor;
|
||||
|
||||
cursor = gdk_drag_get_cursor (context, action);
|
||||
gdk_drag_context_set_cursor (context, cursor);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_drop_performed (GdkDragContext *context,
|
||||
guint32 time_)
|
||||
{
|
||||
gdk_drag_context_set_cursor (context, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_cancel (GdkDragContext *context,
|
||||
GdkDragCancelReason reason)
|
||||
{
|
||||
gdk_drag_context_set_cursor (context, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_drop_done (GdkDragContext *context,
|
||||
gboolean success)
|
||||
{
|
||||
GdkWaylandDragContext *context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context);
|
||||
GdkDevice *device = gdk_drag_context_get_device (context);
|
||||
|
||||
gdk_wayland_seat_set_drag (gdk_device_get_seat (device), context);
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (context_wayland->dnd_surface)
|
||||
gdk_surface_hide (context_wayland->dnd_surface);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_class_init (GdkWaylandDragContextClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GdkDragContextClass *context_class = GDK_DRAG_CONTEXT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gdk_wayland_drag_context_finalize;
|
||||
|
||||
context_class->drag_abort = gdk_wayland_drag_context_drag_abort;
|
||||
context_class->drag_drop = gdk_wayland_drag_context_drag_drop;
|
||||
context_class->get_drag_surface = gdk_wayland_drag_context_get_drag_surface;
|
||||
context_class->set_hotspot = gdk_wayland_drag_context_set_hotspot;
|
||||
context_class->drop_done = gdk_wayland_drag_context_drop_done;
|
||||
context_class->set_cursor = gdk_wayland_drag_context_set_cursor;
|
||||
context_class->action_changed = gdk_wayland_drag_context_action_changed;
|
||||
context_class->drop_performed = gdk_wayland_drag_context_drop_performed;
|
||||
context_class->cancel = gdk_wayland_drag_context_cancel;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_wayland_surface_register_dnd (GdkSurface *surface)
|
||||
{
|
||||
}
|
||||
|
||||
static GdkSurface *
|
||||
create_dnd_surface (GdkDisplay *display)
|
||||
{
|
||||
GdkSurface *surface;
|
||||
|
||||
surface = gdk_surface_new_popup (display, &(GdkRectangle) { 0, 0, 100, 100 });
|
||||
|
||||
gdk_surface_set_type_hint (surface, GDK_SURFACE_TYPE_HINT_DND);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
static inline GdkDragAction
|
||||
_wl_to_gdk_actions (uint32_t dnd_actions)
|
||||
{
|
||||
GdkDragAction actions = 0;
|
||||
|
||||
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
|
||||
actions |= GDK_ACTION_COPY;
|
||||
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
|
||||
actions |= GDK_ACTION_MOVE;
|
||||
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
|
||||
actions |= GDK_ACTION_ASK;
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
static void
|
||||
data_source_target (void *data,
|
||||
struct wl_data_source *source,
|
||||
const char *mime_type)
|
||||
{
|
||||
GDK_NOTE (EVENTS,
|
||||
g_message ("data source target, source = %p, mime_type = %s",
|
||||
source, mime_type));
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_write_done (GObject *context,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!gdk_drag_context_write_finish (GDK_DRAG_CONTEXT (context), result, &error))
|
||||
{
|
||||
GDK_DISPLAY_NOTE (gdk_drag_context_get_display (GDK_DRAG_CONTEXT (context)), DND, g_message ("%p: failed to write stream: %s", context, error->message));
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
data_source_send (void *data,
|
||||
struct wl_data_source *source,
|
||||
const char *mime_type,
|
||||
int32_t fd)
|
||||
{
|
||||
GdkDragContext *context = data;
|
||||
GOutputStream *stream;
|
||||
|
||||
GDK_DISPLAY_NOTE (gdk_drag_context_get_display (context), DND, g_message ("%p: data source send request for %s on fd %d\n",
|
||||
source, mime_type, fd));
|
||||
|
||||
//mime_type = gdk_intern_mime_type (mime_type);
|
||||
mime_type = g_intern_string (mime_type);
|
||||
stream = g_unix_output_stream_new (fd, TRUE);
|
||||
|
||||
gdk_drag_context_write_async (context,
|
||||
mime_type,
|
||||
stream,
|
||||
G_PRIORITY_DEFAULT,
|
||||
NULL,
|
||||
gdk_wayland_drag_context_write_done,
|
||||
context);
|
||||
g_object_unref (stream);
|
||||
}
|
||||
|
||||
static void
|
||||
data_source_cancelled (void *data,
|
||||
struct wl_data_source *source)
|
||||
{
|
||||
GdkDragContext *context = data;
|
||||
|
||||
GDK_DISPLAY_NOTE (gdk_drag_context_get_display (context), EVENTS,
|
||||
g_message ("data source cancelled, source = %p", source));
|
||||
|
||||
gdk_drag_context_cancel (context, GDK_DRAG_CANCEL_ERROR);
|
||||
}
|
||||
|
||||
static void
|
||||
data_source_dnd_drop_performed (void *data,
|
||||
struct wl_data_source *source)
|
||||
{
|
||||
GdkDragContext *context = data;
|
||||
|
||||
g_signal_emit_by_name (context, "drop-performed");
|
||||
}
|
||||
|
||||
static void
|
||||
data_source_dnd_finished (void *data,
|
||||
struct wl_data_source *source)
|
||||
{
|
||||
GdkDragContext *context = data;
|
||||
|
||||
g_signal_emit_by_name (context, "dnd-finished");
|
||||
}
|
||||
|
||||
static void
|
||||
data_source_action (void *data,
|
||||
struct wl_data_source *source,
|
||||
uint32_t action)
|
||||
{
|
||||
GdkDragContext *context = data;
|
||||
|
||||
GDK_DISPLAY_NOTE (gdk_drag_context_get_display (context), EVENTS,
|
||||
g_message ("data source action, source = %p action=%x",
|
||||
source, action));
|
||||
|
||||
context->action = _wl_to_gdk_actions (action);
|
||||
g_signal_emit_by_name (context, "action-changed", context->action);
|
||||
}
|
||||
|
||||
static const struct wl_data_source_listener data_source_listener = {
|
||||
data_source_target,
|
||||
data_source_send,
|
||||
data_source_cancelled,
|
||||
data_source_dnd_drop_performed,
|
||||
data_source_dnd_finished,
|
||||
data_source_action,
|
||||
};
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_create_data_source (GdkDragContext *context)
|
||||
{
|
||||
GdkWaylandDragContext *context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context);
|
||||
GdkDisplay *display = gdk_drag_context_get_display (context);
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
const char *const *mimetypes;
|
||||
gsize i, n_mimetypes;
|
||||
|
||||
context_wayland->data_source = wl_data_device_manager_create_data_source (display_wayland->data_device_manager);
|
||||
wl_data_source_add_listener (context_wayland->data_source,
|
||||
&data_source_listener,
|
||||
context);
|
||||
|
||||
mimetypes = gdk_content_formats_get_mime_types (gdk_drag_context_get_formats (context), &n_mimetypes);
|
||||
for (i = 0; i < n_mimetypes; i++)
|
||||
{
|
||||
wl_data_source_offer (context_wayland->data_source, mimetypes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
GdkDragContext *
|
||||
_gdk_wayland_surface_drag_begin (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider *content,
|
||||
GdkDragAction actions,
|
||||
gint dx,
|
||||
gint dy)
|
||||
{
|
||||
GdkWaylandDragContext *context_wayland;
|
||||
GdkDragContext *context;
|
||||
GdkSeat *seat;
|
||||
GdkWaylandDisplay *display_wayland;
|
||||
|
||||
display_wayland = GDK_WAYLAND_DISPLAY (gdk_device_get_display (device));
|
||||
seat = gdk_device_get_seat (device);
|
||||
|
||||
context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT,
|
||||
"device", device,
|
||||
"content", content,
|
||||
NULL);
|
||||
context = GDK_DRAG_CONTEXT (context_wayland);
|
||||
context->source_surface = g_object_ref (surface);
|
||||
|
||||
context_wayland->dnd_surface = create_dnd_surface (gdk_surface_get_display (surface));
|
||||
context_wayland->dnd_wl_surface = gdk_wayland_surface_get_wl_surface (context_wayland->dnd_surface);
|
||||
|
||||
gdk_wayland_drag_context_create_data_source (context);
|
||||
|
||||
if (display_wayland->data_device_manager_version >=
|
||||
WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION)
|
||||
{
|
||||
wl_data_source_set_actions (context_wayland->data_source,
|
||||
gdk_to_wl_actions (actions));
|
||||
}
|
||||
|
||||
gdk_wayland_seat_set_drag (seat, context);
|
||||
|
||||
wl_data_device_start_drag (gdk_wayland_device_get_data_device (device),
|
||||
context_wayland->data_source,
|
||||
gdk_wayland_surface_get_wl_surface (surface),
|
||||
context_wayland->dnd_wl_surface,
|
||||
_gdk_wayland_display_get_serial (display_wayland));
|
||||
|
||||
gdk_seat_ungrab (seat);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_wayland_drag_context_set_source_surface (GdkDragContext *context,
|
||||
GdkSurface *surface)
|
||||
{
|
||||
if (context->source_surface)
|
||||
g_object_unref (context->source_surface);
|
||||
|
||||
context->source_surface = surface ? g_object_ref (surface) : NULL;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,409 @@
|
||||
/*
|
||||
* Copyright © 2010 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkdragprivate.h"
|
||||
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkproperty.h"
|
||||
#include "gdkprivate-wayland.h"
|
||||
#include "gdkcontentformats.h"
|
||||
#include "gdkdisplay-wayland.h"
|
||||
#include "gdkintl.h"
|
||||
#include "gdkseat-wayland.h"
|
||||
|
||||
#include "gdkdeviceprivate.h"
|
||||
|
||||
#include <glib-unix.h>
|
||||
#include <gio/gunixinputstream.h>
|
||||
#include <gio/gunixoutputstream.h>
|
||||
#include <string.h>
|
||||
|
||||
#define GDK_TYPE_WAYLAND_DRAG (gdk_wayland_drag_get_type ())
|
||||
#define GDK_WAYLAND_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_DRAG, GdkWaylandDrag))
|
||||
#define GDK_WAYLAND_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_DRAG, GdkWaylandDragClass))
|
||||
#define GDK_IS_WAYLAND_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DRAG))
|
||||
#define GDK_IS_WAYLAND_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_DRAG))
|
||||
#define GDK_WAYLAND_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_DRAG, GdkWaylandDragClass))
|
||||
|
||||
typedef struct _GdkWaylandDrag GdkWaylandDrag;
|
||||
typedef struct _GdkWaylandDragClass GdkWaylandDragClass;
|
||||
|
||||
struct _GdkWaylandDrag
|
||||
{
|
||||
GdkDrag drag;
|
||||
GdkSurface *dnd_surface;
|
||||
struct wl_surface *dnd_wl_surface;
|
||||
struct wl_data_source *data_source;
|
||||
struct wl_data_offer *offer;
|
||||
uint32_t serial;
|
||||
gint hot_x;
|
||||
gint hot_y;
|
||||
};
|
||||
|
||||
struct _GdkWaylandDragClass
|
||||
{
|
||||
GdkDragClass parent_class;
|
||||
};
|
||||
|
||||
static GList *drags;
|
||||
|
||||
GType gdk_wayland_drag_get_type (void);
|
||||
|
||||
G_DEFINE_TYPE (GdkWaylandDrag, gdk_wayland_drag, GDK_TYPE_DRAG)
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_finalize (GObject *object)
|
||||
{
|
||||
GdkWaylandDrag *wayland_drag = GDK_WAYLAND_DRAG (object);
|
||||
GdkDrag *drag = GDK_DRAG (object);
|
||||
GdkSurface *dnd_surface;
|
||||
|
||||
drags = g_list_remove (drags, drag);
|
||||
|
||||
gdk_drag_set_cursor (drag, NULL);
|
||||
|
||||
g_clear_pointer (&wayland_drag->data_source, wl_data_source_destroy);
|
||||
g_clear_pointer (&wayland_drag->offer, wl_data_offer_destroy);
|
||||
|
||||
dnd_surface = wayland_drag->dnd_surface;
|
||||
|
||||
G_OBJECT_CLASS (gdk_wayland_drag_parent_class)->finalize (object);
|
||||
|
||||
if (dnd_surface)
|
||||
gdk_surface_destroy (dnd_surface);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
gdk_to_wl_actions (GdkDragAction action)
|
||||
{
|
||||
uint32_t dnd_actions = 0;
|
||||
|
||||
if (action & (GDK_ACTION_COPY | GDK_ACTION_LINK))
|
||||
dnd_actions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
|
||||
if (action & GDK_ACTION_MOVE)
|
||||
dnd_actions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
|
||||
if (action & GDK_ACTION_ASK)
|
||||
dnd_actions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
|
||||
|
||||
return dnd_actions;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_init (GdkWaylandDrag *drag_wayland)
|
||||
{
|
||||
GdkDrag *drag;
|
||||
|
||||
drag = GDK_DRAG (drag_wayland);
|
||||
drags = g_list_prepend (drags, drag);
|
||||
|
||||
gdk_drag_set_selected_action (drag, GDK_ACTION_COPY);
|
||||
}
|
||||
|
||||
static GdkSurface *
|
||||
gdk_wayland_drag_get_drag_surface (GdkDrag *drag)
|
||||
{
|
||||
return GDK_WAYLAND_DRAG (drag)->dnd_surface;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_set_hotspot (GdkDrag *drag,
|
||||
gint hot_x,
|
||||
gint hot_y)
|
||||
{
|
||||
GdkWaylandDrag *drag_wayland = GDK_WAYLAND_DRAG (drag);
|
||||
gint prev_hot_x = drag_wayland->hot_x;
|
||||
gint prev_hot_y = drag_wayland->hot_y;
|
||||
const GdkRectangle damage_rect = { .width = 1, .height = 1 };
|
||||
|
||||
drag_wayland->hot_x = hot_x;
|
||||
drag_wayland->hot_y = hot_y;
|
||||
|
||||
if (prev_hot_x == hot_x && prev_hot_y == hot_y)
|
||||
return;
|
||||
|
||||
_gdk_wayland_surface_offset_next_wl_buffer (drag_wayland->dnd_surface,
|
||||
-hot_x, -hot_y);
|
||||
gdk_surface_invalidate_rect (drag_wayland->dnd_surface, &damage_rect);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_set_cursor (GdkDrag *drag,
|
||||
GdkCursor *cursor)
|
||||
{
|
||||
GdkDevice *device = gdk_drag_get_device (drag);
|
||||
|
||||
if (device != NULL)
|
||||
gdk_wayland_seat_set_global_cursor (gdk_device_get_seat (device), cursor);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_drop_performed (GdkDrag *drag,
|
||||
guint32 time_)
|
||||
{
|
||||
gdk_drag_set_cursor (drag, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_cancel (GdkDrag *drag,
|
||||
GdkDragCancelReason reason)
|
||||
{
|
||||
gdk_drag_set_cursor (drag, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_drop_done (GdkDrag *drag,
|
||||
gboolean success)
|
||||
{
|
||||
GdkWaylandDrag *drag_wayland = GDK_WAYLAND_DRAG (drag);
|
||||
GdkDevice *device = gdk_drag_get_device (drag);
|
||||
|
||||
gdk_wayland_seat_set_drag (gdk_device_get_seat (device), drag);
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (drag_wayland->dnd_surface)
|
||||
gdk_surface_hide (drag_wayland->dnd_surface);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_class_init (GdkWaylandDragClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GdkDragClass *drag_class = GDK_DRAG_CLASS (klass);
|
||||
|
||||
object_class->finalize = gdk_wayland_drag_finalize;
|
||||
|
||||
drag_class->get_drag_surface = gdk_wayland_drag_get_drag_surface;
|
||||
drag_class->set_hotspot = gdk_wayland_drag_set_hotspot;
|
||||
drag_class->drop_done = gdk_wayland_drag_drop_done;
|
||||
drag_class->set_cursor = gdk_wayland_drag_set_cursor;
|
||||
drag_class->drop_performed = gdk_wayland_drag_drop_performed;
|
||||
drag_class->cancel = gdk_wayland_drag_cancel;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_wayland_surface_register_dnd (GdkSurface *surface)
|
||||
{
|
||||
}
|
||||
|
||||
static GdkSurface *
|
||||
create_dnd_surface (GdkDisplay *display)
|
||||
{
|
||||
GdkSurface *surface;
|
||||
|
||||
surface = gdk_surface_new_popup (display, &(GdkRectangle) { 0, 0, 100, 100 });
|
||||
|
||||
gdk_surface_set_type_hint (surface, GDK_SURFACE_TYPE_HINT_DND);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
static inline GdkDragAction
|
||||
_wl_to_gdk_actions (uint32_t dnd_actions)
|
||||
{
|
||||
GdkDragAction actions = 0;
|
||||
|
||||
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
|
||||
actions |= GDK_ACTION_COPY;
|
||||
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
|
||||
actions |= GDK_ACTION_MOVE;
|
||||
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
|
||||
actions |= GDK_ACTION_ASK;
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
static void
|
||||
data_source_target (void *data,
|
||||
struct wl_data_source *source,
|
||||
const char *mime_type)
|
||||
{
|
||||
GDK_NOTE (EVENTS,
|
||||
g_message ("data source target, source = %p, mime_type = %s",
|
||||
source, mime_type));
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_write_done (GObject *drag,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!gdk_drag_write_finish (GDK_DRAG (drag), result, &error))
|
||||
{
|
||||
GDK_DISPLAY_NOTE (gdk_drag_get_display (GDK_DRAG (drag)), DND, g_message ("%p: failed to write stream: %s", drag, error->message));
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
data_source_send (void *data,
|
||||
struct wl_data_source *source,
|
||||
const char *mime_type,
|
||||
int32_t fd)
|
||||
{
|
||||
GdkDrag *drag = data;
|
||||
GOutputStream *stream;
|
||||
|
||||
GDK_DISPLAY_NOTE (gdk_drag_get_display (drag), DND, g_message ("%p: data source send request for %s on fd %d\n",
|
||||
source, mime_type, fd));
|
||||
|
||||
//mime_type = gdk_intern_mime_type (mime_type);
|
||||
mime_type = g_intern_string (mime_type);
|
||||
stream = g_unix_output_stream_new (fd, TRUE);
|
||||
|
||||
gdk_drag_write_async (drag,
|
||||
mime_type,
|
||||
stream,
|
||||
G_PRIORITY_DEFAULT,
|
||||
NULL,
|
||||
gdk_wayland_drag_write_done,
|
||||
drag);
|
||||
g_object_unref (stream);
|
||||
}
|
||||
|
||||
static void
|
||||
data_source_cancelled (void *data,
|
||||
struct wl_data_source *source)
|
||||
{
|
||||
GdkDrag *drag = data;
|
||||
|
||||
GDK_DISPLAY_NOTE (gdk_drag_get_display (drag), EVENTS,
|
||||
g_message ("data source cancelled, source = %p", source));
|
||||
|
||||
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_ERROR);
|
||||
}
|
||||
|
||||
static void
|
||||
data_source_dnd_drop_performed (void *data,
|
||||
struct wl_data_source *source)
|
||||
{
|
||||
GdkDrag *drag = data;
|
||||
|
||||
g_signal_emit_by_name (drag, "drop-performed");
|
||||
}
|
||||
|
||||
static void
|
||||
data_source_dnd_finished (void *data,
|
||||
struct wl_data_source *source)
|
||||
{
|
||||
GdkDrag *drag = data;
|
||||
|
||||
g_signal_emit_by_name (drag, "dnd-finished");
|
||||
}
|
||||
|
||||
static void
|
||||
data_source_action (void *data,
|
||||
struct wl_data_source *source,
|
||||
uint32_t action)
|
||||
{
|
||||
GdkDrag *drag = data;
|
||||
|
||||
GDK_DISPLAY_NOTE (gdk_drag_get_display (drag), EVENTS,
|
||||
g_message ("data source action, source = %p action=%x",
|
||||
source, action));
|
||||
|
||||
gdk_drag_set_selected_action (drag, _wl_to_gdk_actions (action));
|
||||
}
|
||||
|
||||
static const struct wl_data_source_listener data_source_listener = {
|
||||
data_source_target,
|
||||
data_source_send,
|
||||
data_source_cancelled,
|
||||
data_source_dnd_drop_performed,
|
||||
data_source_dnd_finished,
|
||||
data_source_action,
|
||||
};
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_create_data_source (GdkDrag *drag)
|
||||
{
|
||||
GdkWaylandDrag *drag_wayland = GDK_WAYLAND_DRAG (drag);
|
||||
GdkDisplay *display = gdk_drag_get_display (drag);
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
const char *const *mimetypes;
|
||||
gsize i, n_mimetypes;
|
||||
|
||||
drag_wayland->data_source = wl_data_device_manager_create_data_source (display_wayland->data_device_manager);
|
||||
wl_data_source_add_listener (drag_wayland->data_source,
|
||||
&data_source_listener,
|
||||
drag);
|
||||
|
||||
mimetypes = gdk_content_formats_get_mime_types (gdk_drag_get_formats (drag), &n_mimetypes);
|
||||
for (i = 0; i < n_mimetypes; i++)
|
||||
{
|
||||
wl_data_source_offer (drag_wayland->data_source, mimetypes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
GdkDrag *
|
||||
_gdk_wayland_surface_drag_begin (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider *content,
|
||||
GdkDragAction actions,
|
||||
gint dx,
|
||||
gint dy)
|
||||
{
|
||||
GdkWaylandDrag *drag_wayland;
|
||||
GdkDrag *drag;
|
||||
GdkSeat *seat;
|
||||
GdkWaylandDisplay *display_wayland;
|
||||
GdkCursor *cursor;
|
||||
|
||||
display_wayland = GDK_WAYLAND_DISPLAY (gdk_device_get_display (device));
|
||||
seat = gdk_device_get_seat (device);
|
||||
|
||||
drag_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG,
|
||||
"surface", surface,
|
||||
"device", device,
|
||||
"content", content,
|
||||
"actions", actions,
|
||||
NULL);
|
||||
|
||||
drag = GDK_DRAG (drag_wayland);
|
||||
|
||||
drag_wayland->dnd_surface = create_dnd_surface (gdk_surface_get_display (surface));
|
||||
drag_wayland->dnd_wl_surface = gdk_wayland_surface_get_wl_surface (drag_wayland->dnd_surface);
|
||||
|
||||
gdk_wayland_drag_create_data_source (drag);
|
||||
|
||||
if (display_wayland->data_device_manager_version >=
|
||||
WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION)
|
||||
{
|
||||
wl_data_source_set_actions (drag_wayland->data_source,
|
||||
gdk_to_wl_actions (actions));
|
||||
}
|
||||
|
||||
gdk_wayland_seat_set_drag (seat, drag);
|
||||
|
||||
wl_data_device_start_drag (gdk_wayland_device_get_data_device (device),
|
||||
drag_wayland->data_source,
|
||||
gdk_wayland_surface_get_wl_surface (surface),
|
||||
drag_wayland->dnd_wl_surface,
|
||||
_gdk_wayland_display_get_serial (display_wayland));
|
||||
|
||||
cursor = gdk_drag_get_cursor (drag, gdk_drag_get_selected_action (drag));
|
||||
gdk_drag_set_cursor (drag, cursor);
|
||||
|
||||
gdk_seat_ungrab (seat);
|
||||
|
||||
return drag;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ gdk_wayland_drop_finalize (GObject *object)
|
||||
{
|
||||
GdkWaylandDrop *wayland_drop = GDK_WAYLAND_DROP (object);
|
||||
|
||||
g_clear_pointer (&wayland_drop->offer, (GDestroyNotify) wl_data_offer_destroy);
|
||||
g_clear_pointer (&wayland_drop->offer, wl_data_offer_destroy);
|
||||
|
||||
G_OBJECT_CLASS (gdk_wayland_drop_parent_class)->finalize (object);
|
||||
}
|
||||
@@ -261,7 +261,7 @@ gdk_wayland_drop_init (GdkWaylandDrop *drop)
|
||||
|
||||
GdkDrop *
|
||||
gdk_wayland_drop_new (GdkDevice *device,
|
||||
GdkDragContext *drag,
|
||||
GdkDrag *drag,
|
||||
GdkContentFormats *formats,
|
||||
GdkSurface *surface,
|
||||
struct wl_data_offer *offer,
|
||||
|
||||
@@ -62,20 +62,20 @@ gdk_wayland_primary_discard_pending (GdkWaylandPrimary *cb)
|
||||
gdk_content_formats_unref (ignore);
|
||||
cb->pending_builder = NULL;
|
||||
}
|
||||
g_clear_pointer (&cb->pending, (GDestroyNotify) gtk_primary_selection_offer_destroy);
|
||||
g_clear_pointer (&cb->pending, gtk_primary_selection_offer_destroy);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_primary_discard_offer (GdkWaylandPrimary *cb)
|
||||
{
|
||||
g_clear_pointer (&cb->offer_formats, gdk_content_formats_unref);
|
||||
g_clear_pointer (&cb->offer, (GDestroyNotify) gtk_primary_selection_offer_destroy);
|
||||
g_clear_pointer (&cb->offer, gtk_primary_selection_offer_destroy);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_primary_discard_source (GdkWaylandPrimary *cb)
|
||||
{
|
||||
g_clear_pointer (&cb->source, (GDestroyNotify) wl_data_source_destroy);
|
||||
g_clear_pointer (&cb->source, gtk_primary_selection_source_destroy);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -95,7 +95,7 @@ void gdk_wayland_surface_attach_image (GdkSurface
|
||||
const cairo_region_t *damage);
|
||||
|
||||
void _gdk_wayland_surface_register_dnd (GdkSurface *surface);
|
||||
GdkDragContext *_gdk_wayland_surface_drag_begin (GdkSurface *surface,
|
||||
GdkDrag *_gdk_wayland_surface_drag_begin (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider *content,
|
||||
GdkDragAction actions,
|
||||
@@ -105,7 +105,7 @@ void _gdk_wayland_surface_offset_next_wl_buffer (GdkSurface *surface,
|
||||
int x,
|
||||
int y);
|
||||
GdkDrop * gdk_wayland_drop_new (GdkDevice *device,
|
||||
GdkDragContext *drag,
|
||||
GdkDrag *drag,
|
||||
GdkContentFormats *formats,
|
||||
GdkSurface *surface,
|
||||
struct wl_data_offer *offer,
|
||||
@@ -115,13 +115,10 @@ void gdk_wayland_drop_set_source_actions (GdkDrop
|
||||
void gdk_wayland_drop_set_action (GdkDrop *drop,
|
||||
uint32_t action);
|
||||
|
||||
void _gdk_wayland_drag_context_set_source_surface (GdkDragContext *context,
|
||||
GdkSurface *surface);
|
||||
|
||||
void _gdk_wayland_display_create_surface_impl (GdkDisplay *display,
|
||||
GdkSurface *surface,
|
||||
GdkSurface *real_parent,
|
||||
GdkSurfaceAttr *attributes);
|
||||
void _gdk_wayland_display_create_surface_impl (GdkDisplay *display,
|
||||
GdkSurface *surface,
|
||||
GdkSurface *real_parent,
|
||||
GdkSurfaceAttr *attributes);
|
||||
|
||||
gint _gdk_wayland_display_text_property_to_utf8_list (GdkDisplay *display,
|
||||
GdkAtom encoding,
|
||||
@@ -147,7 +144,7 @@ struct wl_data_device * gdk_wayland_device_get_data_device (GdkDevice *gdk_devic
|
||||
void gdk_wayland_device_set_selection (GdkDevice *gdk_device,
|
||||
struct wl_data_source *source);
|
||||
|
||||
GdkDragContext * gdk_wayland_device_get_drop_context (GdkDevice *gdk_device);
|
||||
GdkDrag* gdk_wayland_device_get_drop_context (GdkDevice *gdk_device);
|
||||
|
||||
void gdk_wayland_device_unset_touch_grab (GdkDevice *device,
|
||||
GdkEventSequence *sequence);
|
||||
@@ -193,7 +190,7 @@ struct gtk_surface1 * gdk_wayland_surface_get_gtk_surface (GdkSurface *surface);
|
||||
void gdk_wayland_seat_set_global_cursor (GdkSeat *seat,
|
||||
GdkCursor *cursor);
|
||||
void gdk_wayland_seat_set_drag (GdkSeat *seat,
|
||||
GdkDragContext *drag);
|
||||
GdkDrag *drag);
|
||||
|
||||
struct wl_output *gdk_wayland_surface_get_wl_output (GdkSurface *surface);
|
||||
|
||||
|
||||
@@ -41,4 +41,6 @@ struct _GdkWaylandSeatClass
|
||||
|
||||
GType gdk_wayland_seat_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void gdk_wayland_seat_update_cursor_scale (GdkWaylandSeat *seat);
|
||||
|
||||
#endif /* __GDK_WAYLAND_SEAT_H__ */
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "gdkprivate-wayland.h"
|
||||
#include "gdkdisplay-wayland.h"
|
||||
#include "gdkcontentformatsprivate.h"
|
||||
#include "gdkdndprivate.h"
|
||||
#include "gdkproperty.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -2639,8 +2639,6 @@ gdk_wayland_surface_show (GdkSurface *surface,
|
||||
gdk_wayland_surface_create_surface (surface);
|
||||
|
||||
gdk_wayland_surface_map (surface);
|
||||
|
||||
_gdk_make_event (surface, GDK_MAP, NULL, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -5,7 +5,7 @@ gdk_wayland_sources = files([
|
||||
'gdkcursor-wayland.c',
|
||||
'gdkdevice-wayland.c',
|
||||
'gdkdisplay-wayland.c',
|
||||
'gdkdnd-wayland.c',
|
||||
'gdkdrag-wayland.c',
|
||||
'gdkdrop-wayland.c',
|
||||
'gdkeventsource.c',
|
||||
'gdkglcontext-wayland.c',
|
||||
|
||||
@@ -280,7 +280,7 @@ Otherwise it's similar to how the clipboard works. Only the DnD server
|
||||
#include "gdkclipboard-win32.h"
|
||||
#include "gdkclipdrop-win32.h"
|
||||
#include "gdkhdataoutputstream-win32.h"
|
||||
#include "gdk/gdkdndprivate.h"
|
||||
#include "gdk/gdkdragprivate.h"
|
||||
#include "gdkwin32dnd.h"
|
||||
#include "gdkwin32dnd-private.h"
|
||||
#include "gdkwin32.h"
|
||||
|
||||
+183
-221
@@ -130,7 +130,7 @@
|
||||
* From that point forward the context gets any events emitted
|
||||
* by GDK, and can prevent these events from going anywhere else.
|
||||
* They are all handled in
|
||||
* S: gdk_drag_context_handle_source_event() -> backend:handle_event()
|
||||
* S: gdk_drag_handle_source_event() -> backend:handle_event()
|
||||
* (except for wayland backend - it doesn't have that function).
|
||||
*
|
||||
* That function catches the following events:
|
||||
@@ -195,14 +195,14 @@
|
||||
/* For C-style COM wrapper macros */
|
||||
#define COBJMACROS
|
||||
|
||||
#include "gdkdnd.h"
|
||||
#include "gdkdrag.h"
|
||||
#include "gdkproperty.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkprivate-win32.h"
|
||||
#include "gdkwin32.h"
|
||||
#include "gdkwin32dnd.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdk/gdkdndprivate.h"
|
||||
#include "gdk/gdkdragprivate.h"
|
||||
#include "gdkwin32dnd-private.h"
|
||||
#include "gdkdisplay-win32.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
@@ -226,12 +226,12 @@ typedef struct
|
||||
IDropSource ids;
|
||||
IDropSourceNotify idsn;
|
||||
gint ref_count;
|
||||
GdkDragContext *drag;
|
||||
GdkDrag *drag;
|
||||
|
||||
/* These are thread-local
|
||||
* copies of the similar fields from GdkWin32DragContext
|
||||
* copies of the similar fields from GdkWin32Drag
|
||||
*/
|
||||
GdkWin32DragContextUtilityData util_data;
|
||||
GdkWin32DragUtilityData util_data;
|
||||
|
||||
/* Cached here, so that we don't have to look in
|
||||
* the context every time.
|
||||
@@ -249,7 +249,7 @@ typedef struct
|
||||
typedef struct {
|
||||
IDataObject ido;
|
||||
int ref_count;
|
||||
GdkDragContext *drag;
|
||||
GdkDrag *drag;
|
||||
GArray *formats;
|
||||
} data_object;
|
||||
|
||||
@@ -342,8 +342,8 @@ struct _GdkWin32DnDThreadUpdateDragState
|
||||
{
|
||||
GdkWin32DnDThreadQueueItem base;
|
||||
|
||||
gpointer opaque_ddd;
|
||||
GdkWin32DragContextUtilityData produced_util_data;
|
||||
gpointer opaque_ddd;
|
||||
GdkWin32DragUtilityData produced_util_data;
|
||||
};
|
||||
|
||||
typedef struct _GdkWin32DnDThread GdkWin32DnDThread;
|
||||
@@ -485,10 +485,10 @@ process_dnd_queue (gboolean timed,
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_local_drag_context_drop_response (GdkDragContext *drag,
|
||||
GdkDragAction action)
|
||||
_gdk_win32_local_drag_drop_response (GdkDrag *drag,
|
||||
GdkDragAction action)
|
||||
{
|
||||
GDK_NOTE (DND, g_print ("_gdk_win32_local_drag_context_drop_response: 0x%p\n",
|
||||
GDK_NOTE (DND, g_print ("_gdk_win32_local_drag_drop_response: 0x%p\n",
|
||||
drag));
|
||||
|
||||
g_signal_emit_by_name (drag, "dnd-finished");
|
||||
@@ -500,8 +500,8 @@ do_drag_drop_response (gpointer user_data)
|
||||
{
|
||||
GdkWin32DnDThreadDoDragDrop *ddd = (GdkWin32DnDThreadDoDragDrop *) user_data;
|
||||
HRESULT hr = ddd->received_result;
|
||||
GdkDragContext *drag = GDK_DRAG_CONTEXT (ddd->base.opaque_context);
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkDrag *drag = GDK_DRAG (ddd->base.opaque_context);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
|
||||
gpointer table_value = g_hash_table_lookup (clipdrop->active_source_drags, drag);
|
||||
|
||||
@@ -560,7 +560,7 @@ received_drag_context_data (GObject *drag,
|
||||
GdkWin32DnDThreadGetData *getdata = (GdkWin32DnDThreadGetData *) user_data;
|
||||
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
|
||||
|
||||
if (!gdk_drag_context_write_finish (GDK_DRAG_CONTEXT (drag), result, &error))
|
||||
if (!gdk_drag_write_finish (GDK_DRAG (drag), result, &error))
|
||||
{
|
||||
HANDLE handle;
|
||||
gboolean is_hdata;
|
||||
@@ -593,7 +593,7 @@ get_data_response (gpointer user_data)
|
||||
{
|
||||
GdkWin32DnDThreadGetData *getdata = (GdkWin32DnDThreadGetData *) user_data;
|
||||
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
|
||||
GdkDragContext *drag = GDK_DRAG_CONTEXT (getdata->base.opaque_context);
|
||||
GdkDrag *drag = GDK_DRAG (getdata->base.opaque_context);
|
||||
gpointer ddd = g_hash_table_lookup (clipdrop->active_source_drags, drag);
|
||||
|
||||
GDK_NOTE (DND, g_print ("idataobject_getdata will request target 0x%p (%s)",
|
||||
@@ -610,7 +610,7 @@ get_data_response (gpointer user_data)
|
||||
if (stream)
|
||||
{
|
||||
getdata->stream = GDK_WIN32_HDATA_OUTPUT_STREAM (stream);
|
||||
gdk_drag_context_write_async (drag,
|
||||
gdk_drag_write_async (drag,
|
||||
getdata->pair.contentformat,
|
||||
stream,
|
||||
G_PRIORITY_DEFAULT,
|
||||
@@ -721,16 +721,16 @@ typedef enum {
|
||||
|
||||
static gboolean use_ole2_dnd = TRUE;
|
||||
|
||||
static gboolean drag_context_grab (GdkDragContext *drag);
|
||||
static gboolean drag_context_grab (GdkDrag *drag);
|
||||
|
||||
G_DEFINE_TYPE (GdkWin32DragContext, gdk_win32_drag_context, GDK_TYPE_DRAG_CONTEXT)
|
||||
G_DEFINE_TYPE (GdkWin32Drag, gdk_win32_drag, GDK_TYPE_DRAG)
|
||||
|
||||
static void
|
||||
move_drag_surface (GdkDragContext *drag,
|
||||
guint x_root,
|
||||
guint y_root)
|
||||
move_drag_surface (GdkDrag *drag,
|
||||
guint x_root,
|
||||
guint y_root)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
g_assert (_win32_main_thread == NULL ||
|
||||
_win32_main_thread == g_thread_self ());
|
||||
@@ -742,7 +742,7 @@ move_drag_surface (GdkDragContext *drag,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_win32_drag_context_init (GdkWin32DragContext *drag)
|
||||
gdk_win32_drag_init (GdkWin32Drag *drag)
|
||||
{
|
||||
g_assert (_win32_main_thread == NULL ||
|
||||
_win32_main_thread == g_thread_self ());
|
||||
@@ -750,32 +750,32 @@ gdk_win32_drag_context_init (GdkWin32DragContext *drag)
|
||||
drag->handle_events = TRUE;
|
||||
drag->dest_window = INVALID_HANDLE_VALUE;
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_init %p\n", drag));
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_init %p\n", drag));
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_win32_drag_context_finalize (GObject *object)
|
||||
gdk_win32_drag_finalize (GObject *object)
|
||||
{
|
||||
GdkDragContext *drag;
|
||||
GdkWin32DragContext *drag_win32;
|
||||
GdkDrag *drag;
|
||||
GdkWin32Drag *drag_win32;
|
||||
GdkSurface *drag_surface;
|
||||
|
||||
g_assert (_win32_main_thread == NULL ||
|
||||
_win32_main_thread == g_thread_self ());
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_finalize %p\n", object));
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_finalize %p\n", object));
|
||||
|
||||
g_return_if_fail (GDK_IS_WIN32_DRAG_CONTEXT (object));
|
||||
g_return_if_fail (GDK_IS_WIN32_DRAG (object));
|
||||
|
||||
drag = GDK_DRAG_CONTEXT (object);
|
||||
drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
drag = GDK_DRAG (object);
|
||||
drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
gdk_drag_context_set_cursor (drag, NULL);
|
||||
gdk_drag_set_cursor (drag, NULL);
|
||||
|
||||
g_set_object (&drag_win32->grab_surface, NULL);
|
||||
drag_surface = drag_win32->drag_surface;
|
||||
|
||||
G_OBJECT_CLASS (gdk_win32_drag_context_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (gdk_win32_drag_parent_class)->finalize (object);
|
||||
|
||||
if (drag_surface)
|
||||
gdk_surface_destroy (drag_surface);
|
||||
@@ -783,30 +783,32 @@ gdk_win32_drag_context_finalize (GObject *object)
|
||||
|
||||
/* Drag Contexts */
|
||||
|
||||
static GdkDragContext *
|
||||
gdk_drag_context_new (GdkDisplay *display,
|
||||
GdkContentProvider *content,
|
||||
GdkDragAction actions,
|
||||
GdkDevice *device,
|
||||
GdkDragProtocol protocol)
|
||||
static GdkDrag *
|
||||
gdk_drag_new (GdkDisplay *display,
|
||||
GdkSurface *surface,
|
||||
GdkContentProvider *content,
|
||||
GdkDragAction actions,
|
||||
GdkDevice *device,
|
||||
GdkDragProtocol protocol)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32;
|
||||
GdkWin32Drag *drag_win32;
|
||||
GdkWin32Display *win32_display = GDK_WIN32_DISPLAY (display);
|
||||
GdkDragContext *drag;
|
||||
GdkDrag *drag;
|
||||
|
||||
drag_win32 = g_object_new (GDK_TYPE_WIN32_DRAG_CONTEXT,
|
||||
"device", device,
|
||||
"content", content,
|
||||
NULL);
|
||||
drag_win32 = g_object_new (GDK_TYPE_WIN32_DRAG,
|
||||
"device", device,
|
||||
"content", content,
|
||||
"surface", surface,
|
||||
"actions", actions,
|
||||
NULL);
|
||||
|
||||
drag = GDK_DRAG_CONTEXT (drag_win32);
|
||||
drag = GDK_DRAG (drag_win32);
|
||||
|
||||
if (win32_display->has_fixed_scale)
|
||||
drag_win32->scale = win32_display->surface_scale;
|
||||
else
|
||||
drag_win32->scale = _gdk_win32_display_get_monitor_scale_factor (win32_display, NULL, NULL, NULL);
|
||||
|
||||
gdk_drag_context_set_actions (drag, actions, actions);
|
||||
drag_win32->protocol = protocol;
|
||||
|
||||
return drag;
|
||||
@@ -828,15 +830,15 @@ gdk_drag_context_new (GdkDisplay *display,
|
||||
|
||||
static enum_formats *enum_formats_new (GArray *formats);
|
||||
|
||||
/* Finds a GdkDragContext object that corresponds to a DnD operation
|
||||
/* Finds a GdkDrag object that corresponds to a DnD operation
|
||||
* which is currently targetting the dest_window
|
||||
* Does not give a reference.
|
||||
*/
|
||||
GdkDragContext *
|
||||
GdkDrag *
|
||||
_gdk_win32_find_drag_for_dest_window (HWND dest_window)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
GdkWin32DragContext *drag_win32;
|
||||
GdkWin32Drag *drag_win32;
|
||||
GdkWin32DnDThreadDoDragDrop *ddd;
|
||||
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
|
||||
|
||||
@@ -844,7 +846,7 @@ _gdk_win32_find_drag_for_dest_window (HWND dest_window)
|
||||
|
||||
while (g_hash_table_iter_next (&iter, (gpointer *) &drag_win32, (gpointer *) &ddd))
|
||||
if (ddd->src_context->dest_window_handle == dest_window)
|
||||
return GDK_DRAG_CONTEXT (drag_win32);
|
||||
return GDK_DRAG (drag_win32);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -888,7 +890,7 @@ static gboolean
|
||||
notify_dnd_enter (gpointer user_data)
|
||||
{
|
||||
GdkWin32DnDEnterLeaveNotify *notify = (GdkWin32DnDEnterLeaveNotify *) user_data;
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (notify->opaque_context);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (notify->opaque_context);
|
||||
|
||||
drag_win32->dest_window = notify->target_window_handle;
|
||||
|
||||
@@ -901,7 +903,7 @@ static gboolean
|
||||
notify_dnd_leave (gpointer user_data)
|
||||
{
|
||||
GdkWin32DnDEnterLeaveNotify *notify = (GdkWin32DnDEnterLeaveNotify *) user_data;
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (notify->opaque_context);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (notify->opaque_context);
|
||||
|
||||
if (notify->target_window_handle != drag_win32->dest_window)
|
||||
g_warning ("DnD leave says that the window handle is 0x%p, but drag has 0x%p", notify->target_window_handle, drag_win32->dest_window);
|
||||
@@ -998,7 +1000,7 @@ idropsource_queryinterface (LPDROPSOURCE This,
|
||||
static gboolean
|
||||
unref_context_in_main_thread (gpointer opaque_context)
|
||||
{
|
||||
GdkDragContext *drag = GDK_DRAG_CONTEXT (opaque_context);
|
||||
GdkDrag *drag = GDK_DRAG (opaque_context);
|
||||
|
||||
g_clear_object (&drag);
|
||||
|
||||
@@ -1066,21 +1068,21 @@ idropsource_querycontinuedrag (LPDROPSOURCE This,
|
||||
}
|
||||
|
||||
static void
|
||||
maybe_emit_action_changed (GdkWin32DragContext *drag_win32,
|
||||
maybe_emit_action_changed (GdkWin32Drag *drag_win32,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
if (actions != drag_win32->current_action)
|
||||
{
|
||||
drag_win32->current_action = actions;
|
||||
g_signal_emit_by_name (GDK_DRAG_CONTEXT (drag_win32), "action-changed", actions);
|
||||
gdk_drag_set_selected_action (GDK_DRAG (drag_win32), actions);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_local_drag_give_feedback (GdkDragContext *drag,
|
||||
_gdk_win32_local_drag_give_feedback (GdkDrag *drag,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
if (drag_win32->drag_status == GDK_DRAG_STATUS_MOTION_WAIT)
|
||||
drag_win32->drag_status = GDK_DRAG_STATUS_DRAG;
|
||||
@@ -1088,7 +1090,6 @@ _gdk_win32_local_drag_give_feedback (GdkDragContext *drag,
|
||||
GDK_NOTE (DND, g_print ("_gdk_win32_local_drag_give_feedback: 0x%p\n",
|
||||
drag));
|
||||
|
||||
drag->action = actions;
|
||||
maybe_emit_action_changed (drag_win32, actions);
|
||||
}
|
||||
|
||||
@@ -1101,14 +1102,13 @@ give_feedback (gpointer user_data)
|
||||
|
||||
if (ddd)
|
||||
{
|
||||
GdkDragContext *drag = GDK_DRAG_CONTEXT (feedback->base.opaque_context);
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkDrag *drag = GDK_DRAG (feedback->base.opaque_context);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_dnd_handle_drag_status: 0x%p\n",
|
||||
drag));
|
||||
|
||||
drag->action = action_for_drop_effect (feedback->received_drop_effect);
|
||||
maybe_emit_action_changed (drag_win32, drag->action);
|
||||
maybe_emit_action_changed (drag_win32, action_for_drop_effect (feedback->received_drop_effect));
|
||||
}
|
||||
|
||||
free_queue_item (&feedback->base);
|
||||
@@ -1587,31 +1587,36 @@ static IEnumFORMATETCVtbl ief_vtbl = {
|
||||
};
|
||||
|
||||
static source_drag_context *
|
||||
source_context_new (GdkDragContext *drag,
|
||||
source_context_new (GdkDrag *drag,
|
||||
GdkContentFormats *formats)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32;
|
||||
GdkWin32Drag *drag_win32;
|
||||
source_drag_context *result;
|
||||
GdkSurface *surface;
|
||||
|
||||
drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
g_object_get (drag, "surface", &surface, NULL);
|
||||
|
||||
result = g_new0 (source_drag_context, 1);
|
||||
result->drag = g_object_ref (drag);
|
||||
result->ids.lpVtbl = &ids_vtbl;
|
||||
result->idsn.lpVtbl = &idsn_vtbl;
|
||||
result->ref_count = 1;
|
||||
result->source_window_handle = GDK_SURFACE_HWND (drag->source_surface);
|
||||
result->source_window_handle = GDK_SURFACE_HWND (surface);
|
||||
result->scale = drag_win32->scale;
|
||||
result->util_data.state = GDK_WIN32_DND_PENDING; /* Implicit */
|
||||
result->dest_window_handle = INVALID_HANDLE_VALUE;
|
||||
|
||||
g_object_unref (surface);
|
||||
|
||||
GDK_NOTE (DND, g_print ("source_context_new: %p (drag %p)\n", result, result->drag));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static data_object *
|
||||
data_object_new (GdkDragContext *drag)
|
||||
data_object_new (GdkDrag *drag)
|
||||
{
|
||||
data_object *result;
|
||||
const char * const *mime_types;
|
||||
@@ -1624,7 +1629,7 @@ data_object_new (GdkDragContext *drag)
|
||||
result->drag = drag;
|
||||
result->formats = g_array_new (FALSE, FALSE, sizeof (GdkWin32ContentFormatPair));
|
||||
|
||||
mime_types = gdk_content_formats_get_mime_types (gdk_drag_context_get_formats (drag), &n_mime_types);
|
||||
mime_types = gdk_content_formats_get_mime_types (gdk_drag_get_formats (drag), &n_mime_types);
|
||||
|
||||
for (i = 0; i < n_mime_types; i++)
|
||||
{
|
||||
@@ -1701,7 +1706,7 @@ create_drag_surface (GdkDisplay *display)
|
||||
return surface;
|
||||
}
|
||||
|
||||
GdkDragContext *
|
||||
GdkDrag *
|
||||
_gdk_win32_surface_drag_begin (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider *content,
|
||||
@@ -1709,21 +1714,20 @@ _gdk_win32_surface_drag_begin (GdkSurface *surface,
|
||||
gint dx,
|
||||
gint dy)
|
||||
{
|
||||
GdkDragContext *drag;
|
||||
GdkWin32DragContext *drag_win32;
|
||||
GdkDrag *drag;
|
||||
GdkWin32Drag *drag_win32;
|
||||
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
|
||||
int x_root, y_root;
|
||||
|
||||
g_return_val_if_fail (surface != NULL, NULL);
|
||||
|
||||
drag = gdk_drag_context_new (gdk_surface_get_display (surface),
|
||||
content,
|
||||
actions,
|
||||
device,
|
||||
use_ole2_dnd ? GDK_DRAG_PROTO_OLE2 : GDK_DRAG_PROTO_LOCAL);
|
||||
drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
|
||||
g_set_object (&drag->source_surface, surface);
|
||||
drag = gdk_drag_new (gdk_surface_get_display (surface),
|
||||
surface,
|
||||
content,
|
||||
actions,
|
||||
device,
|
||||
use_ole2_dnd ? GDK_DRAG_PROTO_OLE2 : GDK_DRAG_PROTO_LOCAL);
|
||||
drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
GDK_NOTE (DND, g_print ("_gdk_win32_surface_drag_begin\n"));
|
||||
|
||||
@@ -1752,8 +1756,7 @@ _gdk_win32_surface_drag_begin (GdkSurface *surface,
|
||||
source_drag_context *source_ctx;
|
||||
data_object *data_obj;
|
||||
|
||||
source_ctx = source_context_new (drag,
|
||||
gdk_drag_context_get_formats (drag));
|
||||
source_ctx = source_context_new (drag, gdk_drag_get_formats (drag));
|
||||
data_obj = data_object_new (drag);
|
||||
|
||||
ddd->base.item_type = GDK_WIN32_DND_THREAD_QUEUE_ITEM_DO_DRAG_DROP;
|
||||
@@ -1830,12 +1833,12 @@ find_window_enum_proc (HWND hwnd,
|
||||
* drop targets about drags that move over them.
|
||||
*/
|
||||
static HWND
|
||||
gdk_win32_drag_context_find_window (GdkDragContext *drag,
|
||||
GdkSurface *drag_surface,
|
||||
gint x_root,
|
||||
gint y_root)
|
||||
gdk_win32_drag_find_window (GdkDrag *drag,
|
||||
GdkSurface *drag_surface,
|
||||
gint x_root,
|
||||
gint y_root)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
find_window_enum_arg a;
|
||||
HWND result;
|
||||
|
||||
@@ -1848,14 +1851,14 @@ gdk_win32_drag_context_find_window (GdkDragContext *drag,
|
||||
a.result = INVALID_HANDLE_VALUE;
|
||||
|
||||
GDK_NOTE (DND,
|
||||
g_print ("gdk_win32_drag_context_find_window: %p %+d%+d\n",
|
||||
g_print ("gdk_win32_drag_find_window: %p %+d%+d\n",
|
||||
(drag_surface ? GDK_SURFACE_HWND (drag_surface) : NULL),
|
||||
a.x, a.y));
|
||||
|
||||
EnumWindows (find_window_enum_proc, (LPARAM) &a);
|
||||
|
||||
GDK_NOTE (DND,
|
||||
g_print ("gdk_win32_drag_context_find_window: %p %+d%+d: %p\n",
|
||||
g_print ("gdk_win32_drag_find_window: %p %+d%+d: %p\n",
|
||||
(drag_surface ? GDK_SURFACE_HWND (drag_surface) : NULL),
|
||||
x_root, y_root,
|
||||
a.result));
|
||||
@@ -1900,7 +1903,7 @@ _gdk_win32_get_drop_for_dest_window (HWND dest_window)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_win32_local_drag_motion (GdkDragContext *drag,
|
||||
gdk_win32_local_drag_motion (GdkDrag *drag,
|
||||
HWND dest_window,
|
||||
gint x_root,
|
||||
gint y_root,
|
||||
@@ -1908,7 +1911,7 @@ gdk_win32_local_drag_motion (GdkDragContext *drag,
|
||||
DWORD key_state,
|
||||
guint32 time_)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32;
|
||||
GdkWin32Drag *drag_win32;
|
||||
GdkDrop *drop;
|
||||
GdkDragAction actions;
|
||||
|
||||
@@ -1917,20 +1920,19 @@ gdk_win32_local_drag_motion (GdkDragContext *drag,
|
||||
|
||||
g_return_val_if_fail (drag != NULL, FALSE);
|
||||
|
||||
drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
drop = _gdk_win32_get_drop_for_dest_window (drag_win32->dest_window);
|
||||
|
||||
actions = gdk_drag_context_get_actions (drag);
|
||||
actions = gdk_drag_get_actions (drag);
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_local_drag_motion: @ %+d:%+d possible=%s\n"
|
||||
" dest=%p (current %p) drop=%p drag=%p:{actions=%s,suggested=%s,action=%s}\n",
|
||||
" dest=%p (current %p) drop=%p drag=%p:{actions=%s,action=%s}\n",
|
||||
x_root, y_root,
|
||||
_gdk_win32_drag_action_to_string (possible_actions),
|
||||
dest_window, drag_win32->dest_window, drop, drag,
|
||||
_gdk_win32_drag_action_to_string (actions),
|
||||
_gdk_win32_drag_action_to_string (gdk_drag_context_get_suggested_action (drag)),
|
||||
_gdk_win32_drag_action_to_string (drag->action)));
|
||||
_gdk_win32_drag_action_to_string (gdk_drag_get_selected_action (drag))));
|
||||
|
||||
if (drag_win32->dest_window != dest_window)
|
||||
{
|
||||
@@ -1962,7 +1964,7 @@ gdk_win32_local_drag_motion (GdkDragContext *drag,
|
||||
drag_win32->drag_status == GDK_DRAG_STATUS_DRAG &&
|
||||
_gdk_win32_local_drop_target_will_emit_motion (drop, x_root, y_root, key_state))
|
||||
{
|
||||
actions = gdk_drag_context_get_actions (drag);
|
||||
actions = gdk_drag_get_actions (drag);
|
||||
drag_win32->drag_status = GDK_DRAG_STATUS_MOTION_WAIT;
|
||||
|
||||
_gdk_win32_local_drop_target_dragover (drop, drag, x_root, y_root, key_state, time_, &actions);
|
||||
@@ -1971,34 +1973,33 @@ gdk_win32_local_drag_motion (GdkDragContext *drag,
|
||||
}
|
||||
|
||||
GDK_NOTE (DND, g_print (" returning %s\n"
|
||||
" drag=%p:{actions=%s,suggested=%s,action=%s}\n",
|
||||
" drag=%p:{actions=%s,action=%s}\n",
|
||||
(drop != NULL && drag_win32->drag_status == GDK_DRAG_STATUS_DRAG) ? "TRUE" : "FALSE",
|
||||
drag,
|
||||
_gdk_win32_drag_action_to_string (gdk_drag_context_get_actions (drag)),
|
||||
_gdk_win32_drag_action_to_string (gdk_drag_context_get_suggested_action (drag)),
|
||||
_gdk_win32_drag_action_to_string (drag->action)));
|
||||
_gdk_win32_drag_action_to_string (gdk_drag_get_actions (drag)),
|
||||
_gdk_win32_drag_action_to_string (gdk_drag_get_selected_action (drag))));
|
||||
return (drop != NULL && drag_win32->drag_status == GDK_DRAG_STATUS_DRAG);
|
||||
}
|
||||
|
||||
static void
|
||||
send_source_state_update (GdkWin32Clipdrop *clipdrop,
|
||||
GdkWin32DragContext *context_win32,
|
||||
GdkWin32Drag *drag_win32,
|
||||
gpointer *ddd)
|
||||
{
|
||||
GdkWin32DnDThreadUpdateDragState *status = g_new0 (GdkWin32DnDThreadUpdateDragState, 1);
|
||||
status->base.item_type = GDK_WIN32_DND_THREAD_QUEUE_ITEM_UPDATE_DRAG_STATE;
|
||||
status->opaque_ddd = ddd;
|
||||
status->produced_util_data = context_win32->util_data;
|
||||
status->produced_util_data = drag_win32->util_data;
|
||||
increment_dnd_queue_counter ();
|
||||
g_async_queue_push (clipdrop->dnd_queue, status);
|
||||
API_CALL (PostThreadMessage, (clipdrop->dnd_thread_id, thread_wakeup_message, 0, 0));
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_win32_drag_context_drag_drop (GdkDragContext *drag,
|
||||
guint32 time_)
|
||||
gdk_win32_drag_drop (GdkDrag *drag,
|
||||
guint32 time_)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
|
||||
|
||||
g_assert (_win32_main_thread == NULL ||
|
||||
@@ -2006,7 +2007,7 @@ gdk_win32_drag_context_drag_drop (GdkDragContext *drag,
|
||||
|
||||
g_return_if_fail (drag != NULL);
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_drag_drop\n"));
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_drop\n"));
|
||||
|
||||
if (drag_win32->protocol == GDK_DRAG_PROTO_LOCAL)
|
||||
{
|
||||
@@ -2016,10 +2017,10 @@ gdk_win32_drag_context_drag_drop (GdkDragContext *drag,
|
||||
{
|
||||
GdkDragAction actions;
|
||||
|
||||
actions = gdk_drag_context_get_actions (drag);
|
||||
actions = gdk_drag_get_actions (drag);
|
||||
_gdk_win32_local_drop_target_drop (drop, drag, time_, &actions);
|
||||
maybe_emit_action_changed (drag_win32, actions);
|
||||
_gdk_win32_local_drag_context_drop_response (drag, actions);
|
||||
_gdk_win32_local_drag_drop_response (drag, actions);
|
||||
}
|
||||
}
|
||||
else if (drag_win32->protocol == GDK_DRAG_PROTO_OLE2)
|
||||
@@ -2034,37 +2035,12 @@ gdk_win32_drag_context_drag_drop (GdkDragContext *drag,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_win32_drag_context_drag_abort (GdkDragContext *drag,
|
||||
guint32 time_)
|
||||
gdk_win32_drag_set_cursor (GdkDrag *drag,
|
||||
GdkCursor *cursor)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
g_assert (_win32_main_thread == NULL ||
|
||||
_win32_main_thread == g_thread_self ());
|
||||
|
||||
g_return_if_fail (drag != NULL);
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_drag_abort\n"));
|
||||
|
||||
if (drag_win32->protocol == GDK_DRAG_PROTO_OLE2)
|
||||
{
|
||||
gpointer ddd = g_hash_table_lookup (clipdrop->active_source_drags, drag);
|
||||
|
||||
drag_win32->util_data.state = GDK_WIN32_DND_NONE;
|
||||
|
||||
if (ddd)
|
||||
send_source_state_update (clipdrop, drag_win32, ddd);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_win32_drag_context_set_cursor (GdkDragContext *drag,
|
||||
GdkCursor *cursor)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_set_cursor: 0x%p 0x%p\n", drag, cursor));
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_set_cursor: 0x%p 0x%p\n", drag, cursor));
|
||||
|
||||
if (!g_set_object (&drag_win32->cursor, cursor))
|
||||
return;
|
||||
@@ -2092,7 +2068,7 @@ ease_out_cubic (double t)
|
||||
|
||||
typedef struct _GdkDragAnim GdkDragAnim;
|
||||
struct _GdkDragAnim {
|
||||
GdkWin32DragContext *drag;
|
||||
GdkWin32Drag *drag;
|
||||
GdkFrameClock *frame_clock;
|
||||
gint64 start_time;
|
||||
};
|
||||
@@ -2108,7 +2084,7 @@ static gboolean
|
||||
gdk_drag_anim_timeout (gpointer data)
|
||||
{
|
||||
GdkDragAnim *anim = data;
|
||||
GdkWin32DragContext *drag = anim->drag;
|
||||
GdkWin32Drag *drag = anim->drag;
|
||||
GdkFrameClock *frame_clock = anim->frame_clock;
|
||||
gint64 current_time;
|
||||
double f;
|
||||
@@ -2136,10 +2112,10 @@ gdk_drag_anim_timeout (gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_win32_drag_context_drop_done (GdkDragContext *drag,
|
||||
gboolean success)
|
||||
gdk_win32_drag_drop_done (GdkDrag *drag,
|
||||
gboolean success)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
GdkDragAnim *anim;
|
||||
/*
|
||||
cairo_surface_t *win_surface;
|
||||
@@ -2148,7 +2124,7 @@ gdk_win32_drag_context_drop_done (GdkDragContext *drag,
|
||||
*/
|
||||
guint id;
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_drop_done: 0x%p %s\n",
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_drop_done: 0x%p %s\n",
|
||||
drag,
|
||||
success ? "dropped successfully" : "dropped unsuccessfully"));
|
||||
|
||||
@@ -2207,7 +2183,7 @@ gdk_win32_drag_context_drop_done (GdkDragContext *drag,
|
||||
anim->frame_clock = gdk_surface_get_frame_clock (drag_win32->drag_surface);
|
||||
anim->start_time = gdk_frame_clock_get_frame_time (anim->frame_clock);
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_drop_done: animate the drag window from %d : %d to %d : %d\n",
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_drop_done: animate the drag window from %d : %d to %d : %d\n",
|
||||
drag_win32->util_data.last_x, drag_win32->util_data.last_y,
|
||||
drag_win32->start_x, drag_win32->start_y));
|
||||
|
||||
@@ -2218,9 +2194,9 @@ gdk_win32_drag_context_drop_done (GdkDragContext *drag,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
drag_context_grab (GdkDragContext *drag)
|
||||
drag_context_grab (GdkDrag *drag)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
GdkSeatCapabilities capabilities;
|
||||
GdkSeat *seat;
|
||||
GdkCursor *cursor;
|
||||
@@ -2232,11 +2208,11 @@ drag_context_grab (GdkDragContext *drag)
|
||||
if (!drag_win32->grab_surface)
|
||||
return FALSE;
|
||||
|
||||
seat = gdk_device_get_seat (gdk_drag_context_get_device (drag));
|
||||
seat = gdk_device_get_seat (gdk_drag_get_device (drag));
|
||||
|
||||
capabilities = GDK_SEAT_CAPABILITY_ALL;
|
||||
|
||||
cursor = gdk_drag_get_cursor (drag, gdk_drag_context_get_selected_action (drag));
|
||||
cursor = gdk_drag_get_cursor (drag, gdk_drag_get_selected_action (drag));
|
||||
g_set_object (&drag_win32->cursor, cursor);
|
||||
|
||||
if (gdk_seat_grab (seat, drag_win32->grab_surface,
|
||||
@@ -2252,9 +2228,9 @@ drag_context_grab (GdkDragContext *drag)
|
||||
}
|
||||
|
||||
static void
|
||||
drag_context_ungrab (GdkDragContext *drag)
|
||||
drag_context_ungrab (GdkDrag *drag)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
GDK_NOTE (DND, g_print ("drag_context_ungrab: 0x%p 0x%p\n",
|
||||
drag,
|
||||
@@ -2271,10 +2247,10 @@ drag_context_ungrab (GdkDragContext *drag)
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_win32_drag_context_cancel (GdkDragContext *drag,
|
||||
GdkDragCancelReason reason)
|
||||
gdk_win32_drag_cancel (GdkDrag *drag,
|
||||
GdkDragCancelReason reason)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
const gchar *reason_str = NULL;
|
||||
switch (reason)
|
||||
@@ -2293,7 +2269,7 @@ gdk_win32_drag_context_cancel (GdkDragContext *drag,
|
||||
break;
|
||||
}
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_cancel: 0x%p %s\n",
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_cancel: 0x%p %s\n",
|
||||
drag,
|
||||
reason_str));
|
||||
|
||||
@@ -2305,20 +2281,21 @@ gdk_win32_drag_context_cancel (GdkDragContext *drag,
|
||||
drop = NULL;
|
||||
}
|
||||
|
||||
gdk_drag_context_set_cursor (drag, NULL);
|
||||
gdk_drag_set_cursor (drag, NULL);
|
||||
drag_context_ungrab (drag);
|
||||
gdk_drag_drop_done (drag, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_win32_drag_context_drop_performed (GdkDragContext *drag,
|
||||
guint32 time_)
|
||||
gdk_win32_drag_drop_performed (GdkDrag *drag,
|
||||
guint32 time_)
|
||||
{
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_drop_performed: 0x%p %u\n",
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_drop_performed: 0x%p %u\n",
|
||||
drag,
|
||||
time_));
|
||||
gdk_drag_drop (drag, time_);
|
||||
gdk_drag_context_set_cursor (drag, NULL);
|
||||
|
||||
gdk_win32_drag_drop (drag, time_);
|
||||
gdk_drag_set_cursor (drag, NULL);
|
||||
drag_context_ungrab (drag);
|
||||
}
|
||||
|
||||
@@ -2326,33 +2303,33 @@ gdk_win32_drag_context_drop_performed (GdkDragContext *drag,
|
||||
#define SMALL_STEP 1
|
||||
|
||||
static void
|
||||
gdk_local_drag_update (GdkDragContext *drag,
|
||||
gdouble x_root,
|
||||
gdouble y_root,
|
||||
DWORD grfKeyState,
|
||||
guint32 evtime)
|
||||
gdk_local_drag_update (GdkDrag *drag,
|
||||
gdouble x_root,
|
||||
gdouble y_root,
|
||||
DWORD grfKeyState,
|
||||
guint32 evtime)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
HWND dest_window;
|
||||
|
||||
g_assert (_win32_main_thread == NULL ||
|
||||
_win32_main_thread == g_thread_self ());
|
||||
|
||||
dest_window = gdk_win32_drag_context_find_window (drag,
|
||||
drag_win32->drag_surface,
|
||||
x_root, y_root);
|
||||
dest_window = gdk_win32_drag_find_window (drag,
|
||||
drag_win32->drag_surface,
|
||||
x_root, y_root);
|
||||
|
||||
gdk_win32_local_drag_motion (drag, dest_window, x_root, y_root,
|
||||
gdk_drag_context_get_actions (drag),
|
||||
gdk_drag_get_actions (drag),
|
||||
grfKeyState, evtime);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_motion_event (GdkDragContext *drag,
|
||||
gdk_dnd_handle_motion_event (GdkDrag *drag,
|
||||
const GdkEventMotion *event)
|
||||
{
|
||||
GdkModifierType state;
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
DWORD key_state;
|
||||
|
||||
if (!gdk_event_get_state ((GdkEvent *) event, &state))
|
||||
@@ -2391,10 +2368,10 @@ gdk_dnd_handle_motion_event (GdkDragContext *drag,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_key_event (GdkDragContext *drag,
|
||||
gdk_dnd_handle_key_event (GdkDrag *drag,
|
||||
const GdkEventKey *event)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
GdkModifierType state;
|
||||
GdkDevice *pointer;
|
||||
gint dx, dy;
|
||||
@@ -2413,7 +2390,7 @@ gdk_dnd_handle_key_event (GdkDragContext *drag,
|
||||
switch (event->keyval)
|
||||
{
|
||||
case GDK_KEY_Escape:
|
||||
gdk_drag_context_cancel (drag, GDK_DRAG_CANCEL_USER_CANCELLED);
|
||||
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_USER_CANCELLED);
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_space:
|
||||
@@ -2421,13 +2398,13 @@ gdk_dnd_handle_key_event (GdkDragContext *drag,
|
||||
case GDK_KEY_ISO_Enter:
|
||||
case GDK_KEY_KP_Enter:
|
||||
case GDK_KEY_KP_Space:
|
||||
if ((gdk_drag_context_get_selected_action (drag) != 0) &&
|
||||
if ((gdk_drag_get_selected_action (drag) != 0) &&
|
||||
(drag_win32->dest_window != INVALID_HANDLE_VALUE))
|
||||
{
|
||||
g_signal_emit_by_name (drag, "drop-performed");
|
||||
}
|
||||
else
|
||||
gdk_drag_context_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET);
|
||||
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET);
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -2477,10 +2454,10 @@ gdk_dnd_handle_key_event (GdkDragContext *drag,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_grab_broken_event (GdkDragContext *drag,
|
||||
gdk_dnd_handle_grab_broken_event (GdkDrag *drag,
|
||||
const GdkEventGrabBroken *event)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_dnd_handle_grab_broken_event: 0x%p\n",
|
||||
drag));
|
||||
@@ -2495,15 +2472,15 @@ gdk_dnd_handle_grab_broken_event (GdkDragContext *drag,
|
||||
return FALSE;
|
||||
|
||||
if (gdk_event_get_device ((GdkEvent *) event) !=
|
||||
gdk_drag_context_get_device (drag))
|
||||
gdk_drag_get_device (drag))
|
||||
return FALSE;
|
||||
|
||||
gdk_drag_context_cancel (drag, GDK_DRAG_CANCEL_ERROR);
|
||||
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_ERROR);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_dnd_handle_button_event (GdkDragContext *drag,
|
||||
gdk_dnd_handle_button_event (GdkDrag *drag,
|
||||
const GdkEventButton *event)
|
||||
{
|
||||
GDK_NOTE (DND, g_print ("gdk_dnd_handle_button_event: 0x%p\n",
|
||||
@@ -2515,22 +2492,22 @@ gdk_dnd_handle_button_event (GdkDragContext *drag,
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
if ((gdk_drag_context_get_selected_action (drag) != 0))
|
||||
if ((gdk_drag_get_selected_action (drag) != 0))
|
||||
{
|
||||
g_signal_emit_by_name (drag, "drop-performed");
|
||||
}
|
||||
else
|
||||
gdk_drag_context_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET);
|
||||
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET);
|
||||
|
||||
/* Make sure GTK gets mouse release button event */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_win32_drag_context_handle_event (GdkDragContext *drag,
|
||||
const GdkEvent *event)
|
||||
gdk_win32_drag_handle_event (GdkDrag *drag,
|
||||
const GdkEvent *event)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
if (!drag_win32->grab_seat)
|
||||
return FALSE;
|
||||
@@ -2559,30 +2536,20 @@ gdk_win32_drag_context_handle_event (GdkDragContext *drag,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_win32_drag_context_action_changed (GdkDragContext *drag,
|
||||
GdkDragAction action)
|
||||
{
|
||||
GdkCursor *cursor;
|
||||
|
||||
cursor = gdk_drag_get_cursor (drag, action);
|
||||
gdk_drag_context_set_cursor (drag, cursor);
|
||||
}
|
||||
|
||||
static GdkSurface *
|
||||
gdk_win32_drag_context_get_drag_surface (GdkDragContext *drag)
|
||||
gdk_win32_drag_get_drag_surface (GdkDrag *drag)
|
||||
{
|
||||
return GDK_WIN32_DRAG_CONTEXT (drag)->drag_surface;
|
||||
return GDK_WIN32_DRAG (drag)->drag_surface;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_win32_drag_context_set_hotspot (GdkDragContext *drag,
|
||||
gint hot_x,
|
||||
gint hot_y)
|
||||
gdk_win32_drag_set_hotspot (GdkDrag *drag,
|
||||
gint hot_x,
|
||||
gint hot_y)
|
||||
{
|
||||
GdkWin32DragContext *drag_win32 = GDK_WIN32_DRAG_CONTEXT (drag);
|
||||
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_drag_context_set_hotspot: 0x%p %d:%d\n",
|
||||
GDK_NOTE (DND, g_print ("gdk_drag_set_hotspot: 0x%p %d:%d\n",
|
||||
drag,
|
||||
hot_x, hot_y));
|
||||
|
||||
@@ -2597,23 +2564,18 @@ gdk_win32_drag_context_set_hotspot (GdkDragContext *drag,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_win32_drag_context_class_init (GdkWin32DragContextClass *klass)
|
||||
gdk_win32_drag_class_init (GdkWin32DragClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GdkDragContextClass *context_class = GDK_DRAG_CONTEXT_CLASS (klass);
|
||||
GdkDragClass *drag_class = GDK_DRAG_CLASS (klass);
|
||||
|
||||
object_class->finalize = gdk_win32_drag_context_finalize;
|
||||
|
||||
context_class->drag_abort = gdk_win32_drag_context_drag_abort;
|
||||
context_class->drag_drop = gdk_win32_drag_context_drag_drop;
|
||||
|
||||
context_class->get_drag_surface = gdk_win32_drag_context_get_drag_surface;
|
||||
context_class->set_hotspot = gdk_win32_drag_context_set_hotspot;
|
||||
context_class->drop_done = gdk_win32_drag_context_drop_done;
|
||||
context_class->set_cursor = gdk_win32_drag_context_set_cursor;
|
||||
context_class->cancel = gdk_win32_drag_context_cancel;
|
||||
context_class->drop_performed = gdk_win32_drag_context_drop_performed;
|
||||
context_class->handle_event = gdk_win32_drag_context_handle_event;
|
||||
context_class->action_changed = gdk_win32_drag_context_action_changed;
|
||||
object_class->finalize = gdk_win32_drag_finalize;
|
||||
|
||||
drag_class->get_drag_surface = gdk_win32_drag_get_drag_surface;
|
||||
drag_class->set_hotspot = gdk_win32_drag_set_hotspot;
|
||||
drag_class->drop_done = gdk_win32_drag_drop_done;
|
||||
drag_class->set_cursor = gdk_win32_drag_set_cursor;
|
||||
drag_class->cancel = gdk_win32_drag_cancel;
|
||||
drag_class->drop_performed = gdk_win32_drag_drop_performed;
|
||||
drag_class->handle_event = gdk_win32_drag_handle_event;
|
||||
}
|
||||
|
||||
+11
-11
@@ -41,7 +41,7 @@
|
||||
|
||||
#include "gdkdropprivate.h"
|
||||
|
||||
#include "gdkdnd.h"
|
||||
#include "gdkdrag.h"
|
||||
#include "gdkproperty.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkprivate-win32.h"
|
||||
@@ -172,7 +172,7 @@ gdk_win32_drop_finalize (GObject *object)
|
||||
static GdkDrop *
|
||||
gdk_drop_new (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
GdkDragContext *drag,
|
||||
GdkDrag *drag,
|
||||
GdkContentFormats *formats,
|
||||
GdkSurface *surface,
|
||||
GdkDragProtocol protocol)
|
||||
@@ -453,7 +453,7 @@ set_source_actions_helper (GdkDrop *drop,
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_local_drop_target_dragenter (GdkDragContext *drag,
|
||||
_gdk_win32_local_drop_target_dragenter (GdkDrag *drag,
|
||||
GdkSurface *dest_surface,
|
||||
gint x_root,
|
||||
gint y_root,
|
||||
@@ -478,7 +478,7 @@ _gdk_win32_local_drop_target_dragenter (GdkDragContext *drag,
|
||||
drop = gdk_drop_new (display,
|
||||
gdk_seat_get_pointer (gdk_display_get_default_seat (display)),
|
||||
drag,
|
||||
gdk_content_formats_ref (gdk_drag_context_get_formats (drag)),
|
||||
gdk_content_formats_ref (gdk_drag_get_formats (drag)),
|
||||
dest_surface,
|
||||
GDK_DRAG_PROTO_LOCAL);
|
||||
drop_win32 = GDK_WIN32_DROP (drop);
|
||||
@@ -518,7 +518,7 @@ idroptarget_dragenter (LPDROPTARGET This,
|
||||
GdkDisplay *display;
|
||||
gint pt_x;
|
||||
gint pt_y;
|
||||
GdkDragContext *drag;
|
||||
GdkDrag *drag;
|
||||
GdkDragAction source_actions;
|
||||
GdkDragAction dest_actions;
|
||||
|
||||
@@ -531,7 +531,7 @@ idroptarget_dragenter (LPDROPTARGET This,
|
||||
|
||||
g_clear_object (&ctx->drop);
|
||||
|
||||
/* Try to find the GdkDragContext object for this DnD operation,
|
||||
/* Try to find the GdkDrag object for this DnD operation,
|
||||
* if it originated in our own application.
|
||||
*/
|
||||
drag = NULL;
|
||||
@@ -593,7 +593,7 @@ _gdk_win32_local_drop_target_will_emit_motion (GdkDrop *drop,
|
||||
|
||||
void
|
||||
_gdk_win32_local_drop_target_dragover (GdkDrop *drop,
|
||||
GdkDragContext *drag,
|
||||
GdkDrag *drag,
|
||||
gint x_root,
|
||||
gint y_root,
|
||||
DWORD grfKeyState,
|
||||
@@ -710,7 +710,7 @@ idroptarget_dragleave (LPDROPTARGET This)
|
||||
|
||||
void
|
||||
_gdk_win32_local_drop_target_drop (GdkDrop *drop,
|
||||
GdkDragContext *drag,
|
||||
GdkDrag *drag,
|
||||
guint32 time_,
|
||||
GdkDragAction *actions)
|
||||
{
|
||||
@@ -1065,7 +1065,7 @@ gdk_win32_drop_status (GdkDrop *drop,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
GdkWin32Drop *drop_win32 = GDK_WIN32_DROP (drop);
|
||||
GdkDragContext *drag;
|
||||
GdkDrag *drag;
|
||||
|
||||
g_return_if_fail (drop != NULL);
|
||||
|
||||
@@ -1090,7 +1090,7 @@ static void
|
||||
gdk_win32_drop_finish (GdkDrop *drop,
|
||||
GdkDragAction action)
|
||||
{
|
||||
GdkDragContext *drag;
|
||||
GdkDrag *drag;
|
||||
GdkWin32Drop *drop_win32 = GDK_WIN32_DROP (drop);
|
||||
|
||||
g_return_if_fail (drop != NULL);
|
||||
@@ -1107,7 +1107,7 @@ gdk_win32_drop_finish (GdkDrop *drop,
|
||||
drag = gdk_drop_get_drag (drop);
|
||||
|
||||
if (drag != NULL)
|
||||
_gdk_win32_local_drag_context_drop_response (drag, action);
|
||||
_gdk_win32_local_drag_drop_response (drag, action);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
+6
-121
@@ -59,7 +59,7 @@
|
||||
#include "gdkwin32dnd-private.h"
|
||||
#include "gdkdisplay-win32.h"
|
||||
//#include "gdkselection-win32.h"
|
||||
#include "gdkdndprivate.h"
|
||||
#include "gdkdragprivate.h"
|
||||
|
||||
#include <windowsx.h>
|
||||
|
||||
@@ -738,8 +738,6 @@ build_wm_ime_composition_event (GdkEvent *event,
|
||||
build_key_event_state (event, key_state);
|
||||
|
||||
event->key.hardware_keycode = 0; /* FIXME: What should it be? */
|
||||
event->key.string = NULL;
|
||||
event->key.length = 0;
|
||||
event->key.keyval = gdk_unicode_to_keyval (wc);
|
||||
}
|
||||
|
||||
@@ -768,7 +766,7 @@ print_event_state (guint state)
|
||||
void
|
||||
_gdk_win32_print_event (const GdkEvent *event)
|
||||
{
|
||||
gchar *escaped, *kvname;
|
||||
gchar *kvname;
|
||||
|
||||
g_print ("%s%*s===> ", (debug_indent > 0 ? "\n" : ""), debug_indent, "");
|
||||
switch (event->any.type)
|
||||
@@ -777,7 +775,6 @@ _gdk_win32_print_event (const GdkEvent *event)
|
||||
CASE (GDK_NOTHING);
|
||||
CASE (GDK_DELETE);
|
||||
CASE (GDK_DESTROY);
|
||||
CASE (GDK_EXPOSE);
|
||||
CASE (GDK_MOTION_NOTIFY);
|
||||
CASE (GDK_BUTTON_PRESS);
|
||||
CASE (GDK_BUTTON_RELEASE);
|
||||
@@ -786,9 +783,6 @@ _gdk_win32_print_event (const GdkEvent *event)
|
||||
CASE (GDK_ENTER_NOTIFY);
|
||||
CASE (GDK_LEAVE_NOTIFY);
|
||||
CASE (GDK_FOCUS_CHANGE);
|
||||
CASE (GDK_CONFIGURE);
|
||||
CASE (GDK_MAP);
|
||||
CASE (GDK_UNMAP);
|
||||
CASE (GDK_PROXIMITY_IN);
|
||||
CASE (GDK_PROXIMITY_OUT);
|
||||
CASE (GDK_DRAG_ENTER);
|
||||
@@ -807,8 +801,6 @@ _gdk_win32_print_event (const GdkEvent *event)
|
||||
|
||||
switch (event->any.type)
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
break;
|
||||
case GDK_MOTION_NOTIFY:
|
||||
g_print ("(%.4g,%.4g) (%.4g,%.4g)",
|
||||
event->motion.x, event->motion.y,
|
||||
@@ -825,17 +817,10 @@ _gdk_win32_print_event (const GdkEvent *event)
|
||||
break;
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
if (event->key.length == 0)
|
||||
escaped = g_strdup ("");
|
||||
else
|
||||
escaped = g_strescape (event->key.string, NULL);
|
||||
kvname = gdk_keyval_name (event->key.keyval);
|
||||
g_print ("%#.02x group:%d %s %d:\"%s\" ",
|
||||
g_print ("%#.02x group:%d %s",
|
||||
event->key.hardware_keycode, event->key.group,
|
||||
(kvname ? kvname : "??"),
|
||||
event->key.length,
|
||||
escaped);
|
||||
g_free (escaped);
|
||||
(kvname ? kvname : "??"));
|
||||
print_event_state (event->key.state);
|
||||
break;
|
||||
case GDK_ENTER_NOTIFY:
|
||||
@@ -861,11 +846,6 @@ _gdk_win32_print_event (const GdkEvent *event)
|
||||
case GDK_FOCUS_CHANGE:
|
||||
g_print ("%s", (event->focus_change.in ? "IN" : "OUT"));
|
||||
break;
|
||||
case GDK_CONFIGURE:
|
||||
g_print ("x:%d y:%d w:%d h:%d",
|
||||
event->configure.x, event->configure.y,
|
||||
event->configure.width, event->configure.height);
|
||||
break;
|
||||
case GDK_DRAG_ENTER:
|
||||
case GDK_DRAG_LEAVE:
|
||||
case GDK_DRAG_MOTION:
|
||||
@@ -873,7 +853,7 @@ _gdk_win32_print_event (const GdkEvent *event)
|
||||
if (event->dnd.drop != NULL)
|
||||
g_print ("ctx:%p: %s",
|
||||
event->dnd.drop,
|
||||
_gdk_win32_drag_protocol_to_string (GDK_WIN32_DRAG_CONTEXT (event->dnd.drop)->protocol));
|
||||
_gdk_win32_drag_protocol_to_string (GDK_WIN32_DRAG (event->dnd.drop)->protocol));
|
||||
break;
|
||||
case GDK_SCROLL:
|
||||
g_print ("(%.4g,%.4g) (%.4g,%.4g) %s ",
|
||||
@@ -951,73 +931,6 @@ _gdk_win32_append_event (GdkEvent *event)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
fill_key_event_string (GdkEvent *event)
|
||||
{
|
||||
gunichar c;
|
||||
gchar buf[256];
|
||||
|
||||
/* Fill in event->string crudely, since various programs
|
||||
* depend on it.
|
||||
*/
|
||||
|
||||
c = 0;
|
||||
if (event->key.keyval != GDK_KEY_VoidSymbol)
|
||||
c = gdk_keyval_to_unicode (event->key.keyval);
|
||||
|
||||
if (c)
|
||||
{
|
||||
gsize bytes_written;
|
||||
gint len;
|
||||
|
||||
/* Apply the control key - Taken from Xlib
|
||||
*/
|
||||
if (event->key.state & GDK_CONTROL_MASK)
|
||||
{
|
||||
if ((c >= '@' && c < '\177') || c == ' ')
|
||||
c &= 0x1F;
|
||||
else if (c == '2')
|
||||
{
|
||||
event->key.string = g_memdup ("\0\0", 2);
|
||||
event->key.length = 1;
|
||||
return;
|
||||
}
|
||||
else if (c >= '3' && c <= '7')
|
||||
c -= ('3' - '\033');
|
||||
else if (c == '8')
|
||||
c = '\177';
|
||||
else if (c == '/')
|
||||
c = '_' & 0x1F;
|
||||
}
|
||||
|
||||
len = g_unichar_to_utf8 (c, buf);
|
||||
buf[len] = '\0';
|
||||
|
||||
event->key.string = g_locale_from_utf8 (buf, len,
|
||||
NULL, &bytes_written,
|
||||
NULL);
|
||||
if (event->key.string)
|
||||
event->key.length = bytes_written;
|
||||
}
|
||||
else if (event->key.keyval == GDK_KEY_Escape)
|
||||
{
|
||||
event->key.length = 1;
|
||||
event->key.string = g_strdup ("\033");
|
||||
}
|
||||
else if (event->key.keyval == GDK_KEY_Return ||
|
||||
event->key.keyval == GDK_KEY_KP_Enter)
|
||||
{
|
||||
event->key.length = 1;
|
||||
event->key.string = g_strdup ("\r");
|
||||
}
|
||||
|
||||
if (!event->key.string)
|
||||
{
|
||||
event->key.length = 0;
|
||||
event->key.string = g_strdup ("");
|
||||
}
|
||||
}
|
||||
|
||||
static GdkWin32MessageFilterReturn
|
||||
apply_message_filters (GdkDisplay *display,
|
||||
MSG *msg,
|
||||
@@ -1429,17 +1342,7 @@ _gdk_win32_do_emit_configure_event (GdkSurface *window,
|
||||
|
||||
_gdk_surface_update_size (window);
|
||||
|
||||
event = gdk_event_new (GDK_CONFIGURE);
|
||||
|
||||
event->any.surface = window;
|
||||
|
||||
event->configure.width = window->width;
|
||||
event->configure.height = window->height;
|
||||
|
||||
event->configure.x = window->x;
|
||||
event->configure.y = window->y;
|
||||
|
||||
_gdk_win32_append_event (event);
|
||||
g_signal_emit_by_name (window, "size-changed", window->width, window->height);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2309,8 +2212,6 @@ gdk_event_translate (MSG *msg,
|
||||
event->any.surface = window;
|
||||
event->key.time = _gdk_win32_get_next_tick (msg->time);
|
||||
event->key.keyval = GDK_KEY_VoidSymbol;
|
||||
event->key.string = NULL;
|
||||
event->key.length = 0;
|
||||
event->key.hardware_keycode = msg->wParam;
|
||||
/* save original scancode */
|
||||
gdk_event_set_scancode (event, msg->lParam >> 16);
|
||||
@@ -2381,8 +2282,6 @@ gdk_event_translate (MSG *msg,
|
||||
else
|
||||
impl->leading_surrogate_keyup = 0;
|
||||
|
||||
fill_key_event_string (event);
|
||||
|
||||
/* Only one release key event is fired when both shift keys are pressed together
|
||||
and then released. In order to send the missing event, press events for shift
|
||||
keys are recorded and sent together when the release event occurs.
|
||||
@@ -3125,15 +3024,6 @@ gdk_event_translate (MSG *msg,
|
||||
gdk_device_ungrab (device, msg -> time);
|
||||
}
|
||||
|
||||
/* Send MAP events */
|
||||
if ((windowpos->flags & SWP_SHOWWINDOW) &&
|
||||
!GDK_SURFACE_DESTROYED (window))
|
||||
{
|
||||
event = gdk_event_new (GDK_MAP);
|
||||
event->any.surface = window;
|
||||
_gdk_win32_append_event (event);
|
||||
}
|
||||
|
||||
/* Update window state */
|
||||
if (windowpos->flags & (SWP_STATECHANGED | SWP_SHOWWINDOW | SWP_HIDEWINDOW))
|
||||
{
|
||||
@@ -3192,11 +3082,6 @@ gdk_event_translate (MSG *msg,
|
||||
if ((windowpos->flags & SWP_HIDEWINDOW) &&
|
||||
!GDK_SURFACE_DESTROYED (window))
|
||||
{
|
||||
/* Send UNMAP events */
|
||||
event = gdk_event_new (GDK_UNMAP);
|
||||
event->any.surface = window;
|
||||
_gdk_win32_append_event (event);
|
||||
|
||||
/* Make transient parent the forground window when window unmaps */
|
||||
impl = GDK_SURFACE_IMPL_WIN32 (window->impl);
|
||||
|
||||
|
||||
@@ -423,12 +423,12 @@ void _gdk_win32_display_create_surface_impl (GdkDisplay *display,
|
||||
void _gdk_win32_surface_register_dnd (GdkSurface *window);
|
||||
void _gdk_win32_surface_unregister_dnd (GdkSurface *window);
|
||||
|
||||
GdkDragContext *_gdk_win32_surface_drag_begin (GdkSurface *window,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider *content,
|
||||
GdkDragAction actions,
|
||||
gint x_root,
|
||||
gint y_root);
|
||||
GdkDrag *_gdk_win32_surface_drag_begin (GdkSurface *window,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider *content,
|
||||
GdkDragAction actions,
|
||||
gint x_root,
|
||||
gint y_root);
|
||||
|
||||
/* Stray GdkWin32Screen members */
|
||||
gboolean _gdk_win32_get_setting (const gchar *name, GValue *value);
|
||||
|
||||
@@ -760,17 +760,11 @@ gdk_win32_surface_destroy (GdkSurface *window,
|
||||
_gdk_remove_modal_window (window);
|
||||
|
||||
/* Remove all our transient children */
|
||||
tmp = surface_impl->transient_children;
|
||||
while (tmp != NULL)
|
||||
while (surface_impl->transient_children != NULL)
|
||||
{
|
||||
GdkSurface *child = tmp->data;
|
||||
GdkSurfaceImplWin32 *child_impl = GDK_SURFACE_IMPL_WIN32 (GDK_SURFACE (child)->impl);
|
||||
|
||||
child_impl->transient_owner = NULL;
|
||||
tmp = tmp->next;
|
||||
GdkSurface *child = surface_impl->transient_children->data;
|
||||
gdk_surface_set_transient_for (child, NULL);
|
||||
}
|
||||
g_slist_free (surface_impl->transient_children);
|
||||
surface_impl->transient_children = NULL;
|
||||
|
||||
/* Remove ourself from our transient owner */
|
||||
if (surface_impl->transient_owner != NULL)
|
||||
@@ -1672,27 +1666,29 @@ gdk_win32_surface_set_transient_for (GdkSurface *window,
|
||||
return;
|
||||
}
|
||||
|
||||
if (parent == NULL)
|
||||
if (surface_impl->transient_owner == parent)
|
||||
return;
|
||||
|
||||
if (GDK_IS_SURFACE (surface_impl->transient_owner))
|
||||
{
|
||||
GdkSurfaceImplWin32 *trans_impl = GDK_SURFACE_IMPL_WIN32 (surface_impl->transient_owner->impl);
|
||||
if (trans_impl->transient_children != NULL)
|
||||
{
|
||||
item = g_slist_find (trans_impl->transient_children, window);
|
||||
item->data = NULL;
|
||||
trans_impl->transient_children = g_slist_delete_link (trans_impl->transient_children, item);
|
||||
trans_impl->num_transients--;
|
||||
item = g_slist_find (trans_impl->transient_children, window);
|
||||
item->data = NULL;
|
||||
trans_impl->transient_children = g_slist_delete_link (trans_impl->transient_children, item);
|
||||
trans_impl->num_transients--;
|
||||
|
||||
if (!trans_impl->num_transients)
|
||||
{
|
||||
trans_impl->transient_children = NULL;
|
||||
}
|
||||
if (!trans_impl->num_transients)
|
||||
{
|
||||
trans_impl->transient_children = NULL;
|
||||
}
|
||||
|
||||
g_object_unref (G_OBJECT (surface_impl->transient_owner));
|
||||
g_object_unref (G_OBJECT (window));
|
||||
|
||||
surface_impl->transient_owner = NULL;
|
||||
}
|
||||
else
|
||||
|
||||
if (parent)
|
||||
{
|
||||
parent_impl = GDK_SURFACE_IMPL_WIN32 (parent->impl);
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GdkWin32DragContextUtilityData GdkWin32DragContextUtilityData;
|
||||
typedef struct _GdkWin32DragUtilityData GdkWin32DragUtilityData;
|
||||
|
||||
/* This structure is deliberately designed to be
|
||||
* copyable with memcpy(), i.e. no pointers inside.
|
||||
*/
|
||||
struct _GdkWin32DragContextUtilityData
|
||||
struct _GdkWin32DragUtilityData
|
||||
{
|
||||
gint last_x; /* Coordinates from last event, in GDK space */
|
||||
gint last_y;
|
||||
@@ -39,15 +39,15 @@ struct _GdkWin32DragContextUtilityData
|
||||
GdkWin32DndState state;
|
||||
};
|
||||
|
||||
struct _GdkWin32DragContext
|
||||
struct _GdkWin32Drag
|
||||
{
|
||||
GdkDragContext drag;
|
||||
GdkDrag drag;
|
||||
|
||||
/* The drag protocol being used */
|
||||
GdkDragProtocol protocol;
|
||||
|
||||
/* The surface used for grabs.
|
||||
* Usually the same as GdkDragContext->source_surface
|
||||
* Usually the same as GdkDrag->source_surface
|
||||
*/
|
||||
GdkSurface *grab_surface;
|
||||
|
||||
@@ -71,7 +71,7 @@ struct _GdkWin32DragContext
|
||||
*/
|
||||
GdkDragAction current_action;
|
||||
|
||||
GdkWin32DragContextUtilityData util_data;
|
||||
GdkWin32DragUtilityData util_data;
|
||||
|
||||
guint scale; /* Temporarily caches the HiDPI scale */
|
||||
gint hot_x; /* Hotspot offset from the top-left of the drag-window, scaled (can be added to GDK space coordinates) */
|
||||
@@ -84,23 +84,23 @@ struct _GdkWin32DragContext
|
||||
guint handle_events : 1; /* Whether handle_event() should do anything */
|
||||
};
|
||||
|
||||
struct _GdkWin32DragContextClass
|
||||
struct _GdkWin32DragClass
|
||||
{
|
||||
GdkDragContextClass parent_class;
|
||||
GdkDragClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
gpointer _gdk_win32_dnd_thread_main (gpointer data);
|
||||
|
||||
GdkDragContext *_gdk_win32_find_drag_for_dest_window (HWND dest_window);
|
||||
GdkDrop *_gdk_win32_get_drop_for_dest_surface (GdkSurface *dest);
|
||||
GdkDrag *_gdk_win32_find_drag_for_dest_window (HWND dest_window);
|
||||
GdkDrop *_gdk_win32_get_drop_for_dest_surface (GdkSurface *dest);
|
||||
|
||||
gboolean _gdk_win32_local_drop_target_will_emit_motion (GdkDrop *drop,
|
||||
gint x_root,
|
||||
gint y_root,
|
||||
DWORD grfKeyState);
|
||||
|
||||
void _gdk_win32_local_drop_target_dragenter (GdkDragContext *drag,
|
||||
void _gdk_win32_local_drop_target_dragenter (GdkDrag *drag,
|
||||
GdkSurface *dest_surface,
|
||||
gint x_root,
|
||||
gint y_root,
|
||||
@@ -108,22 +108,22 @@ void _gdk_win32_local_drop_target_dragenter (GdkDragContext *drag,
|
||||
guint32 time_,
|
||||
GdkDragAction *actions);
|
||||
void _gdk_win32_local_drop_target_dragover (GdkDrop *drop,
|
||||
GdkDragContext *drag,
|
||||
GdkDrag *drag,
|
||||
gint x_root,
|
||||
gint y_root,
|
||||
DWORD grfKeyState,
|
||||
guint32 time_,
|
||||
GdkDragAction *actions);
|
||||
void _gdk_win32_local_drop_target_dragleave (GdkDrop *drop,
|
||||
guint32 time_);
|
||||
void _gdk_win32_local_drop_target_dragleave (GdkDrop *drop,
|
||||
guint32 time_);
|
||||
void _gdk_win32_local_drop_target_drop (GdkDrop *drop,
|
||||
GdkDragContext *drag,
|
||||
GdkDrag *drag,
|
||||
guint32 time_,
|
||||
GdkDragAction *actions);
|
||||
|
||||
void _gdk_win32_local_drag_give_feedback (GdkDragContext *drag,
|
||||
void _gdk_win32_local_drag_give_feedback (GdkDrag *drag,
|
||||
GdkDragAction actions);
|
||||
void _gdk_win32_local_drag_context_drop_response (GdkDragContext *drag,
|
||||
void _gdk_win32_local_drag_drop_response (GdkDrag *drag,
|
||||
GdkDragAction action);
|
||||
|
||||
|
||||
|
||||
+11
-11
@@ -26,23 +26,23 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_WIN32_DRAG_CONTEXT (gdk_win32_drag_context_get_type ())
|
||||
#define GDK_WIN32_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WIN32_DRAG_CONTEXT, GdkWin32DragContext))
|
||||
#define GDK_WIN32_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WIN32_DRAG_CONTEXT, GdkWin32DragContextClass))
|
||||
#define GDK_IS_WIN32_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WIN32_DRAG_CONTEXT))
|
||||
#define GDK_IS_WIN32_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WIN32_DRAG_CONTEXT))
|
||||
#define GDK_WIN32_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WIN32_DRAG_CONTEXT, GdkWin32DragContextClass))
|
||||
#define GDK_TYPE_WIN32_DRAG (gdk_win32_drag_get_type ())
|
||||
#define GDK_WIN32_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WIN32_DRAG, GdkWin32Drag))
|
||||
#define GDK_WIN32_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WIN32_DRAG, GdkWin32DragClass))
|
||||
#define GDK_IS_WIN32_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WIN32_DRAG))
|
||||
#define GDK_IS_WIN32_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WIN32_DRAG))
|
||||
#define GDK_WIN32_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WIN32_DRAG, GdkWin32DragClass))
|
||||
|
||||
#ifdef GDK_COMPILATION
|
||||
typedef struct _GdkWin32DragContext GdkWin32DragContext;
|
||||
typedef struct _GdkWin32Drag GdkWin32Drag;
|
||||
#else
|
||||
typedef GdkDragContext GdkWin32DragContext;
|
||||
typedef GdkDrag GdkWin32Drag;
|
||||
#endif
|
||||
typedef struct _GdkWin32DragContextClass GdkWin32DragContextClass;
|
||||
typedef struct _GdkWin32DragClass GdkWin32DragClass;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gdk_win32_drag_context_get_type (void);
|
||||
GType gdk_win32_drag_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_WIN32_DRAG_CONTEXT_H__ */
|
||||
#endif /* __GDK_WIN32_DRAG_H__ */
|
||||
|
||||
@@ -491,6 +491,14 @@ gdk_x11_clipboard_xevent (GdkDisplay *display,
|
||||
if (sn->selection != cb->xselection)
|
||||
return FALSE;
|
||||
|
||||
if (sn->selection_timestamp < cb->timestamp)
|
||||
{
|
||||
GDK_DISPLAY_NOTE (display, CLIPBOARD,
|
||||
g_printerr ("%s: Ignoring XFixesSelectionNotify with too old timestamp (%lu vs %lu)\n",
|
||||
cb->selection, sn->selection_timestamp, cb->timestamp));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (sn->owner == GDK_X11_DISPLAY (display)->leader_window)
|
||||
{
|
||||
GDK_DISPLAY_NOTE (display, CLIPBOARD,
|
||||
|
||||
@@ -221,8 +221,6 @@ translate_key_event (GdkDisplay *display,
|
||||
|
||||
event->key.is_modifier = gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode);
|
||||
|
||||
_gdk_x11_event_translate_keyboard_string (&event->key);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (display, EVENTS))
|
||||
{
|
||||
@@ -231,10 +229,6 @@ translate_key_event (GdkDisplay *display,
|
||||
xevent->xkey.window,
|
||||
event->key.keyval ? gdk_keyval_name (event->key.keyval) : "(none)",
|
||||
event->key.keyval);
|
||||
|
||||
if (event->key.length > 0)
|
||||
g_message ("\t\tlength: %4d string: \"%s\"",
|
||||
event->key.length, event->key.string);
|
||||
}
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
return;
|
||||
@@ -724,70 +718,6 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
|
||||
return return_val;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_x11_event_translate_keyboard_string (GdkEventKey *event)
|
||||
{
|
||||
gunichar c = 0;
|
||||
gchar buf[7];
|
||||
|
||||
/* Fill in event->string crudely, since various programs
|
||||
* depend on it.
|
||||
*/
|
||||
event->string = NULL;
|
||||
|
||||
if (event->keyval != GDK_KEY_VoidSymbol)
|
||||
c = gdk_keyval_to_unicode (event->keyval);
|
||||
|
||||
if (c)
|
||||
{
|
||||
gsize bytes_written;
|
||||
gint len;
|
||||
|
||||
/* Apply the control key - Taken from Xlib
|
||||
*/
|
||||
if (event->state & GDK_CONTROL_MASK)
|
||||
{
|
||||
if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F;
|
||||
else if (c == '2')
|
||||
{
|
||||
event->string = g_memdup ("\0\0", 2);
|
||||
event->length = 1;
|
||||
buf[0] = '\0';
|
||||
return;
|
||||
}
|
||||
else if (c >= '3' && c <= '7') c -= ('3' - '\033');
|
||||
else if (c == '8') c = '\177';
|
||||
else if (c == '/') c = '_' & 0x1F;
|
||||
}
|
||||
|
||||
len = g_unichar_to_utf8 (c, buf);
|
||||
buf[len] = '\0';
|
||||
|
||||
event->string = g_locale_from_utf8 (buf, len,
|
||||
NULL, &bytes_written,
|
||||
NULL);
|
||||
if (event->string)
|
||||
event->length = bytes_written;
|
||||
}
|
||||
else if (event->keyval == GDK_KEY_Escape)
|
||||
{
|
||||
event->length = 1;
|
||||
event->string = g_strdup ("\033");
|
||||
}
|
||||
else if (event->keyval == GDK_KEY_Return ||
|
||||
event->keyval == GDK_KEY_KP_Enter)
|
||||
{
|
||||
event->length = 1;
|
||||
event->string = g_strdup ("\r");
|
||||
}
|
||||
|
||||
if (!event->string)
|
||||
{
|
||||
event->length = 0;
|
||||
event->string = g_strdup ("");
|
||||
}
|
||||
}
|
||||
|
||||
/* We only care about focus events that indicate that _this_
|
||||
* surface (not a ancestor or child) got or lost the focus
|
||||
*/
|
||||
|
||||
@@ -1104,8 +1104,7 @@ translate_axes (GdkDevice *device,
|
||||
gdouble *axes;
|
||||
gdouble *vals;
|
||||
|
||||
g_object_get (device, "n-axes", &n_axes, NULL);
|
||||
|
||||
n_axes = gdk_device_get_n_axes (device);
|
||||
axes = g_new0 (gdouble, n_axes);
|
||||
vals = valuators->values;
|
||||
|
||||
@@ -1472,8 +1471,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
||||
_gdk_x11_keymap_add_virt_mods (keymap, &state);
|
||||
event->key.state |= state;
|
||||
|
||||
_gdk_x11_event_translate_keyboard_string (&event->key);
|
||||
|
||||
if (ev->evtype == XI_KeyPress)
|
||||
set_user_time (event);
|
||||
|
||||
|
||||
@@ -848,9 +848,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
g_message ("unmap notify:\t\twindow: %ld",
|
||||
xevent->xmap.window));
|
||||
|
||||
event->any.type = GDK_UNMAP;
|
||||
event->any.surface = surface;
|
||||
|
||||
if (surface && !is_substructure)
|
||||
{
|
||||
/* If the WM supports the _NET_WM_STATE_HIDDEN hint, we do not want to
|
||||
@@ -885,6 +882,8 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
_gdk_x11_surface_grab_check_unmap (surface, xevent->xany.serial);
|
||||
}
|
||||
|
||||
return_val = FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case MapNotify:
|
||||
@@ -892,9 +891,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
g_message ("map notify:\t\twindow: %ld",
|
||||
xevent->xmap.window));
|
||||
|
||||
event->any.type = GDK_MAP;
|
||||
event->any.surface = surface;
|
||||
|
||||
if (surface && !is_substructure)
|
||||
{
|
||||
/* Unset iconified if it was set */
|
||||
@@ -907,6 +903,8 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
gdk_surface_thaw_toplevel_updates (surface);
|
||||
}
|
||||
|
||||
return_val = FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case ReparentNotify:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,7 @@
|
||||
#include "gdkclipboard-x11.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkdisplay-x11.h"
|
||||
#include "gdkdndprivate.h"
|
||||
#include "gdkdragprivate.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkintl.h"
|
||||
#include "gdkproperty.h"
|
||||
@@ -336,7 +336,7 @@ gdk_x11_drop_read_actions (GdkDrop *drop)
|
||||
{
|
||||
GdkX11Drop *drop_x11 = GDK_X11_DROP (drop);
|
||||
GdkDisplay *display = gdk_drop_get_display (drop);
|
||||
GdkDragContext *drag;
|
||||
GdkDrag *drag;
|
||||
GdkDragAction actions = GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK;
|
||||
Atom type;
|
||||
int format;
|
||||
@@ -398,7 +398,7 @@ gdk_x11_drop_read_actions (GdkDrop *drop)
|
||||
}
|
||||
else
|
||||
{
|
||||
actions = gdk_drag_context_get_actions (drag);
|
||||
actions = gdk_drag_get_actions (drag);
|
||||
drop_x11->xdnd_have_actions = TRUE;
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ xdnd_enter_filter (GdkSurface *surface,
|
||||
GdkX11Display *display_x11;
|
||||
GdkDrop *drop;
|
||||
GdkX11Drop *drop_x11;
|
||||
GdkDragContext *drag;
|
||||
GdkDrag *drag;
|
||||
GdkSeat *seat;
|
||||
gint i;
|
||||
Atom type;
|
||||
@@ -548,7 +548,7 @@ xdnd_enter_filter (GdkSurface *surface,
|
||||
print_target_list (content_formats);
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
|
||||
drag = gdk_x11_drag_context_find (display, source_window, GDK_SURFACE_XID (surface));
|
||||
drag = gdk_x11_drag_find (display, source_window, GDK_SURFACE_XID (surface));
|
||||
|
||||
drop_x11 = g_object_new (GDK_TYPE_X11_DROP,
|
||||
"device", gdk_seat_get_pointer (seat),
|
||||
@@ -768,7 +768,7 @@ gdk_x11_drop_status (GdkDrop *drop,
|
||||
|
||||
if (gdk_drop_get_drag (drop))
|
||||
{
|
||||
gdk_x11_drag_context_handle_status (display, &xev);
|
||||
gdk_x11_drag_handle_status (display, &xev);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -821,7 +821,7 @@ gdk_x11_drop_finish (GdkDrop *drop,
|
||||
|
||||
if (gdk_drop_get_drag (drop))
|
||||
{
|
||||
gdk_x11_drag_context_handle_status (display, &xev);
|
||||
gdk_x11_drag_handle_status (display, &xev);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -849,7 +849,7 @@ gdk_x11_drop_class_init (GdkX11DropClass *klass)
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_drop_init (GdkX11Drop *context)
|
||||
gdk_x11_drop_init (GdkX11Drop *drag)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+11
-13
@@ -166,8 +166,6 @@ void gdk_x11_device_xi2_store_axes (GdkX11DeviceXI2 *device,
|
||||
gint n_axes);
|
||||
#endif
|
||||
|
||||
void _gdk_x11_event_translate_keyboard_string (GdkEventKey *event);
|
||||
|
||||
GdkAtom _gdk_x11_display_manager_atom_intern (GdkDisplayManager *manager,
|
||||
const gchar *atom_name,
|
||||
gboolean copy_name);
|
||||
@@ -196,16 +194,16 @@ Atom _gdk_x11_get_xatom_for_display_printf (GdkDisplay *display,
|
||||
const gchar *format,
|
||||
...) G_GNUC_PRINTF (2, 3);
|
||||
|
||||
GdkDragContext *gdk_x11_drag_context_find (GdkDisplay *display,
|
||||
Window source_xid,
|
||||
Window dest_xid);
|
||||
void gdk_x11_drag_context_handle_status (GdkDisplay *display,
|
||||
const XEvent *xevent);
|
||||
void gdk_x11_drag_context_handle_finished (GdkDisplay *display,
|
||||
const XEvent *xevent);
|
||||
void gdk_x11_drop_read_actions (GdkDrop *drop);
|
||||
gboolean gdk_x11_drop_filter (GdkSurface *surface,
|
||||
const XEvent *xevent);
|
||||
GdkDrag *gdk_x11_drag_find (GdkDisplay *display,
|
||||
Window source_xid,
|
||||
Window dest_xid);
|
||||
void gdk_x11_drag_handle_status (GdkDisplay *display,
|
||||
const XEvent *xevent);
|
||||
void gdk_x11_drag_handle_finished (GdkDisplay *display,
|
||||
const XEvent *xevent);
|
||||
void gdk_x11_drop_read_actions (GdkDrop *drop);
|
||||
gboolean gdk_x11_drop_filter (GdkSurface *surface,
|
||||
const XEvent *xevent);
|
||||
|
||||
typedef struct _GdkSurfaceCache GdkSurfaceCache;
|
||||
|
||||
@@ -225,7 +223,7 @@ void _gdk_x11_cursor_display_finalize (GdkDisplay *display);
|
||||
|
||||
void _gdk_x11_surface_register_dnd (GdkSurface *window);
|
||||
|
||||
GdkDragContext * _gdk_x11_surface_drag_begin (GdkSurface *window,
|
||||
GdkDrag * _gdk_x11_surface_drag_begin (GdkSurface *window,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider *content,
|
||||
GdkDragAction actions,
|
||||
|
||||
+31
-39
@@ -880,16 +880,8 @@ _gdk_x11_display_create_surface_impl (GdkDisplay *display,
|
||||
{
|
||||
class = InputOutput;
|
||||
|
||||
if (gdk_display_is_rgba (display))
|
||||
{
|
||||
xattributes.background_pixel = 0;
|
||||
xattributes_mask |= CWBackPixel;
|
||||
}
|
||||
else
|
||||
{
|
||||
xattributes.background_pixmap = None;
|
||||
xattributes_mask |= CWBackPixmap;
|
||||
}
|
||||
xattributes.background_pixmap = None;
|
||||
xattributes_mask |= CWBackPixmap;
|
||||
|
||||
xattributes.border_pixel = BlackPixel (xdisplay, x11_screen->screen_num);
|
||||
xattributes_mask |= CWBorderPixel;
|
||||
@@ -1292,35 +1284,6 @@ gdk_surface_x11_show (GdkSurface *surface, gboolean already_mapped)
|
||||
gdk_x11_surface_apply_fullscreen_mode (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_surface_x11_hide (GdkSurface *surface)
|
||||
{
|
||||
/* We'll get the unmap notify eventually, and handle it then,
|
||||
* but checking here makes things more consistent if we are
|
||||
* just doing stuff ourself.
|
||||
*/
|
||||
_gdk_x11_surface_grab_check_unmap (surface,
|
||||
NextRequest (GDK_SURFACE_XDISPLAY (surface)));
|
||||
|
||||
/* You can't simply unmap toplevel surfaces. */
|
||||
switch (surface->surface_type)
|
||||
{
|
||||
case GDK_SURFACE_TOPLEVEL:
|
||||
case GDK_SURFACE_TEMP: /* ? */
|
||||
gdk_surface_withdraw (surface);
|
||||
return;
|
||||
|
||||
case GDK_SURFACE_CHILD:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
_gdk_surface_clear_update_area (surface);
|
||||
|
||||
XUnmapWindow (GDK_SURFACE_XDISPLAY (surface),
|
||||
GDK_SURFACE_XID (surface));
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_surface_x11_withdraw (GdkSurface *surface)
|
||||
{
|
||||
@@ -1338,6 +1301,35 @@ gdk_surface_x11_withdraw (GdkSurface *surface)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_surface_x11_hide (GdkSurface *surface)
|
||||
{
|
||||
/* We'll get the unmap notify eventually, and handle it then,
|
||||
* but checking here makes things more consistent if we are
|
||||
* just doing stuff ourself.
|
||||
*/
|
||||
_gdk_x11_surface_grab_check_unmap (surface,
|
||||
NextRequest (GDK_SURFACE_XDISPLAY (surface)));
|
||||
|
||||
/* You can't simply unmap toplevel surfaces. */
|
||||
switch (surface->surface_type)
|
||||
{
|
||||
case GDK_SURFACE_TOPLEVEL:
|
||||
case GDK_SURFACE_TEMP: /* ? */
|
||||
gdk_surface_x11_withdraw (surface);
|
||||
return;
|
||||
|
||||
case GDK_SURFACE_CHILD:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
_gdk_surface_clear_update_area (surface);
|
||||
|
||||
XUnmapWindow (GDK_SURFACE_XDISPLAY (surface),
|
||||
GDK_SURFACE_XID (surface));
|
||||
}
|
||||
|
||||
static inline void
|
||||
surface_x11_move (GdkSurface *surface,
|
||||
gint x,
|
||||
|
||||
@@ -27,7 +27,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceManagerCore, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceManagerXI2, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceXI2, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Display, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DragContext, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Drag, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11GLContext, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Keymap, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Screen, g_object_unref)
|
||||
|
||||
+11
-11
@@ -26,23 +26,23 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_X11_DRAG_CONTEXT (gdk_x11_drag_context_get_type ())
|
||||
#define GDK_X11_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_X11_DRAG_CONTEXT, GdkX11DragContext))
|
||||
#define GDK_X11_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_X11_DRAG_CONTEXT, GdkX11DragContextClass))
|
||||
#define GDK_IS_X11_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_X11_DRAG_CONTEXT))
|
||||
#define GDK_IS_X11_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_X11_DRAG_CONTEXT))
|
||||
#define GDK_X11_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_X11_DRAG_CONTEXT, GdkX11DragContextClass))
|
||||
#define GDK_TYPE_X11_DRAG (gdk_x11_drag_get_type ())
|
||||
#define GDK_X11_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_X11_DRAG, GdkX11Drag))
|
||||
#define GDK_X11_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_X11_DRAG, GdkX11DragClass))
|
||||
#define GDK_IS_X11_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_X11_DRAG))
|
||||
#define GDK_IS_X11_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_X11_DRAG))
|
||||
#define GDK_X11_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_X11_DRAG, GdkX11DragClass))
|
||||
|
||||
#ifdef GDK_COMPILATION
|
||||
typedef struct _GdkX11DragContext GdkX11DragContext;
|
||||
typedef struct _GdkX11Drag GdkX11Drag;
|
||||
#else
|
||||
typedef GdkDragContext GdkX11DragContext;
|
||||
typedef GdkDrag GdkX11Drag;
|
||||
#endif
|
||||
typedef struct _GdkX11DragContextClass GdkX11DragContextClass;
|
||||
typedef struct _GdkX11DragClass GdkX11DragClass;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gdk_x11_drag_context_get_type (void);
|
||||
GType gdk_x11_drag_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_X11_DRAG_CONTEXT_H__ */
|
||||
#endif /* __GDK_X11_DRAG_H__ */
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ gdk_x11_sources = files([
|
||||
'gdkdevicemanager-x11.c',
|
||||
'gdkdevicemanager-xi2.c',
|
||||
'gdkdisplay-x11.c',
|
||||
'gdkdnd-x11.c',
|
||||
'gdkdrag-x11.c',
|
||||
'gdkdrop-x11.c',
|
||||
'gdkeventsource.c',
|
||||
'gdkeventtranslator.c',
|
||||
@@ -70,7 +70,7 @@ gdk_x11_deps = [
|
||||
xinerama_dep,
|
||||
]
|
||||
|
||||
libgdk_x11 = static_library('gdk-x11',
|
||||
libgdk_x11 = static_library('gdk-x11', gdkmarshal_h,
|
||||
gdk_x11_sources, gdkconfig, gdkenum_h,
|
||||
include_directories: [ confinc, gdkinc, ],
|
||||
c_args: [
|
||||
|
||||
+97
-71
@@ -13,6 +13,7 @@
|
||||
#include "gskglglyphcacheprivate.h"
|
||||
#include "gskglrenderopsprivate.h"
|
||||
#include "gskcairoblurprivate.h"
|
||||
#include "gskglshadowcacheprivate.h"
|
||||
|
||||
#include "gskprivate.h"
|
||||
|
||||
@@ -53,7 +54,6 @@
|
||||
glGetUniformLocation(program_ptr->id, "u_" #uniform_basename);\
|
||||
}G_STMT_END
|
||||
|
||||
|
||||
static void G_GNUC_UNUSED
|
||||
print_render_node_tree (GskRenderNode *root, int level)
|
||||
{
|
||||
@@ -266,6 +266,7 @@ struct _GskGLRenderer
|
||||
GArray *render_ops;
|
||||
|
||||
GskGLGlyphCache glyph_cache;
|
||||
GskGLShadowCache shadow_cache;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
struct {
|
||||
@@ -321,13 +322,19 @@ render_fallback_node (GskGLRenderer *self,
|
||||
const GskQuadVertex *vertex_data)
|
||||
{
|
||||
const float scale = ops_get_scale (builder);
|
||||
const int surface_width = ceilf (node->bounds.size.width) * scale;
|
||||
const int surface_height = ceilf (node->bounds.size.height) * scale;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
int texture_id;
|
||||
|
||||
if (surface_width <= 0 ||
|
||||
surface_height <= 0)
|
||||
return;
|
||||
|
||||
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
||||
ceilf (node->bounds.size.width) * scale,
|
||||
ceilf (node->bounds.size.height) * scale);
|
||||
surface_width,
|
||||
surface_height);
|
||||
cairo_surface_set_device_scale (surface, scale, scale);
|
||||
cr = cairo_create (surface);
|
||||
|
||||
@@ -349,8 +356,8 @@ render_fallback_node (GskGLRenderer *self,
|
||||
|
||||
/* Upload the Cairo surface to a GL texture */
|
||||
texture_id = gsk_gl_driver_create_texture (self->gl_driver,
|
||||
cairo_image_surface_get_width (surface),
|
||||
cairo_image_surface_get_height (surface));
|
||||
surface_width,
|
||||
surface_height);
|
||||
|
||||
gsk_gl_driver_bind_source_texture (self->gl_driver, texture_id);
|
||||
gsk_gl_driver_init_texture_with_surface (self->gl_driver,
|
||||
@@ -378,8 +385,8 @@ render_text_node (GskGLRenderer *self,
|
||||
guint num_glyphs = gsk_text_node_get_num_glyphs (node);
|
||||
int i;
|
||||
int x_position = 0;
|
||||
int x = gsk_text_node_get_x (node) + builder->dx;
|
||||
int y = gsk_text_node_get_y (node) + builder->dy;
|
||||
float x = gsk_text_node_get_x (node) + builder->dx;
|
||||
float y = gsk_text_node_get_y (node) + builder->dy;
|
||||
|
||||
/* If the font has color glyphs, we don't need to recolor anything */
|
||||
if (!force_color && font_has_color_glyphs (font))
|
||||
@@ -398,7 +405,7 @@ render_text_node (GskGLRenderer *self,
|
||||
{
|
||||
const PangoGlyphInfo *gi = &glyphs[i];
|
||||
const GskGLCachedGlyph *glyph;
|
||||
int glyph_x, glyph_y, glyph_w, glyph_h;
|
||||
float glyph_x, glyph_y, glyph_w, glyph_h;
|
||||
float tx, ty, tx2, ty2;
|
||||
double cx;
|
||||
double cy;
|
||||
@@ -1067,10 +1074,8 @@ render_outset_shadow_node (GskGLRenderer *self,
|
||||
graphene_matrix_t prev_modelview;
|
||||
graphene_rect_t prev_viewport;
|
||||
graphene_matrix_t item_proj;
|
||||
GskRoundedRect prev_clip, blit_clip;
|
||||
int prev_render_target;
|
||||
int texture_id, render_target;
|
||||
int blurred_texture_id, blurred_render_target;
|
||||
int blurred_texture_id;
|
||||
int cached_tid;
|
||||
|
||||
/* offset_outline is the minimal outline we need to draw the given drop shadow,
|
||||
* enlarged by the spread and offset by the blur radius. */
|
||||
@@ -1092,77 +1097,97 @@ render_outset_shadow_node (GskGLRenderer *self,
|
||||
texture_width = offset_outline.bounds.size.width + blur_extra;
|
||||
texture_height = offset_outline.bounds.size.height + blur_extra;
|
||||
|
||||
texture_id = gsk_gl_driver_create_texture (self->gl_driver, texture_width, texture_height);
|
||||
gsk_gl_driver_bind_source_texture (self->gl_driver, texture_id);
|
||||
gsk_gl_driver_init_texture_empty (self->gl_driver, texture_id);
|
||||
render_target = gsk_gl_driver_create_render_target (self->gl_driver, texture_id, FALSE, FALSE);
|
||||
cached_tid = gsk_gl_shadow_cache_get_texture_id (&self->shadow_cache,
|
||||
self->gl_driver,
|
||||
&offset_outline,
|
||||
blur_radius);
|
||||
if (cached_tid == 0)
|
||||
{
|
||||
int texture_id, render_target;
|
||||
int blurred_render_target;
|
||||
int prev_render_target;
|
||||
GskRoundedRect prev_clip, blit_clip;
|
||||
|
||||
texture_id = gsk_gl_driver_create_texture (self->gl_driver, texture_width, texture_height);
|
||||
gsk_gl_driver_bind_source_texture (self->gl_driver, texture_id);
|
||||
gsk_gl_driver_init_texture_empty (self->gl_driver, texture_id);
|
||||
render_target = gsk_gl_driver_create_render_target (self->gl_driver, texture_id, FALSE, FALSE);
|
||||
|
||||
|
||||
graphene_matrix_init_ortho (&item_proj,
|
||||
0, texture_width, 0, texture_height,
|
||||
ORTHO_NEAR_PLANE, ORTHO_FAR_PLANE);
|
||||
graphene_matrix_scale (&item_proj, 1, -1, 1);
|
||||
graphene_matrix_init_identity (&identity);
|
||||
graphene_matrix_init_ortho (&item_proj,
|
||||
0, texture_width, 0, texture_height,
|
||||
ORTHO_NEAR_PLANE, ORTHO_FAR_PLANE);
|
||||
graphene_matrix_scale (&item_proj, 1, -1, 1);
|
||||
graphene_matrix_init_identity (&identity);
|
||||
|
||||
prev_render_target = ops_set_render_target (builder, render_target);
|
||||
op.op = OP_CLEAR;
|
||||
ops_add (builder, &op);
|
||||
prev_projection = ops_set_projection (builder, &item_proj);
|
||||
prev_modelview = ops_set_modelview (builder, &identity);
|
||||
prev_viewport = ops_set_viewport (builder, &GRAPHENE_RECT_INIT (0, 0, texture_width, texture_height));
|
||||
prev_render_target = ops_set_render_target (builder, render_target);
|
||||
op.op = OP_CLEAR;
|
||||
ops_add (builder, &op);
|
||||
prev_projection = ops_set_projection (builder, &item_proj);
|
||||
prev_modelview = ops_set_modelview (builder, &identity);
|
||||
prev_viewport = ops_set_viewport (builder, &GRAPHENE_RECT_INIT (0, 0, texture_width, texture_height));
|
||||
|
||||
/* Draw outline */
|
||||
ops_set_program (builder, &self->color_program);
|
||||
prev_clip = ops_set_clip (builder, &offset_outline);
|
||||
ops_set_color (builder, gsk_outset_shadow_node_peek_color (node));
|
||||
ops_draw (builder, (GskQuadVertex[GL_N_VERTICES]) {
|
||||
{ { 0, }, { 0, 1 }, },
|
||||
{ { 0, texture_height }, { 0, 0 }, },
|
||||
{ { texture_width, }, { 1, 1 }, },
|
||||
/* Draw outline */
|
||||
ops_set_program (builder, &self->color_program);
|
||||
prev_clip = ops_set_clip (builder, &offset_outline);
|
||||
ops_set_color (builder, gsk_outset_shadow_node_peek_color (node));
|
||||
ops_draw (builder, (GskQuadVertex[GL_N_VERTICES]) {
|
||||
{ { 0, }, { 0, 1 }, },
|
||||
{ { 0, texture_height }, { 0, 0 }, },
|
||||
{ { texture_width, }, { 1, 1 }, },
|
||||
|
||||
{ { texture_width, texture_height }, { 1, 0 }, },
|
||||
{ { 0, texture_height }, { 0, 0 }, },
|
||||
{ { texture_width, }, { 1, 1 }, },
|
||||
});
|
||||
{ { texture_width, texture_height }, { 1, 0 }, },
|
||||
{ { 0, texture_height }, { 0, 0 }, },
|
||||
{ { texture_width, }, { 1, 1 }, },
|
||||
});
|
||||
|
||||
blurred_texture_id = gsk_gl_driver_create_texture (self->gl_driver, texture_width, texture_height);
|
||||
gsk_gl_driver_bind_source_texture (self->gl_driver, blurred_texture_id);
|
||||
gsk_gl_driver_init_texture_empty (self->gl_driver, blurred_texture_id);
|
||||
blurred_render_target = gsk_gl_driver_create_render_target (self->gl_driver, blurred_texture_id, TRUE, TRUE);
|
||||
blurred_texture_id = gsk_gl_driver_create_permanent_texture (self->gl_driver, texture_width, texture_height);
|
||||
gsk_gl_driver_bind_source_texture (self->gl_driver, blurred_texture_id);
|
||||
gsk_gl_driver_init_texture_empty (self->gl_driver, blurred_texture_id);
|
||||
blurred_render_target = gsk_gl_driver_create_render_target (self->gl_driver, blurred_texture_id, TRUE, TRUE);
|
||||
|
||||
ops_set_render_target (builder, blurred_render_target);
|
||||
op.op = OP_CLEAR;
|
||||
ops_add (builder, &op);
|
||||
ops_set_render_target (builder, blurred_render_target);
|
||||
op.op = OP_CLEAR;
|
||||
ops_add (builder, &op);
|
||||
|
||||
gsk_rounded_rect_init_from_rect (&blit_clip,
|
||||
&GRAPHENE_RECT_INIT (0, 0, texture_width, texture_height), 0.0f);
|
||||
gsk_rounded_rect_init_from_rect (&blit_clip,
|
||||
&GRAPHENE_RECT_INIT (0, 0, texture_width, texture_height), 0.0f);
|
||||
|
||||
ops_set_program (builder, &self->blur_program);
|
||||
op.op = OP_CHANGE_BLUR;
|
||||
op.blur.size.width = texture_width;
|
||||
op.blur.size.height = texture_height;
|
||||
op.blur.radius = blur_radius;
|
||||
ops_add (builder, &op);
|
||||
ops_set_program (builder, &self->blur_program);
|
||||
op.op = OP_CHANGE_BLUR;
|
||||
op.blur.size.width = texture_width;
|
||||
op.blur.size.height = texture_height;
|
||||
op.blur.radius = blur_radius;
|
||||
ops_add (builder, &op);
|
||||
|
||||
ops_set_clip (builder, &blit_clip);
|
||||
ops_set_texture (builder, texture_id);
|
||||
ops_draw (builder, (GskQuadVertex[GL_N_VERTICES]) {
|
||||
{ { 0, 0 }, { 0, 1 }, },
|
||||
{ { 0, texture_height }, { 0, 0 }, },
|
||||
{ { texture_width, 0 }, { 1, 1 }, },
|
||||
ops_set_clip (builder, &blit_clip);
|
||||
ops_set_texture (builder, texture_id);
|
||||
ops_draw (builder, (GskQuadVertex[GL_N_VERTICES]) {
|
||||
{ { 0, 0 }, { 0, 1 }, },
|
||||
{ { 0, texture_height }, { 0, 0 }, },
|
||||
{ { texture_width, 0 }, { 1, 1 }, },
|
||||
|
||||
{ { texture_width, texture_height }, { 1, 0 }, },
|
||||
{ { 0, texture_height }, { 0, 0 }, },
|
||||
{ { texture_width, 0 }, { 1, 1 }, },
|
||||
});
|
||||
{ { texture_width, texture_height }, { 1, 0 }, },
|
||||
{ { 0, texture_height }, { 0, 0 }, },
|
||||
{ { texture_width, 0 }, { 1, 1 }, },
|
||||
});
|
||||
|
||||
|
||||
ops_set_clip (builder, &prev_clip);
|
||||
ops_set_clip (builder, &prev_clip);
|
||||
ops_set_viewport (builder, &prev_viewport);
|
||||
ops_set_modelview (builder, &prev_modelview);
|
||||
ops_set_projection (builder, &prev_projection);
|
||||
ops_set_render_target (builder, prev_render_target);
|
||||
|
||||
ops_set_viewport (builder, &prev_viewport);
|
||||
ops_set_modelview (builder, &prev_modelview);
|
||||
ops_set_projection (builder, &prev_projection);
|
||||
ops_set_render_target (builder, prev_render_target);
|
||||
gsk_gl_shadow_cache_commit (&self->shadow_cache,
|
||||
&offset_outline,
|
||||
blur_radius,
|
||||
blurred_texture_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
blurred_texture_id = cached_tid;
|
||||
}
|
||||
|
||||
ops_set_program (builder, &self->outset_shadow_program);
|
||||
ops_set_texture (builder, blurred_texture_id);
|
||||
@@ -1387,8 +1412,6 @@ render_outset_shadow_node (GskGLRenderer *self,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ops_set_clip (builder, &prev_clip);
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -2000,6 +2023,7 @@ gsk_gl_renderer_realize (GskRenderer *renderer,
|
||||
return FALSE;
|
||||
|
||||
gsk_gl_glyph_cache_init (&self->glyph_cache, renderer, self->gl_driver);
|
||||
gsk_gl_shadow_cache_init (&self->shadow_cache);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -2024,6 +2048,7 @@ gsk_gl_renderer_unrealize (GskRenderer *renderer)
|
||||
glDeleteProgram (self->programs[i].id);
|
||||
|
||||
gsk_gl_glyph_cache_free (&self->glyph_cache);
|
||||
gsk_gl_shadow_cache_free (&self->shadow_cache, self->gl_driver);
|
||||
|
||||
g_clear_object (&self->gl_profiler);
|
||||
g_clear_object (&self->gl_driver);
|
||||
@@ -2518,6 +2543,7 @@ gsk_gl_renderer_do_render (GskRenderer *renderer,
|
||||
|
||||
gsk_gl_driver_begin_frame (self->gl_driver);
|
||||
gsk_gl_glyph_cache_begin_frame (&self->glyph_cache);
|
||||
gsk_gl_shadow_cache_begin_frame (&self->shadow_cache, self->gl_driver);
|
||||
|
||||
memset (&render_op_builder, 0, sizeof (render_op_builder));
|
||||
render_op_builder.renderer = self;
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
|
||||
#include "gskglshadowcacheprivate.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GskRoundedRect outline;
|
||||
float blur_radius;
|
||||
} CacheKey;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GskRoundedRect outline;
|
||||
float blur_radius;
|
||||
|
||||
int texture_id;
|
||||
guint used : 1;
|
||||
} CacheItem;
|
||||
|
||||
static gboolean
|
||||
key_equal (const void *x,
|
||||
const void *y)
|
||||
{
|
||||
const CacheKey *a = x;
|
||||
const CacheKey *b = y;
|
||||
|
||||
return graphene_size_equal (&a->outline.corner[0], &b->outline.corner[0]) &&
|
||||
graphene_size_equal (&a->outline.corner[1], &b->outline.corner[1]) &&
|
||||
graphene_size_equal (&a->outline.corner[2], &b->outline.corner[2]) &&
|
||||
graphene_size_equal (&a->outline.corner[3], &b->outline.corner[3]) &&
|
||||
graphene_rect_equal (&a->outline.bounds, &b->outline.bounds) &&
|
||||
a->blur_radius == b->blur_radius;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gl_shadow_cache_init (GskGLShadowCache *self)
|
||||
{
|
||||
self->textures = g_array_new (FALSE, TRUE, sizeof (CacheItem));
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gl_shadow_cache_free (GskGLShadowCache *self,
|
||||
GskGLDriver *gl_driver)
|
||||
{
|
||||
guint i, p;
|
||||
|
||||
for (i = 0, p = self->textures->len; i < p; i ++)
|
||||
{
|
||||
const CacheItem *item = &g_array_index (self->textures, CacheItem, i);
|
||||
|
||||
gsk_gl_driver_destroy_texture (gl_driver, item->texture_id);
|
||||
}
|
||||
|
||||
g_array_free (self->textures, TRUE);
|
||||
self->textures = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gl_shadow_cache_begin_frame (GskGLShadowCache *self,
|
||||
GskGLDriver *gl_driver)
|
||||
{
|
||||
guint i, p;
|
||||
|
||||
/* We remove all textures with used = FALSE since those have not been used in the
|
||||
* last frame. For all others, we reset the `used` value to FALSE instead and see
|
||||
* if they end up with TRUE in the next call to begin_frame. */
|
||||
for (i = 0, p = self->textures->len; i < p; i ++)
|
||||
{
|
||||
CacheItem *item = &g_array_index (self->textures, CacheItem, i);
|
||||
|
||||
if (!item->used)
|
||||
{
|
||||
gsk_gl_driver_destroy_texture (gl_driver, item->texture_id);
|
||||
g_array_remove_index_fast (self->textures, i);
|
||||
p --;
|
||||
i --;
|
||||
}
|
||||
else
|
||||
{
|
||||
item->used = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX
|
||||
* The offset origin should always be at 0/0, or the blur radius should just go
|
||||
* away since it defines the origin position anyway?
|
||||
*/
|
||||
int
|
||||
gsk_gl_shadow_cache_get_texture_id (GskGLShadowCache *self,
|
||||
GskGLDriver *gl_driver,
|
||||
const GskRoundedRect *shadow_rect,
|
||||
float blur_radius)
|
||||
{
|
||||
CacheItem *item= NULL;
|
||||
guint i;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert (gl_driver != NULL);
|
||||
g_assert (shadow_rect != NULL);
|
||||
|
||||
for (i = 0; i < self->textures->len; i ++)
|
||||
{
|
||||
CacheItem *k = &g_array_index (self->textures, CacheItem, i);
|
||||
|
||||
if (key_equal (&(CacheKey){*shadow_rect, blur_radius},
|
||||
&(CacheKey){k->outline, k->blur_radius}))
|
||||
{
|
||||
item = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (item == NULL)
|
||||
return 0;
|
||||
|
||||
item->used = TRUE;
|
||||
|
||||
g_assert (item->texture_id != 0);
|
||||
|
||||
return item->texture_id;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gl_shadow_cache_commit (GskGLShadowCache *self,
|
||||
const GskRoundedRect *shadow_rect,
|
||||
float blur_radius,
|
||||
int texture_id)
|
||||
{
|
||||
CacheItem *item;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert (shadow_rect != NULL);
|
||||
g_assert (texture_id > 0);
|
||||
|
||||
g_array_set_size (self->textures, self->textures->len + 1);
|
||||
item = &g_array_index (self->textures, CacheItem, self->textures->len - 1);
|
||||
|
||||
item->outline = *shadow_rect;
|
||||
item->blur_radius = blur_radius;
|
||||
item->used = TRUE;
|
||||
item->texture_id = texture_id;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
|
||||
#ifndef __GSK_GL_SHADOW_CACHE_H__
|
||||
#define __GSK_GL_SHADOW_CACHE_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include "gskgldriverprivate.h"
|
||||
#include "gskroundedrect.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GArray *textures;
|
||||
} GskGLShadowCache;
|
||||
|
||||
|
||||
void gsk_gl_shadow_cache_init (GskGLShadowCache *self);
|
||||
void gsk_gl_shadow_cache_free (GskGLShadowCache *self,
|
||||
GskGLDriver *gl_driver);
|
||||
void gsk_gl_shadow_cache_begin_frame (GskGLShadowCache *self,
|
||||
GskGLDriver *gl_driver);
|
||||
int gsk_gl_shadow_cache_get_texture_id (GskGLShadowCache *self,
|
||||
GskGLDriver *gl_driver,
|
||||
const GskRoundedRect *shadow_rect,
|
||||
float blur_radius);
|
||||
void gsk_gl_shadow_cache_commit (GskGLShadowCache *self,
|
||||
const GskRoundedRect *shadow_rect,
|
||||
float blur_radius,
|
||||
int texture_id);
|
||||
|
||||
|
||||
#endif
|
||||
+2
-2
@@ -448,8 +448,8 @@ gsk_renderer_render_texture (GskRenderer *renderer,
|
||||
* gsk_renderer_render:
|
||||
* @renderer: a #GskRenderer
|
||||
* @root: a #GskRenderNode
|
||||
* @region: the #cairo_region_t that must be redrawn or %NULL for the whole
|
||||
* window
|
||||
* @region: (nullable): the #cairo_region_t that must be redrawn or %NULL
|
||||
* for the whole window
|
||||
*
|
||||
* Renders the scene graph, described by a tree of #GskRenderNode instances,
|
||||
* ensuring that the given @region gets redrawn.
|
||||
|
||||
+4
-4
@@ -205,14 +205,14 @@ const graphene_matrix_t *
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_offset_node_new (GskRenderNode *child,
|
||||
double x_offset,
|
||||
double y_offset);
|
||||
float x_offset,
|
||||
float y_offset);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_offset_node_get_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
double gsk_offset_node_get_x_offset (GskRenderNode *node);
|
||||
float gsk_offset_node_get_x_offset (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
double gsk_offset_node_get_y_offset (GskRenderNode *node);
|
||||
float gsk_offset_node_get_y_offset (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_opacity_node_new (GskRenderNode *child,
|
||||
|
||||
+20
-14
@@ -2561,8 +2561,8 @@ struct _GskOffsetNode
|
||||
GskRenderNode render_node;
|
||||
|
||||
GskRenderNode *child;
|
||||
double x_offset;
|
||||
double y_offset;
|
||||
float x_offset;
|
||||
float y_offset;
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -2694,8 +2694,8 @@ static const GskRenderNodeClass GSK_OFFSET_NODE_CLASS = {
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_offset_node_new (GskRenderNode *child,
|
||||
double x_offset,
|
||||
double y_offset)
|
||||
float x_offset,
|
||||
float y_offset)
|
||||
{
|
||||
GskOffsetNode *self;
|
||||
|
||||
@@ -2732,7 +2732,7 @@ gsk_offset_node_get_child (GskRenderNode *node)
|
||||
return self->child;
|
||||
}
|
||||
|
||||
double
|
||||
float
|
||||
gsk_offset_node_get_x_offset (GskRenderNode *node)
|
||||
{
|
||||
GskOffsetNode *self = (GskOffsetNode *) node;
|
||||
@@ -2742,7 +2742,7 @@ gsk_offset_node_get_x_offset (GskRenderNode *node)
|
||||
return self->x_offset;
|
||||
}
|
||||
|
||||
double
|
||||
float
|
||||
gsk_offset_node_get_y_offset (GskRenderNode *node)
|
||||
{
|
||||
GskOffsetNode *self = (GskOffsetNode *) node;
|
||||
@@ -3565,7 +3565,7 @@ gsk_clip_node_diff (GskRenderNode *node1,
|
||||
{
|
||||
cairo_region_t *sub;
|
||||
cairo_rectangle_int_t clip_rect;
|
||||
|
||||
|
||||
sub = cairo_region_create();
|
||||
gsk_render_node_diff (self1->child, self2->child, sub);
|
||||
rectangle_init_from_graphene (&clip_rect, &self1->clip);
|
||||
@@ -3573,8 +3573,10 @@ gsk_clip_node_diff (GskRenderNode *node1,
|
||||
cairo_region_union (region, sub);
|
||||
cairo_region_destroy (sub);
|
||||
}
|
||||
|
||||
gsk_render_node_diff_impossible (node1, node2, region);
|
||||
else
|
||||
{
|
||||
gsk_render_node_diff_impossible (node1, node2, region);
|
||||
}
|
||||
}
|
||||
|
||||
#define GSK_CLIP_NODE_VARIANT_TYPE "(dddduv)"
|
||||
@@ -3737,7 +3739,7 @@ gsk_rounded_clip_node_diff (GskRenderNode *node1,
|
||||
{
|
||||
cairo_region_t *sub;
|
||||
cairo_rectangle_int_t clip_rect;
|
||||
|
||||
|
||||
sub = cairo_region_create();
|
||||
gsk_render_node_diff (self1->child, self2->child, sub);
|
||||
rectangle_init_from_graphene (&clip_rect, &self1->clip.bounds);
|
||||
@@ -3745,8 +3747,10 @@ gsk_rounded_clip_node_diff (GskRenderNode *node1,
|
||||
cairo_region_union (region, sub);
|
||||
cairo_region_destroy (sub);
|
||||
}
|
||||
|
||||
gsk_render_node_diff_impossible (node1, node2, region);
|
||||
else
|
||||
{
|
||||
gsk_render_node_diff_impossible (node1, node2, region);
|
||||
}
|
||||
}
|
||||
|
||||
#define GSK_ROUNDED_CLIP_NODE_VARIANT_TYPE "(dddddddddddduv)"
|
||||
@@ -4262,8 +4266,10 @@ gsk_blend_node_diff (GskRenderNode *node1,
|
||||
gsk_render_node_diff (self1->top, self2->top, region);
|
||||
gsk_render_node_diff (self1->bottom, self2->bottom, region);
|
||||
}
|
||||
|
||||
gsk_render_node_diff_impossible (node1, node2, region);
|
||||
else
|
||||
{
|
||||
gsk_render_node_diff_impossible (node1, node2, region);
|
||||
}
|
||||
}
|
||||
|
||||
#define GSK_BLEND_NODE_VARIANT_TYPE "(uvuvu)"
|
||||
|
||||
@@ -50,7 +50,7 @@ G_BEGIN_DECLS
|
||||
* @bounds: the bounds of the rectangle
|
||||
* @corner: the size of the 4 rounded corners
|
||||
*
|
||||
* A rectanglular region with rounded corners.
|
||||
* A rectangular region with rounded corners.
|
||||
*
|
||||
* Application code should normalize rectangles using gsk_rounded_rect_normalize();
|
||||
* this function will ensure that the bounds of the rectanlge are normalized
|
||||
|
||||
+2
-1
@@ -41,7 +41,8 @@ gsk_private_sources = files([
|
||||
'gl/gskglglyphcache.c',
|
||||
'gl/gskglimage.c',
|
||||
'gl/gskgldriver.c',
|
||||
'gl/gskglrenderops.c'
|
||||
'gl/gskglrenderops.c',
|
||||
'gl/gskglshadowcache.c',
|
||||
])
|
||||
|
||||
gsk_public_headers = files([
|
||||
|
||||
@@ -1,15 +1,102 @@
|
||||
uniform mat4 uMVP;
|
||||
uniform sampler2D uSource;
|
||||
uniform sampler2D uMask;
|
||||
uniform float uAlpha;
|
||||
uniform sampler2D u_source;
|
||||
uniform sampler2D u_mask;
|
||||
uniform mat4 u_projection;
|
||||
uniform mat4 u_modelview;
|
||||
uniform float u_alpha;
|
||||
uniform int uBlendMode;
|
||||
uniform vec4 u_viewport;
|
||||
|
||||
// In GtkSnapshot coordinates
|
||||
uniform vec4 u_clip;
|
||||
uniform vec4 u_clip_corner_widths;
|
||||
uniform vec4 u_clip_corner_heights;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
|
||||
struct RoundedRect
|
||||
{
|
||||
vec4 bounds;
|
||||
vec4 corner_widths;
|
||||
vec4 corner_heights;
|
||||
};
|
||||
|
||||
float
|
||||
ellipsis_dist (vec2 p, vec2 radius)
|
||||
{
|
||||
if (radius == vec2(0, 0))
|
||||
return 0.0;
|
||||
|
||||
vec2 p0 = p / radius;
|
||||
vec2 p1 = 2.0 * p0 / radius;
|
||||
|
||||
return (dot(p0, p0) - 1.0) / length (p1);
|
||||
}
|
||||
|
||||
float
|
||||
ellipsis_coverage (vec2 point, vec2 center, vec2 radius)
|
||||
{
|
||||
float d = ellipsis_dist (point - center, radius);
|
||||
return clamp (0.5 - d, 0.0, 1.0);
|
||||
}
|
||||
|
||||
float
|
||||
rounded_rect_coverage (RoundedRect r, vec2 p)
|
||||
{
|
||||
if (p.x < r.bounds.x || p.y < r.bounds.y ||
|
||||
p.x >= r.bounds.z || p.y >= r.bounds.w)
|
||||
return 0.0;
|
||||
|
||||
vec2 rad_tl = vec2(r.corner_widths.x, r.corner_heights.x);
|
||||
vec2 rad_tr = vec2(r.corner_widths.y, r.corner_heights.y);
|
||||
vec2 rad_br = vec2(r.corner_widths.z, r.corner_heights.z);
|
||||
vec2 rad_bl = vec2(r.corner_widths.w, r.corner_heights.w);
|
||||
|
||||
vec2 ref_tl = r.bounds.xy + vec2( r.corner_widths.x, r.corner_heights.x);
|
||||
vec2 ref_tr = r.bounds.zy + vec2(-r.corner_widths.y, r.corner_heights.y);
|
||||
vec2 ref_br = r.bounds.zw + vec2(-r.corner_widths.z, -r.corner_heights.z);
|
||||
vec2 ref_bl = r.bounds.xw + vec2( r.corner_widths.w, -r.corner_heights.w);
|
||||
|
||||
float d_tl = ellipsis_coverage(p, ref_tl, rad_tl);
|
||||
float d_tr = ellipsis_coverage(p, ref_tr, rad_tr);
|
||||
float d_br = ellipsis_coverage(p, ref_br, rad_br);
|
||||
float d_bl = ellipsis_coverage(p, ref_bl, rad_bl);
|
||||
|
||||
vec4 corner_coverages = 1.0 - vec4(d_tl, d_tr, d_br, d_bl);
|
||||
|
||||
bvec4 is_out = bvec4(p.x < ref_tl.x && p.y < ref_tl.y,
|
||||
p.x > ref_tr.x && p.y < ref_tr.y,
|
||||
p.x > ref_br.x && p.y > ref_br.y,
|
||||
p.x < ref_bl.x && p.y > ref_bl.y);
|
||||
|
||||
return 1.0 - dot(vec4(is_out), corner_coverages);
|
||||
}
|
||||
|
||||
RoundedRect
|
||||
rounded_rect_shrink (RoundedRect r, vec4 amount)
|
||||
{
|
||||
vec4 new_bounds = r.bounds + vec4(1.0,1.0,-1.0,-1.0) * amount.wxyz;
|
||||
vec4 new_widths = max (r.corner_widths - amount.wyyw, 0.0);
|
||||
vec4 new_heights = max (r.corner_heights - amount.xxzz, 0.0);
|
||||
|
||||
return RoundedRect (new_bounds, new_widths, new_heights);
|
||||
}
|
||||
|
||||
vec4 Texture(sampler2D sampler, vec2 texCoords) {
|
||||
return texture2D(sampler, texCoords);
|
||||
}
|
||||
|
||||
void setOutputColor(vec4 color) {
|
||||
gl_FragColor = color;
|
||||
vec4 clipBounds = u_clip;
|
||||
vec4 f = gl_FragCoord;
|
||||
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
clipBounds.z = clipBounds.x + clipBounds.z;
|
||||
clipBounds.w = clipBounds.y + clipBounds.w;
|
||||
|
||||
RoundedRect r = RoundedRect(clipBounds, u_clip_corner_widths, u_clip_corner_heights);
|
||||
|
||||
gl_FragColor = color * rounded_rect_coverage(r, f.xy);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
uniform mat4 uMVP;
|
||||
uniform mat4 u_projection;
|
||||
uniform mat4 u_modelview;
|
||||
|
||||
attribute vec2 aPosition;
|
||||
attribute vec2 aUv;
|
||||
|
||||
@@ -147,7 +147,7 @@ gsk_vulkan_renderer_unrealize (GskRenderer *renderer)
|
||||
data->renderer = NULL;
|
||||
gdk_texture_clear_render_data (data->texture);
|
||||
}
|
||||
g_clear_pointer (&self->textures, (GDestroyNotify) g_slist_free);
|
||||
g_clear_pointer (&self->textures, g_slist_free);
|
||||
|
||||
g_clear_pointer (&self->render, gsk_vulkan_render_free);
|
||||
|
||||
|
||||
@@ -116,13 +116,11 @@ atk_key_event_from_gdk_event_key (GdkEventKey *key,
|
||||
GdkModifierType state;
|
||||
guint keyval;
|
||||
guint16 keycode;
|
||||
const char *string;
|
||||
|
||||
type = gdk_event_get_event_type ((GdkEvent *)key);
|
||||
gdk_event_get_state ((GdkEvent *)key, &state);
|
||||
gdk_event_get_keyval ((GdkEvent *)key, &keyval);
|
||||
gdk_event_get_keycode ((GdkEvent *)key, &keycode);
|
||||
gdk_event_get_string ((GdkEvent *)key, &string);
|
||||
|
||||
if (type == GDK_KEY_PRESS)
|
||||
event->type = ATK_KEY_EVENT_PRESS;
|
||||
@@ -133,14 +131,8 @@ atk_key_event_from_gdk_event_key (GdkEventKey *key,
|
||||
|
||||
event->state = state;
|
||||
event->keyval = keyval;
|
||||
if (string && string[0] &&
|
||||
(state & GDK_CONTROL_MASK ||
|
||||
g_unichar_isgraph (g_utf8_get_char (string))))
|
||||
event->string = (char *) string;
|
||||
else
|
||||
event->string = gdk_keyval_name (keyval);
|
||||
|
||||
event->length = strlen (string);
|
||||
event->string = gdk_keyval_name (keyval);
|
||||
event->length = strlen (event->string);
|
||||
event->keycode = keycode;
|
||||
event->timestamp = gdk_event_get_time ((GdkEvent *)key);
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 201 B |
Binary file not shown.
|
Before Width: | Height: | Size: 183 B |
Binary file not shown.
|
Before Width: | Height: | Size: 216 B |
Binary file not shown.
|
Before Width: | Height: | Size: 197 B |
Binary file not shown.
|
Before Width: | Height: | Size: 144 B |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user