Convert parameters from pointers to references.
Move Shift processing inside keyboard_scroll_calc().
#include "layout-util.h"
#include "layout.h"
#include "main-defines.h"
-#include "main.h"
#include "menu.h"
#include "misc.h"
#include "options.h"
if (x != 0 || y!= 0)
{
- if (event->state & GDK_SHIFT_MASK)
- {
- x *= 3;
- y *= 3;
- }
-
- keyboard_scroll_calc(&x, &y, event);
+ keyboard_scroll_calc(x, y, event);
image_scroll(imd, x, y);
}
return FALSE;
}
+void keyboard_scroll_calc(gint &x, gint &y, const GdkEventKey *event)
+{
+ static gint delta = 0;
+ static guint32 time_old = 0;
+ static guint keyval_old = 0;
+
+ if (event->state & GDK_SHIFT_MASK)
+ {
+ x *= 3;
+ y *= 3;
+ }
+
+ if (event->state & GDK_CONTROL_MASK)
+ {
+ if (x < 0) x = G_MININT / 2;
+ if (x > 0) x = G_MAXINT / 2;
+ if (y < 0) y = G_MININT / 2;
+ if (y > 0) y = G_MAXINT / 2;
+
+ return;
+ }
+
+ if (options->progressive_key_scrolling)
+ {
+ guint32 time_diff;
+
+ time_diff = event->time - time_old;
+
+ /* key pressed within 125ms ? (1/8 second) */
+ if (time_diff > 125 || event->keyval != keyval_old) delta = 0;
+
+ time_old = event->time;
+ keyval_old = event->keyval;
+
+ delta += 2;
+ }
+ else
+ {
+ delta = 8;
+ }
+
+ x *= delta * options->keyboard_scroll_step;
+ y *= delta * options->keyboard_scroll_step;
+}
+
gboolean layout_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
auto lw = static_cast<LayoutWindow *>(data);
if (x != 0 || y!= 0)
{
- if (event->state & GDK_SHIFT_MASK)
- {
- x *= 3;
- y *= 3;
- }
- keyboard_scroll_calc(&x, &y, event);
+ keyboard_scroll_calc(x, y, event);
layout_image_scroll(lw, x, y, (event->state & GDK_SHIFT_MASK));
}
struct LayoutWindow;
+void keyboard_scroll_calc(gint &x, gint &y, const GdkEventKey *event);
+
gboolean layout_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data);
void layout_util_sync_thumb(LayoutWindow *lw);
#include <execinfo.h>
#endif
+#include <gdk/gdk.h>
#include <gio/gio.h>
#include <glib-object.h>
+#include <gtk/gtk.h>
#ifdef ENABLE_NLS
# include <libintl.h>
}
#endif /* defined(SA_SIGINFO) */
-/*
- *-----------------------------------------------------------------------------
- * keyboard functions
- *-----------------------------------------------------------------------------
- */
-
-void keyboard_scroll_calc(gint *x, gint *y, GdkEventKey *event)
-{
- static gint delta = 0;
- static guint32 time_old = 0;
- static guint keyval_old = 0;
-
- if (event->state & GDK_CONTROL_MASK)
- {
- if (*x < 0) *x = G_MININT / 2;
- if (*x > 0) *x = G_MAXINT / 2;
- if (*y < 0) *y = G_MININT / 2;
- if (*y > 0) *y = G_MAXINT / 2;
-
- return;
- }
-
- if (options->progressive_key_scrolling)
- {
- guint32 time_diff;
-
- time_diff = event->time - time_old;
-
- /* key pressed within 125ms ? (1/8 second) */
- if (time_diff > 125 || event->keyval != keyval_old) delta = 0;
-
- time_old = event->time;
- keyval_old = event->keyval;
-
- delta += 2;
- }
- else
- {
- delta = 8;
- }
-
- *x = *x * delta * options->keyboard_scroll_step;
- *y = *y * delta * options->keyboard_scroll_step;
-}
-
-
-
/*
*-----------------------------------------------------------------------------
* command line parser (private) hehe, who needs popt anyway?
#ifndef MAIN_H
#define MAIN_H
-#include <gdk/gdk.h>
#include <glib.h>
-#include <gtk/gtk.h>
extern gboolean thumb_format_changed;
extern gchar *desktop_file_template;
extern gchar *instance_identifier;
-void keyboard_scroll_calc(gint *x, gint *y, GdkEventKey *event);
-
void exit_program();
#define CASE_SORT(a, b) ( (options->file_sort.case_sensitive) ? strcmp((a), (b)) : strcasecmp((a), (b)) )
#include "layout-util.h"
#include "layout.h"
#include "main-defines.h"
-#include "main.h"
#include "menu.h"
#include "metadata.h"
#include "options.h"
if (x != 0 || y!= 0)
{
- if (event->state & GDK_SHIFT_MASK)
- {
- x *= 3;
- y *= 3;
- }
- keyboard_scroll_calc(&x, &y, event);
+ keyboard_scroll_calc(x, y, event);
pixbuf_renderer_scroll(pr, x, y);
}
}