29 |
extern BOOL sendmotion; |
extern BOOL sendmotion; |
30 |
extern BOOL fullscreen; |
extern BOOL fullscreen; |
31 |
extern BOOL grab_keyboard; |
extern BOOL grab_keyboard; |
32 |
|
extern BOOL hide_decorations; |
33 |
extern char title[]; |
extern char title[]; |
34 |
BOOL enable_compose = False; |
BOOL enable_compose = False; |
35 |
BOOL focused; |
BOOL focused; |
47 |
static XIC IC; |
static XIC IC; |
48 |
static XModifierKeymap *mod_map; |
static XModifierKeymap *mod_map; |
49 |
static Cursor current_cursor; |
static Cursor current_cursor; |
50 |
|
static Atom protocol_atom, kill_atom; |
51 |
|
|
52 |
/* endianness */ |
/* endianness */ |
53 |
static BOOL host_be; |
static BOOL host_be; |
57 |
static BOOL ownbackstore; |
static BOOL ownbackstore; |
58 |
static Pixmap backstore; |
static Pixmap backstore; |
59 |
|
|
60 |
|
/* MWM decorations */ |
61 |
|
#define MWM_HINTS_DECORATIONS (1L << 1) |
62 |
|
#define PROP_MOTIF_WM_HINTS_ELEMENTS 5 |
63 |
|
typedef struct |
64 |
|
{ |
65 |
|
unsigned long flags; |
66 |
|
unsigned long functions; |
67 |
|
unsigned long decorations; |
68 |
|
long inputMode; |
69 |
|
unsigned long status; |
70 |
|
} |
71 |
|
PropMotifWmHints; |
72 |
|
|
73 |
|
|
74 |
#define FILL_RECTANGLE(x,y,cx,cy)\ |
#define FILL_RECTANGLE(x,y,cx,cy)\ |
75 |
{ \ |
{ \ |
76 |
XFillRectangle(display, wnd, gc, x, y, cx, cy); \ |
XFillRectangle(display, wnd, gc, x, y, cx, cy); \ |
107 |
#define SET_FUNCTION(rop2) { if (rop2 != ROP2_COPY) XSetFunction(display, gc, rop2_map[rop2]); } |
#define SET_FUNCTION(rop2) { if (rop2 != ROP2_COPY) XSetFunction(display, gc, rop2_map[rop2]); } |
108 |
#define RESET_FUNCTION(rop2) { if (rop2 != ROP2_COPY) XSetFunction(display, gc, GXcopy); } |
#define RESET_FUNCTION(rop2) { if (rop2 != ROP2_COPY) XSetFunction(display, gc, GXcopy); } |
109 |
|
|
110 |
|
void |
111 |
|
mwm_hide_decorations(void) |
112 |
|
{ |
113 |
|
PropMotifWmHints motif_hints; |
114 |
|
Atom hintsatom; |
115 |
|
|
116 |
|
/* setup the property */ |
117 |
|
motif_hints.flags = MWM_HINTS_DECORATIONS; |
118 |
|
motif_hints.decorations = 0; |
119 |
|
|
120 |
|
/* get the atom for the property */ |
121 |
|
hintsatom = XInternAtom(display, "_MOTIF_WM_HINTS", False); |
122 |
|
if (!hintsatom) |
123 |
|
{ |
124 |
|
error("Failed to get atom _MOTIF_WM_HINTS\n"); |
125 |
|
return; |
126 |
|
} |
127 |
|
|
128 |
|
XChangeProperty(display, wnd, hintsatom, hintsatom, 32, PropModeReplace, |
129 |
|
(unsigned char *) &motif_hints, PROP_MOTIF_WM_HINTS_ELEMENTS); |
130 |
|
} |
131 |
|
|
132 |
static void |
static void |
133 |
translate8(uint8 * data, uint8 * out, uint8 * end) |
translate8(uint8 * data, uint8 * out, uint8 * end) |
134 |
{ |
{ |
299 |
host_be = !(BOOL) (*(uint8 *) (&test)); |
host_be = !(BOOL) (*(uint8 *) (&test)); |
300 |
xserver_be = (ImageByteOrder(display) == MSBFirst); |
xserver_be = (ImageByteOrder(display) == MSBFirst); |
301 |
|
|
302 |
|
if ((width == 0) || (height == 0)) |
303 |
|
{ |
304 |
|
/* Fetch geometry from _NET_WORKAREA */ |
305 |
|
uint32 xpos, ypos; |
306 |
|
|
307 |
|
if (get_current_workarea(&xpos, &ypos, &width, &height) < 0) |
308 |
|
{ |
309 |
|
error("Failed to get workarea.\n"); |
310 |
|
error("Perhaps your window manager does not support EWMH?\n"); |
311 |
|
error("Defaulting to geometry 800x600\n"); |
312 |
|
width = 800; |
313 |
|
height = 600; |
314 |
|
} |
315 |
|
} |
316 |
|
|
317 |
if (fullscreen) |
if (fullscreen) |
318 |
{ |
{ |
319 |
width = WidthOfScreen(screen); |
width = WidthOfScreen(screen); |
381 |
|
|
382 |
XStoreName(display, wnd, title); |
XStoreName(display, wnd, title); |
383 |
|
|
384 |
|
if (hide_decorations) |
385 |
|
mwm_hide_decorations(); |
386 |
|
|
387 |
classhints = XAllocClassHint(); |
classhints = XAllocClassHint(); |
388 |
if (classhints != NULL) |
if (classhints != NULL) |
389 |
{ |
{ |
437 |
focused = False; |
focused = False; |
438 |
mouse_in_wnd = False; |
mouse_in_wnd = False; |
439 |
|
|
440 |
|
/* handle the WM_DELETE_WINDOW protocol */ |
441 |
|
protocol_atom = XInternAtom(display, "WM_PROTOCOLS", True); |
442 |
|
kill_atom = XInternAtom(display, "WM_DELETE_WINDOW", True); |
443 |
|
XSetWMProtocols(display, wnd, &kill_atom, 1); |
444 |
|
|
445 |
return True; |
return True; |
446 |
} |
} |
447 |
|
|
479 |
} |
} |
480 |
} |
} |
481 |
|
|
482 |
/* Process all events in Xlib queue */ |
/* Process all events in Xlib queue |
483 |
static void |
Returns 0 after user quit, 1 otherwise */ |
484 |
|
static int |
485 |
xwin_process_events(void) |
xwin_process_events(void) |
486 |
{ |
{ |
487 |
XEvent xevent; |
XEvent xevent; |
509 |
|
|
510 |
switch (xevent.type) |
switch (xevent.type) |
511 |
{ |
{ |
512 |
|
case ClientMessage: |
513 |
|
/* the window manager told us to quit */ |
514 |
|
if ((xevent.xclient.message_type == protocol_atom) |
515 |
|
&& (xevent.xclient.data.l[0] == kill_atom)) |
516 |
|
/* Quit */ |
517 |
|
return 0; |
518 |
|
break; |
519 |
|
|
520 |
case KeyPress: |
case KeyPress: |
521 |
if (IC != NULL) |
if (IC != NULL) |
522 |
/* Multi_key compatible version */ |
/* Multi_key compatible version */ |
539 |
str, sizeof(str), &keysym, NULL); |
str, sizeof(str), &keysym, NULL); |
540 |
} |
} |
541 |
|
|
542 |
DEBUG_KBD(("KeyPress for (keysym 0x%lx, %s)\n", keysym, get_ksname(keysym))); |
DEBUG_KBD(("KeyPress for (keysym 0x%lx, %s)\n", keysym, |
543 |
|
get_ksname(keysym))); |
544 |
|
|
545 |
ev_time = time(NULL); |
ev_time = time(NULL); |
546 |
if (handle_special_keys(keysym, xevent.xkey.state, ev_time, True)) |
if (handle_special_keys(keysym, xevent.xkey.state, ev_time, True)) |
599 |
if (xevent.xfocus.mode == NotifyGrab) |
if (xevent.xfocus.mode == NotifyGrab) |
600 |
break; |
break; |
601 |
focused = True; |
focused = True; |
602 |
XQueryPointer(display, wnd, &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state); |
XQueryPointer(display, wnd, &wdummy, &wdummy, &dummy, &dummy, |
603 |
|
&dummy, &dummy, &state); |
604 |
reset_modifier_keys(state); |
reset_modifier_keys(state); |
605 |
if (grab_keyboard && mouse_in_wnd) |
if (grab_keyboard && mouse_in_wnd) |
606 |
XGrabKeyboard(display, wnd, True, |
XGrabKeyboard(display, wnd, True, |
621 |
mouse_in_wnd = True; |
mouse_in_wnd = True; |
622 |
if (fullscreen) |
if (fullscreen) |
623 |
{ |
{ |
624 |
XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime); |
XSetInputFocus(display, wnd, RevertToPointerRoot, |
625 |
|
CurrentTime); |
626 |
break; |
break; |
627 |
} |
} |
628 |
if (focused) |
if (focused) |
660 |
|
|
661 |
} |
} |
662 |
} |
} |
663 |
|
/* Keep going */ |
664 |
|
return 1; |
665 |
} |
} |
666 |
|
|
667 |
void |
/* Returns 0 after user quit, 1 otherwise */ |
668 |
|
int |
669 |
ui_select(int rdp_socket) |
ui_select(int rdp_socket) |
670 |
{ |
{ |
671 |
int n = (rdp_socket > x_socket) ? rdp_socket + 1 : x_socket + 1; |
int n = (rdp_socket > x_socket) ? rdp_socket + 1 : x_socket + 1; |
676 |
while (True) |
while (True) |
677 |
{ |
{ |
678 |
/* Process any events already waiting */ |
/* Process any events already waiting */ |
679 |
xwin_process_events(); |
if (!xwin_process_events()) |
680 |
|
/* User quit */ |
681 |
|
return 0; |
682 |
|
|
683 |
FD_ZERO(&rfds); |
FD_ZERO(&rfds); |
684 |
FD_SET(rdp_socket, &rfds); |
FD_SET(rdp_socket, &rfds); |
694 |
} |
} |
695 |
|
|
696 |
if (FD_ISSET(rdp_socket, &rfds)) |
if (FD_ISSET(rdp_socket, &rfds)) |
697 |
return; |
return 1; |
698 |
} |
} |
699 |
} |
} |
700 |
|
|
1126 |
FILL_RECTANGLE(x, y, cx, cy); |
FILL_RECTANGLE(x, y, cx, cy); |
1127 |
} |
} |
1128 |
|
|
1129 |
|
/* warning, this function only draws on wnd or backstore, not both */ |
1130 |
void |
void |
1131 |
ui_draw_glyph(int mixmode, |
ui_draw_glyph(int mixmode, |
1132 |
/* dest */ int x, int y, int cx, int cy, |
/* dest */ int x, int y, int cx, int cy, |
1141 |
XSetStipple(display, gc, (Pixmap) glyph); |
XSetStipple(display, gc, (Pixmap) glyph); |
1142 |
XSetTSOrigin(display, gc, x, y); |
XSetTSOrigin(display, gc, x, y); |
1143 |
|
|
1144 |
FILL_RECTANGLE(x, y, cx, cy); |
if (ownbackstore) |
1145 |
|
XFillRectangle(display, backstore, gc, x, y, cx, cy); |
1146 |
|
else |
1147 |
|
XFillRectangle(display, wnd, gc, x, y, cx, cy); |
1148 |
|
|
1149 |
XSetFillStyle(display, gc, FillSolid); |
XSetFillStyle(display, gc, FillSolid); |
1150 |
} |
} |
1214 |
else |
else |
1215 |
{ |
{ |
1216 |
error("this shouldn't be happening\n"); |
error("this shouldn't be happening\n"); |
1217 |
break; |
exit(1); |
1218 |
} |
} |
1219 |
/* this will move pointer from start to first character after FF command */ |
/* this will move pointer from start to first character after FF command */ |
1220 |
length -= i + 3; |
length -= i + 3; |
1253 |
break; |
break; |
1254 |
} |
} |
1255 |
} |
} |
1256 |
|
if (ownbackstore) |
1257 |
|
{ |
1258 |
|
if (boxcx > 1) |
1259 |
|
XCopyArea(display, backstore, wnd, gc, boxx, |
1260 |
|
boxy, boxcx, boxcy, boxx, boxy); |
1261 |
|
else |
1262 |
|
XCopyArea(display, backstore, wnd, gc, clipx, |
1263 |
|
clipy, clipcx, clipcy, clipx, clipy); |
1264 |
|
} |
1265 |
} |
} |
1266 |
|
|
1267 |
void |
void |