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