src/video/photon/SDL_ph_wm.c
author Sam Lantinga <slouken@libsdl.org>
Fri, 10 Feb 2006 06:48:43 +0000
changeset 1358 c71e05b4dc2e
parent 1338 604d73db6802
child 1361 19418e4422cb
permissions -rw-r--r--
More header massaging... works great on Windows. ;-)
     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 <Ph.h>
    26 #include <photon/PpProto.h>
    27 #include <photon/PhWm.h>
    28 #include <photon/wmapi.h>
    29 
    30 #include "SDL_version.h"
    31 #include "SDL_timer.h"
    32 #include "SDL_video.h"
    33 #include "SDL_syswm.h"
    34 #include "SDL_events_c.h"
    35 #include "SDL_pixels_c.h"
    36 #include "SDL_ph_modes_c.h"
    37 #include "SDL_ph_wm_c.h"
    38 
    39 void ph_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
    40 {
    41     return;
    42 }
    43 
    44 /* Set window caption */
    45 void ph_SetCaption(_THIS, const char *title, const char *icon)
    46 {
    47     SDL_Lock_EventThread();
    48 
    49     /* sanity check for set caption call before window init */
    50     if (window!=NULL)
    51     {
    52         PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
    53     }
    54 
    55     SDL_Unlock_EventThread();
    56 }
    57 
    58 /* Iconify current window */
    59 int ph_IconifyWindow(_THIS)
    60 {
    61     PhWindowEvent_t windowevent;
    62 
    63     SDL_Lock_EventThread();
    64 
    65     SDL_memset( &windowevent, 0, sizeof (event) );
    66     windowevent.event_f = Ph_WM_HIDE;
    67     windowevent.event_state = Ph_WM_EVSTATE_HIDE;
    68     windowevent.rid = PtWidgetRid(window);
    69     PtForwardWindowEvent(&windowevent);
    70 
    71     SDL_Unlock_EventThread();
    72 
    73     return 0;
    74 }
    75 
    76 SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
    77 {
    78     short abs_x, abs_y;
    79 
    80     if( mode == SDL_GRAB_OFF )
    81     {
    82         PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISALTKEY);
    83     }
    84     else
    85     {
    86         PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISALTKEY);
    87 
    88         PtGetAbsPosition(window, &abs_x, &abs_y);
    89         PhMoveCursorAbs(PhInputGroup(NULL), abs_x + SDL_VideoSurface->w/2, abs_y + SDL_VideoSurface->h/2);
    90     }
    91 
    92     SDL_Unlock_EventThread();
    93 
    94     return(mode);
    95 }
    96 
    97 SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode)
    98 {
    99     SDL_Lock_EventThread();
   100     mode = ph_GrabInputNoLock(this, mode);
   101     SDL_Unlock_EventThread();
   102 
   103     return(mode);
   104 }
   105 
   106 
   107 int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
   108 {
   109     if (info->version.major <= SDL_MAJOR_VERSION)
   110     {
   111         return 1;
   112     }
   113     else
   114     {
   115         SDL_SetError("Application not compiled with SDL %d.%d\n",
   116                       SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
   117         return -1;
   118     }
   119 }