]>
Dogcows Code - chaz/tint2/blob - src/systray/docker.c
a2e61526a6a82f9fdb3e58016fc6d947d58d7e21
12 #include <X11/Xutil.h>
17 Window win
= None
, hint_win
= None
, root
= None
;
18 gboolean wmaker
= FALSE
; /* WindowMakerMode!!! wheeee */
19 Display
*display
= NULL
;
21 int width
= 0, height
= 0;
22 int border
= 1; /* blank area around icons. must be > 0 */
23 gboolean horizontal
= TRUE
; /* layout direction */
24 int icon_size
= 24; /* width and height of systray icons */
26 //static char *display_string = NULL;
27 /* excluding the border. sum of all child apps */
28 static gboolean exit_app
= FALSE
;
31 void create_hint_win()
34 XClassHint classhints;
36 hint_win = XCreateSimpleWindow(display, root, 0, 0, 1, 1, 0, 0, 0);
39 hints.flags = StateHint | WindowGroupHint | IconWindowHint;
40 hints.initial_state = WithdrawnState;
41 hints.window_group = hint_win;
42 hints.icon_window = win;
44 classhints.res_name = "docker";
45 classhints.res_class = "Docker";
47 XSetWMProperties(display, hint_win, NULL, NULL, argv, argc,
48 NULL, &hints, &classhints);
50 XMapWindow(display, hint_win);
54 void create_main_window()
58 char *name = "Docker";
60 // the border must be > 0 if not in wmaker mode
61 assert(wmaker || border > 0);
64 win = XCreateSimpleWindow(display, root, 0, 0,
65 border * 2, border * 2, 0, 0, 0);
67 win = XCreateSimpleWindow(display, root, 0, 0,
72 XStringListToTextProperty(&name, 1, &text);
73 XSetWMName(display, win, &text);
75 hints.flags = StateHint;
76 hints.initial_state = WithdrawnState;
77 XSetWMHints(display, win, &hints);
81 XSync(display, False);
82 XSetWindowBackgroundPixmap(display, win, ParentRelative);
83 XClearWindow(display, win);
87 void reposition_icons()
89 int x
= border
+ ((width
% icon_size
) / 2),
90 y
= border
+ ((height
% icon_size
) / 2);
93 for (it
= icons
; it
!= NULL
; it
= g_slist_next(it
)) {
94 TrayWindow
*traywin
= it
->data
;
97 XMoveWindow(display
, traywin
->id
, x
, y
);
98 XSync(display
, False
);
101 if (x
+ icon_size
> width
) {
105 } else if (horizontal
)
117 // in wmaker mode we're a fixed size
120 //* find the proper width and height
121 width
= horizontal
? 0 : icon_size
;
122 height
= horizontal
? icon_size
: 0;
123 for (it
= icons
; it
!= NULL
; it
= g_slist_next(it
)) {
130 XResizeWindow(display
, win
, width
+ border
* 2, height
+ border
* 2);
134 int main(int c, char **v)
136 struct sigaction act;
140 act.sa_handler = signal_handler;
142 sigaction(SIGSEGV, &act, NULL);
143 sigaction(SIGPIPE, &act, NULL);
144 sigaction(SIGFPE, &act, NULL);
145 sigaction(SIGTERM, &act, NULL);
146 sigaction(SIGINT, &act, NULL);
147 sigaction(SIGHUP, &act, NULL);
149 parse_cmd_line(argc, argv);
151 display = XOpenDisplay(display_string);
153 g_printerr("Unable to open Display %s. Exiting.\n",
154 DisplayString(display_string));
157 root = RootWindow(display, DefaultScreen(display));
161 width = height = 64 - border * 2;
163 create_main_window();
165 // set up to find KDE systray icons, and get any that already exist
170 // we want to get ConfigureNotify events, and assume our parent's background
171 // has changed when we do, so we need to refresh ourself to match
172 XSelectInput(display, win, StructureNotifyMask);
176 XCloseDisplay(display);
This page took 0.04258 seconds and 4 git commands to generate.