@@ -383,14 +383,16 @@ static Window mkwindow(Ghandles * g, struct windowdata *vm_window)
383383
384384 // select xinput events
385385 XIEventMask xi_mask ;
386- xi_mask .deviceid = XIAllDevices ;
386+ xi_mask .deviceid = XIAllMasterDevices ; // https://stackoverflow.com/questions/44095001/getting-double-rawkeypress-events-using-xinput2
387387 xi_mask .mask_len = XIMaskLen (XI_LASTEVENT );
388388 xi_mask .mask = calloc (xi_mask .mask_len , sizeof (char ));
389389 XISetMask (xi_mask .mask , XI_KeyPress );
390390 XISetMask (xi_mask .mask , XI_KeyRelease );
391391 XISetMask (xi_mask .mask , XI_FocusIn );
392392 XISetMask (xi_mask .mask , XI_FocusOut );
393393 XISelectEvents (g -> display , child_win , & xi_mask , 1 );
394+ free (xi_mask .mask );
395+ XSync (g -> display , False );
394396
395397
396398 XSetWMProtocols (g -> display , child_win , & g -> wmDeleteMessage , 1 );
@@ -1888,6 +1890,16 @@ static void handle_configure_from_vm(Ghandles * g, struct windowdata *vm_window)
18881890 }
18891891}
18901892
1893+ static void send_keymap_notify (Ghandles * g )
1894+ {
1895+ struct msg_hdr hdr ;
1896+ char keys [32 ];
1897+ XQueryKeymap (g -> display , keys );
1898+ hdr .type = MSG_KEYMAP_NOTIFY ;
1899+ hdr .window = 0 ;
1900+ write_message (g -> vchan , hdr , keys );
1901+ }
1902+
18911903/* handle local Xserver event: EnterNotify, LeaveNotify
18921904 * send it to VM, but alwo we use it to fix docked
18931905 * window position */
@@ -1898,11 +1910,7 @@ static void process_xevent_crossing(Ghandles * g, const XCrossingEvent * ev)
18981910 CHECK_NONMANAGED_WINDOW (g , ev -> window );
18991911
19001912 if (ev -> type == EnterNotify ) {
1901- char keys [32 ];
1902- XQueryKeymap (g -> display , keys );
1903- hdr .type = MSG_KEYMAP_NOTIFY ;
1904- hdr .window = 0 ;
1905- write_message (g -> vchan , hdr , keys );
1913+ send_keymap_notify (g );
19061914 }
19071915 /* move tray to correct position in VM */
19081916 if (vm_window -> is_docked &&
@@ -1948,13 +1956,10 @@ static void process_xievent_focus(Ghandles * g, const XILeaveEvent * ev)
19481956 struct msg_hdr hdr ;
19491957 struct msg_focus k ;
19501958 CHECK_NONMANAGED_WINDOW (g , ev -> event );
1959+ update_wm_user_time (g , ev -> event , ev -> time );
19511960
19521961 if (ev -> type == XI_FocusIn ) {
1953- char keys [32 ];
1954- XQueryKeymap (g -> display , keys );
1955- hdr .type = MSG_KEYMAP_NOTIFY ;
1956- hdr .window = 0 ;
1957- write_message (g -> vchan , hdr , keys );
1962+ send_keymap_notify (g );
19581963 }
19591964 hdr .type = MSG_FOCUS ;
19601965 hdr .window = vm_window -> remote_winid ;
@@ -2309,11 +2314,7 @@ static void process_xevent_xembed(Ghandles * g, const XClientMessageEvent * ev)
23092314 } else if (ev -> data .l [1 ] == XEMBED_FOCUS_IN ) {
23102315 struct msg_hdr hdr ;
23112316 struct msg_focus k ;
2312- char keys [32 ];
2313- XQueryKeymap (g -> display , keys );
2314- hdr .type = MSG_KEYMAP_NOTIFY ;
2315- hdr .window = 0 ;
2316- write_message (g -> vchan , hdr , keys );
2317+ send_keymap_notify (g );
23172318 hdr .type = MSG_FOCUS ;
23182319 hdr .window = vm_window -> remote_winid ;
23192320 k .type = FocusIn ;
0 commit comments