src/video/gem/SDL_gemwm.c
author Patrice Mandin <patmandin@gmail.com>
Wed, 12 Nov 2003 18:49:29 +0000
changeset 736 028e03e273c8
parent 557 0ce5a68278fd
child 769 b8d311d90021
permissions -rw-r--r--
Use new C2P routine + corrections for iconification window
slouken@281
     1
/*
slouken@281
     2
    SDL - Simple DirectMedia Layer
slouken@297
     3
    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
slouken@281
     4
slouken@281
     5
    This library is free software; you can redistribute it and/or
slouken@281
     6
    modify it under the terms of the GNU Library General Public
slouken@281
     7
    License as published by the Free Software Foundation; either
slouken@281
     8
    version 2 of the License, or (at your option) any later version.
slouken@281
     9
slouken@281
    10
    This library is distributed in the hope that it will be useful,
slouken@281
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@281
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@281
    13
    Library General Public License for more details.
slouken@281
    14
slouken@281
    15
    You should have received a copy of the GNU Library General Public
slouken@281
    16
    License along with this library; if not, write to the Free
slouken@281
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@281
    18
slouken@281
    19
    Sam Lantinga
slouken@281
    20
    slouken@libsdl.org
slouken@281
    21
*/
slouken@281
    22
slouken@281
    23
#ifdef SAVE_RCSID
slouken@281
    24
static char rcsid =
slouken@281
    25
 "@(#) $Id$";
slouken@281
    26
#endif
slouken@281
    27
slouken@281
    28
/*
patmandin@736
    29
	GEM SDL video driver
patmandin@736
    30
	Window manager functions
patmandin@736
    31
patmandin@736
    32
	Patrice Mandin
patmandin@736
    33
*/
slouken@281
    34
slouken@281
    35
/* Mint includes */
slouken@281
    36
#include <gem.h>
slouken@281
    37
slouken@281
    38
#include "SDL_gemwm_c.h"
slouken@281
    39
slouken@281
    40
/* Defines */
slouken@281
    41
patmandin@736
    42
#define DEBUG_VIDEO_GEM 0
patmandin@736
    43
slouken@281
    44
#define ICONWIDTH 64
slouken@281
    45
#define ICONHEIGHT 64
slouken@281
    46
slouken@281
    47
/* Functions */
slouken@281
    48
slouken@281
    49
void GEM_SetCaption(_THIS, const char *title, const char *icon)
slouken@281
    50
{
patmandin@736
    51
	if (title) {
slouken@281
    52
		GEM_title_name = title;
patmandin@736
    53
		GEM_refresh_name = SDL_TRUE;
slouken@281
    54
	}
slouken@281
    55
patmandin@736
    56
	if (icon) {
patmandin@736
    57
		GEM_icon_name = icon;
patmandin@736
    58
		GEM_refresh_name = SDL_TRUE;
slouken@281
    59
	}
slouken@281
    60
}
slouken@281
    61
slouken@281
    62
void GEM_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
slouken@281
    63
{
patmandin@736
    64
	SDL_Surface *sicon;
patmandin@736
    65
	SDL_Rect bounds;
patmandin@736
    66
patmandin@736
    67
#ifdef DEBUG_VIDEO_GEM
patmandin@736
    68
	printf("sdl:video:gem: SetIcon(0x%08x)\n", (long) icon);
patmandin@736
    69
#endif
patmandin@736
    70
patmandin@736
    71
#if 0
patmandin@736
    72
	if ((GEM_wfeatures & (1<<WF_ICONIFY))==0) {
patmandin@736
    73
#ifdef DEBUG_VIDEO_GEM
patmandin@736
    74
		printf("sdl:video:gem: AES can not iconify windows\n");
patmandin@736
    75
#endif
slouken@281
    76
		return;
patmandin@736
    77
	}
patmandin@736
    78
#endif
slouken@281
    79
patmandin@736
    80
	if (icon == NULL) {
patmandin@736
    81
		return;
patmandin@736
    82
	}
patmandin@736
    83
	
patmandin@736
    84
	/* Convert icon to the screen format */
patmandin@736
    85
	sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h,
patmandin@736
    86
		VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, 0);
patmandin@736
    87
	if ( sicon == NULL ) {
patmandin@736
    88
		return;
patmandin@736
    89
	}
patmandin@736
    90
patmandin@736
    91
	bounds.x = 0;
patmandin@736
    92
	bounds.y = 0;
patmandin@736
    93
	bounds.w = icon->w;
patmandin@736
    94
	bounds.h = icon->h;
patmandin@736
    95
	if ( SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0 ) {
patmandin@736
    96
		SDL_FreeSurface(sicon);
patmandin@736
    97
		return;
patmandin@736
    98
	}
patmandin@736
    99
patmandin@736
   100
	GEM_icon = sicon;
patmandin@736
   101
patmandin@736
   102
#ifdef DEBUG_VIDEO_GEM
patmandin@736
   103
	printf("sdl:video:gem: SetIcon(): done\n");
patmandin@736
   104
#endif
slouken@281
   105
}
slouken@281
   106
slouken@281
   107
int GEM_IconifyWindow(_THIS)
slouken@281
   108
{
slouken@281
   109
	if ((GEM_wfeatures & (1<<WF_ICONIFY))==0)
slouken@281
   110
		return 0;
slouken@281
   111
patmandin@736
   112
	GEM_message[0] = WM_ICONIFY;
patmandin@736
   113
	GEM_message[1] = gl_apid;
patmandin@736
   114
	GEM_message[2] = 0;
patmandin@736
   115
	GEM_message[3] = GEM_handle;
patmandin@736
   116
	GEM_message[4] = 0;
patmandin@736
   117
	GEM_message[5] = GEM_desk_h-ICONHEIGHT;
patmandin@736
   118
	GEM_message[6] = ICONWIDTH;
patmandin@736
   119
	GEM_message[7] = ICONHEIGHT;
slouken@281
   120
patmandin@736
   121
	appl_write(gl_apid, sizeof(GEM_message), GEM_message);
slouken@281
   122
slouken@281
   123
	return 1;
slouken@281
   124
}
slouken@281
   125
slouken@281
   126
SDL_GrabMode GEM_GrabInput(_THIS, SDL_GrabMode mode)
slouken@281
   127
{
slouken@281
   128
	return mode;
slouken@281
   129
}