General cleanup of win32 code.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@26066 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2008-02-14 22:26:00 +00:00
parent f801684505
commit 4d00d5253c
9 changed files with 570 additions and 889 deletions

View file

@ -74,7 +74,6 @@ DWORD windowStyleForGSStyle(unsigned int style);
typedef struct w32serverFlags { typedef struct w32serverFlags {
int _last_WM_ACTIVATE; int _last_WM_ACTIVATE;
int eventQueCount;
int menuRef; // reference to menu window int menuRef; // reference to menu window
unsigned int currentGS_Style; // what style is current event window unsigned int currentGS_Style; // what style is current event window
BOOL HOLD_MENU_FOR_MOVE; // override GS move event on hide BOOL HOLD_MENU_FOR_MOVE; // override GS move event on hide
@ -125,13 +124,27 @@ typedef struct w32serverFlags {
- (void) setFlagsforEventLoop: (HWND)hwnd; - (void) setFlagsforEventLoop: (HWND)hwnd;
// declared but should be implimented in a subclass window server (subclass resposibility) - (DWORD) windowStyleForGSStyle: (unsigned int) style;
- (void) resizeBackingStoreFor: (HWND)hwnd;
- (void) resetForGSWindowStyle: (HWND)hwnd w32Style:(DWORD)aStyle;
@end
@interface WIN32Server (w32_activate)
- (LRESULT) decodeWM_ACTIVEParams: (WPARAM)wParam : (LPARAM)lParam - (LRESULT) decodeWM_ACTIVEParams: (WPARAM)wParam : (LPARAM)lParam
: (HWND)hwnd; : (HWND)hwnd;
- (LRESULT) decodeWM_ACTIVEAPPParams: (HWND)hwnd : (WPARAM)wParam - (LRESULT) decodeWM_ACTIVEAPPParams: (HWND)hwnd : (WPARAM)wParam
: (LPARAM)lParam; : (LPARAM)lParam;
- (void) decodeWM_NCACTIVATEParams: (WPARAM)wParam : (LPARAM)lParam - (void) decodeWM_NCACTIVATEParams: (WPARAM)wParam : (LPARAM)lParam
: (HWND)hwnd; : (HWND)hwnd;
@end
@interface WIN32Server (w32_movesize)
- (LRESULT) decodeWM_SIZEParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam; - (LRESULT) decodeWM_SIZEParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam;
- (LRESULT) decodeWM_MOVEParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam; - (LRESULT) decodeWM_MOVEParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam;
- (void) decodeWM_NCCALCSIZEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; - (void) decodeWM_NCCALCSIZEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
@ -142,24 +155,39 @@ typedef struct w32serverFlags {
- (LRESULT) decodeWM_MOVINGParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam; - (LRESULT) decodeWM_MOVINGParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam;
- (void) decodeWM_SIZINGParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam; - (void) decodeWM_SIZINGParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam;
@end
@interface WIN32Server (w32_create)
- (LRESULT) decodeWM_NCCREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; - (LRESULT) decodeWM_NCCREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (LRESULT) decodeWM_CREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; - (LRESULT) decodeWM_CREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (DWORD) windowStyleForGSStyle: (unsigned int) style; @end
@interface WIN32Server (w32_windowdisplay)
- (void) decodeWM_SHOWWINDOWParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; - (void) decodeWM_SHOWWINDOWParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_NCPAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; - (void) decodeWM_NCPAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (LRESULT) decodeWM_ERASEBKGNDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; - (LRESULT) decodeWM_ERASEBKGNDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_PAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; - (void) decodeWM_PAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_SYNCPAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; - (void) decodeWM_SYNCPAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_CAPTURECHANGEDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; - (void) decodeWM_CAPTURECHANGEDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
//- (HICON) decodeWM_GETICONParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; - (HICON) decodeWM_GETICONParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) resizeBackingStoreFor: (HWND)hwnd; - (HICON) decodeWM_SETICONParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
@end
@interface WIN32Server (w32_text_focus)
//- (LRESULT) decodeWM_SETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; //- (LRESULT) decodeWM_SETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (LRESULT) decodeWM_SETFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; - (LRESULT) decodeWM_SETFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_KILLFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; - (void) decodeWM_KILLFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_GETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; - (void) decodeWM_GETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
@end
@interface WIN32Server (w32_General)
- (void) decodeWM_CLOSEParams: (WPARAM)wParam :(LPARAM)lParam :(HWND)hwnd; - (void) decodeWM_CLOSEParams: (WPARAM)wParam :(LPARAM)lParam :(HWND)hwnd;
- (void) decodeWM_DESTROYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; - (void) decodeWM_DESTROYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_NCDESTROYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd; - (void) decodeWM_NCDESTROYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;

File diff suppressed because it is too large Load diff

View file

@ -1,128 +0,0 @@
/* WIN32Server - Implements window handling for MSWindows
Copyright (C) 2005 Free Software Foundation, Inc.
Written by: Tom MacSween <macsweent@sympatico.ca>
Date August 2005
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 Lesser General Public
License as published by the Free Software Foundation; either
version 3 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _W32_EVENTS_h_INCLUDE
#define _W32_EVENTS_h_INCLUDE
#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>
#include <AppKit/AppKitExceptions.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSGraphics.h>
#include <AppKit/NSMenu.h>
#include <AppKit/NSMenuView.h>
#include <AppKit/NSWindow.h>
#include <AppKit/NSView.h>
#include <AppKit/NSEvent.h>
#include <AppKit/NSCursor.h>
#include <AppKit/NSText.h>
#include <AppKit/DPSOperators.h>
#include "win32/WIN32Server.h"
#include "win32/WIN32Geometry.h"
@interface WIN32Server (w32_notifications)
- (void) ApplicationDidFinishLaunching: (NSNotification*)aNotification;
- (void) ApplicationWillFinishLaunching: (NSNotification*)aNotification;
- (void) ApplicationWillHideNotification: (NSNotification*)aNotification;
- (void) WindowWillMiniaturizeNotification:(NSNotification*)aNotification;
- (void) MenuWillTearOff: (NSNotification*)aNotification;
- (void) MenuwillPopUP: (NSNotification*)aNotification;
- (void) WindowDidCreateWindow: (NSNotification*)aNotification;
@end
@interface WIN32Server (w32_activate)
- (LRESULT) decodeWM_ACTIVEParams: (WPARAM)wParam :(LPARAM)lParam : (HWND)hwnd;
- (LRESULT) decodeWM_ACTIVEAPPParams: (HWND)hwnd :(WPARAM)wParam : (LPARAM)lParam;
- (void) decodeWM_NCACTIVATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
@end
@interface WIN32Server (w32_movesize)
- (LRESULT) decodeWM_SIZEParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam;
- (LRESULT) decodeWM_MOVEParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam;
- (void) decodeWM_NCCALCSIZEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_WINDOWPOSCHANGINGParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_WINDOWPOSCHANGEDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (LRESULT) decodeWM_GETMINMAXINFOParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (LRESULT) decodeWM_EXITSIZEMOVEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_SIZINGParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam;
- (LRESULT) decodeWM_MOVINGParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam;
@end
@interface WIN32Server (w32_create)
- (LRESULT) decodeWM_NCCREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (LRESULT) decodeWM_CREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
@end
@interface WIN32Server (w32_windowdisplay)
- (DWORD) windowStyleForGSStyle: (unsigned int) style;
- (void) decodeWM_SHOWWINDOWParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_NCPAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (LRESULT) decodeWM_ERASEBKGNDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_PAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_SYNCPAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_CAPTURECHANGEDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (HICON) decodeWM_GETICONParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (HICON) decodeWM_SETICONParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) resizeBackingStoreFor: (HWND)hwnd;
@end
@interface WIN32Server (w32_text_focus)
//- (LRESULT) decodeWM_SETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (LRESULT) decodeWM_SETFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_KILLFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_GETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
@end
//small but useful events
@interface WIN32Server (w32_General)
- (void) decodeWM_CLOSEParams: (WPARAM)wParam :(LPARAM)lParam :(HWND)hwnd;
- (void) decodeWM_DESTROYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_NCDESTROYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_QUERYOPENParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_SYSCOMMANDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) decodeWM_COMMANDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
- (void) resetForGSWindowStyle: (HWND)hwnd w32Style:(DWORD)aStyle;
//- (LRESULT) decodeWM_LBUTTONDOWNParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
@end
#endif //_W32_EVENTS_h_INCLUDE

View file

@ -24,101 +24,102 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <AppKit/NSImage.h> #include <AppKit/NSEvent.h>
#include <AppKit/NSBitmapImageRep.h> #include <AppKit/NSWindow.h>
#include <Foundation/NSData.h> #include "win32/WIN32Server.h"
#include "w32_Events.h" #include "win32/WIN32Geometry.h"
@implementation WIN32Server (w32_activate) @implementation WIN32Server (w32_activate)
- (LRESULT) decodeWM_ACTIVEParams:(WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd - (LRESULT) decodeWM_ACTIVEParams:(WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
{ {
// decode our params // decode our params
flags._last_WM_ACTIVATE = LOWORD(wParam); flags._last_WM_ACTIVATE = LOWORD(wParam);
//int minimized = HIWORD(wParam); //int minimized = HIWORD(wParam);
switch (flags._last_WM_ACTIVATE) switch (flags._last_WM_ACTIVATE)
{ {
case WA_ACTIVE: //deactivate case WA_ACTIVE: //deactivate
{ {
// future implimentation if needed // future implimentation if needed
} }
break; break;
case WA_CLICKACTIVE: //order back the window case WA_CLICKACTIVE: //order back the window
{ {
// future implimentation if needed // future implimentation if needed
} }
break; break;
case WA_INACTIVE: // set currentactive and display case WA_INACTIVE: // set currentactive and display
{ {
currentActive=hwnd; currentActive = hwnd;
[EVENT_WINDOW(lParam) display]; [EVENT_WINDOW(lParam) display];
} }
break; break;
default: default:
break; break;
} }
return 0; return 0;
} }
- (LRESULT) decodeWM_ACTIVEAPPParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam - (LRESULT) decodeWM_ACTIVEAPPParams: (HWND)hwnd : (WPARAM)wParam
: (LPARAM)lParam
{ {
BOOL active=[NSApp isActive]; BOOL active = [NSApp isActive];
switch ((int)wParam) switch ((int)wParam)
{ {
case TRUE: case TRUE:
{ {
if (active==YES) if (active==YES)
{ {
if (flags._is_menu==YES) // have menu and app active if (flags._is_menu==YES) // have menu and app active
{ {
// future implimentation if needed // future implimentation if needed
} }
else // Not a menu and app is active else // Not a menu and app is active
{ {
// window is Visable // window is Visable
if ([EVENT_WINDOW(hwnd) isVisible]==YES) if ([EVENT_WINDOW(hwnd) isVisible]==YES)
{ {
// future implimentation if needed // future implimentation if needed
} }
else else
{ {
// future implimentation if needed // future implimentation if needed
} }
} }
} }
else // app is not active else // app is not active
{ {
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
flags._eventHandled=YES; flags._eventHandled=YES;
} }
} }
break; break;
case FALSE: case FALSE:
{ {
if (flags._is_menu==YES) if (flags._is_menu==YES)
{ {
// future implimentation if needed // future implimentation if needed
} }
else else
{ {
// future implimentation if needed // future implimentation if needed
} }
} }
break; break;
default: default:
break; break;
} }
return 0; return 0;
} }
- (void) decodeWM_NCACTIVATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd - (void) decodeWM_NCACTIVATEParams: (WPARAM)wParam : (LPARAM)lParam
: (HWND)hwnd
{ {
} }

View file

@ -26,20 +26,22 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include "w32_Events.h" #include <AppKit/NSEvent.h>
#include <AppKit/NSWindow.h>
#include "win32/WIN32Server.h"
#include "win32/WIN32Geometry.h"
@implementation WIN32Server (w32_create) @implementation WIN32Server (w32_create)
- (LRESULT) decodeWM_NCCREATEParams: (WPARAM)wParam : (LPARAM)lParam
- (LRESULT) decodeWM_NCCREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd : (HWND)hwnd
{ {
return TRUE; return TRUE;
} }
- (LRESULT) decodeWM_CREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd - (LRESULT) decodeWM_CREATEParams: (WPARAM)wParam : (LPARAM)lParam
: (HWND)hwnd
{ {
//Created by original author
WIN_INTERN *win; WIN_INTERN *win;
NSBackingStoreType type = (NSBackingStoreType)((LPCREATESTRUCT)lParam)->lpCreateParams; NSBackingStoreType type = (NSBackingStoreType)((LPCREATESTRUCT)lParam)->lpCreateParams;
@ -61,7 +63,7 @@
hdc = GetDC(hwnd); hdc = GetDC(hwnd);
hdc2 = CreateCompatibleDC(hdc); hdc2 = CreateCompatibleDC(hdc);
hbitmap = CreateCompatibleBitmap(hdc, r.right - r.left, hbitmap = CreateCompatibleBitmap(hdc, r.right - r.left,
r.bottom - r.top); r.bottom - r.top);
win->old = SelectObject(hdc2, hbitmap); win->old = SelectObject(hdc2, hbitmap);
win->hdc = hdc2; win->hdc = hdc2;

View file

@ -27,7 +27,10 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include "w32_Events.h" #include <AppKit/NSEvent.h>
#include <AppKit/NSWindow.h>
#include "win32/WIN32Server.h"
#include "win32/WIN32Geometry.h"
@implementation WIN32Server (w32_General) @implementation WIN32Server (w32_General)
@ -130,18 +133,5 @@
- (void) decodeWM_COMMANDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd - (void) decodeWM_COMMANDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
{ {
} }
- (void) resetForGSWindowStyle:(HWND)hwnd w32Style:(DWORD)aStyle
{
// to be completed for styles
LONG result;
ShowWindow(hwnd, SW_HIDE);
SetLastError(0);
result=SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW);
result=SetWindowLong(hwnd, GWL_STYLE, (LONG)aStyle);
// should check error here...
ShowWindow(hwnd, SW_SHOWNORMAL);
}
@end @end

View file

@ -24,7 +24,10 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include "w32_Events.h" #include <AppKit/NSEvent.h>
#include <AppKit/NSWindow.h>
#include "win32/WIN32Server.h"
#include "win32/WIN32Geometry.h"
@implementation WIN32Server (w32_movesize) @implementation WIN32Server (w32_movesize)
@ -34,10 +37,9 @@
NSRect rect; NSRect rect;
RECT r; RECT r;
NSEvent *ev = nil; NSEvent *ev = nil;
GetWindowRect(hwnd, &r); GetWindowRect(hwnd, &r);
rect = MSScreenRectToGS(r, [EVENT_WINDOW(hwnd) styleMask], self); rect = MSScreenRectToGS(r, [EVENT_WINDOW(hwnd) styleMask], self);
eventLocation = rect.origin; eventLocation = rect.origin;
ev = [NSEvent otherEventWithType: NSAppKitDefined ev = [NSEvent otherEventWithType: NSAppKitDefined
@ -55,18 +57,16 @@
{ {
//need native code here? //need native code here?
if (flags.HOLD_MENU_FOR_MOVE==FALSE) if (flags.HOLD_MENU_FOR_MOVE==FALSE)
{ {
[EVENT_WINDOW(hwnd) sendEvent:ev]; [EVENT_WINDOW(hwnd) sendEvent: ev];
} }
} }
else else
{ {
if (flags.HOLD_TRANSIENT_FOR_MOVE==FALSE) if (flags.HOLD_TRANSIENT_FOR_MOVE==FALSE)
[EVENT_WINDOW(hwnd) sendEvent:ev]; [EVENT_WINDOW(hwnd) sendEvent: ev];
} }
ev=nil;
flags.HOLD_MENU_FOR_MOVE=FALSE; flags.HOLD_MENU_FOR_MOVE=FALSE;
flags.HOLD_MINI_FOR_MOVE=FALSE; flags.HOLD_MINI_FOR_MOVE=FALSE;
flags.HOLD_TRANSIENT_FOR_MOVE=FALSE; flags.HOLD_TRANSIENT_FOR_MOVE=FALSE;
@ -82,10 +82,9 @@
NSEvent *ev =nil; NSEvent *ev =nil;
GetWindowRect(hwnd, &r); GetWindowRect(hwnd, &r);
rect = MSScreenRectToGS(r, [EVENT_WINDOW(hwnd) styleMask], self); rect = MSScreenRectToGS(r, [EVENT_WINDOW(hwnd) styleMask], self);
eventLocation = rect.origin; eventLocation = rect.origin;
switch ((int)wParam) switch ((int)wParam)
{ {
case SIZE_MAXHIDE: case SIZE_MAXHIDE:
@ -313,8 +312,8 @@
return TRUE; return TRUE;
} }
@end @end

View file

@ -27,11 +27,13 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include "w32_Events.h" #include <AppKit/NSEvent.h>
#include <AppKit/NSWindow.h>
#include "win32/WIN32Server.h"
#include "win32/WIN32Geometry.h"
@implementation WIN32Server (w32_text_focus) @implementation WIN32Server (w32_text_focus)
//- (LRESULT) decodeWM_SETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd //- (LRESULT) decodeWM_SETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
//{ //{
//printf("WM_SETTEXT\n"); //printf("WM_SETTEXT\n");
@ -48,7 +50,6 @@
- (LRESULT) decodeWM_SETFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd - (LRESULT) decodeWM_SETFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
{ {
// reused from original author (added debug output)
/* This message comes when the window already got focus, so we send a focus /* This message comes when the window already got focus, so we send a focus
in event to the front end, but also mark the window as having current focus in event to the front end, but also mark the window as having current focus
so that the front end doesn't try to focus the window again. */ so that the front end doesn't try to focus the window again. */
@ -69,16 +70,16 @@
else else
{ {
/* We need to do this directly and not send an event to the frontend - /* We need to do this directly and not send an event to the frontend -
that's too slow and allows the window state to get out of sync, that's too slow and allows the window state to get out of sync,
causing bad recursion problems */ causing bad recursion problems */
NSWindow *window = GSWindowWithNumber((int)hwnd); NSWindow *window = GSWindowWithNumber((int)hwnd);
if ([window canBecomeKeyWindow] == YES) if ([window canBecomeKeyWindow] == YES)
{ {
NSDebugLLog(@"Focus", @"Making %d key", win_num); NSDebugLLog(@"Focus", @"Making %d key", win_num);
[window makeKeyWindow]; [window makeKeyWindow];
[window makeMainWindow]; [window makeMainWindow];
[NSApp activateIgnoringOtherApps: YES]; [NSApp activateIgnoringOtherApps: YES];
} }
} }
return 0; return 0;

View file

@ -27,10 +27,11 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include <AppKit/NSEvent.h>
#include "w32_Events.h" #include <AppKit/NSView.h>
#include <AppKit/NSWindow.h>
static void invalidateWindow(WIN32Server *svr, HWND hwnd, RECT rect); #include "win32/WIN32Server.h"
#include "win32/WIN32Geometry.h"
static void static void
invalidateWindow(WIN32Server *svr, HWND hwnd, RECT rect) invalidateWindow(WIN32Server *svr, HWND hwnd, RECT rect)
@ -72,86 +73,6 @@ invalidateWindow(WIN32Server *svr, HWND hwnd, RECT rect)
@implementation WIN32Server (w32_windowdisplay) @implementation WIN32Server (w32_windowdisplay)
/* styles are mapped between the two systems
* I have not changed current inplimentation of mouse or keyboard
* events. */
- (DWORD) windowStyleForGSStyle: (unsigned int) style
{
/*
NSUtilityWindowMask 16
NSDocModalWindowMask 32
NSBorderlessWindowMask 0
NSTitledWindowMask 1
NSClosableWindowMask 2
NSMiniaturizableWindowMask 4
NSResizableWindowMask 8
NSIconWindowMask 64
NSMiniWindowMask 128
NSMenu(style) = NSTitledWindowMask | NSClosableWindowMask =3;
*/
DWORD wstyle = 0;
if ([self handlesWindowDecorations] == NO)
return WS_POPUP;
switch (style)
{
case 0:
wstyle=WS_POPUP;
break;
case NSTitledWindowMask: // 1
wstyle = WS_CAPTION;
break;
case NSClosableWindowMask: // 2
wstyle =WS_CAPTION+WS_SYSMENU;
break;
case NSMiniaturizableWindowMask: //4
wstyle =WS_MINIMIZEBOX+WS_SYSMENU;
break;
case NSResizableWindowMask: // 8
wstyle=WS_SIZEBOX;
case NSMiniWindowMask: //128
case NSIconWindowMask: // 64
wstyle = WS_ICONIC;
break;
//case NSUtilityWindowMask: //16
//case NSDocModalWindowMask: //32
break;
// combinations
case NSTitledWindowMask+NSClosableWindowMask: //3
wstyle =WS_CAPTION+WS_SYSMENU;
break;
case NSTitledWindowMask+NSClosableWindowMask+NSMiniaturizableWindowMask: //7
wstyle =WS_CAPTION+WS_MINIMIZEBOX+WS_SYSMENU;
break;
case NSTitledWindowMask+NSResizableWindowMask: // 9
wstyle = WS_CAPTION+WS_SIZEBOX;
break;
case NSTitledWindowMask+NSClosableWindowMask+NSResizableWindowMask: // 11
wstyle =WS_CAPTION+WS_SIZEBOX+WS_SYSMENU;
break;
case NSTitledWindowMask+NSResizableWindowMask+NSMiniaturizableWindowMask: //13
wstyle = WS_SIZEBOX+WS_MINIMIZEBOX+WS_SYSMENU+WS_CAPTION;
break;
case NSTitledWindowMask+NSClosableWindowMask+NSResizableWindowMask+
NSMiniaturizableWindowMask: //15
wstyle =WS_CAPTION+WS_SIZEBOX+WS_MINIMIZEBOX+WS_SYSMENU;
break;
default:
wstyle =WS_POPUP; //WS_CAPTION+WS_SYSMENU;
break;
}
//NSLog(@"Window wstyle %d for style %d", wstyle, style);
return wstyle;
}
/*deprecated remove from code */
- (void) decodeWM_SHOWWINDOWParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd - (void) decodeWM_SHOWWINDOWParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
{ {
//SW_OTHERUNZOOM //window is being uncovered //SW_OTHERUNZOOM //window is being uncovered
@ -247,44 +168,12 @@ invalidateWindow(WIN32Server *svr, HWND hwnd, RECT rect)
- (HICON) decodeWM_GETICONParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd - (HICON) decodeWM_GETICONParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
{ {
// stub for future dev // stub for future dev
return currentAppIcon; return currentAppIcon;
} }
- (HICON) decodeWM_SETICONParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd - (HICON) decodeWM_SETICONParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
{ {
return currentAppIcon; return currentAppIcon;
}
- (void) resizeBackingStoreFor: (HWND)hwnd
{
RECT r;
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong((HWND)hwnd, GWL_USERDATA);
// FIXME: We should check if the size really did change.
if (win->useHDC)
{
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)hwnd, &r);
hdc = GetDC((HWND)hwnd);
hdc2 = CreateCompatibleDC(hdc);
hbitmap = CreateCompatibleBitmap(hdc, r.right - r.left, r.bottom - r.top);
win->old = SelectObject(hdc2, hbitmap);
win->hdc = hdc2;
ReleaseDC((HWND)hwnd, hdc);
// After resizing the backing store, we need to redraw the window
win->backingStoreEmpty = YES;
}
} }
@end @end