A Simple X Image Viewer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

165 line
8.2 KiB

  1. #ifdef _WINDOW_CONFIG
  2. /* default window dimensions (overwritten via -g option): */
  3. enum {
  4. WIN_WIDTH = 800,
  5. WIN_HEIGHT = 600
  6. };
  7. /* bar font:
  8. * (see X(7) section "FONT NAMES" for valid values)
  9. */
  10. static const char * const BAR_FONT = "-*-fixed-medium-r-*-*-13-*-*-*-*-60-*-*";
  11. /* colors:
  12. * (see X(7) section "COLOR NAMES" for valid values)
  13. */
  14. static const char * const WIN_BG_COLOR = "#777777";
  15. static const char * const WIN_FS_COLOR = "#000000";
  16. static const char * const SEL_COLOR = "#DDDDDD";
  17. static const char * const BAR_BG_COLOR = "#222222";
  18. static const char * const BAR_FG_COLOR = "#EEEEEE";
  19. #endif
  20. #ifdef _IMAGE_CONFIG
  21. /* levels (in percent) to use when zooming via '-' and '+':
  22. * (first/last value is used as min/max zoom level)
  23. */
  24. static const float zoom_levels[] = {
  25. 12.5, 25.0, 50.0, 75.0,
  26. 100.0, 150.0, 200.0, 400.0, 800.0
  27. };
  28. /* default slideshow delay (in sec, overwritten via -S option): */
  29. enum { SLIDESHOW_DELAY = 5 };
  30. /* default settings for multi-frame gif images: */
  31. enum {
  32. GIF_DELAY = 100, /* delay time (in ms) */
  33. GIF_AUTOPLAY = 1, /* autoplay when loaded [0/1] */
  34. GIF_LOOP = 0 /* loop? [0: no, 1: endless, -1: as specified in file] */
  35. };
  36. /* gamma correction: the user-visible ranges [-GAMMA_RANGE, 0] and
  37. * (0, GAMMA_RANGE] are mapped to the ranges [0, 1], and (1, GAMMA_MAX].
  38. * */
  39. static const double GAMMA_MAX = 10.0;
  40. static const int GAMMA_RANGE = 32;
  41. /* if false, pixelate images at zoom level != 100%,
  42. * toggled with 'a' key binding
  43. */
  44. static const bool ANTI_ALIAS = true;
  45. /* if true, use a checkerboard background for alpha layer,
  46. * toggled with 'A' key binding
  47. */
  48. static const bool ALPHA_LAYER = false;
  49. #endif
  50. #ifdef _THUMBS_CONFIG
  51. /* default dimension of thumbnails (width == height): */
  52. enum { THUMB_SIZE = 60 };
  53. #endif
  54. #ifdef _MAPPINGS_CONFIG
  55. /* keyboard mappings for image and thumbnail mode: */
  56. static const keymap_t keys[] = {
  57. /* modifiers key function argument */
  58. { 0, XK_q, g_quit, (arg_t) None },
  59. { 0, XK_Return, g_switch_mode, (arg_t) None },
  60. { 0, XK_f, g_toggle_fullscreen, (arg_t) None },
  61. { 0, XK_b, g_toggle_bar, (arg_t) None },
  62. { ControlMask, XK_x, g_prefix_external, (arg_t) None },
  63. { 0, XK_g, g_first, (arg_t) None },
  64. { 0, XK_G, g_n_or_last, (arg_t) None },
  65. { 0, XK_r, g_reload_image, (arg_t) None },
  66. { 0, XK_D, g_remove_image, (arg_t) None },
  67. { ControlMask, XK_h, g_scroll_screen, (arg_t) DIR_LEFT },
  68. { ControlMask, XK_Left, g_scroll_screen, (arg_t) DIR_LEFT },
  69. { ControlMask, XK_j, g_scroll_screen, (arg_t) DIR_DOWN },
  70. { ControlMask, XK_Down, g_scroll_screen, (arg_t) DIR_DOWN },
  71. { ControlMask, XK_k, g_scroll_screen, (arg_t) DIR_UP },
  72. { ControlMask, XK_Up, g_scroll_screen, (arg_t) DIR_UP },
  73. { ControlMask, XK_l, g_scroll_screen, (arg_t) DIR_RIGHT },
  74. { ControlMask, XK_Right, g_scroll_screen, (arg_t) DIR_RIGHT },
  75. { 0, XK_m, g_toggle_image_mark, (arg_t) None },
  76. { 0, XK_M, g_reverse_marks, (arg_t) None },
  77. { 0, XK_N, g_navigate_marked, (arg_t) +1 },
  78. { 0, XK_P, g_navigate_marked, (arg_t) -1 },
  79. { 0, XK_h, t_move_sel, (arg_t) DIR_LEFT },
  80. { 0, XK_Left, t_move_sel, (arg_t) DIR_LEFT },
  81. { 0, XK_j, t_move_sel, (arg_t) DIR_DOWN },
  82. { 0, XK_Down, t_move_sel, (arg_t) DIR_DOWN },
  83. { 0, XK_k, t_move_sel, (arg_t) DIR_UP },
  84. { 0, XK_Up, t_move_sel, (arg_t) DIR_UP },
  85. { 0, XK_l, t_move_sel, (arg_t) DIR_RIGHT },
  86. { 0, XK_Right, t_move_sel, (arg_t) DIR_RIGHT },
  87. { 0, XK_R, t_reload_all, (arg_t) None },
  88. { 0, XK_n, i_navigate, (arg_t) +1 },
  89. { 0, XK_space, i_navigate, (arg_t) +1 },
  90. { 0, XK_p, i_navigate, (arg_t) -1 },
  91. { 0, XK_BackSpace, i_navigate, (arg_t) -1 },
  92. { 0, XK_bracketright, i_navigate, (arg_t) +10 },
  93. { 0, XK_bracketleft, i_navigate, (arg_t) -10 },
  94. { ControlMask, XK_6, i_alternate, (arg_t) None },
  95. { ControlMask, XK_n, i_navigate_frame, (arg_t) +1 },
  96. { ControlMask, XK_p, i_navigate_frame, (arg_t) -1 },
  97. { ControlMask, XK_space, i_toggle_animation, (arg_t) None },
  98. { 0, XK_h, i_scroll, (arg_t) DIR_LEFT },
  99. { 0, XK_Left, i_scroll, (arg_t) DIR_LEFT },
  100. { 0, XK_j, i_scroll, (arg_t) DIR_DOWN },
  101. { 0, XK_Down, i_scroll, (arg_t) DIR_DOWN },
  102. { 0, XK_k, i_scroll, (arg_t) DIR_UP },
  103. { 0, XK_Up, i_scroll, (arg_t) DIR_UP },
  104. { 0, XK_l, i_scroll, (arg_t) DIR_RIGHT },
  105. { 0, XK_Right, i_scroll, (arg_t) DIR_RIGHT },
  106. { 0, XK_H, i_scroll_to_edge, (arg_t) DIR_LEFT },
  107. { 0, XK_J, i_scroll_to_edge, (arg_t) DIR_DOWN },
  108. { 0, XK_K, i_scroll_to_edge, (arg_t) DIR_UP },
  109. { 0, XK_L, i_scroll_to_edge, (arg_t) DIR_RIGHT },
  110. { 0, XK_plus, i_zoom, (arg_t) +1 },
  111. { 0, XK_KP_Add, i_zoom, (arg_t) +1 },
  112. { 0, XK_minus, i_zoom, (arg_t) -1 },
  113. { 0, XK_KP_Subtract, i_zoom, (arg_t) -1 },
  114. { 0, XK_equal, i_set_zoom, (arg_t) 100 },
  115. { 0, XK_w, i_fit_to_win, (arg_t) SCALE_DOWN },
  116. { 0, XK_W, i_fit_to_win, (arg_t) SCALE_FIT },
  117. { 0, XK_e, i_fit_to_win, (arg_t) SCALE_WIDTH },
  118. { 0, XK_E, i_fit_to_win, (arg_t) SCALE_HEIGHT },
  119. { 0, XK_less, i_rotate, (arg_t) DEGREE_270 },
  120. { 0, XK_greater, i_rotate, (arg_t) DEGREE_90 },
  121. { 0, XK_question, i_rotate, (arg_t) DEGREE_180 },
  122. { 0, XK_bar, i_flip, (arg_t) FLIP_HORIZONTAL },
  123. { 0, XK_underscore, i_flip, (arg_t) FLIP_VERTICAL },
  124. { 0, XK_braceleft, i_change_gamma, (arg_t) -1 },
  125. { 0, XK_braceright, i_change_gamma, (arg_t) +1 },
  126. { ControlMask, XK_g, i_change_gamma, (arg_t) 0 },
  127. { 0, XK_a, i_toggle_antialias, (arg_t) None },
  128. { 0, XK_A, i_toggle_alpha, (arg_t) None },
  129. { 0, XK_s, i_slideshow, (arg_t) None },
  130. };
  131. /* mouse button mappings for image mode: */
  132. static const button_t buttons[] = {
  133. /* modifiers button function argument */
  134. { 0, 1, i_navigate, (arg_t) +1 },
  135. { 0, 3, i_navigate, (arg_t) -1 },
  136. { 0, 2, i_drag, (arg_t) None },
  137. { 0, 4, i_scroll, (arg_t) DIR_UP },
  138. { 0, 5, i_scroll, (arg_t) DIR_DOWN },
  139. { ShiftMask, 4, i_scroll, (arg_t) DIR_LEFT },
  140. { ShiftMask, 5, i_scroll, (arg_t) DIR_RIGHT },
  141. { 0, 6, i_scroll, (arg_t) DIR_LEFT },
  142. { 0, 7, i_scroll, (arg_t) DIR_RIGHT },
  143. { ControlMask, 4, i_zoom, (arg_t) +1 },
  144. { ControlMask, 5, i_zoom, (arg_t) -1 },
  145. };
  146. #endif