[gtk+/wip/carlosg/event-delivery: 59/71] label: Remove selection window
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/carlosg/event-delivery: 59/71] label: Remove selection window
- Date: Mon, 3 Apr 2017 08:52:24 +0000 (UTC)
commit d75e18e444b9ca46d3df28d165a276ccb6ba3f31
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Apr 2 13:33:12 2017 +0200
label: Remove selection window
It's no longer needed to receive events while the label is selectable.
gtk/gtklabel.c | 88 ++++++--------------------------------------------------
1 files changed, 9 insertions(+), 79 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index ab55866..4ed9946 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -328,7 +328,6 @@ typedef struct
struct _GtkLabelSelectionInfo
{
- GdkWindow *window;
gint selection_anchor;
gint selection_end;
GtkWidget *popup_menu;
@@ -421,8 +420,6 @@ static gboolean gtk_label_focus (GtkWidget *widget,
GtkDirectionType direction);
static void gtk_label_realize (GtkWidget *widget);
-static void gtk_label_unrealize (GtkWidget *widget);
-static void gtk_label_map (GtkWidget *widget);
static void gtk_label_unmap (GtkWidget *widget);
static gboolean gtk_label_motion (GtkWidget *widget,
@@ -461,8 +458,7 @@ static void gtk_label_screen_changed (GtkWidget *widget,
GdkScreen *old_screen);
static gboolean gtk_label_popup_menu (GtkWidget *widget);
-static void gtk_label_create_window (GtkLabel *label);
-static void gtk_label_destroy_window (GtkLabel *label);
+static void gtk_label_set_selectable_hint (GtkLabel *label);
static void gtk_label_ensure_select_info (GtkLabel *label);
static void gtk_label_clear_select_info (GtkLabel *label);
static void gtk_label_update_cursor (GtkLabel *label);
@@ -621,8 +617,6 @@ gtk_label_class_init (GtkLabelClass *class)
widget_class->query_tooltip = gtk_label_query_tooltip;
widget_class->snapshot = gtk_label_snapshot;
widget_class->realize = gtk_label_realize;
- widget_class->unrealize = gtk_label_unrealize;
- widget_class->map = gtk_label_map;
widget_class->unmap = gtk_label_unmap;
widget_class->motion_notify_event = gtk_label_motion;
widget_class->leave_notify_event = gtk_label_leave_notify;
@@ -3996,13 +3990,6 @@ gtk_label_size_allocate (GtkWidget *widget,
if (priv->layout)
gtk_label_update_layout_width (label);
- if (priv->select_info && priv->select_info->window)
- gdk_window_move_resize (priv->select_info->window,
- allocation->x,
- allocation->y,
- allocation->width,
- allocation->height);
-
gtk_label_get_ink_rect (label, &clip_rect);
gdk_rectangle_union (&clip_rect, &clip, &clip_rect);
_gtk_widget_set_simple_clip (widget, &clip_rect);
@@ -4038,7 +4025,7 @@ gtk_label_update_cursor (GtkLabel *label)
else
cursor = NULL;
- gdk_window_set_cursor (priv->select_info->window, cursor);
+ gtk_widget_set_cursor (widget, cursor);
if (cursor)
g_object_unref (cursor);
@@ -4457,31 +4444,7 @@ gtk_label_realize (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_label_parent_class)->realize (widget);
if (priv->select_info)
- gtk_label_create_window (label);
-}
-
-static void
-gtk_label_unrealize (GtkWidget *widget)
-{
- GtkLabel *label = GTK_LABEL (widget);
- GtkLabelPrivate *priv = label->priv;
-
- if (priv->select_info)
- gtk_label_destroy_window (label);
-
- GTK_WIDGET_CLASS (gtk_label_parent_class)->unrealize (widget);
-}
-
-static void
-gtk_label_map (GtkWidget *widget)
-{
- GtkLabel *label = GTK_LABEL (widget);
- GtkLabelPrivate *priv = label->priv;
-
- GTK_WIDGET_CLASS (gtk_label_parent_class)->map (widget);
-
- if (priv->select_info)
- gdk_window_show (priv->select_info->window);
+ gtk_label_set_selectable_hint (label);
}
static void
@@ -4492,8 +4455,6 @@ gtk_label_unmap (GtkWidget *widget)
if (priv->select_info)
{
- gdk_window_hide (priv->select_info->window);
-
if (priv->select_info->popup_menu)
{
gtk_widget_destroy (priv->select_info->popup_menu);
@@ -5291,50 +5252,22 @@ gtk_label_leave_notify (GtkWidget *widget,
}
static void
-gtk_label_create_window (GtkLabel *label)
+gtk_label_set_selectable_hint (GtkLabel *label)
{
GtkLabelPrivate *priv = label->priv;
- GtkAllocation allocation;
GtkWidget *widget;
g_assert (priv->select_info);
widget = GTK_WIDGET (label);
- g_assert (gtk_widget_get_realized (widget));
-
- if (priv->select_info->window)
- return;
-
- gtk_widget_get_allocation (widget, &allocation);
-
- priv->select_info->window = gdk_window_new_input (gtk_widget_get_window (widget),
- GDK_ALL_EVENTS_MASK,
- &allocation);
- if (gtk_widget_is_sensitive (widget) && priv->select_info->selectable)
+ if (priv->select_info->selectable)
{
GdkCursor *cursor;
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_XTERM);
- gdk_window_set_cursor (priv->select_info->window, cursor);
+ gtk_widget_set_cursor (widget, cursor);
g_object_unref (cursor);
}
-
- gtk_widget_register_window (widget, priv->select_info->window);
-}
-
-static void
-gtk_label_destroy_window (GtkLabel *label)
-{
- GtkLabelPrivate *priv = label->priv;
-
- g_assert (priv->select_info);
-
- if (priv->select_info->window == NULL)
- return;
-
- gtk_widget_unregister_window (GTK_WIDGET (label), priv->select_info->window);
- gdk_window_destroy (priv->select_info->window);
- priv->select_info->window = NULL;
}
static void
@@ -5349,10 +5282,7 @@ gtk_label_ensure_select_info (GtkLabel *label)
gtk_widget_set_can_focus (GTK_WIDGET (label), TRUE);
if (gtk_widget_get_realized (GTK_WIDGET (label)))
- gtk_label_create_window (label);
-
- if (gtk_widget_get_mapped (GTK_WIDGET (label)))
- gdk_window_show (priv->select_info->window);
+ gtk_label_set_selectable_hint (label);
priv->select_info->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (label));
g_signal_connect (priv->select_info->drag_gesture, "drag-begin",
@@ -5381,14 +5311,14 @@ gtk_label_clear_select_info (GtkLabel *label)
if (!priv->select_info->selectable && !priv->select_info->links)
{
- gtk_label_destroy_window (label);
-
g_object_unref (priv->select_info->drag_gesture);
g_object_unref (priv->select_info->multipress_gesture);
g_free (priv->select_info);
priv->select_info = NULL;
+ gtk_widget_set_cursor (GTK_WIDGET (label), NULL);
+
gtk_widget_set_can_focus (GTK_WIDGET (label), FALSE);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]