[gimp] Don't let focus-in and focus-out on the canvas invalidate everything
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Don't let focus-in and focus-out on the canvas invalidate everything
- Date: Tue, 3 Nov 2009 13:04:12 +0000 (UTC)
commit 8c07e5275975e56e7548c7f1ec484f4ece474fa6
Author: Michael Natterer <mitch gimp org>
Date: Tue Nov 3 13:58:36 2009 +0100
Don't let focus-in and focus-out on the canvas invalidate everything
Implement GtkWidget::focus_in_event() and ::focus_out_event() in
GimpCanvas and don't chanin up so the default handler never runs.
Remove code that tries to do the same in the canvas' tool events
callback.
The default impl invalidates the entire widget for no reason (the
canvas doesn't draw a focus indicator anyway), and the old solution
failed for empty displays and was constantly invalidating the entire
drop zone when the toplevel window gained or lost focus.
app/display/gimpcanvas.c | 62 ++++++++++++++++++++----------
app/display/gimpdisplayshell-callbacks.c | 5 --
2 files changed, 41 insertions(+), 26 deletions(-)
---
diff --git a/app/display/gimpcanvas.c b/app/display/gimpcanvas.c
index c541c30..ce5749d 100644
--- a/app/display/gimpcanvas.c
+++ b/app/display/gimpcanvas.c
@@ -46,22 +46,26 @@ enum
/* local function prototypes */
-static void gimp_canvas_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gimp_canvas_realize (GtkWidget *widget);
-static void gimp_canvas_unrealize (GtkWidget *widget);
-static void gimp_canvas_style_set (GtkWidget *widget,
- GtkStyle *prev_style);
-
-static GdkGC * gimp_canvas_gc_new (GimpCanvas *canvas,
- GimpCanvasStyle style);
+static void gimp_canvas_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void gimp_canvas_realize (GtkWidget *widget);
+static void gimp_canvas_unrealize (GtkWidget *widget);
+static void gimp_canvas_style_set (GtkWidget *widget,
+ GtkStyle *prev_style);
+static gboolean gimp_canvas_focus_in_event (GtkWidget *widget,
+ GdkEventFocus *event);
+static gboolean gimp_canvas_focus_out_event (GtkWidget *widget,
+ GdkEventFocus *event);
+
+static GdkGC * gimp_canvas_gc_new (GimpCanvas *canvas,
+ GimpCanvasStyle style);
G_DEFINE_TYPE (GimpCanvas, gimp_canvas, GIMP_TYPE_OVERLAY_BOX)
@@ -160,12 +164,14 @@ gimp_canvas_class_init (GimpCanvasClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->set_property = gimp_canvas_set_property;
- object_class->get_property = gimp_canvas_get_property;
+ object_class->set_property = gimp_canvas_set_property;
+ object_class->get_property = gimp_canvas_get_property;
- widget_class->realize = gimp_canvas_realize;
- widget_class->unrealize = gimp_canvas_unrealize;
- widget_class->style_set = gimp_canvas_style_set;
+ widget_class->realize = gimp_canvas_realize;
+ widget_class->unrealize = gimp_canvas_unrealize;
+ widget_class->style_set = gimp_canvas_style_set;
+ widget_class->focus_in_event = gimp_canvas_focus_in_event;
+ widget_class->focus_out_event = gimp_canvas_focus_out_event;
g_object_class_install_property (object_class, PROP_CONFIG,
g_param_spec_object ("config", NULL, NULL,
@@ -289,6 +295,20 @@ gimp_canvas_style_set (GtkWidget *widget,
}
}
+static gboolean
+gimp_canvas_focus_in_event (GtkWidget *widget,
+ GdkEventFocus *event)
+{
+ return FALSE;
+}
+
+static gboolean
+gimp_canvas_focus_out_event (GtkWidget *widget,
+ GdkEventFocus *event)
+{
+ return FALSE;
+}
+
/* Returns: %TRUE if the XOR color is not white */
static gboolean
gimp_canvas_get_xor_color (GimpCanvas *canvas,
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index d46d2b6..f9345a0 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -784,11 +784,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
shell->proximity,
display);
}
-
- /* stop the signal because otherwise gtk+ exposes the whole
- * canvas to get the non-existant focus indicator drawn
- */
- return_val = TRUE;
}
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]