Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Initial work on X11 window code in.
  • Loading branch information
slouken committed Jul 27, 2006
1 parent 7dce748 commit 63d4e0b
Show file tree
Hide file tree
Showing 13 changed files with 1,243 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/video/cocoa/SDL_cocoawindow.h
Expand Up @@ -66,7 +66,7 @@ struct SDL_WindowData
{
SDL_WindowID windowID;
NSWindow *window;
BOOL created;
SDL_bool created;
Cocoa_WindowListener *listener;
struct SDL_VideoData *videodata;
};
Expand Down
9 changes: 5 additions & 4 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -242,9 +242,10 @@ - (void)keyUp:(NSEvent *)theEvent
@end

static int
SetupWindowData(SDL_Window * window, NSWindow *nswindow, BOOL created)
SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
{
NSAutoreleasePool *pool;
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *data;

/* Allocate the window data */
Expand All @@ -256,7 +257,7 @@ - (void)keyUp:(NSEvent *)theEvent
data->windowID = window->id;
data->window = nswindow;
data->created = created;
data->videodata = (SDL_VideoData *) SDL_GetVideoDevice()->driverdata;
data->videodata = videodata;

pool = [[NSAutoreleasePool alloc] init];

Expand Down Expand Up @@ -380,7 +381,7 @@ - (void)keyUp:(NSEvent *)theEvent

[pool release];

if (SetupWindowData(window, nswindow, YES) < 0) {
if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
[nswindow release];
return -1;
}
Expand Down Expand Up @@ -413,7 +414,7 @@ - (void)keyUp:(NSEvent *)theEvent

[pool release];

return SetupWindowData(window, nswindow, NO);
return SetupWindowData(_this, window, nswindow, SDL_FALSE);
}

void
Expand Down
25 changes: 12 additions & 13 deletions src/video/win32/SDL_win32events.c
Expand Up @@ -22,7 +22,6 @@
#include "SDL_config.h"

#include "SDL_win32video.h"
#include "SDL_version.h"
#include "SDL_syswm.h"
#include "SDL_vkeys.h"
#include "../../events/SDL_events_c.h"
Expand Down Expand Up @@ -393,6 +392,18 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
SDL_WindowData *data;

/* Send a SDL_SYSWMEVENT if the application wants them */
if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
SDL_SysWMmsg wmmsg;

SDL_VERSION(&wmmsg.version);
wmmsg.hwnd = hwnd;
wmmsg.msg = msg;
wmmsg.wParam = wParam;
wmmsg.lParam = lParam;
SDL_SendSysWMEvent(&wmmsg);
}

/* Get the window data for the window */
data = (SDL_WindowData *) GetProp(hwnd, TEXT("SDL_WindowData"));
if (!data) {
Expand All @@ -412,18 +423,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
#endif

/* Send a SDL_SYSWMEVENT if the application wants them */
if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
SDL_SysWMmsg wmmsg;

SDL_VERSION(&wmmsg.version);
wmmsg.hwnd = hwnd;
wmmsg.msg = msg;
wmmsg.wParam = wParam;
wmmsg.lParam = lParam;
SDL_SendSysWMEvent(&wmmsg);
}

switch (msg) {

case WM_SHOWWINDOW:
Expand Down
9 changes: 5 additions & 4 deletions src/video/win32/SDL_win32window.c
Expand Up @@ -31,8 +31,9 @@


static int
SetupWindowData(SDL_Window * window, HWND hwnd, BOOL created)
SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
{
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *data;

/* Allocate the window data */
Expand All @@ -46,7 +47,7 @@ SetupWindowData(SDL_Window * window, HWND hwnd, BOOL created)
data->hdc = GetDC(hwnd);
data->created = created;
data->mouse_pressed = SDL_FALSE;
data->videodata = (SDL_VideoData *) SDL_GetVideoDevice()->driverdata;
data->videodata = videodata;

/* Associate the data with the window */
if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) {
Expand Down Expand Up @@ -208,7 +209,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
return -1;
}

if (SetupWindowData(window, hwnd, TRUE) < 0) {
if (SetupWindowData(_this, window, hwnd, SDL_TRUE) < 0) {
DestroyWindow(hwnd);
return -1;
}
Expand Down Expand Up @@ -245,7 +246,7 @@ WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
SDL_stack_free(title);
}

if (SetupWindowData(window, hwnd, FALSE) < 0) {
if (SetupWindowData(_this, window, hwnd, SDL_FALSE) < 0) {
return -1;
}
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/video/win32/SDL_win32window.h
Expand Up @@ -30,7 +30,7 @@ typedef struct
HWND hwnd;
HDC hdc;
WNDPROC wndproc;
BOOL created;
SDL_bool created;
int mouse_pressed;
struct SDL_VideoData *videodata;
} SDL_WindowData;
Expand Down

0 comments on commit 63d4e0b

Please sign in to comment.