4 * The BlackBerry-specific windows message processing methods.
6 * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7 * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8 * Copied for Platform code by Evan Felix <karcaw at gmail.com>
9 * Copyright (C) 2012 Sylvain Beucler
10 * Copyright (C) 2013 Vincent Simonetti
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
26 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 #include <GL/freeglut.h>
31 #include "fg_internal.h"
32 #include "egl/fg_window_egl.h"
35 #define LOGI(...) ((void)slog2fa(NULL, 1337, SLOG2_INFO, __VA_ARGS__, SLOG2_FA_END))
36 #define LOGW(...) ((void)slog2fa(NULL, 1337, SLOG2_WARNING, __VA_ARGS__, SLOG2_FA_END))
37 #include <sys/keycodes.h>
38 #include <input/screen_helpers.h>
40 #include <bps/event.h>
41 #include <bps/screen.h>
42 #include <bps/navigator.h>
44 extern void fghOnReshapeNotify(SFG_Window *window, int width, int height, GLboolean forceNotify);
45 extern void fghOnPositionNotify(SFG_Window *window, int x, int y, GLboolean forceNotify);
46 extern void fgPlatformFullScreenToggle( SFG_Window *win );
47 extern void fgPlatformPositionWindow( SFG_Window *window, int x, int y );
48 extern void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height );
49 extern void fgPlatformPushWindow( SFG_Window *window );
50 extern void fgPlatformPopWindow( SFG_Window *window );
51 extern void fgPlatformHideWindow( SFG_Window *window );
52 extern void fgPlatformIconifyWindow( SFG_Window *window );
53 extern void fgPlatformShowWindow( SFG_Window *window );
54 extern void fgPlatformMainLoopPostWork ( void );
56 static struct touchscreen touchscreen;
58 unsigned int key_special(int qnxKeycode)
86 return GLUT_KEY_PAGE_UP;
88 return GLUT_KEY_PAGE_DOWN;
94 return GLUT_KEY_INSERT;
99 //case KEYCODE_KP_DOWN:
100 return GLUT_KEY_DOWN;
102 //case KEYCODE_KP_LEFT:
103 return GLUT_KEY_LEFT;
105 //case KEYCODE_KP_RIGHT:
106 return GLUT_KEY_RIGHT;
107 case KEYCODE_NUM_LOCK:
108 return GLUT_KEY_NUM_LOCK;
109 case KEYCODE_LEFT_ALT:
110 return GLUT_KEY_ALT_L;
111 case KEYCODE_RIGHT_ALT:
112 return GLUT_KEY_ALT_R;
113 case KEYCODE_LEFT_SHIFT:
114 return GLUT_KEY_SHIFT_L;
115 case KEYCODE_RIGHT_SHIFT:
116 return GLUT_KEY_SHIFT_R;
117 case KEYCODE_LEFT_CTRL:
118 return GLUT_KEY_CTRL_L;
119 case KEYCODE_RIGHT_CTRL:
120 return GLUT_KEY_CTRL_R;
125 unsigned char key_ascii(int qnxKeycode)
127 if (qnxKeycode >= KEYCODE_PC_KEYS && qnxKeycode <= UNICODE_PRIVATE_USE_AREA_LAST) {
128 switch (qnxKeycode) {
129 case KEYCODE_BACKSPACE:
133 case KEYCODE_KP_ENTER:
144 fg_time_t fgPlatformSystemTime ( void )
146 #ifdef CLOCK_MONOTONIC
148 clock_gettime(CLOCK_MONOTONIC, &now);
149 return now.tv_nsec/1000000 + now.tv_sec*1000;
150 #elif defined(HAVE_GETTIMEOFDAY)
152 gettimeofday( &now, NULL );
153 return now.tv_usec/1000 + now.tv_sec*1000;
158 * Does the magic required to relinquish the CPU until something interesting
161 void fgPlatformSleepForEvents( fg_time_t msec )
163 //XXX: Is this right? Is there a more direct way to access the context?
164 if(fgStructure.CurrentWindow && fgDisplay.pDisplay.event == NULL && bps_get_event(&fgDisplay.pDisplay.event, (int)msec) != BPS_SUCCESS) {
165 LOGW("BPS couldn't get event");
169 void handle_left_mouse(int x, int y, int height, int eventType, SFG_Window* window)
171 bool handled = false;
172 /* Virtual arrows PAD */
173 /* Don't interfere with existing mouse move event */
174 if (!touchscreen.in_mmotion) {
175 struct vpad_state prev_vpad = touchscreen.vpad;
176 touchscreen.vpad.left = touchscreen.vpad.right = touchscreen.vpad.up = touchscreen.vpad.down = false;
178 if (eventType == SCREEN_EVENT_MTOUCH_TOUCH || eventType == SCREEN_EVENT_MTOUCH_MOVE) {
179 if ((x > 0 && x < 100) && (y > (height - 100) && y < height))
181 touchscreen.vpad.left = true;
183 if ((x > 200 && x < 300) && (y > (height - 100) && y < height))
185 touchscreen.vpad.right = true;
187 if ((x > 100 && x < 200) && (y > (height - 100) && y < height))
189 touchscreen.vpad.down = true;
191 if ((x > 100 && x < 200) && (y > (height - 200) && y < (height - 100)))
193 touchscreen.vpad.up = true;
197 if (eventType == SCREEN_EVENT_MTOUCH_TOUCH &&
198 (touchscreen.vpad.left || touchscreen.vpad.right || touchscreen.vpad.down || touchscreen.vpad.up)) {
199 touchscreen.vpad.on = true;
201 if (eventType == SCREEN_EVENT_MTOUCH_RELEASE) {
202 touchscreen.vpad.on = false;
205 if (prev_vpad.left != touchscreen.vpad.left
206 || prev_vpad.right != touchscreen.vpad.right
207 || prev_vpad.up != touchscreen.vpad.up
208 || prev_vpad.down != touchscreen.vpad.down
209 || prev_vpad.on != touchscreen.vpad.on) {
210 if (FETCH_WCB(*window, Special)) {
211 if (prev_vpad.left == false && touchscreen.vpad.left == true) {
212 INVOKE_WCB(*window, Special, (GLUT_KEY_LEFT, x, y));
214 else if (prev_vpad.right == false && touchscreen.vpad.right == true) {
215 INVOKE_WCB(*window, Special, (GLUT_KEY_RIGHT, x, y));
217 else if (prev_vpad.up == false && touchscreen.vpad.up == true) {
218 INVOKE_WCB(*window, Special, (GLUT_KEY_UP, x, y));
220 else if (prev_vpad.down == false && touchscreen.vpad.down == true) {
221 INVOKE_WCB(*window, Special, (GLUT_KEY_DOWN, x, y));
224 if (FETCH_WCB(*window, SpecialUp)) {
225 if (prev_vpad.left == true && touchscreen.vpad.left == false) {
226 INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_LEFT, x, y));
228 if (prev_vpad.right == true && touchscreen.vpad.right == false) {
229 INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_RIGHT, x, y));
231 if (prev_vpad.up == true && touchscreen.vpad.up == false) {
232 INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_UP, x, y));
234 if (prev_vpad.down == true && touchscreen.vpad.down == false) {
235 INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_DOWN, x, y));
242 /* Normal mouse events */
243 if (!handled && !touchscreen.vpad.on) {
244 window->State.MouseX = x;
245 window->State.MouseY = y;
247 if(eventType == SCREEN_EVENT_MTOUCH_MOVE) {
248 INVOKE_WCB(*window, Motion, (x, y));
249 } else if(FETCH_WCB(*window, Mouse)) {
250 touchscreen.in_mmotion = eventType == SCREEN_EVENT_MTOUCH_TOUCH;
251 int glutTouchType = eventType == SCREEN_EVENT_MTOUCH_TOUCH ? GLUT_DOWN : GLUT_UP;
252 INVOKE_WCB(*window, Mouse, (GLUT_LEFT_BUTTON, glutTouchType, x, y));
258 * Determine a GLUT modifier mask based on BlackBerry modifier info.
260 int fgPlatformGetModifiers (int mod)
262 return (((mod & KEYMOD_SHIFT) ? GLUT_ACTIVE_SHIFT : 0) |
263 ((mod & KEYMOD_CTRL) ? GLUT_ACTIVE_CTRL : 0) |
264 ((mod & KEYMOD_ALT) ? GLUT_ACTIVE_ALT : 0));
267 void fgPlatformProcessSingleEvent ( void )
269 if(fgStructure.CurrentWindow == NULL)
270 //XXX Is this right? Would this just cause a whole lot of busy looping while we wait for events?
271 LOGW("fgPlatformProcessSingleEvent: Missing current window. Skipping event processing");
277 if(fgDisplay.pDisplay.event != NULL) {
278 SFG_Window* window = fgStructure.CurrentWindow;
279 if (window->Window.Handle != NULL) {
281 screen_get_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size);
282 fghOnReshapeNotify(window,size[0],size[1],GL_FALSE);
285 domain = bps_event_get_domain(fgDisplay.pDisplay.event);
286 if (domain == screen_get_domain()) {
289 screen_event_t screenEvent = screen_event_get_event(fgDisplay.pDisplay.event);
290 screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_TYPE, &eventType);
293 //Mostly from fg_main_android
294 case SCREEN_EVENT_MTOUCH_TOUCH:
295 case SCREEN_EVENT_MTOUCH_RELEASE:
296 case SCREEN_EVENT_MTOUCH_MOVE:
298 mtouch_event_t touchEvent;
299 screen_get_mtouch_event(screenEvent, &touchEvent, 0);
300 screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_KEY_MODIFIERS, &mod);
302 LOGI("fgPlatformProcessSingleEvent: SCREEN_EVENT_MTOUCH_*: Type: 0x%X, X: %d, Y: %d, Contact Id: %d, Mod: 0x%X", SLOG2_FA_SIGNED(eventType), SLOG2_FA_SIGNED(touchEvent.x), SLOG2_FA_SIGNED(touchEvent.y), SLOG2_FA_SIGNED(touchEvent.contact_id), SLOG2_FA_SIGNED(mod));
304 /* Remember the current modifiers state so user can query it from their callback */
305 fgState.Modifiers = fgPlatformGetModifiers(mod);
307 if(touchEvent.contact_id == 0) {
309 screen_get_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size);
310 handle_left_mouse(touchEvent.x, touchEvent.y, size[1], eventType, window);
313 //Now handle mutlitouch (adapted from fg_main_windows)
314 if (eventType == SCREEN_EVENT_MTOUCH_TOUCH) {
315 INVOKE_WCB( *window, MultiEntry, ( touchEvent.contact_id, GLUT_ENTERED ) );
316 INVOKE_WCB( *window, MultiButton, ( touchEvent.contact_id, touchEvent.x, touchEvent.y, 0, GLUT_DOWN ) );
317 } else if (eventType == SCREEN_EVENT_MTOUCH_MOVE) {
318 INVOKE_WCB( *window, MultiMotion, ( touchEvent.contact_id, touchEvent.x, touchEvent.y ) );
319 //XXX No motion is performed without contact, thus MultiPassive is never used
320 } else if (eventType == SCREEN_EVENT_MTOUCH_RELEASE) {
321 INVOKE_WCB( *window, MultiButton, ( touchEvent.contact_id, touchEvent.x, touchEvent.y, 0, GLUT_UP ) );
322 INVOKE_WCB( *window, MultiEntry, ( touchEvent.contact_id, GLUT_LEFT ) );
325 fgState.Modifiers = INVALID_MODIFIERS;
329 case SCREEN_EVENT_POINTER:
331 //Based off/part taken from GamePlay3d PlatformBlackBerry
332 static int mouse_pressed = 0;
336 // A move event will be fired unless a button state changed.
338 bool left_move = false;
339 // This is a mouse move event, it is applicable to a device with a usb mouse or simulator.
340 screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_BUTTONS, &buttons);
341 screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_SOURCE_POSITION, position);
342 screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_MOUSE_WHEEL, &wheel);
343 screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_KEY_MODIFIERS, &mod);
345 screen_get_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size);
347 LOGI("fgPlatformProcessSingleEvent: SCREEN_EVENT_POINTER: Buttons: 0x%X, X: %d, Y: %d, Wheel: %d, Mod: 0x%X", SLOG2_FA_SIGNED(buttons), SLOG2_FA_SIGNED(position[0]), SLOG2_FA_SIGNED(position[1]), SLOG2_FA_SIGNED(wheel), SLOG2_FA_SIGNED(mod));
349 //XXX Should multitouch be handled?
351 /* Remember the current modifiers state so user can query it from their callback */
352 fgState.Modifiers = fgPlatformGetModifiers(mod);
354 // Handle left mouse. Interpret as touch if the left mouse event is not consumed.
355 if (buttons & SCREEN_LEFT_MOUSE_BUTTON) {
356 if (mouse_pressed & SCREEN_LEFT_MOUSE_BUTTON) {
360 mouse_pressed |= SCREEN_LEFT_MOUSE_BUTTON;
361 handle_left_mouse(position[0], position[1], size[1], SCREEN_EVENT_MTOUCH_TOUCH, window);
363 } else if (mouse_pressed & SCREEN_LEFT_MOUSE_BUTTON) {
365 mouse_pressed &= ~SCREEN_LEFT_MOUSE_BUTTON;
366 handle_left_mouse(position[0], position[1], size[1], SCREEN_EVENT_MTOUCH_RELEASE, window);
369 // Handle right mouse.
370 if (buttons & SCREEN_RIGHT_MOUSE_BUTTON) {
371 if ((mouse_pressed & SCREEN_RIGHT_MOUSE_BUTTON) == 0) {
373 mouse_pressed |= SCREEN_RIGHT_MOUSE_BUTTON;
374 INVOKE_WCB(*window, Mouse, (GLUT_RIGHT_BUTTON, GLUT_DOWN, position[0], position[1]));
376 } else if (mouse_pressed & SCREEN_RIGHT_MOUSE_BUTTON) {
378 mouse_pressed &= ~SCREEN_RIGHT_MOUSE_BUTTON;
379 INVOKE_WCB(*window, Mouse, (GLUT_RIGHT_BUTTON, GLUT_UP, position[0], position[1]));
382 // Handle middle mouse.
383 if (buttons & SCREEN_MIDDLE_MOUSE_BUTTON) {
384 if ((mouse_pressed & SCREEN_MIDDLE_MOUSE_BUTTON) == 0) {
386 mouse_pressed |= SCREEN_MIDDLE_MOUSE_BUTTON;
387 INVOKE_WCB(*window, Mouse, (GLUT_MIDDLE_BUTTON, GLUT_DOWN, position[0], position[1]));
389 } else if (mouse_pressed & SCREEN_MIDDLE_MOUSE_BUTTON) {
391 mouse_pressed &= ~SCREEN_MIDDLE_MOUSE_BUTTON;
392 INVOKE_WCB(*window, Mouse, (GLUT_MIDDLE_BUTTON, GLUT_UP, position[0], position[1]));
395 // Fire a move event if none of the buttons changed.
396 if (left_move || move) {
397 handle_left_mouse(position[0], position[1], size[1], SCREEN_EVENT_MTOUCH_MOVE, window);
401 /* Very slightly modified from fg_main_mswin.
402 * Because we don't want MouseWheel to be called every. single. time.
403 * That the action occurs, we mimic the Windows version with "wheel deltas"
404 * XXX Do we even want this?
405 * XXX If we want this, it's possible to get horizontal scroll as well.
406 * XXX -Vertical scroll=wheel 0, horizontal=wheel 1? */
407 fgState.MouseWheelTicks -= wheel;
408 if (abs(fgState.MouseWheelTicks) >= WHEEL_DELTA)
410 int wheel_number = 0;
411 int direction = (fgState.MouseWheelTicks > 0) ? -1 : 1;
413 if (!FETCH_WCB(*window, MouseWheel) && !FETCH_WCB(*window, Mouse))
416 //XXX fgSetWindow(window);
418 while(abs(fgState.MouseWheelTicks) >= WHEEL_DELTA)
420 if (FETCH_WCB(*window, MouseWheel))
421 INVOKE_WCB(*window, MouseWheel, (wheel_number, direction, window->State.MouseX, window->State.MouseY));
422 else /* No mouse wheel, call the mouse button callback twice */
425 * Map wheel zero to button 3 and 4; +1 to 3, -1 to 4
426 * " " one +1 to 5, -1 to 6, ...
428 * XXX The below assumes that you have no more than 3 mouse
429 * XXX buttons. Sorry.
431 int button = wheel_number * 2 + 3;
434 INVOKE_WCB(*window, Mouse, (button, GLUT_DOWN, window->State.MouseX, window->State.MouseY));
435 INVOKE_WCB(*window, Mouse, (button, GLUT_UP, window->State.MouseX, window->State.MouseY));
438 fgState.MouseWheelTicks -= WHEEL_DELTA * direction;
443 fgState.Modifiers = INVALID_MODIFIERS;
447 //Based off fg_main_android
448 case SCREEN_EVENT_KEYBOARD:
452 screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_KEY_FLAGS, &flags);
453 screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_KEY_SYM, &value);
454 screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_KEY_MODIFIERS, &mod);
456 LOGI("fgPlatformProcessSingleEvent: SCREEN_EVENT_KEYBOARD. Flags: 0x%X, Sym: 0x%X, Mod: 0x%X", SLOG2_FA_SIGNED(flags), SLOG2_FA_SIGNED(value), SLOG2_FA_SIGNED(mod));
458 /* Suppress key repeats if desired. Based off fg_main_mswin */
459 if ((flags & KEY_REPEAT) == 0 || (fgState.KeyRepeat == GLUT_KEY_REPEAT_OFF && fgStructure.CurrentWindow->State.IgnoreKeyRepeat == GL_TRUE)) {
460 unsigned int keypress = 0;
461 unsigned char ascii = 0;
463 /* Remember the current modifiers state so user can query it from their callback */
464 fgState.Modifiers = fgPlatformGetModifiers(mod);
467 if ((keypress = key_special(value))) {
468 if(flags & KEY_DOWN) {
469 INVOKE_WCB(*window, Special, (keypress, window->State.MouseX, window->State.MouseY));
471 INVOKE_WCB(*window, SpecialUp, (keypress, window->State.MouseX, window->State.MouseY));
473 } else if((flags & KEY_SYM_VALID) && (ascii = key_ascii(value))) {
474 if(flags & KEY_DOWN) {
475 INVOKE_WCB(*window, Keyboard, (ascii, window->State.MouseX, window->State.MouseY));
477 INVOKE_WCB(*window, KeyboardUp, (ascii, window->State.MouseX, window->State.MouseY));
480 LOGW("fgPlatformProcessSingleEvent: SCREEN_EVENT_KEYBOARD. Unhandled key event");
483 fgState.Modifiers = INVALID_MODIFIERS;
488 case SCREEN_EVENT_PROPERTY:
489 case SCREEN_EVENT_IDLE:
493 LOGW("fgPlatformProcessSingleEvent: unknown screen event: 0x%X", SLOG2_FA_SIGNED(eventType));
496 } else if (domain == navigator_get_domain()) {
497 int eventType = bps_event_get_code(fgDisplay.pDisplay.event);
500 case NAVIGATOR_WINDOW_STATE:
502 LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE");
503 navigator_window_state_t state = navigator_event_get_window_state(fgDisplay.pDisplay.event);
506 case NAVIGATOR_WINDOW_FULLSCREEN:
507 LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE-NAVIGATOR_WINDOW_FULLSCREEN");
508 INVOKE_WCB(*window, AppStatus, (GLUT_APPSTATUS_RESUME));
510 case NAVIGATOR_WINDOW_THUMBNAIL:
511 case NAVIGATOR_WINDOW_INVISIBLE:
512 LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE-NAVIGATOR_WINDOW_THUMBNAIL/NAVIGATOR_WINDOW_INVISIBLE");
513 INVOKE_WCB(*window, AppStatus, (GLUT_APPSTATUS_PAUSE));
516 LOGW("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE unknown: 0x%X", SLOG2_FA_SIGNED(state));
524 LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_EXIT");
526 fgPlatformMainLoopPostWork();
528 /* User closed the application for good, let's kill the window */
529 SFG_Window* window = fgStructure.CurrentWindow;
530 if (window != NULL) {
531 fgDestroyWindow(window);
533 LOGW("NAVIGATOR_EXIT: No current window");
538 case NAVIGATOR_SWIPE_DOWN:
540 case NAVIGATOR_WINDOW_ACTIVE:
541 case NAVIGATOR_WINDOW_INACTIVE:
542 case NAVIGATOR_KEYBOARD_STATE:
543 case NAVIGATOR_KEYBOARD_POSITION:
544 case NAVIGATOR_DEVICE_LOCK_STATE:
545 case NAVIGATOR_WINDOW_COVER:
546 case NAVIGATOR_WINDOW_COVER_ENTER:
547 case NAVIGATOR_WINDOW_COVER_EXIT:
548 case NAVIGATOR_APP_STATE:
549 //XXX Should probably do something with these
553 LOGW("fgPlatformProcessSingleEvent: unknown navigator event: 0x%X", SLOG2_FA_SIGNED(eventType));
558 } while(bps_get_event(&fgDisplay.pDisplay.event, 1) == BPS_SUCCESS && fgDisplay.pDisplay.event != NULL);
560 /* Reset event to reduce chances of triggering something */
561 fgDisplay.pDisplay.event = NULL;
564 void fgPlatformMainLoopPreliminaryWork ( void )
566 LOGI("fgPlatformMainLoopPreliminaryWork");
568 /* Request navigator events */
569 navigator_request_events(0);
570 //XXX rotation lock? navigator_rotation_lock(true);
572 /* Request window events */
573 screen_request_events(fgDisplay.pDisplay.screenContext);
576 void fgPlatformMainLoopPostWork ( void )
578 LOGI("fgPlatformMainLoopPostWork");
580 screen_stop_events(fgDisplay.pDisplay.screenContext);
582 navigator_stop_events(0);
585 /* deal with work list items */
586 void fgPlatformInitWork(SFG_Window* window)
588 /* notify windowStatus/visibility */
589 INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_RETAINED ) );
591 /* Position callback, always at 0,0 */
592 fghOnPositionNotify(window, 0, 0, GL_TRUE);
594 /* Size gets notified on window creation with size detection in mainloop above
595 * XXX CHECK: does this messages happen too early like on windows,
596 * so client code cannot have registered a callback yet and the message
597 * is thus never received by client?
601 void fgPlatformPosResZordWork(SFG_Window* window, unsigned int workMask)
603 if (workMask & GLUT_FULL_SCREEN_WORK)
604 fgPlatformFullScreenToggle( window );
605 if (workMask & GLUT_POSITION_WORK)
606 fgPlatformPositionWindow( window, window->State.DesiredXpos, window->State.DesiredYpos );
607 if (workMask & GLUT_SIZE_WORK)
608 fgPlatformReshapeWindow ( window, window->State.DesiredWidth, window->State.DesiredHeight );
609 if (workMask & GLUT_ZORDER_WORK)
611 if (window->State.DesiredZOrder < 0)
612 fgPlatformPushWindow( window );
614 fgPlatformPopWindow( window );
618 void fgPlatformVisibilityWork(SFG_Window* window)
620 /* Visibility status of window should get updated in the window message handlers
621 * For now, none of these functions called below do anything, so don't worry
624 SFG_Window *win = window;
625 switch (window->State.DesiredVisibility)
627 case DesireHiddenState:
628 fgPlatformHideWindow( window );
630 case DesireIconicState:
631 /* Call on top-level window */
634 fgPlatformIconifyWindow( win );
636 case DesireNormalState:
637 fgPlatformShowWindow( window );