Commit 97c81738 authored by Sam Lantinga's avatar Sam Lantinga

Date: Thu, 16 Jan 2003 13:48:31 +0200

From: "Mike Gorchak"
Subject: All QNX patches

whole patches concerning QNX. Almost all code has been rewritten by Julian
and me. Added initial support for hw overlays in QNX and many many others
fixes.

P.S. This patches has been reviewed by Dave Rempel from QSSL and included in
SDL 1.2.5 distribution, which coming on 3rd party CD for newest 6.2.1
version of QNX, which will be available soon.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40572
parent b38a873c
...@@ -188,14 +188,8 @@ QNX: -= NOT YET SUPPORTED =- ...@@ -188,14 +188,8 @@ QNX: -= NOT YET SUPPORTED =-
The only hardware surface is the primary view surface. The only hardware surface is the primary view surface.
Mouse events don't seem to be working right.
Fullscreen doesn't display correctly. Fullscreen doesn't display correctly.
The software surfaces could use some speed up.
The mouse cursor doesn't look right.
AmigaOS: -= NOT YET SUPPORTED =- AmigaOS: -= NOT YET SUPPORTED =-
The OpenGL support isn't implemented yet. The OpenGL support isn't implemented yet.
......
This diff is collapsed.
...@@ -55,45 +55,8 @@ SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym); ...@@ -55,45 +55,8 @@ SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym);
(idea shamelessly lifted from GII -- thanks guys! :) (idea shamelessly lifted from GII -- thanks guys! :)
*/ */
#if 0
static int ph_KeyRepeat(_THIS, PhKeyEvent_t* keyevent)
{
// PhEvent_t* peekevent;
PhKeyEvent_t* keyEvent;
int repeated;
repeated = 0;
switch (PhEventPeek( peekevent, EVENT_SIZE ))
{
case Ph_EVENT_MSG: {
if(peekevent->type == Ph_EV_KEY)
{
keyEvent = PhGetData( peekevent );
if ( !(Pk_KF_Key_Down & keyEvent->key_flags) &&
(keyEvent->key_cap == keyevent->key_cap) &&
(peekevent->timestamp == event->timestamp)
) {
repeated = 1;
/* PhEventNext( peekevent, EVENT_SIZE ); */
}
}
}
break;
case -1: {
perror( "PhEventPeek failed" );
}
break;
default: /* no events pending */
}
return(repeated);
}
#endif
static int ph_WarpedMotion(_THIS, PhEvent_t *winEvent) static int ph_WarpedMotion(_THIS, PhEvent_t *winEvent)
{ {
/* PhPointerEvent_t *pointer = PhGetData( winEvent ); */
PhRect_t *rect = PhGetRects( winEvent ); PhRect_t *rect = PhGetRects( winEvent );
int centre_x, centre_y; int centre_x, centre_y;
...@@ -111,11 +74,9 @@ static int ph_WarpedMotion(_THIS, PhEvent_t *winEvent) ...@@ -111,11 +74,9 @@ static int ph_WarpedMotion(_THIS, PhEvent_t *winEvent)
/* Move mouse cursor to middle of the window */ /* Move mouse cursor to middle of the window */
PtGetAbsPosition( window, &abs_x, &abs_y ); PtGetAbsPosition( window, &abs_x, &abs_y );
PhMoveCursorAbs( PhInputGroup(NULL), PhMoveCursorAbs(PhInputGroup(NULL), abs_x + centre_x, abs_y + centre_y);
abs_x + centre_x,
abs_y + centre_y );
return(posted); return (posted);
} }
/* Control which motion flags the window has set, a flags value of -1 sets /* Control which motion flags the window has set, a flags value of -1 sets
...@@ -123,7 +84,8 @@ static int ph_WarpedMotion(_THIS, PhEvent_t *winEvent) ...@@ -123,7 +84,8 @@ static int ph_WarpedMotion(_THIS, PhEvent_t *winEvent)
static void set_motion_sensitivity(_THIS, unsigned int flags) static void set_motion_sensitivity(_THIS, unsigned int flags)
{ {
int rid, fields = Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON; int rid;
int fields = Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON;
PhRegion_t region; PhRegion_t region;
if( window ) if( window )
...@@ -131,27 +93,25 @@ static void set_motion_sensitivity(_THIS, unsigned int flags) ...@@ -131,27 +93,25 @@ static void set_motion_sensitivity(_THIS, unsigned int flags)
rid = PtWidgetRid( window ); rid = PtWidgetRid( window );
if( rid != 0 && PhRegionQuery( rid, &region, NULL, NULL, 0 ) == 0 ) if( rid != 0 && PhRegionQuery( rid, &region, NULL, NULL, 0 ) == 0 )
{ {
region.events_sense = ( region.events_sense & ~fields ) | region.events_sense=(region.events_sense & ~fields)|(flags & fields);
( flags & fields ); PhRegionChange(Ph_REGION_EV_SENSE, 0, &region, NULL, NULL);
PhRegionChange( Ph_REGION_EV_SENSE, 0, &region,
NULL, NULL );
} }
} }
} }
/* Convert the photon button state value to an SDL value */ /* Convert the photon button state value to an SDL value */
static Uint8 ph2sdl_mousebutton( unsigned short button_state ) static Uint8 ph2sdl_mousebutton(unsigned short button_state)
{ {
Uint8 mouse_button = 0; Uint8 mouse_button = 0;
if( button_state & Ph_BUTTON_SELECT ) if (button_state & Ph_BUTTON_SELECT)
mouse_button |= SDL_BUTTON_LEFT; mouse_button |= SDL_BUTTON_LEFT;
if( button_state & Ph_BUTTON_MENU ) if (button_state & Ph_BUTTON_MENU)
mouse_button |= SDL_BUTTON_RIGHT; mouse_button |= SDL_BUTTON_RIGHT;
if( button_state & Ph_BUTTON_ADJUST ) if (button_state & Ph_BUTTON_ADJUST)
mouse_button |= SDL_BUTTON_MIDDLE; mouse_button |= SDL_BUTTON_MIDDLE;
return( mouse_button ); return (mouse_button);
} }
static int ph_DispatchEvent(_THIS) static int ph_DispatchEvent(_THIS)
...@@ -245,10 +205,6 @@ static int ph_DispatchEvent(_THIS) ...@@ -245,10 +205,6 @@ static int ph_DispatchEvent(_THIS)
{ {
set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON); set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON);
posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
/* Queue leaving fullscreen mode */
switch_waiting = 0x01;
switch_time = SDL_GetTicks() + 200;
} }
/* gaining focus */ /* gaining focus */
else if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUS)) else if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUS))
...@@ -327,18 +283,16 @@ int ph_Pending(_THIS) ...@@ -327,18 +283,16 @@ int ph_Pending(_THIS)
PgFlush(); PgFlush();
while( 1 ) while( 1 )
{ //note this is a non-blocking call { /* note this is a non-blocking call */
switch( PhEventPeek( event, EVENT_SIZE ) ) switch( PhEventPeek( event, EVENT_SIZE ) )
{ {
case Ph_EVENT_MSG: case Ph_EVENT_MSG:
return 1; return 1;
break; break;
case -1: case -1:
perror( "PhEventNext failed" ); perror("ph_Pending(): PhEventNext failed");
break; break;
default: default:
return 0; return 0;
} }
} }
...@@ -347,94 +301,14 @@ int ph_Pending(_THIS) ...@@ -347,94 +301,14 @@ int ph_Pending(_THIS)
return(0); return(0);
} }
/*
SAMPLE EVENT PUMP
=================
static void update( int block ){
int ch,fl;
PhKeyEvent_t *key;
for( ;; ){
if( block ){
do{
fl=PhEventNext( event,EVENT_SIZE );
}while( fl!=Ph_EVENT_MSG );
block=0;
}else{
do{
fl=PhEventPeek( event,EVENT_SIZE );
if( !fl ) return;
}while( fl!=Ph_EVENT_MSG );
}
switch( event->type ){
case Ph_EV_KEY:
key=PhGetData( event );
ch=key->key_cap; // & 127;
fl=key->key_flags;
if( ch<32 || ch>127 ) break;
if( fl & Pk_KF_Key_Down ){
if( !(fl & Pk_KF_Key_Repeat) ){
if( queput-queget<QUE_SIZE ) keyque[ queput++ & QUE_MASK ]=ch;
keyMatrix[ch]=1;
}
}else{
keyMatrix[ch]=0;
}
break;
default:
PtEventHandler( event );
}
}
}
*/
void ph_PumpEvents(_THIS) void ph_PumpEvents(_THIS)
{ {
int pending; /* Flush the display connection and look to see if events are queued */
PgFlush();
/* Keep processing pending events */ while (ph_Pending(this))
pending = 0; {
while ( ph_Pending(this) ) {
ph_DispatchEvent(this); ph_DispatchEvent(this);
++pending;
}
if ( switch_waiting ) {
Uint32 now;
now = SDL_GetTicks();
#if 0
if ( pending || !SDL_VideoSurface ) {
/* Try again later... */
if ( switch_waiting & SDL_FULLSCREEN ) {
switch_time = now + 1500;
} else {
switch_time = now + 200;
}
} else if ( now >= switch_time ) {
Uint32 go_fullscreen;
go_fullscreen = switch_waiting & SDL_FULLSCREEN;
switch_waiting = 0;
if ( SDL_VideoSurface->flags & SDL_FULLSCREEN ) {
if ( go_fullscreen ) {
ph_EnterFullScreen(this);
} else {
ph_LeaveFullScreen(this);
}
}
/* Handle focus in/out when grabbed */
/*
if ( go_fullscreen ) {
ph_GrabInputNoLock(this, this->input_grab);
} else {
ph_GrabInputNoLock(this, SDL_GRAB_OFF);
}
*/
}
#endif
} }
} }
...@@ -443,11 +317,11 @@ void ph_InitKeymap(void) ...@@ -443,11 +317,11 @@ void ph_InitKeymap(void)
int i; int i;
/* Odd keys used in international keyboards */ /* Odd keys used in international keyboards */
for ( i=0; i<SDL_TABLESIZE(ODD_keymap); ++i ) for (i=0; i<SDL_TABLESIZE(ODD_keymap); ++i)
ODD_keymap[i] = SDLK_UNKNOWN; ODD_keymap[i] = SDLK_UNKNOWN;
/* Map the miscellaneous keys */ /* Map the miscellaneous keys */
for ( i=0; i<SDL_TABLESIZE(MISC_keymap); ++i ) for (i=0; i<SDL_TABLESIZE(MISC_keymap); ++i)
MISC_keymap[i] = SDLK_UNKNOWN; MISC_keymap[i] = SDLK_UNKNOWN;
MISC_keymap[Pk_BackSpace&0xFF] = SDLK_BACKSPACE; MISC_keymap[Pk_BackSpace&0xFF] = SDLK_BACKSPACE;
...@@ -515,12 +389,11 @@ void ph_InitKeymap(void) ...@@ -515,12 +389,11 @@ void ph_InitKeymap(void)
MISC_keymap[Pk_Meta_R&0xFF] = SDLK_RMETA; MISC_keymap[Pk_Meta_R&0xFF] = SDLK_RMETA;
MISC_keymap[Pk_Meta_L&0xFF] = SDLK_LMETA; MISC_keymap[Pk_Meta_L&0xFF] = SDLK_LMETA;
MISC_keymap[Pk_Super_L&0xFF] = SDLK_LSUPER; /* Left "Windows" */ MISC_keymap[Pk_Super_L&0xFF] = SDLK_LSUPER; /* Left "Windows" */
MISC_keymap[Pk_Super_R&0xFF] = SDLK_RSUPER; /* Right "Windows */ MISC_keymap[Pk_Super_R&0xFF] = SDLK_RSUPER; /* Right "Windows" */
MISC_keymap[Pk_Mode_switch&0xFF] = SDLK_MODE; /* "Alt Gr" key */ MISC_keymap[Pk_Mode_switch&0xFF] = SDLK_MODE; /* "Alt Gr" key */
MISC_keymap[Pk_Help&0xFF] = SDLK_HELP; MISC_keymap[Pk_Help&0xFF] = SDLK_HELP;
MISC_keymap[Pk_Print&0xFF] = SDLK_PRINT; MISC_keymap[Pk_Print&0xFF] = SDLK_PRINT;
// MISC_keymap[Pk_Sys_Req] = SDLK_SYSREQ;
MISC_keymap[Pk_Break&0xFF] = SDLK_BREAK; MISC_keymap[Pk_Break&0xFF] = SDLK_BREAK;
MISC_keymap[Pk_Menu&0xFF] = SDLK_MENU; MISC_keymap[Pk_Menu&0xFF] = SDLK_MENU;
MISC_keymap[Pk_Hyper_R&0xFF] = SDLK_MENU; /* Windows "Menu" key */ MISC_keymap[Pk_Hyper_R&0xFF] = SDLK_MENU; /* Windows "Menu" key */
...@@ -530,14 +403,16 @@ static unsigned long cap; ...@@ -530,14 +403,16 @@ static unsigned long cap;
SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym) SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym)
{ {
/* /* 'sym' is set to the value of the key with modifiers applied to it.
'sym' is set to the value of the key with modifiers applied to it.
This member is valid only if Pk_KF_Sym_Valid is set in the key_flags. This member is valid only if Pk_KF_Sym_Valid is set in the key_flags.
We will assume it is valid. We will assume it is valid. */
*/
/* FIXME: This needs to check whether the cap & scancode is valid */ /* FIXME: This needs to check whether the cap & scancode is valid */
cap = key->key_cap; cap = key->key_cap;
switch (cap>>8) {
switch (cap>>8)
{
case 0x00: /* Latin 1 */ case 0x00: /* Latin 1 */
case 0x01: /* Latin 2 */ case 0x01: /* Latin 2 */
case 0x02: /* Latin 3 */ case 0x02: /* Latin 3 */
...@@ -555,30 +430,28 @@ SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym) ...@@ -555,30 +430,28 @@ SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym)
if ((keysym->sym >= 'A')&&(keysym->sym <= 'Z')) if ((keysym->sym >= 'A')&&(keysym->sym <= 'Z'))
keysym->sym += ('a'-'A'); keysym->sym += ('a'-'A');
break; break;
// case 0xFE:
// keysym->sym = ODD_keymap[sym&0xFF];
// break;
case 0xF0: case 0xF0:
keysym->sym = MISC_keymap[cap&0xFF]; keysym->sym = MISC_keymap[cap&0xFF];
break; break;
default: default:
/* fprintf(stderr,"Photon: Unknown key_cap, cap = 0x%.4x\n", (unsigned int)cap); */
keysym->sym = SDLK_UNKNOWN; keysym->sym = SDLK_UNKNOWN;
break; break;
} }
keysym->scancode = key->key_scan; keysym->scancode = key->key_scan;
keysym->unicode = 0; keysym->unicode = 0;
if( SDL_TranslateUNICODE )
if (SDL_TranslateUNICODE)
{ {
char utf8[MB_CUR_MAX]; char utf8[MB_CUR_MAX];
int utf8len; int utf8len;
wchar_t unicode; wchar_t unicode;
utf8len = PhKeyToMb( utf8, key ); utf8len = PhKeyToMb(utf8, key);
if( utf8len > 0 ) if (utf8len > 0)
{ {
utf8len = mbtowc( &unicode, utf8, utf8len ); utf8len = mbtowc(&unicode, utf8, utf8len);
if( utf8len > 0) if (utf8len > 0)
keysym->unicode = unicode; keysym->unicode = unicode;
} }
} }
...@@ -590,4 +463,3 @@ void ph_InitOSKeymap(_THIS) ...@@ -590,4 +463,3 @@ void ph_InitOSKeymap(_THIS)
{ {
ph_InitKeymap(); ph_InitKeymap();
} }
...@@ -27,7 +27,7 @@ static char rcsid = ...@@ -27,7 +27,7 @@ static char rcsid =
#include "SDL_ph_video.h" #include "SDL_ph_video.h"
#define EVENT_SIZE sizeof( PhEvent_t ) + 1000 #define EVENT_SIZE sizeof(PhEvent_t) + 1000
/* Functions to be exported */ /* Functions to be exported */
extern void ph_InitOSKeymap(_THIS); extern void ph_InitOSKeymap(_THIS);
......
...@@ -29,16 +29,60 @@ static char rcsid = ...@@ -29,16 +29,60 @@ static char rcsid =
#include <Ph.h> #include <Ph.h>
#include <photon/Pg.h> #include <photon/Pg.h>
#include "SDL.h"
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_endian.h" #include "SDL_endian.h"
#include "SDL_video.h"
#include "SDL_pixels_c.h"
#include "SDL_ph_image_c.h" #include "SDL_ph_image_c.h"
/* remove this line, if photon headers updates */ /* Mask values for SDL_ReallocFormat() */
int PgWaitHWIdle(void); struct ColourMasks
{
Uint32 red;
Uint32 green;
Uint32 blue;
Uint32 alpha;
Uint32 bpp;
};
static const struct ColourMasks *ph_GetColourMasks( int format )
{
/* The alpha mask doesn't appear to be needed */
static const struct ColourMasks phColorMasks[5] = {
/* 8 bit */ {0, 0, 0, 0, 8},
/* 15 bit ARGB */ {0x7C00, 0x03E0, 0x001F, 0x8000, 16},
/* 16 bit RGB */ {0xF800, 0x07E0, 0x001F, 0x0000, 16},
/* 24 bit RGB */ {0xFF0000, 0x00FF00, 0x0000FF, 0x000000, 24},
/* 32 bit ARGB */ {0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, 32},
};
switch( format )
{
case Pg_IMAGE_PALETTE_BYTE:
return &phColorMasks[0];
break;
case Pg_IMAGE_DIRECT_1555:
case Pg_IMAGE_DIRECT_555:
return &phColorMasks[1];
break;
case Pg_IMAGE_DIRECT_565:
return &phColorMasks[2];
break;
case Pg_IMAGE_DIRECT_888:
return &phColorMasks[3];
break;
case Pg_IMAGE_DIRECT_8888:
return &phColorMasks[4];
break;
}
return NULL;
}
int ph_SetupImage(_THIS, SDL_Surface *screen) int ph_SetupImage(_THIS, SDL_Surface *screen)
{ {
PgColor_t* palette=NULL; PgColor_t* palette=NULL;
const struct ColourMasks* mask;
int type=0; int type=0;
int bpp; int bpp;
...@@ -68,7 +112,7 @@ int ph_SetupImage(_THIS, SDL_Surface *screen) ...@@ -68,7 +112,7 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
} }
break; break;
default:{ default:{
fprintf(stderr,"ph_SetupImage(): unsupported bbp = %d\n", bpp); fprintf(stderr,"ph_SetupImage(): unsupported bpp=%d !\n", bpp);
return -1; return -1;
} }
break; break;
...@@ -84,7 +128,7 @@ int ph_SetupImage(_THIS, SDL_Surface *screen) ...@@ -84,7 +128,7 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
/* using shared memory for speed (set last param to 1) */ /* using shared memory for speed (set last param to 1) */
if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, palette, _Pg_MAX_PALETTE, 1)) == NULL) if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, palette, _Pg_MAX_PALETTE, 1)) == NULL)
{ {
fprintf(stderr,"ph_SetupImage(): PhCreateImage failed for bpp=8.\n"); fprintf(stderr,"ph_SetupImage(): PhCreateImage failed for bpp=8 !\n");
return -1; return -1;
} }
} }
...@@ -93,7 +137,7 @@ int ph_SetupImage(_THIS, SDL_Surface *screen) ...@@ -93,7 +137,7 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
/* using shared memory for speed (set last param to 1) */ /* using shared memory for speed (set last param to 1) */
if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, NULL, 0, 1)) == NULL) if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, NULL, 0, 1)) == NULL)
{ {
fprintf(stderr,"ph_SetupImage: PhCreateImage failed.\n"); fprintf(stderr,"ph_SetupImage: PhCreateImage failed !\n");
return -1; return -1;
} }
} }
...@@ -101,6 +145,12 @@ int ph_SetupImage(_THIS, SDL_Surface *screen) ...@@ -101,6 +145,12 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
screen->pixels = SDL_Image->image; screen->pixels = SDL_Image->image;
screen->pitch = SDL_Image->bpl; /* Recalculated pitch, created by PhCreateImage */ screen->pitch = SDL_Image->bpl; /* Recalculated pitch, created by PhCreateImage */
mask = ph_GetColourMasks(type);
if (mask != NULL)
{
SDL_ReallocFormat(screen, mask->bpp, mask->red, mask->green, mask->blue, 0);
}
this->UpdateRects = ph_NormalUpdate; this->UpdateRects = ph_NormalUpdate;
return 0; return 0;
...@@ -108,9 +158,13 @@ int ph_SetupImage(_THIS, SDL_Surface *screen) ...@@ -108,9 +158,13 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
int ph_SetupOCImage(_THIS, SDL_Surface *screen) int ph_SetupOCImage(_THIS, SDL_Surface *screen)
{ {
const struct ColourMasks *mask;
int type = 0; int type = 0;
int bpp; int bpp;
screen->flags &= ~SDL_DOUBLEBUF;
OCImage.flags = screen->flags;
bpp=screen->format->BitsPerPixel; bpp=screen->format->BitsPerPixel;
/* Determine image type */ /* Determine image type */
...@@ -137,22 +191,14 @@ int ph_SetupOCImage(_THIS, SDL_Surface *screen) ...@@ -137,22 +191,14 @@ int ph_SetupOCImage(_THIS, SDL_Surface *screen)
} }
break; break;
default:{ default:{
fprintf(stderr,"ph_SetupOCImage(): unsupported bpp = %d\n", bpp); fprintf(stderr,"ph_SetupOCImage(): unsupported bpp=%d !\n", bpp);
return -1; return -1;
} }
break; break;
} }
OCImage.FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof(FRAMEDATA))); /* Currently only offscreen contexts with the same bit depth as the
OCImage.FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof(FRAMEDATA))); * display can be created. */
memset(OCImage.FrameData0, 0x00, (size_t)(sizeof(FRAMEDATA)));
memset(OCImage.FrameData1, 0x00, (size_t)(sizeof(FRAMEDATA)));
if(OCImage.direct_context == NULL)
{
OCImage.direct_context = PdCreateDirectContext();
}
OCImage.offscreen_context = PdCreateOffscreenContext(0, screen->w, screen->h, Pg_OSC_MEM_PAGE_ALIGN); OCImage.offscreen_context = PdCreateOffscreenContext(0, screen->w, screen->h, Pg_OSC_MEM_PAGE_ALIGN);
if (OCImage.offscreen_context == NULL) if (OCImage.offscreen_context == NULL)
...@@ -161,13 +207,22 @@ int ph_SetupOCImage(_THIS, SDL_Surface *screen) ...@@ -161,13 +207,22 @@ int ph_SetupOCImage(_THIS, SDL_Surface *screen)
return -1; return -1;
} }
screen->pitch = OCImage.offscreen_context->pitch; /* Recalculated pitch */ /* If the bit depth of the context is different than was requested,
* these values need to be updated accordingly. SDL will
* allocate a shadow surface if it needs to. */
mask = ph_GetColourMasks(OCImage.offscreen_context->format);
if (mask != NULL)
{
SDL_ReallocFormat(screen, mask->bpp, mask->red, mask->green, mask->blue, 0);
if (OCImage.flags & SDL_DOUBLEBUF) if (mask->bpp > 8)
{ {
fprintf(stderr, "ph_SetupOCImage(): Hardware flag for doublebuf offscreen context\n"); screen->flags &= ~SDL_HWPALETTE;
}
} }
screen->pitch = OCImage.offscreen_context->pitch; /* Recalculated pitch */
OCImage.dc_ptr.ptr8 = (unsigned char *) PdGetOffscreenContextPtr(OCImage.offscreen_context); OCImage.dc_ptr.ptr8 = (unsigned char *) PdGetOffscreenContextPtr(OCImage.offscreen_context);
if (OCImage.dc_ptr.ptr8 == NULL) if (OCImage.dc_ptr.ptr8 == NULL)
...@@ -176,15 +231,13 @@ int ph_SetupOCImage(_THIS, SDL_Surface *screen) ...@@ -176,15 +231,13 @@ int ph_SetupOCImage(_THIS, SDL_Surface *screen)
return -1; return -1;
} }
OCImage.FrameData0 = OCImage.dc_ptr.ptr8;
OCImage.CurrentFrameData = OCImage.FrameData0; OCImage.CurrentFrameData = OCImage.FrameData0;
OCImage.CurrentFrameData->Y = OCImage.dc_ptr.ptr8;
OCImage.CurrentFrameData->U = NULL;
OCImage.CurrentFrameData->V = NULL;
OCImage.current = 0; OCImage.current = 0;
PhDCSetCurrent(OCImage.offscreen_context); PhDCSetCurrent(OCImage.offscreen_context);
screen->pixels = OCImage.CurrentFrameData->Y; screen->pixels = OCImage.CurrentFrameData;
this->UpdateRects = ph_OCUpdate; this->UpdateRects = ph_OCUpdate;
...@@ -198,15 +251,67 @@ int ph_SetupOpenGLImage(_THIS, SDL_Surface* screen) ...@@ -198,15 +251,67 @@ int ph_SetupOpenGLImage(_THIS, SDL_Surface* screen)
return 0; return 0;
} }
int ph_SetupFullScreenImage(_THIS, SDL_Surface* screen)
{
const struct ColourMasks *mask;
screen->flags &= ~SDL_DOUBLEBUF;
OCImage.flags = screen->flags;
OCImage.offscreen_context = PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY);
if (OCImage.offscreen_context == NULL)
{
fprintf(stderr, "ph_SetupFullScreenImage(): PdCreateOffscreenContext failed !\n");
return -1;
}
/* If the bit depth of the context is different than was requested,
* these values need to be updated accordingly. SDL will
* allocate a shadow surface if it needs to. */
mask = ph_GetColourMasks(OCImage.offscreen_context->format);
if (mask != NULL)
{
SDL_ReallocFormat(screen, mask->bpp, mask->red, mask->green, mask->blue, 0);
if (mask->bpp > 8)
{
screen->flags &= ~SDL_HWPALETTE;
}
}
screen->pitch = OCImage.offscreen_context->pitch; /* Recalculated pitch */
OCImage.dc_ptr.ptr8 = (unsigned char *)PdGetOffscreenContextPtr(OCImage.offscreen_context);
if (OCImage.dc_ptr.ptr8 == NULL)
{
fprintf(stderr, "ph_SetupOCImage(): PdGetOffscreenContextPtr failed !\n");
return -1;
}
/* wait for hw */
PgWaitHWIdle();
OCImage.FrameData0 = OCImage.dc_ptr.ptr8;
OCImage.CurrentFrameData = OCImage.FrameData0;
OCImage.current = 0;
PhDCSetCurrent(OCImage.offscreen_context);
screen->pixels = OCImage.CurrentFrameData;
this->UpdateRects = ph_OCUpdate;
return 0;
}
void ph_DestroyImage(_THIS, SDL_Surface *screen) void ph_DestroyImage(_THIS, SDL_Surface *screen)
{ {
if (OCImage.offscreen_context != NULL) if (OCImage.offscreen_context != NULL)
{ {
PhDCRelease(OCImage.offscreen_context); PhDCRelease(OCImage.offscreen_context);
OCImage.offscreen_context = NULL; OCImage.offscreen_context = NULL;
free(OCImage.FrameData0);
OCImage.FrameData0 = NULL; OCImage.FrameData0 = NULL;
free(OCImage.FrameData1);
OCImage.FrameData1 = NULL; OCImage.FrameData1 = NULL;
} }
...@@ -230,23 +335,24 @@ void ph_DestroyImage(_THIS, SDL_Surface *screen) ...@@ -230,23 +335,24 @@ void ph_DestroyImage(_THIS, SDL_Surface *screen)
} }
} }
int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags) int ph_SetupUpdateFunction(_THIS, SDL_Surface *screen, Uint32 flags)
{ {
ph_DestroyImage(this, screen); ph_DestroyImage(this, screen);
if (flags & SDL_HWSURFACE) if ((flags & SDL_FULLSCREEN)==SDL_FULLSCREEN)
{
return ph_SetupFullScreenImage(this, screen);
}
if ((flags & SDL_HWSURFACE)==SDL_HWSURFACE)
{ {
OCImage.flags = flags; /* needed for SDL_DOUBLEBUF check */
return ph_SetupOCImage(this, screen); return ph_SetupOCImage(this, screen);
} }
else if (flags & SDL_OPENGL) if ((flags & SDL_OPENGL)==SDL_OPENGL)
{ {
return ph_SetupOpenGLImage(this, screen); return ph_SetupOpenGLImage(this, screen);
} }
else
{
return ph_SetupImage(this, screen); return ph_SetupImage(this, screen);
}
} }
int ph_AllocHWSurface(_THIS, SDL_Surface *surface) int ph_AllocHWSurface(_THIS, SDL_Surface *surface)
{ {
...@@ -265,11 +371,6 @@ int ph_FlipHWSurface(_THIS, SDL_Surface *surface) ...@@ -265,11 +371,6 @@ int ph_FlipHWSurface(_THIS, SDL_Surface *surface)
int ph_LockHWSurface(_THIS, SDL_Surface *surface) int ph_LockHWSurface(_THIS, SDL_Surface *surface)
{ {
if ((surface == SDL_VideoSurface) && blit_queued) {
PgFlush();
blit_queued = 0;
}
return(0); return(0);
} }
...@@ -307,7 +408,7 @@ void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) ...@@ -307,7 +408,7 @@ void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
if (PgDrawPhImageRectmx(&ph_pos, SDL_Image, &ph_rect, 0) < 0) if (PgDrawPhImageRectmx(&ph_pos, SDL_Image, &ph_rect, 0) < 0)
{ {
fprintf(stderr,"ph_NormalUpdate(): PgDrawPhImageRectmx failed.\n"); fprintf(stderr,"ph_NormalUpdate(): PgDrawPhImageRectmx failed !\n");
} }
} }
...@@ -325,11 +426,6 @@ void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects) ...@@ -325,11 +426,6 @@ void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects)
PhArea_t src_rect; PhArea_t src_rect;
PhArea_t dest_rect; PhArea_t dest_rect;
if(OCImage.direct_context == NULL)
{
return;
}
PgSetRegion(PtWidgetRid(window)); PgSetRegion(PtWidgetRid(window));
PgSetClipping(0, NULL); PgSetClipping(0, NULL);
PgWaitHWIdle(); PgWaitHWIdle();
......
...@@ -29,7 +29,7 @@ static char rcsid = ...@@ -29,7 +29,7 @@ static char rcsid =
extern int ph_SetupImage(_THIS, SDL_Surface *screen); extern int ph_SetupImage(_THIS, SDL_Surface *screen);
extern void ph_DestroyImage(_THIS, SDL_Surface *screen); extern void ph_DestroyImage(_THIS, SDL_Surface *screen);
extern int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags); extern int ph_SetupUpdateFunction(_THIS, SDL_Surface *screen, Uint32 flags);
extern int ph_AllocHWSurface(_THIS, SDL_Surface *surface); extern int ph_AllocHWSurface(_THIS, SDL_Surface *surface);
extern void ph_FreeHWSurface(_THIS, SDL_Surface *surface); extern void ph_FreeHWSurface(_THIS, SDL_Surface *surface);
......
...@@ -31,19 +31,19 @@ static unsigned long key1, key2; ...@@ -31,19 +31,19 @@ static unsigned long key1, key2;
static PgVideoModeInfo_t mode_info; static PgVideoModeInfo_t mode_info;
static PgVideoModes_t mode_list; static PgVideoModes_t mode_list;
/* The current list of available video modes */ /* The current list of available video modes */
SDL_Rect SDL_modelist[PH_MAX_VIDEOMODES]; SDL_Rect SDL_modelist[PH_MAX_VIDEOMODES];
SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES]; SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES];
static int compare_modes_by_res(const void* mode1, const void* mode2) static int compare_modes_by_res(const void* mode1, const void* mode2)
{ {
if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0) if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
{ {
fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n", fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
*(unsigned short*)mode1); *(unsigned short*)mode1);
return 0; return 0;
} }
key1 = mode_info.width * mode_info.height; key1 = mode_info.width * mode_info.height;
if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0) if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
...@@ -52,6 +52,7 @@ static int compare_modes_by_res(const void* mode1, const void* mode2) ...@@ -52,6 +52,7 @@ static int compare_modes_by_res(const void* mode1, const void* mode2)
*(unsigned short*)mode2); *(unsigned short*)mode2);
return 0; return 0;
} }
key2 = mode_info.width * mode_info.height; key2 = mode_info.width * mode_info.height;
if (key1 > key2) if (key1 > key2)
...@@ -117,89 +118,6 @@ void ph_FreeVideoModes(_THIS) ...@@ -117,89 +118,6 @@ void ph_FreeVideoModes(_THIS)
return; return;
} }
#if 0
static void set_best_resolution(_THIS, int width, int height)
{
/* warning ! dead variable use_vidmode ! */
if ( use_vidmode ) {
PgDisplaySettings_t settings;
PgVideoModeInfo_t current_mode_info;
PgHWCaps_t my_hwcaps;
unsigned short current_bpp;
int i;
/*
if (PgGetVideoMode( &settings ) < 0)
{
fprintf(stderr,"error: PgGetVideoMode failed\n");
return;
}
if (PgGetVideoModeInfo( settings.mode, &current_mode_info ) < 0)
{
fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
return;
}
*/
//lu_zero
if (PgGetGraphicsHWCaps(&my_hwcaps) < 0)
{
fprintf(stderr,"set_best_resolution: GetGraphicsHWCaps failed!! \n");
//that HAVE to work
}
if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &current_mode_info) < 0)
{
fprintf(stderr,"set_best_resolution: PgGetVideoModeInfo failed\n");
}
current_bpp = current_mode_info.bits_per_pixel;
if (PgGetVideoModeList(&mode_list) >= 0)
{
qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res);
#ifdef PH_DEBUG
printf("Available modes:\n");
for ( i = 0; i < mode_list.num_modes; ++i )
{
PgGetVideoModeInfo(mode_list.modes[i], &mode_info);
printf("Mode %d: %dx%d\n", i, mode_info.width, mode_info.height);
}
#endif
for ( i = mode_list.num_modes-1; i >= 0 ; --i )
{
if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
{
fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
}
if ( (mode_info.width >= width) &&
(mode_info.height >= height) &&
(mode_info.bits_per_pixel == current_bpp) )
break;
}
if (i >= 0)
{
if ( (mode_info.width != current_mode_info.width) ||
(mode_info.height != current_mode_info.height) )
{
settings.mode = mode_list.modes[i];
if(PgSetVideoMode( &settings ) < 0)
{
fprintf(stderr,"error: PgSetVideoMode failed\n");
}
}
}
}
}
}
int ph_ResizeFullScreen(_THIS)
{
if (currently_fullscreen)
{
set_best_resolution(this, current_w, current_h);
}
return (1);
}
#endif /* 0 */
/* return the mode associated with width, height and bpp */ /* return the mode associated with width, height and bpp */
/* if there is no mode then zero is returned */ /* if there is no mode then zero is returned */
int get_mode(int width, int height, int bpp) int get_mode(int width, int height, int bpp)
...@@ -270,7 +188,7 @@ int get_mode_any_format(int width, int height, int bpp) ...@@ -270,7 +188,7 @@ int get_mode_any_format(int width, int height, int bpp)
/* get closest bpp */ /* get closest bpp */
closest = i++; closest = i++;
if (mode_info.bits_per_pixel == bpp) if (mode_info.bits_per_pixel == bpp)
return mode_list.modes[ closest ]; return mode_list.modes[closest];
min_delta = abs(mode_info.bits_per_pixel - bpp); min_delta = abs(mode_info.bits_per_pixel - bpp);
while(1) while(1)
...@@ -300,16 +218,12 @@ int get_mode_any_format(int width, int height, int bpp) ...@@ -300,16 +218,12 @@ int get_mode_any_format(int width, int height, int bpp)
i++; i++;
} }
} }
return mode_list.modes[ closest ]; return mode_list.modes[closest];
} }
else else
return 0; return 0;
} }
void ph_WaitMapped(_THIS);
void ph_WaitUnmapped(_THIS);
void ph_QueueEnterFullScreen(_THIS);
int ph_ToggleFullScreen(_THIS, int on) int ph_ToggleFullScreen(_THIS, int on)
{ {
if (currently_fullscreen) if (currently_fullscreen)
...@@ -338,17 +252,18 @@ int ph_EnterFullScreen(_THIS) ...@@ -338,17 +252,18 @@ int ph_EnterFullScreen(_THIS)
} }
} }
if (OCImage.direct_context == NULL) if (OCImage.direct_context==NULL)
{ {
OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext(); OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext();
} }
if (!OCImage.direct_context) if (!OCImage.direct_context)
{ {
fprintf(stderr, "ph_EnterFullScreen: Can't create direct context\n" ); fprintf(stderr, "ph_EnterFullScreen(): Can't create direct context !\n");
return 0;
} }
PdDirectStart(OCImage.direct_context); OCImage.oldDC=PdDirectStart(OCImage.direct_context);
currently_fullscreen = 1; currently_fullscreen = 1;
} }
...@@ -372,6 +287,7 @@ int ph_LeaveFullScreen(_THIS) ...@@ -372,6 +287,7 @@ int ph_LeaveFullScreen(_THIS)
{ {
PdDirectStop(OCImage.direct_context); PdDirectStop(OCImage.direct_context);
PdReleaseDirectContext(OCImage.direct_context); PdReleaseDirectContext(OCImage.direct_context);
PhDCSetCurrent(OCImage.oldDC);
currently_fullscreen=0; currently_fullscreen=0;
...@@ -384,7 +300,8 @@ int ph_LeaveFullScreen(_THIS) ...@@ -384,7 +300,8 @@ int ph_LeaveFullScreen(_THIS)
if (PgSetVideoMode(&mymode_settings) < 0) if (PgSetVideoMode(&mymode_settings) < 0)
{ {
fprintf(stderr,"error: PgSetVideoMode failed\n"); fprintf(stderr, "Ph_LeaveFullScreen(): PgSetVideoMode failed !\n");
return 0;
} }
} }
......
...@@ -36,9 +36,6 @@ static char rcsid = ...@@ -36,9 +36,6 @@ static char rcsid =
extern SDL_Rect **ph_ListModes(_THIS,SDL_PixelFormat *format, Uint32 flags); extern SDL_Rect **ph_ListModes(_THIS,SDL_PixelFormat *format, Uint32 flags);
extern void ph_FreeVideoModes(_THIS); extern void ph_FreeVideoModes(_THIS);
extern int ph_ResizeFullScreen(_THIS); extern int ph_ResizeFullScreen(_THIS);
extern void ph_WaitMapped(_THIS);
extern void ph_WaitUnmapped(_THIS);
extern void ph_QueueEnterFullScreen(_THIS);
extern int ph_EnterFullScreen(_THIS); extern int ph_EnterFullScreen(_THIS);
extern int ph_LeaveFullScreen(_THIS); extern int ph_LeaveFullScreen(_THIS);
extern int get_mode(int width, int height, int bpp); extern int get_mode(int width, int height, int bpp);
......
...@@ -35,18 +35,18 @@ static char rcsid = ...@@ -35,18 +35,18 @@ static char rcsid =
#include "SDL_cursor_c.h" #include "SDL_cursor_c.h"
#include "SDL_ph_mouse_c.h" #include "SDL_ph_mouse_c.h"
struct WMcursor { struct WMcursor
{
PhCursorDef_t *ph_cursor ; PhCursorDef_t *ph_cursor ;
}; };
void ph_FreeWMCursor(_THIS, WMcursor *cursor) void ph_FreeWMCursor(_THIS, WMcursor *cursor)
{ {
if (window != NULL) if (window != NULL)
{ {
SDL_Lock_EventThread(); SDL_Lock_EventThread();
if (PtSetResource( window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_INHERIT, 0 ) < 0) if (PtSetResource( window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_INHERIT, 0) < 0)
{ {
/* TODO: output error msg */ /* TODO: output error msg */
} }
...@@ -73,7 +73,7 @@ WMcursor *ph_CreateWMCursor(_THIS, ...@@ -73,7 +73,7 @@ WMcursor *ph_CreateWMCursor(_THIS,
memset(cursor,0,sizeof(WMcursor)); memset(cursor,0,sizeof(WMcursor));
cursor->ph_cursor = (PhCursorDef_t *) malloc(sizeof(PhCursorDef_t) + 32*4*2); cursor->ph_cursor = (PhCursorDef_t *) malloc(sizeof(PhCursorDef_t) + 32*4*2);
if(cursor->ph_cursor == NULL) if (cursor->ph_cursor == NULL)
printf("cursor malloc failed\n"); printf("cursor malloc failed\n");
memset(cursor->ph_cursor,0,(sizeof(PhCursorDef_t) + 32*4*2)); memset(cursor->ph_cursor,0,(sizeof(PhCursorDef_t) + 32*4*2));
...@@ -94,17 +94,15 @@ WMcursor *ph_CreateWMCursor(_THIS, ...@@ -94,17 +94,15 @@ WMcursor *ph_CreateWMCursor(_THIS,
clen = (w/8)*h; clen = (w/8)*h;
/* Copy the mask and the data to different /* Copy the mask and the data to different bitmap planes */
bitmap planes */ for (i=0; i<clen; ++i)
for ( i=0; i<clen; ++i )
{ {
for ( bit = 0; bit < 8; bit++ ) for (bit = 0; bit < 8; bit++)
{ {
databit = data[i] & (1 << bit); databit = data[i] & (1 << bit);
maskbit = mask[i] & (1 << bit); maskbit = mask[i] & (1 << bit);
cursor->ph_cursor->images[i] |= cursor->ph_cursor->images[i] |= (databit == 0) ? maskbit : 0;
(databit == 0) ? maskbit : 0;
/* If the databit != 0, treat it as a black pixel and /* If the databit != 0, treat it as a black pixel and
* ignore the maskbit (can't do an inverted color) */ * ignore the maskbit (can't do an inverted color) */
cursor->ph_cursor->images[i+clen] |= databit; cursor->ph_cursor->images[i+clen] |= databit;
...@@ -117,7 +115,6 @@ WMcursor *ph_CreateWMCursor(_THIS, ...@@ -117,7 +115,6 @@ WMcursor *ph_CreateWMCursor(_THIS,
return (cursor); return (cursor);
} }
PhCursorDef_t ph_GetWMPhCursor(WMcursor *cursor) PhCursorDef_t ph_GetWMPhCursor(WMcursor *cursor)
{ {
return(*cursor->ph_cursor); return(*cursor->ph_cursor);
...@@ -127,45 +124,44 @@ int ph_ShowWMCursor(_THIS, WMcursor *cursor) ...@@ -127,45 +124,44 @@ int ph_ShowWMCursor(_THIS, WMcursor *cursor)
{ {
PtArg_t args[3]; PtArg_t args[3];
int nargs = 0; int nargs = 0;
short cursor_is_defined = 0;
/* Don't do anything if the display is gone */ /* Don't do anything if the display is gone */
if ( window == NULL ) { if (window == NULL)
return(0); {
return (0);
} }
/* Set the photon cursor cursor, or blank if cursor is NULL */ /* looks like photon can't draw mouse cursor in direct mode */
if ( window ) { if ((this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
{
return (0);
}
if ( cursor != NULL ) { /* Set the photon cursor cursor, or blank if cursor is NULL */
PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0 ); if (cursor!=NULL)
{
PtSetArg(&args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0);
/* Could set next to any PgColor_t value */ /* Could set next to any PgColor_t value */
PtSetArg( &args[1], Pt_ARG_CURSOR_COLOR,Ph_CURSOR_DEFAULT_COLOR , 0 ); PtSetArg(&args[1], Pt_ARG_CURSOR_COLOR, Ph_CURSOR_DEFAULT_COLOR , 0);
PtSetArg( &args[2], Pt_ARG_BITMAP_CURSOR, cursor->ph_cursor, (cursor->ph_cursor->hdr.len + sizeof(PhRegionDataHdr_t)) ); PtSetArg(&args[2], Pt_ARG_BITMAP_CURSOR, cursor->ph_cursor, (cursor->ph_cursor->hdr.len + sizeof(PhRegionDataHdr_t)));
nargs = 3; nargs = 3;
cursor_is_defined = 1;
} }
else /* Ph_CURSOR_NONE */ else /* Ph_CURSOR_NONE */
{ {
PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE,Ph_CURSOR_NONE, 0); PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0);
nargs = 1; nargs = 1;
cursor_is_defined = 1;
} }
if (cursor_is_defined)
{
SDL_Lock_EventThread(); SDL_Lock_EventThread();
if (PtSetResources( window, nargs, args ) < 0 ) if (PtSetResources(window, nargs, args) < 0 )
{ {
return(0); return (0);
} }
SDL_Unlock_EventThread(); SDL_Unlock_EventThread();
}
else return (1);
return(0);
}
return(1);
} }
void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y) void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
......
This diff is collapsed.
...@@ -44,18 +44,16 @@ ...@@ -44,18 +44,16 @@
#define SDLPH_PAL_SYSTEM 0x00000002L #define SDLPH_PAL_SYSTEM 0x00000002L
typedef union vidptr{ typedef union vidptr{
uint8_t *volatile ptr8; uint8_t* volatile ptr8;
uint16_t *volatile ptr16; uint16_t* volatile ptr16;
uint32_t *volatile ptr32; uint32_t* volatile ptr32;
} VidPtr_t; } VidPtr_t;
typedef struct { typedef struct {
unsigned char *Y; unsigned char* Y;
unsigned char *V; unsigned char* V;
unsigned char *U; unsigned char* U;
}FRAMEDATA; } FRAMEDATA;
#define EVENT_SIZE sizeof( PhEvent_t ) + 1000
/* Private display data */ /* Private display data */
struct SDL_PrivateVideoData { struct SDL_PrivateVideoData {
...@@ -65,15 +63,17 @@ struct SDL_PrivateVideoData { ...@@ -65,15 +63,17 @@ struct SDL_PrivateVideoData {
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
PdOpenGLContext_t* OGLContext; /* OpenGL context */ PdOpenGLContext_t* OGLContext; /* OpenGL context */
#endif /* HAVE_OPENGL */ #endif /* HAVE_OPENGL */
PgColor_t ph_palette[_Pg_MAX_PALETTE]; PgColor_t savedpal[_Pg_MAX_PALETTE];
PgColor_t syspalph[_Pg_MAX_PALETTE];
struct { struct {
PdDirectContext_t *direct_context; PdDirectContext_t* direct_context;
PdOffscreenContext_t *offscreen_context; PdOffscreenContext_t* offscreen_context;
PhDrawContext_t* oldDC;
VidPtr_t dc_ptr; VidPtr_t dc_ptr;
FRAMEDATA *CurrentFrameData; unsigned char* CurrentFrameData;
FRAMEDATA *FrameData0; unsigned char* FrameData0;
FRAMEDATA *FrameData1; unsigned char* FrameData1;
int current; int current;
long flags; long flags;
} ocimage; } ocimage;
...@@ -82,40 +82,15 @@ struct SDL_PrivateVideoData { ...@@ -82,40 +82,15 @@ struct SDL_PrivateVideoData {
int old_video_mode; /* Stored mode before fullscreen switch */ int old_video_mode; /* Stored mode before fullscreen switch */
int old_refresh_rate; /* Stored refresh rate befor fullscreen switch */ int old_refresh_rate; /* Stored refresh rate befor fullscreen switch */
/* The current width and height of the fullscreen mode */
int current_w;
int current_h;
/* Support for internal mouse warping */
struct {
int x;
int y;
} mouse_last;
struct {
int numerator;
int denominator;
int threshold;
} mouse_accel;
int mouse_relative; int mouse_relative;
WMcursor* BlankCursor; WMcursor* BlankCursor;
int depth; /* current visual depth (not bpp) */ int depth; /* current visual depth (not bpp) */
int desktopbpp; /* bpp of desktop at the moment of start */ int desktopbpp; /* bpp of desktop at the moment of start */
int desktoppal; /* palette mode emulation or system */ int desktoppal; /* palette mode emulation or system */
int captionflag; /* caption setting flag */
int use_vidmode;
int currently_fullscreen; int currently_fullscreen;
/* Automatic mode switching support (entering/leaving fullscreen) */
Uint32 switch_waiting;
Uint32 switch_time;
/* Prevent too many XSync() calls */
int blit_queued;
PhEvent_t* event; PhEvent_t* event;
}; };
...@@ -129,23 +104,13 @@ struct SDL_PrivateVideoData { ...@@ -129,23 +104,13 @@ struct SDL_PrivateVideoData {
#define graphics_card_caps (this->hidden->graphics_card_caps) #define graphics_card_caps (this->hidden->graphics_card_caps)
#define desktopbpp (this->hidden->desktopbpp) #define desktopbpp (this->hidden->desktopbpp)
#define desktoppal (this->hidden->desktoppal) #define desktoppal (this->hidden->desktoppal)
#define ph_palette (this->hidden->ph_palette) #define savedpal (this->hidden->savedpal)
#define syspalph (this->hidden->syspalph)
/* Old variable names */ /* Old variable names */
#define current_w (this->hidden->current_w)
#define current_h (this->hidden->current_h)
#define mouse_last (this->hidden->mouse_last)
#define mouse_accel (this->hidden->mouse_accel)
#define mouse_relative (this->hidden->mouse_relative) #define mouse_relative (this->hidden->mouse_relative)
#define saved_mode (this->hidden->saved_mode)
#define saved_view (this->hidden->saved_view)
#define use_vidmode (this->hidden->use_vidmode)
#define currently_fullscreen (this->hidden->currently_fullscreen) #define currently_fullscreen (this->hidden->currently_fullscreen)
#define switch_waiting (this->hidden->switch_waiting)
#define switch_time (this->hidden->switch_time)
#define blit_queued (this->hidden->blit_queued)
#define event (this->hidden->event) #define event (this->hidden->event)
#define SDL_BlankCursor (this->hidden->BlankCursor) #define SDL_BlankCursor (this->hidden->BlankCursor)
#define captionflag (this->hidden->captionflag)
#endif /* _SDL_x11video_h */ #endif /* _SDL_x11video_h */
...@@ -56,15 +56,11 @@ void ph_SetCaption(_THIS, const char *title, const char *icon) ...@@ -56,15 +56,11 @@ void ph_SetCaption(_THIS, const char *title, const char *icon)
{ {
SDL_Lock_EventThread(); SDL_Lock_EventThread();
/* check for set caption call before window init */ /* sanity check for set caption call before window init */
if (window!=NULL) if (window!=NULL)
{ {
PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0); PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
} }
else
{
captionflag=1;
}
SDL_Unlock_EventThread(); SDL_Unlock_EventThread();
} }
...@@ -87,37 +83,36 @@ int ph_IconifyWindow(_THIS) ...@@ -87,37 +83,36 @@ int ph_IconifyWindow(_THIS)
} }
SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode) SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
{
return(mode);
}
SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode)
{ {
short abs_x, abs_y; short abs_x, abs_y;
SDL_Lock_EventThread();
/* mode = ph_GrabInputNoLock(this, mode);*/
if( mode == SDL_GRAB_OFF ) if( mode == SDL_GRAB_OFF )
{ {
PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_FALSE, PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISALTKEY);
Ph_WM_STATE_ISALTKEY );
} }
else else
{ {
PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_TRUE, PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISALTKEY);
Ph_WM_STATE_ISALTKEY );
PtGetAbsPosition( window, &abs_x, &abs_y ); PtGetAbsPosition(window, &abs_x, &abs_y);
PhMoveCursorAbs( PhInputGroup( NULL ), PhMoveCursorAbs(PhInputGroup(NULL), abs_x + SDL_VideoSurface->w/2, abs_y + SDL_VideoSurface->h/2);
abs_x + SDL_VideoSurface->w/2,
abs_y + SDL_VideoSurface->h/2 );
} }
SDL_Unlock_EventThread(); SDL_Unlock_EventThread();
return(mode);
}
SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode)
{
SDL_Lock_EventThread();
mode = ph_GrabInputNoLock(this, mode);
SDL_Unlock_EventThread();
return(mode); return(mode);
} }
int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info) int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
{ {
if (info->version.major <= SDL_MAJOR_VERSION) if (info->version.major <= SDL_MAJOR_VERSION)
......
This diff is collapsed.
...@@ -31,11 +31,7 @@ static char rcsid = ...@@ -31,11 +31,7 @@ static char rcsid =
#include "SDL_ph_video.h" #include "SDL_ph_video.h"
extern SDL_Overlay *ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display); extern SDL_Overlay *ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display);
extern int ph_LockYUVOverlay(_THIS, SDL_Overlay *overlay); extern int ph_LockYUVOverlay(_THIS, SDL_Overlay *overlay);
extern void ph_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay); extern void ph_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay);
extern int ph_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect); extern int ph_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect);
extern void ph_FreeYUVOverlay(_THIS, SDL_Overlay *overlay); extern void ph_FreeYUVOverlay(_THIS, SDL_Overlay *overlay);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment