Back to index

lightning-sunbird  0.9+nobinonly
Static Public Member Functions | Static Private Member Functions | Static Private Attributes
nsXKBModeSwitch Class Reference

#include <nsKeyboardUtils.h>

List of all members.

Static Public Member Functions

static void ControlWorkaround (gboolean grab_during_popup, gboolean ungrab_during_mode_switch)
static gint GrabKeyboard (GdkWindow *win, gint owner_events, guint32 time)
static void UnGrabKeyboard (guint32 time)
static void HandleKeyPress (XKeyEvent *xke)
static void HandleKeyRelease (XKeyEvent *xke)
static void HandleMappingNotify ()

Static Private Member Functions

static void Init ()

Static Private Attributes

static PRUint32 gModeSwitchKeycode1 = 0
static PRUint32 gModeSwitchKeycode2 = 0
static PRBool gGrabDuringPopup = PR_TRUE
static PRBool gUnGrabDuringModeSwitch = PR_TRUE
static PRBool gModeSwitchDown = PR_FALSE
static gint gOwnerEvents
static guint32 gGrabTime

Detailed Description

Definition at line 49 of file nsKeyboardUtils.h.


Member Function Documentation

void nsXKBModeSwitch::ControlWorkaround ( gboolean  grab_during_popup,
gboolean  ungrab_during_mode_switch 
) [static]

Definition at line 95 of file nsKeyboardUtils.cpp.

{
#ifdef DEBUG_bzbarsky
  NS_WARNING("nsXKBModeSwitch::ControlWorkaround:");
  NS_WARNING(nsPrintfCString("    grab_during_popup = %d", grab_during_popup).get());
  NS_WARNING(nsPrintfCString("    ungrab_during_mode_switch = %d", ungrab_during_mode_switch).get());
#endif
  gGrabDuringPopup = grab_during_popup;
  gUnGrabDuringModeSwitch = ungrab_during_mode_switch;

  //
  // This really should be called whenever a MappingNotify
  // event happens but gdk does not support that.
  //
  HandleMappingNotify();
}

Here is the call graph for this function:

gint nsXKBModeSwitch::GrabKeyboard ( GdkWindow *  win,
gint  owner_events,
guint32  time 
) [static]

Definition at line 114 of file nsKeyboardUtils.cpp.

{
  // if grab is disabled pretend it succeeded
  if (!gGrabDuringPopup) {
    return GrabSuccess;
  }

  gint retval;
  retval = gdk_keyboard_grab(win, owner_events, time);
  if (retval == GrabSuccess) {
    gOwnerEvents = owner_events;
    gGrabTime = time;
  }
  else {
    gOwnerEvents = 0;
    gGrabTime = 0;
  }
 
  return retval;
}
void nsXKBModeSwitch::HandleKeyPress ( XKeyEvent *  xke) [static]

Definition at line 211 of file nsKeyboardUtils.cpp.

{
  // if grab is completely disabled then there is nothing to do
  if (!gGrabDuringPopup) {
    return;
  }

  // check for a Mode_switch keypress
  if ((xke->keycode == gModeSwitchKeycode1) 
      || (xke->keycode == gModeSwitchKeycode2)) {
    gModeSwitchDown = TRUE;
    NS_WARNING("nsXKBModeSwitch::HandleKeyPress: Mode_switch is down");
    nsWindow *win = nsWindow::GetGrabWindow();
    if (!win)
      return;
    if (win->GrabInProgress()) {
      if (gUnGrabDuringModeSwitch) {
        gdk_keyboard_ungrab(GDK_CURRENT_TIME);
        NS_WARNING("\n\n*** ungrab keyboard ***\n\n");
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsXKBModeSwitch::HandleKeyRelease ( XKeyEvent *  xke) [static]

Definition at line 236 of file nsKeyboardUtils.cpp.

{
  // if grab is completely disabled then there is nothing to do
  if (!gGrabDuringPopup) {
    return;
  }

  // check for a Mode_switch keyrelease
  if ((xke->keycode == gModeSwitchKeycode1) 
          || (xke->keycode == gModeSwitchKeycode2)) {
    gModeSwitchDown = FALSE;
    NS_WARNING("nsXKBModeSwitch::HandleKeyPress: Mode_switch is up");
    nsWindow *win = nsWindow::GetGrabWindow();
    if (!win)
      return;
    if (win->GrabInProgress()) {
      if (gUnGrabDuringModeSwitch) {
        if (!win->GetGdkGrabWindow())
          return;
        gdk_keyboard_grab(win->GetGdkGrabWindow(), gOwnerEvents, gGrabTime);
        NS_WARNING("\n\n*** re-grab keyboard ***\n\n");
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 136 of file nsKeyboardUtils.cpp.

{
  XModifierKeymap *xmodmap;
  int i, j, max_keypermod;

  // since the mapping could change we (re)initialize variables
  Init();

  Display *lGdkDisplay = GDK_DISPLAY();
  if (!lGdkDisplay)
    return;
  xmodmap = XGetModifierMapping(lGdkDisplay);
  if (!xmodmap)
    return;

  max_keypermod = MIN(xmodmap->max_keypermod,5);
  for (i=0; i<max_keypermod; i++) {
    for (j=0; j<MODIFIERMAP_ROW_SIZE; j++) {
      KeyCode keycode;
      KeySym keysym;
      char *keysymName;
      keycode = *((xmodmap->modifiermap)+(i*MODIFIERMAP_ROW_SIZE)+j);
      if (!keycode)
        continue;
      keysym = XKeycodeToKeysym(GDK_DISPLAY(), keycode, 0);
      if (!keysym)
        continue;
      keysymName = XKeysymToString(keysym);
      if (!keysymName)
        continue;
      if (!strcmp(keysymName,"Mode_switch")) {
        if (!gModeSwitchKeycode1)
          gModeSwitchKeycode1 = keycode;
        else if (!gModeSwitchKeycode2)
          gModeSwitchKeycode2 = keycode;
      }
    }
  }
  XFreeModifiermap(xmodmap);

#ifdef DEBUG_bzbarsky
  if (!gModeSwitchKeycode1) {
    NS_WARNING("\n\nnsXKBModeSwitch::HandleMappingNotify: no Mode_switch\n\n");
  }
  NS_WARNING("\n\nnsXKBModeSwitch::HandleMappingNotify:");
  NS_WARNING(nsPrintfCString("    gModeSwitchKeycode1 = %d", gModeSwitchKeycode1).get());
  NS_WARNING(nsPrintfCString("    gModeSwitchKeycode2 = %d", gModeSwitchKeycode2).get());
#endif

#if defined(HAVE_X11_XKBLIB_H) && \
  defined(XkbMajorVersion) && defined(XbMinorVersion)
  {
    gint xkb_major = XkbMajorVersion;
    gint xkb_minor = XkbMinorVersion;
    if (XkbLibraryVersion (&xkb_major, &xkb_minor)) {
      xkb_major = XkbMajorVersion;
      xkb_minor = XkbMinorVersion;
      if (XkbQueryExtension (gdk_display, NULL, NULL, NULL,
                               &xkb_major, &xkb_minor)) {
      }
    }
  }
#endif

}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsXKBModeSwitch::Init ( void  ) [static, private]

Definition at line 203 of file nsKeyboardUtils.cpp.

Here is the caller graph for this function:

void nsXKBModeSwitch::UnGrabKeyboard ( guint32  time) [static]

Definition at line 263 of file nsKeyboardUtils.cpp.

{
  // if grab is completely disabled then there is nothing to do
  if (!gGrabDuringPopup) {
    return;
  }

  gdk_keyboard_ungrab(time);
  gOwnerEvents = 0;
  gGrabTime = 0;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 64 of file nsKeyboardUtils.h.

guint32 nsXKBModeSwitch::gGrabTime [static, private]

Definition at line 68 of file nsKeyboardUtils.h.

Definition at line 66 of file nsKeyboardUtils.h.

Definition at line 62 of file nsKeyboardUtils.h.

Definition at line 63 of file nsKeyboardUtils.h.

gint nsXKBModeSwitch::gOwnerEvents [static, private]

Definition at line 67 of file nsKeyboardUtils.h.

Definition at line 65 of file nsKeyboardUtils.h.


The documentation for this class was generated from the following files: