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