-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFionaUTLinux.cpp
More file actions
669 lines (563 loc) · 20.6 KB
/
FionaUTLinux.cpp
File metadata and controls
669 lines (563 loc) · 20.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
//Kevin Ponto
// 8/3/2013
// Linux Fiona windowing stuff
#include <stdlib.h>
#include "FionaUT.h"
#include <sys/time.h>
#define GLX_GLXEXT_PROTOTYPES
#include <GL/glx.h>
#include <GL/glext.h>
#include <GL/glxext.h>
#include <X11/X.h>
#include <X11/extensions/xf86vmode.h>
#include <unistd.h>
#define TITLE "OpenGL in X11"
#define DEBUGPRINT
static bool GLEWInited = false;
static bool GLUTMainLoopInited = false;
static bool PrintFPS = false;
/* original desktop mode which we save so we can restore it later */
XF86VidModeModeInfo desktopMode;
//*****************************************************************
//
//From http://www.opengl.org/sdk/docs/man2/xhtml/glXIntro.xml
//
//*****************************************************************
int singleBufferAttributess[] = {
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_RED_SIZE, 1, /* Request a single buffered color buffer */
GLX_GREEN_SIZE, 1, /* with the maximum number of color bits */
GLX_BLUE_SIZE, 1, /* for each component */
None
};
int doubleBufferAttributes[] = {
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DOUBLEBUFFER, True, /* Request a double-buffered color buffer with */
GLX_RED_SIZE, 1, /* the maximum number of bits per component */
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
None
};
static Bool WaitForNotify( Display *dpy, XEvent *event, XPointer arg ) {
return (event->type == MapNotify) && (event->xmap.window == (Window) arg);
}
//*****************************************************************
void __FionaUTInitNative (void)
{
//not sure what to do here?
//try calling glutInit
DEBUGPRINT("init\n");
printf("in init window 0: %p\n", fionaWinConf[0].window);
}
void __FionaUTMakeFillScreen (void *_win,int)
{
DEBUGPRINT("full screen\n");
//not sure what to do here
// glutFullScreen();
}
int __FionaUTGetW(void* _win)
{
FionaUTWin* win = (FionaUTWin *)_win;
return win->w;
}
int __FionaUTGetH(void* _win)
{
FionaUTWin* win = (FionaUTWin *)_win;
return win->h;
}
Display * __FionaUTGetDeviceContext (WIN win, bool secondGPU)
{
FionaUTWin* w = (FionaUTWin*)fionaWinConf[0].window;
return w->dsp;
}
void HandleEvents()
{
//assume the events come from window 0
FionaUTWin* win = (FionaUTWin*)fionaWinConf[0].window;
_FionaUTJoystick(0, jvec3( 0,0, 0));
while (XPending(win->dsp) > 0)
{
XEvent event;
XNextEvent(win->dsp,&event);
if(XPending(win->dsp)>=0)
{
int button;
switch(event.xbutton.button){
case Button1:
button = GLUT_LEFT_BUTTON;
break;
case Button3:
button = GLUT_RIGHT_BUTTON;
break;
default:
button = GLUT_LEFT_BUTTON;
break;
}
switch (event.type) {
//mouse event
case ButtonPress:
{
_FionaUTMouseUp(win, button, event.xbutton.x, event.xbutton.y );
break;
}
case ButtonRelease:
{
_FionaUTMouseDown(win, button, event.xbutton.x, event.xbutton.y);
break;
}
case KeyPress :
{
int keycode = event.xkey.keycode;
printf("Key Pressed %d\n", keycode);
switch( keycode )
{
case 111: _FionaUTJoystick(0, jvec3( 0,0, fionaConf.navigationSpeed)); break; // up arrow
case 116: _FionaUTJoystick(0, jvec3( 0,0,-fionaConf.navigationSpeed)); break; // down arrow
case 113: _FionaUTJoystick(0, jvec3(-fionaConf.navigationSpeed,0, 0)); break; // left arrow
case 114: _FionaUTJoystick(0, jvec3( fionaConf.navigationSpeed,0, 0)); break; // right arrow
case 65: _FionaUTJoystick(0, jvec3( 0,0, 0)); break; // right arrow
case 119: _FionaUTJoystick(0, jvec3(0.f,-fionaConf.navigationSpeed,0.f)); break; //delete key
case 118: _FionaUTJoystick(0, jvec3(0.f, fionaConf.navigationSpeed, 0.f)); break; //insert key
case 9: FionaUTExit(); break; // exit
}
//make it ascii
char buf[2];
int len;
KeySym keysym_return;
len = XLookupString(&event.xkey, buf, 1, &keysym_return, NULL);
if ( len == 0 ){
buf[0] = '\0';
}
//add in wand button spoof
switch( buf[0] )
{
case '`': _FionaUTWandButton(5, 0); break;
case '1': _FionaUTWandButton(1, 0); break;
case '2': _FionaUTWandButton(0, 0); break;
case '3': _FionaUTWandButton(2, 0); break;
case '4': _FionaUTWandButton(3, 0); break;
}
_FionaUTKeyboard(win,buf[0]);
break;
}
case KeyRelease :
{
int keycode = event.xkey.keycode;
/*
//is there another event?
if (XPending(win->dsp) > 0)
{
XEvent nextEvent;
XPeekEvent(win->dsp,&nextEvent);
int nextKeycode = nextEvent.xkey.keycode;
//this is auto-repeat
if ((keycode == nextKeycode) && (nextEvent.type == KeyPress))
{
printf("Key Held %d\n", keycode);
break;
}
}
*/
//printf("Key Released %d\n", keycode);
switch( keycode )
{
case 111: _FionaUTJoystick(0, jvec3( 0,0, 0)); break; // up arrow
case 116: _FionaUTJoystick(0, jvec3( 0,0, 0)); break; // down arrow
case 113: _FionaUTJoystick(0, jvec3( 0,0, 0)); break; // left arrow
case 114: _FionaUTJoystick(0, jvec3( 0,0, 0)); break; // right arrow
case 119: _FionaUTJoystick(0, jvec3(0.f,0.f,0.f)); break; //delete key
case 118: _FionaUTJoystick(0, jvec3(0.f,0.f, 0.f)); break; //insert key
}
break;
}
//case Expose:
case ConfigureNotify:
//printf("reshape event\n");
/* call resizeGL only if our window-size changed */
if ((event.xconfigure.width != __FionaUTGetW(win)) ||
(event.xconfigure.height != __FionaUTGetH(win)))
{
int width = event.xconfigure.width;
int height = event.xconfigure.height;
_FionaUTReshape(win, width, height);
}
break;
case EnterNotify : DEBUGPRINT("Enter\n"); break;
}
}
}
}
void __FionaUTMainLoop (int _framerate)
{
if( _framerate>=1 ) fionaConf.framerate = _framerate;
//MSG msg;
long int last, cur;
long int freq;
//QueryPerformanceFrequency(&freq);
//float step = freq.QuadPart/(fionaConf.framerate+1);
float fr = fionaConf.framerate;
if(fr == 0.f)
{
fr = 60.f;
}
float step = 1.0 / fr;
bool inited = false;
float startTime = FionaUTTime();
int numFrameCounter=0;
float prevCounterFrameTime=startTime;
while(1)
//for (int i=0; i < 100000; i++)
{
/*
if( PeekMessage(&msg,NULL,0,0,1) )
{
if(msg.message == WM_QUIT) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}*/
//FionaUTSleep(10);
//get the events
HandleEvents();
_FionaUTIdle();
float curTime = FionaUTTime();
//printf("main loop window 0: %p\n", fionaWinConf[0].window);
//QueryPerformanceCounter(&cur);
if( fionaNetSlave==NULL )
//if( !inited || cur.QuadPart-last.QuadPart>=step )
if (!inited || curTime-startTime > step)
{
startTime = curTime;
inited =true;
DEBUGPRINT("head: %f %f %f\n", fionaConf.headPos.x,fionaConf.headPos.y,fionaConf.headPos.z) ;
//DEBUGPRINT("rot: %f %f %f\n", fionaConf.headRot.yaw()*(180/3.14),fionaConf.headRot.pitch()*(180/3.14), fionaConf.headRot.roll()*(180/3.14)) ;
_FionaUTFrame();
//printf("post-FionaUTFrame window 0: %p\n", fionaWinConf[0].window);
if (PrintFPS)
{
numFrameCounter++;
float dTime = curTime - prevCounterFrameTime;
if (dTime > 5)
{
printf("frame at rate %f\n", numFrameCounter / dTime);
prevCounterFrameTime = curTime;
numFrameCounter=0;
}
}
}
}
FionaUTExit(0);
}
float FionaUTTime(void) {
struct timeval tv;
float s=0;
if(!gettimeofday(&tv, NULL)) s=tv.tv_usec/1000000.0f+tv.tv_sec%1000;
return s;
}
void FionaUTSleep(float t)
{
if( t>=1.0f ){ sleep((int)t); t-=(int)t; }
usleep(t*1000000);
}
void __FionaUTMakeCurrent(void* _win, bool secondGPU) {
FionaUTWin* win = (FionaUTWin *)_win;
DEBUGPRINT("make context current\n");
glXMakeCurrent(win->dsp, win->xwin, win->cxt);
//new version
//glXMakeContextCurrent( win->dsp, win->glxWin, win->glxWin, win->cxt );
//XSetInputFocus(win->dsp, win->xwin, RevertToParent, CurrentTime);
}
CTX __FionaUTGetContext(void* _win, bool secondContext){
DEBUGPRINT("get context\n");
FionaUTWin* win = (FionaUTWin *)_win;
DEBUGPRINT("FionaUTGetContext window: %p\n", win);
//printf("getting context\n");
return win->cxt;
}
void __FionaUTSwapBuffer(void* _win) {
FionaUTWin* win = (FionaUTWin *)_win;
//SwapBuffers(win->cxt);
DEBUGPRINT("swap buffers\n");
glXMakeCurrent(win->dsp, win->xwin, win->cxt);
glFlush();
glXSwapBuffers( win->dsp, win->xwin );
}
//note I stole this from CGLX
typedef struct GLInfo_S{
char vendor[128];
char renderer[128];
char version[32];
char clientvendor[64];
char clientversion[32];
} *GLInfo_P;
GLInfo_S glinfo;
bool getGLInfo(Display *dpy, int screen)
{
Window win;
int attribSingle[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
None };
int attribDouble[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
None };
XSetWindowAttributes attr;
unsigned long mask;
Window root;
GLXContext ctx;
XVisualInfo *visinfo;
int width = 100, height = 100;
root = RootWindow(dpy, screen);
visinfo = glXChooseVisual(dpy, screen, attribSingle);
if (!visinfo) {
visinfo = glXChooseVisual(dpy, screen, attribDouble);
if (!visinfo) {
fprintf(stderr, "Error: couldn't find RGB GLX visual\n");
return (false);
}
}
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow(dpy, root, 0, 0, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr);
ctx = glXCreateContext( dpy, visinfo, NULL, true );
if (!ctx) {
fprintf(stderr, "Error: glXCreateContext failed\n");
XDestroyWindow(dpy, win);
return (false);
}
if (glXMakeCurrent(dpy, win, ctx)) {
// ===================
// general information
// ===================
strcpy(glinfo.vendor,(const char *)glGetString(GL_VENDOR));
strcpy(glinfo.renderer,(const char *)glGetString(GL_RENDERER));
strcpy(glinfo.version,(const char *)glGetString(GL_VERSION));
//const char *glExtensions = (const char *) glGetString(GL_EXTENSIONS);
// =======
// server
// =======
//const char *serverVendor = glXQueryServerString(dpy, screen, GLX_VENDOR);
//const char *serverVersion = glXQueryServerString(dpy, screen, GLX_VERSION);
//const char *serverExtensions = glXQueryServerString(dpy, screen, GLX_EXTENSIONS);
// =======
// client
// =======
strcpy(glinfo.clientvendor,glXGetClientString(dpy, GLX_VENDOR));
strcpy(glinfo.clientversion,glXGetClientString(dpy, GLX_VERSION));
// YYY unused
const char *clientExtensions = glXGetClientString(dpy, GLX_EXTENSIONS);
//const char *glxExtensions = glXQueryExtensionsString(dpy, screen);
//printf("Extentions:\n %s\n",clientExtensions);
}
// delete visinfo // new valgrid
free (visinfo);
glXDestroyContext(dpy, ctx);
XDestroyWindow(dpy, win);
return(true);
}
void __FionaUTCloseWindow (void)
{
/*for(int i=0;i<MAX_WINDOW;i++)
{
if(fionaWinConf[i].window!=NULL)
{
WIN win = fionaWinConf[i].window;
__FionaUTMakeCurrent(win);
glXDestroyContext(info[i].hrc);
//ReleaseDC(info[i].hwnd, info[i].hdc);
XDestroyWindow(info[i].hwnd);
}
}*/
}
int _invalid_window_handler(Display *dsp, XErrorEvent *err) {
printf("ERROR: INVALID WINDOW HANDLER\n");
return 0;
}
void *__FionaUTCreateWindow(const char* name,int x,int y,int w,int h,int mode)
{
printf("*********************CREATING WINDOW********************\n");
DEBUGPRINT("create window %s: %d %d %d %d\n", name, x, y, w, h);
if( !GLEWInited )
{
glewInit(); GLEWInited=true;
}
fionaWinConf[fionaCurWindow].winw=w;
fionaWinConf[fionaCurWindow].winh=h;
//lets make a new struct
FionaUTWin *win = new FionaUTWin(name, x, y, w, h);
//im guessing here on the full screen thing from cglx
//mode=1;
bool fullscreen = (mode != 0);
if (!fullscreen)
{
win->dsp = XOpenDisplay(getenv("DISPLAY"));
}
else
{
win->dsp = XOpenDisplay(":0.0");
}
if ( win->dsp == NULL ) {
printf( "Unable to open a connection to the X server\n" );
exit( EXIT_FAILURE );
}
//second option is screen number. not sure how to set it. Is it fionaCurWindow?
win->screen=DefaultScreen(win->dsp);
//do we need this?
//root = DefaultRootWindow(win->dsp);
/* Request a suitable framebuffer configuration - try for a double
** buffered configuration first */
int numReturned;
win->fbConfigs = glXChooseFBConfig( win->dsp, win->screen,
doubleBufferAttributes, &numReturned );
/* this would be bad...let us not go there
if ( win->fbConfigs == NULL ) {
win->fbConfigs = glXChooseFBConfig( dpy, DefaultScreen(dpy),
singleBufferAttributess, &numReturned );
swapFlag = False;
}
*/
//info = XGetVisualInfo(disp, VisualNoMask, &templ, &unused);
//con = glXCreateContext(disp, info, NULL, true);
/*
getGLInfo(win->dsp, win->screen);
std::cout << "---------------------------------------------" << std::endl;
std::cout << "(II) GL vendor ....... "<< glinfo.vendor << std::endl;
std::cout << "(II) GL renderer ....... "<< glinfo.renderer << std::endl;
std::cout << "(II) GL version ....... "<< glinfo.version << std::endl;
std::cout << "(II) GL cl. vendor ....... "<< glinfo.clientvendor << std::endl;
std::cout << "(II) GL cl. version ....... "<< glinfo.clientversion << std::endl;
*/
//attribute list for single buffer
GLint attrListSgl[32], attrListDbl[32];
// the following is the X setting
// single buffer
int iNumAttr = 0;
attrListSgl[iNumAttr++] = GLX_RGBA;
attrListSgl[iNumAttr++] = GLX_RED_SIZE;
attrListSgl[iNumAttr++] = 4;
attrListSgl[iNumAttr++] = GLX_GREEN_SIZE;
attrListSgl[iNumAttr++] = 4;
attrListSgl[iNumAttr++] = GLX_BLUE_SIZE;
attrListSgl[iNumAttr++] = 4;
attrListSgl[iNumAttr++] = GLX_DEPTH_SIZE;
attrListSgl[iNumAttr++] = 16;
attrListSgl[iNumAttr++] = None;
// double buffer
iNumAttr = 0;
attrListDbl[iNumAttr++] = GLX_RGBA; // was RGBA
attrListDbl[iNumAttr++] = GLX_DOUBLEBUFFER;
attrListDbl[iNumAttr++] = GLX_RED_SIZE;
attrListDbl[iNumAttr++] = 4;
attrListDbl[iNumAttr++] = GLX_BLUE_SIZE;
attrListDbl[iNumAttr++] = 4;
attrListDbl[iNumAttr++] = GLX_DEPTH_SIZE;
attrListDbl[iNumAttr++] = 16;
attrListDbl[iNumAttr++] = None;
//cglx way
int glxMajor, glxMinor, vmMajor, vmMinor;
glXQueryVersion(win->dsp, &glxMajor, &glxMinor);
printf("GLX-Version %d.%d\n", glxMajor, glxMinor);
win->vi =glXChooseVisual(win->dsp, win->screen, attrListDbl);
//other version
//win->vi = glXGetVisualFromFBConfig( win->dsp, win->fbConfigs[0] );
//create a gl context?
// GLXContext glXCreateContext(Display * dpy, XVisualInfo * vis, GLXContext shareList, Bool direct);
//printf("create gl context\n");
//win->cxt = glXCreateContext(win->dsp, win->vi, NULL, GL_TRUE);
/* create a GLX context */
win->cxt = glXCreateContext(win->dsp, win->vi, 0, GL_TRUE);
if (glXIsDirect(win->dsp, win->cxt))//&&glXIsDirect(cvi[dspID]->vis.dpy, cvi[dspID]->vis.ctx2))
printf("direct draw is on\n");
else
printf("direct draw is off\n");
printf("create color map\n");
win->cmap = XCreateColormap(win->dsp, RootWindow(win->dsp,win->screen), win->vi->visual, AllocNone);
//now some window options
unsigned long valuemask;
//this is probably the headnode options
//CWOverrideRedirect for fullscreen
valuemask=CWBorderPixel | CWColormap | CWEventMask ;
//if (fullscreen)
// valuemask=CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
//set some attributes
win->attr.colormap = win->cmap;
win->attr.border_pixel = 0;
win->attr.event_mask = ExposureMask | StructureNotifyMask | KeyPressMask;
win->attr.override_redirect = True;
if (fullscreen)
{
/* switch to fullscreen */
XF86VidModeModeInfo **modes;
int modeNum, bestMode=0;
int dpyWidth, dpyHeight;
XF86VidModeQueryVersion(win->dsp, &vmMajor, &vmMinor);
printf("XF86 VideoMode extension version %d.%d\n", vmMajor, vmMinor);
XF86VidModeGetAllModeLines(win->dsp, win->screen, &modeNum, &modes);
/* save desktop-resolution before switching modes */
//GLWin.deskMode = *modes[0];
desktopMode = *modes[0];
/* look for mode with requested resolution */
for (int i = 0; i < modeNum; i++)
{
if ((modes[i]->hdisplay == h) && (modes[i]->vdisplay == w))
bestMode = i;
}
XF86VidModeSwitchToMode(win->dsp, win->screen, modes[bestMode]);
XF86VidModeSetViewPort(win->dsp, win->screen, 0, 0);
dpyWidth = modes[bestMode]->hdisplay;
dpyHeight = modes[bestMode]->vdisplay;
printf("resolution %dx%d\n", dpyWidth, dpyHeight);
XFree(modes);
/* set window attributes */
win->attr.override_redirect = True;
win->attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask |
StructureNotifyMask;
win->xwin = XCreateWindow(win->dsp, RootWindow(win->dsp, win->vi->screen),
0, 0, dpyWidth, dpyHeight, 0, win->vi->depth, InputOutput, win->vi->visual,
CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect,
&win->attr);
XWarpPointer(win->dsp, None, win->xwin, 0, 0, 0, 0, 0, 0);
XMapRaised(win->dsp, win->xwin);
XGrabKeyboard(win->dsp, win->xwin, True, GrabModeAsync,
GrabModeAsync, CurrentTime);
XGrabPointer(win->dsp, win->xwin, True, ButtonPressMask,
GrabModeAsync, GrabModeAsync, win->xwin, None, CurrentTime);
_FionaUTReshape(win, dpyWidth, dpyHeight);
}
else
{
/* create a window in window mode*/
win->attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | StructureNotifyMask;
win->xwin = XCreateWindow(win->dsp, RootWindow(win->dsp, win->vi->screen),
0, 0, w, h, 0, win->vi->depth, InputOutput, win->vi->visual,
CWBorderPixel | CWColormap | CWEventMask, &win->attr);
/* only set window title and handle wm_delete_events if in windowed mode */
Atom wmDelete = XInternAtom(win->dsp, "WM_DELETE_WINDOW", true);
XSetWMProtocols(win->dsp, win->xwin, &wmDelete, 1);
XSetStandardProperties(win->dsp, win->xwin, TITLE,
TITLE, None, NULL, 0, NULL);
XMapRaised(win->dsp, win->xwin);
}
/*
__FionaUTMakeCurrent(win);
unsigned int borderDummy;
Window winDummy;
printf("set geometry\n");
XGetGeometry(win->dsp, win->xwin, &winDummy,
&win->x, &win->y,
&win->w, &win->h,
&borderDummy, (unsigned int *)&win->vi->depth);
*/
printf("returning %p\n", win);
return win;
}