changeset 3375:6e4944657ab9 trunk

prevent some useless redraws
author Tomasz Mon <desowin@gmail.com>
date Thu, 23 Aug 2007 12:43:57 +0200
parents 5a39f264f9f5
children 30088b5ae4e4
files src/audacious/ui_playlist.c
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/ui_playlist.c	Tue Aug 21 14:29:53 2007 +0900
+++ b/src/audacious/ui_playlist.c	Thu Aug 23 12:43:57 2007 +0200
@@ -1096,14 +1096,17 @@
     return TRUE;
 }
 
-static void
+static gboolean
 playlistwin_keypress_up_down_handler(UiSkinnedPlaylist * pl,
                                      gboolean up, guint state)
 {
     Playlist *playlist = playlist_get_active();
+    if ((!(pl->prev_selected || pl->first) && up) ||
+       ((pl->prev_selected >= playlist_get_length(playlist) - 1) && !up))
+         return FALSE;
 
     if ((state & GDK_MOD1_MASK) && (state & GDK_SHIFT_MASK))
-        return;
+        return FALSE;
     if (!(state & GDK_MOD1_MASK))
         playlist_select_all(playlist, FALSE);
 
@@ -1125,7 +1128,7 @@
         pl->first = MAX(pl->first, pl->prev_max -
                            pl->num_visible + 1);
         playlist_select_range(playlist, pl->prev_min, pl->prev_max, TRUE);
-        return;
+        return TRUE;
     }
     else if (state & GDK_MOD1_MASK) {
         if (up)
@@ -1136,7 +1139,7 @@
             pl->first = pl->prev_min;
         else if (pl->prev_max >= (pl->first + pl->num_visible))
             pl->first = pl->prev_max - pl->num_visible + 1;
-        return;
+        return TRUE;
     }
     else if (up)
         pl->prev_selected--;
@@ -1153,6 +1156,8 @@
 
     playlist_select_range(playlist, pl->prev_selected, pl->prev_selected, TRUE);
     pl->prev_min = -1;
+
+    return TRUE;
 }
 
 /* FIXME: Handle the keys through menu */
@@ -1173,11 +1178,10 @@
     case GDK_KP_Down:
     case GDK_Up:
     case GDK_Down:
-        playlistwin_keypress_up_down_handler(UI_SKINNED_PLAYLIST(playlistwin_list),
-                                             keyval == GDK_Up
-                                             || keyval == GDK_KP_Up,
-                                             event->state);
-        refresh = TRUE;
+        refresh = playlistwin_keypress_up_down_handler(UI_SKINNED_PLAYLIST(playlistwin_list),
+                                                       keyval == GDK_Up
+                                                       || keyval == GDK_KP_Up,
+                                                       event->state);
         break;
     case GDK_Page_Up:
         playlistwin_scroll(-UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible);