1 /*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2006 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21 */
22 #include "SDL_config.h"
23
24 #include <Ph.h>
25 #include <photon/PpProto.h>
26 #include <photon/PhWm.h>
27 #include <photon/wmapi.h>
28
29 #include "SDL_version.h"
30 #include "SDL_timer.h"
31 #include "SDL_video.h"
32 #include "SDL_syswm.h"
33 #include "../SDL_pixels_c.h"
34 #include "../../events/SDL_events_c.h"
35 #include "SDL_ph_modes_c.h"
36 #include "SDL_ph_wm_c.h"
37
ph_SetIcon(_THIS,SDL_Surface * icon,Uint8 * mask)38 void ph_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
39 {
40 return;
41 }
42
43 /* Set window caption */
ph_SetCaption(_THIS,const char * title,const char * icon)44 void ph_SetCaption(_THIS, const char *title, const char *icon)
45 {
46 SDL_Lock_EventThread();
47
48 /* sanity check for set caption call before window init */
49 if (window!=NULL)
50 {
51 PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
52 }
53
54 SDL_Unlock_EventThread();
55 }
56
57 /* Iconify current window */
ph_IconifyWindow(_THIS)58 int ph_IconifyWindow(_THIS)
59 {
60 PhWindowEvent_t windowevent;
61
62 SDL_Lock_EventThread();
63
64 SDL_memset(&windowevent, 0, sizeof(windowevent));
65 windowevent.event_f = Ph_WM_HIDE;
66 windowevent.event_state = Ph_WM_EVSTATE_HIDE;
67 windowevent.rid = PtWidgetRid(window);
68 PtForwardWindowEvent(&windowevent);
69
70 SDL_Unlock_EventThread();
71
72 return 0;
73 }
74
ph_GrabInputNoLock(_THIS,SDL_GrabMode mode)75 SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
76 {
77 short abs_x, abs_y;
78
79 if( mode == SDL_GRAB_OFF )
80 {
81 PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISALTKEY);
82 }
83 else
84 {
85 PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISALTKEY);
86
87 PtGetAbsPosition(window, &abs_x, &abs_y);
88 PhMoveCursorAbs(PhInputGroup(NULL), abs_x + SDL_VideoSurface->w/2, abs_y + SDL_VideoSurface->h/2);
89 }
90
91 SDL_Unlock_EventThread();
92
93 return(mode);
94 }
95
ph_GrabInput(_THIS,SDL_GrabMode mode)96 SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode)
97 {
98 SDL_Lock_EventThread();
99 mode = ph_GrabInputNoLock(this, mode);
100 SDL_Unlock_EventThread();
101
102 return(mode);
103 }
104
105
ph_GetWMInfo(_THIS,SDL_SysWMinfo * info)106 int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
107 {
108 if (info->version.major <= SDL_MAJOR_VERSION)
109 {
110 return 1;
111 }
112 else
113 {
114 SDL_SetError("Application not compiled with SDL %d.%d\n",
115 SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
116 return -1;
117 }
118 }
119