--- sourceforge.net/trunk/rdesktop/xwin.c 2003/02/09 17:17:37 316 +++ sourceforge.net/trunk/rdesktop/xwin.c 2003/03/14 12:00:17 342 @@ -32,6 +32,7 @@ extern BOOL hide_decorations; extern char title[]; extern int server_bpp; +extern int win_button_size; BOOL enable_compose = False; BOOL focused; BOOL mouse_in_wnd; @@ -58,6 +59,11 @@ static BOOL ownbackstore; static Pixmap backstore; +/* Moving in single app mode */ +static BOOL moving_wnd; +static int move_x_offset = 0; +static int move_y_offset = 0; + /* MWM decorations */ #define MWM_HINTS_DECORATIONS (1L << 1) #define PROP_MOTIF_WM_HINTS_ELEMENTS 5 @@ -122,7 +128,7 @@ #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 +static void mwm_hide_decorations(void) { PropMotifWmHints motif_hints; @@ -144,7 +150,7 @@ (unsigned char *) &motif_hints, PROP_MOTIF_WM_HINTS_ELEMENTS); } -PixelColour +static PixelColour split_colour15(uint32 colour) { PixelColour rv; @@ -157,7 +163,7 @@ return rv; } -PixelColour +static PixelColour split_colour16(uint32 colour) { PixelColour rv; @@ -170,7 +176,7 @@ return rv; } -PixelColour +static PixelColour split_colour24(uint32 colour) { PixelColour rv; @@ -180,7 +186,8 @@ return rv; } -uint32 make_colour16(PixelColour pc) +static uint32 +make_colour16(PixelColour pc) { pc.red = (pc.red * 0x1f) / 0xff; pc.green = (pc.green * 0x3f) / 0xff; @@ -188,12 +195,14 @@ return (pc.red << 11) | (pc.green << 5) | pc.blue; } -uint32 make_colour24(PixelColour pc) +static uint32 +make_colour24(PixelColour pc) { return (pc.red << 16) | (pc.green << 8) | pc.blue; } -uint32 make_colour32(PixelColour pc) +static uint32 +make_colour32(PixelColour pc) { return (pc.red << 16) | (pc.green << 8) | pc.blue; } @@ -426,13 +435,15 @@ switch (bpp) { case 32: - translate16to32((uint16 *) data, (uint32 *) out, (uint32 *) end); + translate16to32((uint16 *) data, (uint32 *) out, + (uint32 *) end); break; case 24: translate16to24((uint16 *) data, out, end); break; case 16: - translate16to16((uint16 *) data, (uint16 *) out, (uint16 *) end); + translate16to16((uint16 *) data, (uint16 *) out, + (uint16 *) end); break; } break; @@ -440,13 +451,15 @@ switch (bpp) { case 32: - translate15to32((uint16 *) data, (uint32 *) out, (uint32 *) end); + translate15to32((uint16 *) data, (uint32 *) out, + (uint32 *) end); break; case 24: translate15to24((uint16 *) data, out, end); break; case 16: - translate15to16((uint16 *) data, (uint16 *) out, (uint16 *) end); + translate15to16((uint16 *) data, (uint16 *) out, + (uint16 *) end); break; } break; @@ -847,11 +860,68 @@ if (button == 0) break; + /* If win_button_size is nonzero, enable single app mode */ + if (xevent.xbutton.y < win_button_size) + { + /* Stop moving window when button is released, regardless of cursor position */ + if (moving_wnd && (xevent.type == ButtonRelease)) + moving_wnd = False; + + /* Check from right to left: */ + + if (xevent.xbutton.x >= width - win_button_size) + { + /* The close button, continue */ + ; + } + else if (xevent.xbutton.x >= width - win_button_size * 2) + { + /* The maximize/restore button. Do not send to + server. It might be a good idea to change the + cursor or give some other visible indication + that rdesktop inhibited this click */ + break; + } + else if (xevent.xbutton.x >= width - win_button_size * 3) + { + /* The minimize button. Iconify window. */ + XIconifyWindow(display, wnd, + DefaultScreen(display)); + break; + } + else if (xevent.xbutton.x <= win_button_size) + { + /* The system menu. Ignore. */ + break; + } + else + { + /* The title bar. */ + if ((xevent.type == ButtonPress) && !fullscreen + && hide_decorations) + { + moving_wnd = True; + move_x_offset = xevent.xbutton.x; + move_y_offset = xevent.xbutton.y; + } + break; + + } + } + rdp_send_input(time(NULL), RDP_INPUT_MOUSE, flags | button, xevent.xbutton.x, xevent.xbutton.y); break; case MotionNotify: + if (moving_wnd) + { + XMoveWindow(display, wnd, + xevent.xmotion.x_root - move_x_offset, + xevent.xmotion.y_root - move_y_offset); + break; + } + if (fullscreen && !focused) XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime);