| 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 | |
| 19 | #ifndef WINDOW_H |
| 20 | #define WINDOW_H |
| 21 | |
| 22 | #include <X11/Xlib.h> |
| 23 | #include <X11/Xutil.h> |
| 24 | |
| 25 | #include "types.h" |
| 26 | |
| 27 | typedef struct { |
| 28 | Display *dpy; |
| 29 | int scr; |
| 30 | int scrw, scrh; |
| 31 | Visual *vis; |
| 32 | Colormap cmap; |
| 33 | int depth; |
| 34 | } win_env_t; |
| 35 | |
| 36 | typedef struct { |
| 37 | Window xwin; |
| 38 | win_env_t env; |
| 39 | |
| 40 | unsigned long white; |
| 41 | unsigned long bgcol; |
| 42 | unsigned long fscol; |
| 43 | unsigned long selcol; |
| 44 | Pixmap pm; |
| 45 | |
| 46 | int x; |
| 47 | int y; |
| 48 | unsigned int w; |
| 49 | unsigned int h; /* = win height - bar height */ |
| 50 | unsigned int bw; |
| 51 | |
| 52 | XSizeHints sizehints; |
| 53 | |
| 54 | bool fullscreen; |
| 55 | |
| 56 | struct { |
| 57 | unsigned int h; |
| 58 | char *l; |
| 59 | char *r; |
| 60 | unsigned long bgcol; |
| 61 | unsigned long fgcol; |
| 62 | } bar; |
| 63 | } win_t; |
| 64 | |
| 65 | extern Atom wm_delete_win; |
| 66 | |
| 67 | void win_init(win_t*); |
| 68 | void win_open(win_t*); |
| 69 | void win_close(win_t*); |
| 70 | |
| 71 | bool win_configure(win_t*, XConfigureEvent*); |
| 72 | void win_expose(win_t*, XExposeEvent*); |
| 73 | bool win_moveresize(win_t*, int, int, unsigned int, unsigned int); |
| 74 | |
| 75 | void win_toggle_fullscreen(win_t*); |
| 76 | void win_toggle_bar(win_t*); |
| 77 | |
| 78 | void win_clear(win_t*); |
| 79 | void win_draw(win_t*); |
| 80 | void win_draw_rect(win_t*, Pixmap, int, int, int, int, bool, int, |
| 81 | unsigned long); |
| 82 | |
| 83 | int win_textwidth(const char*, unsigned int, bool); |
| 84 | |
| 85 | void win_set_title(win_t*, const char*); |
| 86 | void win_set_bar_info(win_t*, char*, char*); |
| 87 | void win_set_cursor(win_t*, cursor_t); |
| 88 | |
| 89 | #endif /* WINDOW_H */ |