src/video/photon/SDL_ph_wm.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 20 Jan 2003 01:38:37 +0000
changeset 571 8e3ce997621c
parent 315 3333b6e68289
child 663 8bedd6d61642
permissions -rw-r--r--
Date: Thu, 16 Jan 2003 13:48:31 +0200
From: "Mike Gorchak"
Subject: All QNX patches

whole patches concerning QNX. Almost all code has been rewritten by Julian
and me. Added initial support for hw overlays in QNX and many many others
fixes.

P.S. This patches has been reviewed by Dave Rempel from QSSL and included in
SDL 1.2.5 distribution, which coming on 3rd party CD for newest 6.2.1
version of QNX, which will be available soon.
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@297
     3
    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  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
/* This is necessary for working properly with Enlightenment, etc. */
slouken@0
    47
#define USE_ICON_WINDOW
slouken@0
    48
slouken@0
    49
void ph_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
slouken@0
    50
{
slouken@315
    51
    return;
slouken@0
    52
}
slouken@0
    53
slouken@19
    54
/* Set window caption */
slouken@0
    55
void ph_SetCaption(_THIS, const char *title, const char *icon)
slouken@0
    56
{
slouken@315
    57
    SDL_Lock_EventThread();
slouken@315
    58
slouken@571
    59
    /* sanity check for set caption call before window init */
slouken@315
    60
    if (window!=NULL)
slouken@315
    61
    {
slouken@315
    62
        PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
slouken@315
    63
    }
slouken@315
    64
slouken@315
    65
    SDL_Unlock_EventThread();
slouken@19
    66
}
slouken@0
    67
slouken@266
    68
/* Iconify current window */
slouken@19
    69
int ph_IconifyWindow(_THIS)
slouken@19
    70
{
slouken@315
    71
    PhWindowEvent_t windowevent;
slouken@315
    72
slouken@315
    73
    SDL_Lock_EventThread();
slouken@0
    74
slouken@315
    75
    memset( &windowevent, 0, sizeof (event) );
slouken@315
    76
    windowevent.event_f = Ph_WM_HIDE;
slouken@315
    77
    windowevent.event_state = Ph_WM_EVSTATE_HIDE;
slouken@315
    78
    windowevent.rid = PtWidgetRid( window );
slouken@315
    79
    PtForwardWindowEvent( &windowevent );
slouken@315
    80
    SDL_Unlock_EventThread();
slouken@315
    81
slouken@315
    82
    return 0;
slouken@0
    83
}
slouken@0
    84
slouken@0
    85
SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
slouken@0
    86
{
slouken@571
    87
    short abs_x, abs_y;
slouken@571
    88
slouken@571
    89
    if( mode == SDL_GRAB_OFF )
slouken@571
    90
    {
slouken@571
    91
        PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISALTKEY);
slouken@571
    92
    }
slouken@571
    93
    else
slouken@571
    94
    {
slouken@571
    95
        PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISALTKEY);
slouken@571
    96
slouken@571
    97
        PtGetAbsPosition(window, &abs_x, &abs_y);
slouken@571
    98
        PhMoveCursorAbs(PhInputGroup(NULL), abs_x + SDL_VideoSurface->w/2, abs_y + SDL_VideoSurface->h/2);
slouken@571
    99
    }
slouken@571
   100
slouken@571
   101
    SDL_Unlock_EventThread();
slouken@571
   102
slouken@315
   103
    return(mode);
slouken@0
   104
}
slouken@0
   105
slouken@0
   106
SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode)
slouken@0
   107
{
slouken@571
   108
    SDL_Lock_EventThread();
slouken@571
   109
    mode = ph_GrabInputNoLock(this, mode);
slouken@571
   110
    SDL_Unlock_EventThread();
slouken@283
   111
slouken@571
   112
    return(mode);
slouken@571
   113
}
slouken@283
   114
slouken@0
   115
slouken@0
   116
int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
slouken@0
   117
{
slouken@315
   118
    if (info->version.major <= SDL_MAJOR_VERSION)
slouken@315
   119
    {
slouken@315
   120
        return 1;
slouken@315
   121
    }
slouken@315
   122
    else
slouken@315
   123
    {
slouken@315
   124
        SDL_SetError("Application not compiled with SDL %d.%d\n",
slouken@315
   125
                      SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
slouken@315
   126
        return -1;
slouken@315
   127
    }
slouken@0
   128
}