2002-04-21 22:51:21 +00:00
|
|
|
|
/* WIN32Server - Implements window handling for MSWindows
|
|
|
|
|
|
2005-09-14 15:48:11 +00:00
|
|
|
|
Copyright (C) 2002,2005 Free Software Foundation, Inc.
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
|
|
|
|
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
|
|
|
|
Date: March 2002
|
2005-10-30 07:35:52 +00:00
|
|
|
|
Part of this code have been re-written by:
|
2005-09-14 15:48:11 +00:00
|
|
|
|
Tom MacSween <macsweent@sympatico.ca>
|
|
|
|
|
Date August 2005
|
2002-04-21 22:51:21 +00:00
|
|
|
|
This file is part of the GNU Objective C User Interface Library.
|
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
|
License along with this library; if not, write to the Free
|
2006-09-12 19:53:46 +00:00
|
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02111 USA.
|
2002-04-21 22:51:21 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <Foundation/NSDebug.h>
|
|
|
|
|
#include <Foundation/NSString.h>
|
|
|
|
|
#include <Foundation/NSArray.h>
|
|
|
|
|
#include <Foundation/NSValue.h>
|
|
|
|
|
#include <Foundation/NSConnection.h>
|
|
|
|
|
#include <Foundation/NSRunLoop.h>
|
|
|
|
|
#include <Foundation/NSTimer.h>
|
2003-12-27 01:06:19 +00:00
|
|
|
|
#include <Foundation/NSUserDefaults.h>
|
2005-03-29 14:03:30 +00:00
|
|
|
|
#include <Foundation/NSException.h>
|
2002-04-21 22:51:21 +00:00
|
|
|
|
#include <AppKit/AppKitExceptions.h>
|
|
|
|
|
#include <AppKit/NSApplication.h>
|
|
|
|
|
#include <AppKit/NSGraphics.h>
|
2003-12-27 01:06:19 +00:00
|
|
|
|
#include <AppKit/NSMenu.h>
|
2002-04-21 22:51:21 +00:00
|
|
|
|
#include <AppKit/NSWindow.h>
|
|
|
|
|
#include <AppKit/NSView.h>
|
|
|
|
|
#include <AppKit/NSEvent.h>
|
|
|
|
|
#include <AppKit/NSCursor.h>
|
|
|
|
|
#include <AppKit/NSText.h>
|
2005-10-21 03:07:19 +00:00
|
|
|
|
#include <AppKit/NSTextField.h>
|
2002-04-21 22:51:21 +00:00
|
|
|
|
#include <AppKit/DPSOperators.h>
|
|
|
|
|
|
|
|
|
|
#include "win32/WIN32Server.h"
|
|
|
|
|
#include "win32/WIN32Geometry.h"
|
2005-09-14 15:48:11 +00:00
|
|
|
|
#include "w32_config.h"
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
2004-09-19 09:23:24 +00:00
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
|
#include <sys/file.h>
|
|
|
|
|
#endif
|
2005-10-30 07:35:52 +00:00
|
|
|
|
static NSString * Version =@"(C) 2005 FSF gnustep-back 0.10.1";
|
2005-09-14 15:48:11 +00:00
|
|
|
|
// custom event notifications
|
|
|
|
|
static NSString *NSMenuWillTearOff = @"MenuWillTearOff";
|
|
|
|
|
static NSString *NSMenuwillPopUP =@"MenuwillPopUP";
|
2005-10-30 07:35:52 +00:00
|
|
|
|
static NSString *NSWindowDidCreateWindow =@"WindowDidCreateWindow";
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2006-09-12 19:53:46 +00:00
|
|
|
|
static NSEvent *process_key_event(WIN32Server *svr,
|
|
|
|
|
HWND hwnd, WPARAM wParam, LPARAM lParam, NSEventType eventType);
|
|
|
|
|
static NSEvent *process_mouse_event(WIN32Server *svr,
|
|
|
|
|
HWND hwnd, WPARAM wParam, LPARAM lParam, NSEventType eventType);
|
2005-03-29 14:03:30 +00:00
|
|
|
|
|
2005-09-14 15:48:11 +00:00
|
|
|
|
//static BOOL HAVE_MAIN_MENU = NO;
|
2005-03-29 14:03:30 +00:00
|
|
|
|
static BOOL handlesWindowDecorations = NO;
|
|
|
|
|
|
2002-04-21 22:51:21 +00:00
|
|
|
|
static void
|
2006-09-12 19:53:46 +00:00
|
|
|
|
validateWindow(WIN32Server *svr, HWND hwnd, RECT rect);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
|
|
|
|
WPARAM wParam, LPARAM lParam);
|
|
|
|
|
|
|
|
|
|
@implementation WIN32Server
|
|
|
|
|
|
2005-09-14 15:48:11 +00:00
|
|
|
|
// server opts
|
|
|
|
|
|
|
|
|
|
- (void) callback: (id) sender
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
MSG msg;
|
|
|
|
|
WINBOOL bRet;
|
|
|
|
|
|
|
|
|
|
while ((bRet = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) != 0)
|
|
|
|
|
{
|
|
|
|
|
if (msg.message == WM_QUIT)
|
|
|
|
|
{
|
|
|
|
|
// Exit the program
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (bRet == -1)
|
|
|
|
|
{
|
|
|
|
|
// handle the error and possibly exit
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Don't translate messages, as this would give extra character messages.
|
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) hasEvent
|
|
|
|
|
{
|
|
|
|
|
return (GetQueueStatus(QS_ALLEVENTS) != 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) receivedEvent: (void*)data
|
|
|
|
|
type: (RunLoopEventType)type
|
|
|
|
|
extra: (void*)extra
|
|
|
|
|
forMode: (NSString*)mode
|
|
|
|
|
{
|
2005-10-30 12:54:09 +00:00
|
|
|
|
if (type == ET_WINMSG)
|
|
|
|
|
{
|
|
|
|
|
MSG *m = (MSG*)extra;
|
|
|
|
|
|
|
|
|
|
if (m->message == WM_QUIT)
|
|
|
|
|
{
|
2006-01-09 08:15:57 +00:00
|
|
|
|
[NSApp terminate: nil];
|
2005-10-30 12:54:09 +00:00
|
|
|
|
// Exit the program
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DispatchMessage(m);
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-10-30 07:35:52 +00:00
|
|
|
|
if (mode != nil)
|
2005-09-14 15:48:11 +00:00
|
|
|
|
[self callback: mode];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (NSEvent*) getEventMatchingMask: (unsigned)mask
|
|
|
|
|
beforeDate: (NSDate*)limit
|
|
|
|
|
inMode: (NSString*)mode
|
|
|
|
|
dequeue: (BOOL)flag
|
|
|
|
|
{
|
|
|
|
|
[self callback: nil];
|
|
|
|
|
#ifdef __W32_debug_Event_loop
|
2005-10-30 07:35:52 +00:00
|
|
|
|
NSEvent * theEvent = [super getEventMatchingMask: mask
|
2005-09-14 15:48:11 +00:00
|
|
|
|
beforeDate: limit
|
|
|
|
|
inMode: mode
|
|
|
|
|
dequeue: flag];
|
|
|
|
|
|
|
|
|
|
printf("Got EventType %d\n",[theEvent type]);
|
|
|
|
|
return theEvent;
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
return [super getEventMatchingMask: mask
|
|
|
|
|
beforeDate: limit
|
|
|
|
|
inMode: mode
|
|
|
|
|
dequeue: flag];
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) discardEventsMatchingMask: (unsigned)mask
|
|
|
|
|
beforeEvent: (NSEvent*)limit
|
|
|
|
|
{
|
|
|
|
|
[self callback: nil];
|
|
|
|
|
[super discardEventsMatchingMask: mask
|
|
|
|
|
beforeEvent: limit];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// server
|
|
|
|
|
|
2002-04-21 22:51:21 +00:00
|
|
|
|
/* Initialize AppKit backend */
|
|
|
|
|
+ (void)initializeBackend
|
|
|
|
|
{
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
#ifdef __debugServer__
|
|
|
|
|
printf("\n\n##############################################################\n");
|
|
|
|
|
printf("############## + (void)initializeBackend ##########################\n");
|
|
|
|
|
printf("\n\n##############################################################\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-03-29 14:03:30 +00:00
|
|
|
|
NSUserDefaults *defs;
|
|
|
|
|
|
2002-04-21 22:51:21 +00:00
|
|
|
|
NSDebugLog(@"Initializing GNUstep win32 backend.\n");
|
2005-03-29 14:03:30 +00:00
|
|
|
|
defs = [NSUserDefaults standardUserDefaults];
|
2006-09-28 13:09:57 +00:00
|
|
|
|
if ([defs objectForKey: @"GSBackHandlesWindowDecorations"])
|
2005-03-29 14:03:30 +00:00
|
|
|
|
{
|
|
|
|
|
handlesWindowDecorations =
|
2006-09-28 13:09:57 +00:00
|
|
|
|
[defs boolForKey: @"GSBackHandlesWindowDecorations"];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ([defs objectForKey: @"GSWIN32HandlesWindowDecorations"])
|
|
|
|
|
{
|
|
|
|
|
handlesWindowDecorations =
|
|
|
|
|
[defs boolForKey: @"GSWINHandlesWindowDecorations"];
|
|
|
|
|
}
|
2005-03-29 14:03:30 +00:00
|
|
|
|
}
|
2002-04-21 22:51:21 +00:00
|
|
|
|
[GSDisplayServer setDefaultServerClass: [WIN32Server class]];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
//Flag to handle main menu window type -- parent of other menu windows
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) _initWin32Context
|
|
|
|
|
{
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
#ifdef __debugServer__
|
|
|
|
|
printf("\n\n##############################################################\n");
|
|
|
|
|
printf("############## - (void) _initWin32Context ##########################\n");
|
|
|
|
|
printf("\n\n##############################################################\n");
|
|
|
|
|
#endif
|
2002-04-21 22:51:21 +00:00
|
|
|
|
WNDCLASSEX wc;
|
|
|
|
|
hinstance = (HINSTANCE)GetModuleHandle(NULL);
|
|
|
|
|
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2002-04-21 22:51:21 +00:00
|
|
|
|
// Register the main window class.
|
|
|
|
|
wc.cbSize = sizeof(wc);
|
|
|
|
|
//wc.style = CS_OWNDC; // | CS_HREDRAW | CS_VREDRAW;
|
|
|
|
|
wc.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
|
wc.lpfnWndProc = (WNDPROC) MainWndProc;
|
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
|
// Keep extra space for each window, for GS data
|
|
|
|
|
wc.cbWndExtra = sizeof(WIN_INTERN);
|
|
|
|
|
wc.hInstance = hinstance;
|
2005-10-21 03:07:19 +00:00
|
|
|
|
wc.hIcon = NULL;//currentAppIcon;
|
2003-12-24 23:21:59 +00:00
|
|
|
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
wc.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
|
wc.lpszMenuName = NULL;
|
|
|
|
|
wc.lpszClassName = "GNUstepWindowClass";
|
2005-10-21 03:07:19 +00:00
|
|
|
|
wc.hIconSm = NULL;//currentAppIcon;
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
|
|
|
|
if (!RegisterClassEx(&wc))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// FIXME We should use GetSysColor to get standard colours from MS Window and
|
|
|
|
|
// use them in NSColor
|
|
|
|
|
|
|
|
|
|
// Should we create a message only window here, so we can get events, even when
|
|
|
|
|
// no windows are created?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setupRunLoopInputSourcesForMode: (NSString*)mode
|
|
|
|
|
{
|
2005-10-30 12:54:09 +00:00
|
|
|
|
NSRunLoop *currentRunLoop = [NSRunLoop currentRunLoop];
|
|
|
|
|
|
2005-09-14 15:48:11 +00:00
|
|
|
|
#ifdef __debugServer__
|
|
|
|
|
printf("\n\n##############################################################\n");
|
|
|
|
|
printf("##- (void) setupRunLoopInputSourcesForMode: (NSString*)mode #######\n");
|
|
|
|
|
printf("\n\n##############################################################\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-08-24 18:53:39 +00:00
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
|
int fdMessageQueue;
|
|
|
|
|
#define WIN_MSG_QUEUE_FNAME "/dev/windows"
|
|
|
|
|
|
|
|
|
|
// Open a file descriptor for the windows message queue
|
|
|
|
|
fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, O_RDONLY);
|
|
|
|
|
if (fdMessageQueue == -1)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Failed opening %s\n", WIN_MSG_QUEUE_FNAME);
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
[currentRunLoop addEvent: (void*)fdMessageQueue
|
|
|
|
|
type: ET_RDESC
|
|
|
|
|
watcher: (id<RunLoopEvents>)self
|
|
|
|
|
forMode: mode];
|
|
|
|
|
#else
|
2005-04-01 15:44:24 +00:00
|
|
|
|
#if 0
|
2002-04-21 22:51:21 +00:00
|
|
|
|
NSTimer *timer;
|
|
|
|
|
|
2004-02-28 14:21:38 +00:00
|
|
|
|
timer = [NSTimer timerWithTimeInterval: 0.01
|
2002-04-21 22:51:21 +00:00
|
|
|
|
target: self
|
|
|
|
|
selector: @selector(callback:)
|
|
|
|
|
userInfo: nil
|
|
|
|
|
repeats: YES];
|
2005-10-30 12:54:09 +00:00
|
|
|
|
[currentRunLoop addTimer: timer forMode: mode];
|
2005-04-01 15:44:24 +00:00
|
|
|
|
#else
|
2005-10-30 12:54:09 +00:00
|
|
|
|
|
|
|
|
|
/* OBSOLETE
|
|
|
|
|
[currentRunLoop addMsgTarget: self
|
|
|
|
|
withMethod: @selector(callback:)
|
|
|
|
|
forMode: mode];
|
|
|
|
|
*/
|
|
|
|
|
[currentRunLoop addEvent: (void*)0
|
|
|
|
|
type: ET_WINMSG
|
|
|
|
|
watcher: (id<RunLoopEvents>)self
|
|
|
|
|
forMode: mode];
|
2005-04-01 15:44:24 +00:00
|
|
|
|
#endif
|
2004-08-24 18:53:39 +00:00
|
|
|
|
#endif
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
- (id) initWithAttributes: (NSDictionary *)info
|
|
|
|
|
{
|
2005-09-14 15:48:11 +00:00
|
|
|
|
#ifdef __debugServer__
|
|
|
|
|
printf("\n\n##############################################################\n");
|
|
|
|
|
printf("##initWithAttributes: (NSDictionary *)info #######\n");
|
|
|
|
|
printf("\n\n##############################################################\n");
|
|
|
|
|
#endif
|
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
|
2002-04-21 22:51:21 +00:00
|
|
|
|
[self _initWin32Context];
|
|
|
|
|
[super initWithAttributes: info];
|
|
|
|
|
|
|
|
|
|
[self setupRunLoopInputSourcesForMode: NSDefaultRunLoopMode];
|
|
|
|
|
[self setupRunLoopInputSourcesForMode: NSConnectionReplyMode];
|
|
|
|
|
[self setupRunLoopInputSourcesForMode: NSModalPanelRunLoopMode];
|
|
|
|
|
[self setupRunLoopInputSourcesForMode: NSEventTrackingRunLoopMode];
|
2003-12-27 01:06:19 +00:00
|
|
|
|
|
2005-10-21 03:07:19 +00:00
|
|
|
|
//flags.useWMTaskBar = YES;
|
|
|
|
|
//flags.useWMStyles = YES;
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
if ([[NSUserDefaults standardUserDefaults] stringForKey: @"GSUseWMTaskbar"]
|
|
|
|
|
!= nil)
|
2005-10-21 03:07:19 +00:00
|
|
|
|
{
|
|
|
|
|
flags.useWMTaskBar = [[NSUserDefaults standardUserDefaults]
|
2005-10-30 07:35:52 +00:00
|
|
|
|
boolForKey: @"GSUseWMTaskbar"];
|
|
|
|
|
flags.HAVE_SERVER_PREFS = YES;
|
2005-10-21 03:07:19 +00:00
|
|
|
|
}
|
2005-10-30 07:35:52 +00:00
|
|
|
|
else
|
2003-12-27 01:06:19 +00:00
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
flags.HAVE_SERVER_PREFS = NO;
|
2003-12-27 01:06:19 +00:00
|
|
|
|
}
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
if ([[NSUserDefaults standardUserDefaults] stringForKey: @"GSUseWMStyles"]
|
|
|
|
|
!= nil)
|
2005-10-21 03:07:19 +00:00
|
|
|
|
{
|
|
|
|
|
flags.useWMStyles = [[NSUserDefaults standardUserDefaults]
|
2005-10-30 07:35:52 +00:00
|
|
|
|
boolForKey: @"GSUseWMStyles"];
|
|
|
|
|
flags.HAVE_SERVER_PREFS = YES;
|
2005-10-21 03:07:19 +00:00
|
|
|
|
}
|
2005-10-30 07:35:52 +00:00
|
|
|
|
else
|
2005-10-21 03:07:19 +00:00
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
flags.HAVE_SERVER_PREFS = NO;
|
2005-10-21 03:07:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
if (flags.useWMStyles == YES)
|
|
|
|
|
{
|
|
|
|
|
handlesWindowDecorations = YES;
|
|
|
|
|
}
|
2005-10-21 03:07:19 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
/* the backend needs to be able to keep tabs on events that
|
|
|
|
|
* are only produced by GNUstep so that it can make changes
|
|
|
|
|
* or override behavior in favor of the real platform window server
|
|
|
|
|
*/
|
2005-09-14 15:48:11 +00:00
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(ApplicationDidFinishLaunching:)
|
|
|
|
|
name: NSApplicationDidFinishLaunchingNotification
|
|
|
|
|
object: nil];
|
|
|
|
|
|
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(ApplicationWillFinishLaunching:)
|
|
|
|
|
name: NSApplicationWillFinishLaunchingNotification
|
|
|
|
|
object: nil];
|
|
|
|
|
|
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(ApplicationWillHideNotification:)
|
|
|
|
|
name: NSApplicationWillHideNotification
|
|
|
|
|
object: nil];
|
|
|
|
|
|
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(WindowWillMiniaturizeNotification:)
|
|
|
|
|
name: NSWindowWillMiniaturizeNotification
|
|
|
|
|
object: nil];
|
|
|
|
|
|
|
|
|
|
// register for custom notifications
|
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(MenuWillTearOff:)
|
|
|
|
|
name: NSMenuWillTearOff
|
|
|
|
|
object: nil];
|
|
|
|
|
|
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(MenuwillPopUP:)
|
|
|
|
|
name: NSMenuwillPopUP
|
|
|
|
|
object: nil];
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[nc addObserver: self
|
2005-10-21 03:07:19 +00:00
|
|
|
|
selector: @selector(WindowDidCreateWindow:)
|
|
|
|
|
name: NSWindowDidCreateWindow
|
|
|
|
|
object: nil];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
#ifdef __APPNOTIFICATIONS__
|
|
|
|
|
[self registerForWindowEvents];
|
|
|
|
|
[self registerForViewEvents];
|
|
|
|
|
#endif
|
2005-10-30 07:35:52 +00:00
|
|
|
|
flags.eventQueCount =0;
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2002-04-21 22:51:21 +00:00
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-14 15:48:11 +00:00
|
|
|
|
// required Notification hooks back to the application
|
|
|
|
|
|
|
|
|
|
- (void) ApplicationDidFinishLaunching: (NSNotification*)aNotification
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) ApplicationWillFinishLaunching: (NSNotification*)aNotification
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) ApplicationWillHideNotification: (NSNotification*)aNotification
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(void) WindowWillMiniaturizeNotification: (NSNotification*)aNotification
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(void) MenuWillTearOff: (NSNotification*)aNotification
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(void) MenuwillPopUP: (NSNotification*)aNotification
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-21 03:07:19 +00:00
|
|
|
|
// make a configure window for the backend
|
|
|
|
|
/* win32 is unique in that it can support both the win32 look and feel or
|
|
|
|
|
a openstep look and feel.
|
|
|
|
|
|
|
|
|
|
To make it easier to switch between the 2 I have added a small server inspector
|
|
|
|
|
panel that will provide access to settings without recompile.
|
|
|
|
|
|
|
|
|
|
If main debug feature is on then I can also add access to some of the switches
|
|
|
|
|
to control debug output... or log specific event to a log panel.
|
|
|
|
|
*/
|
|
|
|
|
- (void) initConfigWindow
|
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
unsigned int style = NSTitledWindowMask | NSClosableWindowMask;
|
|
|
|
|
NSRect rect;
|
|
|
|
|
NSView *content;
|
|
|
|
|
NSTextField *theText;
|
|
|
|
|
NSTextField *theText2;
|
2005-10-21 03:07:19 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
rect = NSMakeRect (715,800,236,182);
|
|
|
|
|
configWindow = RETAIN([[NSWindow alloc] initWithContentRect: rect
|
2005-10-21 03:07:19 +00:00
|
|
|
|
styleMask: style
|
|
|
|
|
backing: NSBackingStoreBuffered
|
|
|
|
|
defer: YES]);
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[configWindow setTitle: @"server Preferences"];
|
|
|
|
|
[configWindow setReleasedWhenClosed: NO];
|
|
|
|
|
|
|
|
|
|
content = [configWindow contentView];
|
|
|
|
|
theText = [[NSTextField alloc] initWithFrame: NSMakeRect (27,155,190,22)];
|
|
|
|
|
[theText setStringValue: @"Win32 GNUStep Display Server"];
|
|
|
|
|
[theText setEditable: NO];
|
|
|
|
|
[theText setEnabled: NO];
|
|
|
|
|
[theText setSelectable: NO];
|
|
|
|
|
[[theText cell] setBackgroundColor: [NSColor lightGrayColor]];
|
|
|
|
|
[[theText cell] setBordered: NO];
|
|
|
|
|
[[theText cell] setBezeled: NO];
|
|
|
|
|
[content addSubview: theText];
|
2005-10-21 03:07:19 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
/*
|
|
|
|
|
NSTextField *theText1;
|
|
|
|
|
|
|
|
|
|
theText1 = [[NSTextField alloc] initWithFrame: NSMakeRect (27,135,190,22)];
|
|
|
|
|
[theText1 setStringValue: @"Revitalized By Tom MacSween"];
|
|
|
|
|
[theText1 setEditable: NO];
|
|
|
|
|
[theText1 setEnabled: NO];
|
|
|
|
|
[theText1 setSelectable: NO];
|
|
|
|
|
[[theText1 cell] setBackgroundColor: [NSColor lightGrayColor]];
|
|
|
|
|
[[theText1 cell] setBordered: NO];
|
|
|
|
|
[[theText1 cell] setBezeled: NO];
|
|
|
|
|
[content addSubview: theText1];*/
|
2005-10-21 03:07:19 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
theText2 = [[NSTextField alloc] initWithFrame: NSMakeRect (17,115,200,22)];
|
|
|
|
|
[theText2 setStringValue: Version];
|
|
|
|
|
[theText2 setEditable: NO];
|
|
|
|
|
[theText2 setEnabled: NO];
|
|
|
|
|
[theText2 setSelectable: NO];
|
|
|
|
|
[[theText2 cell] setBackgroundColor: [NSColor lightGrayColor]];
|
|
|
|
|
[[theText2 cell] setBordered: NO];
|
|
|
|
|
[[theText2 cell] setBezeled: NO];
|
|
|
|
|
[content addSubview: theText2];
|
2005-10-21 03:07:19 +00:00
|
|
|
|
|
|
|
|
|
// popup for style
|
2005-10-30 07:35:52 +00:00
|
|
|
|
styleButton
|
|
|
|
|
= [[NSPopUpButton alloc] initWithFrame: NSMakeRect (30,80,171,22)];
|
|
|
|
|
[styleButton setAutoenablesItems: YES];
|
|
|
|
|
[styleButton setTarget: self];
|
|
|
|
|
[styleButton setAction: @selector(setStyle:)];
|
|
|
|
|
[styleButton setTitle: @"Select window Style"];
|
|
|
|
|
[styleButton addItemWithTitle: @"GNUStep window Style"];
|
|
|
|
|
[styleButton addItemWithTitle: @"MicroSoft window Style"];
|
|
|
|
|
[content addSubview: styleButton];
|
2005-10-21 03:07:19 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
// set the tags on the items
|
|
|
|
|
[[styleButton itemAtIndex: 0] setTag: 0];
|
|
|
|
|
[[styleButton itemAtIndex: 1] setTag: 1];
|
|
|
|
|
[[styleButton itemAtIndex: 2] setTag: 2];
|
2005-10-21 03:07:19 +00:00
|
|
|
|
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
// check box for using taskbar
|
|
|
|
|
taskbarButton = [[NSButton alloc] initWithFrame: NSMakeRect (30,55,171,22)];
|
|
|
|
|
[taskbarButton setButtonType: NSSwitchButton];
|
|
|
|
|
[taskbarButton setTitle: @"Use Win Taskbar"];
|
|
|
|
|
[taskbarButton setTarget: self];
|
|
|
|
|
[taskbarButton setAction: @selector(setTaskBar:)];
|
|
|
|
|
[content addSubview: taskbarButton];
|
|
|
|
|
// save to defaults
|
|
|
|
|
saveButton = [[NSButton alloc] initWithFrame: NSMakeRect (30,25,171,22)];
|
|
|
|
|
[saveButton setButtonType: NSMomentaryPushInButton];
|
|
|
|
|
[saveButton setTitle: @"Save to defaults"];
|
|
|
|
|
[saveButton setTarget: self];
|
|
|
|
|
[saveButton setAction: @selector(setSave:)];
|
|
|
|
|
[content addSubview: saveButton];
|
|
|
|
|
[saveButton setEnabled: NO];
|
2005-10-21 03:07:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// set the buttons to match the current state
|
2005-10-30 07:35:52 +00:00
|
|
|
|
if (flags.useWMStyles == YES)
|
|
|
|
|
[styleButton selectItemAtIndex: 2];
|
|
|
|
|
else
|
|
|
|
|
[styleButton selectItemAtIndex: 1];
|
2005-10-21 03:07:19 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
if (flags.useWMTaskBar == YES)
|
|
|
|
|
[taskbarButton setState: NSOnState];
|
|
|
|
|
else
|
|
|
|
|
[taskbarButton setState: NSOffState];
|
2005-10-21 03:07:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// config window actions
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
- (void) setStyle: (id)sender
|
2005-10-21 03:07:19 +00:00
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
//defaults key: GSUseWMStyles
|
|
|
|
|
// code flag: flags.useWMStyles
|
|
|
|
|
[saveButton setEnabled: YES];
|
2005-10-21 03:07:19 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
if ([[sender selectedItem] tag] > 1)
|
2005-10-21 03:07:19 +00:00
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
flags.useWMStyles = YES;
|
|
|
|
|
flags.useWMTaskBar = YES;
|
|
|
|
|
[taskbarButton setState: NSOnState];
|
2005-10-21 03:07:19 +00:00
|
|
|
|
}
|
2005-10-30 07:35:52 +00:00
|
|
|
|
else
|
2005-10-21 03:07:19 +00:00
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
flags.useWMStyles = NO;
|
|
|
|
|
flags.useWMTaskBar = NO;
|
|
|
|
|
[taskbarButton setState: NSOffState];
|
2005-10-21 03:07:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
- (void) setTaskBar: (id)sender
|
2005-10-21 03:07:19 +00:00
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
//defaults key: GSUseWMTaskbar
|
|
|
|
|
// code flag: flags.useWMTaskBar
|
|
|
|
|
[saveButton setEnabled: YES];
|
|
|
|
|
flags.useWMTaskBar = [sender state];
|
2005-10-21 03:07:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
- (void) setSave: (id)sender
|
2005-10-21 03:07:19 +00:00
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
NSString *theValue = @"NO";
|
2005-10-21 03:07:19 +00:00
|
|
|
|
//NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
|
|
|
|
//printf("Save to defaults\n");
|
2005-10-30 07:35:52 +00:00
|
|
|
|
if (flags.useWMTaskBar == YES)
|
|
|
|
|
theValue = @"YES";
|
2005-10-21 03:07:19 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[[NSUserDefaults standardUserDefaults]
|
|
|
|
|
setObject: theValue forKey: @"GSUseWMTaskbar"];
|
2005-10-21 03:07:19 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
theValue = @"NO";
|
|
|
|
|
if (flags.useWMStyles == YES)
|
|
|
|
|
theValue = @"YES";
|
2005-10-21 03:07:19 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[[NSUserDefaults standardUserDefaults]
|
|
|
|
|
setObject: theValue forKey: @"GSUseWMStyles"];
|
2005-10-21 03:07:19 +00:00
|
|
|
|
|
|
|
|
|
// user must restart application for changes
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
NSRunInformationalAlertPanel(@"Server Preferences Changed",
|
2005-10-21 03:07:19 +00:00
|
|
|
|
@"Changes will take affect on the next restart",
|
|
|
|
|
@"OK",nil, nil);
|
2005-10-30 07:35:52 +00:00
|
|
|
|
flags.HAVE_SERVER_PREFS = YES;
|
|
|
|
|
[configWindow close];
|
|
|
|
|
[saveButton setEnabled: NO];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
2005-10-21 03:07:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
- (void) showServerPrefs: (id)sender
|
2005-10-21 03:07:19 +00:00
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[configWindow makeKeyAndOrderFront: self];
|
2005-10-21 03:07:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-09-14 15:48:11 +00:00
|
|
|
|
/*
|
2005-10-30 07:35:52 +00:00
|
|
|
|
|
|
|
|
|
when debug is active (#define __W32_debug__) the following
|
|
|
|
|
additional notifications are registered for in the backend server.
|
|
|
|
|
Helps to show where appevents and server
|
|
|
|
|
events are happening relitive to each other
|
2005-10-21 03:07:19 +00:00
|
|
|
|
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
NSWindowDidBecomeKeyNotification
|
|
|
|
|
Posted whenever an NSWindow becomes the key window.
|
2005-10-30 07:35:52 +00:00
|
|
|
|
The notification object is the NSWindow that has become key.
|
|
|
|
|
This notification does not contain a userInfo dictionary.
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
NSWindowDidBecomeMainNotification
|
|
|
|
|
Posted whenever an NSWindow becomes the main window.
|
2005-10-30 07:35:52 +00:00
|
|
|
|
The notification object is the NSWindow that has become main.
|
|
|
|
|
This notification does not contain a userInfo dictionary.
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
NSWindowDidChangeScreenNotification
|
2005-10-30 07:35:52 +00:00
|
|
|
|
Posted whenever a portion of an NSWindow<EFBFBD>s frame moves onto
|
|
|
|
|
or off of a screen.
|
|
|
|
|
The notification object is the NSWindow that has changed screens.
|
|
|
|
|
This notification does not contain a userInfo dictionary.
|
2005-09-14 15:48:11 +00:00
|
|
|
|
This notification is not sent in Mac OS X versions earlier than 10.4.
|
|
|
|
|
|
|
|
|
|
NSWindowDidChangeScreenProfileNotification
|
|
|
|
|
Posted whenever the display profile for the screen containing the window
|
|
|
|
|
changes.
|
|
|
|
|
This notification is sent only if the window returns YES from
|
|
|
|
|
displaysWhenScreenProfileChanges. This notification may be sent
|
|
|
|
|
when a majority of the window is moved to a different screen
|
|
|
|
|
(whose profile is also different from the previous screen) or when
|
|
|
|
|
the ColorSync profile for the current screen changes. The
|
|
|
|
|
notification object is the NSWindow whose profile changed. This
|
|
|
|
|
notification does not contain a userInfo dictionary.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSWindowDidDeminiaturizeNotification
|
|
|
|
|
Posted whenever an NSWindow is deminiaturized.
|
|
|
|
|
The notification object is the NSWindow that has been deminiaturized. This
|
|
|
|
|
notification does not contain a userInfo dictionary.
|
|
|
|
|
|
|
|
|
|
NSWindowDidEndSheetNotification
|
|
|
|
|
Posted whenever an NSWindow closes an attached sheet.
|
|
|
|
|
The notification object is the NSWindow that contained the sheet. This
|
|
|
|
|
notification does not contain a userInfo dictionary.
|
|
|
|
|
|
|
|
|
|
NSWindowDidExposeNotification
|
|
|
|
|
Posted whenever a portion of a nonretained NSWindow is exposed,
|
|
|
|
|
whether by being ordered in front of other windows or by other
|
|
|
|
|
windows being removed from in front of it. The notification
|
|
|
|
|
object is the NSWindow that has been exposed. The userInfo
|
|
|
|
|
dictionary contains the following information: Key
|
|
|
|
|
@"NSExposedRect" Value The rectangle that has been exposed
|
|
|
|
|
(NSValue containing an NSRect).
|
|
|
|
|
|
|
|
|
|
NSWindowDidMiniaturizeNotification
|
|
|
|
|
Posted whenever an NSWindow is miniaturized.
|
|
|
|
|
The notification object is the NSWindow that has been miniaturized. This
|
|
|
|
|
notification does not contain a userInfo dictionary.
|
|
|
|
|
|
|
|
|
|
NSWindowDidMoveNotification
|
|
|
|
|
Posted whenever an NSWindow is moved.
|
|
|
|
|
The notification object is the NSWindow that has moved. This
|
|
|
|
|
notification does not contain a userInfo dictionary.
|
|
|
|
|
|
|
|
|
|
NSWindowDidResignKeyNotification
|
|
|
|
|
Posted whenever an NSWindow resigns its status as key window.
|
|
|
|
|
The notification object is the NSWindow that has resigned its key window
|
|
|
|
|
status. This notification does not contain a userInfo dictionary.
|
|
|
|
|
|
|
|
|
|
NSWindowDidResignMainNotification
|
|
|
|
|
Posted whenever an NSWindow resigns its status as main window.
|
|
|
|
|
The notification object is the NSWindow that has resigned its main window
|
|
|
|
|
status. This notification does not contain a userInfo dictionary.
|
|
|
|
|
|
|
|
|
|
NSWindowDidResizeNotification
|
|
|
|
|
Posted whenever an NSWindow<EFBFBD>s size changes.
|
|
|
|
|
The notification object is the NSWindow whose size has changed. This
|
|
|
|
|
notification does not contain a userInfo dictionary.
|
|
|
|
|
|
|
|
|
|
NSWindowDidUpdateNotification
|
|
|
|
|
Posted whenever an NSWindow receives an update message.
|
|
|
|
|
The notification object is the NSWindow that received the update
|
|
|
|
|
message. This notification does not contain a userInfo dictionary.
|
|
|
|
|
|
|
|
|
|
NSWindowWillBeginSheetNotification
|
|
|
|
|
Posted whenever an NSWindow is about to open a sheet.
|
|
|
|
|
The notification object is the NSWindow that is about to open the
|
|
|
|
|
sheet. This notification does not contain a userInfo dictionary.
|
|
|
|
|
|
|
|
|
|
NSWindowWillCloseNotification
|
|
|
|
|
Posted whenever an NSWindow is about to close.
|
|
|
|
|
The notification object is the NSWindow that is about to close. This
|
|
|
|
|
notification does not contain a userInfo dictionary.
|
|
|
|
|
|
|
|
|
|
NSWindowWillMiniaturizeNotification
|
|
|
|
|
Posted whenever an NSWindow is about to be miniaturized.
|
|
|
|
|
The notification object is the NSWindow that is about to be
|
|
|
|
|
miniaturized. This notification does not contain a userInfo
|
|
|
|
|
dictionary.
|
|
|
|
|
|
|
|
|
|
NSWindowWillMoveNotification
|
|
|
|
|
Posted whenever an NSWindow is about to move.
|
|
|
|
|
The notification object is the NSWindow that is about to move. This
|
|
|
|
|
notification does not contain a userInfo dictionary.
|
|
|
|
|
*/
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
- (void) registerForWindowEvents
|
2005-09-14 15:48:11 +00:00
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowDidDeminiaturizeNotification
|
|
|
|
|
object: nil];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowDidMiniaturizeNotification
|
|
|
|
|
object: nil];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowDidBecomeKeyNotification
|
|
|
|
|
object: nil];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowDidBecomeMainNotification
|
|
|
|
|
object: nil];
|
|
|
|
|
|
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowDidChangeScreenNotification
|
|
|
|
|
object: nil];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
/*
|
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowDidChangeScreenProfileNotification
|
|
|
|
|
object: nil];
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowDidExposeNotification
|
|
|
|
|
object: nil];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
/*
|
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowDidEndSheetNotification
|
|
|
|
|
object: nil];
|
|
|
|
|
*/
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowDidMoveNotification
|
|
|
|
|
object: nil];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowDidResignKeyNotification
|
|
|
|
|
object: nil];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowDidResignMainNotification
|
|
|
|
|
object: nil];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowDidResizeNotification
|
|
|
|
|
object: nil];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowDidUpdateNotification
|
|
|
|
|
object: nil];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
/*
|
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowWillBeginSheetNotification
|
|
|
|
|
object: nil];
|
|
|
|
|
*/
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowWillCloseNotification
|
|
|
|
|
object: nil];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSWindowWillMoveNotification
|
|
|
|
|
object: nil];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
NSViewBoundsDidChangeNotification
|
|
|
|
|
Posted whenever the NSView<EFBFBD>s bounds rectangle changes
|
|
|
|
|
independently of the frame rectangle, if the NSView is configured
|
|
|
|
|
using setPostsBoundsChangedNotifications: to post such
|
|
|
|
|
notifications. The notification object is the NSView whose bounds
|
|
|
|
|
rectangle has changed. This notification does not contain a
|
|
|
|
|
userInfo dictionary. The following methods can result in
|
2005-10-30 07:35:52 +00:00
|
|
|
|
notification posting:
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
setBounds:
|
|
|
|
|
setBoundsOrigin:
|
|
|
|
|
setBoundsRotation:
|
|
|
|
|
setBoundsSize:
|
|
|
|
|
translateOriginToPoint:
|
|
|
|
|
scaleUnitSquareToSize:
|
|
|
|
|
rotateByAngle:
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
Note that the bounds rectangle resizes automatically to track the
|
|
|
|
|
frame rectangle. Because the primary change is that of the frame
|
|
|
|
|
rectangle, however, setFrame: and setFrameSize: don<EFBFBD>t result in
|
|
|
|
|
a bounds-changed notification.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSViewFocusDidChangeNotification
|
|
|
|
|
Deprecated notification that was posted for an NSView and each of
|
|
|
|
|
its descendents (recursively) whenever the frame or bounds
|
|
|
|
|
geometry of the view changed.
|
|
|
|
|
*/
|
|
|
|
|
- (void) registerForViewEvents
|
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSViewBoundsDidChangeNotification
|
|
|
|
|
object: nil];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[nc addObserver: self
|
|
|
|
|
selector: @selector(handleNotification:)
|
|
|
|
|
name: NSViewFocusDidChangeNotification
|
|
|
|
|
object: nil];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
|
|
|
|
- (void) _destroyWin32Context
|
|
|
|
|
{
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
#ifdef __debugServer__
|
|
|
|
|
printf("\n\n##############################################################\n");
|
|
|
|
|
printf("- (void) _destroyWin32Context\n");
|
|
|
|
|
printf("\n\n##############################################################\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-04-21 22:51:21 +00:00
|
|
|
|
UnregisterClass("GNUstepWindowClass", hinstance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
#ifdef __debugServer__
|
|
|
|
|
printf("\n\n##############################################################\n");
|
|
|
|
|
printf("- (void) dealloc\n");
|
|
|
|
|
printf("\n\n##############################################################\n");
|
|
|
|
|
#endif
|
2002-04-21 22:51:21 +00:00
|
|
|
|
[self _destroyWin32Context];
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-19 15:36:58 +00:00
|
|
|
|
- (void) restrictWindow: (int)win toImage: (NSImage*)image
|
2002-04-21 22:51:21 +00:00
|
|
|
|
{
|
2005-09-14 15:48:11 +00:00
|
|
|
|
#ifdef __debugServer__
|
|
|
|
|
printf("\n\n##############################################################\n");
|
|
|
|
|
printf("restrictWindow\n");
|
|
|
|
|
printf("\n\n##############################################################\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-06-19 15:36:58 +00:00
|
|
|
|
//[self subclassResponsibility: _cmd];
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-06-19 15:36:58 +00:00
|
|
|
|
- (int) findWindowAt: (NSPoint)screenLocation
|
|
|
|
|
windowRef: (int*)windowRef
|
|
|
|
|
excluding: (int)win
|
2002-04-21 22:51:21 +00:00
|
|
|
|
{
|
2004-06-19 15:36:58 +00:00
|
|
|
|
HWND hwnd;
|
|
|
|
|
POINT p;
|
|
|
|
|
|
|
|
|
|
p = GSScreenPointToMS(screenLocation);
|
|
|
|
|
hwnd = WindowFromPoint(p);
|
|
|
|
|
if ((int)hwnd == win)
|
|
|
|
|
{
|
2005-03-28 07:45:42 +00:00
|
|
|
|
/*
|
2005-03-29 14:03:30 +00:00
|
|
|
|
* If the window at the point we want is excluded,
|
2005-03-28 07:45:42 +00:00
|
|
|
|
* we must look through ALL windows at a lower level
|
|
|
|
|
* until we find one which contains the same point.
|
|
|
|
|
*/
|
|
|
|
|
while (hwnd != 0)
|
|
|
|
|
{
|
|
|
|
|
RECT r;
|
|
|
|
|
|
|
|
|
|
hwnd = GetWindow(hwnd, GW_HWNDNEXT);
|
|
|
|
|
GetWindowRect(hwnd, &r);
|
2005-03-29 14:03:30 +00:00
|
|
|
|
if (PtInRect(&r, p) && IsWindowVisible(hwnd))
|
2005-03-28 07:45:42 +00:00
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-06-19 15:36:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-03-28 07:45:42 +00:00
|
|
|
|
*windowRef = (int)hwnd; // Any windows
|
|
|
|
|
|
2004-06-19 15:36:58 +00:00
|
|
|
|
return (int)hwnd;
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-05-11 23:30:31 +00:00
|
|
|
|
// FIXME: The following methods wont work for multiple screens
|
2002-04-21 22:51:21 +00:00
|
|
|
|
/* Screen information */
|
|
|
|
|
- (NSSize) resolutionForScreen: (int)screen
|
|
|
|
|
{
|
|
|
|
|
int xres, yres;
|
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
|
xres = GetDeviceCaps(hdc, LOGPIXELSX);
|
|
|
|
|
yres = GetDeviceCaps(hdc, LOGPIXELSY);
|
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
|
|
|
|
|
|
return NSMakeSize(xres, yres);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSRect) boundsForScreen: (int)screen
|
|
|
|
|
{
|
|
|
|
|
return NSMakeRect(0, 0, GetSystemMetrics(SM_CXSCREEN),
|
|
|
|
|
GetSystemMetrics(SM_CYSCREEN));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSWindowDepth) windowDepthForScreen: (int)screen
|
|
|
|
|
{
|
|
|
|
|
HDC hdc;
|
|
|
|
|
int bits;
|
|
|
|
|
//int planes;
|
|
|
|
|
|
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
|
bits = GetDeviceCaps(hdc, BITSPIXEL) / 3;
|
|
|
|
|
//planes = GetDeviceCaps(hdc, PLANES);
|
|
|
|
|
//NSLog(@"bits %d planes %d", bits, planes);
|
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
|
|
|
|
|
|
return (_GSRGBBitValue | bits);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (const NSWindowDepth *) availableDepthsForScreen: (int)screen
|
|
|
|
|
{
|
|
|
|
|
int ndepths = 1;
|
|
|
|
|
NSZone *defaultZone = NSDefaultMallocZone();
|
|
|
|
|
NSWindowDepth *depths = 0;
|
|
|
|
|
|
|
|
|
|
depths = NSZoneMalloc(defaultZone, sizeof(NSWindowDepth)*(ndepths + 1));
|
|
|
|
|
// FIXME
|
|
|
|
|
depths[0] = [self windowDepthForScreen: screen];
|
|
|
|
|
depths[1] = 0;
|
|
|
|
|
|
|
|
|
|
return depths;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSArray *) screenList
|
|
|
|
|
{
|
|
|
|
|
return [NSArray arrayWithObject: [NSNumber numberWithInt: 0]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Returns the handle of the module instance. */
|
|
|
|
|
- (void *) serverDevice
|
|
|
|
|
{
|
|
|
|
|
return hinstance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
As the number of the window is actually is handle we return this. */
|
|
|
|
|
- (void *) windowDevice: (int)win
|
|
|
|
|
{
|
|
|
|
|
return (void *)win;
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-04 02:21:35 +00:00
|
|
|
|
- (void) beep
|
|
|
|
|
{
|
|
|
|
|
Beep(400, 500);
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-14 15:48:11 +00:00
|
|
|
|
/* stubs for window server events note other stubs should be
|
2005-10-21 03:07:19 +00:00
|
|
|
|
declared for mouse and keyboards
|
2005-09-14 15:48:11 +00:00
|
|
|
|
these should be implmented in a subclass or a catagory
|
|
|
|
|
*/
|
|
|
|
|
- (LRESULT) decodeWM_ACTIVEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
- (LRESULT) decodeWM_ACTIVEAPPParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam
|
2002-04-21 22:51:21 +00:00
|
|
|
|
{
|
2005-09-14 15:48:11 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
2005-10-21 03:07:19 +00:00
|
|
|
|
- (void) decodeWM_NCACTIVATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
2005-09-14 15:48:11 +00:00
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (LRESULT) decodeWM_SIZEParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
- (void) decodeWM_SIZINGParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam
|
2005-10-21 03:07:19 +00:00
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
- (LRESULT) decodeWM_MOVINGParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam
|
2005-10-21 03:07:19 +00:00
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
- (LRESULT) decodeWM_MOVEParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-21 03:07:19 +00:00
|
|
|
|
- (void) decodeWM_NCCALCSIZEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
2005-09-14 15:48:11 +00:00
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) decodeWM_WINDOWPOSCHANGINGParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) decodeWM_WINDOWPOSCHANGEDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (LRESULT) decodeWM_GETMINMAXINFOParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (LRESULT) decodeWM_NCCREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (LRESULT) decodeWM_CREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-21 03:07:19 +00:00
|
|
|
|
- (DWORD) windowStyleForGSStyle: (unsigned int) style
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
- (void) decodeWM_SHOWWINDOWParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) decodeWM_NCPAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (LRESULT) decodeWM_ERASEBKGNDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) decodeWM_PAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) decodeWM_SYNCPAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) decodeWM_CAPTURECHANGEDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-21 03:07:19 +00:00
|
|
|
|
//- (HICON) decodeWM_GETICONParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
//{
|
|
|
|
|
//[self subclassResponsibility: _cmd];
|
|
|
|
|
//return nil;
|
|
|
|
|
//}
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
- (void) resizeBackingStoreFor: (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//- (LRESULT) decodeWM_SETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
//{
|
|
|
|
|
//[self subclassResponsibility: _cmd];
|
|
|
|
|
|
|
|
|
|
//return 0;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (LRESULT) decodeWM_SETFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) decodeWM_KILLFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) decodeWM_GETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
- (void) decodeWM_CLOSEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
2005-09-14 15:48:11 +00:00
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) decodeWM_DESTROYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) decodeWM_NCDESTROYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) decodeWM_QUERYOPENParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) decodeWM_SYSCOMMANDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-21 03:07:19 +00:00
|
|
|
|
- (void) decodeWM_COMMANDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-21 03:07:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
- (BOOL) displayEvent: (unsigned int)uMsg; // diagnotic filter
|
2005-09-14 15:48:11 +00:00
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (LRESULT) decodeWM_EXITSIZEMOVEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// main event loop
|
|
|
|
|
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
- (NSString *) getNativeClassName: (HWND)hwnd
|
2005-09-14 15:48:11 +00:00
|
|
|
|
{
|
|
|
|
|
char * windowType[80];
|
2005-10-30 07:35:52 +00:00
|
|
|
|
UINT wsize =80;
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
if (RealGetWindowClass(hwnd,(LPTSTR)windowType,wsize)>0)
|
2002-04-21 22:51:21 +00:00
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
return [NSString stringWithCString: (char *)windowType length: wsize+1];
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
- (NSString *) getWindowtext: (HWND)hwnd
|
2005-09-14 15:48:11 +00:00
|
|
|
|
{
|
|
|
|
|
char * windowText[80];
|
2005-10-30 07:35:52 +00:00
|
|
|
|
int wsize = 80;
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
if (GetWindowText(hwnd,(LPTSTR)windowText,wsize) > 0)
|
|
|
|
|
return [NSString stringWithCString: (char *)windowText length: wsize + 1];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Reset all of our flags before the next run through the event switch
|
|
|
|
|
*
|
|
|
|
|
*/
|
2005-10-30 07:35:52 +00:00
|
|
|
|
- (void) setFlagsforEventLoop: (HWND)hwnd
|
2005-09-14 15:48:11 +00:00
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
flags._eventHandled = NO;
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
flags._is_menu = NO;
|
|
|
|
|
if ((HWND)flags.menuRef == hwnd && flags.HAVE_MAIN_MENU == YES)
|
|
|
|
|
flags._is_menu = YES;
|
2005-09-14 15:48:11 +00:00
|
|
|
|
// note some cache windows are needed..... just get the zeros
|
2005-10-30 07:35:52 +00:00
|
|
|
|
flags._is_cache = [[EVENT_WINDOW(hwnd) className] isEqual: @"GSCacheW"];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
flags._hasGSClassName = NO;
|
|
|
|
|
if ([EVENT_WINDOW(hwnd) className] != nil)
|
|
|
|
|
flags._hasGSClassName = YES;
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
// future house keeping can go here
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (LRESULT) windowEventProc: (HWND)hwnd : (UINT)uMsg
|
|
|
|
|
: (WPARAM)wParam : (LPARAM)lParam
|
|
|
|
|
{
|
|
|
|
|
NSEvent *ev = nil;
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
[self setFlagsforEventLoop: hwnd];
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
#ifdef __W32_debug__
|
2005-10-30 07:35:52 +00:00
|
|
|
|
if ([self displayEvent: uMsg]== YES)
|
2005-09-14 15:48:11 +00:00
|
|
|
|
{
|
|
|
|
|
printf("\n\n\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
printf("+++ NEW EVENT CYCLE %u +++\n",uMsg);
|
|
|
|
|
printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
#ifdef __W32_debug_Event_loop
|
|
|
|
|
printf("Events Posted = %d\n",flags.eventQueCount);
|
|
|
|
|
printf("EVENT Que Count = %d\n",(int)[GSCurrentServer() eventQueCount]);
|
2005-10-30 07:35:52 +00:00
|
|
|
|
printf("%s",[[GSCurrentServer() dumpQue: 10] cString]);
|
2005-09-14 15:48:11 +00:00
|
|
|
|
#endif
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
2005-09-14 15:48:11 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
switch (uMsg)
|
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
case WM_SIZING:
|
|
|
|
|
[self decodeWM_SIZINGParams: hwnd : wParam : lParam];
|
|
|
|
|
case WM_NCCREATE:
|
|
|
|
|
return [self decodeWM_NCCREATEParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_NCCALCSIZE:
|
|
|
|
|
[self decodeWM_NCCALCSIZEParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_NCACTIVATE:
|
|
|
|
|
[self decodeWM_NCACTIVATEParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_NCPAINT:
|
|
|
|
|
if (flags.useWMStyles == NO)
|
|
|
|
|
[self decodeWM_NCPAINTParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
//case WM_SHOWWINDOW:
|
|
|
|
|
//[self decodeWM_SHOWWINDOWParams: wParam : lParam : hwnd];
|
|
|
|
|
//break;
|
|
|
|
|
case WM_NCDESTROY:
|
|
|
|
|
[self decodeWM_NCDESTROYParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_GETTEXT:
|
|
|
|
|
[self decodeWM_GETTEXTParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_STYLECHANGING:
|
|
|
|
|
break;
|
|
|
|
|
case WM_STYLECHANGED:
|
|
|
|
|
break;
|
|
|
|
|
case WM_GETMINMAXINFO:
|
|
|
|
|
return [self decodeWM_GETMINMAXINFOParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_CREATE:
|
|
|
|
|
return [self decodeWM_CREATEParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_WINDOWPOSCHANGING:
|
|
|
|
|
[self decodeWM_WINDOWPOSCHANGINGParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_WINDOWPOSCHANGED:
|
|
|
|
|
[self decodeWM_WINDOWPOSCHANGEDParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_MOVE:
|
|
|
|
|
return [self decodeWM_MOVEParams: hwnd : wParam : lParam];
|
|
|
|
|
break;
|
|
|
|
|
case WM_MOVING:
|
|
|
|
|
return [self decodeWM_MOVINGParams: hwnd : wParam : lParam];
|
|
|
|
|
break;
|
|
|
|
|
case WM_SIZE:
|
|
|
|
|
return [self decodeWM_SIZEParams: hwnd : wParam : lParam];
|
|
|
|
|
break;
|
|
|
|
|
case WM_ENTERSIZEMOVE:
|
|
|
|
|
break;
|
|
|
|
|
case WM_EXITSIZEMOVE:
|
|
|
|
|
//return [self decodeWM_EXITSIZEMOVEParams: wParam : lParam : hwnd];
|
|
|
|
|
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
|
|
|
|
break;
|
|
|
|
|
case WM_ACTIVATE:
|
|
|
|
|
if ((int)lParam !=0)
|
|
|
|
|
[self decodeWM_ACTIVEParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_ACTIVATEAPP:
|
|
|
|
|
//if (_is_cache == NO)
|
|
|
|
|
return [self decodeWM_ACTIVEAPPParams: hwnd : wParam : lParam];
|
|
|
|
|
break;
|
|
|
|
|
case WM_SETFOCUS:
|
|
|
|
|
return [self decodeWM_SETFOCUSParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_KILLFOCUS:
|
|
|
|
|
if (wParam == (int)hwnd)
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
[self decodeWM_KILLFOCUSParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_SETCURSOR:
|
|
|
|
|
break;
|
|
|
|
|
case WM_QUERYOPEN:
|
|
|
|
|
[self decodeWM_QUERYOPENParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_CAPTURECHANGED:
|
|
|
|
|
[self decodeWM_CAPTURECHANGEDParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_ERASEBKGND:
|
|
|
|
|
return [self decodeWM_ERASEBKGNDParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_PAINT:
|
|
|
|
|
[self decodeWM_PAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd];
|
|
|
|
|
case WM_SYNCPAINT:
|
|
|
|
|
if (flags.useWMStyles == NO)
|
|
|
|
|
[self decodeWM_SYNCPAINTParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_CLOSE:
|
|
|
|
|
[self decodeWM_CLOSEParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
|
[self decodeWM_DESTROYParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_QUIT:
|
|
|
|
|
break;
|
|
|
|
|
case WM_USER:
|
|
|
|
|
break;
|
|
|
|
|
case WM_APP:
|
|
|
|
|
break;
|
|
|
|
|
case WM_ENTERMENULOOP:
|
|
|
|
|
break;
|
|
|
|
|
case WM_EXITMENULOOP:
|
|
|
|
|
break;
|
|
|
|
|
case WM_INITMENU:
|
|
|
|
|
break;
|
|
|
|
|
case WM_MENUSELECT:
|
|
|
|
|
break;
|
|
|
|
|
case WM_ENTERIDLE:
|
|
|
|
|
break;
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
|
[self decodeWM_COMMANDParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_SYSKEYDOWN:
|
|
|
|
|
break;
|
|
|
|
|
case WM_SYSKEYUP:
|
|
|
|
|
break;
|
|
|
|
|
case WM_SYSCOMMAND:
|
|
|
|
|
[self decodeWM_SYSCOMMANDParams: wParam : lParam : hwnd];
|
|
|
|
|
break;
|
|
|
|
|
case WM_HELP:
|
|
|
|
|
break;
|
|
|
|
|
//case WM_GETICON:
|
|
|
|
|
//return [self decodeWM_GETICONParams: wParam : lParam : hwnd];
|
|
|
|
|
//break;
|
|
|
|
|
//case WM_SETICON:
|
|
|
|
|
//return [self decodeWM_SETICONParams: wParam : lParam : hwnd];
|
|
|
|
|
//break;
|
|
|
|
|
case WM_CANCELMODE: // new added by Tom MacSween
|
|
|
|
|
break;
|
|
|
|
|
case WM_ENABLE:
|
|
|
|
|
case WM_CHILDACTIVATE:
|
|
|
|
|
break;
|
|
|
|
|
case WM_NULL:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* resued from WIN32EventServer.m (now removed from this project) */
|
|
|
|
|
case WM_NCHITTEST: //MOUSE
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "NCHITTEST", hwnd);
|
|
|
|
|
break;
|
|
|
|
|
case WM_NCMOUSEMOVE: //MOUSE
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "NCMOUSEMOVE", hwnd);
|
|
|
|
|
break;
|
|
|
|
|
case WM_NCLBUTTONDOWN: //MOUSE
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "NCLBUTTONDOWN", hwnd);
|
|
|
|
|
break;
|
|
|
|
|
case WM_NCLBUTTONUP: //MOUSE
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "NCLBUTTONUP", hwnd);
|
|
|
|
|
break;
|
|
|
|
|
case WM_MOUSEACTIVATE: //MOUSE
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MOUSEACTIVATE", hwnd);
|
|
|
|
|
break;
|
|
|
|
|
case WM_MOUSEMOVE: //MOUSE
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MOUSEMOVE", hwnd);
|
2006-09-12 19:53:46 +00:00
|
|
|
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSMouseMoved);
|
2005-10-30 07:35:52 +00:00
|
|
|
|
break;
|
|
|
|
|
case WM_LBUTTONDOWN: //MOUSE
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "LBUTTONDOWN", hwnd);
|
|
|
|
|
//[self decodeWM_LBUTTONDOWNParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd];
|
2006-09-12 19:53:46 +00:00
|
|
|
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSLeftMouseDown);
|
2005-10-30 07:35:52 +00:00
|
|
|
|
break;
|
|
|
|
|
case WM_LBUTTONUP: //MOUSE
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "LBUTTONUP", hwnd);
|
2006-09-12 19:53:46 +00:00
|
|
|
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSLeftMouseUp);
|
2005-10-30 07:35:52 +00:00
|
|
|
|
break;
|
|
|
|
|
case WM_LBUTTONDBLCLK: //MOUSE
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "LBUTTONDBLCLK", hwnd);
|
|
|
|
|
break;
|
|
|
|
|
case WM_MBUTTONDOWN: //MOUSE
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MBUTTONDOWN", hwnd);
|
2006-09-12 19:53:46 +00:00
|
|
|
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSOtherMouseDown);
|
2005-10-30 07:35:52 +00:00
|
|
|
|
break;
|
|
|
|
|
case WM_MBUTTONUP: //MOUSE
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MBUTTONUP", hwnd);
|
2006-09-12 19:53:46 +00:00
|
|
|
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSOtherMouseUp);
|
2005-10-30 07:35:52 +00:00
|
|
|
|
break;
|
|
|
|
|
case WM_MBUTTONDBLCLK: //MOUSE
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MBUTTONDBLCLK", hwnd);
|
|
|
|
|
break;
|
|
|
|
|
case WM_RBUTTONDOWN: //MOUSE
|
|
|
|
|
{
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "RBUTTONDOWN", hwnd);
|
2006-09-12 19:53:46 +00:00
|
|
|
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSRightMouseDown);
|
2005-10-30 07:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WM_RBUTTONUP: //MOUSE
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "RBUTTONUP", hwnd);
|
|
|
|
|
{
|
2006-09-12 19:53:46 +00:00
|
|
|
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSRightMouseUp);
|
2005-10-30 07:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WM_RBUTTONDBLCLK: //MOUSE
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "RBUTTONDBLCLK", hwnd);
|
|
|
|
|
break;
|
|
|
|
|
case WM_MOUSEWHEEL: //MOUSE
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MOUSEWHEEL", hwnd);
|
2006-09-12 19:53:46 +00:00
|
|
|
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSScrollWheel);
|
2005-10-30 07:35:52 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WM_KEYDOWN: //KEYBOARD
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "KEYDOWN", hwnd);
|
2006-09-12 19:53:46 +00:00
|
|
|
|
ev = process_key_event(self, hwnd, wParam, lParam, NSKeyDown);
|
2005-10-30 07:35:52 +00:00
|
|
|
|
break;
|
|
|
|
|
case WM_KEYUP: //KEYBOARD
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "KEYUP", hwnd);
|
2006-09-12 19:53:46 +00:00
|
|
|
|
ev = process_key_event(self, hwnd, wParam, lParam, NSKeyUp);
|
2005-10-30 07:35:52 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WM_POWERBROADCAST: //SYSTEM
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "POWERBROADCAST", hwnd);
|
|
|
|
|
break;
|
|
|
|
|
case WM_TIMECHANGE: //SYSTEM
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "TIMECHANGE", hwnd);
|
|
|
|
|
break;
|
|
|
|
|
case WM_DEVICECHANGE: //SYSTEM
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "DEVICECHANGE", hwnd);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
// Process all other messages.
|
|
|
|
|
#ifdef __W32_debug__
|
|
|
|
|
printf("Uhandled message: %d on window %s\n",uMsg,[[GSWindowWithNumber((int)hwnd) className] cString]);
|
|
|
|
|
#endif
|
|
|
|
|
NSDebugLLog(@"NSEvent", @"Got unhandled Message %d for %d", uMsg, hwnd);
|
|
|
|
|
break;
|
2005-09-14 15:48:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* see if the event was handled in the the main loop or in the
|
2005-10-30 07:35:52 +00:00
|
|
|
|
* menu loop. if eventHandled = YES then we are done and need to
|
2005-09-14 15:48:11 +00:00
|
|
|
|
* tell the windows event handler we are finished
|
|
|
|
|
*/
|
2005-10-30 07:35:52 +00:00
|
|
|
|
if (flags._eventHandled == YES)
|
2005-09-14 15:48:11 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (ev != nil)
|
|
|
|
|
{
|
|
|
|
|
[GSCurrentServer() postEvent: ev atStart: NO];
|
|
|
|
|
flags.eventQueCount++;
|
|
|
|
|
#ifdef __W32_debug__
|
2005-10-30 07:35:52 +00:00
|
|
|
|
if ([ev type]== NSAppKitDefined)
|
2005-09-14 15:48:11 +00:00
|
|
|
|
{
|
|
|
|
|
printf("uMsg %d ",uMsg);
|
2005-10-30 07:35:52 +00:00
|
|
|
|
printf("Post event %s ",[[ev eventNameWithSubtype: YES] cString]);
|
2005-09-14 15:48:11 +00:00
|
|
|
|
printf("on window %s\n",[[[ev window] className] cString]);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
return 0;
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
2005-09-14 15:48:11 +00:00
|
|
|
|
/*
|
|
|
|
|
* We did not care about the event return it back to the windows
|
|
|
|
|
* event handler
|
|
|
|
|
*/
|
|
|
|
|
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
|
|
|
|
@implementation WIN32Server (WindowOps)
|
|
|
|
|
|
2005-03-29 14:03:30 +00:00
|
|
|
|
-(BOOL) handlesWindowDecorations
|
|
|
|
|
{
|
|
|
|
|
return handlesWindowDecorations;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-09-14 15:48:11 +00:00
|
|
|
|
/*
|
|
|
|
|
styleMask specifies the receiver's style. It can either be
|
|
|
|
|
NSBorderlessWindowMask, or it can contain any of the following
|
|
|
|
|
options, combined using the C bitwise OR operator: Option Meaning
|
|
|
|
|
|
|
|
|
|
NSTitledWindowMask The NSWindow displays a title bar.
|
|
|
|
|
NSClosableWindowMask The NSWindow displays a close button.
|
|
|
|
|
NSMiniaturizableWindowMask The NSWindow displays a miniaturize button.
|
|
|
|
|
NSResizableWindowMask The NSWindow displays a resize bar or border.
|
|
|
|
|
NSBorderlessWindowMask
|
|
|
|
|
|
|
|
|
|
NSUtilityWindowMask 16
|
|
|
|
|
NSDocModalWindowMask 32
|
|
|
|
|
NSBorderlessWindowMask 0
|
|
|
|
|
NSTitledWindowMask 1
|
|
|
|
|
NSClosableWindowMask 2
|
|
|
|
|
NSMiniaturizableWindowMask 4
|
|
|
|
|
NSResizableWindowMask 8
|
|
|
|
|
NSIconWindowMask 64
|
|
|
|
|
NSMiniWindowMask 128
|
|
|
|
|
|
|
|
|
|
Borderless windows display none of the usual peripheral elements and
|
|
|
|
|
are generally useful only for display or caching purposes; you
|
|
|
|
|
should normally not need to create them. Also, note that an
|
|
|
|
|
NSWindow's style mask should include NSTitledWindowMask if it
|
|
|
|
|
includes any of the others.
|
|
|
|
|
|
|
|
|
|
backingType specifies how the drawing done in the receiver is
|
|
|
|
|
buffered by the object's window device: NSBackingStoreBuffered
|
|
|
|
|
NSBackingStoreRetained NSBackingStoreNonretained
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flag determines whether the Window Server creates a window device
|
|
|
|
|
for the new object immediately. If flag is YES, it defers creating
|
|
|
|
|
the window until the receiver is moved on screen. All display
|
|
|
|
|
messages sent to the NSWindow or its NSViews are postponed until the
|
|
|
|
|
window is created, just before it's moved on screen. Deferring the
|
|
|
|
|
creation of the window improves launch time and minimizes the
|
|
|
|
|
virtual memory load on the Window Server. The new NSWindow creates
|
|
|
|
|
an instance of NSView to be its default content view. You can
|
|
|
|
|
replace it with your own object by using the setContentView: method.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2002-04-21 22:51:21 +00:00
|
|
|
|
- (int) window: (NSRect)frame : (NSBackingStoreType)type : (unsigned int)style
|
2002-04-22 15:45:10 +00:00
|
|
|
|
: (int) screen
|
2002-04-21 22:51:21 +00:00
|
|
|
|
{
|
|
|
|
|
HWND hwnd;
|
|
|
|
|
RECT r;
|
2005-03-29 14:03:30 +00:00
|
|
|
|
DWORD wstyle;
|
|
|
|
|
DWORD estyle;
|
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
flags.currentGS_Style = style;
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
wstyle = [self windowStyleForGSStyle: style];
|
2005-03-30 14:15:52 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
if ((style & NSMiniaturizableWindowMask) == NSMiniaturizableWindowMask)
|
2005-03-30 14:15:52 +00:00
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
if (flags.useWMTaskBar == YES)
|
|
|
|
|
estyle = WS_EX_APPWINDOW;
|
|
|
|
|
else
|
|
|
|
|
estyle = WS_EX_TOOLWINDOW;
|
2005-03-29 14:03:30 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
estyle = WS_EX_TOOLWINDOW;
|
2005-09-14 15:48:11 +00:00
|
|
|
|
}
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
2004-08-09 12:42:12 +00:00
|
|
|
|
r = GSScreenRectToMS(frame, style, self);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
2005-09-14 15:48:11 +00:00
|
|
|
|
#ifdef __debugServer__
|
|
|
|
|
printf("\n\n##############################################################\n");
|
|
|
|
|
printf("handlesWindowDecorations %s\n",handlesWindowDecorations ? "YES" : "NO");
|
|
|
|
|
printf("checking for NSMiniaturizableWindowMask %u\n",(style & NSMiniaturizableWindowMask));
|
|
|
|
|
printf("GS Window Style %u\n",style);
|
2005-11-16 11:40:31 +00:00
|
|
|
|
printf("Extended Style %d [hex] %X\n",(int)estyle,(UINT)estyle);
|
2005-10-21 03:40:07 +00:00
|
|
|
|
printf("Win32 Style picked %ld [hex] %X\n",wstyle,(unsigned int)wstyle);
|
2005-09-14 15:48:11 +00:00
|
|
|
|
printf("\n##############################################################\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* from here down is reused and unmodified from WIN32EventServer.m
|
|
|
|
|
* which has been removed form the subproject
|
|
|
|
|
*/
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"window: %@ : %d : %d : %d", NSStringFromRect(frame),
|
|
|
|
|
type, style, screen);
|
|
|
|
|
NSDebugLLog(@"WTrace", @" device frame: %d, %d, %d, %d",
|
|
|
|
|
r.left, r.top, r.right - r.left, r.bottom - r.top);
|
2005-03-29 14:03:30 +00:00
|
|
|
|
hwnd = CreateWindowEx(estyle,
|
2002-04-21 22:51:21 +00:00
|
|
|
|
"GNUstepWindowClass",
|
|
|
|
|
"GNUstepWindow",
|
|
|
|
|
wstyle,
|
|
|
|
|
r.left,
|
|
|
|
|
r.top,
|
|
|
|
|
r.right - r.left,
|
|
|
|
|
r.bottom - r.top,
|
2005-03-30 14:15:52 +00:00
|
|
|
|
(HWND)NULL,
|
|
|
|
|
(HMENU)NULL,
|
2002-04-21 22:51:21 +00:00
|
|
|
|
hinstance,
|
|
|
|
|
(void*)type);
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @" num/handle: %d", hwnd);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
|
|
|
|
[self _setWindowOwnedByServer: (int)hwnd];
|
|
|
|
|
return (int)hwnd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) termwindow: (int) winNum
|
|
|
|
|
{
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"termwindow: %d", winNum);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
DestroyWindow((HWND)winNum);
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-17 13:35:50 +00:00
|
|
|
|
- (void) stylewindow: (unsigned int)style : (int) winNum
|
2002-04-21 22:51:21 +00:00
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
DWORD wstyle = [self windowStyleForGSStyle: style];
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
2005-03-29 14:03:30 +00:00
|
|
|
|
NSAssert(handlesWindowDecorations,
|
2005-10-30 07:35:52 +00:00
|
|
|
|
@"-stylewindow: : called when handlesWindowDecorations == NO");
|
2005-03-29 14:03:30 +00:00
|
|
|
|
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"stylewindow: %d : %d", style, winNum);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
SetWindowLong((HWND)winNum, GWL_STYLE, wstyle);
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-19 22:19:50 +00:00
|
|
|
|
- (void) setbackgroundcolor: (NSColor *)color : (int)win
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-21 22:51:21 +00:00
|
|
|
|
/** Changes window's the backing store to type */
|
|
|
|
|
- (void) windowbacking: (NSBackingStoreType)type : (int) winNum
|
|
|
|
|
{
|
|
|
|
|
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong((HWND)winNum, GWL_USERDATA);
|
|
|
|
|
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"windowbacking: %d : %d", type, winNum);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
if (win->useHDC)
|
|
|
|
|
{
|
2002-04-27 10:12:58 +00:00
|
|
|
|
HGDIOBJ old;
|
|
|
|
|
|
|
|
|
|
old = SelectObject(win->hdc, win->old);
|
|
|
|
|
DeleteObject(old);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
DeleteDC(win->hdc);
|
|
|
|
|
win->hdc = NULL;
|
2002-04-27 10:12:58 +00:00
|
|
|
|
win->old = NULL;
|
|
|
|
|
win->useHDC = NO;
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-06-02 12:21:57 +00:00
|
|
|
|
if (type != NSBackingStoreNonretained)
|
2002-04-21 22:51:21 +00:00
|
|
|
|
{
|
|
|
|
|
HDC hdc, hdc2;
|
|
|
|
|
HBITMAP hbitmap;
|
|
|
|
|
RECT r;
|
|
|
|
|
|
|
|
|
|
GetClientRect((HWND)winNum, &r);
|
|
|
|
|
hdc = GetDC((HWND)winNum);
|
|
|
|
|
hdc2 = CreateCompatibleDC(hdc);
|
|
|
|
|
hbitmap = CreateCompatibleBitmap(hdc, r.right - r.left, r.bottom - r.top);
|
2002-04-27 10:12:58 +00:00
|
|
|
|
win->old = SelectObject(hdc2, hbitmap);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
win->hdc = hdc2;
|
2002-04-27 10:12:58 +00:00
|
|
|
|
win->useHDC = YES;
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
|
|
|
|
ReleaseDC((HWND)winNum, hdc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) titlewindow: (NSString*)window_title : (int) winNum
|
|
|
|
|
{
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"titlewindow: %@ : %d", window_title, winNum);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
SetWindowText((HWND)winNum, [window_title cString]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) miniwindow: (int) winNum
|
|
|
|
|
{
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"miniwindow: %d", winNum);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
ShowWindow((HWND)winNum, SW_MINIMIZE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Returns NO as we don't provide mini windows on MS Windows */
|
|
|
|
|
- (BOOL) appOwnsMiniwindow
|
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) windowdevice: (int) winNum
|
|
|
|
|
{
|
|
|
|
|
NSGraphicsContext *ctxt;
|
2006-09-12 19:53:46 +00:00
|
|
|
|
RECT rect;
|
|
|
|
|
float h, l, r, t, b;
|
|
|
|
|
NSWindow *window;
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"windowdevice: %d", winNum);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
ctxt = GSCurrentContext();
|
2006-09-12 19:53:46 +00:00
|
|
|
|
window = GSWindowWithNumber(winNum);
|
|
|
|
|
GetClientRect((HWND)winNum, &rect);
|
|
|
|
|
h = rect.bottom - rect.top;
|
|
|
|
|
[self styleoffsets: &l : &r : &t : &b : [window styleMask]];
|
|
|
|
|
GSSetDevice(ctxt, (void*)winNum, l, h + b);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
DPSinitmatrix(ctxt);
|
|
|
|
|
DPSinitclip(ctxt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) orderwindow: (int) op : (int) otherWin : (int) winNum
|
|
|
|
|
{
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"orderwindow: %d : %d : %d", op, otherWin, winNum);
|
2003-12-27 01:06:19 +00:00
|
|
|
|
|
|
|
|
|
if (flags.useWMTaskBar)
|
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
/* When using this policy, we make these changes:
|
2003-12-27 01:06:19 +00:00
|
|
|
|
- don't show the application icon window
|
|
|
|
|
- Never order out the main menu, just minimize it, so that
|
|
|
|
|
when the user clicks on it in the taskbar it will activate the
|
|
|
|
|
application.
|
|
|
|
|
*/
|
|
|
|
|
int special;
|
|
|
|
|
special = [[NSApp iconWindow] windowNumber];
|
|
|
|
|
if (winNum == special)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
special = [[[NSApp mainMenu] window] windowNumber];
|
|
|
|
|
if (winNum == special && op == NSWindowOut)
|
|
|
|
|
{
|
|
|
|
|
ShowWindow((HWND)winNum, SW_MINIMIZE);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-21 22:51:21 +00:00
|
|
|
|
if (op != NSWindowOut)
|
|
|
|
|
{
|
2003-12-27 01:06:19 +00:00
|
|
|
|
int flag = SW_SHOW;
|
2004-05-11 23:30:31 +00:00
|
|
|
|
|
2003-12-27 01:06:19 +00:00
|
|
|
|
if (IsIconic((HWND)winNum))
|
|
|
|
|
flag = SW_RESTORE;
|
|
|
|
|
ShowWindow((HWND)winNum, flag);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (op)
|
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
case NSWindowOut:
|
|
|
|
|
SetWindowPos((HWND)winNum, NULL, 0, 0, 0, 0,
|
|
|
|
|
SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
|
|
|
|
|
break;
|
|
|
|
|
case NSWindowBelow:
|
|
|
|
|
if (otherWin == 0)
|
|
|
|
|
otherWin = (int)HWND_BOTTOM;
|
|
|
|
|
SetWindowPos((HWND)winNum, (HWND)otherWin, 0, 0, 0, 0,
|
|
|
|
|
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
|
|
|
|
|
break;
|
|
|
|
|
case NSWindowAbove:
|
|
|
|
|
if (otherWin <= 0)
|
|
|
|
|
{
|
|
|
|
|
/* FIXME: Need to find the current key window (otherWin == 0
|
|
|
|
|
means keep the window below the current key.) */
|
|
|
|
|
otherWin = winNum;
|
|
|
|
|
winNum = (int)HWND_TOP;
|
|
|
|
|
}
|
|
|
|
|
SetWindowPos((HWND) otherWin, (HWND)winNum, 0, 0, 0, 0,
|
|
|
|
|
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
|
|
|
|
|
break;
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) movewindow: (NSPoint)loc : (int)winNum
|
|
|
|
|
{
|
|
|
|
|
POINT p;
|
|
|
|
|
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"movewindow: %@ : %d", NSStringFromPoint(loc),
|
|
|
|
|
winNum);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
p = GSWindowOriginToMS((HWND)winNum, loc);
|
|
|
|
|
|
|
|
|
|
SetWindowPos((HWND)winNum, NULL, p.x, p.y, 0, 0,
|
2004-05-11 23:30:31 +00:00
|
|
|
|
SWP_NOZORDER | SWP_NOSIZE);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) placewindow: (NSRect)frame : (int) winNum
|
|
|
|
|
{
|
|
|
|
|
RECT r;
|
2002-04-27 10:12:58 +00:00
|
|
|
|
RECT r2;
|
|
|
|
|
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong((HWND)winNum, GWL_USERDATA);
|
2004-08-09 12:42:12 +00:00
|
|
|
|
NSWindow *window = GSWindowWithNumber(winNum);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"placewindow: %@ : %d", NSStringFromRect(frame),
|
|
|
|
|
winNum);
|
2004-08-09 12:42:12 +00:00
|
|
|
|
r = GSScreenRectToMS(frame, [window styleMask], self);
|
2002-04-27 10:12:58 +00:00
|
|
|
|
GetWindowRect((HWND)winNum, &r2);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
SetWindowPos((HWND)winNum, NULL,
|
|
|
|
|
r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
2005-10-30 07:35:52 +00:00
|
|
|
|
if ((win->useHDC)
|
|
|
|
|
&& (r.right - r.left != r2.right - r2.left)
|
|
|
|
|
&& (r.bottom - r.top != r2.bottom - r2.top))
|
2002-04-27 10:12:58 +00:00
|
|
|
|
{
|
|
|
|
|
HDC hdc, hdc2;
|
|
|
|
|
HBITMAP hbitmap;
|
|
|
|
|
HGDIOBJ old;
|
|
|
|
|
|
|
|
|
|
old = SelectObject(win->hdc, win->old);
|
|
|
|
|
DeleteObject(old);
|
|
|
|
|
DeleteDC(win->hdc);
|
|
|
|
|
win->hdc = NULL;
|
|
|
|
|
win->old = NULL;
|
|
|
|
|
|
|
|
|
|
GetClientRect((HWND)winNum, &r);
|
|
|
|
|
hdc = GetDC((HWND)winNum);
|
|
|
|
|
hdc2 = CreateCompatibleDC(hdc);
|
|
|
|
|
hbitmap = CreateCompatibleBitmap(hdc, r.right - r.left, r.bottom - r.top);
|
|
|
|
|
win->old = SelectObject(hdc2, hbitmap);
|
|
|
|
|
win->hdc = hdc2;
|
|
|
|
|
|
|
|
|
|
ReleaseDC((HWND)winNum, hdc);
|
|
|
|
|
}
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) findwindow: (NSPoint)loc : (int) op : (int) otherWin
|
|
|
|
|
: (NSPoint *)floc : (int*) winFound
|
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSRect) windowbounds: (int) winNum
|
|
|
|
|
{
|
|
|
|
|
RECT r;
|
2004-08-24 18:53:39 +00:00
|
|
|
|
NSWindow *window = GSWindowWithNumber(winNum);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
|
|
|
|
GetWindowRect((HWND)winNum, &r);
|
2004-08-09 12:42:12 +00:00
|
|
|
|
return MSScreenRectToGS(r, [window styleMask], self);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setwindowlevel: (int) level : (int) winNum
|
|
|
|
|
{
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"setwindowlevel: %d : %d", level, winNum);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (int) windowlevel: (int) winNum
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSArray *) windowlist
|
|
|
|
|
{
|
2006-10-21 19:16:47 +00:00
|
|
|
|
// FIXME
|
|
|
|
|
return [super windowlist];
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (int) windowdepth: (int) winNum
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Set the maximum size of the window */
|
|
|
|
|
- (void) setmaxsize: (NSSize)size : (int) winNum
|
|
|
|
|
{
|
|
|
|
|
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong((HWND)winNum, GWL_USERDATA);
|
|
|
|
|
POINT p;
|
|
|
|
|
|
|
|
|
|
p.x = size.width;
|
|
|
|
|
p.y = size.height;
|
|
|
|
|
win->minmax.ptMaxTrackSize = p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Set the minimum size of the window */
|
|
|
|
|
- (void) setminsize: (NSSize)size : (int) winNum
|
|
|
|
|
{
|
|
|
|
|
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong((HWND)winNum, GWL_USERDATA);
|
|
|
|
|
POINT p;
|
|
|
|
|
|
|
|
|
|
p.x = size.width;
|
|
|
|
|
p.y = size.height;
|
|
|
|
|
win->minmax.ptMinTrackSize = p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Set the resize incremenet of the window */
|
|
|
|
|
- (void) setresizeincrements: (NSSize)size : (int) winNum
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Causes buffered graphics to be flushed to the screen */
|
|
|
|
|
- (void) flushwindowrect: (NSRect)rect : (int) winNum
|
|
|
|
|
{
|
2006-09-12 19:53:46 +00:00
|
|
|
|
RECT r = GSWindowRectToMS(self, (HWND)winNum, rect);
|
|
|
|
|
validateWindow(self, (HWND)winNum, r);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) styleoffsets: (float *) l : (float *) r : (float *) t : (float *) b
|
2003-06-17 13:35:50 +00:00
|
|
|
|
: (unsigned int) style
|
2002-04-21 22:51:21 +00:00
|
|
|
|
{
|
2005-03-29 14:03:30 +00:00
|
|
|
|
if (handlesWindowDecorations)
|
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
DWORD wstyle = [self windowStyleForGSStyle: style];
|
2005-03-29 14:03:30 +00:00
|
|
|
|
RECT rect = {100, 100, 200, 200};
|
|
|
|
|
|
|
|
|
|
AdjustWindowRectEx(&rect, wstyle, NO, 0);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
2005-03-29 14:03:30 +00:00
|
|
|
|
*l = 100 - rect.left;
|
|
|
|
|
*r = rect.right - 200;
|
|
|
|
|
*t = 100 - rect.top;
|
|
|
|
|
*b = rect.bottom - 200;
|
|
|
|
|
//NSLog(@"Style %d offset %f %f %f %f", wstyle, *l, *r, *t, *b);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/*
|
2005-09-14 15:48:11 +00:00
|
|
|
|
If we don't handle decorations, all our windows are going to be
|
|
|
|
|
border- and decorationless. In that case, -gui won't call this method,
|
|
|
|
|
but we still use it internally.
|
2005-03-29 14:03:30 +00:00
|
|
|
|
*/
|
|
|
|
|
*l = *r = *t = *b = 0.0;
|
|
|
|
|
}
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) docedited: (int) edited : (int) winNum
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setinputstate: (int)state : (int)winNum
|
|
|
|
|
{
|
2005-03-29 14:03:30 +00:00
|
|
|
|
if (handlesWindowDecorations == NO)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-04-21 22:51:21 +00:00
|
|
|
|
if (state == GSTitleBarKey)
|
|
|
|
|
{
|
|
|
|
|
SetActiveWindow((HWND)winNum);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Forces focus to the window so that all key events are sent to this
|
|
|
|
|
window */
|
|
|
|
|
- (void) setinputfocus: (int) winNum
|
|
|
|
|
{
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"setinputfocus: %d", winNum);
|
2004-05-11 23:30:31 +00:00
|
|
|
|
NSDebugLLog(@"Focus", @"Setting input focus to %d", winNum);
|
2003-12-03 20:39:45 +00:00
|
|
|
|
if (winNum == 0)
|
|
|
|
|
{
|
|
|
|
|
NSDebugLLog(@"Focus", @" invalid focus window");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (currentFocus == (HWND)winNum)
|
|
|
|
|
{
|
|
|
|
|
NSDebugLLog(@"Focus", @" window already has focus");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
desiredFocus = (HWND)winNum;
|
|
|
|
|
SetFocus((HWND)winNum);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSPoint) mouselocation
|
|
|
|
|
{
|
|
|
|
|
POINT p;
|
|
|
|
|
|
|
|
|
|
if (!GetCursorPos(&p))
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"GetCursorPos failed with %d", GetLastError());
|
|
|
|
|
return NSZeroPoint;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return MSScreenPointToGS(p.x, p.y);
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-27 10:12:58 +00:00
|
|
|
|
- (NSPoint) mouseLocationOnScreen: (int)screen window: (int *)win
|
2002-04-23 21:05:50 +00:00
|
|
|
|
{
|
|
|
|
|
return [self mouselocation];
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-21 22:51:21 +00:00
|
|
|
|
- (BOOL) capturemouse: (int) winNum
|
|
|
|
|
{
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"capturemouse: %d", winNum);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
SetCapture((HWND)winNum);
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) releasemouse
|
|
|
|
|
{
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"releasemouse");
|
2002-04-21 22:51:21 +00:00
|
|
|
|
ReleaseCapture();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) hidecursor
|
|
|
|
|
{
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"hidecursor");
|
2002-04-21 22:51:21 +00:00
|
|
|
|
ShowCursor(NO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) showcursor
|
|
|
|
|
{
|
|
|
|
|
ShowCursor(YES);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) standardcursor: (int)style : (void **)cid
|
|
|
|
|
{
|
2004-12-08 23:57:06 +00:00
|
|
|
|
HCURSOR hCursor = 0;
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
2003-12-02 23:46:18 +00:00
|
|
|
|
NSDebugLLog(@"WTrace", @"standardcursor: %d", style);
|
2002-04-21 22:51:21 +00:00
|
|
|
|
switch (style)
|
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
case GSArrowCursor:
|
|
|
|
|
hCursor = LoadCursor(NULL, IDC_ARROW);
|
|
|
|
|
break;
|
|
|
|
|
case GSIBeamCursor:
|
|
|
|
|
hCursor = LoadCursor(NULL, IDC_IBEAM);
|
|
|
|
|
break;
|
|
|
|
|
case GSCrosshairCursor:
|
|
|
|
|
hCursor = LoadCursor(NULL, IDC_CROSS);
|
|
|
|
|
break;
|
|
|
|
|
case GSPointingHandCursor:
|
|
|
|
|
hCursor = LoadCursor(NULL, IDC_HAND);
|
|
|
|
|
break;
|
|
|
|
|
case GSResizeLeftRightCursor:
|
|
|
|
|
hCursor = LoadCursor(NULL, IDC_SIZEWE);
|
|
|
|
|
break;
|
|
|
|
|
case GSResizeUpDownCursor:
|
|
|
|
|
hCursor = LoadCursor(NULL, IDC_SIZENS);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return;
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
*cid = (void*)hCursor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) imagecursor: (NSPoint)hotp : (int) w : (int) h
|
2005-01-21 20:49:29 +00:00
|
|
|
|
: (int)colors : (const unsigned char *)image : (void **)cid
|
2002-04-21 22:51:21 +00:00
|
|
|
|
{
|
|
|
|
|
/*
|
2005-09-14 15:48:11 +00:00
|
|
|
|
HCURSOR cur;
|
|
|
|
|
BYTE *and;
|
|
|
|
|
BYTE *xor;
|
|
|
|
|
|
|
|
|
|
xor = image;
|
|
|
|
|
cur = CreateCursor(hinstance, (int)hotp.x, (int)hotp.y, (int)w, (int)h, and, xor);
|
|
|
|
|
*cid = (void*)hCursor;
|
|
|
|
|
*/
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setcursorcolor: (NSColor *)fg : (NSColor *)bg : (void*) cid
|
|
|
|
|
{
|
|
|
|
|
/* FIXME The colour is currently ignored
|
2005-09-14 15:48:11 +00:00
|
|
|
|
if (fg != nil)
|
|
|
|
|
{
|
|
|
|
|
ICONINFO iconinfo;
|
|
|
|
|
|
|
|
|
|
if (GetIconInfo((HCURSOR)cid, &iconinfo))
|
|
|
|
|
{
|
|
|
|
|
iconinfo.hbmColor = ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
SetCursor((HCURSOR)cid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
// static keyboard/mouse methods >into a subclass some day
|
|
|
|
|
|
|
|
|
|
static unichar
|
|
|
|
|
process_char(WPARAM wParam, unsigned *eventModifierFlags)
|
|
|
|
|
{
|
|
|
|
|
switch (wParam)
|
2002-04-21 22:51:21 +00:00
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
case VK_RETURN: return NSCarriageReturnCharacter;
|
|
|
|
|
case VK_TAB: return NSTabCharacter;
|
|
|
|
|
case VK_ESCAPE: return 0x1b;
|
|
|
|
|
case VK_BACK: return NSBackspaceCharacter;
|
|
|
|
|
|
|
|
|
|
/* The following keys need to be reported as function keys */
|
|
|
|
|
#define WIN_FUNCTIONKEY \
|
|
|
|
|
*eventModifierFlags = *eventModifierFlags | NSFunctionKeyMask;
|
|
|
|
|
case VK_F1: WIN_FUNCTIONKEY return NSF1FunctionKey;
|
|
|
|
|
case VK_F2: WIN_FUNCTIONKEY return NSF2FunctionKey;
|
|
|
|
|
case VK_F3: WIN_FUNCTIONKEY return NSF3FunctionKey;
|
|
|
|
|
case VK_F4: WIN_FUNCTIONKEY return NSF4FunctionKey;
|
|
|
|
|
case VK_F5: WIN_FUNCTIONKEY return NSF5FunctionKey;
|
|
|
|
|
case VK_F6: WIN_FUNCTIONKEY return NSF6FunctionKey;
|
|
|
|
|
case VK_F7: WIN_FUNCTIONKEY return NSF7FunctionKey;
|
|
|
|
|
case VK_F8: WIN_FUNCTIONKEY return NSF8FunctionKey;
|
|
|
|
|
case VK_F9: WIN_FUNCTIONKEY return NSF9FunctionKey;
|
|
|
|
|
case VK_F10: WIN_FUNCTIONKEY return NSF10FunctionKey;
|
|
|
|
|
case VK_F11: WIN_FUNCTIONKEY return NSF12FunctionKey;
|
|
|
|
|
case VK_F12: WIN_FUNCTIONKEY return NSF12FunctionKey;
|
|
|
|
|
case VK_F13: WIN_FUNCTIONKEY return NSF13FunctionKey;
|
|
|
|
|
case VK_F14: WIN_FUNCTIONKEY return NSF14FunctionKey;
|
|
|
|
|
case VK_F15: WIN_FUNCTIONKEY return NSF15FunctionKey;
|
|
|
|
|
case VK_F16: WIN_FUNCTIONKEY return NSF16FunctionKey;
|
|
|
|
|
case VK_F17: WIN_FUNCTIONKEY return NSF17FunctionKey;
|
|
|
|
|
case VK_F18: WIN_FUNCTIONKEY return NSF18FunctionKey;
|
|
|
|
|
case VK_F19: WIN_FUNCTIONKEY return NSF19FunctionKey;
|
|
|
|
|
case VK_F20: WIN_FUNCTIONKEY return NSF20FunctionKey;
|
|
|
|
|
case VK_F21: WIN_FUNCTIONKEY return NSF21FunctionKey;
|
|
|
|
|
case VK_F22: WIN_FUNCTIONKEY return NSF22FunctionKey;
|
|
|
|
|
case VK_F23: WIN_FUNCTIONKEY return NSF23FunctionKey;
|
|
|
|
|
case VK_F24: WIN_FUNCTIONKEY return NSF24FunctionKey;
|
|
|
|
|
|
|
|
|
|
case VK_DELETE: WIN_FUNCTIONKEY return NSDeleteFunctionKey;
|
|
|
|
|
case VK_HOME: WIN_FUNCTIONKEY return NSHomeFunctionKey;
|
|
|
|
|
case VK_LEFT: WIN_FUNCTIONKEY return NSLeftArrowFunctionKey;
|
|
|
|
|
case VK_RIGHT: WIN_FUNCTIONKEY return NSRightArrowFunctionKey;
|
|
|
|
|
case VK_UP: WIN_FUNCTIONKEY return NSUpArrowFunctionKey;
|
|
|
|
|
case VK_DOWN: WIN_FUNCTIONKEY return NSDownArrowFunctionKey;
|
|
|
|
|
case VK_PRIOR: WIN_FUNCTIONKEY return NSPrevFunctionKey;
|
|
|
|
|
case VK_NEXT: WIN_FUNCTIONKEY return NSNextFunctionKey;
|
|
|
|
|
case VK_END: WIN_FUNCTIONKEY return NSEndFunctionKey;
|
|
|
|
|
//case VK_BEGIN: WIN_FUNCTIONKEY return NSBeginFunctionKey;
|
|
|
|
|
case VK_SELECT: WIN_FUNCTIONKEY return NSSelectFunctionKey;
|
|
|
|
|
case VK_PRINT: WIN_FUNCTIONKEY return NSPrintFunctionKey;
|
|
|
|
|
case VK_EXECUTE: WIN_FUNCTIONKEY return NSExecuteFunctionKey;
|
|
|
|
|
case VK_INSERT: WIN_FUNCTIONKEY return NSInsertFunctionKey;
|
|
|
|
|
case VK_HELP: WIN_FUNCTIONKEY return NSHelpFunctionKey;
|
|
|
|
|
case VK_CANCEL: WIN_FUNCTIONKEY return NSBreakFunctionKey;
|
|
|
|
|
//case VK_MODECHANGE: WIN_FUNCTIONKEY return NSModeSwitchFunctionKey;
|
|
|
|
|
case VK_SCROLL: WIN_FUNCTIONKEY return NSScrollLockFunctionKey;
|
|
|
|
|
case VK_PAUSE: WIN_FUNCTIONKEY return NSPauseFunctionKey;
|
|
|
|
|
case VK_OEM_CLEAR: WIN_FUNCTIONKEY return NSClearDisplayFunctionKey;
|
|
|
|
|
#undef WIN_FUNCTIONKEY
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
2005-09-14 15:48:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NSEvent*
|
2006-09-12 19:53:46 +00:00
|
|
|
|
process_key_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
2005-09-14 15:48:11 +00:00
|
|
|
|
NSEventType eventType)
|
|
|
|
|
{
|
|
|
|
|
NSEvent *event;
|
|
|
|
|
BOOL repeat;
|
|
|
|
|
DWORD pos;
|
|
|
|
|
NSPoint eventLocation;
|
|
|
|
|
unsigned int eventFlags;
|
|
|
|
|
NSTimeInterval time;
|
|
|
|
|
LONG ltime;
|
|
|
|
|
unichar unicode[5];
|
|
|
|
|
unsigned int scan;
|
|
|
|
|
int result;
|
|
|
|
|
BYTE keyState[256];
|
|
|
|
|
NSString *keys, *ukeys;
|
|
|
|
|
NSGraphicsContext *gcontext;
|
|
|
|
|
unichar uChar;
|
|
|
|
|
|
|
|
|
|
/* FIXME: How do you guarentee a context is associated with an event? */
|
|
|
|
|
gcontext = GSCurrentContext();
|
|
|
|
|
|
|
|
|
|
repeat = (lParam & 0xFFFF) != 0;
|
|
|
|
|
|
|
|
|
|
pos = GetMessagePos();
|
2005-10-30 07:35:52 +00:00
|
|
|
|
eventLocation
|
2006-09-12 19:53:46 +00:00
|
|
|
|
= MSWindowPointToGS(svr, hwnd, GET_X_LPARAM(pos), GET_Y_LPARAM(pos));
|
2005-09-14 15:48:11 +00:00
|
|
|
|
|
|
|
|
|
ltime = GetMessageTime();
|
|
|
|
|
time = ltime / 1000;
|
|
|
|
|
|
|
|
|
|
GetKeyboardState(keyState);
|
|
|
|
|
eventFlags = 0;
|
|
|
|
|
if (keyState[VK_CONTROL] & 128)
|
|
|
|
|
eventFlags |= NSControlKeyMask;
|
|
|
|
|
if (keyState[VK_SHIFT] & 128)
|
|
|
|
|
eventFlags |= NSShiftKeyMask;
|
|
|
|
|
if (keyState[VK_CAPITAL] & 128)
|
|
|
|
|
eventFlags |= NSShiftKeyMask;
|
|
|
|
|
if (keyState[VK_MENU] & 128)
|
|
|
|
|
eventFlags |= NSAlternateKeyMask;
|
2006-10-03 18:54:22 +00:00
|
|
|
|
if (keyState[VK_HELP] & 128)
|
|
|
|
|
eventFlags |= NSHelpKeyMask;
|
2005-09-14 15:48:11 +00:00
|
|
|
|
if ((keyState[VK_LWIN] & 128) || (keyState[VK_RWIN] & 128))
|
|
|
|
|
eventFlags |= NSCommandKeyMask;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(wParam)
|
|
|
|
|
{
|
2005-10-30 07:35:52 +00:00
|
|
|
|
case VK_SHIFT:
|
|
|
|
|
case VK_CAPITAL:
|
|
|
|
|
case VK_CONTROL:
|
|
|
|
|
case VK_MENU:
|
2006-10-03 18:54:22 +00:00
|
|
|
|
case VK_HELP:
|
2005-10-30 07:35:52 +00:00
|
|
|
|
case VK_NUMLOCK:
|
|
|
|
|
eventType = NSFlagsChanged;
|
|
|
|
|
break;
|
|
|
|
|
case VK_NUMPAD0:
|
|
|
|
|
case VK_NUMPAD1:
|
|
|
|
|
case VK_NUMPAD2:
|
|
|
|
|
case VK_NUMPAD3:
|
|
|
|
|
case VK_NUMPAD4:
|
|
|
|
|
case VK_NUMPAD5:
|
|
|
|
|
case VK_NUMPAD6:
|
|
|
|
|
case VK_NUMPAD7:
|
|
|
|
|
case VK_NUMPAD8:
|
|
|
|
|
case VK_NUMPAD9:
|
|
|
|
|
eventFlags |= NSNumericPadKeyMask;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2005-09-14 15:48:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
2005-09-14 15:48:11 +00:00
|
|
|
|
uChar = process_char(wParam, &eventFlags);
|
|
|
|
|
if (uChar)
|
|
|
|
|
{
|
|
|
|
|
keys = [NSString stringWithCharacters: &uChar length: 1];
|
|
|
|
|
ukeys = [NSString stringWithCharacters: &uChar length: 1];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
scan = ((lParam >> 16) & 0xFF);
|
|
|
|
|
//NSLog(@"Got key code %d %d", scan, wParam);
|
|
|
|
|
result = ToUnicode(wParam, scan, keyState, unicode, 5, 0);
|
|
|
|
|
//NSLog(@"To Unicode resulted in %d with %d", result, unicode[0]);
|
|
|
|
|
if (result == -1)
|
|
|
|
|
{
|
|
|
|
|
// A non spacing accent key was found, we still try to use the result
|
|
|
|
|
result = 1;
|
|
|
|
|
}
|
|
|
|
|
keys = [NSString stringWithCharacters: unicode length: result];
|
|
|
|
|
// Now switch modifiers off
|
|
|
|
|
keyState[VK_LCONTROL] = 0;
|
|
|
|
|
keyState[VK_RCONTROL] = 0;
|
|
|
|
|
keyState[VK_LMENU] = 0;
|
|
|
|
|
keyState[VK_RMENU] = 0;
|
|
|
|
|
result = ToUnicode(wParam, scan, keyState, unicode, 5, 0);
|
|
|
|
|
//NSLog(@"To Unicode resulted in %d with %d", result, unicode[0]);
|
|
|
|
|
if (result == -1)
|
2002-04-21 22:51:21 +00:00
|
|
|
|
{
|
2005-09-14 15:48:11 +00:00
|
|
|
|
// A non spacing accent key was found, we still try to use the result
|
|
|
|
|
result = 1;
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
2005-09-14 15:48:11 +00:00
|
|
|
|
ukeys = [NSString stringWithCharacters: unicode length: result];
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-09-14 15:48:11 +00:00
|
|
|
|
event = [NSEvent keyEventWithType: eventType
|
|
|
|
|
location: eventLocation
|
|
|
|
|
modifierFlags: eventFlags
|
|
|
|
|
timestamp: time
|
|
|
|
|
windowNumber: (int)hwnd
|
|
|
|
|
context: gcontext
|
|
|
|
|
characters: keys
|
|
|
|
|
charactersIgnoringModifiers: ukeys
|
|
|
|
|
isARepeat: repeat
|
|
|
|
|
keyCode: wParam];
|
|
|
|
|
|
|
|
|
|
return event;
|
2002-04-21 22:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-09-14 15:48:11 +00:00
|
|
|
|
static NSEvent*
|
2006-09-12 19:53:46 +00:00
|
|
|
|
process_mouse_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
2005-09-14 15:48:11 +00:00
|
|
|
|
NSEventType eventType)
|
|
|
|
|
{
|
|
|
|
|
NSEvent *event;
|
|
|
|
|
NSPoint eventLocation;
|
|
|
|
|
unsigned int eventFlags;
|
|
|
|
|
NSTimeInterval time;
|
|
|
|
|
LONG ltime;
|
|
|
|
|
DWORD tick;
|
|
|
|
|
NSGraphicsContext *gcontext;
|
|
|
|
|
short deltaY = 0;
|
|
|
|
|
static int clickCount = 1;
|
|
|
|
|
static LONG lastTime = 0;
|
|
|
|
|
|
|
|
|
|
gcontext = GSCurrentContext();
|
2006-09-12 19:53:46 +00:00
|
|
|
|
eventLocation = MSWindowPointToGS(svr, hwnd, GET_X_LPARAM(lParam),
|
2005-09-14 15:48:11 +00:00
|
|
|
|
GET_Y_LPARAM(lParam));
|
|
|
|
|
ltime = GetMessageTime();
|
|
|
|
|
time = ltime / 1000;
|
|
|
|
|
tick = GetTickCount();
|
|
|
|
|
eventFlags = 0;
|
|
|
|
|
if (wParam & MK_CONTROL)
|
|
|
|
|
{
|
|
|
|
|
eventFlags |= NSControlKeyMask;
|
|
|
|
|
}
|
|
|
|
|
if (wParam & MK_SHIFT)
|
|
|
|
|
{
|
|
|
|
|
eventFlags |= NSShiftKeyMask;
|
|
|
|
|
}
|
|
|
|
|
if (GetKeyState(VK_MENU) < 0)
|
|
|
|
|
{
|
|
|
|
|
eventFlags |= NSAlternateKeyMask;
|
|
|
|
|
}
|
2006-10-03 18:54:22 +00:00
|
|
|
|
if (GetKeyState(VK_HELP) < 0)
|
|
|
|
|
{
|
|
|
|
|
eventFlags |= NSHelpKeyMask;
|
|
|
|
|
}
|
2005-09-14 15:48:11 +00:00
|
|
|
|
// What about other modifiers?
|
|
|
|
|
|
|
|
|
|
if (eventType == NSScrollWheel)
|
|
|
|
|
{
|
|
|
|
|
deltaY = GET_WHEEL_DELTA_WPARAM(wParam) / 120;
|
|
|
|
|
//NSLog(@"Scroll event with delat %d", deltaY);
|
|
|
|
|
}
|
|
|
|
|
else if (eventType == NSMouseMoved)
|
|
|
|
|
{
|
|
|
|
|
if (wParam & MK_LBUTTON)
|
|
|
|
|
{
|
|
|
|
|
eventType = NSLeftMouseDragged;
|
|
|
|
|
}
|
|
|
|
|
else if (wParam & MK_RBUTTON)
|
|
|
|
|
{
|
|
|
|
|
eventType = NSRightMouseDragged;
|
|
|
|
|
}
|
|
|
|
|
else if (wParam & MK_MBUTTON)
|
|
|
|
|
{
|
|
|
|
|
eventType = NSOtherMouseDragged;
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-10-03 18:54:22 +00:00
|
|
|
|
else if ((eventType == NSLeftMouseDown)
|
|
|
|
|
|| (eventType == NSRightMouseDown)
|
|
|
|
|
|| (eventType == NSOtherMouseDown))
|
2005-09-14 15:48:11 +00:00
|
|
|
|
{
|
|
|
|
|
if (lastTime + GetDoubleClickTime() > ltime)
|
|
|
|
|
{
|
|
|
|
|
clickCount += 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
clickCount = 1;
|
|
|
|
|
lastTime = ltime;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
event = [NSEvent mouseEventWithType: eventType
|
|
|
|
|
location: eventLocation
|
|
|
|
|
modifierFlags: eventFlags
|
|
|
|
|
timestamp: time
|
|
|
|
|
windowNumber: (int)hwnd
|
|
|
|
|
context: gcontext
|
|
|
|
|
eventNumber: tick
|
|
|
|
|
clickCount: clickCount
|
|
|
|
|
pressure: 1.0
|
|
|
|
|
buttonNumber: 0 /* FIXME */
|
|
|
|
|
deltaX: 0.
|
|
|
|
|
deltaY: deltaY
|
|
|
|
|
deltaZ: 0.];
|
|
|
|
|
|
|
|
|
|
return event;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
|
|
|
|
WPARAM wParam, LPARAM lParam)
|
|
|
|
|
{
|
|
|
|
|
WIN32Server *ctxt = (WIN32Server *)GSCurrentServer();
|
|
|
|
|
|
|
|
|
|
return [ctxt windowEventProc: hwnd : uMsg : wParam : lParam];
|
|
|
|
|
}
|
|
|
|
|
// end static Keyboard mouse
|
|
|
|
|
|
|
|
|
|
|
2002-04-21 22:51:21 +00:00
|
|
|
|
|
|
|
|
|
static void
|
2006-09-12 19:53:46 +00:00
|
|
|
|
validateWindow(WIN32Server *svr, HWND hwnd, RECT rect)
|
2002-04-21 22:51:21 +00:00
|
|
|
|
{
|
|
|
|
|
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong((HWND)hwnd, GWL_USERDATA);
|
|
|
|
|
|
|
|
|
|
if (win->useHDC)
|
|
|
|
|
{
|
|
|
|
|
HDC hdc = GetDC((HWND)hwnd);
|
|
|
|
|
WINBOOL result;
|
|
|
|
|
|
|
|
|
|
result = BitBlt(hdc, rect.left, rect.top,
|
|
|
|
|
(rect.right - rect.left), (rect.bottom - rect.top),
|
|
|
|
|
win->hdc, rect.left, rect.top, SRCCOPY);
|
|
|
|
|
if (!result)
|
2002-06-02 12:21:57 +00:00
|
|
|
|
{
|
|
|
|
|
NSLog(@"validated window %d %@", hwnd,
|
2006-09-12 19:53:46 +00:00
|
|
|
|
NSStringFromRect(MSWindowRectToGS(svr, (HWND)hwnd, rect)));
|
2002-06-02 12:21:57 +00:00
|
|
|
|
NSLog(@"validateWindow failed %d", GetLastError());
|
2005-09-14 15:48:11 +00:00
|
|
|
|
}
|
2002-04-21 22:51:21 +00:00
|
|
|
|
ReleaseDC((HWND)hwnd, hdc);
|
|
|
|
|
}
|
|
|
|
|
}
|