I have an application where I need to intercept keyboard LEFT / RIGHT key
presses and translate them to SHIFT+TAB / TAB. I understand that
Gdk::Window::add_filter() or gdk_window_add_filter() is my way forward.

So I installed a filter function by calling the above method and I am able
to intercept the events right. However I am unable to translate the X event
to an equivalent Gdk event.

001 GdkFilterReturn FilterInput(GdkXEvent *xevent,
002                             GdkEvent *event,
003                             gpointer data)
004 {
005   GdkFilterReturn eRet = GDK_FILTER_CONTINUE;
006
007   {
008     XEvent *pEvent = (XEvent*)xevent;
009
010     if (2
011         == pEvent->type)
012     {
013       if ((113
014            == pEvent->xkey.keycode)
015           || (114
016               == pEvent->xkey.keycode))
017       {
018         event->key.hardware_keycode = pEvent->xkey.keycode;
019         event->key.keyval = GDK_KEY_Tab;
020         event->key.length = 0;
021         event->key.time = pEvent->xkey.time;
022         event->key.type = GDK_KEY_PRESS;
023
024         if(113 == pEvent->xkey.keycode)
025         {
026           event->key.state |= GDK_SHIFT_MASK;
027           event->key.keyval = GDK_KEY_ISO_Left_Tab;
028         }
029
030         eRet = GDK_FILTER_TRANSLATE;
031       }
032     }
033   }
034
035   return eRet;
036 }

Above code always causes the application to crash when I do LEFT / RIGHT
with the following warning.

*Gdk-WARNING **: 13:16:43.246: Event with type 8 not holding a GdkDevice.
It is most likely synthesized outside Gdk/GTK+*

I did quite a bit of search to find examples on translating X events to Gdk
events without any leads. Can someone tell me what is missing in my code or
point me to some examples where filtering is done?

-- 


-- 
*Please consider the Environment before printing this e-mail.*




        
        
        
        
The information contained in this message 
(including any attachments) is 
confidential and may be privileged or 
otherwise protected from disclosure. 
 If you are not the intended 
recipient, you must not copy this message or 
attachment or disclose the 
contents to any other person.  If you have 
received this transmission in
 error, please notify the sender immediately 
by return e-mail and 
permanently delete this message and any attachments 
from your system.  
Any dissemination, use, review, distribution, printing 
or copying of 
this message in whole or in part is strictly prohibited.  
Please note 
that e-mails are susceptible to change. 
 
*SKANRAY* 
<http://www.skanray.com>*(including
 its group of companies) shall not be 
liable for any omission or error 
in the message, improper or incomplete 
transmission of the information 
contained in this communication or for any 
delay in its receipt or 
damage to your system. * *SKANRAY* 
<http://www.skanray.com>*(or
 its group of companies) does not guarantee 
that the integrity of this 
communication has been maintained or that this 
communication is free of 
viruses, interceptions or interference.*
_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to