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() |
351 |
height = HeightOfScreen(screen); |
height = HeightOfScreen(screen); |
352 |
} |
} |
353 |
|
|
354 |
|
/* make sure width is a multiple of 4 */ |
355 |
|
width = (width + 3) & ~3; |
356 |
|
|
357 |
xkeymap_init(); |
xkeymap_init(); |
358 |
return True; |
return True; |
359 |
} |
} |
373 |
0, CopyFromParent, InputOutput, CopyFromParent, |
0, CopyFromParent, InputOutput, CopyFromParent, |
374 |
CWBackPixel | CWBackingStore | CWOverrideRedirect, &attribs); |
CWBackPixel | CWBackingStore | CWOverrideRedirect, &attribs); |
375 |
|
|
376 |
|
if (ownbackstore) |
377 |
|
backstore = XCreatePixmap(display, wnd, width, height, depth); |
378 |
|
|
379 |
XStoreName(display, wnd, title); |
XStoreName(display, wnd, title); |
380 |
|
|
381 |
classhints = XAllocClassHint(); |
classhints = XAllocClassHint(); |
410 |
|
|
411 |
XSelectInput(display, wnd, input_mask); |
XSelectInput(display, wnd, input_mask); |
412 |
|
|
413 |
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); |
|
414 |
|
|
415 |
/* clear the window so that cached data is not viewed upon start... */ |
/* clear the window so that cached data is not seen */ |
416 |
XSetBackground(display, gc, 0); |
gc = XCreateGC(display, wnd, 0, NULL); |
417 |
XSetForeground(display, gc, 0); |
XSetForeground(display, gc, 0); |
418 |
FILL_RECTANGLE(0, 0, width, height); |
FILL_RECTANGLE(0, 0, width, height); |
|
/* make sure the window is focused */ |
|
|
XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime); |
|
419 |
|
|
420 |
return True; |
return True; |
421 |
} |
} |
435 |
display = NULL; |
display = NULL; |
436 |
} |
} |
437 |
|
|
438 |
void |
static void |
439 |
reset_keys() |
xwin_reset_keys() |
440 |
{ |
{ |
441 |
/* reset keys */ |
/* reset keys */ |
442 |
uint32 ev_time; |
uint32 ev_time; |
450 |
} |
} |
451 |
|
|
452 |
void |
void |
453 |
toggle_fullscreen() |
xwin_toggle_fullscreen() |
454 |
{ |
{ |
455 |
/* save window contents */ |
XEvent xevent; |
456 |
Pixmap pixmap; |
XSetWindowAttributes attribs; |
457 |
pixmap = XCreatePixmap(display, wnd, width, height, depth); |
int newwidth, newheight; |
458 |
if (ownbackstore) |
|
459 |
XCopyArea(display, backstore, pixmap, gc, 0, 0, width, height, 0, 0); |
fullscreen = !fullscreen; |
460 |
else |
newwidth = fullscreen ? WidthOfScreen(screen) : width; |
461 |
XCopyArea(display, wnd, pixmap, gc, 0, 0, width, height, 0, 0); |
newheight = fullscreen ? HeightOfScreen(screen) : height; |
462 |
fullscreen = fullscreen ? False : True; |
|
463 |
close_inputmethod(); |
XUnmapWindow(display, wnd); |
464 |
if (ownbackstore) |
attribs.override_redirect = fullscreen; |
465 |
XFreePixmap(display, backstore); |
XMoveResizeWindow(display, wnd, 0, 0, newwidth, newheight); |
466 |
XFreeGC(display, gc); |
XChangeWindowAttributes(display, wnd, CWOverrideRedirect, &attribs); |
467 |
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); |
|
468 |
} |
} |
469 |
|
|
470 |
/* Process all events in Xlib queue */ |
/* Process all events in Xlib queue */ |
472 |
xwin_process_events() |
xwin_process_events() |
473 |
{ |
{ |
474 |
XEvent xevent; |
XEvent xevent; |
|
|
|
475 |
KeySym keysym; |
KeySym keysym; |
476 |
uint16 button, flags; |
uint16 button, flags; |
477 |
uint32 ev_time; |
uint32 ev_time; |
480 |
char str[256]; |
char str[256]; |
481 |
Status status; |
Status status; |
482 |
|
|
483 |
while (XCheckMaskEvent(display, ~0, &xevent)) |
while (XPending(display) > 0) |
484 |
{ |
{ |
485 |
|
XNextEvent(display, &xevent); |
486 |
|
|
487 |
if (enable_compose && (XFilterEvent(&xevent, None) == True)) |
if (enable_compose && (XFilterEvent(&xevent, None) == True)) |
488 |
{ |
{ |
489 |
DEBUG_KBD(("Filtering event\n")); |
DEBUG_KBD(("Filtering event\n")); |
571 |
MOUSE_FLAG_MOVE, xevent.xmotion.x, xevent.xmotion.y); |
MOUSE_FLAG_MOVE, xevent.xmotion.x, xevent.xmotion.y); |
572 |
break; |
break; |
573 |
|
|
|
case FocusIn: |
|
|
/* fall through */ |
|
574 |
case EnterNotify: |
case EnterNotify: |
575 |
if (grab_keyboard) |
if (grab_keyboard) |
576 |
XGrabKeyboard(display, wnd, True, |
XGrabKeyboard(display, wnd, True, |
577 |
GrabModeAsync, GrabModeAsync, CurrentTime); |
GrabModeAsync, GrabModeAsync, CurrentTime); |
578 |
break; |
break; |
579 |
|
|
|
case FocusOut: |
|
|
reset_keys(); |
|
|
/* fall through */ |
|
580 |
case LeaveNotify: |
case LeaveNotify: |
581 |
if (grab_keyboard) |
if (grab_keyboard) |
582 |
XUngrabKeyboard(display, CurrentTime); |
XUngrabKeyboard(display, CurrentTime); |
583 |
break; |
break; |
584 |
|
|
585 |
|
case FocusOut: |
586 |
|
xwin_reset_keys(); |
587 |
|
break; |
588 |
|
|
589 |
case Expose: |
case Expose: |
590 |
XCopyArea(display, backstore, wnd, gc, |
XCopyArea(display, backstore, wnd, gc, |
591 |
xevent.xexpose.x, xevent.xexpose.y, |
xevent.xexpose.x, xevent.xexpose.y, |
617 |
while (True) |
while (True) |
618 |
{ |
{ |
619 |
/* Process any events already waiting */ |
/* Process any events already waiting */ |
|
XFlush(display); |
|
620 |
xwin_process_events(); |
xwin_process_events(); |
621 |
|
|
622 |
FD_ZERO(&rfds); |
FD_ZERO(&rfds); |