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.

13 年之前
13 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* Copyright 2011 Bert Muennich
  2. *
  3. * This file is part of sxiv.
  4. *
  5. * sxiv is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published
  7. * by the Free Software Foundation; either version 2 of the License,
  8. * or (at your option) any later version.
  9. *
  10. * sxiv is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef WINDOW_H
  19. #define WINDOW_H
  20. #include <X11/Xlib.h>
  21. #include <X11/Xutil.h>
  22. #include <X11/Xft/Xft.h>
  23. #include "types.h"
  24. enum {
  25. BAR_L_LEN = 512,
  26. BAR_R_LEN = 64
  27. };
  28. enum {
  29. ATOM_WM_DELETE_WINDOW,
  30. ATOM__NET_WM_NAME,
  31. ATOM__NET_WM_ICON_NAME,
  32. ATOM__NET_WM_ICON,
  33. ATOM__NET_WM_STATE,
  34. ATOM__NET_WM_STATE_FULLSCREEN,
  35. ATOM__NET_SUPPORTED,
  36. ATOM_COUNT
  37. };
  38. typedef struct {
  39. Display *dpy;
  40. int scr;
  41. int scrw, scrh;
  42. Visual *vis;
  43. Colormap cmap;
  44. int depth;
  45. } win_env_t;
  46. typedef struct {
  47. size_t size;
  48. char *p;
  49. char *buf;
  50. } win_bar_t;
  51. typedef struct {
  52. Window xwin;
  53. win_env_t env;
  54. XftColor bgcol;
  55. XftColor fscol;
  56. XftColor selcol;
  57. int x;
  58. int y;
  59. unsigned int w;
  60. unsigned int h; /* = win height - bar height */
  61. unsigned int bw;
  62. bool fullscreen;
  63. struct {
  64. int w;
  65. int h;
  66. Pixmap pm;
  67. } buf;
  68. struct {
  69. unsigned int h;
  70. win_bar_t l;
  71. win_bar_t r;
  72. XftColor bgcol;
  73. XftColor fgcol;
  74. } bar;
  75. } win_t;
  76. extern Atom atoms[ATOM_COUNT];
  77. void win_init(win_t*);
  78. void win_open(win_t*);
  79. CLEANUP void win_close(win_t*);
  80. bool win_configure(win_t*, XConfigureEvent*);
  81. void win_toggle_fullscreen(win_t*);
  82. void win_toggle_bar(win_t*);
  83. void win_clear(win_t*);
  84. void win_draw(win_t*);
  85. void win_draw_rect(win_t*, int, int, int, int, bool, int, unsigned long);
  86. int win_textwidth(const win_env_t*, const char*, unsigned int, bool);
  87. void win_set_title(win_t*, const char*);
  88. void win_set_cursor(win_t*, cursor_t);
  89. #endif /* WINDOW_H */