1 /*************************************************************************
2 * Copyright (C) 2024 Francesco Palumbo <phranz.dev@gmail.com>, Naples (Italy)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *************************************************************************/
19 #include "../dectypes.h"
23 extern Display
* display
;
26 extern map_strcol_t
* colors
;
28 extern map_widloci_t
* widlines
;
29 extern map_widloci_t
* widareas
;
30 extern map_widarcssets_t
* widarcssets
;
31 extern map_widarcssets_t
* widarcsareas
;
32 extern map_widloci_t
* widloci
;
33 extern map_widloci_t
* widpixels
;
34 extern map_widnamedpoints_t
* widnamedpoints
;
36 static void draw(widget_t
* w
) {
37 if (w
->flags
& F_HOVERED
&& w
->flags
& F_APPLYHOVER
) {
38 XSetWindowBackground(display
, w
->wid
, w
->hbg
->pixel
);
39 XSetForeground(display
, gc
, w
->hfg
->pixel
);
45 XSetWindowBackground(display
, w
->wid
, w
->bg
->pixel
);
46 XSetForeground(display
, gc
, w
->fg
->pixel
);
48 XSetFont(display
, gc
, w
->fs
->fid
);
49 XClearWindow(display
, w
->wid
);
50 write_align(w
, w
->data
, w
->align
, NULL
);
67 void label_t_free(label_t
* p
) {
68 ((widget_t
*)p
)->free((widget_t
*)p
);;
72 label_t
* label_t_init(label_t
* p
, int ww
, int hh
) {
75 memset(p
, 0, sizeof(label_t
));
76 widget_t
* w
= (widget_t
*)p
;
79 p
->free
= label_t_free
;
88 colors
->get(colors
, "lightgray", &w
->bg
);
89 colors
->get(colors
, "black", &w
->fg
);
91 colors
->get(colors
, "lightgray", &w
->pbg
);
92 colors
->get(colors
, "black", &w
->pfg
);
94 colors
->get(colors
, "lightgray", &w
->hbg
);
95 colors
->get(colors
, "black", &w
->hfg
);
97 XSetWindowAttributes wa
= {0};
99 w
->wid
= XCreateWindow(display
, root
, w
->x
, w
->y
, w
->w
, w
->h
, w
->b
, DefaultDepth(display
, screen
), InputOutput
, DefaultVisual(display
, screen
), CWOverrideRedirect
, &wa
);
101 w
->mask
= VisibilityChangeMask
|ExposureMask
|StructureNotifyMask
;
102 XSelectInput(display
, w
->wid
, w
->mask
);
104 XSetWMProtocols(display
, w
->wid
, &delatom
, 1);