mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
add mouse_cursor_obscured.
2002-01-27 Anders Carlsson <andersca@gnu.org> * gtk/gtktextview.h (struct _GtkTextView): add mouse_cursor_obscured. * gtk/gtkentry.h (struct _GtkEntry): Add mouse_cursor_obscured. * gtk/gtktextview.c (set_invisible_cursor): New function. (gtk_text_view_obscure_mouse_cursor): Likewise. (gtk_text_view_key_press_event): Call obscure_cursor if text has been inserted. (gtk_text_view_motion_event): Restore the mouse cursor. * gtk/gtkentry.c (gtk_entry_realize): Add GDK_POINTER_MOTION_MASK. (set_invisible_cursor): New function. (gtk_entry_obscure_mouse_cursor): Likewise. (gtk_entry_key_press): call obscure_cursor if text has been inserted. (gtk_entry_motion_notify): Restore the mouse cursor.
This commit is contained in:
parent
f03d717b59
commit
8290dc99dc
18
ChangeLog
18
ChangeLog
@ -1,3 +1,21 @@
|
||||
2002-01-27 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gtk/gtktextview.h (struct _GtkTextView): add mouse_cursor_obscured.
|
||||
|
||||
* gtk/gtkentry.h (struct _GtkEntry): Add mouse_cursor_obscured.
|
||||
|
||||
* gtk/gtktextview.c (set_invisible_cursor): New function.
|
||||
(gtk_text_view_obscure_mouse_cursor): Likewise.
|
||||
(gtk_text_view_key_press_event): Call obscure_cursor if text
|
||||
has been inserted.
|
||||
(gtk_text_view_motion_event): Restore the mouse cursor.
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_realize): Add GDK_POINTER_MOTION_MASK.
|
||||
(set_invisible_cursor): New function.
|
||||
(gtk_entry_obscure_mouse_cursor): Likewise.
|
||||
(gtk_entry_key_press): call obscure_cursor if text has been inserted.
|
||||
(gtk_entry_motion_notify): Restore the mouse cursor.
|
||||
|
||||
2002-01-27 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* gtk/gtkstyle.c (sanitize_size): removed unused return value.
|
||||
|
@ -1,3 +1,21 @@
|
||||
2002-01-27 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gtk/gtktextview.h (struct _GtkTextView): add mouse_cursor_obscured.
|
||||
|
||||
* gtk/gtkentry.h (struct _GtkEntry): Add mouse_cursor_obscured.
|
||||
|
||||
* gtk/gtktextview.c (set_invisible_cursor): New function.
|
||||
(gtk_text_view_obscure_mouse_cursor): Likewise.
|
||||
(gtk_text_view_key_press_event): Call obscure_cursor if text
|
||||
has been inserted.
|
||||
(gtk_text_view_motion_event): Restore the mouse cursor.
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_realize): Add GDK_POINTER_MOTION_MASK.
|
||||
(set_invisible_cursor): New function.
|
||||
(gtk_entry_obscure_mouse_cursor): Likewise.
|
||||
(gtk_entry_key_press): call obscure_cursor if text has been inserted.
|
||||
(gtk_entry_motion_notify): Restore the mouse cursor.
|
||||
|
||||
2002-01-27 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* gtk/gtkstyle.c (sanitize_size): removed unused return value.
|
||||
|
@ -1,3 +1,21 @@
|
||||
2002-01-27 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gtk/gtktextview.h (struct _GtkTextView): add mouse_cursor_obscured.
|
||||
|
||||
* gtk/gtkentry.h (struct _GtkEntry): Add mouse_cursor_obscured.
|
||||
|
||||
* gtk/gtktextview.c (set_invisible_cursor): New function.
|
||||
(gtk_text_view_obscure_mouse_cursor): Likewise.
|
||||
(gtk_text_view_key_press_event): Call obscure_cursor if text
|
||||
has been inserted.
|
||||
(gtk_text_view_motion_event): Restore the mouse cursor.
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_realize): Add GDK_POINTER_MOTION_MASK.
|
||||
(set_invisible_cursor): New function.
|
||||
(gtk_entry_obscure_mouse_cursor): Likewise.
|
||||
(gtk_entry_key_press): call obscure_cursor if text has been inserted.
|
||||
(gtk_entry_motion_notify): Restore the mouse cursor.
|
||||
|
||||
2002-01-27 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* gtk/gtkstyle.c (sanitize_size): removed unused return value.
|
||||
|
@ -1,3 +1,21 @@
|
||||
2002-01-27 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gtk/gtktextview.h (struct _GtkTextView): add mouse_cursor_obscured.
|
||||
|
||||
* gtk/gtkentry.h (struct _GtkEntry): Add mouse_cursor_obscured.
|
||||
|
||||
* gtk/gtktextview.c (set_invisible_cursor): New function.
|
||||
(gtk_text_view_obscure_mouse_cursor): Likewise.
|
||||
(gtk_text_view_key_press_event): Call obscure_cursor if text
|
||||
has been inserted.
|
||||
(gtk_text_view_motion_event): Restore the mouse cursor.
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_realize): Add GDK_POINTER_MOTION_MASK.
|
||||
(set_invisible_cursor): New function.
|
||||
(gtk_entry_obscure_mouse_cursor): Likewise.
|
||||
(gtk_entry_key_press): call obscure_cursor if text has been inserted.
|
||||
(gtk_entry_motion_notify): Restore the mouse cursor.
|
||||
|
||||
2002-01-27 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* gtk/gtkstyle.c (sanitize_size): removed unused return value.
|
||||
|
@ -1,3 +1,21 @@
|
||||
2002-01-27 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gtk/gtktextview.h (struct _GtkTextView): add mouse_cursor_obscured.
|
||||
|
||||
* gtk/gtkentry.h (struct _GtkEntry): Add mouse_cursor_obscured.
|
||||
|
||||
* gtk/gtktextview.c (set_invisible_cursor): New function.
|
||||
(gtk_text_view_obscure_mouse_cursor): Likewise.
|
||||
(gtk_text_view_key_press_event): Call obscure_cursor if text
|
||||
has been inserted.
|
||||
(gtk_text_view_motion_event): Restore the mouse cursor.
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_realize): Add GDK_POINTER_MOTION_MASK.
|
||||
(set_invisible_cursor): New function.
|
||||
(gtk_entry_obscure_mouse_cursor): Likewise.
|
||||
(gtk_entry_key_press): call obscure_cursor if text has been inserted.
|
||||
(gtk_entry_motion_notify): Restore the mouse cursor.
|
||||
|
||||
2002-01-27 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* gtk/gtkstyle.c (sanitize_size): removed unused return value.
|
||||
|
@ -1,3 +1,21 @@
|
||||
2002-01-27 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gtk/gtktextview.h (struct _GtkTextView): add mouse_cursor_obscured.
|
||||
|
||||
* gtk/gtkentry.h (struct _GtkEntry): Add mouse_cursor_obscured.
|
||||
|
||||
* gtk/gtktextview.c (set_invisible_cursor): New function.
|
||||
(gtk_text_view_obscure_mouse_cursor): Likewise.
|
||||
(gtk_text_view_key_press_event): Call obscure_cursor if text
|
||||
has been inserted.
|
||||
(gtk_text_view_motion_event): Restore the mouse cursor.
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_realize): Add GDK_POINTER_MOTION_MASK.
|
||||
(set_invisible_cursor): New function.
|
||||
(gtk_entry_obscure_mouse_cursor): Likewise.
|
||||
(gtk_entry_key_press): call obscure_cursor if text has been inserted.
|
||||
(gtk_entry_motion_notify): Restore the mouse cursor.
|
||||
|
||||
2002-01-27 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* gtk/gtkstyle.c (sanitize_size): removed unused return value.
|
||||
|
@ -1,3 +1,21 @@
|
||||
2002-01-27 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gtk/gtktextview.h (struct _GtkTextView): add mouse_cursor_obscured.
|
||||
|
||||
* gtk/gtkentry.h (struct _GtkEntry): Add mouse_cursor_obscured.
|
||||
|
||||
* gtk/gtktextview.c (set_invisible_cursor): New function.
|
||||
(gtk_text_view_obscure_mouse_cursor): Likewise.
|
||||
(gtk_text_view_key_press_event): Call obscure_cursor if text
|
||||
has been inserted.
|
||||
(gtk_text_view_motion_event): Restore the mouse cursor.
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_realize): Add GDK_POINTER_MOTION_MASK.
|
||||
(set_invisible_cursor): New function.
|
||||
(gtk_entry_obscure_mouse_cursor): Likewise.
|
||||
(gtk_entry_key_press): call obscure_cursor if text has been inserted.
|
||||
(gtk_entry_motion_notify): Restore the mouse cursor.
|
||||
|
||||
2002-01-27 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* gtk/gtkstyle.c (sanitize_size): removed unused return value.
|
||||
|
@ -1016,6 +1016,7 @@ gtk_entry_realize (GtkWidget *widget)
|
||||
GDK_BUTTON1_MOTION_MASK |
|
||||
GDK_BUTTON3_MOTION_MASK |
|
||||
GDK_POINTER_MOTION_HINT_MASK |
|
||||
GDK_POINTER_MOTION_MASK |
|
||||
GDK_ENTER_NOTIFY_MASK |
|
||||
GDK_LEAVE_NOTIFY_MASK);
|
||||
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
|
||||
@ -1031,7 +1032,7 @@ gtk_entry_realize (GtkWidget *widget)
|
||||
entry->text_area = gdk_window_new (widget->window, &attributes, attributes_mask);
|
||||
gdk_window_set_user_data (entry->text_area, entry);
|
||||
|
||||
gdk_cursor_destroy (attributes.cursor);
|
||||
gdk_cursor_unref (attributes.cursor);
|
||||
|
||||
widget->style = gtk_style_attach (widget->style, widget->window);
|
||||
|
||||
@ -1469,7 +1470,17 @@ gtk_entry_motion_notify (GtkWidget *widget,
|
||||
GtkEntry *entry = GTK_ENTRY (widget);
|
||||
gint tmp_pos;
|
||||
|
||||
if (event->window != entry->text_area || entry->button != 1)
|
||||
if (entry->mouse_cursor_obscured)
|
||||
{
|
||||
GdkCursor *cursor;
|
||||
|
||||
cursor = gdk_cursor_new (GDK_XTERM);
|
||||
gdk_window_set_cursor (entry->text_area, cursor);
|
||||
gdk_cursor_unref (cursor);
|
||||
entry->mouse_cursor_obscured = FALSE;
|
||||
}
|
||||
|
||||
if (event->window != entry->text_area || entry->button !=1)
|
||||
return FALSE;
|
||||
|
||||
if (event->is_hint || (entry->text_area != event->window))
|
||||
@ -1514,6 +1525,44 @@ gtk_entry_motion_notify (GtkWidget *widget,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
set_invisible_cursor (GdkWindow *window)
|
||||
{
|
||||
GdkBitmap *empty_bitmap;
|
||||
GdkCursor *cursor;
|
||||
GdkColor useless;
|
||||
char invisible_cursor_bits[] = { 0x0 };
|
||||
|
||||
useless.red = useless.green = useless.blue = 0;
|
||||
useless.pixel = 0;
|
||||
|
||||
empty_bitmap = gdk_bitmap_create_from_data (window,
|
||||
invisible_cursor_bits,
|
||||
1, 1);
|
||||
|
||||
cursor = gdk_cursor_new_from_pixmap (empty_bitmap,
|
||||
empty_bitmap,
|
||||
&useless,
|
||||
&useless, 0, 0);
|
||||
|
||||
gdk_window_set_cursor (window, cursor);
|
||||
|
||||
gdk_cursor_unref (cursor);
|
||||
|
||||
g_object_unref (empty_bitmap);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_entry_obscure_mouse_cursor (GtkEntry *entry)
|
||||
{
|
||||
if (entry->mouse_cursor_obscured)
|
||||
return;
|
||||
|
||||
set_invisible_cursor (entry->text_area);
|
||||
|
||||
entry->mouse_cursor_obscured = TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gtk_entry_key_press (GtkWidget *widget,
|
||||
GdkEventKey *event)
|
||||
@ -1527,6 +1576,7 @@ gtk_entry_key_press (GtkWidget *widget,
|
||||
|
||||
if (gtk_im_context_filter_keypress (entry->im_context, event))
|
||||
{
|
||||
gtk_entry_obscure_mouse_cursor (entry);
|
||||
entry->need_im_reset = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -88,6 +88,8 @@ struct _GtkEntry
|
||||
guint is_cell_renderer : 1;
|
||||
guint editing_canceled : 1; /* Only used by GtkCellRendererText */
|
||||
|
||||
guint mouse_cursor_obscured : 1;
|
||||
|
||||
guint button;
|
||||
guint blink_timeout;
|
||||
guint recompute_idle;
|
||||
|
@ -3485,6 +3485,45 @@ gtk_text_view_direction_changed (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_invisible_cursor (GdkWindow *window)
|
||||
{
|
||||
GdkBitmap *empty_bitmap;
|
||||
GdkCursor *cursor;
|
||||
GdkColor useless;
|
||||
char invisible_cursor_bits[] = { 0x0 };
|
||||
|
||||
useless.red = useless.green = useless.blue = 0;
|
||||
useless.pixel = 0;
|
||||
|
||||
empty_bitmap = gdk_bitmap_create_from_data (window,
|
||||
invisible_cursor_bits,
|
||||
1, 1);
|
||||
|
||||
cursor = gdk_cursor_new_from_pixmap (empty_bitmap,
|
||||
empty_bitmap,
|
||||
&useless,
|
||||
&useless, 0, 0);
|
||||
|
||||
gdk_window_set_cursor (window, cursor);
|
||||
|
||||
gdk_cursor_unref (cursor);
|
||||
|
||||
g_object_unref (empty_bitmap);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_text_view_obscure_mouse_cursor (GtkTextView *text_view)
|
||||
{
|
||||
if (text_view->mouse_cursor_obscured)
|
||||
return;
|
||||
|
||||
set_invisible_cursor (text_view->text_window->bin_window);
|
||||
|
||||
text_view->mouse_cursor_obscured = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Events
|
||||
*/
|
||||
@ -3620,6 +3659,7 @@ static gint
|
||||
gtk_text_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
|
||||
{
|
||||
gboolean retval = FALSE;
|
||||
gboolean obscure = FALSE;
|
||||
GtkTextView *text_view = GTK_TEXT_VIEW (widget);
|
||||
GtkTextMark *insert;
|
||||
GtkTextIter iter;
|
||||
@ -3634,6 +3674,7 @@ gtk_text_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
|
||||
gtk_im_context_filter_keypress (text_view->im_context, event))
|
||||
{
|
||||
text_view->need_im_reset = TRUE;
|
||||
obscure = TRUE;
|
||||
retval = TRUE;
|
||||
}
|
||||
else if (GTK_WIDGET_CLASS (parent_class)->key_press_event &&
|
||||
@ -3643,6 +3684,8 @@ gtk_text_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
|
||||
event->keyval == GDK_KP_Enter)
|
||||
{
|
||||
gtk_text_view_commit_text (text_view, "\n");
|
||||
|
||||
obscure = TRUE;
|
||||
retval = TRUE;
|
||||
}
|
||||
/* Pass through Tab as literal tab, unless Control is held down */
|
||||
@ -3653,7 +3696,10 @@ gtk_text_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
|
||||
{
|
||||
/* If the text isn't editable, move the focus instead */
|
||||
if (text_view->editable)
|
||||
gtk_text_view_commit_text (text_view, "\t");
|
||||
{
|
||||
gtk_text_view_commit_text (text_view, "\t");
|
||||
obscure = TRUE;
|
||||
}
|
||||
else
|
||||
gtk_text_view_move_focus (text_view,
|
||||
(event->state & GDK_SHIFT_MASK) ?
|
||||
@ -3664,6 +3710,9 @@ gtk_text_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
|
||||
else
|
||||
retval = FALSE;
|
||||
|
||||
if (obscure)
|
||||
gtk_text_view_obscure_mouse_cursor (text_view);
|
||||
|
||||
gtk_text_view_pend_cursor_blink (text_view);
|
||||
|
||||
return retval;
|
||||
@ -3965,6 +4014,16 @@ gtk_text_view_motion_event (GtkWidget *widget, GdkEventMotion *event)
|
||||
{
|
||||
GtkTextView *text_view = GTK_TEXT_VIEW (widget);
|
||||
|
||||
if (text_view->mouse_cursor_obscured)
|
||||
{
|
||||
GdkCursor *cursor;
|
||||
|
||||
cursor = gdk_cursor_new (GDK_XTERM);
|
||||
gdk_window_set_cursor (text_view->text_window->bin_window, cursor);
|
||||
gdk_cursor_unref (cursor);
|
||||
text_view->mouse_cursor_obscured = FALSE;
|
||||
}
|
||||
|
||||
if (event->window == text_view->text_window->bin_window &&
|
||||
text_view->drag_start_x >= 0)
|
||||
{
|
||||
@ -6425,7 +6484,7 @@ text_window_realize (GtkTextWindow *win,
|
||||
/* I-beam cursor */
|
||||
cursor = gdk_cursor_new (GDK_XTERM);
|
||||
gdk_window_set_cursor (win->bin_window, cursor);
|
||||
gdk_cursor_destroy (cursor);
|
||||
gdk_cursor_unref (cursor);
|
||||
|
||||
gtk_im_context_set_client_window (GTK_TEXT_VIEW (win->widget)->im_context,
|
||||
win->window);
|
||||
|
@ -100,6 +100,8 @@ struct _GtkTextView
|
||||
* last "invalidate" signal from the layout
|
||||
*/
|
||||
guint onscreen_validated : 1;
|
||||
|
||||
guint mouse_cursor_obscured : 1;
|
||||
|
||||
GtkTextWindow *text_window;
|
||||
GtkTextWindow *left_window;
|
||||
|
Loading…
Reference in New Issue
Block a user