Krolyxon
Commit 197945f

Branches

Refs →

nsxivwindow.h

109 lines · 2.1 KB · Objective-C

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
27enum {
28 BAR_L_LEN = 512,
29 BAR_R_LEN = 64
30};
31
32enum {
33 ATOM_WM_DELETE_WINDOW,
34 ATOM__NET_WM_NAME,
35 ATOM__NET_WM_ICON_NAME,
36 ATOM__NET_WM_ICON,
37 ATOM__NET_WM_STATE,
38 ATOM__NET_WM_STATE_FULLSCREEN,
39 ATOM__NET_SUPPORTED,
40 ATOM_COUNT
41};
42
43typedef struct {
44 Display *dpy;
45 int scr;
46 int scrw, scrh;
47 Visual *vis;
48 Colormap cmap;
49 int depth;
50} win_env_t;
51
52typedef struct {
53 size_t size;
54 char *p;
55 char *buf;
56} win_bar_t;
57
58typedef struct {
59 Window xwin;
60 win_env_t env;
61
62 unsigned long bgcol;
63 unsigned long fscol;
64 unsigned long selcol;
65
66 int x;
67 int y;
68 unsigned int w;
69 unsigned int h; /* = win height - bar height */
70 unsigned int bw;
71
72 bool fullscreen;
73
74 struct {
75 int w;
76 int h;
77 Pixmap pm;
78 } buf;
79
80 struct {
81 unsigned int h;
82 win_bar_t l;
83 win_bar_t r;
84 unsigned long bgcol;
85 unsigned long fgcol;
86 } bar;
87} win_t;
88
89extern Atom atoms[ATOM_COUNT];
90
91void win_init(win_t*);
92void win_open(win_t*);
93void win_close(win_t*);
94
95bool win_configure(win_t*, XConfigureEvent*);
96
97void win_toggle_fullscreen(win_t*);
98void win_toggle_bar(win_t*);
99
100void win_clear(win_t*);
101void win_draw(win_t*);
102void win_draw_rect(win_t*, int, int, int, int, bool, int, unsigned long);
103
104int win_textwidth(const char*, unsigned int, bool);
105
106void win_set_title(win_t*, const char*);
107void win_set_cursor(win_t*, cursor_t);
108
109#endif /* WINDOW_H */