CVS: rdesktop xwin.c,1.193,1.194
Peter Åstrand <[email protected]>
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29754
Modified Files:
xwin.c
Log Message:
Moved mouse button handling to separate function, handle_button_event. The single app mode has been enhanced: The minimazation now works better.
Index: xwin.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/xwin.c,v
retrieving revision 1.193
retrieving revision 1.194
diff -C2 -d -r1.193 -r1.194
*** xwin.c 4 Aug 2005 13:39:57 -0000 1.193
--- xwin.c 25 Aug 2005 20:27:45 -0000 1.194
***************
*** 1342,1345 ****
--- 1342,1417 ----
}
+ static void
+ handle_button_event(XEvent xevent, BOOL down)
+ {
+ uint16 button, flags = 0;
+ g_last_gesturetime = xevent.xbutton.time;
+ button = xkeymap_translate_button(xevent.xbutton.button);
+ if (button == 0)
+ return;
+
+ if (down)
+ flags = MOUSE_FLAG_DOWN;
+
+ /* Stop moving window when button is released, regardless of cursor position */
+ if (g_moving_wnd && (xevent.type == ButtonRelease))
+ g_moving_wnd = False;
+
+ /* If win_button_size is nonzero, enable single app mode */
+ if (xevent.xbutton.y < g_win_button_size)
+ {
+ /* 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 */
+ if (xevent.type == ButtonPress)
+ return;
+ }
+ else if (xevent.xbutton.x >= g_width - g_win_button_size * 3)
+ {
+ /* The minimize button. Iconify window. */
+ if (xevent.type == ButtonRelease)
+ {
+ /* Release the mouse button outside the minimize button, to prevent the
+ actual minimazation to happen */
+ rdp_send_input(time(NULL), RDP_INPUT_MOUSE, button, 1, 1);
+ XIconifyWindow(g_display, g_wnd, DefaultScreen(g_display));
+ return;
+ }
+ }
+ else if (xevent.xbutton.x <= g_win_button_size)
+ {
+ /* The system menu. Ignore. */
+ if (xevent.type == ButtonPress)
+ return;
+ }
+ else
+ {
+ /* The title bar. */
+ if (xevent.type == ButtonPress)
+ {
+ if (!g_fullscreen && g_hide_decorations)
+ {
+ g_moving_wnd = True;
+ g_move_x_offset = xevent.xbutton.x;
+ g_move_y_offset = xevent.xbutton.y;
+ }
+ return;
+ }
+ }
+ }
+
+ rdp_send_input(time(NULL), RDP_INPUT_MOUSE,
+ flags | button, xevent.xbutton.x, xevent.xbutton.y);
+ }
+
/* Process events in Xlib queue
Returns 0 after user quit, 1 otherwise */
***************
*** 1349,1353 ****
XEvent xevent;
KeySym keysym;
- uint16 button, flags;
uint32 ev_time;
char str[256];
--- 1421,1424 ----
***************
*** 1365,1370 ****
}
- flags = 0;
-
switch (xevent.type)
{
--- 1436,1439 ----
***************
*** 1431,1496 ****
case ButtonPress:
! flags = MOUSE_FLAG_DOWN;
! /* fall through */
case ButtonRelease:
! g_last_gesturetime = xevent.xbutton.time;
! 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);
break;
--- 1500,1508 ----
case ButtonPress:
! handle_button_event(xevent, True);
! break;
case ButtonRelease:
! handle_button_event(xevent, False);
break;
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf