[mutter/wip/carlosg/coverity-fixes: 2/13] core: Drop code to do edge resistance on timeouts




commit 3298d34e6a66e4d32a5e41c11cbbb565e449c569
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Oct 24 19:45:27 2021 +0200

    core: Drop code to do edge resistance on timeouts
    
    This has been long indirectly disabled (these timeouts were defined
    as 0ms long, thus not set), so edge resistance timeouts can be safely
    deemed dead code.
    
    CID: #1418253

 src/core/edge-resistance.c | 98 ----------------------------------------------
 src/core/edge-resistance.h |  2 -
 src/core/keybindings.c     |  2 -
 src/core/window.c          | 17 --------
 4 files changed, 119 deletions(-)
---
diff --git a/src/core/edge-resistance.c b/src/core/edge-resistance.c
index 3e42936e73..4d5166f064 100644
--- a/src/core/edge-resistance.c
+++ b/src/core/edge-resistance.c
@@ -40,11 +40,6 @@
 
 struct ResistanceDataForAnEdge
 {
-  gboolean     timeout_setup;
-  guint        timeout_id;
-  int          timeout_edge_pos;
-  gboolean     timeout_over;
-  GSourceFunc  timeout_func;
   MetaWindow  *window;
   int          keyboard_buildup;
 };
@@ -312,18 +307,6 @@ movement_towards_edge (MetaSide side, int increment)
     }
 }
 
-static gboolean
-edge_resistance_timeout (gpointer data)
-{
-  ResistanceDataForAnEdge *resistance_data = data;
-
-  resistance_data->timeout_over = TRUE;
-  resistance_data->timeout_id = 0;
-  (*resistance_data->timeout_func)(resistance_data->window);
-
-  return FALSE;
-}
-
 static int
 apply_edge_resistance (MetaWindow                *window,
                        int                        old_pos,
@@ -332,7 +315,6 @@ apply_edge_resistance (MetaWindow                *window,
                        const MetaRectangle       *new_rect,
                        GArray                    *edges,
                        ResistanceDataForAnEdge   *resistance_data,
-                       GSourceFunc                timeout_func,
                        gboolean                   xdir,
                        gboolean                   include_windows,
                        gboolean                   keyboard_op)
@@ -348,25 +330,11 @@ apply_edge_resistance (MetaWindow                *window,
   const int PIXEL_DISTANCE_THRESHOLD_AWAYFROM_MONITOR  =  0;
   const int PIXEL_DISTANCE_THRESHOLD_TOWARDS_SCREEN    = 32;
   const int PIXEL_DISTANCE_THRESHOLD_AWAYFROM_SCREEN   =  0;
-  const int TIMEOUT_RESISTANCE_LENGTH_MS_WINDOW   =   0;
-  const int TIMEOUT_RESISTANCE_LENGTH_MS_MONITOR =   0;
-  const int TIMEOUT_RESISTANCE_LENGTH_MS_SCREEN   =   0;
 
   /* Quit if no movement was specified */
   if (old_pos == new_pos)
     return new_pos;
 
-  /* Remove the old timeout if it's no longer relevant */
-  if (resistance_data->timeout_setup &&
-      ((resistance_data->timeout_edge_pos > old_pos &&
-        resistance_data->timeout_edge_pos > new_pos)  ||
-       (resistance_data->timeout_edge_pos < old_pos &&
-        resistance_data->timeout_edge_pos < new_pos)))
-    {
-      resistance_data->timeout_setup = FALSE;
-      g_clear_handle_id (&resistance_data->timeout_id, g_source_remove);
-    }
-
   /* Get the range of indices in the edge array that we move past/to. */
   begin = find_index_of_edge_near_position (edges, old_pos,  increasing, xdir);
   end   = find_index_of_edge_near_position (edges, new_pos, !increasing, xdir);
@@ -410,48 +378,6 @@ apply_edge_resistance (MetaWindow                *window,
         {
           int threshold;
 
-          /* TIMEOUT RESISTANCE: If the edge is relevant and we're moving
-           * towards it, then we may want to have some kind of time delay
-           * before the user can move past this edge.
-           */
-          if (movement_towards_edge (edge->side_type, increment))
-            {
-              /* First, determine the length of time for the resistance */
-              int timeout_length_ms = 0;
-              switch (edge->edge_type)
-                {
-                case META_EDGE_WINDOW:
-                  if (include_windows)
-                    timeout_length_ms = TIMEOUT_RESISTANCE_LENGTH_MS_WINDOW;
-                  break;
-                case META_EDGE_MONITOR:
-                  timeout_length_ms = TIMEOUT_RESISTANCE_LENGTH_MS_MONITOR;
-                  break;
-                case META_EDGE_SCREEN:
-                  timeout_length_ms = TIMEOUT_RESISTANCE_LENGTH_MS_SCREEN;
-                  break;
-                }
-
-              if (!resistance_data->timeout_setup &&
-                  timeout_length_ms != 0)
-                {
-                  resistance_data->timeout_id =
-                    g_timeout_add (timeout_length_ms,
-                                   edge_resistance_timeout,
-                                   resistance_data);
-                  g_source_set_name_by_id (resistance_data->timeout_id,
-                                           "[mutter] edge_resistance_timeout");
-                  resistance_data->timeout_setup = TRUE;
-                  resistance_data->timeout_edge_pos = compare;
-                  resistance_data->timeout_over = FALSE;
-                  resistance_data->timeout_func = timeout_func;
-                  resistance_data->window = window;
-                }
-              if (!resistance_data->timeout_over &&
-                  timeout_length_ms != 0)
-                return compare;
-            }
-
           /* PIXEL DISTANCE MOUSE RESISTANCE: If the edge matters and the
            * user hasn't moved at least threshold pixels past this edge,
            * stop movement at this edge.  (Note that this is different from
@@ -545,7 +471,6 @@ apply_edge_resistance_to_each_side (MetaDisplay             *display,
                                     MetaWindow              *window,
                                     const MetaRectangle     *old_outer,
                                     MetaRectangle           *new_outer,
-                                    GSourceFunc              timeout_func,
                                     MetaEdgeResistanceFlags  flags,
                                     gboolean                 is_resize)
 {
@@ -660,7 +585,6 @@ apply_edge_resistance_to_each_side (MetaDisplay             *display,
                                               new_outer,
                                               edge_data->left_edges,
                                               &edge_data->left_data,
-                                              timeout_func,
                                               TRUE,
                                               include_windows,
                                               keyboard_op);
@@ -671,7 +595,6 @@ apply_edge_resistance_to_each_side (MetaDisplay             *display,
                                               new_outer,
                                               edge_data->right_edges,
                                               &edge_data->right_data,
-                                              timeout_func,
                                               TRUE,
                                               include_windows,
                                               keyboard_op);
@@ -691,7 +614,6 @@ apply_edge_resistance_to_each_side (MetaDisplay             *display,
                                               new_outer,
                                               edge_data->top_edges,
                                               &edge_data->top_data,
-                                              timeout_func,
                                               FALSE,
                                               include_windows,
                                               keyboard_op);
@@ -702,7 +624,6 @@ apply_edge_resistance_to_each_side (MetaDisplay             *display,
                                               new_outer,
                                               edge_data->bottom_edges,
                                               &edge_data->bottom_data,
-                                              timeout_func,
                                               FALSE,
                                               include_windows,
                                               keyboard_op);
@@ -792,16 +713,6 @@ meta_display_cleanup_edges (MetaDisplay *display)
   edge_data->top_edges = NULL;
   edge_data->bottom_edges = NULL;
 
-  /* Cleanup the timeouts */
-  if (edge_data->left_data.timeout_setup)
-    g_clear_handle_id (&edge_data->left_data.timeout_id, g_source_remove);
-  if (edge_data->right_data.timeout_setup)
-    g_clear_handle_id (&edge_data->right_data.timeout_id, g_source_remove);
-  if (edge_data->top_data.timeout_setup)
-    g_clear_handle_id (&edge_data->top_data.timeout_id, g_source_remove);
-  if (edge_data->bottom_data.timeout_setup)
-    g_clear_handle_id (&edge_data->bottom_data.timeout_id, g_source_remove);
-
   g_free (display->grab_edge_resistance_data);
   display->grab_edge_resistance_data = NULL;
 }
@@ -984,11 +895,6 @@ initialize_grab_edge_resistance_data (MetaDisplay *display)
 {
   MetaEdgeResistanceData *edge_data = display->grab_edge_resistance_data;
 
-  edge_data->left_data.timeout_setup   = FALSE;
-  edge_data->right_data.timeout_setup  = FALSE;
-  edge_data->top_data.timeout_setup    = FALSE;
-  edge_data->bottom_data.timeout_setup = FALSE;
-
   edge_data->left_data.keyboard_buildup   = 0;
   edge_data->right_data.keyboard_buildup  = 0;
   edge_data->top_data.keyboard_buildup    = 0;
@@ -1190,7 +1096,6 @@ void
 meta_window_edge_resistance_for_move (MetaWindow              *window,
                                       int                     *new_x,
                                       int                     *new_y,
-                                      GSourceFunc              timeout_func,
                                       MetaEdgeResistanceFlags  flags)
 {
   MetaRectangle old_outer, proposed_outer, new_outer;
@@ -1214,7 +1119,6 @@ meta_window_edge_resistance_for_move (MetaWindow              *window,
                                           window,
                                           &old_outer,
                                           &new_outer,
-                                          timeout_func,
                                           flags,
                                           is_resize))
     {
@@ -1272,7 +1176,6 @@ meta_window_edge_resistance_for_resize (MetaWindow              *window,
                                         int                     *new_width,
                                         int                     *new_height,
                                         MetaGravity              gravity,
-                                        GSourceFunc              timeout_func,
                                         MetaEdgeResistanceFlags  flags)
 {
   MetaRectangle old_outer, new_outer;
@@ -1295,7 +1198,6 @@ meta_window_edge_resistance_for_resize (MetaWindow              *window,
                                           window,
                                           &old_outer,
                                           &new_outer,
-                                          timeout_func,
                                           flags,
                                           TRUE))
     {
diff --git a/src/core/edge-resistance.h b/src/core/edge-resistance.h
index 4eb6abdca3..a1df480295 100644
--- a/src/core/edge-resistance.h
+++ b/src/core/edge-resistance.h
@@ -27,13 +27,11 @@
 void meta_window_edge_resistance_for_move   (MetaWindow              *window,
                                              int                     *new_x,
                                              int                     *new_y,
-                                             GSourceFunc              timeout_func,
                                              MetaEdgeResistanceFlags  flags);
 void meta_window_edge_resistance_for_resize (MetaWindow              *window,
                                              int                     *new_width,
                                              int                     *new_height,
                                              MetaGravity              gravity,
-                                             GSourceFunc              timeout_func,
                                              MetaEdgeResistanceFlags  flags);
 
 #endif /* META_EDGE_RESISTANCE_H */
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index b1ab7bfce2..975e68897a 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -2510,7 +2510,6 @@ process_keyboard_move_grab (MetaDisplay     *display,
       meta_window_edge_resistance_for_move (window,
                                             &x,
                                             &y,
-                                            NULL,
                                             flags);
 
       meta_window_move_frame (window, TRUE, x, y);
@@ -2864,7 +2863,6 @@ process_keyboard_resize_grab (MetaDisplay     *display,
                                               &width,
                                               &height,
                                               gravity,
-                                              NULL,
                                               flags);
 
       meta_window_resize_frame_with_gravity (window,
diff --git a/src/core/window.c b/src/core/window.c
index 9b3f54df9e..0f0c644d6d 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -139,13 +139,11 @@ static void     update_move           (MetaWindow              *window,
                                        MetaEdgeResistanceFlags  flags,
                                        int                      x,
                                        int                      y);
-static gboolean update_move_timeout   (gpointer data);
 static void     update_resize         (MetaWindow              *window,
                                        MetaEdgeResistanceFlags  flags,
                                        int                      x,
                                        int                      y,
                                        gboolean                 force);
-static gboolean update_resize_timeout (gpointer data);
 static gboolean should_be_on_all_workspaces (MetaWindow *window);
 
 static void meta_window_flush_calc_showing   (MetaWindow *window);
@@ -6104,19 +6102,6 @@ check_moveresize_frequency (MetaWindow *window,
   return TRUE;
 }
 
-static gboolean
-update_move_timeout (gpointer data)
-{
-  MetaWindow *window = data;
-
-  update_move (window,
-               window->display->grab_last_edge_resistance_flags,
-               window->display->grab_latest_motion_x,
-               window->display->grab_latest_motion_y);
-
-  return FALSE;
-}
-
 static void
 update_move_maybe_tile (MetaWindow *window,
                         int         shake_threshold,
@@ -6351,7 +6336,6 @@ update_move (MetaWindow              *window,
   meta_window_edge_resistance_for_move (window,
                                         &new_x,
                                         &new_y,
-                                        update_move_timeout,
                                         flags);
 
   meta_window_move_frame (window, TRUE, new_x, new_y);
@@ -6490,7 +6474,6 @@ update_resize (MetaWindow              *window,
                                           &new_rect.width,
                                           &new_rect.height,
                                           gravity,
-                                          update_resize_timeout,
                                           flags);
 
   meta_window_resize_frame_with_gravity (window, TRUE,


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