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); |
|
414 |
|
|
415 |
/* Wait for VisibilityNotify Event */ |
/* clear the window so that cached data is not seen */ |
416 |
for (;;) |
gc = XCreateGC(display, wnd, 0, NULL); |
|
{ |
|
|
XNextEvent(display, &xevent); |
|
|
if (xevent.type == VisibilityNotify) |
|
|
break; |
|
|
} |
|
|
|
|
|
if (ownbackstore) |
|
|
backstore = XCreatePixmap(display, wnd, width, height, depth); |
|
|
|
|
|
/* clear the window so that cached data is not viewed upon start... */ |
|
|
XSetBackground(display, gc, 0); |
|
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 |
|
|
|
void |
|
|
reset_keys() |
|
|
{ |
|
|
/* reset keys */ |
|
|
uint32 ev_time; |
|
|
ev_time = time(NULL); |
|
|
rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LCTRL); |
|
|
rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LALT); |
|
|
rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LSHIFT); |
|
|
rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RCTRL); |
|
|
rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RALT); |
|
|
rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RSHIFT); |
|
|
} |
|
438 |
|
|
439 |
void |
void |
440 |
toggle_fullscreen() |
xwin_toggle_fullscreen() |
441 |
{ |
{ |
442 |
/* save window contents */ |
XEvent xevent; |
443 |
Pixmap pixmap; |
XSetWindowAttributes attribs; |
444 |
pixmap = XCreatePixmap(display, wnd, width, height, depth); |
int newwidth, newheight; |
445 |
if (ownbackstore) |
|
446 |
XCopyArea(display, backstore, pixmap, gc, 0, 0, width, height, 0, 0); |
fullscreen = !fullscreen; |
447 |
else |
newwidth = fullscreen ? WidthOfScreen(screen) : width; |
448 |
XCopyArea(display, wnd, pixmap, gc, 0, 0, width, height, 0, 0); |
newheight = fullscreen ? HeightOfScreen(screen) : height; |
449 |
fullscreen = fullscreen ? False : True; |
|
450 |
close_inputmethod(); |
XUnmapWindow(display, wnd); |
451 |
if (ownbackstore) |
attribs.override_redirect = fullscreen; |
452 |
XFreePixmap(display, backstore); |
XMoveResizeWindow(display, wnd, 0, 0, newwidth, newheight); |
453 |
XFreeGC(display, gc); |
XChangeWindowAttributes(display, wnd, CWOverrideRedirect, &attribs); |
454 |
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); |
|
455 |
} |
} |
456 |
|
|
457 |
/* Process all events in Xlib queue */ |
/* Process all events in Xlib queue */ |
459 |
xwin_process_events() |
xwin_process_events() |
460 |
{ |
{ |
461 |
XEvent xevent; |
XEvent xevent; |
|
|
|
462 |
KeySym keysym; |
KeySym keysym; |
463 |
uint16 button, flags; |
uint16 button, flags; |
464 |
uint32 ev_time; |
uint32 ev_time; |
467 |
char str[256]; |
char str[256]; |
468 |
Status status; |
Status status; |
469 |
|
|
470 |
while (XCheckMaskEvent(display, ~0, &xevent)) |
while (XPending(display) > 0) |
471 |
{ |
{ |
472 |
|
XNextEvent(display, &xevent); |
473 |
|
|
474 |
if (enable_compose && (XFilterEvent(&xevent, None) == True)) |
if (enable_compose && (XFilterEvent(&xevent, None) == True)) |
475 |
{ |
{ |
476 |
DEBUG_KBD(("Filtering event\n")); |
DEBUG_KBD(("Filtering event\n")); |
558 |
MOUSE_FLAG_MOVE, xevent.xmotion.x, xevent.xmotion.y); |
MOUSE_FLAG_MOVE, xevent.xmotion.x, xevent.xmotion.y); |
559 |
break; |
break; |
560 |
|
|
|
case FocusIn: |
|
|
/* fall through */ |
|
561 |
case EnterNotify: |
case EnterNotify: |
562 |
if (grab_keyboard) |
if (grab_keyboard) |
563 |
XGrabKeyboard(display, wnd, True, |
XGrabKeyboard(display, wnd, True, |
564 |
GrabModeAsync, GrabModeAsync, CurrentTime); |
GrabModeAsync, GrabModeAsync, CurrentTime); |
565 |
break; |
break; |
566 |
|
|
|
case FocusOut: |
|
|
reset_keys(); |
|
|
/* fall through */ |
|
567 |
case LeaveNotify: |
case LeaveNotify: |
568 |
if (grab_keyboard) |
if (grab_keyboard) |
569 |
XUngrabKeyboard(display, CurrentTime); |
XUngrabKeyboard(display, CurrentTime); |
570 |
break; |
break; |
571 |
|
|
572 |
|
case FocusIn: |
573 |
|
reset_modifier_keys(); |
574 |
|
break; |
575 |
|
|
576 |
case Expose: |
case Expose: |
577 |
XCopyArea(display, backstore, wnd, gc, |
XCopyArea(display, backstore, wnd, gc, |
578 |
xevent.xexpose.x, xevent.xexpose.y, |
xevent.xexpose.x, xevent.xexpose.y, |
604 |
while (True) |
while (True) |
605 |
{ |
{ |
606 |
/* Process any events already waiting */ |
/* Process any events already waiting */ |
|
XFlush(display); |
|
607 |
xwin_process_events(); |
xwin_process_events(); |
608 |
|
|
609 |
FD_ZERO(&rfds); |
FD_ZERO(&rfds); |