--- sourceforge.net/trunk/rdesktop/xwin.c 2002/11/11 23:15:27 257 +++ sourceforge.net/trunk/rdesktop/xwin.c 2002/11/19 14:45:13 274 @@ -29,6 +29,7 @@ extern BOOL sendmotion; extern BOOL fullscreen; extern BOOL grab_keyboard; +extern BOOL hide_decorations; extern char title[]; BOOL enable_compose = False; BOOL focused; @@ -55,6 +56,20 @@ static BOOL ownbackstore; static Pixmap backstore; +/* MWM decorations */ +#define MWM_HINTS_DECORATIONS (1L << 1) +#define PROP_MOTIF_WM_HINTS_ELEMENTS 5 +typedef struct +{ + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long inputMode; + unsigned long status; +} +PropMotifWmHints; + + #define FILL_RECTANGLE(x,y,cx,cy)\ { \ XFillRectangle(display, wnd, gc, x, y, cx, cy); \ @@ -91,6 +106,28 @@ #define SET_FUNCTION(rop2) { if (rop2 != ROP2_COPY) XSetFunction(display, gc, rop2_map[rop2]); } #define RESET_FUNCTION(rop2) { if (rop2 != ROP2_COPY) XSetFunction(display, gc, GXcopy); } +void +mwm_hide_decorations(void) +{ + PropMotifWmHints motif_hints; + Atom hintsatom; + + /* setup the property */ + motif_hints.flags = MWM_HINTS_DECORATIONS; + motif_hints.decorations = 0; + + /* get the atom for the property */ + hintsatom = XInternAtom(display, "_MOTIF_WM_HINTS", False); + if (!hintsatom) + { + error("Failed to get atom _MOTIF_WM_HINTS\n"); + return; + } + + XChangeProperty(display, wnd, hintsatom, hintsatom, 32, PropModeReplace, + (unsigned char *) &motif_hints, PROP_MOTIF_WM_HINTS_ELEMENTS); +} + static void translate8(uint8 * data, uint8 * out, uint8 * end) { @@ -261,6 +298,21 @@ host_be = !(BOOL) (*(uint8 *) (&test)); xserver_be = (ImageByteOrder(display) == MSBFirst); + if ((width == 0) || (height == 0)) + { + /* Fetch geometry from _NET_WORKAREA */ + uint32 xpos, ypos; + + if (get_current_workarea(&xpos, &ypos, &width, &height) < 0) + { + error("Failed to get workarea.\n"); + error("Perhaps your window manager does not support EWMH?\n"); + error("Defaulting to geometry 800x600\n"); + width = 800; + height = 600; + } + } + if (fullscreen) { width = WidthOfScreen(screen); @@ -328,6 +380,9 @@ XStoreName(display, wnd, title); + if (hide_decorations) + mwm_hide_decorations(); + classhints = XAllocClassHint(); if (classhints != NULL) { @@ -469,7 +524,8 @@ str, sizeof(str), &keysym, NULL); } - DEBUG_KBD(("KeyPress for (keysym 0x%lx, %s)\n", keysym, get_ksname(keysym))); + DEBUG_KBD(("KeyPress for (keysym 0x%lx, %s)\n", keysym, + get_ksname(keysym))); ev_time = time(NULL); if (handle_special_keys(keysym, xevent.xkey.state, ev_time, True)) @@ -528,7 +584,8 @@ if (xevent.xfocus.mode == NotifyGrab) break; focused = True; - XQueryPointer(display, wnd, &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state); + XQueryPointer(display, wnd, &wdummy, &wdummy, &dummy, &dummy, + &dummy, &dummy, &state); reset_modifier_keys(state); if (grab_keyboard && mouse_in_wnd) XGrabKeyboard(display, wnd, True, @@ -549,7 +606,8 @@ mouse_in_wnd = True; if (fullscreen) { - XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime); + XSetInputFocus(display, wnd, RevertToPointerRoot, + CurrentTime); break; } if (focused) @@ -1132,7 +1190,7 @@ else { error("this shouldn't be happening\n"); - break; + exit(1); } /* this will move pointer from start to first character after FF command */ length -= i + 3;