mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-27 09:08:25 +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:
parent
4936c7492c
commit
f6d42c5a69
@ -24,7 +24,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <>
|
||||
#include <config.h>
|
||||
|
||||
#ifdef BUILD_WAYLAND
|
||||
#include <wayland-client.h>
|
||||
|
91
src/x11.cc
91
src/x11.cc
@ -93,7 +93,7 @@ xcb_errors_context_t *xcb_errors_ctx;
|
||||
struct conky_x11_window window;
|
||||
|
||||
#ifdef BUILD_ARGB
|
||||
bool have_argb_visual;
|
||||
bool have_argb_visual = false;
|
||||
#endif /* BUILD_ARGB */
|
||||
|
||||
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 BUILD_ARGB
|
||||
namespace {
|
||||
/* helper function for set_transparent_background() */
|
||||
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);
|
||||
}
|
||||
} // namespace
|
||||
#endif /* BUILD_ARGB */
|
||||
|
||||
/* if no argb visual is configured sets background to ParentRelative for the
|
||||
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)
|
||||
? 0
|
||||
: own_window_argb_value.get(*state));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
#endif /* BUILD_ARGB */
|
||||
// pseudo transparency
|
||||
|
||||
// pseudo transparency
|
||||
if (set_transparent.get(*state)) {
|
||||
Window parent = win;
|
||||
unsigned int i;
|
||||
@ -531,14 +534,14 @@ void set_transparent_background(Window win) {
|
||||
XQueryTree(display, parent, &r, &parent, &children, &n);
|
||||
XFree(children);
|
||||
}
|
||||
} else {
|
||||
do_set_background(win, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef BUILD_ARGB
|
||||
}
|
||||
do_set_background(win, 0);
|
||||
#endif /* BUILD_ARGB */
|
||||
}
|
||||
#endif
|
||||
#endif /* OWN_WINDOW */
|
||||
|
||||
#ifdef BUILD_ARGB
|
||||
static int get_argb_visual(Visual **visual, int *depth) {
|
||||
@ -593,20 +596,16 @@ void x11_init_window(lua::state &l, bool own) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.visual = DefaultVisual(display, screen);
|
||||
window.colourmap = DefaultColormap(display, screen);
|
||||
depth = CopyFromParent;
|
||||
visual = CopyFromParent;
|
||||
#ifdef BUILD_ARGB
|
||||
if (use_argb_visual.get(l) && (get_argb_visual(&visual, &depth) != 0)) {
|
||||
have_argb_visual = true;
|
||||
window.visual = visual;
|
||||
window.colourmap = XCreateColormap(display, DefaultRootWindow(display),
|
||||
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 */
|
||||
|
||||
@ -647,14 +646,12 @@ void x11_init_window(lua::state &l, bool own) {
|
||||
True,
|
||||
0,
|
||||
0};
|
||||
flags |= CWBackPixel;
|
||||
#ifdef BUILD_ARGB
|
||||
if (have_argb_visual) {
|
||||
attrs.colormap = window.colourmap;
|
||||
flags &= ~CWBackPixel;
|
||||
flags |= CWBorderPixel | CWColormap;
|
||||
} else {
|
||||
#endif /* BUILD_ARGB */
|
||||
flags |= CWBackPixel;
|
||||
#ifdef BUILD_ARGB
|
||||
}
|
||||
#endif /* BUILD_ARGB */
|
||||
|
||||
@ -693,16 +690,14 @@ void x11_init_window(lua::state &l, bool own) {
|
||||
XWMHints wmHint;
|
||||
Atom xa;
|
||||
|
||||
flags |= CWBackPixel;
|
||||
#ifdef BUILD_ARGB
|
||||
if (have_argb_visual) {
|
||||
attrs.colormap = window.colourmap;
|
||||
flags &= ~CWBackPixel;
|
||||
flags |= CWBorderPixel | CWColormap;
|
||||
} else {
|
||||
#endif /* BUILD_ARGB */
|
||||
flags |= CWBackPixel;
|
||||
#ifdef BUILD_ARGB
|
||||
}
|
||||
#endif /* BUILD_ARGB */
|
||||
|
||||
if (own_window_type.get(l) == TYPE_DOCK) { window.x = window.y = 0; }
|
||||
/* 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 */
|
||||
int major_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");
|
||||
} else {
|
||||
if (own_window.get(*state) &&
|
||||
@ -916,8 +912,8 @@ void x11_init_window(lua::state &l, bool own) {
|
||||
fflush(stderr);
|
||||
|
||||
XMapWindow(display, window.window);
|
||||
|
||||
} else
|
||||
}
|
||||
else
|
||||
#endif /* OWN_WINDOW */
|
||||
{
|
||||
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
|
||||
* work space */
|
||||
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))) {
|
||||
win = children[j];
|
||||
break;
|
||||
@ -1055,15 +1052,16 @@ static inline void get_x11_desktop_current(Display *current_display,
|
||||
if ((XGetWindowProperty(current_display, root, atom, 0, 1L, False,
|
||||
XA_CARDINAL, &actual_type, &actual_format, &nitems,
|
||||
&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;
|
||||
}
|
||||
if (prop != nullptr) { XFree(prop); }
|
||||
}
|
||||
|
||||
// Get total number of available desktops
|
||||
static inline void get_x11_desktop_number(Display *current_display, Window root,
|
||||
Atom atom) {
|
||||
static inline void get_x11_desktop_number(Display * current_display,
|
||||
Window root, Atom atom) {
|
||||
Atom actual_type;
|
||||
int actual_format;
|
||||
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,
|
||||
XA_CARDINAL, &actual_type, &actual_format, &nitems,
|
||||
&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];
|
||||
}
|
||||
if (prop != nullptr) { XFree(prop); }
|
||||
}
|
||||
|
||||
// Get all desktop names
|
||||
static inline void get_x11_desktop_names(Display *current_display, Window root,
|
||||
Atom atom) {
|
||||
static inline void get_x11_desktop_names(Display * current_display,
|
||||
Window root, Atom atom) {
|
||||
Atom actual_type;
|
||||
int actual_format;
|
||||
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 */
|
||||
if (atom == 0) {
|
||||
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);
|
||||
get_x11_desktop_current(current_display, root, atom_current);
|
||||
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";
|
||||
|
||||
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;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (!out_to_x.get(*state)) {
|
||||
@ -1269,8 +1271,8 @@ void set_struts(int sidenum) {
|
||||
}
|
||||
|
||||
XChangeProperty(display, window.window, strut, XA_CARDINAL, 32,
|
||||
PropModeReplace, reinterpret_cast<unsigned char *>(&sizes),
|
||||
4);
|
||||
PropModeReplace,
|
||||
reinterpret_cast<unsigned char *>(&sizes), 4);
|
||||
|
||||
if ((strut = ATOM(_NET_WM_STRUT_PARTIAL)) != None) {
|
||||
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) {
|
||||
if (ev.type == KeyPress || ev.type == KeyRelease || ev.type == ButtonPress ||
|
||||
ev.type == ButtonRelease || ev.type == MotionNotify ||
|
||||
ev.type == EnterNotify || ev.type == LeaveNotify) {
|
||||
if (ev.type == KeyPress || ev.type == KeyRelease ||
|
||||
ev.type == ButtonPress || ev.type == ButtonRelease ||
|
||||
ev.type == MotionNotify || ev.type == EnterNotify ||
|
||||
ev.type == LeaveNotify) {
|
||||
return reinterpret_cast<InputEvent *>(&ev);
|
||||
} else {
|
||||
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,
|
||||
&root_y_return, &win_x_return, &win_y_return, &mask_return);
|
||||
|
||||
// X11 correctly returns a window which covers conky area, but returned window
|
||||
// is not window.window, but instead a parent node in some cases and the
|
||||
// window.window we want to check for is a 1x1 child of that window.
|
||||
// X11 correctly returns a window which covers conky area, but returned
|
||||
// window is not window.window, but instead a parent node in some cases and
|
||||
// the window.window we want to check for is a 1x1 child of that window.
|
||||
return last_descendant(display, last);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user