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=/trunk/; revision=16983
This commit is contained in:
Matthias Clasen 2006-12-31 00:36:03 +00:00 committed by Matthias Clasen
parent 1ed8f92140
commit 571f4ff972
6 changed files with 147 additions and 43 deletions

View File

@ -1,3 +1,12 @@
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)
2006-12-29 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkrecentmanager.h:

View File

@ -1242,14 +1242,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);
@ -2139,11 +2144,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))

View File

@ -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

View File

@ -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)

View File

@ -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;
@ -512,14 +512,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;
else
cursor_type = GDK_BOTTOM_LEFT_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);
cursor = gdk_cursor_new_for_display (display, cursor_type);
gdk_window_set_cursor (statusbar->grip_window, cursor);
gdk_cursor_unref (cursor);
}
else
gdk_window_set_cursor (statusbar->grip_window, NULL);
}
}
@ -566,6 +571,15 @@ gtk_statusbar_direction_changed (GtkWidget *widget,
set_grip_cursor (statusbar);
}
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)
{

View File

@ -412,7 +412,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);
@ -3478,23 +3478,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);
@ -3634,10 +3630,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))
@ -7486,7 +7495,7 @@ text_window_free (GtkTextWindow *win)
static void
text_window_realize (GtkTextWindow *win,
GdkWindow *parent)
GtkWidget *widget)
{
GdkWindowAttr attributes;
gint attributes_mask;
@ -7504,7 +7513,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);
@ -7536,23 +7545,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);
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 (win->widget)->im_context,
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),