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