summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2006-12-31 00:46:35 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2006-12-31 00:46:35 +0000
commit9ae01e7f7d058fc3bd4ed39c195774062f0c7658 (patch)
tree029c86dde755ba37e68f26d5df057ef4e91f680e /gtk
parentfa8e83c42c162669d64d9efcbe8ddcb1ee8b4a3d (diff)
downloadgdk-pixbuf-9ae01e7f7d058fc3bd4ed39c195774062f0c7658.tar.gz
Don't install cursors on insensitive widgets. (#358864, Jan Schampera)
2006-12-30 Matthias Clasen <mclasen@redhat.com> * gtk/gtkentry.c: * gtk/gtklabel.c: * gtk/gtkpaned.c: * gtk/gtkstatusbar.c: * gtk/gtktextview.c: Don't install cursors on insensitive widgets. (#358864, Jan Schampera) svn path=/branches/gtk-2-10/; revision=16984
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkentry.c26
-rw-r--r--gtk/gtklabel.c31
-rw-r--r--gtk/gtkpaned.c38
-rw-r--r--gtk/gtkstatusbar.c34
-rw-r--r--gtk/gtktextview.c54
5 files changed, 139 insertions, 44 deletions
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index ba8bdc584..7f52f73b4 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -1240,14 +1240,19 @@ gtk_entry_realize (GtkWidget *widget)
gdk_window_set_user_data (widget->window, entry);
get_text_area_size (entry, &attributes.x, &attributes.y, &attributes.width, &attributes.height);
-
- attributes.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_XTERM);
- attributes_mask |= GDK_WA_CURSOR;
+
+ if (GTK_WIDGET_IS_SENSITIVE (widget))
+ {
+ attributes.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_XTERM);
+ attributes_mask |= GDK_WA_CURSOR;
+ }
entry->text_area = gdk_window_new (widget->window, &attributes, attributes_mask);
+
gdk_window_set_user_data (entry->text_area, entry);
- gdk_cursor_unref (attributes.cursor);
+ if (attributes_mask & GDK_WA_CURSOR)
+ gdk_cursor_unref (attributes.cursor);
widget->style = gtk_style_attach (widget->style, widget->window);
@@ -2124,11 +2129,24 @@ gtk_entry_state_changed (GtkWidget *widget,
GtkStateType previous_state)
{
GtkEntry *entry = GTK_ENTRY (widget);
+ GdkCursor *cursor;
if (GTK_WIDGET_REALIZED (widget))
{
gdk_window_set_background (widget->window, &widget->style->base[GTK_WIDGET_STATE (widget)]);
gdk_window_set_background (entry->text_area, &widget->style->base[GTK_WIDGET_STATE (widget)]);
+
+ if (GTK_WIDGET_IS_SENSITIVE (widget))
+ cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_XTERM);
+ else
+ cursor = NULL;
+
+ gdk_window_set_cursor (entry->text_area, cursor);
+
+ if (cursor)
+ gdk_cursor_unref (cursor);
+
+ entry->mouse_cursor_obscured = FALSE;
}
if (!GTK_WIDGET_IS_SENSITIVE (widget))
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 409bc18e5..43d5c66c7 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -2210,11 +2210,27 @@ gtk_label_state_changed (GtkWidget *widget,
GtkStateType prev_state)
{
GtkLabel *label;
+ GdkCursor *cursor;
label = GTK_LABEL (widget);
if (label->select_info)
- gtk_label_select_region (label, 0, 0);
+ {
+ gtk_label_select_region (label, 0, 0);
+
+ if (GTK_WIDGET_REALIZED (widget))
+ {
+ if (GTK_WIDGET_IS_SENSITIVE (widget))
+ cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_XTERM);
+ else
+ cursor = NULL;
+
+ gdk_window_set_cursor (label->select_info->window, cursor);
+
+ if (cursor)
+ gdk_cursor_unref (cursor);
+ }
+ }
if (GTK_WIDGET_CLASS (gtk_label_parent_class)->state_changed)
GTK_WIDGET_CLASS (gtk_label_parent_class)->state_changed (widget, prev_state);
@@ -3085,20 +3101,25 @@ gtk_label_create_window (GtkLabel *label)
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_ONLY;
attributes.override_redirect = TRUE;
- attributes.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
- GDK_XTERM);
attributes.event_mask = gtk_widget_get_events (widget) |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK;
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
+ if (GTK_WIDGET_IS_SENSITIVE (widget))
+ {
+ attributes.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
+ GDK_XTERM);
+ attributes_mask |= GDK_WA_CURSOR;
+ }
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR | GDK_WA_CURSOR;
label->select_info->window = gdk_window_new (widget->window,
&attributes, attributes_mask);
gdk_window_set_user_data (label->select_info->window, widget);
- gdk_cursor_unref (attributes.cursor);
+ if (attributes_mask & GDK_WA_CURSOR)
+ gdk_cursor_unref (attributes.cursor);
}
static void
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index a377c523e..5d229c1da 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -83,6 +83,8 @@ static void gtk_paned_realize (GtkWidget *widget);
static void gtk_paned_unrealize (GtkWidget *widget);
static void gtk_paned_map (GtkWidget *widget);
static void gtk_paned_unmap (GtkWidget *widget);
+static void gtk_paned_state_changed (GtkWidget *widget,
+ GtkStateType previous_state);
static gboolean gtk_paned_expose (GtkWidget *widget,
GdkEventExpose *event);
static gboolean gtk_paned_enter (GtkWidget *widget,
@@ -194,6 +196,7 @@ gtk_paned_class_init (GtkPanedClass *class)
widget_class->motion_notify_event = gtk_paned_motion;
widget_class->grab_broken_event = gtk_paned_grab_broken;
widget_class->grab_notify = gtk_paned_grab_notify;
+ widget_class->state_changed = gtk_paned_state_changed;
container_class->add = gtk_paned_add;
container_class->remove = gtk_paned_remove;
@@ -638,8 +641,6 @@ gtk_paned_realize (GtkWidget *widget)
attributes.y = paned->handle_pos.y;
attributes.width = paned->handle_pos.width;
attributes.height = paned->handle_pos.height;
- attributes.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
- paned->cursor_type);
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= (GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
@@ -647,12 +648,19 @@ gtk_paned_realize (GtkWidget *widget)
GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
+ attributes_mask = GDK_WA_X | GDK_WA_Y;
+ if (GTK_WIDGET_IS_SENSITIVE (widget))
+ {
+ attributes.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
+ paned->cursor_type);
+ attributes_mask |= GDK_WA_CURSOR;
+ }
paned->handle = gdk_window_new (widget->window,
&attributes, attributes_mask);
gdk_window_set_user_data (paned->handle, paned);
- gdk_cursor_unref (attributes.cursor);
+ if (attributes_mask & GDK_WA_CURSOR)
+ gdk_cursor_unref (attributes.cursor);
widget->style = gtk_style_attach (widget->style, widget->window);
@@ -916,6 +924,28 @@ gtk_paned_grab_notify (GtkWidget *widget,
stop_drag (paned);
}
+static void
+gtk_paned_state_changed (GtkWidget *widget,
+ GtkStateType previous_state)
+{
+ GtkPaned *paned = GTK_PANED (widget);
+ GdkCursor *cursor;
+
+ if (GTK_WIDGET_REALIZED (paned))
+ {
+ if (GTK_WIDGET_IS_SENSITIVE (widget))
+ cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
+ paned->cursor_type);
+ else
+ cursor = NULL;
+
+ gdk_window_set_cursor (paned->handle, cursor);
+
+ if (cursor)
+ gdk_cursor_unref (cursor);
+ }
+}
+
static gboolean
gtk_paned_button_release (GtkWidget *widget,
GdkEventButton *event)
diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c
index d6115dd75..3e89b60bb 100644
--- a/gtk/gtkstatusbar.c
+++ b/gtk/gtkstatusbar.c
@@ -77,6 +77,8 @@ static void gtk_statusbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_statusbar_direction_changed (GtkWidget *widget,
GtkTextDirection prev_dir);
+static void gtk_statusbar_state_changed (GtkWidget *widget,
+ GtkStateType previous_state);
static void gtk_statusbar_create_window (GtkStatusbar *statusbar);
static void gtk_statusbar_destroy_window (GtkStatusbar *statusbar);
static void gtk_statusbar_get_property (GObject *object,
@@ -116,14 +118,12 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
widget_class->unrealize = gtk_statusbar_unrealize;
widget_class->map = gtk_statusbar_map;
widget_class->unmap = gtk_statusbar_unmap;
-
widget_class->button_press_event = gtk_statusbar_button_press;
widget_class->expose_event = gtk_statusbar_expose_event;
-
widget_class->size_request = gtk_statusbar_size_request;
widget_class->size_allocate = gtk_statusbar_size_allocate;
-
widget_class->direction_changed = gtk_statusbar_direction_changed;
+ widget_class->state_changed = gtk_statusbar_state_changed;
class->text_pushed = gtk_statusbar_update;
class->text_popped = gtk_statusbar_update;
@@ -523,14 +523,19 @@ set_grip_cursor (GtkStatusbar *statusbar)
GdkCursorType cursor_type;
GdkCursor *cursor;
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
- cursor_type = GDK_BOTTOM_RIGHT_CORNER;
+ if (GTK_WIDGET_IS_SENSITIVE (widget))
+ {
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
+ cursor_type = GDK_BOTTOM_RIGHT_CORNER;
+ else
+ cursor_type = GDK_BOTTOM_LEFT_CORNER;
+
+ cursor = gdk_cursor_new_for_display (display, cursor_type);
+ gdk_window_set_cursor (statusbar->grip_window, cursor);
+ gdk_cursor_unref (cursor);
+ }
else
- cursor_type = GDK_BOTTOM_LEFT_CORNER;
-
- cursor = gdk_cursor_new_for_display (display, cursor_type);
- gdk_window_set_cursor (statusbar->grip_window, cursor);
- gdk_cursor_unref (cursor);
+ gdk_window_set_cursor (statusbar->grip_window, NULL);
}
}
@@ -578,6 +583,15 @@ gtk_statusbar_direction_changed (GtkWidget *widget,
}
static void
+gtk_statusbar_state_changed (GtkWidget *widget,
+ GtkStateType previous_state)
+{
+ GtkStatusbar *statusbar = GTK_STATUSBAR (widget);
+
+ set_grip_cursor (statusbar);
+}
+
+static void
gtk_statusbar_destroy_window (GtkStatusbar *statusbar)
{
gdk_window_set_user_data (statusbar->grip_window, NULL);
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index fcaaa3d65..74b4d6baf 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -400,7 +400,7 @@ static GtkTextWindow *text_window_new (GtkTextWindowType type,
gint height_request);
static void text_window_free (GtkTextWindow *win);
static void text_window_realize (GtkTextWindow *win,
- GdkWindow *parent);
+ GtkWidget *widget);
static void text_window_unrealize (GtkTextWindow *win);
static void text_window_size_allocate (GtkTextWindow *win,
GdkRectangle *rect);
@@ -3472,23 +3472,19 @@ gtk_text_view_realize (GtkWidget *widget)
gdk_window_set_background (widget->window,
&widget->style->bg[GTK_WIDGET_STATE (widget)]);
- text_window_realize (text_view->text_window, widget->window);
+ text_window_realize (text_view->text_window, widget);
if (text_view->left_window)
- text_window_realize (text_view->left_window,
- widget->window);
+ text_window_realize (text_view->left_window, widget);
if (text_view->top_window)
- text_window_realize (text_view->top_window,
- widget->window);
+ text_window_realize (text_view->top_window, widget);
if (text_view->right_window)
- text_window_realize (text_view->right_window,
- widget->window);
+ text_window_realize (text_view->right_window, widget);
if (text_view->bottom_window)
- text_window_realize (text_view->bottom_window,
- widget->window);
+ text_window_realize (text_view->bottom_window, widget);
gtk_text_view_ensure_layout (text_view);
@@ -3628,10 +3624,23 @@ gtk_text_view_state_changed (GtkWidget *widget,
GtkStateType previous_state)
{
GtkTextView *text_view = GTK_TEXT_VIEW (widget);
+ GdkCursor *cursor;
if (GTK_WIDGET_REALIZED (widget))
{
gtk_text_view_set_background (text_view);
+
+ if (GTK_WIDGET_IS_SENSITIVE (widget))
+ cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_XTERM);
+ else
+ cursor = NULL;
+
+ gdk_window_set_cursor (text_view->text_window->bin_window, cursor);
+
+ if (cursor)
+ gdk_cursor_unref (cursor);
+
+ text_view->mouse_cursor_obscured = FALSE;
}
if (!GTK_WIDGET_IS_SENSITIVE (widget))
@@ -7388,7 +7397,7 @@ text_window_free (GtkTextWindow *win)
static void
text_window_realize (GtkTextWindow *win,
- GdkWindow *parent)
+ GtkWidget *widget)
{
GdkWindowAttr attributes;
gint attributes_mask;
@@ -7406,7 +7415,7 @@ text_window_realize (GtkTextWindow *win,
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- win->window = gdk_window_new (parent,
+ win->window = gdk_window_new (widget->window,
&attributes,
attributes_mask);
@@ -7438,23 +7447,26 @@ text_window_realize (GtkTextWindow *win,
if (win->type == GTK_TEXT_WINDOW_TEXT)
{
- /* I-beam cursor */
- cursor = gdk_cursor_new_for_display (gdk_drawable_get_display (parent),
- GDK_XTERM);
- gdk_window_set_cursor (win->bin_window, cursor);
- gdk_cursor_unref (cursor);
-
- gtk_im_context_set_client_window (GTK_TEXT_VIEW (win->widget)->im_context,
+ if (GTK_WIDGET_IS_SENSITIVE (widget))
+ {
+ /* I-beam cursor */
+ cursor = gdk_cursor_new_for_display (gdk_drawable_get_display (widget->window),
+ GDK_XTERM);
+ gdk_window_set_cursor (win->bin_window, cursor);
+ gdk_cursor_unref (cursor);
+ }
+
+ gtk_im_context_set_client_window (GTK_TEXT_VIEW (widget)->im_context,
win->window);
gdk_window_set_background (win->bin_window,
- &win->widget->style->base[GTK_WIDGET_STATE (win->widget)]);
+ &widget->style->base[GTK_WIDGET_STATE (widget)]);
}
else
{
gdk_window_set_background (win->bin_window,
- &win->widget->style->bg[GTK_WIDGET_STATE (win->widget)]);
+ &widget->style->bg[GTK_WIDGET_STATE (widget)]);
}
g_object_set_qdata (G_OBJECT (win->window),