--- sourceforge.net/trunk/rdesktop/xwin.c 2002/07/18 18:28:12 66 +++ sourceforge.net/trunk/rdesktop/xwin.c 2002/07/30 01:57:39 81 @@ -25,11 +25,13 @@ #define XK_MISCELLANY #include #include "rdesktop.h" +#include "scancodes.h" extern int width; extern int height; extern BOOL sendmotion; extern BOOL fullscreen; +extern BOOL grab_keyboard; Display *display = NULL; static int x_socket; @@ -62,6 +64,9 @@ static XIM IM = NULL; static XIC IC = NULL; +/* Compose support */ +BOOL enable_compose = False; + #define TRANSLATE(col) ( owncolmap ? col : translate_colour(colmap[col]) ) #define SET_FOREGROUND(col) XSetForeground(display, gc, TRANSLATE(col)); #define SET_BACKGROUND(col) XSetBackground(display, gc, TRANSLATE(col)); @@ -185,7 +190,7 @@ static unsigned long init_inputmethod(void) { - unsigned long filtered_events; + unsigned long filtered_events = 0; IM = XOpenIM(display, NULL, NULL, NULL); if (IM == NULL) @@ -236,6 +241,24 @@ } } +BOOL +ui_init() +{ + Screen *screen; + display = XOpenDisplay(NULL); + if (display == NULL) + { + error("Failed to open display\n"); + return False; + } + if(fullscreen) + { + screen = DefaultScreenOfDisplay(display); + width = WidthOfScreen(screen); + height = HeightOfScreen(screen); + } + return True; +} BOOL ui_create_window(char *title) @@ -248,15 +271,6 @@ Screen *screen; uint16 test; int i; - unsigned long filtered_events; - - display = XOpenDisplay(NULL); - - if (display == NULL) - { - error("Failed to open display\n"); - return False; - } x_socket = ConnectionNumber(display); screen = DefaultScreenOfDisplay(display); @@ -345,16 +359,19 @@ input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | - ButtonReleaseMask | EnterWindowMask | LeaveWindowMask; + ButtonReleaseMask; + if (grab_keyboard) + input_mask |= EnterWindowMask | LeaveWindowMask; if (sendmotion) input_mask |= PointerMotionMask; if (ownbackstore) input_mask |= ExposureMask; - filtered_events = init_inputmethod(); + if (enable_compose) + input_mask |= init_inputmethod(); - XSelectInput(display, wnd, input_mask | filtered_events); + XSelectInput(display, wnd, input_mask); gc = XCreateGC(display, wnd, 0, NULL); @@ -405,7 +422,7 @@ while (XCheckMaskEvent(display, ~0, &xevent)) { - if (XFilterEvent(&xevent, None) == True) + if (enable_compose && (XFilterEvent(&xevent, None) == True)) { DEBUG_KBD("Filtering event\n"); continue; @@ -456,7 +473,9 @@ tr = xkeymap_translate_key(keysym, xevent.xkey. - keycode); + keycode, + xevent.xkey.state); + ensure_remote_modifiers(ev_time, tr); if (tr.scancode == 0) @@ -479,7 +498,8 @@ tr = xkeymap_translate_key(keysym, xevent.xkey. - keycode); + keycode, + xevent.xkey.state); if (tr.scancode == 0) break; @@ -512,14 +532,28 @@ xevent.xmotion.y); break; + case FocusIn: + /* fall through */ case EnterNotify: - XGrabKeyboard(display, wnd, True, - GrabModeAsync, GrabModeAsync, - CurrentTime); + if (grab_keyboard) + XGrabKeyboard(display, wnd, True, + GrabModeAsync, + GrabModeAsync, + CurrentTime); break; + case FocusOut: + /* reset keys */ + rdp_send_input(ev_time, RDP_INPUT_SCANCODE, + KBD_FLAG_DOWN | KBD_FLAG_UP, + SCANCODE_CHAR_LCTRL, 0); + rdp_send_input(ev_time, RDP_INPUT_SCANCODE, + KBD_FLAG_DOWN | KBD_FLAG_UP, + SCANCODE_CHAR_LALT, 0); + /* fall through */ case LeaveNotify: - XUngrabKeyboard(display, CurrentTime); + if (grab_keyboard) + XUngrabKeyboard(display, CurrentTime); break; case Expose: @@ -583,8 +617,8 @@ tdata = (owncolmap ? data : translate_image(width, height, data)); bitmap = XCreatePixmap(display, wnd, width, height, depth); - image = XCreateImage(display, visual, depth, ZPixmap, 0, tdata, width, - height, 8, 0); + image = XCreateImage(display, visual, depth, ZPixmap, 0, + (char *) tdata, width, height, 8, 0); XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height); @@ -602,8 +636,8 @@ uint8 *tdata; tdata = (owncolmap ? data : translate_image(width, height, data)); - image = XCreateImage(display, visual, depth, ZPixmap, 0, tdata, width, - height, 8, 0); + image = XCreateImage(display, visual, depth, ZPixmap, 0, + (char *) tdata, width, height, 8, 0); if (ownbackstore) { @@ -639,8 +673,8 @@ bitmap = XCreatePixmap(display, wnd, width, height, 1); gc = XCreateGC(display, bitmap, 0, NULL); - image = XCreateImage(display, visual, 1, ZPixmap, 0, data, width, - height, 8, scanline); + image = XCreateImage(display, visual, 1, ZPixmap, 0, (char *) data, + width, height, 8, scanline); image->byte_order = MSBFirst; image->bitmap_bit_order = MSBFirst; XInitImage(image); @@ -886,6 +920,7 @@ FILL_RECTANGLE(x, y, cx, cy); XSetFillStyle(display, gc, FillSolid); + XSetTSOrigin(display, gc, 0, 0); ui_destroy_glyph((HGLYPH) fill); break; @@ -1010,9 +1045,10 @@ if ((xyoffset & 0x80))\ {\ if (flags & TEXT2_VERTICAL) \ - y += ttext[++idx] | (ttext[++idx] << 8);\ + y += ttext[idx+1] | (ttext[idx+2] << 8);\ else\ - x += ttext[++idx] | (ttext[++idx] << 8);\ + x += ttext[idx+1] | (ttext[idx+2] << 8);\ + idx += 2;\ }\ else\ {\ @@ -1150,8 +1186,9 @@ if (data == NULL) return; - image = XCreateImage(display, visual, depth, ZPixmap, 0, data, cx, cy, - BitmapPad(display), cx * bpp / 8); + image = XCreateImage(display, visual, depth, ZPixmap, 0, + (char *) data, cx, cy, BitmapPad(display), + cx * bpp / 8); if (ownbackstore) {