rewrote the movetoedge code so it works with both types of edges (to edge and from...
[dana/openbox-history.git] / openbox / actions / movetofromedge.c
index 72a89c1..8db4509 100644 (file)
@@ -6,24 +6,16 @@
 
 typedef struct {
     ObDirection dir;
-    gboolean hang;
 } Options;
 
 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_to_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_from_func(ObParseInst *i,xmlDocPtr doc, xmlNodePtr node);
 static void     free_func(gpointer options);
 static gboolean run_func(ObActionsData *data, gpointer options);
 
 void action_movetofromedge_startup()
 {
     actions_register("MoveToEdge",
-                     setup_to_func,
-                     free_func,
-                     run_func,
-                     NULL, NULL);
-    actions_register("MoveFromEdge",
-                     setup_from_func,
+                     setup_func,
                      free_func,
                      run_func,
                      NULL, NULL);
@@ -57,20 +49,6 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
     return o;
 }
 
-static gpointer setup_to_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
-{
-    Options *o = setup_func(i, doc, node);
-    o->hang = FALSE;
-    return o;
-}
-
-static gpointer setup_from_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
-{
-    Options *o = setup_func(i, doc, node);
-    o->hang = TRUE;
-    return o;
-}
-
 static void free_func(gpointer options)
 {
     Options *o = options;
@@ -85,40 +63,13 @@ static gboolean run_func(ObActionsData *data, gpointer options)
 
     if (data->client) {
         gint x, y;
-        ObClient *c = data->client;
 
-        x = c->frame->area.x;
-        y = c->frame->area.y;
-    
-        switch(o->dir) {
-        case OB_DIRECTION_NORTH:
-            y = client_directional_edge_search(c, OB_DIRECTION_NORTH,
-                                               o->hang)
-                - (o->hang ? c->frame->area.height : 0);
-            break;
-        case OB_DIRECTION_WEST:
-            x = client_directional_edge_search(c, OB_DIRECTION_WEST,
-                                               o->hang)
-                - (o->hang ? c->frame->area.width : 0);
-            break;
-        case OB_DIRECTION_SOUTH:
-            y = client_directional_edge_search(c, OB_DIRECTION_SOUTH,
-                                               o->hang)
-                - (o->hang ? 0 : c->frame->area.height);
-            break;
-        case OB_DIRECTION_EAST:
-            x = client_directional_edge_search(c, OB_DIRECTION_EAST,
-                                               o->hang)
-                - (o->hang ? 0 : c->frame->area.width);
-            break;
-        default:
-            g_assert_not_reached();
+        client_find_move_directional(data->client, o->dir, &x, &y);
+        if (x != data->client->area.x || y != data->client->area.y) {
+            actions_client_move(data, FALSE);
+            client_move(data->client, x, y);
+            actions_client_move(data, TRUE);
         }
-        frame_frame_gravity(c->frame, &x, &y);
-
-        actions_client_move(data, FALSE);
-        client_move(c, x, y);
-        actions_client_move(data, TRUE);
     }
 
     return FALSE;