/[rdesktop]/sourceforge.net/trunk/rdesktop/xwin.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/xwin.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1403 by stargo, Thu Apr 12 16:04:25 2007 UTC revision 1443 by astrand, Thu Mar 6 15:39:21 2008 UTC
# Line 2  Line 2 
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3     User interface services - X Window System     User interface services - X Window System
4     Copyright (C) Matthew Chapman 1999-2007     Copyright (C) Matthew Chapman 1999-2007
5       Copyright 2007 Pierre Ossman <ossman@cendio.se> for Cendio AB
6    
7     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
# Line 74  typedef struct _seamless_window Line 75  typedef struct _seamless_window
75          int outpos_xoffset, outpos_yoffset;          int outpos_xoffset, outpos_yoffset;
76          int outpos_width, outpos_height;          int outpos_width, outpos_height;
77    
78            unsigned int icon_size;
79            unsigned int icon_offset;
80            char icon_buffer[32 * 32 * 4];
81    
82          struct _seamless_window *next;          struct _seamless_window *next;
83  } seamless_window;  } seamless_window;
84  static seamless_window *g_seamless_windows = NULL;  static seamless_window *g_seamless_windows = NULL;
# Line 102  static int g_bpp; Line 107  static int g_bpp;
107  static XIM g_IM;  static XIM g_IM;
108  static XIC g_IC;  static XIC g_IC;
109  static XModifierKeymap *g_mod_map;  static XModifierKeymap *g_mod_map;
110    /* Maps logical (xmodmap -pp) pointing device buttons (0-based) back
111       to physical (1-based) indices. */
112    static unsigned char g_pointer_log_to_phys_map[16];
113  static Cursor g_current_cursor;  static Cursor g_current_cursor;
114  static RD_HCURSOR g_null_cursor = NULL;  static RD_HCURSOR g_null_cursor = NULL;
115  static Atom g_protocol_atom, g_kill_atom;  static Atom g_protocol_atom, g_kill_atom;
# Line 575  translate_colour(uint32 colour) Line 583  translate_colour(uint32 colour)
583                          SPLITCOLOUR16(colour, pc);                          SPLITCOLOUR16(colour, pc);
584                          break;                          break;
585                  case 24:                  case 24:
586                    case 32:
587                          SPLITCOLOUR24(colour, pc);                          SPLITCOLOUR24(colour, pc);
588                          break;                          break;
589                  default:                  default:
# Line 1183  translate_image(int width, int height, u Line 1192  translate_image(int width, int height, u
1192             is only set for compatible depths, but the RDP depth might've             is only set for compatible depths, but the RDP depth might've
1193             changed during connection negotiations.             changed during connection negotiations.
1194           */           */
1195    
1196            /* todo */
1197            if (g_server_depth == 32 && g_depth == 24)
1198            {
1199                    return data;
1200            }
1201    
1202          if (g_no_translate_image)          if (g_no_translate_image)
1203          {          {
1204                  if ((g_depth == 15 && g_server_depth == 15) ||                  if ((g_depth == 15 && g_server_depth == 15) ||
# Line 1260  translate_image(int width, int height, u Line 1276  translate_image(int width, int height, u
1276          return out;          return out;
1277  }  }
1278    
1279    static void
1280    xwin_refresh_pointer_map(void)
1281    {
1282            unsigned char phys_to_log_map[sizeof(g_pointer_log_to_phys_map)];
1283            int i, pointer_buttons;
1284    
1285            pointer_buttons = XGetPointerMapping(g_display, phys_to_log_map, sizeof(phys_to_log_map));
1286            for (i = 0; i < pointer_buttons; ++i)
1287            {
1288                    /* This might produce multiple logical buttons mapping
1289                       to a single physical one, but hey, that's
1290                       life... */
1291                    g_pointer_log_to_phys_map[phys_to_log_map[i] - 1] = i + 1;
1292            }
1293    }
1294    
1295  RD_BOOL  RD_BOOL
1296  get_key_state(unsigned int state, uint32 keysym)  get_key_state(unsigned int state, uint32 keysym)
1297  {  {
# Line 1614  ui_init(void) Line 1646  ui_init(void)
1646          g_width = (g_width + 3) & ~3;          g_width = (g_width + 3) & ~3;
1647    
1648          g_mod_map = XGetModifierMapping(g_display);          g_mod_map = XGetModifierMapping(g_display);
1649            xwin_refresh_pointer_map();
1650    
1651          xkeymap_init();          xkeymap_init();
1652    
# Line 1877  handle_button_event(XEvent xevent, RD_BO Line 1910  handle_button_event(XEvent xevent, RD_BO
1910  {  {
1911          uint16 button, flags = 0;          uint16 button, flags = 0;
1912          g_last_gesturetime = xevent.xbutton.time;          g_last_gesturetime = xevent.xbutton.time;
1913            /* Reverse the pointer button mapping, e.g. in the case of
1914               "left-handed mouse mode"; the RDP session expects to
1915               receive physical buttons (true in mstsc as well) and
1916               logical button behavior depends on the remote desktop's own
1917               mouse settings */
1918            xevent.xbutton.button = g_pointer_log_to_phys_map[xevent.xbutton.button - 1];
1919          button = xkeymap_translate_button(xevent.xbutton.button);          button = xkeymap_translate_button(xevent.xbutton.button);
1920          if (button == 0)          if (button == 0)
1921                  return;                  return;
# Line 2164  xwin_process_events(void) Line 2203  xwin_process_events(void)
2203                                          XFreeModifiermap(g_mod_map);                                          XFreeModifiermap(g_mod_map);
2204                                          g_mod_map = XGetModifierMapping(g_display);                                          g_mod_map = XGetModifierMapping(g_display);
2205                                  }                                  }
2206    
2207                                    if (xevent.xmapping.request == MappingPointer)
2208                                    {
2209                                            xwin_refresh_pointer_map();
2210                                    }
2211    
2212                                  break;                                  break;
2213    
2214                                  /* clipboard stuff */                                  /* clipboard stuff */
# Line 3407  ui_seamless_create_window(unsigned long Line 3452  ui_seamless_create_window(unsigned long
3452                  ewmh_set_window_modal(wnd);                  ewmh_set_window_modal(wnd);
3453          }          }
3454    
3455            if (flags & SEAMLESSRDP_CREATE_TOPMOST)
3456            {
3457                    /* Make window always-on-top */
3458                    ewmh_set_window_above(wnd);
3459            }
3460    
3461          /* FIXME: Support for Input Context:s */          /* FIXME: Support for Input Context:s */
3462    
3463          get_input_mask(&input_mask);          get_input_mask(&input_mask);
# Line 3420  ui_seamless_create_window(unsigned long Line 3471  ui_seamless_create_window(unsigned long
3471          XSetWMProtocols(g_display, wnd, &g_kill_atom, 1);          XSetWMProtocols(g_display, wnd, &g_kill_atom, 1);
3472    
3473          sw = xmalloc(sizeof(seamless_window));          sw = xmalloc(sizeof(seamless_window));
3474    
3475            memset(sw, 0, sizeof(seamless_window));
3476    
3477          sw->wnd = wnd;          sw->wnd = wnd;
3478          sw->id = id;          sw->id = id;
         sw->behind = 0;  
3479          sw->group = sw_find_group(group, False);          sw->group = sw_find_group(group, False);
3480          sw->group->refcnt++;          sw->group->refcnt++;
         sw->xoffset = 0;  
         sw->yoffset = 0;  
         sw->width = 0;  
         sw->height = 0;  
3481          sw->state = SEAMLESSRDP_NOTYETMAPPED;          sw->state = SEAMLESSRDP_NOTYETMAPPED;
3482          sw->desktop = 0;          sw->desktop = 0;
3483          sw->position_timer = xmalloc(sizeof(struct timeval));          sw->position_timer = xmalloc(sizeof(struct timeval));
# Line 3496  ui_seamless_destroy_group(unsigned long Line 3545  ui_seamless_destroy_group(unsigned long
3545    
3546    
3547  void  void
3548    ui_seamless_seticon(unsigned long id, const char *format, int width, int height, int chunk,
3549                        const char *data, int chunk_len)
3550    {
3551            seamless_window *sw;
3552    
3553            if (!g_seamless_active)
3554                    return;
3555    
3556            sw = sw_get_window_by_id(id);
3557            if (!sw)
3558            {
3559                    warning("ui_seamless_seticon: No information for window 0x%lx\n", id);
3560                    return;
3561            }
3562    
3563            if (chunk == 0)
3564            {
3565                    if (sw->icon_size)
3566                            warning("ui_seamless_seticon: New icon started before previous completed\n");
3567    
3568                    if (strcmp(format, "RGBA") != 0)
3569                    {
3570                            warning("ui_seamless_seticon: Uknown icon format \"%s\"\n", format);
3571                            return;
3572                    }
3573    
3574                    sw->icon_size = width * height * 4;
3575                    if (sw->icon_size > 32 * 32 * 4)
3576                    {
3577                            warning("ui_seamless_seticon: Icon too large (%d bytes)\n", sw->icon_size);
3578                            sw->icon_size = 0;
3579                            return;
3580                    }
3581    
3582                    sw->icon_offset = 0;
3583            }
3584            else
3585            {
3586                    if (!sw->icon_size)
3587                            return;
3588            }
3589    
3590            if (chunk_len > (sw->icon_size - sw->icon_offset))
3591            {
3592                    warning("ui_seamless_seticon: Too large chunk received (%d bytes > %d bytes)\n",
3593                            chunk_len, sw->icon_size - sw->icon_offset);
3594                    sw->icon_size = 0;
3595                    return;
3596            }
3597    
3598            memcpy(sw->icon_buffer + sw->icon_offset, data, chunk_len);
3599            sw->icon_offset += chunk_len;
3600    
3601            if (sw->icon_offset == sw->icon_size)
3602            {
3603                    ewmh_set_icon(sw->wnd, width, height, sw->icon_buffer);
3604                    sw->icon_size = 0;
3605            }
3606    }
3607    
3608    
3609    void
3610    ui_seamless_delicon(unsigned long id, const char *format, int width, int height)
3611    {
3612            seamless_window *sw;
3613    
3614            if (!g_seamless_active)
3615                    return;
3616    
3617            sw = sw_get_window_by_id(id);
3618            if (!sw)
3619            {
3620                    warning("ui_seamless_seticon: No information for window 0x%lx\n", id);
3621                    return;
3622            }
3623    
3624            if (strcmp(format, "RGBA") != 0)
3625            {
3626                    warning("ui_seamless_seticon: Uknown icon format \"%s\"\n", format);
3627                    return;
3628            }
3629    
3630            ewmh_del_icon(sw->wnd, width, height);
3631    }
3632    
3633    
3634    void
3635  ui_seamless_move_window(unsigned long id, int x, int y, int width, int height, unsigned long flags)  ui_seamless_move_window(unsigned long id, int x, int y, int width, int height, unsigned long flags)
3636  {  {
3637          seamless_window *sw;          seamless_window *sw;
# Line 3576  ui_seamless_restack_window(unsigned long Line 3712  ui_seamless_restack_window(unsigned long
3712          }          }
3713    
3714          sw_restack_window(sw, behind);          sw_restack_window(sw, behind);
3715    
3716            if (flags & SEAMLESSRDP_CREATE_TOPMOST)
3717            {
3718                    /* Make window always-on-top */
3719                    ewmh_set_window_above(sw->wnd);
3720            }
3721  }  }
3722    
3723    

Legend:
Removed from v.1403  
changed lines
  Added in v.1443

  ViewVC Help
Powered by ViewVC 1.1.26