mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-23 20:01:22 +00:00
Send an event directly to the window on focus in, instead of handling
this here ourselves. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@29240 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1c46dd6417
commit
938a6dd65a
2 changed files with 39 additions and 36 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2010-01-08 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/win32/w32_text_focus.m: Small clean up in focus handling.
|
||||||
|
|
||||||
2009-12-19 Eric Wasylishen <ewasylishen@gmail.com>
|
2009-12-19 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
* Source/cairo/CairoGState.m:
|
* Source/cairo/CairoGState.m:
|
||||||
|
|
|
@ -34,34 +34,13 @@
|
||||||
|
|
||||||
@implementation WIN32Server (w32_text_focus)
|
@implementation WIN32Server (w32_text_focus)
|
||||||
|
|
||||||
//- (LRESULT) decodeWM_SETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
||||||
//{
|
|
||||||
//printf("WM_SETTEXT\n");
|
|
||||||
//printf("Window text is: %s\n", (LPSTR)lParam);
|
|
||||||
|
|
||||||
//BOOL result=SetWindowText(hwnd, (LPSTR)lParam);
|
|
||||||
|
|
||||||
// if (result==0)
|
|
||||||
//printf("error on setWindow text %ld\n", GetLastError());
|
|
||||||
|
|
||||||
//return 0;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
- (LRESULT) decodeWM_SETFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
- (LRESULT) decodeWM_SETFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||||
{
|
{
|
||||||
/* This message comes when the window already got focus, so we send a focus
|
/* This message comes when the window already got focus, so we send a focus
|
||||||
in event to the front end, but also mark the window as having current focus
|
in event to the front end, but also mark the window as having current focus
|
||||||
so that the front end doesn't try to focus the window again. */
|
so that the front end doesn't try to focus the window again. */
|
||||||
|
|
||||||
int key_num, win_num;
|
|
||||||
NSPoint eventLocation;
|
|
||||||
|
|
||||||
key_num = [[NSApp keyWindow] windowNumber];
|
|
||||||
win_num = (int)hwnd;
|
|
||||||
|
|
||||||
currentFocus = hwnd;
|
currentFocus = hwnd;
|
||||||
eventLocation = NSMakePoint(0, 0);
|
|
||||||
if (currentFocus == desiredFocus)
|
if (currentFocus == desiredFocus)
|
||||||
{
|
{
|
||||||
/* This was from a request from the front end. Mark as done. */
|
/* This was from a request from the front end. Mark as done. */
|
||||||
|
@ -72,14 +51,20 @@
|
||||||
/* We need to do this directly and not send an event to the frontend -
|
/* We need to do this directly and not send an event to the frontend -
|
||||||
that's too slow and allows the window state to get out of sync,
|
that's too slow and allows the window state to get out of sync,
|
||||||
causing bad recursion problems */
|
causing bad recursion problems */
|
||||||
NSWindow *window = GSWindowWithNumber((int)hwnd);
|
NSEvent *ev;
|
||||||
if ([window canBecomeKeyWindow] == YES)
|
|
||||||
{
|
ev = [NSEvent otherEventWithType: NSAppKitDefined
|
||||||
NSDebugLLog(@"Focus", @"Making %d key", win_num);
|
location: NSMakePoint(0, 0)
|
||||||
[window makeKeyWindow];
|
modifierFlags: 0
|
||||||
[window makeMainWindow];
|
timestamp: 0
|
||||||
[NSApp activateIgnoringOtherApps: YES];
|
windowNumber: (int)hwnd
|
||||||
}
|
context: GSCurrentContext()
|
||||||
|
subtype: GSAppKitWindowFocusIn
|
||||||
|
data1: 0
|
||||||
|
data2: 0];
|
||||||
|
|
||||||
|
NSDebugLLog(@"Focus", @"Making %d key", (int)hwnd);
|
||||||
|
[EVENT_WINDOW(hwnd) sendEvent: ev];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -87,12 +72,13 @@
|
||||||
|
|
||||||
- (void) decodeWM_KILLFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
- (void) decodeWM_KILLFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||||
{
|
{
|
||||||
// reused from original author (added debug output)
|
NSEvent *ev;
|
||||||
NSPoint eventLocation = NSMakePoint(0, 0);
|
|
||||||
NSEvent * ev=nil;
|
|
||||||
|
|
||||||
ev = [NSEvent otherEventWithType:NSAppKitDefined
|
// Remember the now focused window
|
||||||
location: eventLocation
|
currentFocus = wParam;
|
||||||
|
|
||||||
|
ev = [NSEvent otherEventWithType: NSAppKitDefined
|
||||||
|
location: NSMakePoint(0, 0)
|
||||||
modifierFlags: 0
|
modifierFlags: 0
|
||||||
timestamp: 0
|
timestamp: 0
|
||||||
windowNumber: (int)hwnd
|
windowNumber: (int)hwnd
|
||||||
|
@ -101,8 +87,8 @@
|
||||||
data1: 0
|
data1: 0
|
||||||
data2: 0];
|
data2: 0];
|
||||||
|
|
||||||
[EVENT_WINDOW(hwnd) sendEvent:ev];
|
[EVENT_WINDOW(hwnd) sendEvent: ev];
|
||||||
flags._eventHandled=YES;
|
flags._eventHandled = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) decodeWM_GETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
- (void) decodeWM_GETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||||
|
@ -110,4 +96,17 @@
|
||||||
// stub for future dev
|
// stub for future dev
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
- (LRESULT) decodeWM_SETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||||
|
{
|
||||||
|
printf("WM_SETTEXT\n");
|
||||||
|
printf("Window text is: %s\n", (LPSTR)lParam);
|
||||||
|
|
||||||
|
if (SetWindowText(hwnd, (LPSTR)lParam) == 0)
|
||||||
|
printf("error on setWindow text %ld\n", GetLastError());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in a new issue