Mercurial > sdl-ios-xcode
annotate src/events/SDL_windowevents.c @ 5260:b0f5108fda60
Cleaned up the file a bit for tutorial viewing
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 11 Feb 2011 13:06:35 -0800 |
parents | 7a963be087ef |
children | 595814f561f7 |
rev | line source |
---|---|
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
3697 | 3 Copyright (C) 1997-2010 Sam Lantinga |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 /* Window event handling code for SDL */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #include "SDL_events.h" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 #include "SDL_events_c.h" |
2794
f7872b7a8732
Fixed mouse coordinate range on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1970
diff
changeset
|
28 #include "SDL_mouse_c.h" |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include "../video/SDL_sysvideo.h" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
3573 | 31 |
32 static int | |
33 RemovePendingSizeEvents(void * userdata, SDL_Event *event) | |
34 { | |
35 SDL_Event *new_event = (SDL_Event *)userdata; | |
36 | |
37 if (event->type == SDL_WINDOWEVENT && | |
38 event->window.event == SDL_WINDOWEVENT_RESIZED && | |
39 event->window.windowID == new_event->window.windowID) { | |
40 /* We're about to post a new size event, drop the old one */ | |
41 return 0; | |
42 } | |
43 return 1; | |
44 } | |
45 | |
5042
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
46 static int |
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
47 RemovePendingMoveEvents(void * userdata, SDL_Event *event) |
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
48 { |
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
49 SDL_Event *new_event = (SDL_Event *)userdata; |
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
50 |
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
51 if (event->type == SDL_WINDOWEVENT && |
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
52 event->window.event == SDL_WINDOWEVENT_MOVED && |
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
53 event->window.windowID == new_event->window.windowID) { |
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
54 /* We're about to post a new move event, drop the old one */ |
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
55 return 0; |
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
56 } |
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
57 return 1; |
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
58 } |
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
59 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 int |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3573
diff
changeset
|
61 SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 int data2) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 int posted; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 if (!window) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 switch (windowevent) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 case SDL_WINDOWEVENT_SHOWN: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 if (window->flags & SDL_WINDOW_SHOWN) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 window->flags |= SDL_WINDOW_SHOWN; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 SDL_OnWindowShown(window); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 case SDL_WINDOWEVENT_HIDDEN: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 if (!(window->flags & SDL_WINDOW_SHOWN)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 window->flags &= ~SDL_WINDOW_SHOWN; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 SDL_OnWindowHidden(window); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 case SDL_WINDOWEVENT_MOVED: |
5254
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
85 if (SDL_WINDOWPOS_ISUNDEFINED(data1) || |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
86 SDL_WINDOWPOS_ISUNDEFINED(data2)) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 } |
5254
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
89 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
90 window->fullscreen.x = data1; |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
91 window->fullscreen.y = data1; |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
92 } else { |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
93 window->windowed.x = data1; |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
94 window->windowed.y = data1; |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
95 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 if (data1 == window->x && data2 == window->y) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 } |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
99 window->x = data1; |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
100 window->y = data2; |
5254
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
101 |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
102 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
103 /* Do we really want to do this? */ |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
104 return 0; |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
105 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 case SDL_WINDOWEVENT_RESIZED: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
5254
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
109 window->fullscreen.w = data1; |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
110 window->fullscreen.h = data1; |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
111 } else { |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
112 window->windowed.w = data1; |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
113 window->windowed.h = data1; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 if (data1 == window->w && data2 == window->h) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 } |
1915
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
118 window->w = data1; |
a228436a2404
Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
119 window->h = data2; |
5169
4d39eeaad00b
Added a way to get a framebuffer interface for a window, and also a way to create a software renderer for an arbitrary surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5150
diff
changeset
|
120 SDL_OnWindowResized(window); |
5254
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
121 |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
122 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
123 /* Do we really want to do this? */ |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
124 return 0; |
7a963be087ef
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
125 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 case SDL_WINDOWEVENT_MINIMIZED: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 if (window->flags & SDL_WINDOW_MINIMIZED) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 window->flags |= SDL_WINDOW_MINIMIZED; |
3502
98a819296cdc
Whenever a window becomes fullscreen, shown, unminimized, and has input focus it will change the display to the corresponding fullscreen video mode.
Sam Lantinga <slouken@libsdl.org>
parents:
2875
diff
changeset
|
132 SDL_OnWindowMinimized(window); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 case SDL_WINDOWEVENT_MAXIMIZED: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 if (window->flags & SDL_WINDOW_MAXIMIZED) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 window->flags |= SDL_WINDOW_MAXIMIZED; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 case SDL_WINDOWEVENT_RESTORED: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 if (!(window->flags & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 window->flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED); |
3502
98a819296cdc
Whenever a window becomes fullscreen, shown, unminimized, and has input focus it will change the display to the corresponding fullscreen video mode.
Sam Lantinga <slouken@libsdl.org>
parents:
2875
diff
changeset
|
145 SDL_OnWindowRestored(window); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 case SDL_WINDOWEVENT_ENTER: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 if (window->flags & SDL_WINDOW_MOUSE_FOCUS) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 window->flags |= SDL_WINDOW_MOUSE_FOCUS; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 case SDL_WINDOWEVENT_LEAVE: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 window->flags &= ~SDL_WINDOW_MOUSE_FOCUS; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 case SDL_WINDOWEVENT_FOCUS_GAINED: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 if (window->flags & SDL_WINDOW_INPUT_FOCUS) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 window->flags |= SDL_WINDOW_INPUT_FOCUS; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 SDL_OnWindowFocusGained(window); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 case SDL_WINDOWEVENT_FOCUS_LOST: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 if (!(window->flags & SDL_WINDOW_INPUT_FOCUS)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 window->flags &= ~SDL_WINDOW_INPUT_FOCUS; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 SDL_OnWindowFocusLost(window); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 /* Post the event, if desired */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 posted = 0; |
4429
faa9fc8e7f67
General improvements for user custom event registration
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
177 if (SDL_GetEventState(SDL_WINDOWEVENT) == SDL_ENABLE) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 SDL_Event event; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 event.type = SDL_WINDOWEVENT; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 event.window.event = windowevent; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 event.window.data1 = data1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 event.window.data2 = data2; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3573
diff
changeset
|
183 event.window.windowID = window->id; |
3573 | 184 |
185 /* Fixes queue overflow with resize events that aren't processed */ | |
186 if (windowevent == SDL_WINDOWEVENT_RESIZED) { | |
187 SDL_FilterEvents(RemovePendingSizeEvents, &event); | |
188 } | |
5042
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
189 if (windowevent == SDL_WINDOWEVENT_MOVED) { |
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
190 SDL_FilterEvents(RemovePendingMoveEvents, &event); |
8c39b82dc7b0
Window move events have the same problem as size events on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
191 } |
3573 | 192 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 posted = (SDL_PushEvent(&event) > 0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 } |
5115
686d795b1b29
When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
krogoway
parents:
5042
diff
changeset
|
195 |
686d795b1b29
When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
krogoway
parents:
5042
diff
changeset
|
196 if (windowevent == SDL_WINDOWEVENT_CLOSE) { |
686d795b1b29
When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
krogoway
parents:
5042
diff
changeset
|
197 if ( !window->prev && !window->next ) { |
686d795b1b29
When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
krogoway
parents:
5042
diff
changeset
|
198 // This is the last window in the list so send the SDL_QUIT event |
686d795b1b29
When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
krogoway
parents:
5042
diff
changeset
|
199 SDL_SendQuit(); |
686d795b1b29
When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
krogoway
parents:
5042
diff
changeset
|
200 } |
686d795b1b29
When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
krogoway
parents:
5042
diff
changeset
|
201 } |
686d795b1b29
When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
krogoway
parents:
5042
diff
changeset
|
202 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 return (posted); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 /* vi: set ts=4 sw=4 expandtab: */ |