Krolyxon
Commit 30e9ec8

Branches

Refs →

nsxivwindow.h

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