src/video/photon/SDL_ph_wm.c
author Sam Lantinga <slouken@libsdl.org>
Tue, 07 Feb 2006 06:59:48 +0000
changeset 1336 3692456e7b0f
parent 1312 c9b51268668f
child 1338 604d73db6802
permissions -rw-r--r--
Use SDL_ prefixed versions of C library functions.
FIXME:
Change #include <stdlib.h> to #include "SDL_stdlib.h"
Change #include <string.h> to #include "SDL_string.h"
Make sure nothing else broke because of this...
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2006 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 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     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 
    23 #define DISABLE_X11
    24 
    25 #include <stdlib.h>
    26 #include <string.h>
    27 #include <Ph.h>
    28 #include <photon/PpProto.h>
    29 #include <photon/PhWm.h>
    30 #include <photon/wmapi.h>
    31 #include "SDL_version.h"
    32 #include "SDL_error.h"
    33 #include "SDL_timer.h"
    34 #include "SDL_video.h"
    35 #include "SDL_syswm.h"
    36 #include "SDL_events_c.h"
    37 #include "SDL_pixels_c.h"
    38 #include "SDL_ph_modes_c.h"
    39 #include "SDL_ph_wm_c.h"
    40 
    41 void ph_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
    42 {
    43     return;
    44 }
    45 
    46 /* Set window caption */
    47 void ph_SetCaption(_THIS, const char *title, const char *icon)
    48 {
    49     SDL_Lock_EventThread();
    50 
    51     /* sanity check for set caption call before window init */
    52     if (window!=NULL)
    53     {
    54         PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
    55     }
    56 
    57     SDL_Unlock_EventThread();
    58 }
    59 
    60 /* Iconify current window */
    61 int ph_IconifyWindow(_THIS)
    62 {
    63     PhWindowEvent_t windowevent;
    64 
    65     SDL_Lock_EventThread();
    66 
    67     SDL_memset( &windowevent, 0, sizeof (event) );
    68     windowevent.event_f = Ph_WM_HIDE;
    69     windowevent.event_state = Ph_WM_EVSTATE_HIDE;
    70     windowevent.rid = PtWidgetRid(window);
    71     PtForwardWindowEvent(&windowevent);
    72 
    73     SDL_Unlock_EventThread();
    74 
    75     return 0;
    76 }
    77 
    78 SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
    79 {
    80     short abs_x, abs_y;
    81 
    82     if( mode == SDL_GRAB_OFF )
    83     {
    84         PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISALTKEY);
    85     }
    86     else
    87     {
    88         PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISALTKEY);
    89 
    90         PtGetAbsPosition(window, &abs_x, &abs_y);
    91         PhMoveCursorAbs(PhInputGroup(NULL), abs_x + SDL_VideoSurface->w/2, abs_y + SDL_VideoSurface->h/2);
    92     }
    93 
    94     SDL_Unlock_EventThread();
    95 
    96     return(mode);
    97 }
    98 
    99 SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode)
   100 {
   101     SDL_Lock_EventThread();
   102     mode = ph_GrabInputNoLock(this, mode);
   103     SDL_Unlock_EventThread();
   104 
   105     return(mode);
   106 }
   107 
   108 
   109 int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
   110 {
   111     if (info->version.major <= SDL_MAJOR_VERSION)
   112     {
   113         return 1;
   114     }
   115     else
   116     {
   117         SDL_SetError("Application not compiled with SDL %d.%d\n",
   118                       SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
   119         return -1;
   120     }
   121 }