metacity r3839 - in trunk: . src src/core src/include



Author: tthurman
Date: Mon Sep  1 01:32:39 2008
New Revision: 3839
URL: http://svn.gnome.org/viewvc/metacity?rev=3839&view=rev

Log:
2008-09-01  Thomas Thurman  <tthurman gnome org>

        Add new move_to_center keybinding, requested by Khanh-Dang Nguyen
        Thu Lam; closes #549979.

        * src/include/prefs.h (void): add name of new binding
        * src/core/prefs.c: added pref for it
        * src/core/keybindings.c (handle_move_to_center): new function
        * src/metacity.schemas.in: included new binding



Modified:
   trunk/ChangeLog
   trunk/src/core/keybindings.c
   trunk/src/core/prefs.c
   trunk/src/include/prefs.h
   trunk/src/metacity.schemas.in

Modified: trunk/src/core/keybindings.c
==============================================================================
--- trunk/src/core/keybindings.c	(original)
+++ trunk/src/core/keybindings.c	Mon Sep  1 01:32:39 2008
@@ -234,6 +234,11 @@
                                        MetaWindow     *window,
                                        XEvent         *event,
                                        MetaKeyBinding *binding);
+static void handle_move_to_center     (MetaDisplay    *display,
+                                       MetaScreen     *screen,
+                                       MetaWindow     *window,
+                                       XEvent         *event,
+                                       MetaKeyBinding *binding);
 static void handle_spew_mark          (MetaDisplay    *display,
                                        MetaScreen     *screen,
                                        MetaWindow     *window,
@@ -489,6 +494,7 @@
   { META_KEYBINDING_MOVE_TO_CORNER_NE, handle_move_to_corner_ne, NULL },
   { META_KEYBINDING_MOVE_TO_CORNER_SW, handle_move_to_corner_sw, NULL },
   { META_KEYBINDING_MOVE_TO_CORNER_SE, handle_move_to_corner_se, NULL },
+  { META_KEYBINDING_MOVE_TO_CENTER,    handle_move_to_center, NULL },
   { NULL, NULL, NULL }
 };
 
@@ -3037,6 +3043,36 @@
     }
 }
 
+static void
+handle_move_to_center  (MetaDisplay    *display,
+                        MetaScreen     *screen,
+                        MetaWindow     *window,
+                        XEvent         *event,
+                        MetaKeyBinding *binding)
+{
+  MetaRectangle work_area;
+  MetaRectangle outer;
+  int orig_x, orig_y;
+  int frame_width, frame_height;
+
+  if (!window)
+    return;
+
+  meta_window_get_work_area_all_xineramas (window, &work_area);
+  meta_window_get_outer_rect (window, &outer);
+  meta_window_get_position (window, &orig_x, &orig_y);
+
+  frame_width = (window->frame ? window->frame->child_x : 0);
+  frame_height = (window->frame ? window->frame->child_y : 0);
+
+  meta_window_move_resize (window,
+          TRUE,
+          work_area.x + (work_area.width +frame_width -outer.width )/2,
+          work_area.y + (work_area.height+frame_height-outer.height)/2,
+          window->rect.width,
+          window->rect.height);
+}
+
 static gboolean
 process_workspace_switch_grab (MetaDisplay *display,
                                MetaScreen  *screen,

Modified: trunk/src/core/prefs.c
==============================================================================
--- trunk/src/core/prefs.c	(original)
+++ trunk/src/core/prefs.c	Mon Sep  1 01:32:39 2008
@@ -1929,6 +1929,7 @@
   { META_KEYBINDING_MOVE_TO_SIDE_S, NULL, FALSE },
   { META_KEYBINDING_MOVE_TO_SIDE_E, NULL, FALSE },
   { META_KEYBINDING_MOVE_TO_SIDE_W, NULL, FALSE },
+  { META_KEYBINDING_MOVE_TO_CENTER, NULL, FALSE },
   { NULL, NULL, FALSE }
 };
 

Modified: trunk/src/include/prefs.h
==============================================================================
--- trunk/src/include/prefs.h	(original)
+++ trunk/src/include/prefs.h	Mon Sep  1 01:32:39 2008
@@ -231,6 +231,7 @@
 #define META_KEYBINDING_MOVE_TO_SIDE_S           "move_to_side_s"
 #define META_KEYBINDING_MOVE_TO_SIDE_E           "move_to_side_e"
 #define META_KEYBINDING_MOVE_TO_SIDE_W           "move_to_side_w"
+#define META_KEYBINDING_MOVE_TO_CENTER           "move_to_center"
 
 typedef enum _MetaKeyBindingAction
 {

Modified: trunk/src/metacity.schemas.in
==============================================================================
--- trunk/src/metacity.schemas.in	(original)
+++ trunk/src/metacity.schemas.in	Mon Sep  1 01:32:39 2008
@@ -1329,6 +1329,30 @@
       </locale>
     </schema>
 
+    <schema>
+      <key>/schemas/apps/metacity/window_keybindings/move_to_center</key>
+      <applyto>/apps/metacity/window_keybindings/move_to_center</applyto>
+      <owner>metacity</owner>
+      <type>string</type>
+      <!-- no default for this one -->
+      <locale name="C">
+         <short>Move window to center of screen</short>
+         <long>
+            This keybinding moves a window into the center
+            of the screen.
+
+            The format looks like "&lt;Control&gt;a" or
+            "&lt;Shift&gt;&lt;Alt&gt;F1".
+
+            The parser is fairly liberal and allows lower or upper case,
+            and also abbreviations such as "&lt;Ctl&gt;" and
+            "&lt;Ctrl&gt;". If you set the option to the special string
+            "disabled", then there will be no keybinding for this
+            action.
+         </long>
+      </locale>
+    </schema>
+
     <!-- Global Keybindings -->
 
 



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