/[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 976 by astrand, Thu Aug 4 13:39:57 2005 UTC revision 1030 by astrand, Wed Nov 23 12:49:37 2005 UTC
# Line 79  static Pixmap g_backstore = 0; Line 79  static Pixmap g_backstore = 0;
79  static BOOL g_moving_wnd;  static BOOL g_moving_wnd;
80  static int g_move_x_offset = 0;  static int g_move_x_offset = 0;
81  static int g_move_y_offset = 0;  static int g_move_y_offset = 0;
82    static BOOL g_using_full_workarea = False;
83    
84  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
85  extern int g_dsp_fd;  extern int g_dsp_fd;
# Line 137  PixelColour; Line 138  PixelColour;
138                                  XDrawArc(g_display, g_backstore, g_gc, x, y, cx, cy, 0, 360*64); \                                  XDrawArc(g_display, g_backstore, g_gc, x, y, cx, cy, 0, 360*64); \
139                          break; \                          break; \
140                  case 1: /* Filled */ \                  case 1: /* Filled */ \
141                          XFillArc(g_display, g_ownbackstore ? g_backstore : g_wnd, g_gc, x, y, \                          XFillArc(g_display, g_wnd, g_gc, x, y, cx, cy, 0, 360*64); \
                                  cx, cy, 0, 360*64); \  
142                          if (g_ownbackstore) \                          if (g_ownbackstore) \
143                                  XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y); \                                  XFillArc(g_display, g_backstore, g_gc, x, y, cx, cy, 0, 360*64); \
144                          break; \                          break; \
145          } \          } \
146  }  }
# Line 1091  ui_init(void) Line 1091  ui_init(void)
1091          else if (g_width < 0)          else if (g_width < 0)
1092          {          {
1093                  /* Percent of screen */                  /* Percent of screen */
1094                    if (-g_width >= 100)
1095                            g_using_full_workarea = True;
1096                  g_height = HeightOfScreen(g_screen) * (-g_width) / 100;                  g_height = HeightOfScreen(g_screen) * (-g_width) / 100;
1097                  g_width = WidthOfScreen(g_screen) * (-g_width) / 100;                  g_width = WidthOfScreen(g_screen) * (-g_width) / 100;
1098          }          }
# Line 1098  ui_init(void) Line 1100  ui_init(void)
1100          {          {
1101                  /* Fetch geometry from _NET_WORKAREA */                  /* Fetch geometry from _NET_WORKAREA */
1102                  uint32 x, y, cx, cy;                  uint32 x, y, cx, cy;
1103                    g_using_full_workarea = True;
1104    
1105                  if (get_current_workarea(&x, &y, &cx, &cy) == 0)                  if (get_current_workarea(&x, &y, &cx, &cy) == 0)
1106                  {                  {
# Line 1341  xwin_toggle_fullscreen(void) Line 1344  xwin_toggle_fullscreen(void)
1344          }          }
1345  }  }
1346    
1347    static void
1348    handle_button_event(XEvent xevent, BOOL down)
1349    {
1350            uint16 button, flags = 0;
1351            g_last_gesturetime = xevent.xbutton.time;
1352            button = xkeymap_translate_button(xevent.xbutton.button);
1353            if (button == 0)
1354                    return;
1355    
1356            if (down)
1357                    flags = MOUSE_FLAG_DOWN;
1358    
1359            /* Stop moving window when button is released, regardless of cursor position */
1360            if (g_moving_wnd && (xevent.type == ButtonRelease))
1361                    g_moving_wnd = False;
1362    
1363            /* If win_button_size is nonzero, enable single app mode */
1364            if (xevent.xbutton.y < g_win_button_size)
1365            {
1366                    /*  Check from right to left: */
1367                    if (xevent.xbutton.x >= g_width - g_win_button_size)
1368                    {
1369                            /* The close button, continue */
1370                            ;
1371                    }
1372                    else if (xevent.xbutton.x >= g_width - g_win_button_size * 2)
1373                    {
1374                            /* The maximize/restore button. Do not send to
1375                               server.  It might be a good idea to change the
1376                               cursor or give some other visible indication
1377                               that rdesktop inhibited this click */
1378                            if (xevent.type == ButtonPress)
1379                                    return;
1380                    }
1381                    else if (xevent.xbutton.x >= g_width - g_win_button_size * 3)
1382                    {
1383                            /* The minimize button. Iconify window. */
1384                            if (xevent.type == ButtonRelease)
1385                            {
1386                                    /* Release the mouse button outside the minimize button, to prevent the
1387                                       actual minimazation to happen */
1388                                    rdp_send_input(time(NULL), RDP_INPUT_MOUSE, button, 1, 1);
1389                                    XIconifyWindow(g_display, g_wnd, DefaultScreen(g_display));
1390                                    return;
1391                            }
1392                    }
1393                    else if (xevent.xbutton.x <= g_win_button_size)
1394                    {
1395                            /* The system menu. Ignore. */
1396                            if (xevent.type == ButtonPress)
1397                                    return;
1398                    }
1399                    else
1400                    {
1401                            /* The title bar. */
1402                            if (xevent.type == ButtonPress)
1403                            {
1404                                    if (!g_fullscreen && g_hide_decorations && !g_using_full_workarea)
1405                                    {
1406                                            g_moving_wnd = True;
1407                                            g_move_x_offset = xevent.xbutton.x;
1408                                            g_move_y_offset = xevent.xbutton.y;
1409                                    }
1410                                    return;
1411                            }
1412                    }
1413            }
1414    
1415            rdp_send_input(time(NULL), RDP_INPUT_MOUSE,
1416                           flags | button, xevent.xbutton.x, xevent.xbutton.y);
1417    }
1418    
1419  /* Process events in Xlib queue  /* Process events in Xlib queue
1420     Returns 0 after user quit, 1 otherwise */     Returns 0 after user quit, 1 otherwise */
1421  static int  static int
# Line 1348  xwin_process_events(void) Line 1423  xwin_process_events(void)
1423  {  {
1424          XEvent xevent;          XEvent xevent;
1425          KeySym keysym;          KeySym keysym;
         uint16 button, flags;  
1426          uint32 ev_time;          uint32 ev_time;
1427          char str[256];          char str[256];
1428          Status status;          Status status;
# Line 1364  xwin_process_events(void) Line 1438  xwin_process_events(void)
1438                          continue;                          continue;
1439                  }                  }
1440    
                 flags = 0;  
   
1441                  switch (xevent.type)                  switch (xevent.type)
1442                  {                  {
1443                          case VisibilityNotify:                          case VisibilityNotify:
# Line 1430  xwin_process_events(void) Line 1502  xwin_process_events(void)
1502                                  break;                                  break;
1503    
1504                          case ButtonPress:                          case ButtonPress:
1505                                  flags = MOUSE_FLAG_DOWN;                                  handle_button_event(xevent, True);
1506                                  /* fall through */                                  break;
1507    
1508                          case ButtonRelease:                          case ButtonRelease:
1509                                  g_last_gesturetime = xevent.xbutton.time;                                  handle_button_event(xevent, False);
                                 button = xkeymap_translate_button(xevent.xbutton.button);  
                                 if (button == 0)  
                                         break;  
   
                                 /* If win_button_size is nonzero, enable single app mode */  
                                 if (xevent.xbutton.y < g_win_button_size)  
                                 {  
                                         /* Stop moving window when button is released, regardless of cursor position */  
                                         if (g_moving_wnd && (xevent.type == ButtonRelease))  
                                                 g_moving_wnd = False;  
   
                                         /*  Check from right to left: */  
   
                                         if (xevent.xbutton.x >= g_width - g_win_button_size)  
                                         {  
                                                 /* The close button, continue */  
                                                 ;  
                                         }  
                                         else if (xevent.xbutton.x >=  
                                                  g_width - g_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 >=  
                                                  g_width - g_win_button_size * 3)  
                                         {  
                                                 /* The minimize button. Iconify window. */  
                                                 XIconifyWindow(g_display, g_wnd,  
                                                                DefaultScreen(g_display));  
                                                 break;  
                                         }  
                                         else if (xevent.xbutton.x <= g_win_button_size)  
                                         {  
                                                 /* The system menu. Ignore. */  
                                                 break;  
                                         }  
                                         else  
                                         {  
                                                 /* The title bar. */  
                                                 if ((xevent.type == ButtonPress) && !g_fullscreen  
                                                     && g_hide_decorations)  
                                                 {  
                                                         g_moving_wnd = True;  
                                                         g_move_x_offset = xevent.xbutton.x;  
                                                         g_move_y_offset = xevent.xbutton.y;  
                                                 }  
                                                 break;  
   
                                         }  
                                 }  
   
                                 rdp_send_input(time(NULL), RDP_INPUT_MOUSE,  
                                                flags | button, xevent.xbutton.x, xevent.xbutton.y);  
1510                                  break;                                  break;
1511    
1512                          case MotionNotify:                          case MotionNotify:
# Line 2430  ui_draw_text(uint8 font, uint8 flags, ui Line 2445  ui_draw_text(uint8 font, uint8 flags, ui
2445                  switch (text[i])                  switch (text[i])
2446                  {                  {
2447                          case 0xff:                          case 0xff:
2448                                  if (i + 2 < length)                                  if (i + 3 > length)
                                         cache_put_text(text[i + 1], text, text[i + 2]);  
                                 else  
2449                                  {                                  {
2450                                          error("this shouldn't be happening\n");                                          /* short command, skip */
2451                                          exit(1);                                          i = length = 0;
2452                                            break;
2453                                  }                                  }
2454                                    cache_put_text(text[i + 1], text, text[i + 2]);
2455                                    i += 3;
2456                                    length -= i;
2457                                  /* this will move pointer from start to first character after FF command */                                  /* this will move pointer from start to first character after FF command */
2458                                  length -= i + 3;                                  text = &(text[i]);
                                 text = &(text[i + 3]);  
2459                                  i = 0;                                  i = 0;
2460                                  break;                                  break;
2461    
2462                          case 0xfe:                          case 0xfe:
2463                                    if (i + 3 > length)
2464                                    {
2465                                            /* short command, skip */
2466                                            i = length = 0;
2467                                            break;
2468                                    }
2469                                  entry = cache_get_text(text[i + 1]);                                  entry = cache_get_text(text[i + 1]);
2470                                  if (entry != NULL)                                  if (entry->data != NULL)
2471                                  {                                  {
2472                                          if ((((uint8 *) (entry->data))[1] ==                                          if ((((uint8 *) (entry->data))[1] ==
2473                                               0) && (!(flags & TEXT2_IMPLICIT_X)))                                               0) && (!(flags & TEXT2_IMPLICIT_X)))
# Line 2458  ui_draw_text(uint8 font, uint8 flags, ui Line 2480  ui_draw_text(uint8 font, uint8 flags, ui
2480                                          for (j = 0; j < entry->size; j++)                                          for (j = 0; j < entry->size; j++)
2481                                                  DO_GLYPH(((uint8 *) (entry->data)), j);                                                  DO_GLYPH(((uint8 *) (entry->data)), j);
2482                                  }                                  }
2483                                  if (i + 2 < length)                                  i += 3;
                                         i += 3;  
                                 else  
                                         i += 2;  
2484                                  length -= i;                                  length -= i;
2485                                  /* this will move pointer from start to first character after FE command */                                  /* this will move pointer from start to first character after FE command */
2486                                  text = &(text[i]);                                  text = &(text[i]);

Legend:
Removed from v.976  
changed lines
  Added in v.1030

  ViewVC Help
Powered by ViewVC 1.1.26