[comp.windows.x] my small patch to vtwm

mcross@blublaze.sw.stratus.com (Matt Cross) (08/15/90)

I was irritated by the way the virtual desktop window handled the moving of
windows.  When you clicked on a window in it, it would move the top left
corner of the window to your current cursor position.  I have changed it so
is more consistent with the way it handles moving real windows - when you click
on a window, it stays in the same place, and moves with the cursor.  If you
click, but not on a window, it moves the center of the main screen to
the cursor
position.  (This is the first time I have ever posted a patch, so let me know
if there's any problems)

-------------------------cut here (and remove sig from
end)----------------------
*** desktop.c.orig	Tue Aug 14 16:54:13 1990
--- desktop.c	Tue Aug 14 16:45:29 1990
***************
*** 219,225 ****
  /*
   * state during the move
   */
! static unsigned int moving_x, moving_y, moving_w, moving_h, moving_bw;
  Window moving_window;
  
  /*
--- 219,226 ----
  /*
   * state during the move
   */
! static unsigned int moving_x, moving_y, moving_w, moving_h, moving_bw,
!                     moving_x_off, moving_y_off;
  Window moving_window;
  
  /*
***************
*** 231,236 ****
--- 232,238 ----
  	Window nowindow;
  	int xoff, yoff;
  	unsigned int d;
+         short int no_win = 0;
  	
  	if (!Scr->Virtual)
  		return;
***************
*** 238,244 ****
  	moving_window = ev.subwindow;
  
  	if (!moving_window)
! 		moving_window = Scr->VirtualDesktopDScreen;
  
  	XGrabPointer(dpy, Scr->VirtualDesktopDisplayOuter, True,
  		     ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
--- 240,250 ----
  	moving_window = ev.subwindow;
  
  	if (!moving_window)
!         {
!              moving_window = Scr->VirtualDesktopDScreen;
!              no_win = 1;
!         }
!              
  
  	XGrabPointer(dpy, Scr->VirtualDesktopDisplayOuter, True,
  		     ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
***************
*** 248,255 ****
  	XGetGeometry(dpy, moving_window, &nowindow, &xoff, &yoff,
  		     &moving_w, &moving_h, &moving_bw, &d);
  
! 	moving_x = ev.x;
! 	moving_y = ev.y;
  
  	DoMoveWindowOnDesktop(ev.x, ev.y);
  }
--- 254,269 ----
  	XGetGeometry(dpy, moving_window, &nowindow, &xoff, &yoff,
  		     &moving_w, &moving_h, &moving_bw, &d);
  
!         if (no_win)
!         {
!              moving_x_off = moving_w / 2;
!              moving_y_off = moving_h / 2;
!         }
!         else
!         {
!              moving_x_off = ev.x - xoff - moving_bw;
!              moving_y_off = ev.y - yoff - moving_bw;
!         }
  
  	DoMoveWindowOnDesktop(ev.x, ev.y);
  }
***************
*** 260,265 ****
--- 274,282 ----
  	if (!Scr->Virtual)
  		return;
  
+         x -= moving_x_off;
+         y -= moving_y_off;
+ 
  	/* check that we are legit */
  	if (x < 0)
  		x = 0;
***************
*** 280,286 ****
  	moving_y = y;
  	
  	/* move the display window */
! 	XMoveWindow(dpy, moving_window, x - moving_bw, y - moving_bw);
  }
  
  void EndMoveWindowOnDesktop()
--- 297,304 ----
  	moving_y = y;
  	
  	/* move the display window */
! 	XMoveWindow(dpy, moving_window, moving_x - moving_bw,
!                     moving_y - moving_bw);
  }
  
  void EndMoveWindowOnDesktop()


-- 
These are my views, and in no way reflect the views of Stratus Computer, Inc.

Mail to: mcross@es.stratus.com or profesor@wpi.wpi.edu