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