42 |
static Visual *visual; |
static Visual *visual; |
43 |
static int depth; |
static int depth; |
44 |
static int bpp; |
static int bpp; |
|
static int dpy_width; |
|
|
static int dpy_height; |
|
45 |
|
|
46 |
/* endianness */ |
/* endianness */ |
47 |
static BOOL host_be; |
static BOOL host_be; |
278 |
return (current_state & keysymMask) ? True : False; |
return (current_state & keysymMask) ? True : False; |
279 |
} |
} |
280 |
|
|
281 |
|
static void |
282 |
|
xwin_map_window() |
283 |
|
{ |
284 |
|
XEvent xevent; |
285 |
|
|
286 |
|
XMapWindow(display, wnd); |
287 |
|
|
288 |
|
/* wait for VisibilityChange */ |
289 |
|
XMaskEvent(display, VisibilityChangeMask, &xevent); |
290 |
|
|
291 |
|
if (fullscreen) |
292 |
|
XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime); |
293 |
|
} |
294 |
|
|
295 |
BOOL |
BOOL |
296 |
ui_init() |
ui_init() |
370 |
0, CopyFromParent, InputOutput, CopyFromParent, |
0, CopyFromParent, InputOutput, CopyFromParent, |
371 |
CWBackPixel | CWBackingStore | CWOverrideRedirect, &attribs); |
CWBackPixel | CWBackingStore | CWOverrideRedirect, &attribs); |
372 |
|
|
373 |
|
if (ownbackstore) |
374 |
|
backstore = XCreatePixmap(display, wnd, width, height, depth); |
375 |
|
|
376 |
XStoreName(display, wnd, title); |
XStoreName(display, wnd, title); |
377 |
|
|
378 |
classhints = XAllocClassHint(); |
classhints = XAllocClassHint(); |
407 |
|
|
408 |
XSelectInput(display, wnd, input_mask); |
XSelectInput(display, wnd, input_mask); |
409 |
|
|
410 |
gc = XCreateGC(display, wnd, 0, NULL); |
xwin_map_window(); |
|
|
|
|
XMapWindow(display, wnd); |
|
|
|
|
|
/* Wait for VisibilityNotify Event */ |
|
|
for (;;) |
|
|
{ |
|
|
XNextEvent(display, &xevent); |
|
|
if (xevent.type == VisibilityNotify) |
|
|
break; |
|
|
} |
|
|
|
|
|
if (ownbackstore) |
|
|
backstore = XCreatePixmap(display, wnd, width, height, depth); |
|
411 |
|
|
412 |
/* clear the window so that cached data is not viewed upon start... */ |
/* clear the window so that cached data is not seen */ |
413 |
XSetBackground(display, gc, 0); |
gc = XCreateGC(display, wnd, 0, NULL); |
414 |
XSetForeground(display, gc, 0); |
XSetForeground(display, gc, 0); |
415 |
FILL_RECTANGLE(0, 0, width, height); |
FILL_RECTANGLE(0, 0, width, height); |
|
/* make sure the window is focused */ |
|
|
XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime); |
|
416 |
|
|
417 |
return True; |
return True; |
418 |
} |
} |
432 |
display = NULL; |
display = NULL; |
433 |
} |
} |
434 |
|
|
435 |
void |
static void |
436 |
reset_keys() |
xwin_reset_keys() |
437 |
{ |
{ |
438 |
/* reset keys */ |
/* reset keys */ |
439 |
uint32 ev_time; |
uint32 ev_time; |
447 |
} |
} |
448 |
|
|
449 |
void |
void |
450 |
toggle_fullscreen() |
xwin_toggle_fullscreen() |
451 |
{ |
{ |
452 |
/* save window contents */ |
XEvent xevent; |
453 |
Pixmap pixmap; |
XSetWindowAttributes attribs; |
454 |
pixmap = XCreatePixmap(display, wnd, width, height, depth); |
int newwidth, newheight; |
455 |
if (ownbackstore) |
|
456 |
XCopyArea(display, backstore, pixmap, gc, 0, 0, width, height, 0, 0); |
fullscreen = !fullscreen; |
457 |
else |
newwidth = fullscreen ? WidthOfScreen(screen) : width; |
458 |
XCopyArea(display, wnd, pixmap, gc, 0, 0, width, height, 0, 0); |
newheight = fullscreen ? HeightOfScreen(screen) : height; |
459 |
fullscreen = fullscreen ? False : True; |
|
460 |
close_inputmethod(); |
XUnmapWindow(display, wnd); |
461 |
if (ownbackstore) |
attribs.override_redirect = fullscreen; |
462 |
XFreePixmap(display, backstore); |
XChangeWindowAttributes(display, wnd, CWOverrideRedirect, &attribs); |
463 |
XFreeGC(display, gc); |
XResizeWindow(display, wnd, newwidth, newheight); |
464 |
XDestroyWindow(display, wnd); |
xwin_map_window(); |
|
ui_create_window(); |
|
|
ui_set_cursor(cache_get_cursor(0)); |
|
|
ui_move_pointer(width / 2, height / 2); |
|
|
reset_keys(); |
|
|
/* restore window contents */ |
|
|
if (ownbackstore) |
|
|
XCopyArea(display, pixmap, backstore, gc, 0, 0, width, height, 0, 0); |
|
|
XCopyArea(display, pixmap, wnd, gc, 0, 0, width, height, 0, 0); |
|
|
XFreePixmap(display, pixmap); |
|
465 |
} |
} |
466 |
|
|
467 |
/* Process all events in Xlib queue */ |
/* Process all events in Xlib queue */ |
469 |
xwin_process_events() |
xwin_process_events() |
470 |
{ |
{ |
471 |
XEvent xevent; |
XEvent xevent; |
|
|
|
472 |
KeySym keysym; |
KeySym keysym; |
473 |
uint16 button, flags; |
uint16 button, flags; |
474 |
uint32 ev_time; |
uint32 ev_time; |
477 |
char str[256]; |
char str[256]; |
478 |
Status status; |
Status status; |
479 |
|
|
480 |
while (XCheckMaskEvent(display, ~0, &xevent)) |
while (XPending(display) > 0) |
481 |
{ |
{ |
482 |
|
XNextEvent(display, &xevent); |
483 |
|
|
484 |
if (enable_compose && (XFilterEvent(&xevent, None) == True)) |
if (enable_compose && (XFilterEvent(&xevent, None) == True)) |
485 |
{ |
{ |
486 |
DEBUG_KBD(("Filtering event\n")); |
DEBUG_KBD(("Filtering event\n")); |
577 |
break; |
break; |
578 |
|
|
579 |
case FocusOut: |
case FocusOut: |
580 |
reset_keys(); |
xwin_reset_keys(); |
581 |
/* fall through */ |
/* fall through */ |
582 |
case LeaveNotify: |
case LeaveNotify: |
583 |
if (grab_keyboard) |
if (grab_keyboard) |
615 |
while (True) |
while (True) |
616 |
{ |
{ |
617 |
/* Process any events already waiting */ |
/* Process any events already waiting */ |
|
XFlush(display); |
|
618 |
xwin_process_events(); |
xwin_process_events(); |
619 |
|
|
620 |
FD_ZERO(&rfds); |
FD_ZERO(&rfds); |