/[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 987 by astrand, Thu Aug 4 13:39:57 2005 UTC revision 988 by astrand, Thu Aug 25 20:27:45 2005 UTC
# Line 1341  xwin_toggle_fullscreen(void) Line 1341  xwin_toggle_fullscreen(void)
1341          }          }
1342  }  }
1343    
1344    static void
1345    handle_button_event(XEvent xevent, BOOL down)
1346    {
1347            uint16 button, flags = 0;
1348            g_last_gesturetime = xevent.xbutton.time;
1349            button = xkeymap_translate_button(xevent.xbutton.button);
1350            if (button == 0)
1351                    return;
1352    
1353            if (down)
1354                    flags = MOUSE_FLAG_DOWN;
1355    
1356            /* Stop moving window when button is released, regardless of cursor position */
1357            if (g_moving_wnd && (xevent.type == ButtonRelease))
1358                    g_moving_wnd = False;
1359    
1360            /* If win_button_size is nonzero, enable single app mode */
1361            if (xevent.xbutton.y < g_win_button_size)
1362            {
1363                    /*  Check from right to left: */
1364                    if (xevent.xbutton.x >= g_width - g_win_button_size)
1365                    {
1366                            /* The close button, continue */
1367                            ;
1368                    }
1369                    else if (xevent.xbutton.x >= g_width - g_win_button_size * 2)
1370                    {
1371                            /* The maximize/restore button. Do not send to
1372                               server.  It might be a good idea to change the
1373                               cursor or give some other visible indication
1374                               that rdesktop inhibited this click */
1375                            if (xevent.type == ButtonPress)
1376                                    return;
1377                    }
1378                    else if (xevent.xbutton.x >= g_width - g_win_button_size * 3)
1379                    {
1380                            /* The minimize button. Iconify window. */
1381                            if (xevent.type == ButtonRelease)
1382                            {
1383                                    /* Release the mouse button outside the minimize button, to prevent the
1384                                       actual minimazation to happen */
1385                                    rdp_send_input(time(NULL), RDP_INPUT_MOUSE, button, 1, 1);
1386                                    XIconifyWindow(g_display, g_wnd, DefaultScreen(g_display));
1387                                    return;
1388                            }
1389                    }
1390                    else if (xevent.xbutton.x <= g_win_button_size)
1391                    {
1392                            /* The system menu. Ignore. */
1393                            if (xevent.type == ButtonPress)
1394                                    return;
1395                    }
1396                    else
1397                    {
1398                            /* The title bar. */
1399                            if (xevent.type == ButtonPress)
1400                            {
1401                                    if (!g_fullscreen && g_hide_decorations)
1402                                    {
1403                                            g_moving_wnd = True;
1404                                            g_move_x_offset = xevent.xbutton.x;
1405                                            g_move_y_offset = xevent.xbutton.y;
1406                                    }
1407                                    return;
1408                            }
1409                    }
1410            }
1411    
1412            rdp_send_input(time(NULL), RDP_INPUT_MOUSE,
1413                           flags | button, xevent.xbutton.x, xevent.xbutton.y);
1414    }
1415    
1416  /* Process events in Xlib queue  /* Process events in Xlib queue
1417     Returns 0 after user quit, 1 otherwise */     Returns 0 after user quit, 1 otherwise */
1418  static int  static int
# Line 1348  xwin_process_events(void) Line 1420  xwin_process_events(void)
1420  {  {
1421          XEvent xevent;          XEvent xevent;
1422          KeySym keysym;          KeySym keysym;
         uint16 button, flags;  
1423          uint32 ev_time;          uint32 ev_time;
1424          char str[256];          char str[256];
1425          Status status;          Status status;
# Line 1364  xwin_process_events(void) Line 1435  xwin_process_events(void)
1435                          continue;                          continue;
1436                  }                  }
1437    
                 flags = 0;  
   
1438                  switch (xevent.type)                  switch (xevent.type)
1439                  {                  {
1440                          case VisibilityNotify:                          case VisibilityNotify:
# Line 1430  xwin_process_events(void) Line 1499  xwin_process_events(void)
1499                                  break;                                  break;
1500    
1501                          case ButtonPress:                          case ButtonPress:
1502                                  flags = MOUSE_FLAG_DOWN;                                  handle_button_event(xevent, True);
1503                                  /* fall through */                                  break;
1504    
1505                          case ButtonRelease:                          case ButtonRelease:
1506                                  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);  
1507                                  break;                                  break;
1508    
1509                          case MotionNotify:                          case MotionNotify:

Legend:
Removed from v.987  
changed lines
  Added in v.988

  ViewVC Help
Powered by ViewVC 1.1.26