| 1 | /* sxiv: window.h |
| 2 | * Copyright (c) 2012 Bert Muennich <be.muennich at googlemail.com> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU General Public License as published by the |
| 6 | * Free Software Foundation; either version 2 of the License, or (at your |
| 7 | * option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but |
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along |
| 15 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 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 */ |