diff options
author | Jon Trowbridge <trow@ximian.com> | 2001-04-20 16:15:24 +0800 |
---|---|---|
committer | Jon Trowbridge <trow@src.gnome.org> | 2001-04-20 16:15:24 +0800 |
commit | 7221bd79c2c61f5c66f35ffcf0f471f85bdb6ac7 (patch) | |
tree | 5f890cfefd04a8ec0c32aabdaebdf83801164876 /widgets/text/e-entry.c | |
parent | 4ab57773ab02e3460e8b34897662fe4eb66c7ad7 (diff) | |
download | gsoc2013-evolution-7221bd79c2c61f5c66f35ffcf0f471f85bdb6ac7.tar gsoc2013-evolution-7221bd79c2c61f5c66f35ffcf0f471f85bdb6ac7.tar.gz gsoc2013-evolution-7221bd79c2c61f5c66f35ffcf0f471f85bdb6ac7.tar.bz2 gsoc2013-evolution-7221bd79c2c61f5c66f35ffcf0f471f85bdb6ac7.tar.lz gsoc2013-evolution-7221bd79c2c61f5c66f35ffcf0f471f85bdb6ac7.tar.xz gsoc2013-evolution-7221bd79c2c61f5c66f35ffcf0f471f85bdb6ac7.tar.zst gsoc2013-evolution-7221bd79c2c61f5c66f35ffcf0f471f85bdb6ac7.zip |
Limit total matches, for better performance on slow machines. It is
2001-04-20 Jon Trowbridge <trow@ximian.com>
* gal/e-text/e-completion-test.c: Limit total matches, for better
performance on slow machines. It is supposed to be a test, so
correctness of the completion operations isn't really a
priority...
* gal/e-text/e-completion-view.c (e_completion_view_construct):
Set GTK_CAN_FOCUS flag.
* gal/e-text/e-entry.c (e_entry_show_popup): Evil! Evil! Unclean!
Unclean! Manually check if the pointer is in the area where the
popup is going to appear, and if it is, warp the pointer out of
the way. After days of fucking around, this horrible hack is the
only way that I've been able to figure out to keep the focus from
being taken away from the entry and ending up somewhere strange
when the popup pops up. (The main problem is with the case of
focus-follows-cursor --- click-to-focus works fine. Sawfish
idiocincracies may also be causing problems, but I don't want to
unjustly accuse the WM of anything, as tempting and appealing as
that can be.)
(key_press_cb): Proxy for forwarding the popup's key press events
to the entry.
(key_release_cb): Proxy for forwarding the popup's key release
events to the entry.
These proxies should be enough to take care of my focus problems.
Unfortunately, they aren't, and the pointer-warping-focus-horror
is required for reasons that I don't fully understand.
* gal/e-text/e-text.c (_get_xy_from_position): Made
_get_xy_from_position return a boolean. It returns TRUE if the
computation was successful
(and if valid data is now in *xp and *yp), FALSE otherwise. Make
sure that text->lines is not NULL, and return FALSE if it is.
(_get_position): Test that _get_xy_from_position returns TRUE
before using the values in x and y.
(_get_position): Test that _get_xy_from_position returns TRUE
before using the values in x and y.
Garbage values being returned in passed-in pointers created a race
condition where you could hang an EText if you deleted the entire
contents of the buffer really quickly.
svn path=/trunk/; revision=9468
Diffstat (limited to 'widgets/text/e-entry.c')
-rw-r--r-- | widgets/text/e-entry.c | 80 |
1 files changed, 68 insertions, 12 deletions
diff --git a/widgets/text/e-entry.c b/widgets/text/e-entry.c index 4ab21be725..b84e622de6 100644 --- a/widgets/text/e-entry.c +++ b/widgets/text/e-entry.c @@ -49,6 +49,12 @@ #include "e-text.h" #include "e-entry.h" +#define EVIL_POINTER_WARPING_HACK + +#ifdef EVIL_POINTER_WARPING_HACK +#include <gdk/gdkx.h> +#endif + #define MIN_ENTRY_WIDTH 150 #define INNER_BORDER 2 @@ -457,13 +463,13 @@ e_entry_show_popup (EEntry *entry, gboolean visible) if (visible) { GtkAllocation *dim = &(GTK_WIDGET (entry)->allocation); - gint x, y, fudge; + gint x, y, xo, yo, fudge; const GdkEventMask grab_mask = (GdkEventMask)GDK_BUTTON_PRESS_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_RELEASE_MASK; /* Figure out where to put our popup. */ - gdk_window_get_origin (GTK_WIDGET (entry)->window, &x, &y); - x += dim->x; - y += dim->height + dim->y; + gdk_window_get_origin (GTK_WIDGET (entry)->window, &xo, &yo); + x = xo + dim->x; + y = yo + dim->height + dim->y; /* Put our popup slightly to the right and up, to try to give a visual cue that this popup is tied to this entry. Otherwise one-row popups can sort of "blend" with an entry @@ -475,16 +481,41 @@ e_entry_show_popup (EEntry *entry, gboolean visible) gtk_widget_set_uposition (pop, x, y); e_completion_view_set_width (E_COMPLETION_VIEW (entry->priv->completion_view), dim->width); +#ifdef EVIL_POINTER_WARPING_HACK + /* + I should have learned by now to listen to Havoc... + http://developer.gnome.org/doc/GGAD/faqs.html + */ + + if (! entry->priv->popup_is_visible) { + GdkWindow *gwin = GTK_WIDGET (entry)->window; + gint xx, yy; + gdk_window_get_pointer (gwin, &xx, &yy, NULL); + xx += xo; + yy += yo; + + /* If we are inside the "zone of death" where the popup will appear, warp the pointer to safety. + This is a horrible thing to do. */ + if (y <= yy && yy < yy + dim->height && x <= xx && xx < xx + dim->width) { + XWarpPointer (GDK_WINDOW_XDISPLAY (gwin), None, GDK_WINDOW_XWINDOW (gwin), + 0, 0, 0, 0, + xx - xo, (y-1) - yo); + } + } +#endif + gtk_widget_show (pop); if (! entry->priv->ptr_grab) { - entry->priv->ptr_grab = gdk_pointer_grab (GTK_WIDGET (entry->priv->completion_view)->window, TRUE, - grab_mask, NULL, NULL, GDK_CURRENT_TIME); - if (entry->priv->ptr_grab) - gtk_grab_add (GTK_WIDGET (entry->priv->completion_view)); + entry->priv->ptr_grab = (0 == gdk_pointer_grab (GTK_WIDGET (entry->priv->completion_view)->window, TRUE, + grab_mask, NULL, NULL, GDK_CURRENT_TIME)); + if (entry->priv->ptr_grab) { + gtk_grab_add (GTK_WIDGET (entry->priv->completion_view)); + } } - + + } else { gtk_widget_hide (pop); @@ -497,8 +528,6 @@ e_entry_show_popup (EEntry *entry, gboolean visible) entry->priv->ptr_grab = FALSE; entry->priv->last_completion_pos = -1; - - } e_completion_view_set_editable (E_COMPLETION_VIEW (entry->priv->completion_view), visible); @@ -668,6 +697,24 @@ button_press_cb (GtkWidget *w, GdkEvent *ev, gpointer user_data) unbrowse_cb (E_COMPLETION_VIEW (w), entry); } +static gint +key_press_cb (GtkWidget *w, GdkEventKey *ev, gpointer user_data) +{ + gint rv = 0; + /* Forward signal */ + gtk_signal_emit_by_name (GTK_OBJECT (user_data), "key_press_event", ev, &rv); + return rv; +} + +static gint +key_release_cb (GtkWidget *w, GdkEventKey *ev, gpointer user_data) +{ + gint rv = 0; + /* Forward signal */ + gtk_signal_emit_by_name (GTK_OBJECT (user_data), "key_release_event", ev, &rv); + return rv; +} + void e_entry_enable_completion_full (EEntry *entry, ECompletion *completion, gint delay, EEntryCompletionHandler handler) { @@ -725,7 +772,16 @@ e_entry_enable_completion_full (EEntry *entry, ECompletion *completion, gint del entry); entry->priv->completion_view_popup = gtk_window_new (GTK_WINDOW_POPUP); - + + gtk_signal_connect (GTK_OBJECT (entry->priv->completion_view_popup), + "key_press_event", + GTK_SIGNAL_FUNC (key_press_cb), + entry->canvas); + gtk_signal_connect (GTK_OBJECT (entry->priv->completion_view_popup), + "key_release_event", + GTK_SIGNAL_FUNC (key_release_cb), + entry->canvas); + gtk_object_ref (GTK_OBJECT (entry->priv->completion_view_popup)); gtk_object_sink (GTK_OBJECT (entry->priv->completion_view_popup)); gtk_window_set_policy (GTK_WINDOW (entry->priv->completion_view_popup), FALSE, TRUE, FALSE); |