-
Notifications
You must be signed in to change notification settings - Fork 45
/
alttab.h
160 lines (141 loc) · 4.92 KB
/
alttab.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
Global includes.
Copyright 2017-2018 Alexander Kulak.
This file is part of alttab program.
alttab is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
alttab is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with alttab. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ALTTAB_H
#define ALTTAB_H
#define MAXNAMESZ 256
#define MAXPATHSZ 8200
#define MAXRPOUT 8200
#define MAXWINDOWS 1024
// as there are no files involved, we can die at any time
// BUT? "it is a good idea to free all the pixmaps that your program created before exiting from the program, pixmaps are stored in the server, if they are not freed they could remain allocated after the program exits"
#define die(e) do { fprintf(stderr, "%s\n", e); exit(1); } while (0);
#define die2(e,f) do { fprintf(stderr, "%s%s\n", e, f); exit(1); } while (0);
#define XWINNAME "alttab"
#define XRMAPPNAME XWINNAME
#define XCLASSNAME XWINNAME
#define XCLASS "AltTab"
#define DEFTILEW 112
#define DEFTILEH 128
#define DEFTILE "112x128"
#define DEFICONW 32
#define DEFICONH 32
#define DEFICON "32x32"
#define DEFTHEME "hicolor"
#define FRAME_W 8
//#define DEFFONT "xft:DejaVu Sans Condensed-10"
#define DEFFONT "xft:sans-10"
#define COLBG 0
#define COLFG 1
#define COLFRAME 2
#define NCOLORS 3
#define DEFCOLBG "black"
#define DEFCOLFG "grey"
#define DEFCOLFRAME "#a0abab"
#define XDEPTH 24 // TODO: get rid of this
#define DEFMODMASK Mod1Mask
#define DEFBACKMASK ShiftMask
#define DEFMODKS XK_Alt_L
#define DEFKEYKS XK_Tab
#include "icon.h"
typedef struct {
Window id;
int wm_id; // wm's internal window id, when WM has it (ratpoison)
char name[MAXNAMESZ];
int reclevel;
Pixmap icon_drawable; // Window or Pixmap
Pixmap icon_mask;
unsigned int icon_w, icon_h;
bool icon_allocated; // we must free icon, because we created it (placeholder or depth conversion)
Pixmap tile; // ready to display. w/h are all equal and defined in gui.c
int order; // in sort stack, kept in sync with g.sortlist
} WindowInfo;
typedef struct {
//char name[MAXNAMESZ];
char *name;
XColor xcolor;
XftColor xftcolor;
//XRenderColor xrendercolor;
} Color;
typedef struct {
int debug;
bool uiShowHasRun; // means: 1. window is ready to Expose, 2. need to call uiHide to free X stuff
WindowInfo *winlist;
int maxNdx; // number of items in list above
int selNdx; // current (selected) item
int startNdx; // current item at start of uiShow (current window before setFocus)
Window sortlist[MAXWINDOWS]; // auxiliary list for sorting
// display-wide, for all groups/desktops
// unlike g.winlist, survives uiHide
// for each uiShow, g.winlist[].order is initialized using this list
int sortNdx; // number of elements in list above
// option_* are initialized from command line arguments or X resources or defaults
int option_max_reclevel; // max reclevel. -1 is "everything"
#define WM_MIN 0
#define WM_NO 0
#define WM_EWMH 1
#define WM_RATPOISON 2
#define WM_TWM 3
#define WM_MAX 3
int option_wm;
char *option_font;
int option_tileW, option_tileH;
int option_iconW, option_iconH;
#define ISRC_MIN 0
#define ISRC_RAM 0
#define ISRC_FALLBACK 1
#define ISRC_SIZE 2
#define ISRC_FILES 3
#define ISRC_MAX 3
#define ISRC_DEFAULT 2
int option_iconSrc;
char *option_theme;
unsigned int option_modMask, option_backMask;
KeyCode option_modCode, option_keyCode;
Color color[NCOLORS];
GC gcDirect, gcReverse, gcFrame; // used in both gui.c and win.c
unsigned int ignored_modmask;
icon_t *ic; // cache of all icons
} Globals;
// gui
int startupGUItasks();
int uiShow(bool direction);
void uiExpose();
int uiHide();
int uiNextWindow();
int uiPrevWindow();
// windows
int startupWintasks();
int addIconFromHints (WindowInfo* wi);
int addIconFromFiles (WindowInfo* wi);
int addWindowInfo(Window win, int reclevel, int wm_id, char *wm_name);
int initWinlist(bool direction);
void freeWinlist();
int setFocus(int winNdx);
int rp_startupWintasks();
int x_initWindowsInfoRecursive(Window win, int reclevel);
int rp_initWinlist();
int x_setFocus(int wndx);
int rp_setFocus(int winNdx);
int execAndReadStdout(char *exe, char *args[], char *buf, int bufsize);
int pulloutWindowToTop(int winNdx);
/* EWHM */
char *ewmh_getWmName();
int ewmh_initWinlist();
int ewmh_setFocus(int winNdx, Window fwin); // fwin used if non-zero
unsigned long ewmh_getCurrentDesktop();
unsigned long ewmh_getDesktopOfWindow(Window w);
bool ewmh_skipWindowInTaskbar(Window w);
#endif