src/video/photon/SDL_ph_wm.c
author Sam Lantinga <slouken@libsdl.org>
Sat, 23 Mar 2002 20:19:44 +0000
changeset 315 3333b6e68289
parent 297 f6ffac90895c
child 571 8e3ce997621c
permissions -rw-r--r--
Date: Sat, 23 Mar 2002 13:53:37 +0200
From: "Mike Gorchak" <mike@malva.ua>
Subject: Big QNX patch again.

Added 8bit palette emulation code for window mode with bpp>=15.
Added store/restore original palette for 8bit modes.
Added more information about photon API call fails.
Rewroten change palette code, slow but works.
Fixed bug with set caption before window was inited.
Fixed bugs with some initial state of variables.
Fixed bug with storing old video mode settings.
Fixed bug with switching to fullscreen mode and back.
Fixed few double SEGFAULTS during parachute mode.
Removed compilation warning with no PgWaitHWIdle prototype.
Removed pack of dead unusable code.
Cleanups SDL_PrivateVideoData structure, some headers.
Some code formatting.
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@297
     3
    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@0
     6
    modify it under the terms of the GNU Library General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@0
     8
    version 2 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@0
    13
    Library General Public License for more details.
slouken@0
    14
slouken@0
    15
    You should have received a copy of the GNU Library General Public
slouken@0
    16
    License along with this library; if not, write to the Free
slouken@0
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@0
    23
#ifdef SAVE_RCSID
slouken@0
    24
static char rcsid =
slouken@0
    25
 "@(#) $Id$";
slouken@0
    26
#endif
slouken@0
    27
slouken@19
    28
#define DISABLE_X11
slouken@19
    29
slouken@0
    30
#include <stdlib.h>
slouken@0
    31
#include <string.h>
slouken@0
    32
#include <Ph.h>
slouken@19
    33
#include <photon/PpProto.h>
slouken@19
    34
#include <photon/PhWm.h>
slouken@19
    35
#include <photon/wmapi.h>
slouken@0
    36
#include "SDL_version.h"
slouken@0
    37
#include "SDL_error.h"
slouken@0
    38
#include "SDL_timer.h"
slouken@0
    39
#include "SDL_video.h"
slouken@0
    40
#include "SDL_syswm.h"
slouken@0
    41
#include "SDL_events_c.h"
slouken@0
    42
#include "SDL_pixels_c.h"
slouken@0
    43
#include "SDL_ph_modes_c.h"
slouken@0
    44
#include "SDL_ph_wm_c.h"
slouken@0
    45
slouken@0
    46
/* This is necessary for working properly with Enlightenment, etc. */
slouken@0
    47
#define USE_ICON_WINDOW
slouken@0
    48
slouken@0
    49
void ph_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
slouken@0
    50
{
slouken@315
    51
    return;
slouken@0
    52
}
slouken@0
    53
slouken@19
    54
/* Set window caption */
slouken@0
    55
void ph_SetCaption(_THIS, const char *title, const char *icon)
slouken@0
    56
{
slouken@315
    57
    SDL_Lock_EventThread();
slouken@315
    58
slouken@315
    59
    /* check for set caption call before window init */
slouken@315
    60
    if (window!=NULL)
slouken@315
    61
    {
slouken@315
    62
        PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
slouken@315
    63
    }
slouken@315
    64
    else
slouken@315
    65
    {
slouken@315
    66
        captionflag=1;
slouken@315
    67
    }
slouken@315
    68
slouken@315
    69
    SDL_Unlock_EventThread();
slouken@19
    70
}
slouken@0
    71
slouken@266
    72
/* Iconify current window */
slouken@19
    73
int ph_IconifyWindow(_THIS)
slouken@19
    74
{
slouken@315
    75
    PhWindowEvent_t windowevent;
slouken@315
    76
slouken@315
    77
    SDL_Lock_EventThread();
slouken@0
    78
slouken@315
    79
    memset( &windowevent, 0, sizeof (event) );
slouken@315
    80
    windowevent.event_f = Ph_WM_HIDE;
slouken@315
    81
    windowevent.event_state = Ph_WM_EVSTATE_HIDE;
slouken@315
    82
    windowevent.rid = PtWidgetRid( window );
slouken@315
    83
    PtForwardWindowEvent( &windowevent );
slouken@315
    84
    SDL_Unlock_EventThread();
slouken@315
    85
slouken@315
    86
    return 0;
slouken@0
    87
}
slouken@0
    88
slouken@0
    89
SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
slouken@0
    90
{
slouken@315
    91
    return(mode);
slouken@0
    92
}
slouken@0
    93
slouken@0
    94
SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode)
slouken@0
    95
{
slouken@283
    96
	short abs_x, abs_y;
slouken@283
    97
slouken@283
    98
	SDL_Lock_EventThread();
slouken@283
    99
/*	mode = ph_GrabInputNoLock(this, mode);*/
slouken@283
   100
slouken@283
   101
	if( mode == SDL_GRAB_OFF )
slouken@283
   102
	{
slouken@283
   103
		PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_FALSE,
slouken@283
   104
				Ph_WM_STATE_ISALTKEY );
slouken@283
   105
	}
slouken@283
   106
	else
slouken@283
   107
	{
slouken@283
   108
		PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_TRUE,
slouken@283
   109
				Ph_WM_STATE_ISALTKEY );
slouken@283
   110
slouken@283
   111
		PtGetAbsPosition( window, &abs_x, &abs_y );
slouken@283
   112
		PhMoveCursorAbs( PhInputGroup( NULL ),
slouken@283
   113
				abs_x + SDL_VideoSurface->w/2,
slouken@283
   114
				abs_y + SDL_VideoSurface->h/2 );
slouken@283
   115
	}
slouken@283
   116
slouken@283
   117
	SDL_Unlock_EventThread();
slouken@283
   118
	return(mode);
slouken@0
   119
}
slouken@0
   120
slouken@0
   121
int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
slouken@0
   122
{
slouken@315
   123
    if (info->version.major <= SDL_MAJOR_VERSION)
slouken@315
   124
    {
slouken@315
   125
        return 1;
slouken@315
   126
    }
slouken@315
   127
    else
slouken@315
   128
    {
slouken@315
   129
        SDL_SetError("Application not compiled with SDL %d.%d\n",
slouken@315
   130
                      SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
slouken@315
   131
        return -1;
slouken@315
   132
    }
slouken@0
   133
}