Skip to content
Permalink
Browse files

Save/restore system palette when application topped/untopped

  • Loading branch information
pmandin committed Jun 7, 2005
1 parent 88d1958 commit 33c58791887ae6929ee85746615b1b89e5bce5ad
Showing with 35 additions and 17 deletions.
  1. +6 −0 src/video/gem/SDL_gemevents.c
  2. +24 −17 src/video/gem/SDL_gemvideo.c
  3. +5 −0 src/video/gem/SDL_gemvideo.h
@@ -245,6 +245,9 @@ static int do_messages(_THIS, short *message)
case WM_TOPPED:
wind_set(message[3],WF_TOP,message[4],0,0,0);
SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
if (VDI_setpalette) {
VDI_setpalette(this, VDI_curpalette);
}
break;
case WM_REDRAW:
if (!GEM_lock_redraw) {
@@ -307,6 +310,9 @@ static int do_messages(_THIS, short *message)
case WM_BOTTOMED:
case WM_UNTOPPED:
SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
if (VDI_setpalette) {
VDI_setpalette(this, VDI_oldpalette);
}
break;
}

@@ -106,6 +106,7 @@ static int GEM_ToggleFullScreen(_THIS, int on);
static void GEM_FreeBuffers(_THIS);
static void GEM_ClearScreen(_THIS);
static void GEM_ClearRect(_THIS, short *rect);
static void GEM_SetNewPalette(_THIS, Uint16 newpal[256][3]);
static void GEM_LockScreen(_THIS);
static void GEM_UnlockScreen(_THIS);
static void refresh_window(_THIS, int winhandle, short *rect);
@@ -396,6 +397,8 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)
VDI_oldpalette[i][1] = rgb[1];
VDI_oldpalette[i][2] = rgb[2];
}
VDI_setpalette = GEM_SetNewPalette;
memcpy(VDI_curpalette,VDI_oldpalette,sizeof(VDI_curpalette));

/* Setup screen info */
GEM_title_name = empty_name;
@@ -520,6 +523,23 @@ static void GEM_ClearScreen(_THIS)
v_show_c(VDI_handle, 1);
}

static void GEM_SetNewPalette(_THIS, Uint16 newpal[256][3])
{
int i;
short rgb[3];

if (VDI_oldnumcolors==0)
return;

for(i = 0; i < VDI_oldnumcolors; i++) {
rgb[0] = newpal[i][0];
rgb[1] = newpal[i][1];
rgb[2] = newpal[i][2];

vs_color(VDI_handle, i, rgb);
}
}

static void GEM_LockScreen(_THIS)
{
if (!GEM_locked) {
@@ -1048,9 +1068,9 @@ static int GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
g = colors[i].g;
b = colors[i].b;

rgb[0] = (1000 * r) / 255;
rgb[1] = (1000 * g) / 255;
rgb[2] = (1000 * b) / 255;
rgb[0] = VDI_curpalette[i][0] = (1000 * r) / 255;
rgb[1] = VDI_curpalette[i][1] =(1000 * g) / 255;
rgb[2] = VDI_curpalette[i][2] =(1000 * b) / 255;

vs_color(VDI_handle, vdi_index[firstcolor+i], rgb);
}
@@ -1101,20 +1121,7 @@ void GEM_VideoQuit(_THIS)

appl_exit();

/* Restore palette */
if (VDI_oldnumcolors) {
int i;

for(i = 0; i < VDI_oldnumcolors; i++) {
short rgb[3];

rgb[0] = VDI_oldpalette[i][0];
rgb[1] = VDI_oldpalette[i][1];
rgb[2] = VDI_oldpalette[i][2];

vs_color(VDI_handle, i, rgb);
}
}
GEM_SetNewPalette(this, VDI_oldpalette);

/* Close VDI workstation */
if (VDI_handle) {
@@ -65,6 +65,9 @@ struct SDL_PrivateVideoData {
short blit_coords[8]; /* Coordinates for bitblt */
MFDB src_mfdb, dst_mfdb; /* VDI MFDB for bitblt */
Uint16 old_palette[256][3]; /* Saved current palette */
Uint16 cur_palette[256][3]; /* SDL application palette */
/* Function to set/restore palette */
void (*setpalette)(_THIS, Uint16 newpal[256][3]);

/* GEM infos */
short desk_x, desk_y; /* Desktop properties */
@@ -96,6 +99,8 @@ struct SDL_PrivateVideoData {
#define VDI_pixelsize (this->hidden->pixelsize)
#define VDI_oldnumcolors (this->hidden->old_numcolors)
#define VDI_oldpalette (this->hidden->old_palette)
#define VDI_curpalette (this->hidden->cur_palette)
#define VDI_setpalette (this->hidden->setpalette)
#define VDI_pitch (this->hidden->pitch)
#define VDI_format (this->hidden->format)
#define VDI_screen (this->hidden->screen)

0 comments on commit 33c5879

Please sign in to comment.