FreeWRL / FreeX3D 4.3.0
fwCommonX11.c
1/*
2
3 FreeWRL support library.
4 X11 common functions.
5
6*/
7
8/****************************************************************************
9 This file is part of the FreeWRL/FreeX3D Distribution.
10
11 Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
12
13 FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
14 it under the terms of the GNU Lesser Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 FreeWRL/FreeX3D is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
25****************************************************************************/
26
27#include <config.h>
28
29// OLD_IPHONE_AQUA #if !(defined(IPHONE) || defined(_ANDROID) || defined(AQUA))
30
31#if !(defined(_ANDROID))
32
33#include <system.h>
34#include <display.h>
35#include <internal.h>
36
37#include <threads.h>
38
39#include <libFreeWRL.h>
40
41#include "ui/common.h"
42#include <X11/cursorfont.h>
43
44static Cursor arrowc;
45static Cursor sensorc;
46static Cursor cursor;
47
48#if KEEP_X11_INLIB
49
50int win_height; /* window */
51int win_width;
52int fullscreen;
53int shutterGlasses; /* shutter glasses, stereo enabled ? */
54int quadbuff_stereo_mode; /* quad buffer enabled ? */
55
56GLXContext GLcx;
57long event_mask;
58XEvent event;
59Display *Xdpy;
60int Xscreen;
61Window Xroot_window;
62Colormap colormap;
63XVisualInfo *Xvi;
64Window Xwin;
65Window GLwin;
66XSetWindowAttributes attr;
67unsigned long mask = 0;
68Atom WM_DELETE_WINDOW;
69
70long event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask |
71 ButtonMotionMask | ButtonReleaseMask |
72 ExposureMask | StructureNotifyMask |
73 PointerMotionMask;
74
78#ifdef HAVE_XF86_VMODE
79
80int oldx = 0, oldy = 0;
81int vmode_nb_modes;
82XF86VidModeModeInfo **vmode_modes = NULL;
83int vmode_mode_selected = -1;
84
88static int mode_cmp(const void *pa,const void *pb)
89{
90 XF86VidModeModeInfo *a = *(XF86VidModeModeInfo**)pa;
91 XF86VidModeModeInfo *b = *(XF86VidModeModeInfo**)pb;
92 if(a->hdisplay > b->hdisplay) return -1;
93 return b->vdisplay - a->vdisplay;
94}
95
96void fv_switch_to_mode(int i)
97{
98 if ((!vmode_modes) || (i<0)) {
99 ERROR_MSG("fv_switch_to_mode: no valid mode available.\n");
100 return;
101 }
102
103 vmode_mode_selected = i;
104
105 win_width = vmode_modes[i]->hdisplay;
106 win_height = vmode_modes[i]->vdisplay;
107 TRACE_MSG("fv_switch_to_mode: mode selected: %d (%d,%d).\n",
108 vmode_mode_selected, win_width, win_height);
109 XF86VidModeSwitchToMode(Xdpy, Xscreen, vmode_modes[i]);
110 XF86VidModeSetViewPort(Xdpy, Xscreen, 0, 0);
111}
112#endif /* HAVE_XF86_VMODE */
113
117XVisualInfo *fv_find_best_visual()
118{
119 XVisualInfo *vi = NULL;
120#define DEFAULT_COMPONENT_WEIGHT 5
121
122 /*
123 * If FreeWRL is to be configurable one day,
124 * we will improve this visual query.
125 * One possibility: glXGetConfig.
126 */
127 static int attribs[100] = {
128 GLX_RGBA,
129 GLX_DOUBLEBUFFER,
130 GLX_RED_SIZE, DEFAULT_COMPONENT_WEIGHT,
131 GLX_GREEN_SIZE, DEFAULT_COMPONENT_WEIGHT,
132 GLX_BLUE_SIZE, DEFAULT_COMPONENT_WEIGHT,
133 GLX_ALPHA_SIZE, DEFAULT_COMPONENT_WEIGHT,
134 GLX_DEPTH_SIZE, DEFAULT_COMPONENT_WEIGHT,
135 None
136 };
137
138 if (shutterGlasses) {
139 /* FIXME: handle stereo visual creation */
140#ifdef STEREOCOMMAND
141 system(STEREOCOMMAND);
142#endif
143 }
144
145 if ((shutterGlasses) && (quadbuff_stereo_mode == 0)) {
146 TRACE_MSG("Warning: No quadbuffer stereo visual found !");
147 TRACE_MSG("On SGI IRIX systems read 'man setmon' or 'man xsetmon'\n");
148 }
149
150 quadbuff_stereo_mode = 0;
151
152 vi = glXChooseVisual(Xdpy, Xscreen, attribs);
153 return vi;
154}
155
156static int fv_catch_XLIB(Display *disp, XErrorEvent *err)
157{
158 static int XLIB_errors = 0;
159 static char error_msg[4096];
160
161 XGetErrorText(disp, err->error_code, error_msg, sizeof(error_msg));
162
163 ERROR_MSG("FreeWRL caught an XLib error !\n"
164 " Display: %s (%p)\n"
165 " Error code: %d\n"
166 " Error msg: %s\n"
167 " Request: %d\n",
168 XDisplayName(NULL), disp, err->error_code,
169 error_msg, err->request_code);
170
171 XLIB_errors++;
172 if (XLIB_errors > 20) {
173 ERROR_MSG("FreeWRL - too many XLib errors (%d>20), exiting...\n", XLIB_errors);
174 exit(0);
175 }
176 return 0;
177}
178
179int fv_create_colormap()
180{
181 colormap = XCreateColormap(Xdpy, RootWindow(Xdpy, Xvi->screen),Xvi->visual, AllocNone);
182 return TRUE;
183}
184
185/* void setMenuFps(float fps) */
186/* { */
187/* myFps = fps; */
188/* setMessageBar(); */
189/* } */
190
191void fv_resetGeometry()
192{
193#ifdef HAVE_XF86_VMODE
194 int oldMode, i;
195
196 if (fullscreen) {
197 XF86VidModeGetAllModeLines(Xdpy, Xscreen, &vmode_nb_modes, &vmode_modes);
198 oldMode = 0;
199
200 for (i=0; i < vmode_nb_modes; i++) {
201 if ((vmode_modes[i]->hdisplay == oldx) && (vmode_modes[i]->vdisplay==oldy)) {
202 oldMode = i;
203 break;
204 }
205 }
206
207 XF86VidModeSwitchToMode(Xdpy, Xscreen, vmode_modes[oldMode]);
208 XF86VidModeSetViewPort(Xdpy, Xscreen, 0, 0);
209 XFlush(Xdpy);
210 }
211#endif /* HAVE_XF86_VMODE */
212}
213
214/*======== "VIRTUAL FUNCTIONS" ==============*/
215
219int fv_open_display()
220{
221 char *display;
222
223 fwl_thread_dump();
224
225 /* Display */
226 XInitThreads();
227
228 display = getenv("DISPLAY");
229 Xdpy = XOpenDisplay(display);
230 if (!Xdpy) {
231 ERROR_MSG("can't open display %s.\n", display);
232 return FALSE;
233 }
234
235 /* start up a XLib error handler to catch issues with FreeWRL. There
236 should not be any issues, but, if there are, we'll most likely just
237 throw our hands up, and continue */
238 XSetErrorHandler(fv_catch_XLIB);
239
240 Xscreen = DefaultScreen(Xdpy);
241 Xroot_window = RootWindow(Xdpy,Xscreen);
242
243 /* Visual */
244
245 Xvi = fv_find_best_visual();
246 if(!Xvi) {
247 ERROR_MSG("FreeWRL can not find an appropriate visual from GLX\n");
248 return FALSE;
249 }
250
251 /* Fullscreen */
252
253 if (fullscreen) {
254#ifdef HAVE_XF86_VMODE
255 int i;
256 if (vmode_modes == NULL) {
257 if (XF86VidModeGetAllModeLines(Xdpy, Xscreen, &vmode_nb_modes, &vmode_modes) == 0) {
258 ERROR_MSG("can`t get mode lines through XF86VidModeGetAllModeLines.\n");
259 return FALSE;
260 }
261 qsort(vmode_modes, vmode_nb_modes, sizeof(XF86VidModeModeInfo*), mode_cmp);
262 }
263 for (i = 0; i < vmode_nb_modes; i++) {
264 if (vmode_modes[i]->hdisplay <= win_width && vmode_modes[i]->vdisplay <= win_height) {
265 fv_switch_to_mode(i);
266 break;
267 }
268 }
269#endif
270 }
271
272
273 /* Color map */
274 fv_create_colormap();
275
276 /* Initialize cursors */
277 loadCursors();
278
279 return TRUE;
280}
281
282/*=== fv_create_main_window: in fwBareWindow.c or in fwMotifWindow.c */
283
288bool fv_create_GLcontext()
289{
290 int direct_rendering = TRUE;
291
292 fwl_thread_dump();
293
294#if defined(TARGET_X11) || defined(TARGET_MOTIF)
295
296 GLcx = glXCreateContext(Xdpy, Xvi, NULL, direct_rendering);
297 if (!GLcx) {
298 ERROR_MSG("can't create OpenGL context.\n");
299 return FALSE;
300 }
301 if (glXIsDirect(Xdpy, GLcx)) {
302 TRACE_MSG("glX: direct rendering enabled\n");
303 }
304#endif
305 return TRUE;
306}
307bool fv_create_GLcontext1(freewrl_params_t *share)
308{
309 GLXContext share_context;
310 int direct_rendering = TRUE;
311 share_context = NULL;
312 if(share) share_context = share->context;
313
314 fwl_thread_dump();
315
316#if defined(TARGET_X11) || defined(TARGET_MOTIF)
317
318 GLcx = glXCreateContext(Xdpy, Xvi, share_context, direct_rendering);
319 if (!GLcx) {
320 ERROR_MSG("can't create OpenGL context.\n");
321 return FALSE;
322 }
323 if (glXIsDirect(Xdpy, GLcx)) {
324 TRACE_MSG("glX: direct rendering enabled\n");
325 }
326#endif
327 return TRUE;
328}
333bool fv_bind_GLcontext()
334{
335 fwl_thread_dump();
336
337#if defined(TARGET_X11) || defined(TARGET_MOTIF)
338 if (!Xwin) {
339 ERROR_MSG("window not initialized, can't initialize OpenGL context.\n");
340 return FALSE;
341 }
342 if (!glXMakeCurrent(Xdpy, GLwin, GLcx)) {
343/*
344 ERROR_MSG("fv_bind_GLcontext: can't set OpenGL context for this thread %d (glXMakeCurrent: %s).\n", fw_thread_id(), GL_ERROR_MSG);
345*/
346 ERROR_MSG("fv_bind_GLcontext: can't set OpenGL context for this thread %d , glGetError=%d).\n", fw_thread_id(), glGetError());
347 return FALSE;
348 }
349#endif
350
351// OLD_IPHONE_AQUA #if defined(TARGET_AQUA)
352// OLD_IPHONE_AQUA return aglSetCurrentContext(aqglobalContext);
353// OLD_IPHONE_AQUA #endif
354
355 return TRUE;
356}
357#endif /* KEEP_FV_INLIB */
358
363void loadCursors() {
364 arrowc = XCreateFontCursor(Xdpy,XC_arrow);
365 sensorc = XCreateFontCursor(Xdpy,XC_hand1);
366}
367
372void setCursor(int ccurse)
373{
374 switch (ccurse) {
375 case SCURSE: cursor = sensorc; break;
376 case ACURSE: cursor = arrowc; break;
377 default:
378 DEBUG_MSG("setCursor: invalid value for ccurse: %d\n", ccurse);
379 }
380 XDefineCursor(Xdpy, GLwin, cursor);
381}
382
383void setWindowTitle()
384{
385 XStoreName(Xdpy, Xwin, getWindowTitle());
386 XSetIconName(Xdpy, Xwin, getWindowTitle());
387}
388int fv_create_window_and_context(freewrl_params_t *params, freewrl_params_t *share){
389 /* make the window, create the OpenGL context, share the context if necessary
390 Nov 2015: linux desktop is still single windowed, with static GLXContext etc, no sharing
391 - to get sharing, you need to populate params during creation of window and gl context
392 d->display = Display *Xdpy;
393 d->surface = Drawable or ???
394 d->context = GLXContext GLcx;
395 so when the targetwindow changes, there's enough info to do glXMakeCurrent and glXSwapBuffers
396 - and when doing glCreateContext you have the previous window's GLXcontext to use as a shareList
397 */
398
399
400 if (!fv_open_display()) {
401 printf("open_display failed\n");
402 return FALSE;
403 }
404
405 if (!fv_create_GLcontext1(share)) {
406 printf("create_GLcontext failed\n");
407 return FALSE;
408 }
409 fv_create_main_window(params);
410
411 fv_bind_GLcontext();
412 //scrape parameters from statics
413 params->context = GLcx;
414 params->display = Xdpy;
415
416 // JAS - this is actually a "Window" but store it as a pointer...
417 params->surface = (void*) GLwin;
418
419 return TRUE;
420}
421// remember, Window {aka long unsigned int} is stored as a pointer, so
422// type cast it back again.
423
424void fv_change_GLcontext(freewrl_params_t* d){
425 glXMakeCurrent(d->display,
426 (Window) d->surface,
427 d->context);
428}
429void fv_swapbuffers(freewrl_params_t* d){
430 glXSwapBuffers(d->display,
431 (Window) d->surface);
432}
433
434#define TRY_MAINLOOP_STUFF_HERE 1
435#ifdef TRY_MAINLOOP_STUFF_HERE
436//XK_ constants from /usr/include/X11/keysymdef.h
437#define PHOME_KEY XK_Home //80
438#define PPGDN_KEY XK_Page_Down //86
439#define PLEFT_KEY XK_Left //106
440#define PEND_KEY XK_End //87
441#define PUP_KEY XK_Up //112
442#define PRIGHT_KEY XK_Right //108
443#define PPGUP_KEY XK_Page_Up //85
444#define PDOWN_KEY XK_Down //59
445#define PF1_KEY XK_F1 //0xFFBE
446#define PF12_KEY XK_F12 //0XFFC9
447#define PALT_KEY XK_Alt_L //0XFFE9 //left, and 0XFFEA //0XFFE7
448#define PALT_KEYR XK_Alt_R //0XFFE9 //left, and 0XFFEA //0XFFE7
449#define PCTL_KEY XK_Control_L //0XFFE3 //left, and 0XFFE4 on right
450#define PCTL_KEYR XK_Control_R //0XFFE3 //left, and 0XFFE4 on right
451#define PSFT_KEY XK_Shift_L //0XFFE1 //left, and 0XFFE2 on right
452#define PSFT_KEYR XK_Shift_R //0XFFE1 //left, and 0XFFE2 on right
453#define PDEL_KEY XK_Delete //0XFF9F //on numpad, and 0XFFFF near Insert //0x08
454#define PNUM0 XK_KP_Insert //XK_KP_0
455#define PNUM1 XK_KP_End //XK_KP_1
456#define PNUM2 XK_KP_Down //XK_KP_2
457#define PNUM3 XK_KP_Page_Down //XK_KP_3
458#define PNUM4 XK_KP_Left //XK_KP_4
459#define PNUM5 XK_KP_Begin //XK_KP_5
460#define PNUM6 XK_KP_Right //XK_KP_6
461#define PNUM7 XK_KP_Home //XK_KP_7
462#define PNUM8 XK_KP_Up //XK_KP_8
463#define PNUM9 XK_KP_Page_Up //XK_KP_9
464#define PNUMDEC XK_KP_Delete //XK_KP_Decimal
465
467//section 21.4.1
468//Key Value
469//Home 13
470//End 14
471//PGUP 15
472//PGDN 16
473//UP 17
474//DOWN 18
475//LEFT 19
476//RIGHT 20
477//F1-F12 1 to 12
478//ALT,CTRL,SHIFT true/false
479//*/
480//#define F1_KEY 1
481//#define F2_KEY 2
482//#define F3_KEY 3
483//#define F4_KEY 4
484//#define F5_KEY 5
485//#define F6_KEY 6
486//#define F7_KEY 7
487//#define F8_KEY 8
488//#define F9_KEY 9
489//#define F10_KEY 10
490//#define F11_KEY 11
491//#define F12_KEY 12
492//#define HOME_KEY 13
493//#define END_KEY 14
494//#define PGUP_KEY 15
495//#define PGDN_KEY 16
496//#define UP_KEY 17
497//#define DOWN_KEY 18
498//#define LEFT_KEY 19
499//#define RIGHT_KEY 20
500//#define ALT_KEY 30 /* not available on OSX */
501//#define CTL_KEY 31 /* not available on OSX */
502//#define SFT_KEY 32 /* not available on OSX */
503//#define DEL_KEY 0XFFFF /* problem: I'm insterting this back into the translated char stream so 0XFFFF too high to clash with a latin? */
504//#define RTN_KEY 13 //what about 10 newline?
505
506
507int platform2web3dActionKeyLINUX(int platformKey)
508{
509 int key;
510
511 key = 0; //platformKey;
512 if(platformKey >= PF1_KEY && platformKey <= PF12_KEY)
513 key = platformKey - PF1_KEY + F1_KEY;
514 else
515 switch(platformKey)
516 {
517 case PHOME_KEY:
518 key = HOME_KEY; break;
519 case PEND_KEY:
520 key = END_KEY; break;
521 case PPGDN_KEY:
522 key = PGDN_KEY; break;
523 case PPGUP_KEY:
524 key = PGUP_KEY; break;
525 case PUP_KEY:
526 key = UP_KEY; break;
527 case PDOWN_KEY:
528 key = DOWN_KEY; break;
529 case PLEFT_KEY:
530 key = LEFT_KEY; break;
531 case PRIGHT_KEY:
532 key = RIGHT_KEY; break;
533 case PDEL_KEY:
534 key = DEL_KEY; break;
535 case PALT_KEY:
536 case PALT_KEYR:
537 key = ALT_KEY; break;
538 case PCTL_KEY:
539 case PCTL_KEYR:
540 key = CTL_KEY; break;
541 case PSFT_KEY:
542 case PSFT_KEYR:
543 key = SFT_KEY; break;
544 case PNUM0:
545 key = NUM0; break;
546 case PNUM1:
547 key = NUM1; break;
548 case PNUM2:
549 key = NUM2; break;
550 case PNUM3:
551 key = NUM3; break;
552 case PNUM4:
553 key = NUM4; break;
554 case PNUM5:
555 key = NUM5; break;
556 case PNUM6:
557 key = NUM6; break;
558 case PNUM7:
559 key = NUM7; break;
560 case PNUM8:
561 key = NUM8; break;
562 case PNUM9:
563 key = NUM9; break;
564 case PNUMDEC:
565 key = NUMDEC; break;
566 default:
567 key = 0;
568 }
569 return key;
570}
571
572//#include <libFreeWRL.h>
573void handle_Xevents(XEvent event) {
574
575 XEvent nextevent;
576 char buf[10];
577 KeySym ks, ksraw, ksupper, kslower;
578 KeySym *keysym;
579
580 int keysyms_per_keycode_return;
581
582 //int count;
583 int actionKey, windex;
584 int cursorStyle;
585 //ppMainloop p;
586 //ttglobal tg = gglobal();
587 //p = (ppMainloop)tg->Mainloop.prv;
588 //p->lastMouseEvent=event.type;
589
590#ifdef VERBOSE
591 switch (event.type) {
592 case ConfigureNotify: printf ("Event: ConfigureNotify\n"); break;
593 case ClientMessage: printf ("Event: ClientMessage\n"); break;
594 case KeyPress: printf ("Event: KeyPress\n"); break;
595 case KeyRelease: printf ("Event: KeyRelease\n"); break;
596 case ButtonPress: printf ("Event: ButtonPress\n"); break;
597 case ButtonRelease: printf ("Event: ButtonRelease\n"); break;
598 case MotionNotify: printf ("Event: MotionNotify\n"); break;
599 case MapNotify: printf ("Event: MapNotify\n"); break;
600 case UnmapNotify: printf ("Event: *****UnmapNotify\n"); break;
601 default: printf ("event, unknown %d\n", event.type);
602 }
603#endif
604 // window is Window {aka long unsigned int} but we store it as a void *, so...
605 windex = fwl_hwnd_to_windex( (void *)event.xany.window); //sets it if doesn't exist
606
607 switch(event.type) {
608//#ifdef HAVE_NOTOOLKIT
609 /* Motif, etc, usually handles this. */
610 case ConfigureNotify:
611 /* printf("%s,%d ConfigureNotify %d %d\n",__FILE__,__LINE__,event.xconfigure.width,event.xconfigure.height); */
612//#ifdef STATUSBAR_HUD
613// statusbar_set_window_size(event.xconfigure.width,event.xconfigure.height);
614//#else
615 fwl_setScreenDim1 (event.xconfigure.width,event.xconfigure.height,windex);
616//#endif
617 break;
618//#endif
619 case ClientMessage:
620 if (event.xclient.data.l[0] == WM_DELETE_WINDOW && !RUNNINGASPLUGIN) {
621 #ifdef VERBOSE
622 printf("---XClient sent wmDeleteMessage, quitting freewrl\n");
623 #endif
624 fwl_doQuit(__FILE__,__LINE__);
625 }
626 break;
627 case KeyPress:
628 case KeyRelease:
629 XLookupString(&event.xkey,buf,sizeof(buf),&ks,0);
631 //if(0) switch(ks) {
632 // /* the non-keyboard arrow keys*/
633 // case XK_Left: ks = XK_j; break;
634 // case XK_Right: ks = XK_l; break;
635 // case XK_Up: ks = XK_p; break;
636 // case XK_Down: ks = XK_semicolon; break;
637 // case XK_KP_0:
638 // case XK_KP_Insert:
639 // ks = XK_a; break;
640 // case XK_KP_Decimal:
641 // case XK_KP_Delete:
642 // ks = XK_z; break;
643 // case XK_KP_7:
644 // case XK_KP_Home:
645 // ks = XK_7; break;
646 // case XK_KP_9:
647 // case XK_KP_Page_Up:
648 // ks = XK_9; break;
649 // case XK_KP_8:
650 // case XK_KP_Up:
651 // ks = XK_k; break;
652 // case XK_KP_2:
653 // case XK_KP_Down:
654 // ks = XK_8; break;
655 // case XK_KP_4:
656 // case XK_KP_Left:
657 // ks = XK_u; break;
658 // case XK_KP_6:
659 // case XK_KP_Right:
660 // ks = XK_o; break;
661 // case XK_Num_Lock: ks = XK_h; break;
662 // default: break;
663 //}
664
665 /* doubt that this is necessary */
666 buf[0]=(char)ks;buf[1]='\0';
667
668 DEBUG_XEV("Key type = %s\n", (event.type == KeyPress ? "KEY PRESS" : "KEY RELEASE"));
669 //fwl_do_keyPress((char)ks,event.type);
670 //ksraw = (char)buf[0];
671
672
673 // deprecated: ksraw = XKeycodeToKeysym(event.xkey.display, event.xkey.keycode, 0);
674
675 keysym = XGetKeyboardMapping(event.xkey.display,
676 event.xkey.keycode, 1, &keysyms_per_keycode_return);
677 ksraw = *keysym;
678 XFree(keysym);
679
680 XConvertCase(ksraw,&kslower,&ksupper);
681
682 ksraw = ksupper;
683 if(event.type == KeyRelease && !IsModifierKey(ks)
684 && !IsFunctionKey(ks) && !IsMiscFunctionKey(ks) && !IsCursorKey(ks)){
685 fwl_do_rawKeyPress((int)ks,1);
686 //printf("ks=%c %d %o %x\n",ks,(int)ks,(int)ks,(int)ks);
687 }
688 //printf("ksraw=%c %d %o %x\n",ksraw,(int)ksraw,(int)ksraw,(int)ksraw);
689 actionKey = platform2web3dActionKeyLINUX(ksraw);
690 if(actionKey)
691 fwl_do_rawKeyPress(actionKey,event.type+10);
692 else
693 fwl_do_rawKeyPress(ksraw,event.type);
694 break;
695
696 case ButtonPress:
697 case ButtonRelease:
698 cursorStyle = fwl_handle_mouse(event.type,event.xbutton.button,event.xbutton.x,event.xbutton.y,windex);
699 setCursor(cursorStyle);
700 //if(0){
701 // /* printf("got a button press or button release\n"); */
702 // /* if a button is pressed, we should not change state,*/
703 // /* so keep a record.*/
704 // if(handleStatusbarHud(event.type, &tg->Mainloop.clipPlane))break;
705 // if (event.xbutton.button>=5) break; /* bounds check*/
706 // p->ButDown[p->currentCursor][event.xbutton.button] = (event.type == ButtonPress);
707
708 // /* if we are Not over an enabled sensitive node, and we do NOT
709 // already have a button down from a sensitive node... */
710 // /* printf("cursoroversensitive is %u lastPressedOver %u\n", p->CursorOverSensitive,p->lastPressedOver); */
711 // if ((p->CursorOverSensitive==NULL) && (p->lastPressedOver==NULL)) {
712 // p->NavigationMode=p->ButDown[p->currentCursor][1] || p->ButDown[p->currentCursor][3];
713 // handle (event.type,event.xbutton.button,
714 // (float) ((float)event.xbutton.x/tg->display.screenWidth),
715 // (float) ((float)event.xbutton.y/tg->display.screenHeight));
716 // }
717 //}
718 break;
719
720 case MotionNotify:
721#if KEEP_X11_INLIB
722 /* printf("got a motion notify\n"); */
723 /* do we have more motion notify events queued?*/
724 if (XPending(Xdpy)) {
725 XPeekEvent(Xdpy,&nextevent);
726 if (nextevent.type==MotionNotify) { break;
727 }
728 }
729#endif /* KEEP_X11_INLIB */
730 cursorStyle = fwl_handle_mouse(event.type,event.xbutton.button,event.xbutton.x,event.xbutton.y,windex);
731 setCursor(cursorStyle);
732 //if(0){
733
734 // /* save the current x and y positions for picking.*/
735 // tg->Mainloop.currentX[p->currentCursor] = event.xbutton.x;
736 // tg->Mainloop.currentY[p->currentCursor] = event.xbutton.y;
737 // /* printf("navigationMode is %d\n", NavigationMode); */
738 // if(handleStatusbarHud(6, &tg->Mainloop.clipPlane))break;
739 // if (p->NavigationMode) {
740 // /* find out what the first button down is*/
741 // count = 0;
742 // while ((count < 5) && (!p->ButDown[p->currentCursor][count])) count++;
743 // if (count == 5) return; /* no buttons down???*/
744
745 // handle (event.type,(unsigned)count,
746 // (float)((float)event.xbutton.x/tg->display.screenWidth),
747 // (float)((float)event.xbutton.y/tg->display.screenHeight));
748 // }
749 //}
750 break;
751 }
752}
753#endif //TRY_MAINLOOP_STUFF_HERE
754
755
756#endif /* IPHONE */
Initialization.
Definition libFreeWRL.h:72
Definition Viewer.h:139