src/video/gem/SDL_gemwm.c
author Patrice Mandin <patmandin@gmail.com>
Tue, 12 Sep 2006 19:34:18 +0000
branchSDL-1.2
changeset 3859 5d14acfdf84d
parent 1402 d910939febfa
child 4159 a1b03ba2fcd0
permissions -rw-r--r--
Allow grabing mouse by locking its position
slouken@281
     1
/*
slouken@281
     2
    SDL - Simple DirectMedia Layer
slouken@1312
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@281
     4
slouken@281
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@281
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 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@1312
    13
    Lesser General Public License for more details.
slouken@281
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@281
    18
slouken@281
    19
    Sam Lantinga
slouken@281
    20
    slouken@libsdl.org
slouken@281
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@281
    23
slouken@281
    24
/*
patmandin@736
    25
	GEM SDL video driver
patmandin@736
    26
	Window manager functions
patmandin@736
    27
patmandin@736
    28
	Patrice Mandin
patmandin@736
    29
*/
slouken@281
    30
slouken@281
    31
/* Mint includes */
slouken@281
    32
#include <gem.h>
slouken@281
    33
slouken@281
    34
#include "SDL_gemwm_c.h"
slouken@281
    35
slouken@281
    36
/* Defines */
slouken@281
    37
slouken@281
    38
#define ICONWIDTH 64
slouken@281
    39
#define ICONHEIGHT 64
slouken@281
    40
slouken@281
    41
/* Functions */
slouken@281
    42
slouken@281
    43
void GEM_SetCaption(_THIS, const char *title, const char *icon)
slouken@281
    44
{
patmandin@736
    45
	if (title) {
slouken@281
    46
		GEM_title_name = title;
patmandin@736
    47
		GEM_refresh_name = SDL_TRUE;
slouken@281
    48
	}
slouken@281
    49
patmandin@736
    50
	if (icon) {
patmandin@736
    51
		GEM_icon_name = icon;
patmandin@736
    52
		GEM_refresh_name = SDL_TRUE;
slouken@281
    53
	}
slouken@281
    54
}
slouken@281
    55
slouken@281
    56
void GEM_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
slouken@281
    57
{
patmandin@736
    58
	SDL_Surface *sicon;
patmandin@736
    59
	SDL_Rect bounds;
patmandin@736
    60
patmandin@736
    61
#if 0
patmandin@736
    62
	if ((GEM_wfeatures & (1<<WF_ICONIFY))==0) {
slouken@281
    63
		return;
patmandin@736
    64
	}
patmandin@736
    65
#endif
slouken@281
    66
patmandin@736
    67
	if (icon == NULL) {
patmandin@736
    68
		return;
patmandin@736
    69
	}
patmandin@736
    70
	
patmandin@736
    71
	/* Convert icon to the screen format */
patmandin@736
    72
	sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h,
patmandin@736
    73
		VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, 0);
patmandin@736
    74
	if ( sicon == NULL ) {
patmandin@736
    75
		return;
patmandin@736
    76
	}
patmandin@736
    77
patmandin@736
    78
	bounds.x = 0;
patmandin@736
    79
	bounds.y = 0;
patmandin@736
    80
	bounds.w = icon->w;
patmandin@736
    81
	bounds.h = icon->h;
patmandin@736
    82
	if ( SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0 ) {
patmandin@736
    83
		SDL_FreeSurface(sicon);
patmandin@736
    84
		return;
patmandin@736
    85
	}
patmandin@736
    86
patmandin@736
    87
	GEM_icon = sicon;
slouken@281
    88
}
slouken@281
    89
slouken@281
    90
int GEM_IconifyWindow(_THIS)
slouken@281
    91
{
slouken@281
    92
	if ((GEM_wfeatures & (1<<WF_ICONIFY))==0)
slouken@281
    93
		return 0;
slouken@281
    94
patmandin@736
    95
	GEM_message[0] = WM_ICONIFY;
patmandin@736
    96
	GEM_message[1] = gl_apid;
patmandin@736
    97
	GEM_message[2] = 0;
patmandin@736
    98
	GEM_message[3] = GEM_handle;
patmandin@736
    99
	GEM_message[4] = 0;
patmandin@736
   100
	GEM_message[5] = GEM_desk_h-ICONHEIGHT;
patmandin@736
   101
	GEM_message[6] = ICONWIDTH;
patmandin@736
   102
	GEM_message[7] = ICONHEIGHT;
slouken@281
   103
patmandin@736
   104
	appl_write(gl_apid, sizeof(GEM_message), GEM_message);
slouken@281
   105
slouken@281
   106
	return 1;
slouken@281
   107
}
slouken@281
   108
slouken@281
   109
SDL_GrabMode GEM_GrabInput(_THIS, SDL_GrabMode mode)
slouken@281
   110
{
patmandin@3859
   111
	if (this->screen == NULL) {
patmandin@3859
   112
		return SDL_GRAB_OFF;
patmandin@3859
   113
	}
patmandin@3859
   114
patmandin@3859
   115
	return mode;
slouken@281
   116
}