Hide the mouse cursor in the completion feedback window

2008-03-13  Federico Mena Quintero  <federico@novell.com>

	* gtk/gtkfilechooserentry.c (create_completion_feedback_window):
	Set the mouse cursor of the feedback window to invisible, so that
	we respect GtkEntry's invisible cursor while typing.

Signed-off-by: Federico Mena Quintero <federico@gnu.org>

svn path=/trunk/; revision=19870
This commit is contained in:
Federico Mena Quintero 2008-03-14 02:45:44 +00:00 committed by Federico Mena Quintero
parent d31b7a0dd8
commit 5ed9d8099c
2 changed files with 50 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2008-03-13 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserentry.c (create_completion_feedback_window):
Set the mouse cursor of the feedback window to invisible, so that
we respect GtkEntry's invisible cursor while typing.
2008-03-13 Federico Mena Quintero <federico@novell.com> 2008-03-13 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserentry.c (show_completion_feedback_window): Put * gtk/gtkfilechooserentry.c (show_completion_feedback_window): Put

View File

@ -850,6 +850,47 @@ completion_feedback_window_expose_event_cb (GtkWidget *widget,
return FALSE; return FALSE;
} }
static void
set_invisible_mouse_cursor (GdkWindow *window)
{
/* Stolen from gtkentry.c:set_invisible_cursor() */
/* FIXME: implement a stupid public gdk_window_set_invisible_mouse_cursor() */
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
completion_feedback_window_realize_cb (GtkWidget *widget,
gpointer data)
{
/* We hide the mouse cursor inside the completion feedback window, since
* GtkEntry hides the cursor when the user types. We don't want the cursor to
* come back if the completion feedback ends up where the mouse is.
*/
set_invisible_mouse_cursor (widget->window);
}
static void static void
create_completion_feedback_window (GtkFileChooserEntry *chooser_entry) create_completion_feedback_window (GtkFileChooserEntry *chooser_entry)
{ {
@ -875,6 +916,9 @@ create_completion_feedback_window (GtkFileChooserEntry *chooser_entry)
g_signal_connect (chooser_entry->completion_feedback_window, "expose_event", g_signal_connect (chooser_entry->completion_feedback_window, "expose_event",
G_CALLBACK (completion_feedback_window_expose_event_cb), chooser_entry); G_CALLBACK (completion_feedback_window_expose_event_cb), chooser_entry);
g_signal_connect (chooser_entry->completion_feedback_window, "realize",
G_CALLBACK (completion_feedback_window_realize_cb), chooser_entry);
/* FIXME: connect to motion-notify-event, and *show* the cursor when the mouse moves */
chooser_entry->completion_feedback_label = gtk_label_new (NULL); chooser_entry->completion_feedback_label = gtk_label_new (NULL);
gtk_container_add (GTK_CONTAINER (alignment), chooser_entry->completion_feedback_label); gtk_container_add (GTK_CONTAINER (alignment), chooser_entry->completion_feedback_label);