Compare commits

..

1 Commits

Author SHA1 Message Date
Alex Samorukov b09ea5610d Fix minimize button on border-less windows, see #2345 2020-01-04 12:18:54 +00:00
442 changed files with 26273 additions and 31615 deletions
+1 -2
View File
@@ -13,7 +13,7 @@ stages:
- subprojects/pango/
fedora-x86_64: &fedora-x86_64-defaults
image: registry.gitlab.gnome.org/gnome/gtk/master:v9
image: registry.gitlab.gnome.org/gnome/gtk/master:v8
stage: build
script:
- bash -x ./.gitlab-ci/test-docker.sh
@@ -29,7 +29,6 @@ fedora-x86_64: &fedora-x86_64-defaults
- "${CI_PROJECT_DIR}/_build/report.html"
- "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*.png"
- "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*.png"
- "${CI_PROJECT_DIR}/_build/testsuite/css/output/*.syscap"
cache:
key: "$CI_JOB_NAME"
<<: *cache-paths
-1
View File
@@ -67,7 +67,6 @@ RUN dnf -y install \
python3-wheel \
redhat-rpm-config \
sassc \
sysprof-devel \
systemtap-sdt-devel \
vulkan-devel \
wayland-devel \
-1
View File
@@ -16,7 +16,6 @@ meson \
-Dwayland-backend=true \
-Dbroadway-backend=true \
-Dvulkan=yes \
-Dprofiler=true \
--werror \
${EXTRA_MESON_FLAGS:-} \
_build $srcdir
+1 -1
View File
@@ -174,7 +174,7 @@ maintainers review your contribution.
Each contribution is reviewed by the core developers of the GTK project.
The [CODEOWNERS](./docs/CODEOWNERS) document contains the list of core
The [CODE-OWNERS](./docs/CODE-OWNERS) document contains the list of core
contributors to GTK and the areas for which they are responsible; you
should ensure to receive their review and signoff on your changes.
+49 -74
View File
@@ -119,76 +119,48 @@ get_image_paintable (GtkImage *image)
}
static void
drag_begin (GtkDragSource *source,
GdkDrag *drag,
GtkWidget *widget)
drag_begin (GtkWidget *widget,
GdkDrag *drag,
gpointer data)
{
GdkPaintable *paintable;
paintable = get_image_paintable (GTK_IMAGE (widget));
if (paintable)
{
gtk_drag_source_set_icon (source, paintable, -2, -2);
gtk_drag_set_icon_paintable (drag, paintable, -2, -2);
g_object_unref (paintable);
}
}
static void
get_texture (GValue *value,
gpointer data)
void
drag_data_get (GtkWidget *widget,
GdkDrag *drag,
GtkSelectionData *selection_data,
guint info,
gpointer data)
{
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (data));
GdkPaintable *paintable;
paintable = get_image_paintable (GTK_IMAGE (widget));
if (GDK_IS_TEXTURE (paintable))
g_value_set_object (value, paintable);
}
static GdkContentProvider *
prepare_drag (GtkDragSource *source,
double x,
double y,
GtkWidget *image)
{
return gdk_content_provider_new_with_callback (GDK_TYPE_TEXTURE, get_texture, image);
gtk_selection_data_set_texture (selection_data, GDK_TEXTURE (paintable));
}
static void
got_texture (GObject *source,
GAsyncResult *result,
gpointer data)
drag_data_received (GtkWidget *widget,
GdkDrop *drop,
GtkSelectionData *selection_data,
gpointer data)
{
GdkDrop *drop = GDK_DROP (source);
GtkWidget *image = data;
const GValue *value;
GError *error = NULL;
value = gdk_drop_read_value_finish (drop, result, &error);
if (value)
if (gtk_selection_data_get_length (selection_data) > 0)
{
GdkTexture *texture = g_value_get_object (value);
gtk_image_set_from_paintable (GTK_IMAGE (image), GDK_PAINTABLE (texture));
}
else
{
g_print ("Failed to get data: %s\n", error->message);
g_error_free (error);
}
}
GdkTexture *texture;
static gboolean
drag_drop (GtkDropTarget *dest,
GdkDrop *drop,
int x,
int y,
GtkWidget *widget)
{
if (gdk_drop_has_value (drop, GDK_TYPE_TEXTURE))
{
gdk_drop_read_value_async (drop, GDK_TYPE_TEXTURE, G_PRIORITY_DEFAULT, NULL, got_texture, widget);
return TRUE;
texture = gtk_selection_data_get_texture (selection_data);
gtk_image_set_from_paintable (GTK_IMAGE (data), GDK_PAINTABLE (texture));
g_object_unref (texture);
}
return FALSE;
}
static void
@@ -199,8 +171,12 @@ copy_image (GSimpleAction *action,
GdkClipboard *clipboard = gtk_widget_get_clipboard (GTK_WIDGET (data));
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (data));
g_print ("copy image\n");
if (GDK_IS_TEXTURE (paintable))
gdk_clipboard_set_texture (clipboard, GDK_TEXTURE (paintable));
{
g_print ("set clipboard\n");
gdk_clipboard_set_texture (clipboard, GDK_TEXTURE (paintable));
}
if (paintable)
g_object_unref (paintable);
@@ -271,9 +247,6 @@ do_clipboard (GtkWidget *do_widget)
{ "paste", paste_image, NULL, NULL, NULL },
};
GActionGroup *actions;
GtkDragSource *source;
GtkDropTarget *dest;
GdkContentFormats *formats;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_display (GTK_WINDOW (window),
@@ -332,21 +305,22 @@ do_clipboard (GtkWidget *do_widget)
/* Create the first image */
image = gtk_image_new_from_icon_name ("dialog-warning");
gtk_image_set_pixel_size (GTK_IMAGE (image), 48);
gtk_container_add (GTK_CONTAINER (hbox), image);
/* make image a drag source */
source = gtk_drag_source_new ();
g_signal_connect (source, "prepare", G_CALLBACK (prepare_drag), NULL);
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
gtk_drag_source_add_image_targets (image);
g_signal_connect (image, "drag-begin",
G_CALLBACK (drag_begin), image);
g_signal_connect (image, "drag-data-get",
G_CALLBACK (drag_data_get), image);
/* accept drops on image */
formats = gdk_content_formats_new_for_gtype (GDK_TYPE_TEXTURE);
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL,
NULL, GDK_ACTION_COPY);
gtk_drag_dest_add_image_targets (image);
g_signal_connect (image, "drag-data-received",
G_CALLBACK (drag_data_received), image);
/* context menu on image */
gesture = gtk_gesture_click_new ();
@@ -363,21 +337,22 @@ do_clipboard (GtkWidget *do_widget)
/* Create the second image */
image = gtk_image_new_from_icon_name ("process-stop");
gtk_image_set_pixel_size (GTK_IMAGE (image), 48);
gtk_container_add (GTK_CONTAINER (hbox), image);
/* make image a drag source */
source = gtk_drag_source_new ();
g_signal_connect (source, "prepare", G_CALLBACK (prepare_drag), NULL);
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
gtk_drag_source_add_image_targets (image);
g_signal_connect (image, "drag-begin",
G_CALLBACK (drag_begin), image);
g_signal_connect (image, "drag-data-get",
G_CALLBACK (drag_data_get), image);
/* accept drops on image */
formats = gdk_content_formats_new_for_gtype (GDK_TYPE_TEXTURE);
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL,
NULL, GDK_ACTION_COPY);
gtk_drag_dest_add_image_targets (image);
g_signal_connect (image, "drag-data-received",
G_CALLBACK (drag_data_received), image);
/* context menu on image */
gesture = gtk_gesture_click_new ();
+1 -1
View File
@@ -262,7 +262,7 @@ draw_menu (GtkWidget *widget,
gint toggle_x, toggle_y, toggle_width, toggle_height;
/* This information is taken from the GtkMenu docs, see "CSS nodes" */
menu_context = get_style (NULL, "menu");
menu_context = get_style (gtk_widget_get_style_context(widget), "menu");
hovermenuitem_context = get_style (menu_context, "menuitem:hover");
hoveredarrowmenuitem_context = get_style (hovermenuitem_context, "arrow.right:dir(ltr)");
menuitem_context = get_style (menu_context, "menuitem");
+1 -4
View File
@@ -94,12 +94,9 @@ drawing_area_draw (GtkDrawingArea *area,
cairo_pattern_t *pat;
cairo_matrix_t matrix;
gdouble angle, scale;
gdouble x_center, y_center;
gtk_gesture_get_bounding_box_center (GTK_GESTURE (zoom), &x_center, &y_center);
cairo_get_matrix (cr, &matrix);
cairo_matrix_translate (&matrix, x_center, y_center);
cairo_matrix_translate (&matrix, width / 2, height / 2);
cairo_save (cr);
-1
View File
@@ -97,7 +97,6 @@ do_infobar (GtkWidget *do_widget)
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label);
gtk_info_bar_set_default_response (GTK_INFO_BAR (bar), GTK_RESPONSE_OK);
button = gtk_toggle_button_new_with_label ("Question");
g_object_bind_property (bar, "revealed", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+72 -77
View File
@@ -5,6 +5,9 @@
#include <gtk/gtk.h>
/* Drag 'n Drop */
static const char *target_table[] = {
"text/uri-list"
};
typedef struct
{
@@ -73,11 +76,30 @@ search_text_changed (GtkEntry *entry, IconBrowserWindow *win)
gtk_tree_model_filter_refilter (win->filter_model);
}
static GdkPixbuf *
get_icon (GtkWidget *image, const gchar *name, gint size)
{
GtkIconInfo *info;
GtkStyleContext *context;
GdkTexture *texture;
GdkPixbuf *pixbuf;
context = gtk_widget_get_style_context (image);
info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (), name, size, 0);
texture = GDK_TEXTURE (gtk_icon_info_load_symbolic_for_context (info, context, NULL, NULL));
pixbuf = gdk_pixbuf_get_from_texture (texture);
g_object_unref (texture);
g_object_unref (info);
return pixbuf;
}
static void
set_image (GtkWidget *image, const gchar *name, gint size)
{
gtk_image_set_from_icon_name (GTK_IMAGE (image), name);
gtk_image_set_pixel_size (GTK_IMAGE (image), size);
gtk_drag_source_set_icon_name (image, name);
}
static void
@@ -343,107 +365,78 @@ search_mode_toggled (GObject *searchbar, GParamSpec *pspec, IconBrowserWindow *w
gtk_list_box_unselect_all (GTK_LIST_BOX (win->context_list));
}
static GdkPaintable *
get_image_paintable (GtkImage *image)
static void
get_image_data (GtkWidget *widget,
GdkDrag *drag,
GtkSelectionData *selection,
guint target_info,
gpointer data)
{
const gchar *icon_name;
GtkIconTheme *icon_theme;
GtkIconInfo *icon_info;
int size;
GtkWidget *image;
const gchar *name;
gint size;
GdkPixbuf *pixbuf;
switch (gtk_image_get_storage_type (image))
{
case GTK_IMAGE_PAINTABLE:
return g_object_ref (gtk_image_get_paintable (image));
case GTK_IMAGE_ICON_NAME:
icon_name = gtk_image_get_icon_name (image);
size = gtk_image_get_pixel_size (image);
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (image)));
icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, size,
GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
if (icon_info == NULL)
return NULL;
return gtk_icon_info_load_icon (icon_info, NULL);
default:
g_warning ("Image storage type %d not handled",
gtk_image_get_storage_type (image));
return NULL;
}
image = gtk_bin_get_child (GTK_BIN (widget));
name = gtk_image_get_icon_name (GTK_IMAGE (image));
size = gtk_image_get_pixel_size (GTK_IMAGE (image));
pixbuf = get_icon (image, name, size);
gtk_selection_data_set_pixbuf (selection, pixbuf);
g_object_unref (pixbuf);
}
static void
drag_begin (GtkDragSource *source,
GdkDrag *drag,
GtkWidget *widget)
get_scalable_image_data (GtkWidget *widget,
GdkDrag *drag,
GtkSelectionData *selection,
guint target_info,
gpointer data)
{
GdkPaintable *paintable;
paintable = get_image_paintable (GTK_IMAGE (widget));
if (paintable)
{
int w, h;
w = gdk_paintable_get_intrinsic_width (paintable);
h = gdk_paintable_get_intrinsic_height (paintable);
gtk_drag_source_set_icon (source, paintable, w, h);
g_object_unref (paintable);
}
}
static void
get_texture (GValue *value,
gpointer data)
{
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (data));
if (GDK_IS_TEXTURE (paintable))
g_value_set_object (value, paintable);
}
static void
get_file (GValue *value,
gpointer data)
{
const char *name;
gchar *uris[2];
GtkIconInfo *info;
GtkWidget *image;
GFile *file;
const gchar *name;
name = gtk_image_get_icon_name (GTK_IMAGE (data));
image = gtk_bin_get_child (GTK_BIN (widget));
name = gtk_image_get_icon_name (GTK_IMAGE (image));
info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (), name, -1, 0);
file = g_file_new_for_path (gtk_icon_info_get_filename (info));
g_value_set_object (value, file);
g_object_unref (file);
uris[0] = g_file_get_uri (file);
uris[1] = NULL;
gtk_selection_data_set_uris (selection, uris);
g_free (uris[0]);
g_object_unref (info);
g_object_unref (file);
}
static void
setup_image_dnd (GtkWidget *image)
{
GdkContentProvider *content;
GtkDragSource *source;
source = gtk_drag_source_new ();
content = gdk_content_provider_new_with_callback (GDK_TYPE_TEXTURE, get_texture, image);
gtk_drag_source_set_content (source, content);
g_object_unref (content);
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
gtk_drag_source_add_image_targets (image);
g_signal_connect (image, "drag-data-get", G_CALLBACK (get_image_data), NULL);
}
static void
setup_scalable_image_dnd (GtkWidget *image)
{
GdkContentProvider *content;
GtkDragSource *source;
GtkWidget *parent;
GdkContentFormats *targets;
source = gtk_drag_source_new ();
content = gdk_content_provider_new_with_callback (G_TYPE_FILE, get_file, image);
gtk_drag_source_set_content (source, content);
g_object_unref (content);
parent = gtk_widget_get_parent (image);
targets = gdk_content_formats_new (target_table, G_N_ELEMENTS (target_table));
gtk_drag_source_set (parent, GDK_BUTTON1_MASK,
targets,
GDK_ACTION_COPY);
gdk_content_formats_unref (targets);
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
g_signal_connect (parent, "drag-data-get", G_CALLBACK (get_scalable_image_data), NULL);
}
static void
@@ -453,7 +446,8 @@ icon_browser_window_init (IconBrowserWindow *win)
gtk_widget_init_template (GTK_WIDGET (win));
list = gdk_content_formats_new_for_gtype (G_TYPE_STRING);
list = gdk_content_formats_new (NULL, 0);
list = gtk_content_formats_add_text_targets (list);
gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (win->list),
GDK_BUTTON1_MASK,
list,
@@ -465,6 +459,7 @@ icon_browser_window_init (IconBrowserWindow *win)
setup_image_dnd (win->image3);
setup_image_dnd (win->image4);
setup_image_dnd (win->image5);
setup_image_dnd (win->image6);
setup_scalable_image_dnd (win->image6);
win->contexts = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, context_free);
-10
View File
@@ -2000,13 +2000,6 @@ toggle_action (GSimpleAction *action,
g_variant_new_boolean (!g_variant_get_boolean (state)));
}
static gboolean
quit_timeout (gpointer data)
{
exit (0);
return G_SOURCE_REMOVE;
}
int
main (int argc, char *argv[])
{
@@ -2072,9 +2065,6 @@ main (int argc, char *argv[])
g_application_add_main_option (G_APPLICATION (app), "version", 0, 0, G_OPTION_ARG_NONE, "Show program version", NULL);
if (g_getenv ("GTK_DEBUG_AUTO_QUIT"))
g_timeout_add (500, quit_timeout, NULL);
g_signal_connect (app, "handle-local-options", G_CALLBACK (local_options), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
-2
View File
@@ -30,7 +30,6 @@ GskRenderNodeType
gsk_render_node_get_node_type
gsk_render_node_draw
GskSerializationError
GskParseErrorFunc
gsk_render_node_serialize
gsk_render_node_deserialize
gsk_render_node_write_to_file
@@ -183,7 +182,6 @@ gsk_transform_perspective
gsk_transform_equal
<SUBSECTION>
gsk_transform_transform_bounds
gsk_transform_transform_point
<SUBSECTION Private>
GSK_TYPE_TRANSFORM
gsk_transform_get_type
+1 -7
View File
@@ -344,13 +344,6 @@
<xi:include href="xml/gtkpadcontroller.xml" />
</chapter>
<chapter>
<title>Data exchange, clipboards and Drag-and-Drop</title>
<xi:include href="xml/gtkdragsource.xml"/>
<xi:include href="xml/gtkdragicon.xml"/>
<xi:include href="xml/gtkdroptarget.xml"/>
</chapter>
</part>
<part id="gtkbase">
@@ -359,6 +352,7 @@
<xi:include href="xml/gtkfeatures.xml" />
<xi:include href="xml/gtkaccelgroup.xml" />
<xi:include href="xml/gtkaccelmap.xml" />
<xi:include href="xml/gtkdnd.xml" />
<xi:include href="xml/gtksettings.xml" />
<xi:include href="xml/gtkbindings.xml" />
<xi:include href="xml/gtkenums.xml" />
+46 -66
View File
@@ -775,6 +775,7 @@ gtk_container_add
gtk_container_remove
gtk_container_foreach
gtk_container_get_children
gtk_container_get_path_for_child
gtk_container_get_focus_vadjustment
gtk_container_set_focus_vadjustment
gtk_container_get_focus_hadjustment
@@ -4411,6 +4412,7 @@ gtk_widget_get_layout_manager
gtk_widget_should_layout
<SUBSECTION>
gtk_widget_get_path
gtk_widget_get_style_context
gtk_widget_reset_style
gtk_widget_class_get_css_name
@@ -4895,6 +4897,7 @@ gtk_border_free
<SUBSECTION>
gtk_render_arrow
gtk_render_background
gtk_render_background_get_clip
gtk_render_check
gtk_render_expander
gtk_render_focus
@@ -4998,6 +5001,49 @@ GTK_TYPE_SELECTION_DATA
gtk_selection_data_get_type
</SECTION>
<SECTION>
<FILE>gtkdnd</FILE>
<TITLE>Drag and Drop</TITLE>
GtkDestDefaults
GtkDragResult
<SUBSECTION Destination Side>
gtk_drag_dest_set
gtk_drag_dest_unset
gtk_drag_dest_find_target
gtk_drag_dest_get_target_list
gtk_drag_dest_set_target_list
gtk_drag_dest_add_text_targets
gtk_drag_dest_add_image_targets
gtk_drag_dest_add_uri_targets
gtk_drag_dest_set_track_motion
gtk_drag_dest_get_track_motion
gtk_drag_get_data
gtk_drag_get_source_widget
gtk_drag_highlight
gtk_drag_unhighlight
<SUBSECTION Source Side>
gtk_drag_begin
gtk_drag_cancel
gtk_drag_set_icon_widget
gtk_drag_set_icon_paintable
gtk_drag_set_icon_name
gtk_drag_set_icon_gicon
gtk_drag_set_icon_default
gtk_drag_check_threshold
gtk_drag_source_set
gtk_drag_source_set_icon_name
gtk_drag_source_set_icon_gicon
gtk_drag_source_set_icon_paintable
gtk_drag_source_unset
gtk_drag_source_set_target_list
gtk_drag_source_get_target_list
gtk_drag_source_add_text_targets
gtk_drag_source_add_image_targets
gtk_drag_source_add_uri_targets
</SECTION>
<SECTION>
<FILE>gtkbindings</FILE>
<TITLE>Bindings</TITLE>
@@ -7145,69 +7191,3 @@ gtk_constraint_guide_get_max_size
GTK_TYPE_CONSTRAINT_GUIDE
gtk_constraint_guide_get_tyoe
</SECTION>
<SECTION>
<FILE>gtkdragsource</FILE>
GtkDragSource
gtk_drag_source_new
gtk_drag_source_set_content
gtk_drag_source_get_content
gtk_drag_source_set_actions
gtk_drag_source_get_actions
gtk_drag_source_set_icon
gtk_drag_source_drag_cancel
gtk_drag_source_get_drag
gtk_drag_check_threshold
<SUBSECTION Standard>
GTK_TYPE_DRAG_SOURCE
GTK_DRAG_SOURCE
GTK_DRAG_SOURCE_CLASS
GTK_IS_DRAG_SOURCE
GTK_IS_DRAG_SOURCE_CLASS
GTK_DRAG_SOURCE_GET_CLASS
<SUBSECTION Private>
gtk_drag_source_get_type
</SECTION>
<SECTION>
<FILE>gtkdroptarget</FILE>
GtkDropTarget
gtk_drop_target_new
gtk_drop_target_set_formats
gtk_drop_target_get_formats
gtk_drop_target_set_actions
gtk_drop_target_get_actions
gtk_drop_target_get_drop
gtk_drop_target_find_mimetype
gtk_drop_target_read_selection
gtk_drop_target_read_selection_finish
gtk_drag_highlight
gtk_drag_unhighlight
<SUBSECTION Standard>
GTK_TYPE_DROP_TARGET
GTK_DROP_TARGET
GTK_DROP_TARGET_CLASS
GTK_IS_DROP_TARGET
GTK_IS_DROP_TARGET_CLASS
GTK_DROP_TARGET_GET_CLASS
<SUBSECTION Private>
gtk_drop_target_get_type
</SECTION>
<SECTION>
<FILE>gtkdragicon</FILE>
GtkDragIcon
gtk_drag_icon_new_for_drag
gtk_drag_icon_set_from_paintable
<SUBSECTION Standard>
GTK_TYPE_DRAG_ICON
GTK_DRAG_ICON
GTK_DRAG_ICON_CLASS
GTK_IS_DRAG_ICON
GTK_IS_DRAG_ICON_CLASS
GTK_DRAG_ICON_GET_CLASS
<SUBSECTION Private>
gtk_drag_icon_get_type
</SECTION>
-3
View File
@@ -57,10 +57,7 @@ gtk_constraint_target_get_type
gtk_container_get_type
gtk_css_provider_get_type
gtk_dialog_get_type
gtk_drag_icon_get_type
gtk_drag_source_get_type
gtk_drawing_area_get_type
gtk_drop_target_get_type
gtk_editable_get_type
gtk_entry_buffer_get_type
gtk_entry_completion_get_type
+2
View File
@@ -48,6 +48,7 @@ private_headers = [
'gtkcssfontfeaturesvalueprivate.h',
'gtkcssfontvariationsvalueprivate.h',
'gtkcssiconthemevalueprivate.h',
'gtkcssimagebuiltinprivate.h',
'gtkcssimagecrossfadeprivate.h',
'gtkcssimagefallbackprivate.h',
'gtkcssimageiconthemeprivate.h',
@@ -96,6 +97,7 @@ private_headers = [
'gtkcsswidgetnodeprivate.h',
'gtkcsswin32sizevalueprivate.h',
'gtkdialogprivate.h',
'gtkdndprivate.h',
'gtkentryprivate.h',
'gtkeventcontrollerlegacyprivate.h',
'gtkeventcontrollerprivate.h',
-31
View File
@@ -903,37 +903,6 @@
gtk_tooltip_set_custom().
</para>
</section>
<section>
<title>Switch to the new DND api</title>
<para>
The source-side DND apis in GTK 4 have been changed to use an event controller, #GtkDragSource.
</para>
<para>
Instead of calling gtk_drag_source_set() and connecting to #GtkWidget signals, you create
a #GtkDragSource object, attach it to the widget with gtk_widget_add_controller(), and connect
to #GtkDragSource signals. Instead of calling gtk_drag_begin() on a widget to start a drag
manually, call gdk_drag_begin().
</para>
<para>
The ::drag-data-get signal has been replaced by the #GtkDragSource::prepare signal, which
returns a #GdkContentProvider for the drag operation.
</para>
<para>
The destination-side DND apis in GTK 4 have also been changed to use and event controller,
#GTkDropTarget.
</para>
<para>
Instead of calling gtk_drag_dest_set() and connecting to #GtkWidget signals, you create
a #GtkDropTarget object, attach it to the widget with gtk_widget_add_controller(), and
connect to #GtkDropTarget signals.
</para>
<para>
The ::drag-motion signal has been renamed to #GtkDragSource::accept, and instead of
::drag-data-received, you need to use async read methods on the #GdkDrop object, such
as gdk_drop_read_value_async() or gdk_drop_read_text_async().
</para>
</section>
</section>
</chapter>
+62 -239
View File
@@ -23,10 +23,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include "gdkcontentformats.h"
#include "gdkcontentserializer.h"
#include "gdkcontentdeserializer.h"
#include <gio/gio.h>
#ifdef G_OS_UNIX
@@ -47,6 +43,58 @@
static GDBusProxy *file_transfer_proxy = NULL;
static GDBusProxy *
ensure_file_transfer_portal (void)
{
if (file_transfer_proxy == NULL)
{
GError *error = NULL;
file_transfer_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
| G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS
| G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
NULL,
"org.freedesktop.portal.Documents",
"/org/freedesktop/portal/documents",
"org.freedesktop.portal.FileTransfer",
NULL, &error);
if (error)
{
g_debug ("Failed to get proxy: %s", error->message);
g_error_free (error);
}
}
if (file_transfer_proxy)
{
char *owner = g_dbus_proxy_get_name_owner (file_transfer_proxy);
if (owner)
{
g_free (owner);
return file_transfer_proxy;
}
}
return NULL;
}
gboolean
file_transfer_portal_available (void)
{
gboolean available;
ensure_file_transfer_portal ();
available = file_transfer_proxy != NULL;
g_clear_object (&file_transfer_proxy);
return available;
}
typedef struct {
GTask *task;
const char **files;
@@ -193,12 +241,15 @@ file_transfer_portal_register_files (const char **files,
gpointer data)
{
GTask *task;
GDBusProxy *proxy;
AddFileData *afd;
GVariantBuilder options;
task = g_task_new (NULL, NULL, callback, data);
if (file_transfer_proxy == NULL)
proxy = ensure_file_transfer_portal ();
if (proxy == NULL)
{
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"No portal found");
@@ -216,7 +267,7 @@ file_transfer_portal_register_files (const char **files,
g_variant_builder_add (&options, "{sv}", "writable", g_variant_new_boolean (writable));
g_variant_builder_add (&options, "{sv}", "autostop", g_variant_new_boolean (TRUE));
g_dbus_proxy_call (file_transfer_proxy, "StartTransfer",
g_dbus_proxy_call (proxy, "StartTransfer",
g_variant_new ("(a{sv})", &options),
0, -1, NULL, start_session_done, afd);
}
@@ -268,12 +319,15 @@ file_transfer_portal_retrieve_files (const char *key,
GAsyncReadyCallback callback,
gpointer data)
{
GDBusProxy *proxy;
GTask *task;
GVariantBuilder options;
task = g_task_new (NULL, NULL, callback, data);
if (file_transfer_proxy == NULL)
proxy = ensure_file_transfer_portal ();
if (proxy == NULL)
{
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"No portal found");
@@ -282,7 +336,7 @@ file_transfer_portal_retrieve_files (const char *key,
}
g_variant_builder_init (&options, G_VARIANT_TYPE_VARDICT);
g_dbus_proxy_call (file_transfer_proxy,
g_dbus_proxy_call (proxy,
"RetrieveFiles",
g_variant_new ("(sa{sv})", key, &options),
0, -1, NULL,
@@ -303,235 +357,4 @@ file_transfer_portal_retrieve_files_finish (GAsyncResult *result,
return FALSE;
}
/* serializer */
static void
file_serializer_finish (GObject *source,
GAsyncResult *result,
gpointer serializer)
{
GOutputStream *stream = G_OUTPUT_STREAM (source);
GError *error = NULL;
if (!g_output_stream_write_all_finish (stream, result, NULL, &error))
gdk_content_serializer_return_error (serializer, error);
else
gdk_content_serializer_return_success (serializer);
}
static void
portal_ready (GObject *object,
GAsyncResult *result,
gpointer serializer)
{
GError *error = NULL;
char *key;
if (!file_transfer_portal_register_files_finish (result, &key, &error))
{
gdk_content_serializer_return_error (serializer, error);
return;
}
g_output_stream_write_all_async (gdk_content_serializer_get_output_stream (serializer),
key,
strlen (key) + 1,
gdk_content_serializer_get_priority (serializer),
gdk_content_serializer_get_cancellable (serializer),
file_serializer_finish,
serializer);
gdk_content_serializer_set_task_data (serializer, key, g_free);
}
static void
portal_file_serializer (GdkContentSerializer *serializer)
{
GFile *file;
const GValue *value;
GPtrArray *files;
files = g_ptr_array_new_with_free_func (g_free);
value = gdk_content_serializer_get_value (serializer);
if (G_VALUE_HOLDS (value, G_TYPE_FILE))
{
file = g_value_get_object (gdk_content_serializer_get_value (serializer));
if (file)
g_ptr_array_add (files, g_file_get_path (file));
g_ptr_array_add (files, NULL);
}
else if (G_VALUE_HOLDS (value, GDK_TYPE_FILE_LIST))
{
GSList *l;
for (l = g_value_get_boxed (value); l; l = l->next)
g_ptr_array_add (files, g_file_get_path (l->data));
g_ptr_array_add (files, NULL);
}
/* this call doesn't copy the strings, so keep the array around until the registration is done */
file_transfer_portal_register_files ((const char **)files->pdata, TRUE, portal_ready, serializer);
gdk_content_serializer_set_task_data (serializer, files, (GDestroyNotify)g_ptr_array_unref);
}
/* deserializer */
static void
portal_finish (GObject *object,
GAsyncResult *result,
gpointer deserializer)
{
char **files = NULL;
GError *error = NULL;
GValue *value;
if (!file_transfer_portal_retrieve_files_finish (result, &files, &error))
{
gdk_content_deserializer_return_error (deserializer, error);
return;
}
value = gdk_content_deserializer_get_value (deserializer);
if (G_VALUE_HOLDS (value, G_TYPE_FILE))
{
if (files[0] != NULL)
g_value_take_object (value, g_file_new_for_path (files[0]));
}
else
{
GSList *l = NULL;
gsize i;
for (i = 0; files[i] != NULL; i++)
l = g_slist_prepend (l, g_file_new_for_path (files[i]));
g_value_take_boxed (value, g_slist_reverse (l));
}
g_strfreev (files);
gdk_content_deserializer_return_success (deserializer);
}
static void
portal_file_deserializer_finish (GObject *source,
GAsyncResult *result,
gpointer deserializer)
{
GOutputStream *stream = G_OUTPUT_STREAM (source);
GError *error = NULL;
gssize written;
char *key;
written = g_output_stream_splice_finish (stream, result, &error);
if (written < 0)
{
gdk_content_deserializer_return_error (deserializer, error);
return;
}
/* write terminating NULL */
if (!g_output_stream_write (stream, "", 1, NULL, &error))
{
gdk_content_deserializer_return_error (deserializer, error);
return;
}
key = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (stream));
if (key == NULL)
{
GError *gerror = g_error_new (G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
"Could not convert data from %s to %s",
gdk_content_deserializer_get_mime_type (deserializer),
g_type_name (gdk_content_deserializer_get_gtype (deserializer)));
gdk_content_deserializer_return_error (deserializer, gerror);
return;
}
file_transfer_portal_retrieve_files (key, portal_finish, deserializer);
gdk_content_deserializer_set_task_data (deserializer, key, g_free);
}
static void
portal_file_deserializer (GdkContentDeserializer *deserializer)
{
GOutputStream *output;
output = g_memory_output_stream_new_resizable ();
g_output_stream_splice_async (output,
gdk_content_deserializer_get_input_stream (deserializer),
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
gdk_content_deserializer_get_priority (deserializer),
gdk_content_deserializer_get_cancellable (deserializer),
portal_file_deserializer_finish,
deserializer);
g_object_unref (output);
}
static void
got_proxy (GObject *source,
GAsyncResult *result,
gpointer data)
{
GError *error = NULL;
file_transfer_proxy = g_dbus_proxy_new_for_bus_finish (result, &error);
if (!file_transfer_proxy)
{
g_message ("Failed to get file transfer portal: %s", error->message);
g_clear_error (&error);
return;
}
gdk_content_register_serializer (G_TYPE_FILE,
"application/vnd.portal.files",
portal_file_serializer,
NULL,
NULL);
gdk_content_register_serializer (GDK_TYPE_FILE_LIST,
"application/vnd.portal.files",
portal_file_serializer,
NULL,
NULL);
gdk_content_register_deserializer ("application/vnd.portal.files",
GDK_TYPE_FILE_LIST,
portal_file_deserializer,
NULL,
NULL);
gdk_content_register_deserializer ("application/vnd.portal.files",
G_TYPE_FILE,
portal_file_deserializer,
NULL,
NULL);
}
void
file_transfer_portal_register (void)
{
static gboolean called;
if (!called)
{
called = TRUE;
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
| G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS
| G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
NULL,
"org.freedesktop.portal.Documents",
"/org/freedesktop/portal/documents",
"org.freedesktop.portal.FileTransfer",
NULL,
got_proxy,
NULL);
}
}
#endif /* G_OS_UNIX */
+1 -2
View File
@@ -19,8 +19,7 @@
#define __FILE_TRANSFER_PROTOCOL_H__
void file_transfer_portal_register (void);
gboolean file_transfer_portal_available (void);
void file_transfer_portal_register_files (const char **files,
gboolean writable,
GAsyncReadyCallback callback,
+5 -5
View File
@@ -212,14 +212,14 @@ gdk_pre_parse (void)
_gdk_debug_flags = g_parse_debug_string (debug_string,
(GDebugKey *) gdk_debug_keys,
G_N_ELEMENTS (gdk_debug_keys));
if (g_getenv ("GTK_TRACE_FD"))
gdk_profiler_start (atoi (g_getenv ("GTK_TRACE_FD")));
else if (g_getenv ("GTK_TRACE"))
gdk_profiler_start (-1);
}
#endif /* G_ENABLE_DEBUG */
if (g_getenv ("GTK_TRACE_FD"))
gdk_profiler_start (atoi (g_getenv ("GTK_TRACE_FD")));
else if (g_getenv ("GTK_TRACE"))
gdk_profiler_start (-1);
#ifndef G_HAS_CONSTRUCTORS
stash_desktop_startup_notification_id ();
#endif
+105 -65
View File
@@ -24,7 +24,6 @@
#include "gdkcontentformats.h"
#include "filetransferportalprivate.h"
#include "gdktexture.h"
#include "gdkrgbaprivate.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -692,6 +691,95 @@ string_deserializer (GdkContentDeserializer *deserializer)
g_object_unref (filter);
}
#ifdef G_OS_UNIX
static void
portal_finish (GObject *object,
GAsyncResult *result,
gpointer deserializer)
{
char **files = NULL;
GError *error = NULL;
GValue *value;
if (!file_transfer_portal_retrieve_files_finish (result, &files, &error))
{
gdk_content_deserializer_return_error (deserializer, error);
return;
}
value = gdk_content_deserializer_get_value (deserializer);
if (G_VALUE_HOLDS (value, G_TYPE_FILE))
{
if (files[0] != NULL)
g_value_take_object (value, g_file_new_for_path (files[0]));
}
else
{
GSList *l = NULL;
gsize i;
for (i = 0; files[i] != NULL; i++)
l = g_slist_prepend (l, g_file_new_for_path (files[i]));
g_value_take_boxed (value, g_slist_reverse (l));
}
g_strfreev (files);
gdk_content_deserializer_return_success (deserializer);
}
static void
portal_file_deserializer_finish (GObject *source,
GAsyncResult *result,
gpointer deserializer)
{
GOutputStream *stream = G_OUTPUT_STREAM (source);
GError *error = NULL;
gssize written;
char *key;
written = g_output_stream_splice_finish (stream, result, &error);
if (written < 0)
{
gdk_content_deserializer_return_error (deserializer, error);
return;
}
/* write terminating NULL */
if (!g_output_stream_write (stream, "", 1, NULL, &error))
{
gdk_content_deserializer_return_error (deserializer, error);
return;
}
key = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (stream));
if (key == NULL)
{
deserialize_not_found (deserializer);
return;
}
file_transfer_portal_retrieve_files (key, portal_finish, deserializer);
gdk_content_deserializer_set_task_data (deserializer, key, g_free);
}
static void
portal_file_deserializer (GdkContentDeserializer *deserializer)
{
GOutputStream *output;
output = g_memory_output_stream_new_resizable ();
g_output_stream_splice_async (output,
gdk_content_deserializer_get_input_stream (deserializer),
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
gdk_content_deserializer_get_priority (deserializer),
gdk_content_deserializer_get_cancellable (deserializer),
portal_file_deserializer_finish,
deserializer);
g_object_unref (output);
}
#endif /* G_OS_UNIX */
static void
file_uri_deserializer_finish (GObject *source,
GAsyncResult *result,
@@ -760,63 +848,6 @@ file_uri_deserializer (GdkContentDeserializer *deserializer)
g_object_unref (output);
}
static void
color_deserializer_finish (GObject *source,
GAsyncResult *result,
gpointer deserializer)
{
GOutputStream *stream = G_OUTPUT_STREAM (source);
GError *error = NULL;
gssize written;
written = g_output_stream_splice_finish (stream, result, &error);
if (written < 0)
{
gdk_content_deserializer_return_error (deserializer, error);
return;
}
else if (written == 0)
{
GdkRGBA black = GDK_RGBA ("000");
/* Never return NULL, we only return that on error */
g_value_set_boxed (gdk_content_deserializer_get_value (deserializer), &black);
}
else
{
guint16 *data;
GdkRGBA rgba;
data = (guint16 *)g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (stream));
rgba.red = data[0] / 65535.0;
rgba.green = data[1] / 65535.0;
rgba.blue = data[2] / 65535.0;
rgba.alpha = data[3] / 65535.0;
g_value_set_boxed (gdk_content_deserializer_get_value (deserializer), &rgba);
}
gdk_content_deserializer_return_success (deserializer);
}
static void
color_deserializer (GdkContentDeserializer *deserializer)
{
GOutputStream *output;
guint16 *data;
data = g_new0 (guint16, 4);
output = g_memory_output_stream_new (data, 4 * sizeof (guint16), NULL, g_free);
g_output_stream_splice_async (output,
gdk_content_deserializer_get_input_stream (deserializer),
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
gdk_content_deserializer_get_priority (deserializer),
gdk_content_deserializer_get_cancellable (deserializer),
color_deserializer_finish,
deserializer);
g_object_unref (output);
}
static void
init (void)
{
@@ -876,7 +907,13 @@ init (void)
g_slist_free (formats);
#ifdef G_OS_UNIX
file_transfer_portal_register ();
gboolean has_portal = file_transfer_portal_available ();
if (has_portal)
gdk_content_register_deserializer ("application/vnd.portal.files",
GDK_TYPE_FILE_LIST,
portal_file_deserializer,
NULL,
NULL);
#endif
gdk_content_register_deserializer ("text/uri-list",
@@ -885,6 +922,15 @@ init (void)
NULL,
NULL);
#ifdef G_OS_UNIX
if (has_portal)
gdk_content_register_deserializer ("application/vnd.portal.files",
G_TYPE_FILE,
portal_file_deserializer,
NULL,
NULL);
#endif
gdk_content_register_deserializer ("text/uri-list",
G_TYPE_FILE,
file_uri_deserializer,
@@ -910,11 +956,5 @@ init (void)
string_deserializer,
(gpointer) "ASCII",
NULL);
gdk_content_register_deserializer ("application/x-color",
GDK_TYPE_RGBA,
color_deserializer,
NULL,
NULL);
}
-230
View File
@@ -21,7 +21,6 @@
#include "gdkcontentprovider.h"
#include "gdkcontentformats.h"
#include "gdkcontentserializer.h"
#include "gdkintl.h"
#include "gdkcontentproviderimpl.h"
@@ -281,232 +280,3 @@ gdk_content_provider_new_for_bytes (const char *mime_type,
return GDK_CONTENT_PROVIDER (content);
}
#define GDK_TYPE_CONTENT_PROVIDER_CALLBACK (gdk_content_provider_callback_get_type ())
#define GDK_CONTENT_PROVIDER_CALLBACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_CONTENT_PROVIDER_CALLBACK, GdkContentProviderCallback))
typedef struct _GdkContentProviderCallback GdkContentProviderCallback;
typedef struct _GdkContentProviderCallbackClass GdkContentProviderCallbackClass;
struct _GdkContentProviderCallback
{
GdkContentProvider parent;
GType type;
GdkContentProviderGetValueFunc func;
gpointer data;
};
struct _GdkContentProviderCallbackClass
{
GdkContentProviderClass parent_class;
};
GType gdk_content_provider_callback_get_type (void) G_GNUC_CONST;
G_DEFINE_TYPE (GdkContentProviderCallback, gdk_content_provider_callback, GDK_TYPE_CONTENT_PROVIDER)
static GdkContentFormats *
gdk_content_provider_callback_ref_formats (GdkContentProvider *provider)
{
GdkContentProviderCallback *callback = GDK_CONTENT_PROVIDER_CALLBACK (provider);
return gdk_content_formats_new_for_gtype (callback->type);
}
static gboolean
gdk_content_provider_callback_get_value (GdkContentProvider *provider,
GValue *value,
GError **error)
{
GdkContentProviderCallback *callback = GDK_CONTENT_PROVIDER_CALLBACK (provider);
if (G_VALUE_HOLDS (value, callback->type) && callback->func != NULL)
{
callback->func (value, callback->data);
return TRUE;
}
return GDK_CONTENT_PROVIDER_CLASS (gdk_content_provider_callback_parent_class)->get_value (provider, value, error);
}
static void
gdk_content_provider_callback_class_init (GdkContentProviderCallbackClass *class)
{
GdkContentProviderClass *provider_class = GDK_CONTENT_PROVIDER_CLASS (class);
provider_class->ref_formats = gdk_content_provider_callback_ref_formats;
provider_class->get_value = gdk_content_provider_callback_get_value;
}
static void
gdk_content_provider_callback_init (GdkContentProviderCallback *content)
{
}
/**
* gdk_content_provider_new_for_callback:
* @type: the type that the callback provides
* @func: callback to populate a #GValue
* @data: (closure): data that gets passed to @func
*
* Create a content provider that provides data that is provided via a callback.
*
* Returns: a new #GdkContentProvider
**/
GdkContentProvider *
gdk_content_provider_new_with_callback (GType type,
GdkContentProviderGetValueFunc func,
gpointer data)
{
GdkContentProviderCallback *content;
content = g_object_new (GDK_TYPE_CONTENT_PROVIDER_CALLBACK, NULL);
content->type = type;
content->func = func;
content->data = data;
return GDK_CONTENT_PROVIDER (content);
}
#define GDK_TYPE_CONTENT_PROVIDER_CALLBACK2 (gdk_content_provider_callback2_get_type ())
#define GDK_CONTENT_PROVIDER_CALLBACK2(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_CONTENT_PROVIDER_CALLBACK2, GdkContentProviderCallback2))
typedef struct _GdkContentProviderCallback2 GdkContentProviderCallback2;
typedef struct _GdkContentProviderCallback2Class GdkContentProviderCallback2Class;
struct _GdkContentProviderCallback2
{
GdkContentProvider parent;
GdkContentFormats *formats;
GdkContentProviderGetBytesFunc func;
gpointer data;
};
struct _GdkContentProviderCallback2Class
{
GdkContentProviderClass parent_class;
};
GType gdk_content_provider_callback2_get_type (void) G_GNUC_CONST;
G_DEFINE_TYPE (GdkContentProviderCallback2, gdk_content_provider_callback2, GDK_TYPE_CONTENT_PROVIDER)
static GdkContentFormats *
gdk_content_provider_callback2_ref_formats (GdkContentProvider *provider)
{
GdkContentProviderCallback2 *callback = GDK_CONTENT_PROVIDER_CALLBACK2 (provider);
return gdk_content_formats_ref (callback->formats);
}
static void
gdk_content_provider_callback2_write_mime_type_done (GObject *stream,
GAsyncResult *result,
gpointer task)
{
GError *error = NULL;
if (!g_output_stream_write_all_finish (G_OUTPUT_STREAM (stream), result, NULL, &error))
g_task_return_error (task, error);
else
g_task_return_boolean (task, TRUE);
g_object_unref (task);
}
static void
gdk_content_provider_callback2_write_mime_type_async (GdkContentProvider *provider,
const char *mime_type,
GOutputStream *stream,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GdkContentProviderCallback2 *content = GDK_CONTENT_PROVIDER_CALLBACK2 (provider);
GTask *task;
GBytes *bytes;
task = g_task_new (content, cancellable, callback, user_data);
g_task_set_priority (task, io_priority);
g_task_set_source_tag (task, gdk_content_provider_callback2_write_mime_type_async);
if (!gdk_content_formats_contain_mime_type (content->formats, mime_type))
{
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
_("Cannot provide contents as “%s”"), mime_type);
g_object_unref (task);
return;
}
bytes = content->func (mime_type, content->data);
if (!bytes)
{
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
_("Failed to get contents as “%s”"), mime_type);
g_object_unref (task);
return;
}
g_object_set_data_full (G_OBJECT (task), "bytes", bytes, (GDestroyNotify)g_bytes_unref);
g_output_stream_write_all_async (stream,
g_bytes_get_data (bytes, NULL),
g_bytes_get_size (bytes),
io_priority,
cancellable,
gdk_content_provider_callback2_write_mime_type_done,
task);
}
static gboolean
gdk_content_provider_callback2_write_mime_type_finish (GdkContentProvider *provider,
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, provider), FALSE);
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gdk_content_provider_callback2_write_mime_type_async, FALSE);
return g_task_propagate_boolean (G_TASK (result), error);
}
static void
gdk_content_provider_callback2_class_init (GdkContentProviderCallback2Class *class)
{
GdkContentProviderClass *provider_class = GDK_CONTENT_PROVIDER_CLASS (class);
provider_class->ref_formats = gdk_content_provider_callback2_ref_formats;
provider_class->write_mime_type_async = gdk_content_provider_callback2_write_mime_type_async;
provider_class->write_mime_type_finish = gdk_content_provider_callback2_write_mime_type_finish;
}
static void
gdk_content_provider_callback2_init (GdkContentProviderCallback2 *content)
{
}
/**
* gdk_content_provider_new_with_formats:
* @formats: formats to advertise
* @func: callback to populate a #GValue
* @data: data that gets passed to @func
*
* Create a content provider that provides data that is provided via a callback.
*
* Returns: a new #GdkContentProvider
**/
GdkContentProvider *
gdk_content_provider_new_with_formats (GdkContentFormats *formats,
GdkContentProviderGetBytesFunc func,
gpointer data)
{
GdkContentProviderCallback2 *content;
content = g_object_new (GDK_TYPE_CONTENT_PROVIDER_CALLBACK2, NULL);
content->formats = gdk_content_formats_union_serialize_mime_types (gdk_content_formats_ref (formats));
content->func = func;
content->data = data;
return GDK_CONTENT_PROVIDER (content);
}
-15
View File
@@ -35,21 +35,6 @@ GDK_AVAILABLE_IN_ALL
GdkContentProvider * gdk_content_provider_new_for_bytes (const char *mime_type,
GBytes *bytes);
typedef void (*GdkContentProviderGetValueFunc) (GValue *value,
gpointer data);
GDK_AVAILABLE_IN_ALL
GdkContentProvider * gdk_content_provider_new_with_callback (GType type,
GdkContentProviderGetValueFunc func,
gpointer data);
typedef GBytes * (*GdkContentProviderGetBytesFunc) (const char *mime_type,
gpointer data);
GDK_AVAILABLE_IN_ALL
GdkContentProvider * gdk_content_provider_new_with_formats (GdkContentFormats *formats,
GdkContentProviderGetBytesFunc func,
gpointer data);
G_END_DECLS
+76 -50
View File
@@ -25,7 +25,6 @@
#include "gdkpixbuf.h"
#include "filetransferportalprivate.h"
#include "gdktextureprivate.h"
#include "gdkrgba.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <string.h>
@@ -703,6 +702,65 @@ file_serializer_finish (GObject *source,
gdk_content_serializer_return_success (serializer);
}
#ifdef G_OS_UNIX
static void
portal_ready (GObject *object,
GAsyncResult *result,
gpointer serializer)
{
GError *error = NULL;
char *key;
if (!file_transfer_portal_register_files_finish (result, &key, &error))
{
gdk_content_serializer_return_error (serializer, error);
return;
}
g_output_stream_write_all_async (gdk_content_serializer_get_output_stream (serializer),
key,
strlen (key) + 1,
gdk_content_serializer_get_priority (serializer),
gdk_content_serializer_get_cancellable (serializer),
file_serializer_finish,
serializer);
gdk_content_serializer_set_task_data (serializer, key, g_free);
}
static void
portal_file_serializer (GdkContentSerializer *serializer)
{
GFile *file;
const GValue *value;
GPtrArray *files;
files = g_ptr_array_new_with_free_func (g_free);
value = gdk_content_serializer_get_value (serializer);
if (G_VALUE_HOLDS (value, G_TYPE_FILE))
{
file = g_value_get_object (gdk_content_serializer_get_value (serializer));
if (file)
g_ptr_array_add (files, g_file_get_path (file));
g_ptr_array_add (files, NULL);
}
else if (G_VALUE_HOLDS (value, GDK_TYPE_FILE_LIST))
{
GSList *l;
for (l = g_value_get_boxed (value); l; l = l->next)
g_ptr_array_add (files, g_file_get_path (l->data));
g_ptr_array_add (files, NULL);
}
/* this call doesn't copy the strings, so keep the array around until the registration is done */
file_transfer_portal_register_files ((const char **)files->pdata, TRUE, portal_ready, serializer);
gdk_content_serializer_set_task_data (serializer, files, (GDestroyNotify)g_ptr_array_unref);
}
#endif /* G_OS_UNIX */
static void
file_uri_serializer (GdkContentSerializer *serializer)
{
@@ -804,48 +862,6 @@ file_text_serializer (GdkContentSerializer *serializer)
gdk_content_serializer_set_task_data (serializer, path, g_free);
}
static void
color_serializer_finish (GObject *source,
GAsyncResult *result,
gpointer serializer)
{
GOutputStream *stream = G_OUTPUT_STREAM (source);
GError *error = NULL;
if (!g_output_stream_write_all_finish (stream, result, NULL, &error))
gdk_content_serializer_return_error (serializer, error);
else
gdk_content_serializer_return_success (serializer);
}
static void
color_serializer (GdkContentSerializer *serializer)
{
const GValue *value;
GdkRGBA *rgba;
guint16 *data;
value = gdk_content_serializer_get_value (serializer);
rgba = g_value_get_boxed (value);
data = g_new0 (guint16, 4);
if (rgba)
{
data[0] = (guint16) (rgba->red * 65535);
data[1] = (guint16) (rgba->green * 65535);
data[2] = (guint16) (rgba->blue * 65535);
data[3] = (guint16) (rgba->alpha * 65535);
}
g_output_stream_write_all_async (gdk_content_serializer_get_output_stream (serializer),
data,
4 * sizeof (guint16),
gdk_content_serializer_get_priority (serializer),
gdk_content_serializer_get_cancellable (serializer),
color_serializer_finish,
serializer);
gdk_content_serializer_set_task_data (serializer, data, g_free);
}
static void
init (void)
{
@@ -908,7 +924,14 @@ init (void)
g_slist_free (formats);
#ifdef G_OS_UNIX
file_transfer_portal_register ();
gboolean has_portal = file_transfer_portal_available ();
if (has_portal)
gdk_content_register_serializer (G_TYPE_FILE,
"application/vnd.portal.files",
portal_file_serializer,
NULL,
NULL);
#endif
gdk_content_register_serializer (G_TYPE_FILE,
@@ -922,6 +945,15 @@ init (void)
NULL,
NULL);
#ifdef G_OS_UNIX
if (has_portal)
gdk_content_register_serializer (GDK_TYPE_FILE_LIST,
"application/vnd.portal.files",
portal_file_serializer,
NULL,
NULL);
#endif
gdk_content_register_serializer (GDK_TYPE_FILE_LIST,
"text/uri-list",
file_uri_serializer,
@@ -952,11 +984,5 @@ init (void)
string_serializer,
(gpointer) "ASCII",
NULL);
gdk_content_register_serializer (GDK_TYPE_RGBA,
"application/x-color",
color_serializer,
NULL,
NULL);
}
+7 -17
View File
@@ -90,30 +90,20 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDrag, gdk_drag, G_TYPE_OBJECT)
/**
* SECTION:dnd
* @Title: Drag And Drop
* @Short_description: Functions for controlling drag and drop handling
* @title: Drag And Drop
* @short_description: Functions for controlling drag and drop handling
*
* These functions provide a low-level interface for drag and drop.
* These functions provide a low level interface for drag and drop.
*
* 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. After a drag has been started with gdk_drag_begin(),
* the caller gets informed about the status of the ongoing drag operation
* with signals on the #GtkDrag object.
* the DND operation.
*
* The GdkDrop object represents the target side of an ongoing DND operation.
* Possible drop sites get informed about the status of the ongoing drag operation
* with events of type %GDK_DRAG_ENTER, %GDK_DRAG_LEAVE, %GDK_DRAG_MOTION and
* %GDK_DROP_START. The #GdkDrop object can be obtained from these #GdkEvents
* using gdk_event_get_drop().
*
* The actual data transfer is initiated from the target side via an async
* read, using one of the GdkDrop functions for this purpose: gdk_drop_read_async(),
* gdk_drop_read_value_async() or gdk_drop_read_text_async().
*
* 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][gtk4-Drag-and-Drop] section of the GTK documentation
* 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][gtk4-Drag-and-Drop] section of the GTK+ documentation
* for more information.
*/
+1 -31
View File
@@ -448,10 +448,7 @@ gdk_drop_get_surface (GdkDrop *self)
* Returns the possible actions for this #GdkDrop. If this value
* contains multiple actions - ie gdk_drag_action_is_unique()
* returns %FALSE for the result - gdk_drag_finish() must choose
* the action to use when accepting the drop. This will only
* happen if you passed %GDK_ACTION_ASK as one of the possible
* actions in gdk_drag_status(). %GDK_ACTION_ASK itself will not
* be included in the actions returned by this function.
* the action to use when accepting the drop.
*
* This value may change over the lifetime of the #GdkDrop both
* as a response to source side actions as well as to calls to
@@ -1001,30 +998,3 @@ gdk_drop_emit_drop_event (GdkDrop *self,
gdk_drop_do_emit_event (event, dont_queue);
}
/**
* gdk_drop_has_value:
* @self: a #GdkDrop
* @type: the type to check
*
* Returns whether calling gdk_drop_read_value_async() for @type
* can succeed.
*
* Returns: %TRUE if the data can be deserialized to the given type
*/
gboolean
gdk_drop_has_value (GdkDrop *self,
GType type)
{
GdkContentFormats *formats;
gboolean ret;
formats = gdk_content_formats_ref (gdk_drop_get_formats (self));
formats = gdk_content_formats_union_deserialize_gtypes (formats);
ret = gdk_content_formats_contain_gtype (formats, type);
gdk_content_formats_unref (formats);
return ret;
}
-3
View File
@@ -92,9 +92,6 @@ char * gdk_drop_read_text_finish (GdkDrop
GAsyncResult *result,
GError **error);
GDK_AVAILABLE_IN_ALL
gboolean gdk_drop_has_value (GdkDrop *self,
GType type);
G_END_DECLS
-7
View File
@@ -1013,13 +1013,6 @@ gdk_event_set_coords (GdkEvent *event,
event->touchpad_pinch.x = x;
event->touchpad_pinch.y = y;
break;
case GDK_DRAG_ENTER:
case GDK_DRAG_LEAVE:
case GDK_DRAG_MOTION:
case GDK_DROP_START:
event->dnd.x = x;
event->dnd.y = y;
break;
default:
break;
}
+19 -50
View File
@@ -649,94 +649,46 @@ gdk_frame_clock_get_refresh_info (GdkFrameClock *frame_clock,
void
_gdk_frame_clock_emit_flush_events (GdkFrameClock *frame_clock)
{
guint64 before = g_get_monotonic_time ();
g_signal_emit (frame_clock, signals[FLUSH_EVENTS], 0);
if (gdk_profiler_is_running ())
gdk_profiler_add_mark (before * 1000,
(g_get_monotonic_time () - before) * 1000,
"frameclock ::flush-events", "");
}
void
_gdk_frame_clock_emit_before_paint (GdkFrameClock *frame_clock)
{
guint64 before = g_get_monotonic_time ();
g_signal_emit (frame_clock, signals[BEFORE_PAINT], 0);
if (gdk_profiler_is_running ())
gdk_profiler_add_mark (before * 1000,
(g_get_monotonic_time () - before) * 1000,
"frameclock ::before-paint", "");
}
void
_gdk_frame_clock_emit_update (GdkFrameClock *frame_clock)
{
guint64 before = g_get_monotonic_time ();
g_signal_emit (frame_clock, signals[UPDATE], 0);
if (gdk_profiler_is_running ())
gdk_profiler_add_mark (before * 1000,
(g_get_monotonic_time () - before) * 1000,
"frameclock ::update", "");
}
void
_gdk_frame_clock_emit_layout (GdkFrameClock *frame_clock)
{
guint64 before = g_get_monotonic_time ();
g_signal_emit (frame_clock, signals[LAYOUT], 0);
if (gdk_profiler_is_running ())
gdk_profiler_add_mark (before * 1000,
(g_get_monotonic_time () - before) * 1000,
"frameclock ::layout", "");
}
void
_gdk_frame_clock_emit_paint (GdkFrameClock *frame_clock)
{
guint64 before = g_get_monotonic_time ();
g_signal_emit (frame_clock, signals[PAINT], 0);
if (gdk_profiler_is_running ())
gdk_profiler_add_mark (before * 1000,
(g_get_monotonic_time () - before) * 1000,
"frameclock ::paint", "");
}
void
_gdk_frame_clock_emit_after_paint (GdkFrameClock *frame_clock)
{
guint64 before = g_get_monotonic_time ();
g_signal_emit (frame_clock, signals[AFTER_PAINT], 0);
if (gdk_profiler_is_running ())
gdk_profiler_add_mark (before * 1000,
(g_get_monotonic_time () - before) * 1000,
"frameclock ::after-paint", "");
}
void
_gdk_frame_clock_emit_resume_events (GdkFrameClock *frame_clock)
{
guint64 before = g_get_monotonic_time ();
g_signal_emit (frame_clock, signals[RESUME_EVENTS], 0);
if (gdk_profiler_is_running ())
gdk_profiler_add_mark (before * 1000,
(g_get_monotonic_time () - before) * 1000,
"frameclock ::resume-events", "");
}
#ifdef G_ENABLE_DEBUG
static gint64
guess_refresh_interval (GdkFrameClock *frame_clock)
{
@@ -806,17 +758,34 @@ frame_clock_get_fps (GdkFrameClock *frame_clock)
return ((double) end_counter - start_counter) * G_USEC_PER_SEC / (end_timestamp - start_timestamp);
}
#endif
void
_gdk_frame_clock_add_timings_to_profiler (GdkFrameClock *clock,
GdkFrameTimings *timings)
{
#ifdef G_ENABLE_DEBUG
gdk_profiler_add_mark (timings->frame_time * 1000,
(timings->frame_end_time - timings->frame_time) * 1000,
"frame", "");
if (timings->layout_start_time != 0)
gdk_profiler_add_mark (timings->layout_start_time * 1000,
(timings->paint_start_time - timings->layout_start_time) * 1000,
"layout", "");
if (timings->paint_start_time != 0)
gdk_profiler_add_mark (timings->paint_start_time * 1000,
(timings->frame_end_time - timings->paint_start_time) * 1000,
"paint", "");
if (timings->presentation_time != 0)
gdk_profiler_add_mark (timings->presentation_time * 1000,
0,
"presentation", "");
gdk_profiler_set_counter (fps_counter,
timings->presentation_time * 1000,
timings->frame_end_time * 1000,
frame_clock_get_fps (clock));
#endif
}
+12 -10
View File
@@ -42,7 +42,9 @@ struct _GdkFrameClockIdlePrivate
gint64 frame_time;
gint64 min_next_frame_time;
gint64 sleep_serial;
#ifdef G_ENABLE_DEBUG
gint64 freeze_time;
#endif
guint flush_idle_id;
guint paint_idle_id;
@@ -317,7 +319,6 @@ gdk_frame_clock_paint_idle (void *data)
GdkFrameClockIdlePrivate *priv = clock_idle->priv;
gboolean skip_to_resume_events;
GdkFrameTimings *timings = NULL;
gint64 before = g_get_monotonic_time ();
priv->paint_idle_id = 0;
priv->in_paint_idle = TRUE;
@@ -408,13 +409,13 @@ gdk_frame_clock_paint_idle (void *data)
{
int iter;
#ifdef G_ENABLE_DEBUG
if (GDK_DEBUG_CHECK (FRAMES))
if (GDK_DEBUG_CHECK (FRAMES) || gdk_profiler_is_running ())
{
if (priv->phase != GDK_FRAME_CLOCK_PHASE_LAYOUT &&
(priv->requested & GDK_FRAME_CLOCK_PHASE_LAYOUT))
timings->layout_start_time = g_get_monotonic_time ();
}
#endif
#endif /* G_ENABLE_DEBUG */
priv->phase = GDK_FRAME_CLOCK_PHASE_LAYOUT;
/* We loop in the layout phase, because we don't want to progress
@@ -438,13 +439,13 @@ gdk_frame_clock_paint_idle (void *data)
if (priv->freeze_count == 0)
{
#ifdef G_ENABLE_DEBUG
if (GDK_DEBUG_CHECK (FRAMES))
if (GDK_DEBUG_CHECK (FRAMES) || gdk_profiler_is_running ())
{
if (priv->phase != GDK_FRAME_CLOCK_PHASE_PAINT &&
(priv->requested & GDK_FRAME_CLOCK_PHASE_PAINT))
timings->paint_start_time = g_get_monotonic_time ();
}
#endif
#endif /* G_ENABLE_DEBUG */
priv->phase = GDK_FRAME_CLOCK_PHASE_PAINT;
if (priv->requested & GDK_FRAME_CLOCK_PHASE_PAINT)
@@ -465,7 +466,7 @@ gdk_frame_clock_paint_idle (void *data)
priv->phase = GDK_FRAME_CLOCK_PHASE_NONE;
}
#ifdef G_ENABLE_DEBUG
if (GDK_DEBUG_CHECK (FRAMES))
if (GDK_DEBUG_CHECK (FRAMES) || gdk_profiler_is_running ())
timings->frame_end_time = g_get_monotonic_time ();
#endif /* G_ENABLE_DEBUG */
G_GNUC_FALLTHROUGH;
@@ -501,9 +502,6 @@ gdk_frame_clock_paint_idle (void *data)
if (priv->freeze_count == 0)
priv->sleep_serial = get_sleep_serial ();
if (gdk_profiler_is_running ())
gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "frameclock", "paint_idle");
return FALSE;
}
@@ -563,11 +561,13 @@ gdk_frame_clock_idle_freeze (GdkFrameClock *clock)
GdkFrameClockIdle *clock_idle = GDK_FRAME_CLOCK_IDLE (clock);
GdkFrameClockIdlePrivate *priv = clock_idle->priv;
#ifdef G_ENABLE_DEBUG
if (priv->freeze_count == 0)
{
if (gdk_profiler_is_running ())
priv->freeze_time = g_get_monotonic_time ();
}
#endif
priv->freeze_count++;
maybe_stop_idle (clock_idle);
@@ -594,6 +594,7 @@ gdk_frame_clock_idle_thaw (GdkFrameClock *clock)
priv->sleep_serial = get_sleep_serial ();
#ifdef G_ENABLE_DEBUG
if (gdk_profiler_is_running ())
{
if (priv->freeze_time != 0)
@@ -601,10 +602,11 @@ gdk_frame_clock_idle_thaw (GdkFrameClock *clock)
gint64 thaw_time = g_get_monotonic_time ();
gdk_profiler_add_mark (priv->freeze_time * 1000,
(thaw_time - priv->freeze_time) * 1000,
"frameclock freeze", "");
"freeze", "");
priv->freeze_time = 0;
}
}
#endif
}
}
+1 -2
View File
@@ -955,8 +955,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
if (priv->use_es < 0)
priv->use_es = !epoxy_is_desktop_gl ();
priv->has_debug_output = epoxy_has_gl_extension ("GL_ARB_debug_output") ||
epoxy_has_gl_extension ("GL_KHR_debug");
priv->has_debug_output = epoxy_has_gl_extension ("GL_ARB_debug_output");
#ifdef G_ENABLE_CONSISTENCY_CHECKS
if (priv->has_debug_output)
+9 -12
View File
@@ -100,7 +100,7 @@ gdk_rgba_free (GdkRGBA *rgba)
gboolean
gdk_rgba_is_clear (const GdkRGBA *rgba)
{
return rgba->alpha < ((float) 0x00ff / (float) 0xffff);
return rgba->alpha < ((double) 0x00ff / (double) 0xffff);
}
/**
@@ -115,7 +115,7 @@ gdk_rgba_is_clear (const GdkRGBA *rgba)
gboolean
gdk_rgba_is_opaque (const GdkRGBA *rgba)
{
return rgba->alpha > ((float)0xff00 / (float)0xffff);
return rgba->alpha > ((double)0xff00 / (double)0xffff);
}
#define SKIP_WHITESPACES(s) while (*(s) == ' ') (s)++;
@@ -398,25 +398,23 @@ gdk_rgba_to_string (const GdkRGBA *rgba)
static gboolean
parse_color_channel_value (GtkCssParser *parser,
float *value,
double *value,
gboolean is_percentage)
{
double dvalue;
if (is_percentage)
{
if (!gtk_css_parser_consume_percentage (parser, &dvalue))
if (!gtk_css_parser_consume_percentage (parser, value))
return FALSE;
*value = CLAMP (dvalue, 0.0, 100.0) / 100.0;
*value = CLAMP (*value, 0.0, 100.0) / 100.0;
return TRUE;
}
else
{
if (!gtk_css_parser_consume_number (parser, &dvalue))
if (!gtk_css_parser_consume_number (parser, value))
return FALSE;
*value = CLAMP (dvalue, 0.0, 255.0) / 255.0;
*value = CLAMP (*value, 0.0, 255.0) / 255.0;
return TRUE;
}
}
@@ -427,7 +425,6 @@ parse_color_channel (GtkCssParser *parser,
gpointer data)
{
GdkRGBA *rgba = data;
double dvalue;
switch (arg)
{
@@ -453,10 +450,10 @@ parse_color_channel (GtkCssParser *parser,
return 1;
case 3:
if (!gtk_css_parser_consume_number (parser, &dvalue))
if (!gtk_css_parser_consume_number (parser, &rgba->alpha))
return 0;
rgba->alpha = CLAMP (dvalue, 0.0, 1.0);
rgba->alpha = CLAMP (rgba->alpha, 0.0, 1.0);
return 1;
default:
+8 -8
View File
@@ -36,10 +36,10 @@ G_BEGIN_DECLS
struct _GdkRGBA
{
float red;
float green;
float blue;
float alpha;
gdouble red;
gdouble green;
gdouble blue;
gdouble alpha;
};
#define GDK_TYPE_RGBA (gdk_rgba_get_type ())
@@ -53,15 +53,15 @@ GDK_AVAILABLE_IN_ALL
void gdk_rgba_free (GdkRGBA *rgba);
GDK_AVAILABLE_IN_ALL
gboolean gdk_rgba_is_clear (const GdkRGBA *rgba) G_GNUC_PURE;
gboolean gdk_rgba_is_clear (const GdkRGBA *rgba);
GDK_AVAILABLE_IN_ALL
gboolean gdk_rgba_is_opaque (const GdkRGBA *rgba) G_GNUC_PURE;
gboolean gdk_rgba_is_opaque (const GdkRGBA *rgba);
GDK_AVAILABLE_IN_ALL
guint gdk_rgba_hash (gconstpointer p) G_GNUC_PURE;
guint gdk_rgba_hash (gconstpointer p);
GDK_AVAILABLE_IN_ALL
gboolean gdk_rgba_equal (gconstpointer p1,
gconstpointer p2) G_GNUC_PURE;
gconstpointer p2);
GDK_AVAILABLE_IN_ALL
gboolean gdk_rgba_parse (GdkRGBA *rgba,
+2 -2
View File
@@ -248,10 +248,10 @@ gdk_seat_get_capabilities (GdkSeat *seat)
* elsewhere.
* @event: (nullable): the event that is triggering the grab, or %NULL if none
* is available.
* @prepare_func: (nullable) (scope call): function to
* @prepare_func: (nullable) (scope call) (closure prepare_func_data): function to
* prepare the surface to be grabbed, it can be %NULL if @surface is
* visible before this call.
* @prepare_func_data: (closure): user data to pass to @prepare_func
* @prepare_func_data: user data to pass to @prepare_func
*
* Grabs the seat so that all events corresponding to the given @capabilities
* are passed to this application until the seat is ungrabbed with gdk_seat_ungrab(),
+7 -10
View File
@@ -3583,13 +3583,7 @@ gdk_surface_register_dnd (GdkSurface *surface)
*
* Starts a drag and creates a new drag context for it.
*
* This function is called by the drag source. After this call, you
* probably want to set up the drag icon using the surface returned
* by gdk_drag_get_drag_surface().
*
* Note: if @actions include %GDK_ACTION_MOVE, you need to listen for
* the #GdkDrag::dnd-finished signal and delete the data at the source
* if gdk_drag_get_selected_action() returns %GDK_ACTION_MOVE.
* This function is called by the drag source.
*
* Returns: (transfer full) (nullable): a newly created #GdkDrag or
* %NULL on error.
@@ -4005,6 +3999,7 @@ rewrite_event_for_toplevel (GdkEvent *event)
g_set_object (&event->any.surface, surface);
}
#ifdef G_ENABLE_DEBUG
static void
add_event_mark (GdkEvent *event,
gint64 time,
@@ -4071,9 +4066,6 @@ add_event_mark (GdkEvent *event,
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
message = g_strdup ("");
break;
case GDK_TOUCHPAD_SWIPE:
case GDK_TOUCHPAD_PINCH:
case GDK_SCROLL:
@@ -4115,11 +4107,14 @@ add_event_mark (GdkEvent *event,
g_free (message);
}
#endif
gboolean
gdk_surface_handle_event (GdkEvent *event)
{
#ifdef G_ENABLE_DEBUG
gint64 begin_time = g_get_monotonic_time ();
#endif
gboolean handled = FALSE;
if (check_autohide (event))
@@ -4138,8 +4133,10 @@ gdk_surface_handle_event (GdkEvent *event)
g_signal_emit (gdk_event_get_surface (event), signals[EVENT], 0, event, &handled);
}
#ifdef G_ENABLE_DEBUG
if (gdk_profiler_is_running ())
add_event_mark (event, begin_time, g_get_monotonic_time () - begin_time);
#endif
return handled;
}
+2 -2
View File
@@ -51,9 +51,9 @@ GdkTexture * gdk_texture_new_from_file (GFile
GError **error);
GDK_AVAILABLE_IN_ALL
int gdk_texture_get_width (GdkTexture *texture) G_GNUC_PURE;
int gdk_texture_get_width (GdkTexture *texture);
GDK_AVAILABLE_IN_ALL
int gdk_texture_get_height (GdkTexture *texture) G_GNUC_PURE;
int gdk_texture_get_height (GdkTexture *texture);
GDK_AVAILABLE_IN_ALL
void gdk_texture_download (GdkTexture *texture,
+3 -4
View File
@@ -568,12 +568,11 @@ typedef enum
* @GDK_ACTION_MOVE: Move the data, i.e. first copy it, then delete
* it from the source using the DELETE target of the X selection protocol.
* @GDK_ACTION_LINK: Add a link to the data. Note that this is only
* useful if source and destination agree on what it means, and is not
* supported on all platforms.
* useful if source and destination agree on what it means.
* @GDK_ACTION_ASK: Ask the user what to do with the data.
*
* Used in #GdkDrop and #GdkDrag to indicate the actions that the
* destination can and should do with the dropped data.
* Used in #GdkDrag to indicate what the destination
* should do with the dropped data.
*/
typedef enum
{
+3 -2
View File
@@ -55,6 +55,9 @@ _gdk_quartz_display_open (const gchar *display_name)
if (_gdk_display != NULL)
return NULL;
/* Initialize application */
[NSApplication sharedApplication];
_gdk_display = g_object_new (gdk_quartz_display_get_type (), NULL);
_gdk_device_manager = _gdk_device_manager_new (_gdk_display);
@@ -64,8 +67,6 @@ _gdk_quartz_display_open (const gchar *display_name)
_gdk_quartz_events_init ();
/* Initialize application */
[NSApplication sharedApplication];
#if 0
/* FIXME: Remove the #if 0 when we have these functions */
_gdk_quartz_dnd_init ();
+16 -14
View File
@@ -680,6 +680,7 @@ gdk_quartz_keymap_translate_keyboard_state (GdkKeymap *keymap,
{
guint tmp_keyval;
GdkModifierType bit;
guint tmp_modifiers = 0;
if (keyval)
*keyval = 0;
@@ -693,23 +694,24 @@ gdk_quartz_keymap_translate_keyboard_state (GdkKeymap *keymap,
if (hardware_keycode < 0 || hardware_keycode >= NUM_KEYCODES)
return FALSE;
/* Check if modifiers modify the keyval */
for (bit = GDK_SHIFT_MASK; bit < GDK_BUTTON1_MASK; bit <<= 1)
{
if (translate_keysym (hardware_keycode,
(bit == GDK_MOD1_MASK) ? 0 : group,
state & ~bit,
NULL, NULL) !=
translate_keysym (hardware_keycode,
(bit == GDK_MOD1_MASK) ? 1 : group,
state | bit,
NULL, NULL))
tmp_modifiers |= bit;
}
tmp_keyval = translate_keysym (hardware_keycode, group, state, level, effective_group);
/* Check if modifiers modify the keyval */
if (consumed_modifiers)
{
guint tmp_modifiers = (state & GDK_MODIFIER_MASK);
for (bit = 1; bit <= tmp_modifiers; bit <<= 1)
{
if ((bit & tmp_modifiers) &&
translate_keysym (hardware_keycode, group, state & ~bit,
NULL, NULL) == tmp_keyval)
tmp_modifiers &= ~bit;
}
*consumed_modifiers = tmp_modifiers;
}
*consumed_modifiers = tmp_modifiers;
if (keyval)
*keyval = tmp_keyval;
+3 -1
View File
@@ -795,7 +795,8 @@ _gdk_quartz_display_create_surface_impl (GdkDisplay *display,
if (window->surface_type == GDK_SURFACE_TEMP)
{
style_mask = NSBorderlessWindowMask;
/* without NSMiniaturizableWindowMask window will not minimize */
style_mask = NSBorderlessWindowMask | NSMiniaturizableWindowMask;
}
else
{
@@ -2710,6 +2711,7 @@ gdk_surface_impl_quartz_class_init (GdkSurfaceImplQuartzClass *klass)
impl_class->set_decorations = gdk_quartz_surface_set_decorations;
impl_class->get_decorations = gdk_quartz_surface_get_decorations;
impl_class->set_functions = gdk_quartz_surface_set_functions;
impl_class->set_functions = gdk_quartz_surface_set_functions;
impl_class->begin_resize_drag = gdk_quartz_surface_begin_resize_drag;
impl_class->begin_move_drag = gdk_quartz_surface_begin_move_drag;
impl_class->set_opacity = gdk_quartz_surface_set_opacity;
-12
View File
@@ -1,12 +0,0 @@
wayland_cursor_sources = files([
'wayland-cursor.c',
'xcursor.c',
'os-compatibility.c'
])
libwayland_cursor = static_library('wayland+cursor',
sources: wayland_cursor_sources,
include_directories: [ confinc, ],
dependencies: [ glib_dep, ],
c_args: common_cflags,
link_args: common_ldflags)
-173
View File
@@ -1,173 +0,0 @@
/*
* Copyright © 2012 Collabora, Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "config.h"
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#define HAVE_MEMFD_CREATE
#ifdef HAVE_MEMFD_CREATE
#include <sys/mman.h>
#endif
#include "os-compatibility.h"
#ifndef HAVE_MKOSTEMP
static int
set_cloexec_or_close(int fd)
{
long flags;
if (fd == -1)
return -1;
flags = fcntl(fd, F_GETFD);
if (flags == -1)
goto err;
if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1)
goto err;
return fd;
err:
close(fd);
return -1;
}
#endif
static int
create_tmpfile_cloexec(char *tmpname)
{
int fd;
#ifdef HAVE_MKOSTEMP
fd = mkostemp(tmpname, O_CLOEXEC);
if (fd >= 0)
unlink(tmpname);
#else
fd = mkstemp(tmpname);
if (fd >= 0) {
fd = set_cloexec_or_close(fd);
unlink(tmpname);
}
#endif
return fd;
}
/*
* Create a new, unique, anonymous file of the given size, and
* return the file descriptor for it. The file descriptor is set
* CLOEXEC. The file is immediately suitable for mmap()'ing
* the given size at offset zero.
*
* The file should not have a permanent backing store like a disk,
* but may have if XDG_RUNTIME_DIR is not properly implemented in OS.
*
* The file name is deleted from the file system.
*
* The file is suitable for buffer sharing between processes by
* transmitting the file descriptor over Unix sockets using the
* SCM_RIGHTS methods.
*
* If the C library implements posix_fallocate(), it is used to
* guarantee that disk space is available for the file at the
* given size. If disk space is insufficent, errno is set to ENOSPC.
* If posix_fallocate() is not supported, program may receive
* SIGBUS on accessing mmap()'ed file contents instead.
*
* If the C library implements memfd_create(), it is used to create the
* file purely in memory, without any backing file name on the file
* system, and then sealing off the possibility of shrinking it. This
* can then be checked before accessing mmap()'ed file contents, to
* make sure SIGBUS can't happen. It also avoids requiring
* XDG_RUNTIME_DIR.
*/
int
os_create_anonymous_file(off_t size)
{
static const char template[] = "/wayland-cursor-shared-XXXXXX";
const char *path;
char *name;
int fd;
int ret;
#ifdef HAVE_MEMFD_CREATE
fd = memfd_create("wayland-cursor", MFD_CLOEXEC | MFD_ALLOW_SEALING);
if (fd >= 0) {
/* We can add this seal before calling posix_fallocate(), as
* the file is currently zero-sized anyway.
*
* There is also no need to check for the return value, we
* couldn't do anything with it anyway.
*/
fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
} else
#endif
{
path = getenv("XDG_RUNTIME_DIR");
if (!path) {
errno = ENOENT;
return -1;
}
name = malloc(strlen(path) + sizeof(template));
if (!name)
return -1;
strcpy(name, path);
strcat(name, template);
fd = create_tmpfile_cloexec(name);
free(name);
if (fd < 0)
return -1;
}
#ifdef HAVE_POSIX_FALLOCATE
ret = posix_fallocate(fd, 0, size);
if (ret != 0) {
close(fd);
errno = ret;
return -1;
}
#else
ret = ftruncate(fd, size);
if (ret < 0) {
close(fd);
return -1;
}
#endif
return fd;
}
-34
View File
@@ -1,34 +0,0 @@
/*
* Copyright © 2012 Collabora, Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef OS_COMPATIBILITY_H
#define OS_COMPATIBILITY_H
#include <sys/types.h>
int
os_create_anonymous_file(off_t size);
#endif /* OS_COMPATIBILITY_H */
-385
View File
@@ -1,385 +0,0 @@
/*
* Copyright © 2012 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "config.h"
#include "xcursor.h"
#include "wayland-cursor.h"
#include "wayland-client.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <errno.h>
#include <os-compatibility.h>
#include <glib.h>
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
struct shm_pool {
struct wl_shm_pool *pool;
int fd;
unsigned int size;
unsigned int used;
char *data;
};
static struct shm_pool *
shm_pool_create(struct wl_shm *shm, int size)
{
struct shm_pool *pool;
pool = malloc(sizeof *pool);
if (!pool)
return NULL;
pool->fd = os_create_anonymous_file (size);
if (pool->fd < 0)
goto err_free;
pool->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
pool->fd, 0);
if (pool->data == MAP_FAILED)
goto err_close;
pool->pool = wl_shm_create_pool(shm, pool->fd, size);
pool->size = size;
pool->used = 0;
return pool;
err_close:
close(pool->fd);
err_free:
free(pool);
return NULL;
}
static int
shm_pool_resize(struct shm_pool *pool, int size)
{
if (ftruncate(pool->fd, size) < 0)
return 0;
#ifdef HAVE_POSIX_FALLOCATE
errno = posix_fallocate(pool->fd, 0, size);
if (errno != 0)
return 0;
#endif
wl_shm_pool_resize(pool->pool, size);
munmap(pool->data, pool->size);
pool->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
pool->fd, 0);
if (pool->data == (void *)-1)
return 0;
pool->size = size;
return 1;
}
static int
shm_pool_allocate(struct shm_pool *pool, int size)
{
int offset;
if (pool->used + size > pool->size)
if (!shm_pool_resize(pool, 2 * pool->size + size))
return -1;
offset = pool->used;
pool->used += size;
return offset;
}
static void
shm_pool_destroy(struct shm_pool *pool)
{
munmap(pool->data, pool->size);
wl_shm_pool_destroy(pool->pool);
close(pool->fd);
free(pool);
}
struct wl_cursor_theme {
unsigned int cursor_count;
struct wl_cursor **cursors;
struct wl_shm *shm;
struct shm_pool *pool;
int size;
char *path;
};
struct cursor_image {
struct wl_cursor_image image;
struct wl_cursor_theme *theme;
struct wl_buffer *buffer;
int offset; /* data offset of this image in the shm pool */
};
struct cursor {
struct wl_cursor cursor;
uint32_t total_delay; /* length of the animation in ms */
};
/** Get an shm buffer for a cursor image
*
* \param image The cursor image
* \return An shm buffer for the cursor image. The user should not destroy
* the returned buffer.
*/
struct wl_buffer *
wl_cursor_image_get_buffer(struct wl_cursor_image *_img)
{
struct cursor_image *image = (struct cursor_image *) _img;
struct wl_cursor_theme *theme = image->theme;
if (!image->buffer) {
image->buffer =
wl_shm_pool_create_buffer(theme->pool->pool,
image->offset,
_img->width, _img->height,
_img->width * 4,
WL_SHM_FORMAT_ARGB8888);
};
return image->buffer;
}
static void
wl_cursor_image_destroy(struct wl_cursor_image *_img)
{
struct cursor_image *image = (struct cursor_image *) _img;
if (image->buffer)
wl_buffer_destroy(image->buffer);
free(image);
}
static void
wl_cursor_destroy(struct wl_cursor *cursor)
{
unsigned int i;
for (i = 0; i < cursor->image_count; i++)
wl_cursor_image_destroy(cursor->images[i]);
free(cursor->images);
free(cursor->name);
free(cursor);
}
static struct wl_cursor *
wl_cursor_create_from_xcursor_images(XcursorImages *images,
struct wl_cursor_theme *theme,
const char *name,
unsigned int load_size)
{
struct cursor *cursor;
struct cursor_image *image;
int i, size;
cursor = malloc(sizeof *cursor);
if (!cursor)
return NULL;
cursor->cursor.images =
malloc(images->nimage * sizeof cursor->cursor.images[0]);
if (!cursor->cursor.images) {
free(cursor);
return NULL;
}
cursor->cursor.name = strdup(name);
cursor->cursor.size = load_size;
cursor->total_delay = 0;
for (i = 0; i < images->nimage; i++) {
image = malloc(sizeof *image);
if (image == NULL)
break;
image->theme = theme;
image->buffer = NULL;
image->image.width = images->images[i]->width;
image->image.height = images->images[i]->height;
image->image.hotspot_x = images->images[i]->xhot;
image->image.hotspot_y = images->images[i]->yhot;
image->image.delay = images->images[i]->delay;
size = image->image.width * image->image.height * 4;
image->offset = shm_pool_allocate(theme->pool, size);
if (image->offset < 0) {
free(image);
break;
}
/* copy pixels to shm pool */
memcpy(theme->pool->data + image->offset,
images->images[i]->pixels, size);
cursor->total_delay += image->image.delay;
cursor->cursor.images[i] = (struct wl_cursor_image *) image;
}
cursor->cursor.image_count = i;
if (cursor->cursor.image_count == 0) {
free(cursor->cursor.name);
free(cursor->cursor.images);
free(cursor);
return NULL;
}
return &cursor->cursor;
}
static void
load_cursor(struct wl_cursor_theme *theme, const char *name, unsigned int size)
{
XcursorImages *images;
struct wl_cursor *cursor;
char *path;
path = g_strconcat (theme->path, "/", name, NULL);
images = xcursor_load_images (path, size);
g_free (path);
if (!images)
return;
cursor = wl_cursor_create_from_xcursor_images(images, theme, name, size);
if (cursor) {
theme->cursor_count++;
theme->cursors =
realloc(theme->cursors,
theme->cursor_count * sizeof theme->cursors[0]);
if (theme->cursors == NULL) {
theme->cursor_count--;
free(cursor);
} else {
theme->cursors[theme->cursor_count - 1] = cursor;
}
}
xcursor_images_destroy (images);
}
/** Load a cursor theme to memory shared with the compositor
*
* \param name The name of the cursor theme to load. If %NULL, the default
* theme will be loaded.
* \param size Desired size of the cursor images.
* \param shm The compositor's shm interface.
*
* \return An object representing the theme that should be destroyed with
* wl_cursor_theme_destroy() or %NULL on error. If no theme with the given
* name exists, a default theme will be loaded.
*/
struct wl_cursor_theme *
wl_cursor_theme_create(const char *path, int size, struct wl_shm *shm)
{
struct wl_cursor_theme *theme;
theme = malloc(sizeof *theme);
if (!theme)
return NULL;
theme->path = strdup (path);
theme->size = size;
theme->cursor_count = 0;
theme->cursors = NULL;
theme->pool = shm_pool_create(shm, size * size * 4);
if (!theme->pool) {
free (theme->path);
free (theme);
return NULL;
}
return theme;
}
/** Destroys a cursor theme object
*
* \param theme The cursor theme to be destroyed
*/
void
wl_cursor_theme_destroy(struct wl_cursor_theme *theme)
{
unsigned int i;
for (i = 0; i < theme->cursor_count; i++)
wl_cursor_destroy(theme->cursors[i]);
shm_pool_destroy(theme->pool);
free(theme->cursors);
free(theme->path);
free(theme);
}
/** Get the cursor for a given name from a cursor theme
*
* \param theme The cursor theme
* \param name Name of the desired cursor
* \return The theme's cursor of the given name or %NULL if there is no
* such cursor
*/
struct wl_cursor *
wl_cursor_theme_get_cursor(struct wl_cursor_theme *theme,
const char *name,
unsigned int scale)
{
unsigned int i;
unsigned int size;
size = theme->size * scale;
for (i = 0; i < theme->cursor_count; i++) {
if (size == theme->cursors[i]->size &&
strcmp(name, theme->cursors[i]->name) == 0)
return theme->cursors[i];
}
load_cursor (theme, name, size);
if (i < theme->cursor_count) {
if (size == theme->cursors[i]->size &&
strcmp (name, theme->cursors[theme->cursor_count - 1]->name) == 0)
return theme->cursors[theme->cursor_count - 1];
}
return NULL;
}
-72
View File
@@ -1,72 +0,0 @@
/*
* Copyright © 2012 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef WAYLAND_CURSOR_H
#define WAYLAND_CURSOR_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
struct wl_cursor_theme;
struct wl_buffer;
struct wl_shm;
struct wl_cursor_image {
uint32_t width; /* actual width */
uint32_t height; /* actual height */
uint32_t hotspot_x; /* hot spot x (must be inside image) */
uint32_t hotspot_y; /* hot spot y (must be inside image) */
uint32_t delay; /* animation delay to next frame (ms) */
};
struct wl_cursor {
unsigned int image_count;
struct wl_cursor_image **images;
char *name;
unsigned int size;
};
struct wl_cursor_theme *
wl_cursor_theme_create(const char *name, int size, struct wl_shm *shm);
void
wl_cursor_theme_destroy(struct wl_cursor_theme *theme);
struct wl_cursor *
wl_cursor_theme_get_cursor(struct wl_cursor_theme *theme,
const char *name,
unsigned int scale);
struct wl_buffer *
wl_cursor_image_get_buffer(struct wl_cursor_image *image);
#ifdef __cplusplus
}
#endif
#endif
-612
View File
@@ -1,612 +0,0 @@
/*
* Copyright © 2002 Keith Packard
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "xcursor.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
/*
* From libXcursor/include/X11/extensions/Xcursor.h
*/
#define XcursorTrue 1
#define XcursorFalse 0
/*
* Cursor files start with a header. The header
* contains a magic number, a version number and a
* table of contents which has type and offset information
* for the remaining tables in the file.
*
* File minor versions increment for compatible changes
* File major versions increment for incompatible changes (never, we hope)
*
* Chunks of the same type are always upward compatible. Incompatible
* changes are made with new chunk types; the old data can remain under
* the old type. Upward compatible changes can add header data as the
* header lengths are specified in the file.
*
* File:
* FileHeader
* LISTofChunk
*
* FileHeader:
* CARD32 magic magic number
* CARD32 header bytes in file header
* CARD32 version file version
* CARD32 ntoc number of toc entries
* LISTofFileToc toc table of contents
*
* FileToc:
* CARD32 type entry type
* CARD32 subtype entry subtype (size for images)
* CARD32 position absolute file position
*/
#define XCURSOR_MAGIC 0x72756358 /* "Xcur" LSBFirst */
/*
* Current Xcursor version number. Will be substituted by configure
* from the version in the libXcursor configure.ac file.
*/
#define XCURSOR_LIB_MAJOR 1
#define XCURSOR_LIB_MINOR 1
#define XCURSOR_LIB_REVISION 13
#define XCURSOR_LIB_VERSION ((XCURSOR_LIB_MAJOR * 10000) + \
(XCURSOR_LIB_MINOR * 100) + \
(XCURSOR_LIB_REVISION))
/*
* This version number is stored in cursor files; changes to the
* file format require updating this version number
*/
#define XCURSOR_FILE_MAJOR 1
#define XCURSOR_FILE_MINOR 0
#define XCURSOR_FILE_VERSION ((XCURSOR_FILE_MAJOR << 16) | (XCURSOR_FILE_MINOR))
#define XCURSOR_FILE_HEADER_LEN (4 * 4)
#define XCURSOR_FILE_TOC_LEN (3 * 4)
typedef struct _XcursorFileToc {
XcursorUInt type; /* chunk type */
XcursorUInt subtype; /* subtype (size for images) */
XcursorUInt position; /* absolute position in file */
} XcursorFileToc;
typedef struct _XcursorFileHeader {
XcursorUInt magic; /* magic number */
XcursorUInt header; /* byte length of header */
XcursorUInt version; /* file version number */
XcursorUInt ntoc; /* number of toc entries */
XcursorFileToc *tocs; /* table of contents */
} XcursorFileHeader;
/*
* The rest of the file is a list of chunks, each tagged by type
* and version.
*
* Chunk:
* ChunkHeader
* <extra type-specific header fields>
* <type-specific data>
*
* ChunkHeader:
* CARD32 header bytes in chunk header + type header
* CARD32 type chunk type
* CARD32 subtype chunk subtype
* CARD32 version chunk type version
*/
#define XCURSOR_CHUNK_HEADER_LEN (4 * 4)
typedef struct _XcursorChunkHeader {
XcursorUInt header; /* bytes in chunk header */
XcursorUInt type; /* chunk type */
XcursorUInt subtype; /* chunk subtype (size for images) */
XcursorUInt version; /* version of this type */
} XcursorChunkHeader;
/*
* Here's a list of the known chunk types
*/
/*
* Comments consist of a 4-byte length field followed by
* UTF-8 encoded text
*
* Comment:
* ChunkHeader header chunk header
* CARD32 length bytes in text
* LISTofCARD8 text UTF-8 encoded text
*/
#define XCURSOR_COMMENT_TYPE 0xfffe0001
#define XCURSOR_COMMENT_VERSION 1
#define XCURSOR_COMMENT_HEADER_LEN (XCURSOR_CHUNK_HEADER_LEN + (1 *4))
#define XCURSOR_COMMENT_COPYRIGHT 1
#define XCURSOR_COMMENT_LICENSE 2
#define XCURSOR_COMMENT_OTHER 3
#define XCURSOR_COMMENT_MAX_LEN 0x100000
typedef struct _XcursorComment {
XcursorUInt version;
XcursorUInt comment_type;
char *comment;
} XcursorComment;
/*
* Each cursor image occupies a separate image chunk.
* The length of the image header follows the chunk header
* so that future versions can extend the header without
* breaking older applications
*
* Image:
* ChunkHeader header chunk header
* CARD32 width actual width
* CARD32 height actual height
* CARD32 xhot hot spot x
* CARD32 yhot hot spot y
* CARD32 delay animation delay
* LISTofCARD32 pixels ARGB pixels
*/
#define XCURSOR_IMAGE_TYPE 0xfffd0002
#define XCURSOR_IMAGE_VERSION 1
#define XCURSOR_IMAGE_HEADER_LEN (XCURSOR_CHUNK_HEADER_LEN + (5*4))
#define XCURSOR_IMAGE_MAX_SIZE 0x7fff /* 32767x32767 max cursor size */
typedef struct _XcursorFile XcursorFile;
struct _XcursorFile {
void *closure;
int (*read) (XcursorFile *file, unsigned char *buf, int len);
int (*write) (XcursorFile *file, unsigned char *buf, int len);
int (*seek) (XcursorFile *file, long offset, int whence);
};
typedef struct _XcursorComments {
int ncomment; /* number of comments */
XcursorComment **comments; /* array of XcursorComment pointers */
} XcursorComments;
/*
* From libXcursor/src/file.c
*/
static XcursorImage *
XcursorImageCreate (int width, int height)
{
XcursorImage *image;
if (width < 0 || height < 0)
return NULL;
if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE)
return NULL;
image = malloc (sizeof (XcursorImage) +
width * height * sizeof (XcursorPixel));
if (!image)
return NULL;
image->version = XCURSOR_IMAGE_VERSION;
image->pixels = (XcursorPixel *) (image + 1);
image->size = width > height ? width : height;
image->width = width;
image->height = height;
image->delay = 0;
return image;
}
static void
XcursorImageDestroy (XcursorImage *image)
{
free (image);
}
static XcursorImages *
XcursorImagesCreate (int size)
{
XcursorImages *images;
images = malloc (sizeof (XcursorImages) +
size * sizeof (XcursorImage *));
if (!images)
return NULL;
images->nimage = 0;
images->images = (XcursorImage **) (images + 1);
images->name = NULL;
return images;
}
static void
XcursorImagesDestroy (XcursorImages *images)
{
int n;
if (!images)
return;
for (n = 0; n < images->nimage; n++)
XcursorImageDestroy (images->images[n]);
if (images->name)
free (images->name);
free (images);
}
static XcursorBool
_XcursorReadUInt (XcursorFile *file, XcursorUInt *u)
{
unsigned char bytes[4];
if (!file || !u)
return XcursorFalse;
if ((*file->read) (file, bytes, 4) != 4)
return XcursorFalse;
*u = ((bytes[0] << 0) |
(bytes[1] << 8) |
(bytes[2] << 16) |
(bytes[3] << 24));
return XcursorTrue;
}
static void
_XcursorFileHeaderDestroy (XcursorFileHeader *fileHeader)
{
free (fileHeader);
}
static XcursorFileHeader *
_XcursorFileHeaderCreate (int ntoc)
{
XcursorFileHeader *fileHeader;
if (ntoc > 0x10000)
return NULL;
fileHeader = malloc (sizeof (XcursorFileHeader) +
ntoc * sizeof (XcursorFileToc));
if (!fileHeader)
return NULL;
fileHeader->magic = XCURSOR_MAGIC;
fileHeader->header = XCURSOR_FILE_HEADER_LEN;
fileHeader->version = XCURSOR_FILE_VERSION;
fileHeader->ntoc = ntoc;
fileHeader->tocs = (XcursorFileToc *) (fileHeader + 1);
return fileHeader;
}
static XcursorFileHeader *
_XcursorReadFileHeader (XcursorFile *file)
{
XcursorFileHeader head, *fileHeader;
XcursorUInt skip;
unsigned int n;
if (!file)
return NULL;
if (!_XcursorReadUInt (file, &head.magic))
return NULL;
if (head.magic != XCURSOR_MAGIC)
return NULL;
if (!_XcursorReadUInt (file, &head.header))
return NULL;
if (!_XcursorReadUInt (file, &head.version))
return NULL;
if (!_XcursorReadUInt (file, &head.ntoc))
return NULL;
skip = head.header - XCURSOR_FILE_HEADER_LEN;
if (skip)
if ((*file->seek) (file, skip, SEEK_CUR) == EOF)
return NULL;
fileHeader = _XcursorFileHeaderCreate (head.ntoc);
if (!fileHeader)
return NULL;
fileHeader->magic = head.magic;
fileHeader->header = head.header;
fileHeader->version = head.version;
fileHeader->ntoc = head.ntoc;
for (n = 0; n < fileHeader->ntoc; n++)
{
if (!_XcursorReadUInt (file, &fileHeader->tocs[n].type))
break;
if (!_XcursorReadUInt (file, &fileHeader->tocs[n].subtype))
break;
if (!_XcursorReadUInt (file, &fileHeader->tocs[n].position))
break;
}
if (n != fileHeader->ntoc)
{
_XcursorFileHeaderDestroy (fileHeader);
return NULL;
}
return fileHeader;
}
static XcursorBool
_XcursorSeekToToc (XcursorFile *file,
XcursorFileHeader *fileHeader,
int toc)
{
if (!file || !fileHeader || \
(*file->seek) (file, fileHeader->tocs[toc].position, SEEK_SET) == EOF)
return XcursorFalse;
return XcursorTrue;
}
static XcursorBool
_XcursorFileReadChunkHeader (XcursorFile *file,
XcursorFileHeader *fileHeader,
int toc,
XcursorChunkHeader *chunkHeader)
{
if (!file || !fileHeader || !chunkHeader)
return XcursorFalse;
if (!_XcursorSeekToToc (file, fileHeader, toc))
return XcursorFalse;
if (!_XcursorReadUInt (file, &chunkHeader->header))
return XcursorFalse;
if (!_XcursorReadUInt (file, &chunkHeader->type))
return XcursorFalse;
if (!_XcursorReadUInt (file, &chunkHeader->subtype))
return XcursorFalse;
if (!_XcursorReadUInt (file, &chunkHeader->version))
return XcursorFalse;
/* sanity check */
if (chunkHeader->type != fileHeader->tocs[toc].type ||
chunkHeader->subtype != fileHeader->tocs[toc].subtype)
return XcursorFalse;
return XcursorTrue;
}
#define dist(a,b) ((a) > (b) ? (a) - (b) : (b) - (a))
static XcursorDim
_XcursorFindBestSize (XcursorFileHeader *fileHeader,
XcursorDim size,
int *nsizesp)
{
unsigned int n;
int nsizes = 0;
XcursorDim bestSize = 0;
XcursorDim thisSize;
if (!fileHeader || !nsizesp)
return 0;
for (n = 0; n < fileHeader->ntoc; n++)
{
if (fileHeader->tocs[n].type != XCURSOR_IMAGE_TYPE)
continue;
thisSize = fileHeader->tocs[n].subtype;
if (!bestSize || dist (thisSize, size) < dist (bestSize, size))
{
bestSize = thisSize;
nsizes = 1;
}
else if (thisSize == bestSize)
nsizes++;
}
*nsizesp = nsizes;
return bestSize;
}
static int
_XcursorFindImageToc (XcursorFileHeader *fileHeader,
XcursorDim size,
int count)
{
unsigned int toc;
XcursorDim thisSize;
if (!fileHeader)
return 0;
for (toc = 0; toc < fileHeader->ntoc; toc++)
{
if (fileHeader->tocs[toc].type != XCURSOR_IMAGE_TYPE)
continue;
thisSize = fileHeader->tocs[toc].subtype;
if (thisSize != size)
continue;
if (!count)
break;
count--;
}
if (toc == fileHeader->ntoc)
return -1;
return toc;
}
static XcursorImage *
_XcursorReadImage (XcursorFile *file,
XcursorFileHeader *fileHeader,
int toc)
{
XcursorChunkHeader chunkHeader;
XcursorImage head;
XcursorImage *image;
int n;
XcursorPixel *p;
if (!file || !fileHeader)
return NULL;
if (!_XcursorFileReadChunkHeader (file, fileHeader, toc, &chunkHeader))
return NULL;
if (!_XcursorReadUInt (file, &head.width))
return NULL;
if (!_XcursorReadUInt (file, &head.height))
return NULL;
if (!_XcursorReadUInt (file, &head.xhot))
return NULL;
if (!_XcursorReadUInt (file, &head.yhot))
return NULL;
if (!_XcursorReadUInt (file, &head.delay))
return NULL;
/* sanity check data */
if (head.width > XCURSOR_IMAGE_MAX_SIZE ||
head.height > XCURSOR_IMAGE_MAX_SIZE)
return NULL;
if (head.width == 0 || head.height == 0)
return NULL;
if (head.xhot > head.width || head.yhot > head.height)
return NULL;
/* Create the image and initialize it */
image = XcursorImageCreate (head.width, head.height);
if (image == NULL)
return NULL;
if (chunkHeader.version < image->version)
image->version = chunkHeader.version;
image->size = chunkHeader.subtype;
image->xhot = head.xhot;
image->yhot = head.yhot;
image->delay = head.delay;
n = image->width * image->height;
p = image->pixels;
while (n--)
{
if (!_XcursorReadUInt (file, p))
{
XcursorImageDestroy (image);
return NULL;
}
p++;
}
return image;
}
static XcursorImages *
XcursorXcFileLoadImages (XcursorFile *file, int size)
{
XcursorFileHeader *fileHeader;
XcursorDim bestSize;
int nsize;
XcursorImages *images;
int n;
int toc;
if (!file || size < 0)
return NULL;
fileHeader = _XcursorReadFileHeader (file);
if (!fileHeader)
return NULL;
bestSize = _XcursorFindBestSize (fileHeader, (XcursorDim) size, &nsize);
if (!bestSize)
{
_XcursorFileHeaderDestroy (fileHeader);
return NULL;
}
images = XcursorImagesCreate (nsize);
if (!images)
{
_XcursorFileHeaderDestroy (fileHeader);
return NULL;
}
for (n = 0; n < nsize; n++)
{
toc = _XcursorFindImageToc (fileHeader, bestSize, n);
if (toc < 0)
break;
images->images[images->nimage] = _XcursorReadImage (file, fileHeader,
toc);
if (!images->images[images->nimage])
break;
images->nimage++;
}
_XcursorFileHeaderDestroy (fileHeader);
if (images->nimage != nsize)
{
XcursorImagesDestroy (images);
images = NULL;
}
return images;
}
static int
_XcursorStdioFileRead (XcursorFile *file, unsigned char *buf, int len)
{
FILE *f = file->closure;
return fread (buf, 1, len, f);
}
static int
_XcursorStdioFileWrite (XcursorFile *file, unsigned char *buf, int len)
{
FILE *f = file->closure;
return fwrite (buf, 1, len, f);
}
static int
_XcursorStdioFileSeek (XcursorFile *file, long offset, int whence)
{
FILE *f = file->closure;
return fseek (f, offset, whence);
}
static void
_XcursorStdioFileInitialize (FILE *stdfile, XcursorFile *file)
{
file->closure = stdfile;
file->read = _XcursorStdioFileRead;
file->write = _XcursorStdioFileWrite;
file->seek = _XcursorStdioFileSeek;
}
static XcursorImages *
XcursorFileLoadImages (FILE *file, int size)
{
XcursorFile f;
if (!file)
return NULL;
_XcursorStdioFileInitialize (file, &f);
return XcursorXcFileLoadImages (&f, size);
}
XcursorImages *
xcursor_load_images (const char *path, int size)
{
FILE *f;
XcursorImages *images;
f = fopen (path, "r");
if (!f)
return NULL;
images = XcursorFileLoadImages (f, size);
fclose (f);
return images;
}
void
xcursor_images_destroy (XcursorImages *images)
{
XcursorImagesDestroy (images);
}
-61
View File
@@ -1,61 +0,0 @@
/*
* Copyright © 2002 Keith Packard
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef XCURSOR_H
#define XCURSOR_H
typedef int XcursorBool;
typedef unsigned int XcursorUInt;
typedef XcursorUInt XcursorDim;
typedef XcursorUInt XcursorPixel;
typedef struct _XcursorImage {
XcursorUInt version; /* version of the image data */
XcursorDim size; /* nominal size for matching */
XcursorDim width; /* actual width */
XcursorDim height; /* actual height */
XcursorDim xhot; /* hot spot x (must be inside image) */
XcursorDim yhot; /* hot spot y (must be inside image) */
XcursorUInt delay; /* animation delay to next frame (ms) */
XcursorPixel *pixels; /* pointer to pixels */
} XcursorImage;
/*
* Other data structures exposed by the library API
*/
typedef struct _XcursorImages {
int nimage; /* number of images */
XcursorImage **images; /* array of XcursorImage pointers */
char *name; /* name used to load images */
} XcursorImages;
void
xcursor_images_destroy (XcursorImages *images);
XcursorImages *
xcursor_load_images (const char *path, int size);
#endif
+6 -8
View File
@@ -33,7 +33,8 @@
#include "gdkdisplay-wayland.h"
#include "gdkwayland.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "cursor/wayland-cursor.h"
#include <wayland-cursor.h>
static void
gdk_wayland_cursor_remove_from_cache (gpointer data, GObject *cursor)
@@ -118,12 +119,11 @@ name_fallback (const gchar *name)
static struct wl_cursor *
gdk_wayland_cursor_load_for_name (GdkWaylandDisplay *display_wayland,
struct wl_cursor_theme *theme,
int scale,
const char *name)
{
struct wl_cursor *c;
c = wl_cursor_theme_get_cursor (theme, name, scale);
c = wl_cursor_theme_get_cursor (theme, name);
if (!c)
{
const char *fallback;
@@ -131,7 +131,7 @@ gdk_wayland_cursor_load_for_name (GdkWaylandDisplay *display_wayland,
fallback = name_fallback (name);
if (fallback)
{
c = wl_cursor_theme_get_cursor (theme, fallback, scale);
c = wl_cursor_theme_get_cursor (theme, fallback);
}
}
@@ -172,8 +172,7 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
goto none;
c = gdk_wayland_cursor_load_for_name (display,
_gdk_wayland_display_get_cursor_theme (display),
desired_scale,
_gdk_wayland_display_get_scaled_cursor_theme (display, desired_scale),
gdk_cursor_get_name (cursor));
if (c)
{
@@ -271,8 +270,7 @@ _gdk_wayland_cursor_get_next_image_index (GdkWaylandDisplay *display,
}
c = gdk_wayland_cursor_load_for_name (display,
_gdk_wayland_display_get_cursor_theme (display),
scale,
_gdk_wayland_display_get_scaled_cursor_theme (display, scale),
gdk_cursor_get_name (cursor));
if (c)
+100 -73
View File
@@ -56,8 +56,6 @@
#define BTN_STYLUS3 0x149 /* Linux 4.15 */
#endif
#define GDK_SEAT_NOTE(seat,type,action) GDK_DISPLAY_NOTE(gdk_seat_get_display (GDK_SEAT (seat)),type,action)
typedef struct _GdkWaylandDevicePad GdkWaylandDevicePad;
typedef struct _GdkWaylandDevicePadClass GdkWaylandDevicePadClass;
@@ -1121,7 +1119,7 @@ data_offer_offer (void *data,
if (seat->pending_offer != offer)
{
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS,
g_message ("%p: offer for unknown offer %p of %s",
seat, offer, type));
return;
@@ -1193,7 +1191,7 @@ data_device_data_offer (void *data,
{
GdkWaylandSeat *seat = data;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("data device data offer, data device %p, offer %p",
data_device, offer));
@@ -1230,13 +1228,13 @@ data_device_enter (void *data,
if (offer != seat->pending_offer)
{
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS,
g_message ("%p: enter event for unknown offer %p, expected %p",
seat, offer, seat->pending_offer));
return;
}
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("data device enter, data device %p serial %u, surface %p, x %f y %f, offer %p",
data_device, serial, surface, wl_fixed_to_double (x), wl_fixed_to_double (y), offer));
@@ -1260,8 +1258,6 @@ data_device_enter (void *data,
seat->pending_offer = NULL;
seat->drop = gdk_wayland_drop_new (device, seat->drag, formats, dest_surface, offer, serial);
gdk_wayland_drop_set_source_actions (seat->drop, seat->pending_source_actions);
gdk_wayland_drop_set_action (seat->drop, seat->pending_action);
gdk_wayland_seat_discard_pending_offer (seat);
@@ -1276,7 +1272,7 @@ data_device_leave (void *data,
{
GdkWaylandSeat *seat = data;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("data device leave, data device %p", data_device));
if (seat->drop == NULL)
@@ -1302,7 +1298,7 @@ data_device_motion (void *data,
GdkWaylandSeat *seat = data;
int origin_x, origin_y;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("data device motion, data_device = %p, time = %d, x = %f, y = %f",
data_device, time, wl_fixed_to_double (x), wl_fixed_to_double (y)));
@@ -1329,7 +1325,7 @@ data_device_drop (void *data,
GdkWaylandSeat *seat = data;
int origin_x, origin_y;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("data device drop, data device %p", data_device));
gdk_surface_get_origin (gdk_drop_get_surface (seat->drop), &origin_x, &origin_y);
@@ -1575,7 +1571,7 @@ pointer_handle_enter (void *data,
&event->crossing.x_root,
&event->crossing.y_root);
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("enter, seat %p surface %p",
seat, seat->pointer_info.focus));
@@ -1623,7 +1619,7 @@ pointer_handle_leave (void *data,
&event->crossing.x_root,
&event->crossing.y_root);
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("leave, seat %p surface %p",
seat, seat->pointer_info.focus));
@@ -1669,7 +1665,7 @@ pointer_handle_motion (void *data,
&event->motion.x_root,
&event->motion.y_root);
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("motion %f %f, seat %p state %d",
wl_fixed_to_double (sx), wl_fixed_to_double (sy),
seat, event->motion.state));
@@ -1742,7 +1738,7 @@ pointer_handle_button (void *data,
else
seat->pointer_info.button_modifiers &= ~modifier;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("button %d %s, seat %p state %d",
event->button.button,
state ? "press" : "release",
@@ -1800,7 +1796,7 @@ pointer_handle_axis (void *data,
seat->pointer_info.time = time;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("scroll, axis %s, value %f, seat %p",
get_axis_name (axis), wl_fixed_to_double (value) / 10.0,
seat));
@@ -1815,7 +1811,7 @@ pointer_handle_frame (void *data,
{
GdkWaylandSeat *seat = data;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("frame, seat %p", seat));
gdk_wayland_seat_flush_frame_event (seat);
@@ -1856,7 +1852,7 @@ pointer_handle_axis_source (void *data,
pointer_frame->source = source;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("axis source %s, seat %p", get_axis_source_name (source), seat));
}
@@ -1888,7 +1884,7 @@ pointer_handle_axis_stop (void *data,
pointer_frame->is_scroll_stop = TRUE;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("axis %s stop, seat %p", get_axis_name (axis), seat));
}
@@ -1916,7 +1912,7 @@ pointer_handle_axis_discrete (void *data,
g_return_if_reached ();
}
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("discrete scroll, axis %s, value %d, seat %p",
get_axis_name (axis), value, seat));
}
@@ -1972,7 +1968,7 @@ keyboard_handle_enter (void *data,
gdk_event_set_device (event, seat->master_keyboard);
gdk_event_set_source_device (event, seat->keyboard);
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("focus in, seat %p surface %p",
seat, seat->keyboard_focus));
@@ -2013,7 +2009,7 @@ keyboard_handle_leave (void *data,
seat->keyboard_focus = NULL;
seat->repeat_key = 0;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("focus out, seat %p surface %p",
seat, event->any.surface));
@@ -2108,7 +2104,7 @@ deliver_key_event (GdkWaylandSeat *seat,
_gdk_wayland_display_deliver_event (seat->display, event);
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("keyboard %s event%s, surface %p, code %d, sym %d, "
"mods 0x%x",
(state ? "press" : "release"),
@@ -2396,7 +2392,7 @@ touch_handle_down (void *data,
mimic_pointer_emulating_touch_info (seat->touch_master, touch);
}
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("touch begin %f %f", event->touch.x, event->touch.y));
_gdk_wayland_display_deliver_event (seat->display, event);
@@ -2419,7 +2415,7 @@ touch_handle_up (void *data,
touch = gdk_wayland_seat_get_touch (seat, id);
event = _create_touch_event (seat, touch, GDK_TOUCH_END, time);
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("touch end %f %f", event->touch.x, event->touch.y));
_gdk_wayland_display_deliver_event (seat->display, event);
@@ -2451,7 +2447,7 @@ touch_handle_motion (void *data,
event = _create_touch_event (seat, touch, GDK_TOUCH_UPDATE, time);
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("touch update %f %f", event->touch.x, event->touch.y));
_gdk_wayland_display_deliver_event (seat->display, event);
@@ -2488,7 +2484,7 @@ touch_handle_cancel (void *data,
g_hash_table_iter_remove (&iter);
}
GDK_SEAT_NOTE (wayland_seat, EVENTS, g_message ("touch cancel"));
GDK_DISPLAY_NOTE (wayland_seat->display, EVENTS, g_message ("touch cancel"));
}
static void
@@ -2524,7 +2520,7 @@ emit_gesture_swipe_event (GdkWaylandSeat *seat,
&event->touchpad_swipe.x_root,
&event->touchpad_swipe.y_root);
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("swipe event %d, coords: %f %f, seat %p state %d",
event->any.type, event->touchpad_swipe.x,
event->touchpad_swipe.y, seat,
@@ -2627,7 +2623,7 @@ emit_gesture_pinch_event (GdkWaylandSeat *seat,
&event->touchpad_pinch.x_root,
&event->touchpad_pinch.y_root);
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("pinch event %d, coords: %f %f, seat %p state %d",
event->any.type, event->touchpad_pinch.x,
event->touchpad_pinch.y, seat,
@@ -2953,7 +2949,7 @@ seat_handle_capabilities (void *data,
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
GDK_SEAT_NOTE (seat, MISC,
GDK_DISPLAY_NOTE (seat->display, MISC,
g_message ("seat %p with %s%s%s", wl_seat,
(caps & WL_SEAT_CAPABILITY_POINTER) ? " pointer, " : "",
(caps & WL_SEAT_CAPABILITY_KEYBOARD) ? " keyboard, " : "",
@@ -3176,7 +3172,7 @@ seat_handle_name (void *data,
const char *name)
{
/* We don't care about the name. */
GDK_SEAT_NOTE (GDK_WAYLAND_SEAT (data), MISC,
GDK_DISPLAY_NOTE (GDK_WAYLAND_SEAT (data)->display, MISC,
g_message ("seat %p name %s", seat, name));
}
@@ -3490,7 +3486,7 @@ tablet_tool_handle_proximity_in (void *data,
gdk_wayland_surface_get_wl_output (surface));
pointer_surface_update_scale (tablet->master);
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("proximity in, seat %p surface %p tool %d",
seat, tablet->pointer_info.focus,
gdk_device_tool_get_tool_type (tool->tool)));
@@ -3502,10 +3498,11 @@ tablet_tool_handle_proximity_out (void *data,
{
GdkWaylandTabletToolData *tool = data;
GdkWaylandTabletData *tablet = tool->current_tablet;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tool->seat);
GdkEvent *event;
GDK_SEAT_NOTE (tool->seat, EVENTS,
g_message ("proximity out, seat %p, tool %d", tool->seat,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("proximity out, seat %p, tool %d", seat,
gdk_device_tool_get_tool_type (tool->tool)));
event = gdk_wayland_tablet_get_frame_event (tablet, GDK_PROXIMITY_OUT);
@@ -3601,7 +3598,7 @@ tablet_tool_handle_motion (void *data,
tablet->pointer_info.surface_x = wl_fixed_to_double (sx);
tablet->pointer_info.surface_y = wl_fixed_to_double (sy);
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet motion %f %f",
tablet->pointer_info.surface_x,
tablet->pointer_info.surface_y));
@@ -3634,7 +3631,7 @@ tablet_tool_handle_pressure (void *data,
_gdk_device_translate_axis (tablet->current_device, axis_index,
pressure, &tablet->axes[axis_index]);
GDK_SEAT_NOTE (tool->seat, EVENTS,
GDK_DISPLAY_NOTE (GDK_WAYLAND_SEAT (tool->seat)->display, EVENTS,
g_message ("tablet tool %d pressure %d",
gdk_device_tool_get_tool_type (tool->tool), pressure));
}
@@ -3651,7 +3648,7 @@ tablet_tool_handle_distance (void *data,
_gdk_device_translate_axis (tablet->current_device, axis_index,
distance, &tablet->axes[axis_index]);
GDK_SEAT_NOTE (tool->seat, EVENTS,
GDK_DISPLAY_NOTE (GDK_WAYLAND_SEAT (tool->seat)->display, EVENTS,
g_message ("tablet tool %d distance %d",
gdk_device_tool_get_tool_type (tool->tool), distance));
}
@@ -3674,7 +3671,7 @@ tablet_tool_handle_tilt (void *data,
wl_fixed_to_double (ytilt),
&tablet->axes[ytilt_axis_index]);
GDK_SEAT_NOTE (tool->seat, EVENTS,
GDK_DISPLAY_NOTE (GDK_WAYLAND_SEAT (tool->seat)->display, EVENTS,
g_message ("tablet tool %d tilt %f/%f",
gdk_device_tool_get_tool_type (tool->tool),
wl_fixed_to_double (xtilt), wl_fixed_to_double (ytilt)));
@@ -3729,7 +3726,7 @@ tablet_tool_handle_rotation (void *data,
wl_fixed_to_double (degrees),
&tablet->axes[axis_index]);
GDK_SEAT_NOTE (tool->seat, EVENTS,
GDK_DISPLAY_NOTE (GDK_WAYLAND_SEAT (tool->seat)->display, EVENTS,
g_message ("tablet tool %d rotation %f",
gdk_device_tool_get_tool_type (tool->tool),
wl_fixed_to_double (degrees)));
@@ -3747,7 +3744,7 @@ tablet_tool_handle_slider (void *data,
_gdk_device_translate_axis (tablet->current_device, axis_index,
position, &tablet->axes[axis_index]);
GDK_SEAT_NOTE (tool->seat, EVENTS,
GDK_DISPLAY_NOTE (GDK_WAYLAND_SEAT (tool->seat)->display, EVENTS,
g_message ("tablet tool %d slider %d",
gdk_device_tool_get_tool_type (tool->tool), position));
}
@@ -3763,7 +3760,7 @@ tablet_tool_handle_wheel (void *data,
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
GdkEvent *event;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet tool %d wheel %d/%d",
gdk_device_tool_get_tool_type (tool->tool), degrees, clicks));
@@ -3793,9 +3790,10 @@ tablet_tool_handle_frame (void *data,
{
GdkWaylandTabletToolData *tool = data;
GdkWaylandTabletData *tablet = tool->current_tablet;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
GdkEvent *frame_event;
GDK_SEAT_NOTE (tablet->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet frame, time %d", time));
frame_event = tablet->pointer_info.frame.event;
@@ -3838,8 +3836,10 @@ tablet_pad_ring_handle_source (void *data,
uint32_t source)
{
GdkWaylandTabletPadGroupData *group = data;
GdkWaylandTabletPadData *pad = group->pad;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad ring handle source, ring = %p source = %d",
wp_tablet_pad_ring, source));
@@ -3852,8 +3852,10 @@ tablet_pad_ring_handle_angle (void *data,
wl_fixed_t angle)
{
GdkWaylandTabletPadGroupData *group = data;
GdkWaylandTabletPadData *pad = group->pad;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad ring handle angle, ring = %p angle = %f",
wp_tablet_pad_ring, wl_fixed_to_double (angle)));
@@ -3865,8 +3867,10 @@ tablet_pad_ring_handle_stop (void *data,
struct zwp_tablet_pad_ring_v2 *wp_tablet_pad_ring)
{
GdkWaylandTabletPadGroupData *group = data;
GdkWaylandTabletPadData *pad = group->pad;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad ring handle stop, ring = %p", wp_tablet_pad_ring));
group->axis_tmp_info.is_stop = TRUE;
@@ -3882,7 +3886,7 @@ tablet_pad_ring_handle_frame (void *data,
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GdkEvent *event;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad ring handle frame, ring = %p", wp_tablet_pad_ring));
event = gdk_event_new (GDK_PAD_RING);
@@ -3912,8 +3916,10 @@ tablet_pad_strip_handle_source (void *data,
uint32_t source)
{
GdkWaylandTabletPadGroupData *group = data;
GdkWaylandTabletPadData *pad = group->pad;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad strip handle source, strip = %p source = %d",
wp_tablet_pad_strip, source));
@@ -3926,8 +3932,10 @@ tablet_pad_strip_handle_position (void *data,
uint32_t position)
{
GdkWaylandTabletPadGroupData *group = data;
GdkWaylandTabletPadData *pad = group->pad;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad strip handle position, strip = %p position = %d",
wp_tablet_pad_strip, position));
@@ -3939,8 +3947,10 @@ tablet_pad_strip_handle_stop (void *data,
struct zwp_tablet_pad_strip_v2 *wp_tablet_pad_strip)
{
GdkWaylandTabletPadGroupData *group = data;
GdkWaylandTabletPadData *pad = group->pad;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad strip handle stop, strip = %p",
wp_tablet_pad_strip));
@@ -3957,7 +3967,7 @@ tablet_pad_strip_handle_frame (void *data,
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GdkEvent *event;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad strip handle frame, strip = %p",
wp_tablet_pad_strip));
@@ -3989,9 +3999,11 @@ tablet_pad_group_handle_buttons (void *data,
struct wl_array *buttons)
{
GdkWaylandTabletPadGroupData *group = data;
GdkWaylandTabletPadData *pad = group->pad;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
uint32_t *p;
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad group handle buttons, pad group = %p, n_buttons = %" G_GSIZE_FORMAT,
wp_tablet_pad_group, buttons->size));
@@ -4009,8 +4021,10 @@ tablet_pad_group_handle_ring (void *data,
struct zwp_tablet_pad_ring_v2 *wp_tablet_pad_ring)
{
GdkWaylandTabletPadGroupData *group = data;
GdkWaylandTabletPadData *pad = group->pad;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad group handle ring, pad group = %p, ring = %p",
wp_tablet_pad_group, wp_tablet_pad_ring));
@@ -4028,8 +4042,10 @@ tablet_pad_group_handle_strip (void *data,
struct zwp_tablet_pad_strip_v2 *wp_tablet_pad_strip)
{
GdkWaylandTabletPadGroupData *group = data;
GdkWaylandTabletPadData *pad = group->pad;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad group handle strip, pad group = %p, strip = %p",
wp_tablet_pad_group, wp_tablet_pad_strip));
@@ -4047,8 +4063,10 @@ tablet_pad_group_handle_modes (void *data,
uint32_t modes)
{
GdkWaylandTabletPadGroupData *group = data;
GdkWaylandTabletPadData *pad = group->pad;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad group handle modes, pad group = %p, n_modes = %d",
wp_tablet_pad_group, modes));
@@ -4059,11 +4077,11 @@ static void
tablet_pad_group_handle_done (void *data,
struct zwp_tablet_pad_group_v2 *wp_tablet_pad_group)
{
#ifdef G_ENABLE_DEBUG
GdkWaylandTabletPadGroupData *group = data;
#endif
GdkWaylandTabletPadData *pad = group->pad;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad group handle done, pad group = %p",
wp_tablet_pad_group));
}
@@ -4081,7 +4099,7 @@ tablet_pad_group_handle_mode (void *data,
GdkEvent *event;
guint n_group;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad group handle mode, pad group = %p, mode = %d",
wp_tablet_pad_group, mode));
@@ -4117,8 +4135,9 @@ tablet_pad_handle_group (void *data,
{
GdkWaylandTabletPadData *pad = data;
GdkWaylandTabletPadGroupData *group;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad handle group, pad group = %p, group = %p",
wp_tablet_pad_group, wp_tablet_pad_group));
@@ -4138,8 +4157,9 @@ tablet_pad_handle_path (void *data,
const char *path)
{
GdkWaylandTabletPadData *pad = data;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad handle path, pad = %p, path = %s",
wp_tablet_pad, path));
@@ -4152,8 +4172,9 @@ tablet_pad_handle_buttons (void *data,
uint32_t buttons)
{
GdkWaylandTabletPadData *pad = data;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad handle buttons, pad = %p, n_buttons = %d",
wp_tablet_pad, buttons));
@@ -4165,8 +4186,9 @@ tablet_pad_handle_done (void *data,
struct zwp_tablet_pad_v2 *wp_tablet_pad)
{
GdkWaylandTabletPadData *pad = data;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad handle done, pad = %p", wp_tablet_pad));
pad->device =
@@ -4176,11 +4198,11 @@ tablet_pad_handle_done (void *data,
"input-source", GDK_SOURCE_TABLET_PAD,
"input-mode", GDK_MODE_SCREEN,
"display", gdk_seat_get_display (pad->seat),
"seat", pad->seat,
"seat", seat,
NULL);
_gdk_device_set_associated_device (pad->device, GDK_WAYLAND_SEAT (pad->seat)->master_keyboard);
gdk_seat_device_added (GDK_SEAT (pad->seat), pad->device);
_gdk_device_set_associated_device (pad->device, seat->master_keyboard);
gdk_seat_device_added (GDK_SEAT (seat), pad->device);
}
static void
@@ -4192,10 +4214,11 @@ tablet_pad_handle_button (void *data,
{
GdkWaylandTabletPadData *pad = data;
GdkWaylandTabletPadGroupData *group;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GdkEvent *event;
gint n_group;
GDK_SEAT_NOTE (pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad handle button, pad = %p, button = %d, state = %d",
wp_tablet_pad, button, state));
@@ -4205,7 +4228,7 @@ tablet_pad_handle_button (void *data,
event = gdk_event_new (state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED ?
GDK_PAD_BUTTON_PRESS :
GDK_PAD_BUTTON_RELEASE);
g_set_object (&event->any.surface, GDK_WAYLAND_SEAT (pad->seat)->keyboard_focus);
g_set_object (&event->any.surface, seat->keyboard_focus);
event->pad_button.button = button;
event->pad_button.group = n_group;
event->pad_button.mode = group->current_mode;
@@ -4213,7 +4236,8 @@ tablet_pad_handle_button (void *data,
gdk_event_set_device (event, pad->device);
gdk_event_set_source_device (event, pad->device);
_gdk_wayland_display_deliver_event (gdk_seat_get_display (pad->seat), event);
_gdk_wayland_display_deliver_event (gdk_seat_get_display (pad->seat),
event);
}
static void
@@ -4224,9 +4248,10 @@ tablet_pad_handle_enter (void *data,
struct wl_surface *surface)
{
GdkWaylandTabletPadData *pad = data;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GdkWaylandTabletData *tablet = zwp_tablet_v2_get_user_data (wp_tablet);
GDK_SEAT_NOTE (pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad handle enter, pad = %p, tablet = %p surface = %p",
wp_tablet_pad, wp_tablet, surface));
@@ -4242,8 +4267,9 @@ tablet_pad_handle_leave (void *data,
struct wl_surface *surface)
{
GdkWaylandTabletPadData *pad = data;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad handle leave, pad = %p, surface = %p",
wp_tablet_pad, surface));
@@ -4259,8 +4285,9 @@ tablet_pad_handle_removed (void *data,
struct zwp_tablet_pad_v2 *wp_tablet_pad)
{
GdkWaylandTabletPadData *pad = data;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
GDK_SEAT_NOTE (pad->seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("tablet pad handle removed, pad = %p", wp_tablet_pad));
/* Remove from the current tablet */
@@ -4432,7 +4459,7 @@ pointer_surface_enter (void *data,
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
GdkWaylandTabletData *tablet;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("pointer surface of seat %p entered output %p",
seat, output));
@@ -4461,7 +4488,7 @@ pointer_surface_leave (void *data,
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
GdkWaylandTabletData *tablet;
GDK_SEAT_NOTE (seat, EVENTS,
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("pointer surface of seat %p left output %p",
seat, output));
+42 -51
View File
@@ -47,7 +47,6 @@
#include "gdkglcontext-wayland.h"
#include "gdkvulkancontext-wayland.h"
#include "gdkwaylandmonitor.h"
#include "gdkprofilerprivate.h"
#include <wayland/pointer-gestures-unstable-v1-client-protocol.h>
#include "tablet-unstable-v2-client-protocol.h"
#include <wayland/xdg-shell-unstable-v6-client-protocol.h>
@@ -726,6 +725,7 @@ static void
gdk_wayland_display_finalize (GObject *object)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (object);
guint i;
_gdk_wayland_display_finalize_cursors (display_wayland);
@@ -733,10 +733,13 @@ gdk_wayland_display_finalize (GObject *object)
g_free (display_wayland->cursor_theme_name);
xkb_context_unref (display_wayland->xkb_context);
if (display_wayland->cursor_theme)
for (i = 0; i < GDK_WAYLAND_THEME_SCALES_COUNT; i++)
{
wl_cursor_theme_destroy (display_wayland->cursor_theme);
display_wayland->cursor_theme = NULL;
if (display_wayland->scaled_cursor_themes[i])
{
wl_cursor_theme_destroy (display_wayland->scaled_cursor_themes[i]);
display_wayland->scaled_cursor_themes[i] = NULL;
}
}
g_ptr_array_free (display_wayland->monitors, TRUE);
@@ -1056,33 +1059,6 @@ gdk_wayland_display_get_toplevel_surfaces (GdkDisplay *display)
return GDK_WAYLAND_DISPLAY (display)->toplevels;
}
static struct wl_cursor_theme *
get_cursor_theme (GdkWaylandDisplay *display_wayland,
const char *name,
int size)
{
const char * const *xdg_data_dirs;
struct wl_cursor_theme *theme = NULL;
int i;
xdg_data_dirs = g_get_system_data_dirs ();
for (i = 0; xdg_data_dirs[i]; i++)
{
char *path = g_build_filename (xdg_data_dirs[i], "icons", name, "cursors", NULL);
if (g_file_test (path, G_FILE_TEST_IS_DIR))
theme = wl_cursor_theme_create (path, size, display_wayland->shm);
g_free (path);
if (theme)
return theme;
}
/* This may fall back to builtin cursors */
return wl_cursor_theme_create ("/usr/share/icons/default/cursors", size, display_wayland->shm);
}
void
gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
const gchar *name,
@@ -1090,6 +1066,7 @@ gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY(display);
struct wl_cursor_theme *theme;
int i;
g_assert (display_wayland);
g_assert (display_wayland->shm);
@@ -1098,20 +1075,22 @@ gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
display_wayland->cursor_theme_size == size)
return;
theme = get_cursor_theme (display_wayland, name, size);
theme = wl_cursor_theme_load (name, size, display_wayland->shm);
if (theme == NULL)
{
g_warning ("Failed to load cursor theme %s", name);
return;
}
if (display_wayland->cursor_theme)
for (i = 0; i < GDK_WAYLAND_THEME_SCALES_COUNT; i++)
{
wl_cursor_theme_destroy (display_wayland->cursor_theme);
display_wayland->cursor_theme = NULL;
if (display_wayland->scaled_cursor_themes[i])
{
wl_cursor_theme_destroy (display_wayland->scaled_cursor_themes[i]);
display_wayland->scaled_cursor_themes[i] = NULL;
}
}
display_wayland->cursor_theme = theme;
display_wayland->scaled_cursor_themes[0] = theme;
if (display_wayland->cursor_theme_name != NULL)
g_free (display_wayland->cursor_theme_name);
display_wayland->cursor_theme_name = g_strdup (name);
@@ -1119,11 +1098,31 @@ gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
}
struct wl_cursor_theme *
_gdk_wayland_display_get_cursor_theme (GdkWaylandDisplay *display_wayland)
_gdk_wayland_display_get_scaled_cursor_theme (GdkWaylandDisplay *display_wayland,
guint scale)
{
g_assert (display_wayland->cursor_theme_name);
struct wl_cursor_theme *theme;
return display_wayland->cursor_theme;
g_assert (display_wayland->cursor_theme_name);
g_assert (scale <= GDK_WAYLAND_MAX_THEME_SCALE);
g_assert (scale >= 1);
theme = display_wayland->scaled_cursor_themes[scale - 1];
if (!theme)
{
theme = wl_cursor_theme_load (display_wayland->cursor_theme_name,
display_wayland->cursor_theme_size * scale,
display_wayland->shm);
if (theme == NULL)
{
g_warning ("Failed to load cursor theme %s with scale %u",
display_wayland->cursor_theme_name, scale);
return NULL;
}
display_wayland->scaled_cursor_themes[scale - 1] = theme;
}
return theme;
}
static void
@@ -1132,7 +1131,6 @@ _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland)
guint size;
const gchar *name;
GValue v = G_VALUE_INIT;
gint64 before = g_get_monotonic_time ();
g_assert (display_wayland);
g_assert (display_wayland->shm);
@@ -1152,12 +1150,6 @@ _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland)
gdk_wayland_display_set_cursor_theme (GDK_DISPLAY (display_wayland), name, size);
g_value_unset (&v);
if (gdk_profiler_is_running ())
{
gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "wayland", "load cursor theme");
}
}
guint32
@@ -2315,11 +2307,10 @@ xdg_output_handle_description (void *data,
struct zxdg_output_v1 *xdg_output,
const char *description)
{
GdkWaylandMonitor *monitor = (GdkWaylandMonitor *) data;
GDK_NOTE (MISC,
{
GdkWaylandMonitor *monitor = (GdkWaylandMonitor *) data;
g_message ("handle description xdg-output %d", monitor->id);
});
g_message ("handle description xdg-output %d", monitor->id));
}
static const struct zxdg_output_v1_listener xdg_output_listener = {
+2 -2
View File
@@ -26,6 +26,7 @@
#include <stdint.h>
#include <wayland-client.h>
#include <wayland-cursor.h>
#include <wayland-egl.h>
#include <gdk/wayland/tablet-unstable-v2-client-protocol.h>
#include <gdk/wayland/gtk-shell-client-protocol.h>
@@ -44,7 +45,6 @@
#include "gdkdisplayprivate.h"
#include "gdkwaylanddevice.h"
#include "cursor/wayland-cursor.h"
#include <epoxy/egl.h>
@@ -126,7 +126,7 @@ struct _GdkWaylandDisplay
GList *current_popups;
struct wl_cursor_theme *cursor_theme;
struct wl_cursor_theme *scaled_cursor_themes[GDK_WAYLAND_THEME_SCALES_COUNT];
gchar *cursor_theme_name;
int cursor_theme_size;
GHashTable *cursor_surface_cache;
+1 -1
View File
@@ -173,7 +173,7 @@ gdk_wayland_drag_drop_done (GdkDrag *drag,
GdkWaylandDrag *drag_wayland = GDK_WAYLAND_DRAG (drag);
GdkDevice *device = gdk_drag_get_device (drag);
gdk_wayland_seat_set_drag (gdk_device_get_seat (device), NULL);
gdk_wayland_seat_set_drag (gdk_device_get_seat (device), drag);
if (success)
{
+28 -24
View File
@@ -51,6 +51,7 @@ struct _GdkWaylandDrop
struct wl_data_offer *offer;
uint32_t source_actions;
uint32_t action;
GdkDragAction selected_action;
uint32_t serial;
};
@@ -115,43 +116,43 @@ gdk_wayland_drop_drop_set_status (GdkWaylandDrop *drop_wayland,
}
static void
gdk_wayland_drop_commit_status (GdkWaylandDrop *wayland_drop,
GdkDragAction actions)
gdk_wayland_drop_commit_status (GdkWaylandDrop *wayland_drop)
{
GdkDisplay *display;
uint32_t dnd_actions;
display = gdk_drop_get_display (GDK_DROP (wayland_drop));
dnd_actions = gdk_to_wl_actions (wayland_drop->selected_action);
if (GDK_WAYLAND_DISPLAY (display)->data_device_manager_version >=
WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION)
{
uint32_t dnd_actions;
uint32_t preferred_action;
dnd_actions = gdk_to_wl_actions (actions);
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
preferred_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
else if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
preferred_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
else if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
preferred_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
if (gdk_drag_action_is_unique (wayland_drop->selected_action))
{
wl_data_offer_set_actions (wayland_drop->offer, dnd_actions, dnd_actions);
}
else
preferred_action = 0;
wl_data_offer_set_actions (wayland_drop->offer, dnd_actions, preferred_action);
{
wl_data_offer_set_actions (wayland_drop->offer,
dnd_actions | WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK,
WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK);
}
}
gdk_wayland_drop_drop_set_status (wayland_drop, actions != 0);
gdk_wayland_drop_drop_set_status (wayland_drop, wayland_drop->selected_action != 0);
}
static void
gdk_wayland_drop_status (GdkDrop *drop,
GdkDragAction actions)
GdkDragAction action)
{
GdkWaylandDrop *wayland_drop = GDK_WAYLAND_DROP (drop);
GdkWaylandDrop *wayland_drop;
gdk_wayland_drop_commit_status (wayland_drop, actions);
wayland_drop = GDK_WAYLAND_DROP (drop);
wayland_drop->selected_action = action;
gdk_wayland_drop_commit_status (wayland_drop);
}
static void
@@ -162,9 +163,11 @@ gdk_wayland_drop_finish (GdkDrop *drop,
GdkDisplay *display = gdk_drop_get_display (drop);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
wayland_drop->selected_action = action;
if (action)
{
gdk_wayland_drop_commit_status (wayland_drop, action);
gdk_wayland_drop_commit_status (wayland_drop);
if (display_wayland->data_device_manager_version >=
WL_DATA_OFFER_FINISH_SINCE_VERSION)
@@ -181,17 +184,19 @@ gdk_wayland_drop_read_async (GdkDrop *drop,
gpointer user_data)
{
GdkWaylandDrop *wayland_drop = GDK_WAYLAND_DROP (drop);
GdkDisplay *display;
GInputStream *stream;
const char *mime_type;
int pipe_fd[2];
GError *error = NULL;
GTask *task;
display = gdk_drop_get_display (drop),
task = g_task_new (drop, cancellable, callback, user_data);
g_task_set_priority (task, io_priority);
g_task_set_source_tag (task, gdk_wayland_drop_read_async);
GDK_DISPLAY_NOTE (gdk_drop_get_display (drop), DND, char *s = gdk_content_formats_to_string (formats);
GDK_DISPLAY_NOTE (display, DND, char *s = gdk_content_formats_to_string (formats);
g_message ("%p: read for %s", drop, s);
g_free (s); );
mime_type = gdk_content_formats_match_mime_type (formats,
@@ -283,8 +288,7 @@ gdk_wayland_drop_update_actions (GdkWaylandDrop *drop)
GdkDragAction gdk_actions = 0;
uint32_t wl_actions;
if (drop->action == 0 ||
drop->action & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
if (drop->action & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
wl_actions = drop->source_actions;
else
wl_actions = drop->action;
-2
View File
@@ -31,7 +31,6 @@
#include "gdkinternals.h"
#include "gdksurfaceprivate.h"
#include "gdkprofilerprivate.h"
#include "gdkintl.h"
@@ -239,7 +238,6 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "wayland", "swap buffers");
if (display_wayland->have_egl_swap_buffers_with_damage)
{
int i, j, n_rects = cairo_region_num_rectangles (painted);
+2 -1
View File
@@ -57,7 +57,8 @@ gboolean _gdk_wayland_keymap_key_is_modifier (GdkKeymap *keymap,
void _gdk_wayland_display_init_cursors (GdkWaylandDisplay *display);
void _gdk_wayland_display_finalize_cursors (GdkWaylandDisplay *display);
struct wl_cursor_theme * _gdk_wayland_display_get_cursor_theme (GdkWaylandDisplay *display_wayland);
struct wl_cursor_theme * _gdk_wayland_display_get_scaled_cursor_theme (GdkWaylandDisplay *display_wayland,
guint scale);
void _gdk_wayland_display_get_default_cursor_size (GdkDisplay *display,
guint *width,
+2 -6
View File
@@ -357,7 +357,6 @@ frame_callback (void *data,
GdkFrameClock *clock = gdk_surface_get_frame_clock (surface);
GdkFrameTimings *timings;
gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "wayland", "frame event");
GDK_DISPLAY_NOTE (GDK_DISPLAY (display_wayland), EVENTS, g_message ("frame %p", surface));
wl_callback_destroy (callback);
@@ -396,10 +395,10 @@ frame_callback (void *data,
#ifdef G_ENABLE_DEBUG
if ((_gdk_debug_flags & GDK_DEBUG_FRAMES) != 0)
_gdk_frame_clock_debug_print_timings (clock, timings);
#endif
if (gdk_profiler_is_running ())
_gdk_frame_clock_add_timings_to_profiler (clock, timings);
#endif
}
static const struct wl_callback_listener frame_listener = {
@@ -478,7 +477,6 @@ on_frame_clock_after_paint (GdkFrameClock *clock,
* before we need to stage any changes, then we can take it back and
* use it again.
*/
gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "wayland", "surface commit");
wl_surface_commit (impl->display_server.wl_surface);
impl->pending_commit = FALSE;
@@ -1510,7 +1508,6 @@ gdk_wayland_surface_create_xdg_toplevel (GdkSurface *surface)
if (impl->hint == GDK_SURFACE_TYPE_HINT_DIALOG)
_gdk_wayland_screen_add_orphan_dialog (surface);
gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "wayland", "surface commit");
wl_surface_commit (impl->display_server.wl_surface);
}
@@ -2305,7 +2302,6 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
}
}
gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "wayland", "surface commit");
wl_surface_commit (impl->display_server.wl_surface);
impl->popup_parent = parent;
@@ -4113,7 +4109,7 @@ gdk_wayland_surface_is_exported (GdkSurface *surface)
* gdk_wayland_surface_export_handle:
* @surface: the #GdkSurface to obtain a handle for
* @callback: callback to call with the handle
* @user_data: (closure): user data for @callback
* @user_data: user data for @callback
* @destroy_func: destroy notify for @user_data
*
* Asynchronously obtains a handle for a surface that can be passed
+2 -4
View File
@@ -1,5 +1,3 @@
subdir('cursor')
gdk_wayland_sources = files([
'gdkapplaunchcontext-wayland.c',
'gdkcairocontext-wayland.c',
@@ -35,6 +33,7 @@ gdk_wayland_deps = [
xkbdep,
wlclientdep,
wlprotocolsdep,
wlcursordep,
wlegldep,
]
@@ -106,5 +105,4 @@ libgdk_wayland = static_library('gdk-wayland',
'-DG_LOG_DOMAIN="Gdk"',
] + common_cflags,
link_args: common_ldflags,
link_with: [libwayland_cursor, ],
dependencies: [ gdk_deps, gdk_wayland_deps])
dependencies: [ gdk_deps, gdk_wayland_deps, ])
+8 -9
View File
@@ -65,15 +65,16 @@ print_atoms (GdkX11Clipboard *cb,
const Atom *atoms,
gsize n_atoms)
{
GDK_DISPLAY_NOTE (gdk_clipboard_get_display (GDK_CLIPBOARD (cb)), CLIPBOARD, {
GdkDisplay *display = gdk_clipboard_get_display (GDK_CLIPBOARD (cb));
GDK_DISPLAY_NOTE (display, CLIPBOARD,
gsize i;
GdkDisplay *display = gdk_clipboard_get_display (GDK_CLIPBOARD (cb));
g_printerr ("%s: %s [ ", cb->selection, prefix);
for (i = 0; i < n_atoms; i++)
g_printerr ("%s%s", i > 0 ? ", " : "", gdk_x11_get_xatom_name_for_display (display , atoms[i]));
g_printerr (" ]\n");
});
);
}
static void
@@ -85,7 +86,9 @@ gdk_x11_clipboard_default_output_done (GObject *clipboard,
if (!gdk_clipboard_write_finish (GDK_CLIPBOARD (clipboard), result, &error))
{
GDK_DISPLAY_NOTE (gdk_clipboard_get_display (GDK_CLIPBOARD (clipboard)), CLIPBOARD,
GdkDisplay *display = gdk_clipboard_get_display (GDK_CLIPBOARD (clipboard));
GDK_DISPLAY_NOTE (display, CLIPBOARD,
g_printerr ("%s: failed to write stream: %s\n",
GDK_X11_CLIPBOARD (clipboard)->selection, error->message));
g_error_free (error);
@@ -437,20 +440,16 @@ gdk_x11_clipboard_xevent (GdkDisplay *display,
case SelectionRequest:
{
#ifdef G_ENABLE_DEBUG
const char *target, *property;
#endif
const char *target, *property;
if (xevent->xselectionrequest.selection != cb->xselection)
return FALSE;
#ifdef G_ENABLE_DEBUG
target = gdk_x11_get_xatom_name_for_display (display, xevent->xselectionrequest.target);
if (xevent->xselectionrequest.property == None)
property = target;
else
property = gdk_x11_get_xatom_name_for_display (display, xevent->xselectionrequest.property);
#endif
if (!gdk_clipboard_is_local (GDK_CLIPBOARD (cb)))
{
+21 -30
View File
@@ -1061,7 +1061,6 @@ xdnd_send_enter (GdkX11Drag *drag_x11)
{
GdkDrag *drag = GDK_DRAG (drag_x11);
GdkDisplay *display = gdk_drag_get_display (drag);
GdkContentFormats *formats;
const char * const *atoms;
gsize i, n_atoms;
XEvent xev;
@@ -1081,10 +1080,7 @@ xdnd_send_enter (GdkX11Drag *drag_x11)
GDK_DISPLAY_NOTE (display, DND,
g_message ("Sending enter source window %#lx XDND protocol version %d\n",
GDK_SURFACE_XID (drag_x11->ipc_surface), drag_x11->version));
formats = gdk_content_formats_ref (gdk_drag_get_formats (drag));
formats = gdk_content_formats_union_serialize_mime_types (formats);
atoms = gdk_content_formats_get_mime_types (formats, &n_atoms);
atoms = gdk_content_formats_get_mime_types (gdk_drag_get_formats (drag), &n_atoms);
if (n_atoms > 3)
{
@@ -1304,7 +1300,8 @@ xdnd_precache_atoms (GdkDisplay *display)
/* Source side */
static void
gdk_drag_do_leave (GdkX11Drag *drag_x11)
gdk_drag_do_leave (GdkX11Drag *drag_x11,
guint32 time)
{
if (drag_x11->proxy_xid)
{
@@ -1505,10 +1502,27 @@ gdk_x11_drag_drag_motion (GdkDrag *drag,
}
}
/* When we have a Xdnd target, make sure our XdndActionList
* matches the current actions;
*/
if (protocol == GDK_DRAG_PROTO_XDND && drag_x11->xdnd_actions != gdk_drag_get_actions (drag))
{
if (proxy_xid)
{
GdkDisplay *display = gdk_drag_get_display (drag);
GdkDrop *drop = GDK_X11_DISPLAY (display)->current_drop;
if (drop && GDK_SURFACE_XID (gdk_drop_get_surface (drop)) == proxy_xid)
gdk_x11_drop_read_actions (drop);
else
xdnd_set_actions (drag_x11);
}
}
if (drag_x11->proxy_xid != proxy_xid)
{
/* Send a leave to the last destination */
gdk_drag_do_leave (drag_x11);
gdk_drag_do_leave (drag_x11, time);
drag_x11->drag_status = GDK_DRAG_STATUS_DRAG;
/* Check if new destination accepts drags, and which protocol */
@@ -1544,23 +1558,6 @@ gdk_x11_drag_drag_motion (GdkDrag *drag,
drag_x11->current_action = gdk_drag_get_selected_action (drag);
}
/* When we have a Xdnd target, make sure our XdndActionList
* matches the current actions;
*/
if (protocol == GDK_DRAG_PROTO_XDND && drag_x11->xdnd_actions != gdk_drag_get_actions (drag))
{
if (proxy_xid)
{
GdkDisplay *display = gdk_drag_get_display (drag);
GdkDrop *drop = GDK_X11_DISPLAY (display)->current_drop;
if (drop && GDK_SURFACE_XID (gdk_drop_get_surface (drop)) == proxy_xid)
gdk_x11_drop_read_actions (drop);
else
xdnd_set_actions (drag_x11);
}
}
/* Send a drag-motion event */
drag_x11->last_x = x_root;
@@ -1749,20 +1746,16 @@ gdk_x11_drag_xevent (GdkDisplay *display,
case SelectionRequest:
{
#ifdef G_ENABLE_DEBUG
const char *target, *property;
#endif
if (xevent->xselectionrequest.selection != xselection)
return FALSE;
#ifdef G_ENABLE_DEBUG
target = gdk_x11_get_xatom_name_for_display (display, xevent->xselectionrequest.target);
if (xevent->xselectionrequest.property == None)
property = target;
else
property = gdk_x11_get_xatom_name_for_display (display, xevent->xselectionrequest.property);
#endif
if (xevent->xselectionrequest.requestor == None)
{
@@ -1821,7 +1814,6 @@ struct _GdkDragAnim {
static void
gdk_drag_anim_destroy (GdkDragAnim *anim)
{
gdk_surface_hide (anim->drag->drag_surface);
g_object_unref (anim->drag);
g_slice_free (GdkDragAnim, anim);
}
@@ -2145,7 +2137,6 @@ static void
gdk_x11_drag_cancel (GdkDrag *drag,
GdkDragCancelReason reason)
{
gdk_drag_do_leave (GDK_X11_DRAG (drag));
drag_ungrab (drag);
gdk_drag_drop_done (drag, FALSE);
}
+7 -18
View File
@@ -145,9 +145,9 @@ gdk_x11_drop_read_got_stream (GObject *source,
}
else
{
const char *mime_type = ((GSList *) g_task_get_task_data (task))->data;
#if 0
gsize i;
const char *mime_type = ((GSList *) g_task_get_task_data (task))->data;
for (i = 0; i < G_N_ELEMENTS (special_targets); i++)
{
@@ -166,7 +166,7 @@ gdk_x11_drop_read_got_stream (GObject *source,
#endif
GDK_NOTE (DND, g_printerr ("reading DND as %s now\n",
(const char *)((GSList *) g_task_get_task_data (task))->data));
mime_type));
g_task_return_pointer (task, stream, g_object_unref);
}
@@ -732,14 +732,14 @@ gdk_x11_drop_do_nothing (Window window,
gboolean success,
gpointer data)
{
#ifdef G_ENABLE_DEBUG
GdkDisplay *display = data;
if (!success)
{
GDK_DISPLAY_NOTE (display, DND, g_message ("Send event to %lx failed", window));
GDK_DISPLAY_NOTE (display, DND,
g_message ("Send event to %lx failed",
window));
}
#endif
}
static void
@@ -747,7 +747,7 @@ gdk_x11_drop_status (GdkDrop *drop,
GdkDragAction actions)
{
GdkX11Drop *drop_x11 = GDK_X11_DROP (drop);
GdkDragAction possible_actions, suggested_action;
GdkDragAction possible_actions;
XEvent xev;
GdkDisplay *display;
@@ -755,17 +755,6 @@ gdk_x11_drop_status (GdkDrop *drop,
possible_actions = actions & gdk_drop_get_actions (drop);
if (drop_x11->suggested_action != 0)
suggested_action = drop_x11->suggested_action;
else if (possible_actions & GDK_ACTION_COPY)
suggested_action = GDK_ACTION_COPY;
else if (possible_actions & GDK_ACTION_MOVE)
suggested_action = GDK_ACTION_MOVE;
else if (possible_actions & GDK_ACTION_ASK)
suggested_action = GDK_ACTION_ASK;
else
suggested_action = 0;
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndStatus");
xev.xclient.format = 32;
@@ -775,7 +764,7 @@ gdk_x11_drop_status (GdkDrop *drop,
xev.xclient.data.l[1] = (possible_actions != 0) ? (2 | 1) : 0;
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = xdnd_action_to_atom (display, suggested_action);
xev.xclient.data.l[4] = xdnd_action_to_atom (display, possible_actions);
if (gdk_drop_get_drag (drop))
{
+38 -20
View File
@@ -590,27 +590,29 @@ gsk_gl_driver_create_texture (GskGLDriver *self,
return t->texture_id;
}
void
gsk_gl_driver_create_render_target (GskGLDriver *self,
int width,
int height,
int *out_texture_id,
int *out_render_target_id)
static int
create_render_target (GskGLDriver *self,
int texture_id,
gboolean add_depth_buffer,
gboolean add_stencil_buffer)
{
GLuint fbo_id;
Texture *texture;
GLuint fbo_id, depth_stencil_buffer_id;
Texture *t;
g_return_if_fail (self->in_frame);
g_return_val_if_fail (GSK_IS_GL_DRIVER (self), -1);
g_return_val_if_fail (self->in_frame, -1);
texture = create_texture (self, width, height);
gsk_gl_driver_bind_source_texture (self, texture->texture_id);
gsk_gl_driver_init_texture_empty (self, texture->texture_id, GL_NEAREST, GL_NEAREST);
t = gsk_gl_driver_get_texture (self, texture_id);
if (t == NULL)
return -1;
if (t->fbo.fbo_id != 0)
fbo_clear (&t->fbo);
glGenFramebuffers (1, &fbo_id);
glBindFramebuffer (GL_FRAMEBUFFER, fbo_id);
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->texture_id, 0);
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, t->texture_id, 0);
#if 0
if (add_depth_buffer || add_stencil_buffer)
{
glGenRenderbuffersEXT (1, &depth_stencil_buffer_id);
@@ -636,18 +638,34 @@ gsk_gl_driver_create_render_target (GskGLDriver *self,
if (add_stencil_buffer)
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
GL_RENDERBUFFER, depth_stencil_buffer_id);
texture->fbo.depth_stencil_id = depth_stencil_buffer_id;
}
#endif
texture->fbo.fbo_id = fbo_id;
t->fbo.fbo_id = fbo_id;
t->fbo.depth_stencil_id = depth_stencil_buffer_id;
g_assert_cmphex (glCheckFramebufferStatus (GL_FRAMEBUFFER), ==, GL_FRAMEBUFFER_COMPLETE);
glBindFramebuffer (GL_FRAMEBUFFER, self->default_fbo.fbo_id);
*out_texture_id = texture->texture_id;
*out_render_target_id = fbo_id;
return fbo_id;
}
void
gsk_gl_driver_create_render_target (GskGLDriver *self,
int width,
int height,
int *out_texture_id,
int *out_render_target_id)
{
int texture_id, render_target;
texture_id = gsk_gl_driver_create_texture (self, width, height);
gsk_gl_driver_bind_source_texture (self, texture_id);
gsk_gl_driver_init_texture_empty (self, texture_id, GL_NEAREST, GL_NEAREST);
render_target = create_render_target (self, texture_id, FALSE, FALSE);
*out_texture_id = texture_id;
*out_render_target_id = render_target;
}
/* Mark the texture permanent, meaning it won'e be reused by the GLDriver.
+4 -9
View File
@@ -195,15 +195,10 @@ upload_glyph (GlyphCacheKey *key,
{
glPixelStorei (GL_UNPACK_ROW_LENGTH, r.stride / 4);
glBindTexture (GL_TEXTURE_2D, value->texture_id);
if (gdk_gl_context_get_use_es (gdk_gl_context_get_current ()))
glTexSubImage2D (GL_TEXTURE_2D, 0, r.x, r.y, r.width, r.height,
GL_RGBA, GL_UNSIGNED_BYTE,
r.data);
else
glTexSubImage2D (GL_TEXTURE_2D, 0, r.x, r.y, r.width, r.height,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
r.data);
glTexSubImage2D (GL_TEXTURE_2D, 0,
r.x, r.y, r.width, r.height,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
r.data);
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
g_free (r.data);
}
+12 -19
View File
@@ -83,7 +83,7 @@ gsk_gl_icon_cache_begin_frame (GskGLIconCache *self,
}
if (self->timestamp % MAX_FRAME_AGE == 0)
{
{
g_hash_table_iter_init (&iter, self->icons);
while (g_hash_table_iter_next (&iter, (gpointer *)&texture, (gpointer *)&icon_data))
{
@@ -134,7 +134,6 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
int packed_y = 0;
cairo_surface_t *surface;
unsigned char *surface_data;
guint gl_format;
gsk_gl_texture_atlases_pack (self->atlases, width + 2, height + 2, &atlas, &packed_x, &packed_y);
@@ -156,37 +155,30 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
surface_data = cairo_image_surface_get_data (surface);
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
"Uploading texture");
if (gdk_gl_context_get_use_es (gdk_gl_context_get_current ()))
gl_format = GL_RGBA;
else
gl_format = GL_BGRA;
glBindTexture (GL_TEXTURE_2D, atlas->texture_id);
glTexSubImage2D (GL_TEXTURE_2D, 0,
packed_x + 1, packed_y + 1,
width, height,
gl_format,
GL_UNSIGNED_BYTE,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
surface_data);
/* Padding top */
glTexSubImage2D (GL_TEXTURE_2D, 0,
packed_x + 1, packed_y,
width, 1,
gl_format, GL_UNSIGNED_BYTE,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
surface_data);
/* Padding left */
glTexSubImage2D (GL_TEXTURE_2D, 0,
packed_x, packed_y + 1,
1, height,
gl_format, GL_UNSIGNED_BYTE,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
surface_data);
/* Padding top left */
glTexSubImage2D (GL_TEXTURE_2D, 0,
packed_x, packed_y,
1, 1,
gl_format, GL_UNSIGNED_BYTE,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
surface_data);
/* Padding right */
@@ -195,13 +187,13 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
glTexSubImage2D (GL_TEXTURE_2D, 0,
packed_x + width + 1, packed_y + 1,
1, height,
gl_format, GL_UNSIGNED_BYTE,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
surface_data);
/* Padding top right */
glTexSubImage2D (GL_TEXTURE_2D, 0,
packed_x + width + 1, packed_y,
1, 1,
gl_format, GL_UNSIGNED_BYTE,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
surface_data);
/* Padding bottom */
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
@@ -210,13 +202,13 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
glTexSubImage2D (GL_TEXTURE_2D, 0,
packed_x + 1, packed_y + 1 + height,
width, 1,
gl_format, GL_UNSIGNED_BYTE,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
surface_data);
/* Padding bottom left */
glTexSubImage2D (GL_TEXTURE_2D, 0,
packed_x, packed_y + 1 + height,
1, 1,
gl_format, GL_UNSIGNED_BYTE,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
surface_data);
/* Padding bottom right */
glPixelStorei (GL_UNPACK_ROW_LENGTH, width);
@@ -224,8 +216,9 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
glTexSubImage2D (GL_TEXTURE_2D, 0,
packed_x + 1 + width, packed_y + 1 + height,
1, 1,
gl_format, GL_UNSIGNED_BYTE,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
surface_data);
/* Reset this */
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
@@ -246,7 +239,7 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
char *filename = g_strdup_printf ("atlas_%u_%d.png", atlas->texture_id, k++);
glBindTexture (GL_TEXTURE_2D, atlas->texture_id);
glGetTexImage (GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, data);
glGetTexImage (GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
s = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32, atlas->width, atlas->height, stride);
cairo_surface_write_to_png (s, filename);
+586 -382
View File
File diff suppressed because it is too large Load Diff
+55 -81
View File
@@ -8,46 +8,6 @@ rect_equal (const graphene_rect_t *a,
return memcmp (a, b, sizeof (graphene_rect_t)) == 0;
}
static inline gboolean G_GNUC_PURE
rounded_rect_equal (const GskRoundedRect *r1,
const GskRoundedRect *r2)
{
int i;
if (!r1)
return FALSE;
if (r1->bounds.origin.x != r2->bounds.origin.x ||
r1->bounds.origin.y != r2->bounds.origin.y ||
r1->bounds.size.width != r2->bounds.size.width ||
r1->bounds.size.height != r2->bounds.size.height)
return FALSE;
for (i = 0; i < 4; i ++)
if (r1->corner[i].width != r2->corner[i].width ||
r1->corner[i].height != r2->corner[i].height)
return FALSE;
return TRUE;
}
static inline gboolean G_GNUC_PURE
rounded_rect_corners_equal (const GskRoundedRect *r1,
const GskRoundedRect *r2)
{
int i;
if (!r1)
return FALSE;
for (i = 0; i < 4; i ++)
if (r1->corner[i].width != r2->corner[i].width ||
r1->corner[i].height != r2->corner[i].height)
return FALSE;
return TRUE;
}
static inline ProgramState *
get_current_program_state (RenderOpBuilder *builder)
{
@@ -81,6 +41,16 @@ ops_finish (RenderOpBuilder *builder)
builder->current_viewport = GRAPHENE_RECT_INIT (0, 0, 0, 0);
}
static inline void
rgba_to_float (const GdkRGBA *c,
float *f)
{
f[0] = c->red;
f[1] = c->green;
f[2] = c->blue;
f[3] = c->alpha;
}
/* Debugging only! */
void
ops_dump_framebuffer (RenderOpBuilder *builder,
@@ -127,12 +97,15 @@ static void
extract_matrix_metadata (GskTransform *transform,
OpsMatrixMetadata *md)
{
float dummy;
switch (gsk_transform_get_category (transform))
{
case GSK_TRANSFORM_CATEGORY_IDENTITY:
md->scale_x = 1;
md->scale_y = 1;
break;
case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
gsk_transform_to_translate (transform, &md->translate_x, &md->translate_y);
md->scale_x = 1;
md->scale_y = 1;
break;
@@ -140,7 +113,7 @@ extract_matrix_metadata (GskTransform *transform,
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
gsk_transform_to_affine (transform,
&md->scale_x, &md->scale_y,
&dummy, &dummy);
&md->translate_x, &md->translate_y);
break;
case GSK_TRANSFORM_CATEGORY_UNKNOWN:
@@ -156,6 +129,9 @@ extract_matrix_metadata (GskTransform *transform,
/* TODO: 90% sure this is incorrect. But we should never hit this code
* path anyway. */
md->translate_x = graphene_matrix_get_value (&m, 3, 0);
md->translate_y = graphene_matrix_get_value (&m, 3, 1);
graphene_vec3_init (&col1,
graphene_matrix_get_value (&m, 0, 0),
graphene_matrix_get_value (&m, 1, 0),
@@ -180,15 +156,17 @@ ops_transform_bounds_modelview (const RenderOpBuilder *builder,
const graphene_rect_t *src,
graphene_rect_t *dst)
{
graphene_rect_t r = *src;
const MatrixStackEntry *head;
g_assert (builder->mv_stack != NULL);
g_assert (builder->mv_stack->len >= 1);
r.origin.x += builder->dx;
r.origin.y += builder->dy;
head = &g_array_index (builder->mv_stack, MatrixStackEntry, builder->mv_stack->len - 1);
gsk_transform_transform_bounds (builder->current_modelview, &r, dst);
gsk_transform_transform_bounds (builder->current_modelview, src, dst);
dst->origin.x += builder->dx * head->metadata.scale_x;
dst->origin.y += builder->dy * head->metadata.scale_y;
}
void
@@ -227,6 +205,11 @@ void
ops_set_program (RenderOpBuilder *builder,
const Program *program)
{
/* The tricky part about this is that we want to initialize all uniforms of a program
* to the current value from the builder, but only once. */
static const GskRoundedRect empty_clip;
static const graphene_matrix_t empty_matrix;
static const graphene_rect_t empty_rect;
OpProgram *op;
ProgramState *program_state;
@@ -240,7 +223,9 @@ ops_set_program (RenderOpBuilder *builder,
program_state = &builder->program_state[program->index];
if (memcmp (&builder->current_projection, &program_state->projection, sizeof (graphene_matrix_t)) != 0)
/* If the projection is not yet set for this program, we use the current one. */
if (memcmp (&empty_matrix, &program_state->projection, sizeof (graphene_matrix_t)) == 0 ||
memcmp (&builder->current_projection, &program_state->projection, sizeof (graphene_matrix_t)) != 0)
{
OpMatrix *opm;
@@ -260,7 +245,8 @@ ops_set_program (RenderOpBuilder *builder,
program_state->modelview = gsk_transform_ref (builder->current_modelview);
}
if (!rect_equal (&builder->current_viewport, &program_state->viewport))
if (rect_equal (&empty_rect, &program_state->viewport) ||
!rect_equal (&builder->current_viewport, &program_state->viewport))
{
OpViewport *opv;
@@ -269,13 +255,13 @@ ops_set_program (RenderOpBuilder *builder,
program_state->viewport = builder->current_viewport;
}
if (!rounded_rect_equal (builder->current_clip, &program_state->clip))
if (memcmp (&empty_clip, &program_state->clip, sizeof (GskRoundedRect)) == 0 ||
memcmp (&builder->current_clip, &program_state->clip, sizeof (GskRoundedRect)) != 0)
{
OpClip *opc;
opc = ops_begin (builder, OP_CHANGE_CLIP);
opc->clip = *builder->current_clip;
opc->send_corners = !rounded_rect_corners_equal (builder->current_clip, &program_state->clip);
program_state->clip = *builder->current_clip;
}
@@ -297,25 +283,15 @@ ops_set_clip (RenderOpBuilder *builder,
OpClip *op;
if (current_program_state &&
rounded_rect_equal (&current_program_state->clip, clip))
memcmp (&current_program_state->clip, clip,sizeof (GskRoundedRect)) == 0)
return;
if (!(op = op_buffer_peek_tail_checked (&builder->render_ops, OP_CHANGE_CLIP)))
{
op = op_buffer_add (&builder->render_ops, OP_CHANGE_CLIP);
op->send_corners = !current_program_state ||
!rounded_rect_corners_equal (&current_program_state->clip, clip);
}
else
{
/* If the op before sent the corners, this one needs, too */
op->send_corners |= !current_program_state ||
!rounded_rect_corners_equal (&current_program_state->clip, clip);
}
op = op_buffer_add (&builder->render_ops, OP_CHANGE_CLIP);
op->clip = *clip;
if (current_program_state)
if (builder->current_program != NULL)
current_program_state->clip = *clip;
}
@@ -367,6 +343,7 @@ ops_set_modelview_internal (RenderOpBuilder *builder,
GskTransform *transform)
{
ProgramState *current_program_state = get_current_program_state (builder);
graphene_matrix_t matrix;
OpMatrix *op;
#if 0
@@ -376,10 +353,12 @@ ops_set_modelview_internal (RenderOpBuilder *builder,
return;
#endif
gsk_transform_to_matrix (transform, &matrix);
if (!(op = op_buffer_peek_tail_checked (&builder->render_ops, OP_CHANGE_MODELVIEW)))
op = op_buffer_add (&builder->render_ops, OP_CHANGE_MODELVIEW);
gsk_transform_to_matrix (transform, &op->matrix);
op->matrix = matrix;
if (builder->current_program != NULL)
{
@@ -618,7 +597,7 @@ ops_set_color (RenderOpBuilder *builder,
current_program_state->color = *color;
op = ops_begin (builder, OP_CHANGE_COLOR);
op->rgba = color;
op->rgba = *color;
}
void
@@ -641,8 +620,8 @@ ops_set_color_matrix (RenderOpBuilder *builder,
current_program_state->color_matrix.offset = *offset;
op = ops_begin (builder, OP_CHANGE_COLOR_MATRIX);
op->matrix = matrix;
op->offset = offset;
op->matrix = *matrix;
op->offset = *offset;
}
void
@@ -689,17 +668,19 @@ ops_set_border_color (RenderOpBuilder *builder,
{
ProgramState *current_program_state = get_current_program_state (builder);
OpBorder *op;
float fcolor[4];
if (gdk_rgba_equal (color, &current_program_state->border.color))
rgba_to_float (color, fcolor);
if (memcmp (fcolor, &current_program_state->border.color, sizeof fcolor) == 0)
return;
op = op_buffer_add (&builder->render_ops, OP_CHANGE_BORDER_COLOR);
op->color = color;
current_program_state->border.color = *color;
memcpy (op->color, fcolor, sizeof (float[4]));
memcpy (current_program_state->border.color, fcolor, sizeof (float[4]));
}
GskQuadVertex *
void
ops_draw (RenderOpBuilder *builder,
const GskQuadVertex vertex_data[GL_N_VERTICES])
{
@@ -716,14 +697,7 @@ ops_draw (RenderOpBuilder *builder,
op->vao_size = GL_N_VERTICES;
}
if (vertex_data)
{
g_array_append_vals (builder->vertices, vertex_data, GL_N_VERTICES);
return NULL; /* Better not use this on the caller side */
}
g_array_set_size (builder->vertices, builder->vertices->len + GL_N_VERTICES);
return &g_array_index (builder->vertices, GskQuadVertex, builder->vertices->len - GL_N_VERTICES);
g_array_append_vals (builder->vertices, vertex_data, GL_N_VERTICES);
}
/* The offset is only valid for the current modelview.
+24 -8
View File
@@ -15,8 +15,12 @@
#define GL_N_VERTICES 6
#define GL_N_PROGRAMS 13
typedef struct
{
float translate_x;
float translate_y;
float scale_x;
float scale_y;
@@ -40,10 +44,14 @@ struct _Program
int position_location;
int uv_location;
int alpha_location;
int blend_mode_location;
int viewport_location;
int projection_location;
int modelview_location;
int clip_rect_location;
int clip_location;
int clip_corner_widths_location;
int clip_corner_heights_location;
union {
struct {
int color_location;
@@ -58,6 +66,7 @@ struct _Program
struct {
int num_color_stops_location;
int color_stops_location;
int color_offsets_location;
int start_point_location;
int end_point_location;
} linear_gradient;
@@ -70,14 +79,19 @@ struct _Program
int color_location;
int spread_location;
int offset_location;
int outline_rect_location;
int outline_location;
int corner_widths_location;
int corner_heights_location;
} inset_shadow;
struct {
int color_location;
int outline_rect_location;
int outline_location;
int corner_widths_location;
int corner_heights_location;
} outset_shadow;
struct {
int outline_rect_location;
int outline_location;
int corner_widths_location;
int corner_heights_location;
int color_location;
int spread_location;
int offset_location;
@@ -85,7 +99,9 @@ struct _Program
struct {
int color_location;
int widths_location;
int outline_rect_location;
int outline_location;
int corner_widths_location;
int corner_heights_location;
} border;
struct {
int source2_location;
@@ -119,7 +135,7 @@ typedef struct
} color_matrix;
struct {
float widths[4];
GdkRGBA color;
float color[4];
GskRoundedRect outline;
} border;
};
@@ -214,7 +230,7 @@ void ops_set_border_width (RenderOpBuilder *builder,
void ops_set_border_color (RenderOpBuilder *builder,
const GdkRGBA *color);
GskQuadVertex * ops_draw (RenderOpBuilder *builder,
void ops_draw (RenderOpBuilder *builder,
const GskQuadVertex vertex_data[GL_N_VERTICES]);
void ops_offset (RenderOpBuilder *builder,
-206
View File
@@ -1,206 +0,0 @@
#include "config.h"
#include "gskglshaderbuilderprivate.h"
#include "gskdebugprivate.h"
#include <gdk/gdk.h>
#include <epoxy/gl.h>
void
gsk_gl_shader_builder_init (GskGLShaderBuilder *self,
const char *common_preamble_resource_path,
const char *vs_preamble_resource_path,
const char *fs_preamble_resource_path)
{
memset (self, 0, sizeof (*self));
self->preamble = g_resources_lookup_data (common_preamble_resource_path, 0, NULL);
self->vs_preamble = g_resources_lookup_data (vs_preamble_resource_path, 0, NULL);
self->fs_preamble = g_resources_lookup_data (fs_preamble_resource_path, 0, NULL);
g_assert (self->preamble);
g_assert (self->vs_preamble);
g_assert (self->fs_preamble);
}
void
gsk_gl_shader_builder_finish (GskGLShaderBuilder *self)
{
g_bytes_unref (self->preamble);
g_bytes_unref (self->vs_preamble);
g_bytes_unref (self->fs_preamble);
}
void
gsk_gl_shader_builder_set_glsl_version (GskGLShaderBuilder *self,
int version)
{
self->version = version;
}
static gboolean
check_shader_error (int shader_id,
GError **error)
{
int status;
int log_len;
char *buffer;
int code_len;
char *code;
glGetShaderiv (shader_id, GL_COMPILE_STATUS, &status);
if (G_LIKELY (status == GL_TRUE))
return TRUE;
glGetShaderiv (shader_id, GL_INFO_LOG_LENGTH, &log_len);
buffer = g_malloc0 (log_len + 1);
glGetShaderInfoLog (shader_id, log_len, NULL, buffer);
glGetShaderiv (shader_id, GL_SHADER_SOURCE_LENGTH, &code_len);
code = g_malloc0 (code_len + 1);
glGetShaderSource (shader_id, code_len, NULL, code);
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_COMPILATION_FAILED,
"Compilation failure in shader.\nError message: %s\n\nSource code:\n%s\n\n",
buffer,
code);
g_free (buffer);
g_free (code);
return FALSE;
}
int
gsk_gl_shader_builder_create_program (GskGLShaderBuilder *self,
const char *resource_path,
GError **error)
{
GBytes *source_bytes = g_resources_lookup_data (resource_path, 0, NULL);
char version_buffer[64];
const char *source;
const char *vertex_shader_start;
const char *fragment_shader_start;
int vertex_id;
int fragment_id;
int program_id = -1;
int status;
g_assert (source_bytes);
source = g_bytes_get_data (source_bytes, NULL);
vertex_shader_start = strstr (source, "VERTEX_SHADER");
fragment_shader_start = strstr (source, "FRAGMENT_SHADER");
g_assert (vertex_shader_start);
g_assert (fragment_shader_start);
/* They both start at the next newline */
vertex_shader_start = strstr (vertex_shader_start, "\n");
fragment_shader_start = strstr (fragment_shader_start, "\n");
g_snprintf (version_buffer, sizeof (version_buffer),
"#version %d\n", self->version);
vertex_id = glCreateShader (GL_VERTEX_SHADER);
glShaderSource (vertex_id, 8,
(const char *[]) {
version_buffer,
self->debugging ? "#define GSK_DEBUG 1\n" : "",
self->legacy ? "#define GSK_LEGACY 1\n" : "",
self->gl3 ? "#define GSK_GL3 1\n" : "",
self->gles ? "#define GSK_GLES 1\n" : "",
g_bytes_get_data (self->preamble, NULL),
g_bytes_get_data (self->vs_preamble, NULL),
vertex_shader_start
},
(int[]) {
-1,
-1,
-1,
-1,
-1,
-1,
-1,
fragment_shader_start - vertex_shader_start
});
glCompileShader (vertex_id);
if (!check_shader_error (vertex_id, error))
{
glDeleteShader (vertex_id);
goto out;
}
fragment_id = glCreateShader (GL_FRAGMENT_SHADER);
glShaderSource (fragment_id, 8,
(const char *[]) {
version_buffer,
self->debugging ? "#define GSK_DEBUG 1\n" : "",
self->legacy ? "#define GSK_LEGACY 1\n" : "",
self->gl3 ? "#define GSK_GL3 1\n" : "",
self->gles ? "#define GSK_GLES 1\n" : "",
g_bytes_get_data (self->preamble, NULL),
g_bytes_get_data (self->fs_preamble, NULL),
fragment_shader_start
},
(int[]) {
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
});
glCompileShader (fragment_id);
if (!check_shader_error (fragment_id, error))
{
glDeleteShader (fragment_id);
goto out;
}
program_id = glCreateProgram ();
glAttachShader (program_id, vertex_id);
glAttachShader (program_id, fragment_id);
glLinkProgram (program_id);
glGetProgramiv (program_id, GL_LINK_STATUS, &status);
if (status == GL_FALSE)
{
char *buffer = NULL;
int log_len = 0;
glGetProgramiv (program_id, GL_INFO_LOG_LENGTH, &log_len);
buffer = g_malloc0 (log_len + 1);
glGetProgramInfoLog (program_id, log_len, NULL, buffer);
g_warning ("Linking failure in shader:\n%s", buffer);
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_LINK_FAILED,
"Linking failure in shader: %s", buffer);
g_free (buffer);
glDeleteProgram (program_id);
goto out;
}
glDetachShader (program_id, vertex_id);
glDeleteShader (vertex_id);
glDetachShader (program_id, fragment_id);
glDeleteShader (fragment_id);
out:
g_bytes_unref (source_bytes);
return program_id;
}
-40
View File
@@ -1,40 +0,0 @@
#ifndef __GSK_SHADER_BUILDER_PRIVATE_H__
#define __GSK_SHADER_BUILDER_PRIVATE_H__
#include <gdk/gdk.h>
#include <graphene.h>
G_BEGIN_DECLS
typedef struct
{
GBytes *preamble;
GBytes *vs_preamble;
GBytes *fs_preamble;
int version;
guint debugging: 1;
guint gles: 1;
guint gl3: 1;
guint legacy: 1;
} GskGLShaderBuilder;
void gsk_gl_shader_builder_init (GskGLShaderBuilder *self,
const char *common_preamble_resource_path,
const char *vs_preamble_resource_path,
const char *fs_preamble_resource_path);
void gsk_gl_shader_builder_finish (GskGLShaderBuilder *self);
void gsk_gl_shader_builder_set_glsl_version (GskGLShaderBuilder *self,
int version);
int gsk_gl_shader_builder_create_program (GskGLShaderBuilder *self,
const char *resource_path,
GError **error);
G_END_DECLS
#endif /* __GSK_SHADER_BUILDER_PRIVATE_H__ */
+3 -3
View File
@@ -25,12 +25,12 @@ key_equal (const void *x,
const CacheKey *a = x;
const CacheKey *b = y;
return a->blur_radius == b->blur_radius &&
graphene_size_equal (&a->outline.corner[0], &b->outline.corner[0]) &&
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);
graphene_rect_equal (&a->outline.bounds, &b->outline.bounds) &&
a->blur_radius == b->blur_radius;
}
void
+2 -3
View File
@@ -166,8 +166,7 @@ gsk_gl_texture_atlases_pack (GskGLTextureAtlases *self,
g_ptr_array_add (self->atlases, atlas);
/* Pack it onto that one, which surely has enough space... */
if (!gsk_gl_texture_atlas_pack (atlas, width, height, &x, &y))
g_assert_not_reached ();
gsk_gl_texture_atlas_pack (atlas, width, height, &x, &y);
GSK_NOTE(GLYPH_CACHE, g_message ("adding new atlas"));
}
@@ -305,5 +304,5 @@ gsk_gl_texture_atlas_realize (GskGLTextureAtlas *atlas)
atlas->texture_id = create_shared_texture (atlas->width, atlas->height);
gdk_gl_context_label_object_printf (gdk_gl_context_get_current (),
GL_TEXTURE, atlas->texture_id,
"Texture atlas %d", atlas->texture_id);
"Glyph atlas %d", atlas->texture_id);
}
+332
View File
@@ -0,0 +1,332 @@
#include "config.h"
#include "gskshaderbuilderprivate.h"
#include "gskdebugprivate.h"
#include <gdk/gdk.h>
#include <epoxy/gl.h>
struct _GskShaderBuilder
{
GObject parent_instance;
char *resource_base_path;
char *vertex_preamble;
char *fragment_preamble;
int common_vertex_shader_id;
int version;
GPtrArray *defines;
/* We reuse this one for all the shaders */
GString *shader_code;
};
G_DEFINE_TYPE (GskShaderBuilder, gsk_shader_builder, G_TYPE_OBJECT)
static void
gsk_shader_builder_finalize (GObject *gobject)
{
GskShaderBuilder *self = GSK_SHADER_BUILDER (gobject);
g_free (self->resource_base_path);
g_free (self->vertex_preamble);
g_free (self->fragment_preamble);
g_string_free (self->shader_code, TRUE);
g_clear_pointer (&self->defines, g_ptr_array_unref);
if (self->common_vertex_shader_id > 0)
glDeleteShader (self->common_vertex_shader_id);
G_OBJECT_CLASS (gsk_shader_builder_parent_class)->finalize (gobject);
}
static void
gsk_shader_builder_class_init (GskShaderBuilderClass *klass)
{
G_OBJECT_CLASS (klass)->finalize = gsk_shader_builder_finalize;
}
static void
gsk_shader_builder_init (GskShaderBuilder *self)
{
self->defines = g_ptr_array_new_with_free_func (g_free);
self->shader_code = g_string_new (NULL);
}
GskShaderBuilder *
gsk_shader_builder_new (void)
{
return g_object_new (GSK_TYPE_SHADER_BUILDER, NULL);
}
void
gsk_shader_builder_set_resource_base_path (GskShaderBuilder *builder,
const char *base_path)
{
g_return_if_fail (GSK_IS_SHADER_BUILDER (builder));
g_free (builder->resource_base_path);
builder->resource_base_path = g_strdup (base_path);
}
void
gsk_shader_builder_set_vertex_preamble (GskShaderBuilder *builder,
const char *vertex_preamble)
{
g_return_if_fail (GSK_IS_SHADER_BUILDER (builder));
g_free (builder->vertex_preamble);
builder->vertex_preamble = g_strdup (vertex_preamble);
}
void
gsk_shader_builder_set_fragment_preamble (GskShaderBuilder *builder,
const char *fragment_preamble)
{
g_return_if_fail (GSK_IS_SHADER_BUILDER (builder));
g_free (builder->fragment_preamble);
builder->fragment_preamble = g_strdup (fragment_preamble);
}
void
gsk_shader_builder_set_version (GskShaderBuilder *builder,
int version)
{
g_return_if_fail (GSK_IS_SHADER_BUILDER (builder));
builder->version = version;
}
void
gsk_shader_builder_add_define (GskShaderBuilder *builder,
const char *define_name,
const char *define_value)
{
g_return_if_fail (GSK_IS_SHADER_BUILDER (builder));
g_return_if_fail (define_name != NULL && *define_name != '\0');
g_return_if_fail (define_value != NULL && *define_value != '\0');
g_ptr_array_add (builder->defines, g_strdup (define_name));
g_ptr_array_add (builder->defines, g_strdup (define_value));
}
static gboolean
lookup_shader_code (GString *code,
const char *base_path,
const char *shader_file,
GError **error)
{
GBytes *source;
char *path;
if (base_path != NULL)
path = g_build_filename (base_path, shader_file, NULL);
else
path = g_strdup (shader_file);
source = g_resources_lookup_data (path, 0, error);
g_free (path);
if (source == NULL)
return FALSE;
g_string_append (code, g_bytes_get_data (source, NULL));
g_bytes_unref (source);
return TRUE;
}
static int
gsk_shader_builder_compile_shader (GskShaderBuilder *builder,
int shader_type,
const char *shader_preamble,
const char *shader_source,
GError **error)
{
GString *code;
const char *source;
int shader_id;
int status;
int i;
/* Clear possibly previously set shader code */
g_string_erase (builder->shader_code, 0, -1);
code = builder->shader_code;
if (builder->version > 0)
{
g_string_append_printf (code, "#version %d\n", builder->version);
g_string_append_c (code, '\n');
}
for (i = 0; i < builder->defines->len; i += 2)
{
const char *name = g_ptr_array_index (builder->defines, i);
const char *value = g_ptr_array_index (builder->defines, i + 1);
g_string_append (code, "#define");
g_string_append_c (code, ' ');
g_string_append (code, name);
g_string_append_c (code, ' ');
g_string_append (code, value);
g_string_append_c (code, '\n');
}
g_string_append_c (code, '\n');
if (!lookup_shader_code (code, builder->resource_base_path, shader_preamble, error))
{
return -1;
}
g_string_append_c (code, '\n');
if (!lookup_shader_code (code, builder->resource_base_path, shader_source, error))
{
return -1;
}
source = code->str;
shader_id = glCreateShader (shader_type);
glShaderSource (shader_id, 1, (const GLchar **) &source, NULL);
glCompileShader (shader_id);
#ifdef G_ENABLE_DEBUG
if (GSK_DEBUG_CHECK (SHADERS))
{
g_print ("*** Compiling %s shader from '%s' + '%s' ***\n"
"%s\n",
shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
shader_preamble, shader_source,
source);
}
#endif
glGetShaderiv (shader_id, GL_COMPILE_STATUS, &status);
if (status == GL_FALSE)
{
int log_len;
char *buffer;
glGetShaderiv (shader_id, GL_INFO_LOG_LENGTH, &log_len);
buffer = g_malloc0 (log_len + 1);
glGetShaderInfoLog (shader_id, log_len, NULL, buffer);
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_COMPILATION_FAILED,
"Compilation failure in %s shader:\n%s",
shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
buffer);
g_free (buffer);
glDeleteShader (shader_id);
return -1;
}
return shader_id;
}
void
gsk_shader_builder_set_common_vertex_shader (GskShaderBuilder *self,
const char *vertex_shader,
GError **error)
{
int shader_id;
shader_id = gsk_shader_builder_compile_shader (self,
GL_VERTEX_SHADER,
self->vertex_preamble,
vertex_shader,
error);
g_assert (shader_id > 0);
self->common_vertex_shader_id = shader_id;
}
int
gsk_shader_builder_create_program (GskShaderBuilder *builder,
const char *fragment_shader,
const char *vertex_shader,
GError **error)
{
int vertex_id;
int fragment_id;
int program_id;
int status;
g_return_val_if_fail (GSK_IS_SHADER_BUILDER (builder), -1);
g_return_val_if_fail (fragment_shader != NULL, -1);
g_return_val_if_fail (builder->common_vertex_shader_id != 0, -1);
if (vertex_shader == NULL)
vertex_id = builder->common_vertex_shader_id;
else
vertex_id = gsk_shader_builder_compile_shader (builder, GL_VERTEX_SHADER,
builder->vertex_preamble,
vertex_shader,
error);
if (vertex_id < 0)
return -1;
fragment_id = gsk_shader_builder_compile_shader (builder, GL_FRAGMENT_SHADER,
builder->fragment_preamble,
fragment_shader,
error);
if (fragment_id < 0)
{
glDeleteShader (vertex_id);
return -1;
}
program_id = glCreateProgram ();
glAttachShader (program_id, vertex_id);
glAttachShader (program_id, fragment_id);
glLinkProgram (program_id);
glGetProgramiv (program_id, GL_LINK_STATUS, &status);
if (status == GL_FALSE)
{
char *buffer = NULL;
int log_len = 0;
glGetProgramiv (program_id, GL_INFO_LOG_LENGTH, &log_len);
buffer = g_malloc0 (log_len + 1);
glGetProgramInfoLog (program_id, log_len, NULL, buffer);
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_LINK_FAILED,
"Linking failure in shader:\n%s", buffer);
g_free (buffer);
glDeleteProgram (program_id);
program_id = -1;
goto out;
}
out:
if (vertex_id > 0)
{
/* We delete the common vertex shader when destroying the shader builder */
glDetachShader (program_id, vertex_id);
}
if (fragment_id > 0)
{
glDetachShader (program_id, fragment_id);
glDeleteShader (fragment_id);
}
return program_id;
}
+39
View File
@@ -0,0 +1,39 @@
#ifndef __GSK_SHADER_BUILDER_PRIVATE_H__
#define __GSK_SHADER_BUILDER_PRIVATE_H__
#include <gdk/gdk.h>
#include <graphene.h>
G_BEGIN_DECLS
#define GSK_TYPE_SHADER_BUILDER (gsk_shader_builder_get_type ())
G_DECLARE_FINAL_TYPE (GskShaderBuilder, gsk_shader_builder, GSK, SHADER_BUILDER, GObject)
GskShaderBuilder * gsk_shader_builder_new (void);
void gsk_shader_builder_set_version (GskShaderBuilder *builder,
int version);
void gsk_shader_builder_set_resource_base_path (GskShaderBuilder *builder,
const char *base_path);
void gsk_shader_builder_set_vertex_preamble (GskShaderBuilder *builder,
const char *shader_preamble);
void gsk_shader_builder_set_fragment_preamble (GskShaderBuilder *builder,
const char *shader_preamble);
void gsk_shader_builder_add_define (GskShaderBuilder *builder,
const char *define_name,
const char *define_value);
void gsk_shader_builder_set_common_vertex_shader (GskShaderBuilder *self,
const char *vertex_shader,
GError **error);
int gsk_shader_builder_create_program (GskShaderBuilder *builder,
const char *fragment_shader,
const char *vertex_shader,
GError **error);
G_END_DECLS
#endif /* __GSK_SHADER_BUILDER_PRIVATE_H__ */
+10 -8
View File
@@ -77,7 +77,7 @@ typedef struct
typedef struct
{
const GdkRGBA *rgba;
GdkRGBA rgba;
} OpColor;
typedef struct
@@ -88,7 +88,6 @@ typedef struct
typedef struct
{
GskRoundedRect clip;
guint send_corners: 1;
} OpClip;
typedef struct
@@ -109,7 +108,8 @@ typedef struct
typedef struct
{
const GskColorStop *color_stops;
float color_offsets[8];
float color_stops[4 * 8];
graphene_point_t start_point;
graphene_point_t end_point;
int n_color_stops;
@@ -117,8 +117,8 @@ typedef struct
typedef struct
{
const graphene_matrix_t *matrix;
const graphene_vec4_t *offset;
graphene_matrix_t matrix;
graphene_vec4_t offset;
} OpColorMatrix;
typedef struct
@@ -130,16 +130,18 @@ typedef struct
typedef struct
{
GskRoundedRect outline;
float outline[4];
float corner_widths[4];
float corner_heights[4];
float spread;
float offset[2];
const GdkRGBA *color;
float color[4];
} OpShadow;
typedef struct
{
float widths[4];
const GdkRGBA *color;
float color[4];
GskRoundedRect outline;
} OpBorder;
+7 -4
View File
@@ -145,9 +145,9 @@ gsk_render_node_get_node_type (GskRenderNode *node)
return node->node_class->node_type;
}
G_GNUC_PURE static inline
static inline
GskRenderNodeType
_gsk_render_node_get_node_type (const GskRenderNode *node)
_gsk_render_node_get_node_type (GskRenderNode *node)
{
return node->node_class->node_type;
}
@@ -248,8 +248,8 @@ gsk_render_node_draw (GskRenderNode *node,
* Returns: %TRUE if @node1 and @node2 can be expected to be compared
**/
gboolean
gsk_render_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2)
gsk_render_node_can_diff (GskRenderNode *node1,
GskRenderNode *node2)
{
if (node1 == node2)
return TRUE;
@@ -314,6 +314,9 @@ gsk_render_node_diff (GskRenderNode *node1,
return node1->node_class->diff (node1, node2, region);
}
#define GSK_RENDER_NODE_SERIALIZATION_VERSION 0
#define GSK_RENDER_NODE_SERIALIZATION_ID "GskRenderNode"
/**
* gsk_render_node_write_to_file:
* @node: a #GskRenderNode
+7 -7
View File
@@ -41,7 +41,7 @@ typedef struct _GskShadow GskShadow;
struct _GskColorStop
{
float offset;
double offset;
GdkRGBA color;
};
@@ -210,11 +210,11 @@ GskTransform * gsk_transform_node_get_transform (GskRenderNode
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_opacity_node_new (GskRenderNode *child,
float opacity);
double opacity);
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_opacity_node_get_child (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
float gsk_opacity_node_get_opacity (GskRenderNode *node);
double gsk_opacity_node_get_opacity (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_color_matrix_node_new (GskRenderNode *child,
@@ -280,13 +280,13 @@ GskBlendMode gsk_blend_node_get_blend_mode (GskRenderNode
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_cross_fade_node_new (GskRenderNode *start,
GskRenderNode *end,
float progress);
double progress);
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_cross_fade_node_get_start_child (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_cross_fade_node_get_end_child (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
float gsk_cross_fade_node_get_progress (GskRenderNode *node);
double gsk_cross_fade_node_get_progress (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_text_node_new (PangoFont *font,
@@ -307,11 +307,11 @@ const graphene_point_t *gsk_text_node_get_offset (GskRenderNode
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_blur_node_new (GskRenderNode *child,
float radius);
double radius);
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_blur_node_get_child (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
float gsk_blur_node_get_radius (GskRenderNode *node);
double gsk_blur_node_get_radius (GskRenderNode *node);
G_END_DECLS
+18 -18
View File
@@ -41,8 +41,8 @@ rectangle_init_from_graphene (cairo_rectangle_int_t *cairo,
}
static gboolean
gsk_render_node_can_diff_true (const GskRenderNode *node1,
const GskRenderNode *node2)
gsk_render_node_can_diff_true (GskRenderNode *node1,
GskRenderNode *node2)
{
return TRUE;
}
@@ -1707,8 +1707,8 @@ gsk_container_node_draw (GskRenderNode *node,
}
static gboolean
gsk_container_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2)
gsk_container_node_can_diff (GskRenderNode *node1,
GskRenderNode *node2)
{
return TRUE;
}
@@ -1726,7 +1726,7 @@ gsk_render_node_add_to_region (GskRenderNode *node,
static int
gsk_container_node_compare_func (gconstpointer elem1, gconstpointer elem2, gpointer data)
{
return gsk_render_node_can_diff ((const GskRenderNode *) elem1, (const GskRenderNode *) elem2) ? 0 : 1;
return gsk_render_node_can_diff ((GskRenderNode *) elem1, (GskRenderNode *) elem2) ? 0 : 1;
}
static void
@@ -1918,8 +1918,8 @@ gsk_transform_node_draw (GskRenderNode *node,
}
static gboolean
gsk_transform_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2)
gsk_transform_node_can_diff (GskRenderNode *node1,
GskRenderNode *node2)
{
GskTransformNode *self1 = (GskTransformNode *) node1;
GskTransformNode *self2 = (GskTransformNode *) node2;
@@ -2092,8 +2092,8 @@ gsk_debug_node_draw (GskRenderNode *node,
}
static gboolean
gsk_debug_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2)
gsk_debug_node_can_diff (GskRenderNode *node1,
GskRenderNode *node2)
{
GskDebugNode *self1 = (GskDebugNode *) node1;
GskDebugNode *self2 = (GskDebugNode *) node2;
@@ -2197,7 +2197,7 @@ struct _GskOpacityNode
GskRenderNode render_node;
GskRenderNode *child;
float opacity;
double opacity;
};
static void
@@ -2267,7 +2267,7 @@ static const GskRenderNodeClass GSK_OPACITY_NODE_CLASS = {
*/
GskRenderNode *
gsk_opacity_node_new (GskRenderNode *child,
float opacity)
double opacity)
{
GskOpacityNode *self;
@@ -2301,7 +2301,7 @@ gsk_opacity_node_get_child (GskRenderNode *node)
return self->child;
}
float
double
gsk_opacity_node_get_opacity (GskRenderNode *node)
{
GskOpacityNode *self = (GskOpacityNode *) node;
@@ -3278,7 +3278,7 @@ struct _GskCrossFadeNode
GskRenderNode *start;
GskRenderNode *end;
float progress;
double progress;
};
static void
@@ -3352,7 +3352,7 @@ static const GskRenderNodeClass GSK_CROSS_FADE_NODE_CLASS = {
GskRenderNode *
gsk_cross_fade_node_new (GskRenderNode *start,
GskRenderNode *end,
float progress)
double progress)
{
GskCrossFadeNode *self;
@@ -3390,7 +3390,7 @@ gsk_cross_fade_node_get_end_child (GskRenderNode *node)
return self->end;
}
float
double
gsk_cross_fade_node_get_progress (GskRenderNode *node)
{
GskCrossFadeNode *self = (GskCrossFadeNode *) node;
@@ -3634,7 +3634,7 @@ struct _GskBlurNode
GskRenderNode render_node;
GskRenderNode *child;
float radius;
double radius;
};
static void
@@ -3882,7 +3882,7 @@ static const GskRenderNodeClass GSK_BLUR_NODE_CLASS = {
*/
GskRenderNode *
gsk_blur_node_new (GskRenderNode *child,
float radius)
double radius)
{
GskBlurNode *self;
float clip_radius = gsk_cairo_blur_compute_pixels (radius);
@@ -3911,7 +3911,7 @@ gsk_blur_node_get_child (GskRenderNode *node)
return self->child;
}
float
double
gsk_blur_node_get_radius (GskRenderNode *node)
{
GskBlurNode *self = (GskBlurNode *) node;
+1 -5
View File
@@ -433,13 +433,9 @@ parse_stops (GtkCssParser *parser,
for (;;)
{
double dval;
if (!gtk_css_parser_consume_number (parser, &dval))
if (!gtk_css_parser_consume_number (parser, &stop.offset))
goto error;
stop.offset = dval;
if (!gdk_rgba_parser_parse (parser, &stop.color))
goto error;
+4 -4
View File
@@ -28,8 +28,8 @@ struct _GskRenderNodeClass
void (* finalize) (GskRenderNode *node);
void (* draw) (GskRenderNode *node,
cairo_t *cr);
gboolean (* can_diff) (const GskRenderNode *node1,
const GskRenderNode *node2);
gboolean (* can_diff) (GskRenderNode *node1,
GskRenderNode *node2);
void (* diff) (GskRenderNode *node1,
GskRenderNode *node2,
cairo_region_t *region);
@@ -38,8 +38,8 @@ struct _GskRenderNodeClass
GskRenderNode * gsk_render_node_new (const GskRenderNodeClass *node_class,
gsize extra_size);
gboolean gsk_render_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2) G_GNUC_PURE;
gboolean gsk_render_node_can_diff (GskRenderNode *node1,
GskRenderNode *node2);
void gsk_render_node_diff (GskRenderNode *node1,
GskRenderNode *node2,
cairo_region_t *region);
+4 -4
View File
@@ -98,16 +98,16 @@ GskRoundedRect * gsk_rounded_rect_shrink (GskRoundedRect
float left);
GDK_AVAILABLE_IN_ALL
gboolean gsk_rounded_rect_is_rectilinear (const GskRoundedRect *self) G_GNUC_PURE;
gboolean gsk_rounded_rect_is_rectilinear (const GskRoundedRect *self);
GDK_AVAILABLE_IN_ALL
gboolean gsk_rounded_rect_contains_point (const GskRoundedRect *self,
const graphene_point_t *point) G_GNUC_PURE;
const graphene_point_t *point);
GDK_AVAILABLE_IN_ALL
gboolean gsk_rounded_rect_contains_rect (const GskRoundedRect *self,
const graphene_rect_t *rect) G_GNUC_PURE;
const graphene_rect_t *rect);
GDK_AVAILABLE_IN_ALL
gboolean gsk_rounded_rect_intersects_rect (const GskRoundedRect *self,
const graphene_rect_t *rect) G_GNUC_PURE;
const graphene_rect_t *rect);
G_END_DECLS
+1 -1
View File
@@ -15,7 +15,7 @@ void gsk_rounded_rect_to_float (const GskRounde
float rect[12]);
gboolean gsk_rounded_rect_equal (gconstpointer rect1,
gconstpointer rect2) G_GNUC_PURE;
gconstpointer rect2);
char * gsk_rounded_rect_to_string (const GskRoundedRect *self);
+23 -131
View File
@@ -685,54 +685,16 @@ gsk_rotate_transform_finalize (GskTransform *self)
{
}
static inline void
_sincos (float deg,
float *out_s,
float *out_c)
{
if (deg == 90.0)
{
*out_c = 0.0;
*out_s = 1.0;
}
else if (deg == 180.0)
{
*out_c = -1.0;
*out_s = 0.0;
}
else if (deg == 270.0)
{
*out_c = 0.0;
*out_s = -1.0;
}
else if (deg == 0.0)
{
*out_c = 1.0;
*out_s = 0.0;
}
else
{
float angle = deg * M_PI / 180.0;
#ifdef HAVE_SINCOSF
sincosf (angle, out_s, out_c);
#else
*out_s = sinf (angle);
*out_c = cosf (angle);
#endif
}
}
static void
gsk_rotate_transform_to_matrix (GskTransform *transform,
graphene_matrix_t *out_matrix)
{
GskRotateTransform *self = (GskRotateTransform *) transform;
float c, s;
_sincos (self->angle, &s, &c);
float rad, c, s;
rad = self->angle * M_PI / 180.f;
c = cosf (rad);
s = sinf (rad);
graphene_matrix_init_from_2d (out_matrix,
c, s,
-s, c,
@@ -749,12 +711,14 @@ gsk_rotate_transform_apply_2d (GskTransform *transform,
float *out_dy)
{
GskRotateTransform *self = (GskRotateTransform *) transform;
float s, c, xx, xy, yx, yy;
float s, c, rad, xx, xy, yx, yy;
if (fmodf (self->angle, 360.0f) == 0.0)
return;
_sincos (self->angle, &s, &c);
rad = self->angle * G_PI / 180.0f;
s = sinf (rad);
c = cosf (rad);
xx = c * *out_xx + s * *out_xy;
yx = c * *out_yx + s * *out_yy;
@@ -821,22 +785,6 @@ static const GskTransformClass GSK_ROTATE_TRANSFORM_CLASS =
gsk_rotate_transform_equal,
};
static inline float
normalize_angle (float angle)
{
float f;
if (angle >= 0 && angle < 360)
return angle;
f = angle - (360 * ((int)(angle / 360.0)));
if (f < 0)
f = 360 + f;
return f;
}
/**
* gsk_transform_rotate:
* @next: (allow-none) (transfer full): the next transform
@@ -867,7 +815,7 @@ gsk_transform_rotate (GskTransform *next,
GSK_TRANSFORM_CATEGORY_2D,
next);
result->angle = normalize_angle (angle);
result->angle = angle;
return &result->parent;
}
@@ -990,7 +938,7 @@ gsk_transform_rotate_3d (GskTransform *next,
GSK_TRANSFORM_CATEGORY_3D,
next);
result->angle = normalize_angle (angle);
result->angle = angle;
graphene_vec3_init_from_vec3 (&result->axis, axis);
return &result->parent;
@@ -1085,9 +1033,9 @@ gsk_scale_transform_equal (GskTransform *first_transform,
GskScaleTransform *first = (GskScaleTransform *) first_transform;
GskScaleTransform *second = (GskScaleTransform *) second_transform;
return G_APPROX_VALUE (first->factor_x, second->factor_x, FLT_EPSILON) &&
G_APPROX_VALUE (first->factor_y, second->factor_y, FLT_EPSILON) &&
G_APPROX_VALUE (first->factor_z, second->factor_z, FLT_EPSILON);
return G_APPROX_VALUE (first->factor_x, second->factor_x, 0.01f) &&
G_APPROX_VALUE (first->factor_y, second->factor_y, 0.01f) &&
G_APPROX_VALUE (first->factor_z, second->factor_z, 0.01f);
}
static void
@@ -1672,10 +1620,10 @@ gsk_transform_equal (GskTransform *first,
if (first == NULL || second == NULL)
return FALSE;
if (first->transform_class != second->transform_class)
if (!gsk_transform_equal (first->next, second->next))
return FALSE;
if (!gsk_transform_equal (first->next, second->next))
if (first->transform_class != second->transform_class)
return FALSE;
return first->transform_class->equal (first, second);
@@ -1738,10 +1686,7 @@ gsk_transform_transform_bounds (GskTransform *self,
float dx, dy;
gsk_transform_to_translate (self, &dx, &dy);
out_rect->origin.x = rect->origin.x + dx;
out_rect->origin.y = rect->origin.y + dy;
out_rect->size.width = rect->size.width;
out_rect->size.height = rect->size.height;
graphene_rect_offset_r (rect, dx, dy, out_rect);
}
break;
@@ -1751,10 +1696,13 @@ gsk_transform_transform_bounds (GskTransform *self,
gsk_transform_to_affine (self, &scale_x, &scale_y, &dx, &dy);
out_rect->origin.x = (rect->origin.x * scale_x) + dx;
out_rect->origin.y = (rect->origin.y * scale_y) + dy;
out_rect->size.width = rect->size.width * scale_x;
out_rect->size.height = rect->size.height * scale_y;
*out_rect = *rect;
out_rect->origin.x *= scale_x;
out_rect->origin.y *= scale_y;
out_rect->size.width *= scale_x;
out_rect->size.height *= scale_y;
out_rect->origin.x += dx;
out_rect->origin.y += dy;
}
break;
@@ -1773,62 +1721,6 @@ gsk_transform_transform_bounds (GskTransform *self,
}
}
/**
* gsk_transform_transform_point:
* @self: a #GskTransform
* @point: a #graphene_point_t
* @out_point: (out caller-allocates): return location for
* the transformed point
*
* Transforms a #graphene_point_t using the given transform @self.
*/
void
gsk_transform_transform_point (GskTransform *self,
const graphene_point_t *point,
graphene_point_t *out_point)
{
switch (gsk_transform_get_category (self))
{
case GSK_TRANSFORM_CATEGORY_IDENTITY:
*out_point = *point;
break;
case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
{
float dx, dy;
gsk_transform_to_translate (self, &dx, &dy);
out_point->x = point->x + dx;
out_point->y = point->y + dy;
}
break;
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
{
float dx, dy, scale_x, scale_y;
gsk_transform_to_affine (self, &scale_x, &scale_y, &dx, &dy);
out_point->x = (point->x * scale_x) + dx;
out_point->y = (point->y * scale_y) + dy;
}
break;
case GSK_TRANSFORM_CATEGORY_UNKNOWN:
case GSK_TRANSFORM_CATEGORY_ANY:
case GSK_TRANSFORM_CATEGORY_3D:
case GSK_TRANSFORM_CATEGORY_2D:
default:
{
graphene_matrix_t mat;
gsk_transform_to_matrix (self, &mat);
graphene_matrix_transform_point (&mat, point, out_point);
}
break;
}
}
static guint
gsk_transform_parse_float (GtkCssParser *parser,
guint n,
-5
View File
@@ -116,11 +116,6 @@ GDK_AVAILABLE_IN_ALL
void gsk_transform_transform_bounds (GskTransform *self,
const graphene_rect_t *rect,
graphene_rect_t *out_rect);
GDK_AVAILABLE_IN_ALL
void gsk_transform_transform_point (GskTransform *self,
const graphene_point_t *point,
graphene_point_t *out_point);
G_END_DECLS
+21 -17
View File
@@ -1,20 +1,24 @@
gsk_private_gl_shaders = [
'resources/glsl/preamble.glsl',
'resources/glsl/preamble.fs.glsl',
'resources/glsl/preamble.vs.glsl',
'resources/glsl/border.glsl',
'resources/glsl/blit.glsl',
'resources/glsl/coloring.glsl',
'resources/glsl/color.glsl',
'resources/glsl/linear_gradient.glsl',
'resources/glsl/color_matrix.glsl',
'resources/glsl/blur.glsl',
'resources/glsl/inset_shadow.glsl',
'resources/glsl/outset_shadow.glsl',
'resources/glsl/unblurred_outset_shadow.glsl',
'resources/glsl/cross_fade.glsl',
'resources/glsl/blend.glsl',
'resources/glsl/repeat.glsl',
'resources/glsl/blit.fs.glsl',
'resources/glsl/blit.vs.glsl',
'resources/glsl/color.fs.glsl',
'resources/glsl/coloring.fs.glsl',
'resources/glsl/color_matrix.fs.glsl',
'resources/glsl/linear_gradient.fs.glsl',
'resources/glsl/blur.fs.glsl',
'resources/glsl/inset_shadow.fs.glsl',
'resources/glsl/outset_shadow.fs.glsl',
'resources/glsl/unblurred_outset_shadow.fs.glsl',
'resources/glsl/border.fs.glsl',
'resources/glsl/cross_fade.fs.glsl',
'resources/glsl/blend.fs.glsl',
'resources/glsl/repeat.fs.glsl',
'resources/glsl/es2_common.fs.glsl',
'resources/glsl/es2_common.vs.glsl',
'resources/glsl/gl3_common.fs.glsl',
'resources/glsl/gl3_common.vs.glsl',
'resources/glsl/gl_common.fs.glsl',
'resources/glsl/gl_common.vs.glsl',
]
gsk_public_sources = files([
@@ -34,7 +38,7 @@ gsk_private_sources = files([
'gskdebug.c',
'gskprivate.c',
'gskprofiler.c',
'gl/gskglshaderbuilder.c',
'gl/gskshaderbuilder.c',
'gl/gskglprofiler.c',
'gl/gskglglyphcache.c',
'gl/gskglimage.c',
@@ -1,11 +1,3 @@
// VERTEX_SHADER:
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
}
// FRAGMENT_SHADER:
uniform int u_mode;
uniform sampler2D u_source2;
@@ -272,39 +264,73 @@ void main() {
vec4 result;
if (u_mode == 0)
result = normal(top_color, bottom_color);
{
result = normal(top_color, bottom_color);
}
else if (u_mode == 1)
result = multiply(top_color, bottom_color);
{
result = multiply(top_color, bottom_color);
}
else if (u_mode == 2)
result = screen(top_color, bottom_color);
{
result = screen(top_color, bottom_color);
}
else if (u_mode == 3)
result = overlay(top_color, bottom_color);
{
result = overlay(top_color, bottom_color);
}
else if (u_mode == 4)
result = darken(top_color, bottom_color);
{
result = darken(top_color, bottom_color);
}
else if (u_mode == 5)
result = lighten(top_color, bottom_color);
{
result = lighten(top_color, bottom_color);
}
else if (u_mode == 6)
result = color_dodge(top_color, bottom_color);
{
result = color_dodge(top_color, bottom_color);
}
else if (u_mode == 7)
result = color_burn(top_color, bottom_color);
{
result = color_burn(top_color, bottom_color);
}
else if (u_mode == 8)
result = hard_light(top_color, bottom_color);
{
result = hard_light(top_color, bottom_color);
}
else if (u_mode == 9)
result = soft_light(top_color, bottom_color);
{
result = soft_light(top_color, bottom_color);
}
else if (u_mode == 10)
result = difference(top_color, bottom_color);
{
result = difference(top_color, bottom_color);
}
else if (u_mode == 11)
result = exclusion(top_color, bottom_color);
{
result = exclusion(top_color, bottom_color);
}
else if (u_mode == 12)
result = color(top_color, bottom_color);
{
result = color(top_color, bottom_color);
}
else if (u_mode == 13)
result = hue(top_color, bottom_color);
{
result = hue(top_color, bottom_color);
}
else if (u_mode == 14)
result = saturation(top_color, bottom_color);
{
result = saturation(top_color, bottom_color);
}
else if (u_mode == 15)
result = luminosity(top_color, bottom_color);
{
result = luminosity(top_color, bottom_color);
}
else
discard;
{
discard;
}
setOutputColor(result * u_alpha);
}
+5
View File
@@ -0,0 +1,5 @@
void main() {
vec4 diffuse = Texture(u_source, vUv);
setOutputColor(diffuse * u_alpha);
}
-13
View File
@@ -1,13 +0,0 @@
// VERTEX_SHADER:
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
}
// FRAGMENT_SHADER:
void main() {
vec4 diffuse = Texture(u_source, vUv);
setOutputColor(diffuse * u_alpha);
}
+5
View File
@@ -0,0 +1,5 @@
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
}
+38
View File
@@ -0,0 +1,38 @@
uniform float u_blur_radius;
uniform vec2 u_blur_size;
uniform vec2 u_blur_dir;
const float PI = 3.14159265;
const float RADIUS_MULTIPLIER = 3.0;
// blur_radius 0 is NOT supported and MUST be caught before.
// Partially from http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html
void main() {
float sigma = u_blur_radius; // *shrug*
float blur_radius = u_blur_radius * RADIUS_MULTIPLIER;
vec3 incrementalGaussian;
incrementalGaussian.x = 1.0 / (sqrt(2.0 * PI) * sigma);
incrementalGaussian.y = exp(-0.5 / (sigma * sigma));
incrementalGaussian.z = incrementalGaussian.y * incrementalGaussian.y;
vec2 pixel_step = vec2(1.0) / u_blur_size;
float coefficientSum = 0;
vec4 sum = Texture(u_source, vUv) * incrementalGaussian.x;
coefficientSum += incrementalGaussian.x;
incrementalGaussian.xy *= incrementalGaussian.yz;
int pixels_per_side = int(floor(blur_radius / 2.0));
for (int i = 1; i <= pixels_per_side; i++) {
vec2 p = i * pixel_step * u_blur_dir;
sum += Texture(u_source, vUv - p) * incrementalGaussian.x;
sum += Texture(u_source, vUv + p) * incrementalGaussian.x;
coefficientSum += 2.0 * incrementalGaussian.x;
incrementalGaussian.xy *= incrementalGaussian.yz;
}
setOutputColor(sum / coefficientSum);
}
-58
View File
@@ -1,58 +0,0 @@
// VERTEX_SHADER:
uniform float u_blur_radius;
uniform vec2 u_blur_size;
uniform vec2 u_blur_dir;
_OUT_ vec2 pixel_step;
_OUT_ float pixels_per_side;
_OUT_ vec3 initial_gaussian;
const float PI = 3.14159265;
const float RADIUS_MULTIPLIER = 3.0;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
pixel_step = (vec2(1.0) / u_blur_size) * u_blur_dir;
pixels_per_side = floor(u_blur_radius * RADIUS_MULTIPLIER / 2.0);
float sigma = u_blur_radius; // *shrug*
initial_gaussian.x = 1.0 / (sqrt(2.0 * PI) * sigma);
initial_gaussian.y = exp(-0.5 / (sigma * sigma));
initial_gaussian.z = initial_gaussian.y * initial_gaussian.y;
}
// FRAGMENT_SHADER:
uniform float u_blur_radius;
uniform vec2 u_blur_size;
_IN_ vec2 pixel_step;
_IN_ float pixels_per_side;
_IN_ vec3 initial_gaussian;
// blur_radius 0 is NOT supported and MUST be caught before.
// Partially from http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html
void main() {
vec3 incrementalGaussian = initial_gaussian;
float coefficientSum = 0.0;
vec4 sum = Texture(u_source, vUv) * incrementalGaussian.x;
coefficientSum += incrementalGaussian.x;
incrementalGaussian.xy *= incrementalGaussian.yz;
vec2 p = pixel_step;
for (int i = 1; i <= int(pixels_per_side); i++) {
sum += Texture(u_source, vUv - p) * incrementalGaussian.x;
sum += Texture(u_source, vUv + p) * incrementalGaussian.x;
coefficientSum += 2.0 * incrementalGaussian.x;
incrementalGaussian.xy *= incrementalGaussian.yz;
p += pixel_step;
}
setOutputColor(sum / coefficientSum);
}
+30
View File
@@ -0,0 +1,30 @@
uniform vec4 u_color;
uniform vec4 u_widths;
uniform vec4 u_outline;
uniform vec4 u_corner_widths;
uniform vec4 u_corner_heights;
void main() {
vec4 bounds = u_outline;
bounds.z = bounds.x + bounds.z;
bounds.w = bounds.y + bounds.w;
vec4 f = gl_FragCoord;
f.x += u_viewport.x;
f.y = (u_viewport.y + u_viewport.w) - f.y;
RoundedRect routside = RoundedRect (bounds, u_corner_widths, u_corner_heights);
RoundedRect rinside = rounded_rect_shrink (routside, u_widths);
float alpha = clamp (rounded_rect_coverage (routside, f.xy) -
rounded_rect_coverage (rinside, f.xy),
0.0, 1.0);
/* Pre-multiply */
vec4 color = u_color;
color.rgb *= color.a;
setOutputColor (color * alpha * u_alpha);
}
-44
View File
@@ -1,44 +0,0 @@
// VERTEX_SHADER:
uniform vec4 u_color;
uniform vec4 u_widths;
uniform vec4[3] u_outline_rect;
_OUT_ vec4 final_color;
_OUT_ _ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
_OUT_ _ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
final_color = u_color;
final_color.rgb *= final_color.a; // pre-multiply
final_color *= u_alpha;
RoundedRect outside = create_rect(u_outline_rect);
RoundedRect inside = rounded_rect_shrink (outside, u_widths);
rounded_rect_transform(outside, u_modelview);
rounded_rect_transform(inside, u_modelview);
rounded_rect_encode(outside, transformed_outside_outline);
rounded_rect_encode(inside, transformed_inside_outline);
}
// FRAGMENT_SHADER:
uniform vec4[3] u_outline_rect;
_IN_ vec4 final_color;
_IN_ _ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
_IN_ _ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
void main() {
vec4 f = gl_FragCoord;
f.x += u_viewport.x;
f.y = (u_viewport.y + u_viewport.w) - f.y;
float alpha = clamp(rounded_rect_coverage(decode_rect(transformed_outside_outline), f.xy) -
rounded_rect_coverage(decode_rect(transformed_inside_outline), f.xy),
0.0, 1.0);
setOutputColor(final_color * alpha);
}
+9
View File
@@ -0,0 +1,9 @@
uniform vec4 u_color;
void main() {
vec4 color = u_color;
// Pre-multiply alpha
color.rgb *= color.a;
setOutputColor(color * u_alpha);
}
-21
View File
@@ -1,21 +0,0 @@
// VERTEX_SHADER:
uniform vec4 u_color;
_OUT_ vec4 final_color;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
final_color = u_color;
// Pre-multiply alpha
final_color.rgb *= final_color.a;
final_color *= u_alpha;
}
// FRAGMENT_SHADER:
_IN_ vec4 final_color;
void main() {
setOutputColor(final_color);
}
@@ -1,23 +1,18 @@
// VERTEX_SHADER:
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
}
// FRAGMENT_SHADER:
uniform mat4 u_color_matrix;
uniform vec4 u_color_offset;
void main() {
vec4 color = Texture(u_source, vUv);
vec4 diffuse = Texture(u_source, vUv);
vec4 color;
color = diffuse;
// Un-premultilpy
if (color.a != 0.0)
color.rgb /= color.a;
color = u_color_matrix * color + u_color_offset;
color = clamp(color, 0.0, 1.0);
color = clamp(color, 0.0f, 1.0f);
color.rgb *= color.a;
+15
View File
@@ -0,0 +1,15 @@
uniform vec4 u_color;
void main() {
vec4 diffuse = Texture(u_source, vUv);
vec4 color = u_color;
// pre-multiply
color.rgb *= color.a;
// u_source is drawn using cairo, so already pre-multiplied.
color = vec4(color.rgb * diffuse.a * u_alpha,
color.a * diffuse.a * u_alpha);
setOutputColor(color);
}
-25
View File
@@ -1,25 +0,0 @@
// VERTEX_SHADER:
uniform vec4 u_color;
_OUT_ vec4 final_color;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
final_color = u_color;
// pre-multiply
final_color.rgb *= final_color.a;
final_color *= u_alpha;
}
// FRAGMENT_SHADER:
_IN_ vec4 final_color;
void main() {
vec4 diffuse = Texture(u_source, vUv);
setOutputColor(final_color * diffuse.a);
}
@@ -1,11 +1,4 @@
// VERTEX_SHADER:
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
}
// FRAGMENT_SHADER:
uniform float u_progress;
uniform sampler2D u_source2;
+105
View File
@@ -0,0 +1,105 @@
precision mediump float;
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) {
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);
/*gl_FragColor = color;*/
}
+9
View File
@@ -0,0 +1,9 @@
precision mediump float;
uniform mat4 u_projection;
uniform mat4 u_modelview;
attribute vec2 aPosition;
attribute vec2 aUv;
varying vec2 vUv;
+123
View File
@@ -0,0 +1,123 @@
precision highp float;
uniform sampler2D u_source;
uniform sampler2D u_mask;
uniform mat4 u_projection = mat4(1.0);
uniform mat4 u_modelview = mat4(1.0);
uniform float u_alpha = 1.0;
uniform int uBlendMode;
uniform vec4 u_viewport;
// In GtkSnapshot coordinates
uniform vec4 u_clip;
uniform vec4 u_clip_corner_widths = vec4(0, 0, 0, 0);
uniform vec4 u_clip_corner_heights = vec4(0, 0, 0, 0);
in vec2 vUv;
out vec4 outputColor;
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 = vec4(0);
vec4 new_heights = vec4(0);
// Left top
if (r.corner_widths.x > 0) new_widths.x = r.corner_widths.x - amount.w;
if (r.corner_heights.x > 0) new_heights.x = r.corner_heights.x - amount.x;
// Top right
if (r.corner_widths.y > 0) new_widths.y = r.corner_widths.y - amount.y;
if (r.corner_heights.y > 0) new_heights.y = r.corner_heights.y - amount.x;
// Bottom right
if (r.corner_widths.z > 0) new_widths.z = r.corner_widths.z - amount.y;
if (r.corner_heights.z > 0) new_heights.z = r.corner_heights.z - amount.z;
// Bottom left
if (r.corner_widths.w > 0) new_widths.w = r.corner_widths.w - amount.w;
if (r.corner_heights.w > 0) new_heights.w = r.corner_heights.w - amount.z;
return RoundedRect (new_bounds, new_widths, new_heights);
}
vec4 Texture(sampler2D sampler, vec2 texCoords) {
return texture(sampler, texCoords);
}
void setOutputColor(vec4 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);
outputColor = color * rounded_rect_coverage(r, f.xy);
/*outputColor = color;*/
}

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