Add help key mask support

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@23745 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2006-10-03 18:54:22 +00:00
parent 477e14c709
commit a459507bc2
4 changed files with 80 additions and 20 deletions

View file

@ -1,3 +1,11 @@
2006-10-03 Richard Frith-Macdonald <rfm@gnu.org>
* Source/x11/XWindowBuffer.m: ([_exposeRect:])
Clip draw area to size of buffer rather than size of wiondow,
in case the two have become out of sync somehow.
* Source/win32/WIN32Server.m: Add help key mask
* Source/x11/XGServerEvent.m: ditto
2006-10-02 Nicola Pero <nicola.pero@meta-innovation.com>
* configure.ac: Check the new variable GNUSTEP_IS_FLATTENED,

View file

@ -2193,6 +2193,8 @@ process_key_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
eventFlags |= NSShiftKeyMask;
if (keyState[VK_MENU] & 128)
eventFlags |= NSAlternateKeyMask;
if (keyState[VK_HELP] & 128)
eventFlags |= NSHelpKeyMask;
if ((keyState[VK_LWIN] & 128) || (keyState[VK_RWIN] & 128))
eventFlags |= NSCommandKeyMask;
@ -2203,6 +2205,7 @@ process_key_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
case VK_CAPITAL:
case VK_CONTROL:
case VK_MENU:
case VK_HELP:
case VK_NUMLOCK:
eventType = NSFlagsChanged;
break;
@ -2304,6 +2307,10 @@ process_mouse_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
{
eventFlags |= NSAlternateKeyMask;
}
if (GetKeyState(VK_HELP) < 0)
{
eventFlags |= NSHelpKeyMask;
}
// What about other modifiers?
if (eventType == NSScrollWheel)
@ -2326,9 +2333,9 @@ process_mouse_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
eventType = NSOtherMouseDragged;
}
}
else if ((eventType == NSLeftMouseDown) ||
(eventType == NSRightMouseDown) ||
(eventType == NSOtherMouseDown))
else if ((eventType == NSLeftMouseDown)
|| (eventType == NSRightMouseDown)
|| (eventType == NSOtherMouseDown))
{
if (lastTime + GetDoubleClickTime() > ltime)
{

View file

@ -74,6 +74,7 @@ static unsigned int _num_lock_mask;
static char _control_pressed = 0;
static char _command_pressed = 0;
static char _alt_pressed = 0;
static char _help_pressed = 0;
/*
Keys used for the modifiers (you may set them with user preferences).
Note that the first and second key sym for a modifier must be different.
@ -82,6 +83,7 @@ Otherwise, the _*_pressed tracking will be confused.
static KeySym _control_keysyms[2];
static KeySym _command_keysyms[2];
static KeySym _alt_keysyms[2];
static KeySym _help_keysyms[2];
static BOOL _is_keyboard_initialized = NO;
static BOOL _mod_ignore_shift = NO;
@ -1141,6 +1143,19 @@ static int check_modifier (XEvent *xEvent, KeySym key_sym,
{
_alt_pressed |= 2;
}
// Check if help is pressed
_help_pressed = 0;
if ((_help_keysyms[0] != NoSymbol)
&& check_modifier (&xEvent, _help_keysyms[0], modmap))
{
_help_pressed |= 1;
}
if ((_help_keysyms[1] != NoSymbol)
&& check_modifier (&xEvent, _help_keysyms[1], modmap))
{
_help_pressed |= 2;
}
XFreeModifiermap(modmap);
}
break;
@ -1644,6 +1659,20 @@ initialize_keyboard (void)
if (_alt_keysyms[0] == _alt_keysyms[1])
_alt_keysyms[1] = NoSymbol;
// Initialize Help
_help_keysyms[0] = key_sym_from_defaults(display, defaults,
@"GSFirstHelpKey",
XK_Help);
if (XKeysymToKeycode(display, _help_keysyms[0]) == 0)
_help_keysyms[0] = NoSymbol;
_help_keysyms[1] = key_sym_from_defaults(display, defaults,
@"GSSecondAlternateKey",
NoSymbol);
if (_help_keysyms[0] == _help_keysyms[1])
_help_keysyms[1] = NoSymbol;
set_up_num_lock ();
_mod_ignore_shift = [defaults boolForKey: @"GSModifiersAreKeys"];
@ -1727,6 +1756,7 @@ process_key_event (XEvent* xEvent, XGServer* context, NSEventType eventType)
int control_key = 0;
int command_key = 0;
int alt_key = 0;
int help_key = 0;
KeySym modKeysym; // process modifier independently of shift, etc.
if (_is_keyboard_initialized == NO)
@ -1785,10 +1815,18 @@ process_key_event (XEvent* xEvent, XGServer* context, NSEventType eventType)
{
alt_key = 2;
}
else if (modKeysym == _help_keysyms[0])
{
help_key = 1;
}
else if (modKeysym == _help_keysyms[1])
{
help_key = 2;
}
}
originalType = eventType;
if (control_key || command_key || alt_key)
if (control_key || command_key || alt_key || help_key)
{
eventType = NSFlagsChanged;
if (xEvent->xkey.type == KeyPress)
@ -1799,6 +1837,8 @@ process_key_event (XEvent* xEvent, XGServer* context, NSEventType eventType)
_command_pressed |= command_key;
if (alt_key)
_alt_pressed |= alt_key;
if (help_key)
_help_pressed |= help_key;
}
else if (xEvent->xkey.type == KeyRelease)
{
@ -1808,6 +1848,8 @@ process_key_event (XEvent* xEvent, XGServer* context, NSEventType eventType)
_command_pressed &= ~command_key;
if (alt_key)
_alt_pressed &= ~alt_key;
if (help_key)
_help_pressed &= ~help_key;
}
}
@ -2017,6 +2059,9 @@ process_modifier_flags(unsigned int state)
if (_alt_pressed != 0)
eventModifierFlags = eventModifierFlags | NSAlternateKeyMask;
if (_help_pressed != 0)
eventModifierFlags = eventModifierFlags | NSHelpKeyMask;
// Other modifiers ignored for now.
return eventModifierFlags;

View file

@ -39,7 +39,7 @@ static XWindowBuffer **window_buffers;
static int num_window_buffers;
static int use_shape_hack = 0; /* this is an ugly hack :) */
static int use_shape_hack = 0; /* this is an ugly hack : ) */
static int did_test_xshm = 0;
@ -47,7 +47,7 @@ static int use_xshm = 1;
static int num_xshm_test_errors = 0;
static NSString *xshm_warning
= @"Falling back to normal XImage:s (will be slower).";
= @"Falling back to normal XImage: s (will be slower).";
static int test_xshm_error_handler(Display *d, XErrorEvent *ev)
{
@ -153,7 +153,7 @@ static void test_xshm(Display *display, int drawing_depth)
if (num_xshm_test_errors)
{
NSLog(@"XShm not supported.");
no_xshm:
no_xshm:
NSLog(xshm_warning);
use_xshm = 0;
}
@ -272,7 +272,7 @@ no_xshm:
if (!use_xshm)
goto no_xshm;
/* Use XShm if possible, else fall back to normal XImage:s */
/* Use XShm if possible, else fall back to normal XImage: s */
wi->use_shm = 1;
wi->ximage = XShmCreateImage(wi->display,
DefaultVisual(wi->display, DefaultScreen(wi->display)),
@ -347,7 +347,7 @@ no_xshm:
if (!wi->ximage)
{
no_xshm:
no_xshm:
wi->use_shm = 0;
wi->ximage = XCreateImage(wi->display, DefaultVisual(wi->display,
DefaultScreen(wi->display)), aDI->drawing_depth, ZPixmap, 0, NULL,
@ -388,7 +388,7 @@ no_xshm:
extern int XShmGetEventBase(Display *d);
-(void) _gotShmCompletion
- (void) _gotShmCompletion
{
if (!use_shm)
return;
@ -425,7 +425,7 @@ extern int XShmGetEventBase(Display *d);
// XFlush(window->display);
}
-(void) _exposeRect: (NSRect)rect
- (void) _exposeRect: (NSRect)rect
{
/* TODO: Somehow, we can get negative coordinates in the rectangle. So far
I've tracked them back to [NSWindow flushWindow]. Should probably figure
@ -439,7 +439,7 @@ rects in the new size before we are updated.
For now, we just intersect with our known size to avoid problems with X.
And, to avoid problems with clever optimizations and float vs. double
accuracy, we do the test using int:s.
accuracy, we do the test using int: s.
*/
int x, y, w, h;
@ -458,13 +458,13 @@ accuracy, we do the test using int:s.
h += y;
y = 0;
}
if (x + w > window->xframe.size.width)
if (x + w > sx)
{
w = window->xframe.size.width - x;
w = sx - x;
}
if (y + h > window->xframe.size.height)
if (y + h > sy)
{
h = window->xframe.size.height - y;
h = sy - y;
}
if (w <= 0 || h <= 0)
@ -614,7 +614,7 @@ static int warn = 0;
}
}
-(void) needsAlpha
- (void) needsAlpha
{
if (has_alpha)
return;
@ -650,7 +650,7 @@ static int warn = 0;
memset(alpha, 0xff, sx * sy);
}
-(void) dealloc
- (void) dealloc
{
int i;
@ -686,14 +686,14 @@ static int warn = 0;
}
+(void) initialize
+ (void) initialize
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
use_shape_hack = [ud boolForKey: @"XWindowBuffer-shape-hack"];
}
+(void) _gotShmCompletion: (Drawable)d
+ (void) _gotShmCompletion: (Drawable)d
{
int i;
for (i = 0; i < num_window_buffers; i++)