? metacity-scroll-patch-20020821.diff
? metacity.spec
? scroll.diff
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/metacity/ChangeLog,v
retrieving revision 1.423
diff -u -r1.423 ChangeLog
--- ChangeLog	21 Aug 2002 06:47:13 -0000	1.423
+++ ChangeLog	21 Aug 2002 12:57:24 -0000
@@ -1,3 +1,13 @@
+2002-08-21  Gianluigi Calcaterra  <gianluigi.calcaterra@milug.org>
+
+	* src/core.c (meta_core_move_window_next_workspace) 
+	(meta_core_move_window_pre_workspace): add function
+	that move window through the workspace
+
+	* src/frames.c: 
+	(meta_frames_scroll): add function to Move window through
+	workspace and Shade/unshade window whit alt+scroll and scroll
+
 2002-08-21  Deepa Natarajan  <deepa.natarajan@wipro.com>
 
 	* src/keybindings.c, src/metacity.schemas.in, src/prefs.[ch]:
Index: src/core.c
===================================================================
RCS file: /cvs/gnome/metacity/src/core.c,v
retrieving revision 1.28
diff -u -r1.28 core.c
--- src/core.c	8 Aug 2002 05:08:59 -0000	1.28
+++ src/core.c	21 Aug 2002 12:57:27 -0000
@@ -666,3 +666,79 @@
   meta_display_increment_event_serial (display);
 }
 
+gboolean
+meta_core_move_window_next_workspace(Display *xdisplay,
+				     Window frame_xwindow)
+{
+  
+  int num_workspaces;
+  int num_workspace_current;
+  int activate;
+  MetaWindow *window;
+  MetaDisplay *display;
+  MetaWorkspace *workspace;
+  
+  num_workspaces = meta_prefs_get_num_workspaces ();
+
+  if ( num_workspaces == 1 ) return FALSE;
+
+  num_workspace_current=meta_core_get_frame_workspace(xdisplay,frame_xwindow);
+  
+  display = meta_display_for_x_display (xdisplay);
+  window = meta_display_lookup_x_window (display,frame_xwindow);
+
+  if ( window->on_all_workspaces ) return FALSE;
+
+  if ( num_workspace_current == (num_workspaces-1) ) {
+    activate = 0;
+  } else {
+    activate = num_workspace_current+1;
+  }
+  
+  workspace = meta_display_get_workspace_by_screen_index (window->display,
+							  window->screen,
+							  activate);
+  meta_core_change_workspace(xdisplay,frame_xwindow,activate);
+  meta_workspace_activate(workspace);
+  
+  return TRUE;
+}
+
+gboolean
+meta_core_move_window_pre_workspace(Display *xdisplay,
+				     Window frame_xwindow)
+{
+  int num_workspaces;
+  int num_workspace_current;
+  int activate;
+  MetaWindow *window;
+  MetaDisplay *display;
+  MetaWorkspace *workspace;
+  
+  num_workspaces = meta_prefs_get_num_workspaces ();
+
+  if ( num_workspaces == 1 ) return FALSE;
+
+  num_workspace_current=meta_core_get_frame_workspace(xdisplay,frame_xwindow);
+  
+  display = meta_display_for_x_display (xdisplay);
+  window = meta_display_lookup_x_window (display,frame_xwindow);
+
+  if ( window->on_all_workspaces ) return FALSE;
+  
+  if ( num_workspace_current == 0 ) {
+    activate = num_workspaces-1;
+  } else {
+    activate = num_workspace_current-1;
+  }
+  
+  workspace = meta_display_get_workspace_by_screen_index (window->display,
+							  window->screen,
+							  activate);
+
+  meta_core_change_workspace(xdisplay,frame_xwindow,activate);
+  meta_workspace_activate(workspace);
+
+  return TRUE;
+  
+}
Index: src/core.h
===================================================================
RCS file: /cvs/gnome/metacity/src/core.h,v
retrieving revision 1.17
diff -u -r1.17 core.h
--- src/core.h	23 Jul 2002 20:52:22 -0000	1.17
+++ src/core.h	21 Aug 2002 12:57:28 -0000
@@ -150,6 +150,12 @@
  */
 void meta_core_increment_event_serial (Display *display);
 
+gboolean meta_core_move_window_next_workspace(Display *xdisplay,
+					      Window frame_xwindow);
+
+gboolean meta_core_move_window_pre_workspace(Display *xdisplay,
+					     Window frame_xwindow);
+
 #endif
 
 
Index: src/frames.c
===================================================================
RCS file: /cvs/gnome/metacity/src/frames.c,v
retrieving revision 1.62
diff -u -r1.62 frames.c
--- src/frames.c	20 Aug 2002 20:18:18 -0000	1.62
+++ src/frames.c	21 Aug 2002 12:57:35 -0000
@@ -43,6 +43,8 @@
 static void meta_frames_realize    (GtkWidget       *widget);
 static void meta_frames_unrealize  (GtkWidget       *widget);
 
+static gboolean meta_frames_scroll (GtkWidget *widget,
+				    GdkEvent *event );
 static gboolean meta_frames_button_press_event    (GtkWidget           *widget,
                                                    GdkEventButton      *event);
 static gboolean meta_frames_button_release_event  (GtkWidget           *widget,
@@ -138,6 +140,7 @@
   widget_class->motion_notify_event = meta_frames_motion_notify_event;
   widget_class->enter_notify_event = meta_frames_enter_notify_event;
   widget_class->leave_notify_event = meta_frames_leave_notify_event;
+  widget_class->scroll_event = meta_frames_scroll;
 }
 
 static gint
@@ -978,6 +981,74 @@
                   int x, int y)
 {
   return control == get_control (frames, frame, x, y);
+}
+
+static gboolean 
+meta_frames_scroll (GtkWidget *widget,
+		    GdkEvent *event)
+{
+  
+  MetaUIFrame *frame;
+  MetaFrames *frames;
+  MetaFrameControl control;
+
+  frames = META_FRAMES (widget);
+  
+  frame = meta_frames_lookup_window (frames, GDK_WINDOW_XID (event->scroll.window));
+  
+  if (frame == NULL)
+    return FALSE;
+
+  clear_tip (frames);
+  
+  control = get_control (frames, frame, event->scroll.x, event->scroll.y);
+  
+  /*
+   * Move window through workspace
+   */
+  if ( control == META_FRAME_CONTROL_TITLE )      
+    {
+      MetaFrameFlags flags;
+      
+      flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
+
+       if ( flags  &
+	    event->scroll.state & Mod1Mask )
+	 {
+	   if (  event->scroll.direction == GDK_SCROLL_DOWN )
+	     {
+	       
+	       return meta_core_move_window_pre_workspace(gdk_display,frame->xwindow);
+	       
+	     } 
+	   else if ( event->scroll.direction == GDK_SCROLL_UP )
+	     {
+	
+	       return meta_core_move_window_next_workspace(gdk_display,frame->xwindow);
+	       
+	     }
+	   return FALSE;
+	 }
+      
+      /*
+       * Shade/unshade window
+       */
+      if ( flags & META_FRAME_ALLOWS_SHADE)
+	{
+	  if (META_FRAME_SHADED  &&
+	      event->scroll.direction == GDK_SCROLL_DOWN
+	      )
+	    meta_core_unshade (gdk_display,
+			       frame->xwindow);
+	  else if ( event->scroll.direction == GDK_SCROLL_UP )
+	    meta_core_shade (gdk_display,
+			     frame->xwindow);
+	}
+      
+      return TRUE;
+    }
+  
+  return FALSE;
 }
 
 static gboolean
