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