WineConsole: clipboard selection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As reported on wine-devel, wineconsole would let selection be bigger than the actual screen buffer, which is plain wrong. This patch blocks this.

A+
--
Eric Pouech
Name:          wc_sel
ChangeLog:     forbids selecting (for clipboard) areas larger than the actual screen-buffer size
License:       X11
GenDate:       2003/02/23 09:15:03 UTC
ModifiedFiles: programs/wineconsole/user.c
AddedFiles:    
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/wineconsole/user.c,v
retrieving revision 1.18
diff -u -u -r1.18 user.c
--- programs/wineconsole/user.c	2 Dec 2002 18:10:57 -0000	1.18
+++ programs/wineconsole/user.c	22 Feb 2003 10:35:50 -0000
@@ -607,16 +607,22 @@
     }
 }
 
 /******************************************************************
  *		WCUSER_MoveSelection
  *
  *
  */
-static void	WCUSER_MoveSelection(struct inner_data* data, COORD c1, COORD c2, BOOL final)
+static void	WCUSER_MoveSelection(struct inner_data* data, COORD c1, COORD c2)
 {
     RECT	r;
     HDC		hDC;
 
+    if (c1.X < 0 || c1.X >= data->curcfg.sb_width ||
+        c2.X < 0 || c2.X >= data->curcfg.sb_width ||
+        c1.Y < 0 || c1.Y >= data->curcfg.sb_height ||
+        c2.Y < 0 || c2.Y >= data->curcfg.sb_height)
+        return;
+
     WCUSER_GetSelectionRect(data, &r);
     hDC = GetDC(PRIVATE(data)->hWnd);
     if (hDC)
@@ -635,11 +642,6 @@
 	if (PRIVATE(data)->hWnd == GetFocus() && data->curcfg.cursor_visible)
 	    ShowCaret(PRIVATE(data)->hWnd);
     }
-    if (final)
-    {
-	ReleaseCapture();
-	PRIVATE(data)->has_selection = TRUE;
-    }
 }
 
 /******************************************************************
@@ -923,37 +926,25 @@
             c1 = PRIVATE(data)->selectPt1;
             c2 = PRIVATE(data)->selectPt2;
             c1.X++; c2.X++;
-            if (c1.X < data->curcfg.sb_width && c2.X < data->curcfg.sb_width)
-            {
-                WCUSER_MoveSelection(data, c1, c2, FALSE);
-            }
+            WCUSER_MoveSelection(data, c1, c2);
             break;
         case VK_LEFT:
             c1 = PRIVATE(data)->selectPt1;
             c2 = PRIVATE(data)->selectPt2;
             c1.X--; c2.X--;
-            if (c1.X >= 0 && c2.X >= 0)
-            {
-                WCUSER_MoveSelection(data, c1, c2, FALSE);
-            }
+            WCUSER_MoveSelection(data, c1, c2);
             break;
         case VK_UP:
             c1 = PRIVATE(data)->selectPt1;
             c2 = PRIVATE(data)->selectPt2;
             c1.Y--; c2.Y--;
-            if (c1.Y >= 0 && c2.Y >= 0)
-            {
-                WCUSER_MoveSelection(data, c1, c2, FALSE);
-            }
+            WCUSER_MoveSelection(data, c1, c2);
             break;
         case VK_DOWN:
             c1 = PRIVATE(data)->selectPt1;
             c2 = PRIVATE(data)->selectPt2;
             c1.Y++; c2.Y++;
-            if (c1.X < data->curcfg.sb_height && c2.X < data->curcfg.sb_height)
-            {
-                WCUSER_MoveSelection(data, c1, c2, FALSE);
-            }
+            WCUSER_MoveSelection(data, c1, c2);
             break;
         }
         break;
@@ -964,37 +955,25 @@
             c1 = PRIVATE(data)->selectPt1;
             c2 = PRIVATE(data)->selectPt2;
             c2.X++;
-            if (c2.X < data->curcfg.sb_width)
-            {
-                WCUSER_MoveSelection(data, c1, c2, FALSE);
-            }
+            WCUSER_MoveSelection(data, c1, c2);
             break;
         case VK_LEFT:
             c1 = PRIVATE(data)->selectPt1;
             c2 = PRIVATE(data)->selectPt2;
             c2.X--;
-            if (c2.X >= c1.X)
-            {
-                WCUSER_MoveSelection(data, c1, c2, FALSE);
-            }
+            WCUSER_MoveSelection(data, c1, c2);
             break;
         case VK_UP:
             c1 = PRIVATE(data)->selectPt1;
             c2 = PRIVATE(data)->selectPt2;
             c2.Y--;
-            if (c2.Y >= c1.Y)
-            {
-                WCUSER_MoveSelection(data, c1, c2, FALSE);
-            }
+            WCUSER_MoveSelection(data, c1, c2);
             break;
         case VK_DOWN:
             c1 = PRIVATE(data)->selectPt1;
             c2 = PRIVATE(data)->selectPt2;
             c2.Y++;
-            if (c2.X < data->curcfg.sb_height)
-            {
-                WCUSER_MoveSelection(data, c1, c2, FALSE);
-            }
+            WCUSER_MoveSelection(data, c1, c2);
             break;
         }
         break;
@@ -1137,7 +1116,7 @@
             if (GetCapture() == PRIVATE(data)->hWnd && PRIVATE(data)->has_selection &&
                 (wParam & MK_LBUTTON))
             {
-                WCUSER_MoveSelection(data, PRIVATE(data)->selectPt1, WCUSER_GetCell(data, lParam), FALSE);
+                WCUSER_MoveSelection(data, PRIVATE(data)->selectPt1, WCUSER_GetCell(data, lParam));
             }
         }
         else
@@ -1151,7 +1130,9 @@
             if (GetCapture() == PRIVATE(data)->hWnd && PRIVATE(data)->has_selection &&
                 (wParam& MK_LBUTTON))
             {
-                WCUSER_MoveSelection(data, PRIVATE(data)->selectPt1, WCUSER_GetCell(data, lParam), TRUE);
+                WCUSER_MoveSelection(data, PRIVATE(data)->selectPt1, WCUSER_GetCell(data, lParam));
+                ReleaseCapture();
+                PRIVATE(data)->has_selection = FALSE;
             }
         }
         else

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux