mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-22 07:21:02 +00:00
Support of [NSEvent -isARepeat] for X Window System
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/branches/kazunobu_input_management@19132 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
db7d315949
commit
dc391d3333
5 changed files with 1331 additions and 487 deletions
18
ChangeLog.branch
Normal file
18
ChangeLog.branch
Normal file
|
@ -0,0 +1,18 @@
|
|||
2004-04-17 Kazunobu Kuriyama <kazunobu.kuriyama@nifty.com>
|
||||
|
||||
Support of [NSEvent -isARepeat] for X Window System when libX11
|
||||
has the symbols defined in X11/XKBlib.h
|
||||
|
||||
* configure.ac: Added a test for XKB.
|
||||
* configure: Regenerated.
|
||||
* Source/x11/XGServerEvent.m: #include <X11/XKBlib.h> if the macro
|
||||
XKB is defined.
|
||||
* Source/x11/XGServerEvent.m (detect_repeat_delay_and_interval()):
|
||||
Created.
|
||||
* Source/x11/XGServerEvent.m (is_a_repeat_key_event()): Created.
|
||||
* Source/x11/XGServerEvent.m (process_key_event()): Call
|
||||
is_a_repeat_key_event() to support -isARepeat.
|
||||
|
||||
2004-01-13 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Branch kazunobu_input_management created
|
|
@ -64,6 +64,10 @@
|
|||
# include <Foundation/NSNotification.h>
|
||||
#endif
|
||||
|
||||
#ifdef XKB
|
||||
#include <X11/XKBlib.h>
|
||||
#endif
|
||||
|
||||
#define cWin ((gswindow_device_t*)generic.cachedWindow)
|
||||
|
||||
extern Atom WM_STATE;
|
||||
|
@ -127,6 +131,11 @@ static void initialize_keyboard (void);
|
|||
|
||||
static void set_up_num_lock (void);
|
||||
|
||||
static BOOL detect_repeat_delay_and_interval(XEvent *xEvent,
|
||||
Time *delay,
|
||||
Time *interval);
|
||||
static BOOL is_a_repeat_key_event(XEvent *xEvent);
|
||||
|
||||
static inline int check_modifier (XEvent *xEvent, KeyCode key_code)
|
||||
{
|
||||
return (xEvent->xkeymap.key_vector[key_code / 8] & (1 << (key_code % 8)));
|
||||
|
@ -1477,6 +1486,81 @@ keysym_is_X_modifier (KeySym keysym)
|
|||
}
|
||||
}
|
||||
|
||||
static BOOL
|
||||
detect_repeat_delay_and_interval(XEvent *xEvent,
|
||||
Time *delay,
|
||||
Time *interval)
|
||||
{
|
||||
#ifdef XKB
|
||||
XkbDescPtr xkb_desc = NULL;
|
||||
Status result;
|
||||
|
||||
xkb_desc = XkbAllocKeyboard();
|
||||
if (xkb_desc == NULL)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
result = XkbGetControls(xEvent->xany.display,
|
||||
XkbRepeatKeysMask,
|
||||
xkb_desc);
|
||||
if (result == BadAlloc)
|
||||
{
|
||||
XkbFreeKeyboard(xkb_desc, 0, YES), xkb_desc = NULL;
|
||||
return NO;
|
||||
}
|
||||
if (result != Success)
|
||||
{
|
||||
XkbFreeControls(xkb_desc, 0, YES), xkb_desc->ctrls = NULL;
|
||||
XkbFreeKeyboard(xkb_desc, 0, YES), xkb_desc = NULL;
|
||||
return NO;
|
||||
}
|
||||
|
||||
*delay = xkb_desc->ctrls->repeat_delay;
|
||||
*interval = xkb_desc->ctrls->repeat_interval;
|
||||
|
||||
XkbFreeControls(xkb_desc, 0, YES), xkb_desc->ctrls = NULL;
|
||||
XkbFreeKeyboard(xkb_desc, 0, YES), xkb_desc = NULL;
|
||||
|
||||
return YES;
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
|
||||
static BOOL
|
||||
is_a_repeat_key_event(XEvent *xEvent)
|
||||
{
|
||||
#ifdef XKB
|
||||
static Time prev_event_time = 0;
|
||||
Time delay;
|
||||
Time interval;
|
||||
BOOL result;
|
||||
|
||||
if (xEvent->xany.type != KeyPress)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
if (detect_repeat_delay_and_interval(xEvent, &delay, &interval) == NO)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
if (xEvent->xkey.time - prev_event_time < interval)
|
||||
{
|
||||
result = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = NO;
|
||||
}
|
||||
prev_event_time = xEvent->xkey.time;
|
||||
|
||||
return result;
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
|
||||
static NSEvent*
|
||||
process_key_event (XEvent* xEvent, XGServer* context, NSEventType eventType)
|
||||
{
|
||||
|
@ -1639,7 +1723,7 @@ process_key_event (XEvent* xEvent, XGServer* context, NSEventType eventType)
|
|||
context: GSCurrentContext()
|
||||
characters: keys
|
||||
charactersIgnoringModifiers: ukeys
|
||||
isARepeat: NO /* isARepeat can't be supported with X */
|
||||
isARepeat: is_a_repeat_key_event(xEvent)
|
||||
keyCode: keyCode];
|
||||
|
||||
return event;
|
||||
|
|
|
@ -98,5 +98,8 @@
|
|||
/* Define if you have X11/extensions/XShm.h */
|
||||
#undef XSHM
|
||||
|
||||
/* Define if your server supports XKB */
|
||||
#undef XKB
|
||||
|
||||
/* Define to 1 if the X Window System is missing or not being used. */
|
||||
#undef X_DISPLAY_MISSING
|
||||
|
|
20
configure.ac
20
configure.ac
|
@ -302,6 +302,26 @@ if test "$ac_cv_header_X11_extensions_XShm_h" = yes -a "$ac_cv_func_shmctl" = ye
|
|||
fi
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# XKB extension
|
||||
#--------------------------------------------------------------------
|
||||
save_CPPFLAGS=${CPPFLAGS}
|
||||
save_LIBS=${LIBS}
|
||||
CPPFLAGS="$X_CFLAGS"
|
||||
LIBS="$X_LIBS -lX11"
|
||||
|
||||
have_xkb=no
|
||||
AC_CHECK_HEADERS(X11/XKBlib.h,
|
||||
have_xkb=yes,,
|
||||
[#include <X11/XKBlib.h>])
|
||||
AC_CHECK_FUNCS(XkbGetControls)
|
||||
if test "$ac_cv_header_X11_XKBlib_h" = yes -a "$ac_cv_func_XkbGetControls" = yes; then
|
||||
AC_DEFINE(XKB,1,[Define if your X server supports XKB])
|
||||
fi
|
||||
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
LIBS="$save_LIBS"
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Window's graphics library
|
||||
#--------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue