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