mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +00:00
Make own_window_type a lua setting
This commit is contained in:
parent
518045eaf6
commit
4a5304b395
28
src/conky.cc
28
src/conky.cc
@ -1984,7 +1984,7 @@ static void main_loop(void)
|
||||
}
|
||||
|
||||
/* update struts */
|
||||
if (changed && window.type == TYPE_PANEL) {
|
||||
if (changed && own_window_type.get(*state) == TYPE_PANEL) {
|
||||
int sidenum = -1;
|
||||
|
||||
fprintf(stderr, PACKAGE_NAME": defining struts\n");
|
||||
@ -2119,10 +2119,10 @@ static void main_loop(void)
|
||||
case ButtonPress:
|
||||
if (own_window.get(*state)) {
|
||||
/* if an ordinary window with decorations */
|
||||
if ((window.type == TYPE_NORMAL &&
|
||||
if ((own_window_type.get(*state) == TYPE_NORMAL &&
|
||||
(!TEST_HINT(window.hints,
|
||||
HINT_UNDECORATED))) ||
|
||||
window.type == TYPE_DESKTOP) {
|
||||
own_window_type.get(*state) == TYPE_DESKTOP) {
|
||||
/* allow conky to hold input focus. */
|
||||
break;
|
||||
} else {
|
||||
@ -2142,7 +2142,7 @@ static void main_loop(void)
|
||||
case ButtonRelease:
|
||||
if (own_window.get(*state)) {
|
||||
/* if an ordinary window with decorations */
|
||||
if ((window.type == TYPE_NORMAL)
|
||||
if ((own_window_type.get(*state) == TYPE_NORMAL)
|
||||
&& (!TEST_HINT(window.hints,
|
||||
HINT_UNDECORATED))) {
|
||||
/* allow conky to hold input focus. */
|
||||
@ -2569,7 +2569,6 @@ static void set_default_configurations(void)
|
||||
minimum_height = 5;
|
||||
maximum_width = 0;
|
||||
#ifdef OWN_WINDOW
|
||||
window.type = TYPE_NORMAL;
|
||||
window.hints = 0;
|
||||
#ifdef BUILD_ARGB
|
||||
own_window_argb_value = 255;
|
||||
@ -3269,25 +3268,6 @@ char load_config_file(const char *f)
|
||||
CONF_ERR;
|
||||
}
|
||||
}
|
||||
CONF("own_window_type") {
|
||||
if (value) {
|
||||
if (strncmp(value, "normal", 6) == EQUAL) {
|
||||
window.type = TYPE_NORMAL;
|
||||
} else if (strncmp(value, "desktop", 7) == EQUAL) {
|
||||
window.type = TYPE_DESKTOP;
|
||||
} else if (strncmp(value, "dock", 4) == EQUAL) {
|
||||
window.type = TYPE_DOCK;
|
||||
} else if (strncmp(value, "panel", 5) == EQUAL) {
|
||||
window.type = TYPE_PANEL;
|
||||
} else if (strncmp(value, "override", 8) == EQUAL) {
|
||||
window.type = TYPE_OVERRIDE;
|
||||
} else {
|
||||
CONF_ERR;
|
||||
}
|
||||
} else {
|
||||
CONF_ERR;
|
||||
}
|
||||
}
|
||||
#ifdef BUILD_ARGB
|
||||
CONF("own_window_argb_value") {
|
||||
own_window_argb_value = strtol(value, 0, 0);
|
||||
|
25
src/x11.cc
25
src/x11.cc
@ -294,7 +294,7 @@ void init_window(int w, int h, int back_colour, char **argv, int argc)
|
||||
}
|
||||
#endif /* BUILD_ARGB */
|
||||
|
||||
if (window.type == TYPE_OVERRIDE) {
|
||||
if (own_window_type.get(*state) == TYPE_OVERRIDE) {
|
||||
|
||||
/* An override_redirect True window.
|
||||
* No WM hints or button processing needed. */
|
||||
@ -321,7 +321,7 @@ void init_window(int w, int h, int back_colour, char **argv, int argc)
|
||||
|
||||
fprintf(stderr, PACKAGE_NAME": window type - override\n");
|
||||
fflush(stderr);
|
||||
} else { /* window.type != TYPE_OVERRIDE */
|
||||
} else { /* own_window_type.get(*state) != TYPE_OVERRIDE */
|
||||
|
||||
/* A window managed by the window manager.
|
||||
* Process hints and buttons. */
|
||||
@ -344,7 +344,7 @@ void init_window(int w, int h, int back_colour, char **argv, int argc)
|
||||
}
|
||||
#endif /* BUILD_ARGB */
|
||||
|
||||
if (window.type == TYPE_DOCK) {
|
||||
if (own_window_type.get(*state) == TYPE_DOCK) {
|
||||
window.x = window.y = 0;
|
||||
}
|
||||
/* Parent is root window so WM can take control */
|
||||
@ -366,7 +366,7 @@ void init_window(int w, int h, int back_colour, char **argv, int argc)
|
||||
/* allow decorated windows to be given input focus by WM */
|
||||
wmHint.input =
|
||||
TEST_HINT(window.hints, HINT_UNDECORATED) ? False : True;
|
||||
if (window.type == TYPE_DOCK || window.type == TYPE_PANEL) {
|
||||
if (own_window_type.get(*state) == TYPE_DOCK || own_window_type.get(*state) == TYPE_PANEL) {
|
||||
wmHint.initial_state = WithdrawnState;
|
||||
} else {
|
||||
wmHint.initial_state = NormalState;
|
||||
@ -383,7 +383,7 @@ void init_window(int w, int h, int back_colour, char **argv, int argc)
|
||||
if ((xa = ATOM(_NET_WM_WINDOW_TYPE)) != None) {
|
||||
Atom prop;
|
||||
|
||||
switch (window.type) {
|
||||
switch (own_window_type.get(*state)) {
|
||||
case TYPE_DESKTOP:
|
||||
prop = ATOM(_NET_WM_WINDOW_TYPE_DESKTOP);
|
||||
fprintf(stderr, PACKAGE_NAME": window type - desktop\n");
|
||||
@ -928,7 +928,8 @@ conky::lua_traits<alignment>::Map conky::lua_traits<alignment>::map = {
|
||||
{ "middle_right", MIDDLE_RIGHT },
|
||||
{ "none", NONE }
|
||||
};
|
||||
conky::config_setting<alignment> text_alignment("alignment", conky::simple_accessors<alignment>(NONE, false));
|
||||
conky::config_setting<alignment> text_alignment("alignment",
|
||||
conky::simple_accessors<alignment>(NONE, false));
|
||||
|
||||
conky::config_setting<bool> out_to_x("out_to_x", conky::simple_accessors<bool>(false, false));
|
||||
|
||||
@ -947,6 +948,18 @@ namespace {
|
||||
conky::config_setting<std::string> own_window_title("own_window_title",
|
||||
conky::simple_accessors<std::string>(PACKAGE_NAME " (" + gethostnamecxx()+")", false));
|
||||
|
||||
template<>
|
||||
conky::lua_traits<window_type>::Map conky::lua_traits<window_type>::map = {
|
||||
{ "normal", TYPE_NORMAL },
|
||||
{ "dock", TYPE_DOCK },
|
||||
{ "panel", TYPE_PANEL },
|
||||
{ "desktop", TYPE_DESKTOP },
|
||||
{ "override", TYPE_OVERRIDE }
|
||||
};
|
||||
conky::config_setting<window_type> own_window_type("own_window_type",
|
||||
conky::simple_accessors<window_type>(TYPE_NORMAL, false));
|
||||
|
||||
|
||||
#ifdef BUILD_ARGB
|
||||
conky::config_setting<bool> use_argb_visual("own_window_argb_visual",
|
||||
conky::simple_accessors<bool>(false, false));
|
||||
|
@ -44,7 +44,7 @@
|
||||
#define ATOM(a) XInternAtom(display, #a, False)
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
enum _window_type {
|
||||
enum window_type {
|
||||
TYPE_NORMAL = 0,
|
||||
TYPE_DOCK,
|
||||
TYPE_PANEL,
|
||||
@ -85,7 +85,6 @@ struct conky_window {
|
||||
#ifdef OWN_WINDOW
|
||||
int x;
|
||||
int y;
|
||||
unsigned int type;
|
||||
unsigned long hints;
|
||||
#endif
|
||||
};
|
||||
@ -156,6 +155,7 @@ extern conky::config_setting<bool> own_window;
|
||||
extern conky::config_setting<bool> set_transparent;
|
||||
extern conky::config_setting<std::string> own_window_class;
|
||||
extern conky::config_setting<std::string> own_window_title;
|
||||
extern conky::config_setting<window_type> own_window_type;
|
||||
#ifdef BUILD_ARGB
|
||||
extern conky::config_setting<bool> use_argb_visual;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user