void XWindowsKeyState::fakeKey(const Keystroke& keystroke) { switch (keystroke.m_type) { case Keystroke::kButton: LOG((CLOG_DEBUG1 " %03x (%08x) %s", keystroke.m_data.m_button.m_button, keystroke.m_data.m_button.m_client, keystroke.m_data.m_button.m_press ? "down" : "up")); if (keystroke.m_data.m_button.m_repeat) { int c = keystroke.m_data.m_button.m_button; int i = (c >> 3); int b = 1 << (c & 7); if (m_keyboardState.global_auto_repeat == AutoRepeatModeOff || (c!=113 && c!=116 && (m_keyboardState.auto_repeats[i] & b) == 0)) { LOG((CLOG_DEBUG1 " discard autorepeat")); break; } } XTestFakeKeyEvent(m_display, keystroke.m_data.m_button.m_button, keystroke.m_data.m_button.m_press ? True : False, CurrentTime); break; case Keystroke::kGroup: if (keystroke.m_data.m_group.m_absolute) { LOG((CLOG_DEBUG1 " group %d", keystroke.m_data.m_group.m_group)); #if HAVE_XKB_EXTENSION if (m_xkb != NULL) { if (XkbLockGroup(m_display, XkbUseCoreKbd, keystroke.m_data.m_group.m_group) == False) { LOG((CLOG_DEBUG1 "XkbLockGroup request not sent")); } } else #endif { LOG((CLOG_DEBUG1 " ignored")); } } else { LOG((CLOG_DEBUG1 " group %+d", keystroke.m_data.m_group.m_group)); #if HAVE_XKB_EXTENSION if (m_xkb != NULL) { if (XkbLockGroup(m_display, XkbUseCoreKbd, getEffectiveGroup(pollActiveGroup(), keystroke.m_data.m_group.m_group)) == False) { LOG((CLOG_DEBUG1 "XkbLockGroup request not sent")); } } else #endif { LOG((CLOG_DEBUG1 " ignored")); } } break; }
static void menu_activated(GtkWidget *widget, gpointer data) { ENTER; DBG("asking %d group\n", GPOINTER_TO_INT(data)); XkbLockGroup(dpy, XkbUseCoreKbd, GPOINTER_TO_INT(data)); RET(); }
static void meta_backend_x11_lock_layout_group (MetaBackend *backend, guint idx) { MetaBackendX11 *x11 = META_BACKEND_X11 (backend); MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11); XkbLockGroup (priv->xdisplay, XkbUseCoreKbd, idx); }
gboolean get_key_win(gpointer data) { AConvert *aconv = (AConvert *)data; XEvent xev; WInfo *info; Window w; info = win_find(aconv->keyboard->win,aconv); if(info) { if(aconv->sxkb->cur_group!=info->cur_group) { XkbLockGroup(aconv->keyboard->dpy, XkbUseCoreKbd, info->cur_group); update_flag(aconv->sxkb->group2info[aconv->sxkb->cur_group],aconv); } w=get_active_window(aconv->keyboard->dpy); if(info->win!=w) free_keysym_to_list(aconv); } { if (XPending(aconv->keyboard->dpy)) { XNextEvent (aconv->keyboard->dpy, &xev); switch (xev.type) { case KeyPress: if (xev.xkey.send_event == TRUE) return False; get_key_pres(aconv,&xev); info = win_find(aconv->keyboard->win,aconv); if(info) auto_convert_text(aconv,info); break; case DestroyNotify: if((xev.xdestroywindow.event == aconv->keyboard->root)) break; /* XGetInputFocus (aconv->keyboard->dpy,&w, &(aconv->keyboard->cur_status)); DEBUG_MSG("DestroyNotify ID %#x == ID %#x ++ ID %#x == ID %#x == ID %#x \n",(unsigned int) aconv->keyboard->win,(unsigned int)info->win,(unsigned int)w,(unsigned int)xev.xdestroywindow.window,(unsigned int)xev.xdestroywindow.event);*/ info = win_find(xev.xdestroywindow.event,aconv); if (info) { //printf ("Dest window: ID %#x \n",(unsigned int)info->win); win_free(info,aconv); } break; } } } return TRUE; }
static gboolean clicked(GtkStatusIcon *status_icon, GdkEventButton *event, gpointer data) { ENTER; if (event->button == 1) { XkbLockGroup(dpy, XkbUseCoreKbd, (cur_group + 1) % ngroups); } else { gtk_menu_popup(GTK_MENU(menu), NULL, NULL, gtk_status_icon_position_menu, icon, event->button, event->time); } RET(FALSE); }
int main (int argc, char *argv[]) { Display *dpy; XkbStateRec xkbState; int group, newgroup; char *endptr; if (argc > 2 || argc == 2 && (0 == strcmp(argv[1], "--help") || 0 == strcmp(argv[1], "-h"))) { fprintf(stderr, "Usage: %s [group]\n", argv[0]); exit(EXIT_FAILURE); } dpy = XkbOpenDisplay(NULL, NULL, NULL, NULL, NULL, NULL); if (NULL == dpy) { fprintf (stderr, "%s: Can't open display\n", argv[0]); exit(EXIT_FAILURE); } XkbGetState(dpy, XkbUseCoreKbd, &xkbState); group = xkbState.group; switch (argc) { case 1: fprintf (stdout, "%d\n", group); goto success; break; case 2: errno = 0; newgroup = strtol(argv[1], &endptr, 10); if (errno != 0 || *endptr != '\0') { fprintf(stderr, "The first argument must be an integer\n"); goto failure; } if (newgroup != group) { if (False == XkbLockGroup(dpy, XkbUseCoreKbd, abs (newgroup % 4))) { fprintf(stderr, "%s: Can't lock group\n", argv[0]); goto failure; } XSync(dpy, False); } break; } success: XCloseDisplay(dpy); exit(EXIT_SUCCESS); failure: XCloseDisplay(dpy); exit(EXIT_FAILURE); }
void xConvert_text_eng (gpointer data,WInfo *info) { int i=0; int mod=0; int slen; AConvert *aconv = (AConvert *)data; if((aconv==NULL)||(info==NULL)) return; slen =aconv->keyboard->gstr->len;//g_list_length (info->ks); if(slen<=0) { free_keysym_to_list(aconv); return ; } for (i = 0; i <= aconv->sxkb->ngroups; i++) { if ((g_strcasecmp(aconv->sxkb->group2info[i]->name, "English") == 0) || (g_strcasecmp(aconv->sxkb->group2info[i]->name, "US/ASCII") == 0) || (g_strcasecmp(aconv->sxkb->group2info[i]->name, "en_US") == 0) || (g_strcasecmp(aconv->sxkb->group2info[i]->name, "Maltese (US layout)") == 0) || (g_strcasecmp(aconv->sxkb->group2info[i]->name, "U.S. English") == 0)) break; } info->cur_group=i; mod=(8192*i); XkbLockGroup(aconv->keyboard->dpy, XkbUseCoreKbd,i); update_flag(aconv->sxkb->group2info[aconv->sxkb->cur_group],aconv); delete_char_in_win(info->win,aconv->keyboard->iterator); backspace_char_in_win(info->win,slen-aconv->keyboard->iterator); aconv->keyboard->iterator=0; { GList *p = g_list_first (aconv->keyboard->ks); while (p) { Skeysym *sks=(Skeysym *)p->data; send_key_to_win(info->win,XKeysymToKeycode(aconv->keyboard->dpy,sks->key),mod+sks->mod); p = g_list_next (p); } } }
void xConvert_text (gpointer data) { int mod=0; size_t slen; AConvert *aconv = (AConvert *)data; if(aconv==NULL) return; aconv->keyboard->win=get_active_window(aconv->keyboard->dpy); WInfo *info = win_find(aconv->keyboard->win,aconv); if (!info) return; slen =aconv->keyboard->gstr->len;//g_list_length (info->ks); if(slen<=0) { free_keysym_to_list(aconv); return ; } if(info->cur_group==(aconv->sxkb->ngroups-1)) info->cur_group=0; else if (info->cur_group < (aconv->sxkb->ngroups-1)) info->cur_group++; else info->cur_group=0; mod=(8192*info->cur_group); XkbLockGroup(aconv->keyboard->dpy, XkbUseCoreKbd,info->cur_group); update_flag(aconv->sxkb->group2info[aconv->sxkb->cur_group],aconv); delete_char_in_win(info->win,aconv->keyboard->iterator); backspace_char_in_win(info->win,slen-aconv->keyboard->iterator); aconv->keyboard->iterator=0; { GList *p = g_list_first (aconv->keyboard->ks); while (p) { Skeysym *sks=(Skeysym *)p->data; send_key_to_win(info->win,XKeysymToKeycode(aconv->keyboard->dpy,sks->key),mod+sks->mod); p = g_list_next (p); } } }
void xConvert_text_rus (gpointer data,WInfo *info) { int i=1; int mod=0; size_t slen; AConvert *aconv = (AConvert *)data; if((aconv==NULL)||(info==NULL)) return; slen =aconv->keyboard->gstr->len;//g_list_length (info->ks); if(slen<=0) { free_keysym_to_list(aconv); return ; } for (i = 0; i <= aconv->sxkb->ngroups; i++) { DEBUG_MSG("%s\n",aconv->sxkb->group2info[0]->name); if ((g_strcasecmp(aconv->sxkb->group2info[i]->name, "Russian") == 0) || (g_strcasecmp(aconv->sxkb->group2info[i]->name, "Russian(phonetic)") == 0) || (g_strcasecmp(aconv->sxkb->group2info[i]->name, "Russia - Winkeys") == 0)) break; } info->cur_group=i; mod=(8192*i); XkbLockGroup(aconv->keyboard->dpy, XkbUseCoreKbd,i); update_flag(aconv->sxkb->group2info[aconv->sxkb->cur_group],aconv); delete_char_in_win(info->win,aconv->keyboard->iterator); backspace_char_in_win(info->win,slen-aconv->keyboard->iterator); aconv->keyboard->iterator=0; { GList *p = g_list_first (aconv->keyboard->ks); while (p) { Skeysym *sks=(Skeysym *)p->data; send_key_to_win(info->win,XKeysymToKeycode(aconv->keyboard->dpy,sks->key),mod+sks->mod); p = g_list_next (p); } } }
static void handle_host_xevent (MetaBackend *backend, XEvent *event) { MetaBackendX11 *x11 = META_BACKEND_X11 (backend); MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11); gboolean bypass_clutter = FALSE; XGetEventData (priv->xdisplay, &event->xcookie); { MetaDisplay *display = meta_get_display (); if (display) { MetaCompositor *compositor = display->compositor; if (meta_plugin_manager_xevent_filter (compositor->plugin_mgr, event)) bypass_clutter = TRUE; } } if (priv->mode == META_BACKEND_X11_MODE_NESTED && event->type == FocusIn) { #ifdef HAVE_WAYLAND Window xwin = meta_backend_x11_get_xwindow(x11); XEvent xev; if (event->xfocus.window == xwin) { /* Since we've selected for KeymapStateMask, every FocusIn is followed immediately * by a KeymapNotify event */ XMaskEvent(priv->xdisplay, KeymapStateMask, &xev); MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default (); meta_wayland_compositor_update_key_state (compositor, xev.xkeymap.key_vector, 32, 8); } #else g_assert_not_reached (); #endif } if (event->type == (priv->xsync_event_base + XSyncAlarmNotify)) handle_alarm_notify (backend, event); if (event->type == priv->xkb_event_base) { XkbEvent *xkb_ev = (XkbEvent *) event; if (xkb_ev->any.device == META_VIRTUAL_CORE_KEYBOARD_ID) { switch (xkb_ev->any.xkb_type) { case XkbNewKeyboardNotify: case XkbMapNotify: keymap_changed (backend); break; case XkbStateNotify: if (xkb_ev->state.changed & XkbGroupLockMask) { if (priv->locked_group != xkb_ev->state.locked_group) XkbLockGroup (priv->xdisplay, XkbUseCoreKbd, priv->locked_group); } break; default: break; } } } { MetaMonitorManager *manager = meta_backend_get_monitor_manager (backend); if (META_IS_MONITOR_MANAGER_XRANDR (manager) && meta_monitor_manager_xrandr_handle_xevent (META_MONITOR_MANAGER_XRANDR (manager), event)) bypass_clutter = TRUE; } if (!bypass_clutter) { handle_input_event (x11, event); clutter_x11_handle_event (event); } XFreeEventData (priv->xdisplay, &event->xcookie); }
/*EXTL_DOC * Set the current XKB group. See \code{XkbLockGroup}(3) manual page * for details. See xkbion.lua for example use. */ EXTL_EXPORT int mod_xkb_lock_group(int state) { return XkbLockGroup(ioncore_g.dpy, XkbUseCoreKbd, state); }
void XKeyboard::set_group(int groupNum) { Bool result = XkbLockGroup(_display, _deviceId, groupNum); CHECK(result == True); }
bool X11Helper::setGroup(unsigned int group) { return XkbLockGroup(QX11Info::display(), XkbUseCoreKbd, group); }