Is there any reason not making the text entry focused before sending KeyPress event to it?

Yichao Yu yyc1992 at gmail.com
Mon Jul 16 08:18:10 EDT 2012


Hi Eion

Nop, that is not the reason.
These events are already handled before this, (pasting the code from
gtkconv.c right before those line so u don't need to find it
yourself):

	/* If we have a valid key for the conversation display, then exit */
	if ((event->state & GDK_CONTROL_MASK) ||
		(event->keyval == GDK_F6) ||
		(event->keyval == GDK_F10) ||
		(event->keyval == GDK_Shift_L) ||
		(event->keyval == GDK_Shift_R) ||
		(event->keyval == GDK_Control_L) ||
		(event->keyval == GDK_Control_R) ||
		(event->keyval == GDK_Escape) ||
		(event->keyval == GDK_Up) ||
		(event->keyval == GDK_Down) ||
		(event->keyval == GDK_Left) ||
		(event->keyval == GDK_Right) ||
		(event->keyval == GDK_Page_Up) ||
		(event->keyval == GDK_KP_Page_Up) ||
		(event->keyval == GDK_Page_Down) ||
		(event->keyval == GDK_KP_Page_Down) ||
		(event->keyval == GDK_Home) ||
		(event->keyval == GDK_End) ||
		(event->keyval == GDK_Tab) ||
		(event->keyval == GDK_KP_Tab) ||
		(event->keyval == GDK_ISO_Left_Tab))
	{
		if (event->type == GDK_KEY_PRESS)
			return conv_keypress_common(gtkconv, event);
		return FALSE;
	}

So these special key bindings (hard coded shortcuts ......) are
already handled before sending it to text entry. Even if you have some
other key bindings that want to send to text entry without grabbing
the focus, which I REALLY doubt~~~, the above section is where they
should be added.

According the the current code, the focus will ALWAYS be grabbed when
the key releases and you ALWAYS assume the text entry have already
handled the event (since the return value is always TRUE after that)
so it will not be sent to any following handlers (if there are).
Therefore, the only different by removing the `event->type ==
GDK_KEY_PRESS` would be whether the text entry is focused when
handling this event itself, and I think having it focused is the
correct way.

THX for ur reply. =D

Yichao Yu

On Mon, Jul 16, 2012 at 12:51 AM, Eion Robb <eion at robbmob.com> wrote:
> Does it not grab the focus so that the ctrl+tab key combo still works?
>
> On 16 July 2012 16:12, Yichao Yu <yyc1992 at gmail.com> wrote:
>> O, and btw, I have already reported this bug fix 5 weeks ago (with no
>> reply) in ticket #15159.
>>
>> Yichao Yu
>>
>> On Mon, Jul 16, 2012 at 12:06 AM, Yichao Yu <yyc1992 at gmail.com> wrote:
>>> Hi All,
>>>
>>> When pressing a key in pidgin's chat window, the key will be sent to
>>> the input entry even if it is not focused. However, this event is not
>>> sent to input method (which is REALLY annoy for ppl like me that uses
>>> input method!!!)
>>>
>>> Looking at the source code, in pidgin/gtkconv.c (arround line 2271)
>>>
>>>         if (event->type == GDK_KEY_RELEASE)
>>>                 gtk_widget_grab_focus(gtkconv->entry);
>>>
>>>         gtk_widget_event(gtkconv->entry, (GdkEvent *)event);
>>> which means the entry will not be focused when a keypress event is
>>> sent and this causes the imcontext not sending the event to input
>>> method. Since the event will anyway be sent to the entry, I cannot see
>>> the point why it should not be focused. Is there really any specific
>>> reason for doing that?
>>>
>>> (btw, afaik, removing the if line fixes the input method issue perfectly)
>>>
>>> Yichao Yu
>>
>> _______________________________________________
>> Devel mailing list
>> Devel at pidgin.im
>> http://pidgin.im/cgi-bin/mailman/listinfo/devel




More information about the Devel mailing list