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