1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-16 18:15:17 +00:00

Fix issues building without BUILD_ARGB flag

Fix half-saved change in display-wayland.cc

Signed-off-by: Tin <tin.svagelj@live.com>
This commit is contained in:
Tin 2023-11-10 13:36:44 +01:00 committed by Brenden Matthews
parent 4936c7492c
commit f6d42c5a69
No known key found for this signature in database
GPG Key ID: 137B7AC2BDFD8DF0
2 changed files with 692 additions and 689 deletions

View File

@ -24,7 +24,7 @@
* *
*/ */
#include <> #include <config.h>
#ifdef BUILD_WAYLAND #ifdef BUILD_WAYLAND
#include <wayland-client.h> #include <wayland-client.h>

View File

@ -93,7 +93,7 @@ xcb_errors_context_t *xcb_errors_ctx;
struct conky_x11_window window; struct conky_x11_window window;
#ifdef BUILD_ARGB #ifdef BUILD_ARGB
bool have_argb_visual; bool have_argb_visual = false;
#endif /* BUILD_ARGB */ #endif /* BUILD_ARGB */
conky::simple_config_setting<std::string> display_name("display", std::string(), conky::simple_config_setting<std::string> display_name("display", std::string(),
@ -495,6 +495,7 @@ static Window find_desktop_window(Window *p_root, Window *p_desktop) {
} }
#ifdef OWN_WINDOW #ifdef OWN_WINDOW
#ifdef BUILD_ARGB
namespace { namespace {
/* helper function for set_transparent_background() */ /* helper function for set_transparent_background() */
void do_set_background(Window win, uint8_t alpha) { void do_set_background(Window win, uint8_t alpha) {
@ -504,6 +505,7 @@ void do_set_background(Window win, uint8_t alpha) {
XSetWindowBackground(display, win, xcolor); XSetWindowBackground(display, win, xcolor);
} }
} // namespace } // namespace
#endif /* BUILD_ARGB */
/* if no argb visual is configured sets background to ParentRelative for the /* if no argb visual is configured sets background to ParentRelative for the
Window and all parents, else real transparency is used */ Window and all parents, else real transparency is used */
@ -514,10 +516,11 @@ void set_transparent_background(Window win) {
do_set_background(win, set_transparent.get(*state) do_set_background(win, set_transparent.get(*state)
? 0 ? 0
: own_window_argb_value.get(*state)); : own_window_argb_value.get(*state));
} else { return;
}
#endif /* BUILD_ARGB */ #endif /* BUILD_ARGB */
// pseudo transparency
// pseudo transparency
if (set_transparent.get(*state)) { if (set_transparent.get(*state)) {
Window parent = win; Window parent = win;
unsigned int i; unsigned int i;
@ -531,14 +534,14 @@ void set_transparent_background(Window win) {
XQueryTree(display, parent, &r, &parent, &children, &n); XQueryTree(display, parent, &r, &parent, &children, &n);
XFree(children); XFree(children);
} }
} else { return;
do_set_background(win, 0);
} }
#ifdef BUILD_ARGB #ifdef BUILD_ARGB
} do_set_background(win, 0);
#endif /* BUILD_ARGB */ #endif /* BUILD_ARGB */
} }
#endif #endif /* OWN_WINDOW */
#ifdef BUILD_ARGB #ifdef BUILD_ARGB
static int get_argb_visual(Visual **visual, int *depth) { static int get_argb_visual(Visual **visual, int *depth) {
@ -593,20 +596,16 @@ void x11_init_window(lua::state &l, bool own) {
return; return;
} }
window.visual = DefaultVisual(display, screen);
window.colourmap = DefaultColormap(display, screen);
depth = CopyFromParent;
visual = CopyFromParent;
#ifdef BUILD_ARGB #ifdef BUILD_ARGB
if (use_argb_visual.get(l) && (get_argb_visual(&visual, &depth) != 0)) { if (use_argb_visual.get(l) && (get_argb_visual(&visual, &depth) != 0)) {
have_argb_visual = true; have_argb_visual = true;
window.visual = visual; window.visual = visual;
window.colourmap = XCreateColormap(display, DefaultRootWindow(display), window.colourmap = XCreateColormap(display, DefaultRootWindow(display),
window.visual, AllocNone); window.visual, AllocNone);
} else {
#endif /* BUILD_ARGB */
window.visual = DefaultVisual(display, screen);
window.colourmap = DefaultColormap(display, screen);
depth = CopyFromParent;
visual = CopyFromParent;
#ifdef BUILD_ARGB
have_argb_visual = false;
} }
#endif /* BUILD_ARGB */ #endif /* BUILD_ARGB */
@ -647,14 +646,12 @@ void x11_init_window(lua::state &l, bool own) {
True, True,
0, 0,
0}; 0};
flags |= CWBackPixel;
#ifdef BUILD_ARGB #ifdef BUILD_ARGB
if (have_argb_visual) { if (have_argb_visual) {
attrs.colormap = window.colourmap; attrs.colormap = window.colourmap;
flags &= ~CWBackPixel;
flags |= CWBorderPixel | CWColormap; flags |= CWBorderPixel | CWColormap;
} else {
#endif /* BUILD_ARGB */
flags |= CWBackPixel;
#ifdef BUILD_ARGB
} }
#endif /* BUILD_ARGB */ #endif /* BUILD_ARGB */
@ -693,16 +690,14 @@ void x11_init_window(lua::state &l, bool own) {
XWMHints wmHint; XWMHints wmHint;
Atom xa; Atom xa;
flags |= CWBackPixel;
#ifdef BUILD_ARGB #ifdef BUILD_ARGB
if (have_argb_visual) { if (have_argb_visual) {
attrs.colormap = window.colourmap; attrs.colormap = window.colourmap;
flags &= ~CWBackPixel;
flags |= CWBorderPixel | CWColormap; flags |= CWBorderPixel | CWColormap;
} else { } else {
#endif /* BUILD_ARGB */ #endif /* BUILD_ARGB */
flags |= CWBackPixel;
#ifdef BUILD_ARGB
}
#endif /* BUILD_ARGB */
if (own_window_type.get(l) == TYPE_DOCK) { window.x = window.y = 0; } if (own_window_type.get(l) == TYPE_DOCK) { window.x = window.y = 0; }
/* Parent is root window so WM can take control */ /* Parent is root window so WM can take control */
@ -729,7 +724,8 @@ void x11_init_window(lua::state &l, bool own) {
/* allow only decorated windows to be given mouse input */ /* allow only decorated windows to be given mouse input */
int major_version; int major_version;
int minor_version; int minor_version;
if (XShapeQueryVersion(display, &major_version, &minor_version) == 0) { if (XShapeQueryVersion(display, &major_version, &minor_version) ==
0) {
NORM_ERR("Input shapes are not supported"); NORM_ERR("Input shapes are not supported");
} else { } else {
if (own_window.get(*state) && if (own_window.get(*state) &&
@ -916,8 +912,8 @@ void x11_init_window(lua::state &l, bool own) {
fflush(stderr); fflush(stderr);
XMapWindow(display, window.window); XMapWindow(display, window.window);
}
} else else
#endif /* OWN_WINDOW */ #endif /* OWN_WINDOW */
{ {
XWindowAttributes attrs; XWindowAttributes attrs;
@ -1016,7 +1012,8 @@ static Window find_subwindow(Window win, int w, int h) {
/* Window must be mapped and same size as display or /* Window must be mapped and same size as display or
* work space */ * work space */
if (attrs.map_state != 0 && if (attrs.map_state != 0 &&
((attrs.width == display_width && attrs.height == display_height) || ((attrs.width == display_width &&
attrs.height == display_height) ||
(attrs.width == w && attrs.height == h))) { (attrs.width == w && attrs.height == h))) {
win = children[j]; win = children[j];
break; break;
@ -1055,15 +1052,16 @@ static inline void get_x11_desktop_current(Display *current_display,
if ((XGetWindowProperty(current_display, root, atom, 0, 1L, False, if ((XGetWindowProperty(current_display, root, atom, 0, 1L, False,
XA_CARDINAL, &actual_type, &actual_format, &nitems, XA_CARDINAL, &actual_type, &actual_format, &nitems,
&bytes_after, &prop) == Success) && &bytes_after, &prop) == Success) &&
(actual_type == XA_CARDINAL) && (nitems == 1L) && (actual_format == 32)) { (actual_type == XA_CARDINAL) && (nitems == 1L) &&
(actual_format == 32)) {
current_info->x11.desktop.current = prop[0] + 1; current_info->x11.desktop.current = prop[0] + 1;
} }
if (prop != nullptr) { XFree(prop); } if (prop != nullptr) { XFree(prop); }
} }
// Get total number of available desktops // Get total number of available desktops
static inline void get_x11_desktop_number(Display *current_display, Window root, static inline void get_x11_desktop_number(Display * current_display,
Atom atom) { Window root, Atom atom) {
Atom actual_type; Atom actual_type;
int actual_format; int actual_format;
unsigned long nitems; unsigned long nitems;
@ -1076,15 +1074,16 @@ static inline void get_x11_desktop_number(Display *current_display, Window root,
if ((XGetWindowProperty(current_display, root, atom, 0, 1L, False, if ((XGetWindowProperty(current_display, root, atom, 0, 1L, False,
XA_CARDINAL, &actual_type, &actual_format, &nitems, XA_CARDINAL, &actual_type, &actual_format, &nitems,
&bytes_after, &prop) == Success) && &bytes_after, &prop) == Success) &&
(actual_type == XA_CARDINAL) && (nitems == 1L) && (actual_format == 32)) { (actual_type == XA_CARDINAL) && (nitems == 1L) &&
(actual_format == 32)) {
current_info->x11.desktop.number = prop[0]; current_info->x11.desktop.number = prop[0];
} }
if (prop != nullptr) { XFree(prop); } if (prop != nullptr) { XFree(prop); }
} }
// Get all desktop names // Get all desktop names
static inline void get_x11_desktop_names(Display *current_display, Window root, static inline void get_x11_desktop_names(Display * current_display,
Atom atom) { Window root, Atom atom) {
Atom actual_type; Atom actual_type;
int actual_format; int actual_format;
unsigned long nitems; unsigned long nitems;
@ -1133,7 +1132,8 @@ void get_x11_desktop_info(Display *current_display, Atom atom) {
/* Check if we initialise else retrieve changed property */ /* Check if we initialise else retrieve changed property */
if (atom == 0) { if (atom == 0) {
atom_current = XInternAtom(current_display, "_NET_CURRENT_DESKTOP", True); atom_current = XInternAtom(current_display, "_NET_CURRENT_DESKTOP", True);
atom_number = XInternAtom(current_display, "_NET_NUMBER_OF_DESKTOPS", True); atom_number =
XInternAtom(current_display, "_NET_NUMBER_OF_DESKTOPS", True);
atom_names = XInternAtom(current_display, "_NET_DESKTOP_NAMES", True); atom_names = XInternAtom(current_display, "_NET_DESKTOP_NAMES", True);
get_x11_desktop_current(current_display, root, atom_current); get_x11_desktop_current(current_display, root, atom_current);
get_x11_desktop_number(current_display, root, atom_number); get_x11_desktop_number(current_display, root, atom_number);
@ -1164,7 +1164,8 @@ void get_x11_desktop_info(Display *current_display, Atom atom) {
static const char NOT_IN_X[] = "Not running in X"; static const char NOT_IN_X[] = "Not running in X";
void print_monitor(struct text_object *obj, char *p, unsigned int p_max_size) { void print_monitor(struct text_object * obj, char *p,
unsigned int p_max_size) {
(void)obj; (void)obj;
if (!out_to_x.get(*state)) { if (!out_to_x.get(*state)) {
@ -1185,7 +1186,8 @@ void print_monitor_number(struct text_object *obj, char *p,
snprintf(p, p_max_size, "%d", XScreenCount(display)); snprintf(p, p_max_size, "%d", XScreenCount(display));
} }
void print_desktop(struct text_object *obj, char *p, unsigned int p_max_size) { void print_desktop(struct text_object * obj, char *p,
unsigned int p_max_size) {
(void)obj; (void)obj;
if (!out_to_x.get(*state)) { if (!out_to_x.get(*state)) {
@ -1269,8 +1271,8 @@ void set_struts(int sidenum) {
} }
XChangeProperty(display, window.window, strut, XA_CARDINAL, 32, XChangeProperty(display, window.window, strut, XA_CARDINAL, 32,
PropModeReplace, reinterpret_cast<unsigned char *>(&sizes), PropModeReplace,
4); reinterpret_cast<unsigned char *>(&sizes), 4);
if ((strut = ATOM(_NET_WM_STRUT_PARTIAL)) != None) { if ((strut = ATOM(_NET_WM_STRUT_PARTIAL)) != None) {
XChangeProperty(display, window.window, strut, XA_CARDINAL, 32, XChangeProperty(display, window.window, strut, XA_CARDINAL, 32,
@ -1356,9 +1358,10 @@ void print_mouse_speed(struct text_object *obj, char *p,
} }
InputEvent *xev_as_input_event(XEvent & ev) { InputEvent *xev_as_input_event(XEvent & ev) {
if (ev.type == KeyPress || ev.type == KeyRelease || ev.type == ButtonPress || if (ev.type == KeyPress || ev.type == KeyRelease ||
ev.type == ButtonRelease || ev.type == MotionNotify || ev.type == ButtonPress || ev.type == ButtonRelease ||
ev.type == EnterNotify || ev.type == LeaveNotify) { ev.type == MotionNotify || ev.type == EnterNotify ||
ev.type == LeaveNotify) {
return reinterpret_cast<InputEvent *>(&ev); return reinterpret_cast<InputEvent *>(&ev);
} else { } else {
return nullptr; return nullptr;
@ -1416,9 +1419,9 @@ Window query_x11_window_at_pos(Display *display, int x, int y) {
XQueryPointer(display, window.root, &root_return, &last, &root_x_return, XQueryPointer(display, window.root, &root_return, &last, &root_x_return,
&root_y_return, &win_x_return, &win_y_return, &mask_return); &root_y_return, &win_x_return, &win_y_return, &mask_return);
// X11 correctly returns a window which covers conky area, but returned window // X11 correctly returns a window which covers conky area, but returned
// is not window.window, but instead a parent node in some cases and the // window is not window.window, but instead a parent node in some cases and
// window.window we want to check for is a 1x1 child of that window. // the window.window we want to check for is a 1x1 child of that window.
return last_descendant(display, last); return last_descendant(display, last);
} }