Mouse effects: fixes, changed defaults, more config options
@@ -70,6 +70,11 @@ // backward compatibility
// detect if it's an old config file (==1) static int new_config_file; +static int read_bg_color_hover; +static int read_border_color_hover; +static int read_bg_color_press; +static int read_border_color_press; + void default_config() {@@ -205,10 +210,25 @@
/* Background and border */ if (strcmp (key, "rounded") == 0) { // 'rounded' is the first parameter => alloc a new background + if (backgrounds->len > 0) { + Background *bg = &g_array_index(backgrounds, Background, backgrounds->len-1); + if (!read_bg_color_hover) + memcpy(&bg->back_hover, &bg->back, sizeof(Color)); + if (!read_border_color_hover) + memcpy(&bg->border_hover, &bg->border, sizeof(Color)); + if (!read_bg_color_press) + memcpy(&bg->back_pressed, &bg->back, sizeof(Color)); + if (!read_border_color_press) + memcpy(&bg->border_pressed, &bg->border, sizeof(Color)); + } Background bg; init_background(&bg); bg.border.rounded = atoi(value); g_array_append_val(backgrounds, bg); + read_bg_color_hover = 0; + read_border_color_hover = 0; + read_bg_color_press = 0; + read_border_color_press = 0; } else if (strcmp (key, "border_width") == 0) { g_array_index(backgrounds, Background, backgrounds->len-1).border.width = atoi(value);@@ -233,6 +253,7 @@ extract_values(value, &value1, &value2, &value3);
get_color (value1, bg->back_hover.color); if (value2) bg->back_hover.alpha = (atoi (value2) / 100.0); else bg->back_hover.alpha = 0.5; + read_bg_color_hover = 1; } else if (strcmp (key, "border_color_hover") == 0) { Background* bg = &g_array_index(backgrounds, Background, backgrounds->len-1);@@ -240,6 +261,23 @@ extract_values(value, &value1, &value2, &value3);
get_color (value1, bg->border_hover.color); if (value2) bg->border_hover.alpha = (atoi (value2) / 100.0); else bg->border_hover.alpha = 0.5; + read_border_color_hover = 1; + } + else if (strcmp (key, "background_color_pressed") == 0) { + Background* bg = &g_array_index(backgrounds, Background, backgrounds->len-1); + extract_values(value, &value1, &value2, &value3); + get_color (value1, bg->back_pressed.color); + if (value2) bg->back_pressed.alpha = (atoi (value2) / 100.0); + else bg->back_pressed.alpha = 0.5; + read_bg_color_press = 1; + } + else if (strcmp (key, "border_color_pressed") == 0) { + Background* bg = &g_array_index(backgrounds, Background, backgrounds->len-1); + extract_values(value, &value1, &value2, &value3); + get_color (value1, bg->border_pressed.color); + if (value2) bg->border_pressed.alpha = (atoi (value2) / 100.0); + else bg->border_pressed.alpha = 0.5; + read_border_color_press = 1; } /* Panel */@@ -842,6 +880,19 @@ else if (strcmp (key, "mouse_scroll_down") == 0)
get_action (value, &mouse_scroll_down); else if (strcmp (key, "mouse_effects") == 0) panel_config.mouse_effects = atoi(value); + else if (strcmp(key, "mouse_hover_icon_asb") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config.mouse_over_alpha = atoi(value1); + panel_config.mouse_over_saturation = atoi(value2); + panel_config.mouse_over_brightness = atoi(value3); + } + else if (strcmp(key, "mouse_pressed_icon_asb") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config.mouse_pressed_alpha = atoi(value1); + panel_config.mouse_pressed_saturation = atoi(value2); + panel_config.mouse_pressed_brightness = atoi(value3); + } + /* autohide options */ else if (strcmp(key, "autohide") == 0)@@ -984,6 +1035,18 @@ }
else panel_items_order = strdup("T"); } + + if (backgrounds->len > 0) { + Background *bg = &g_array_index(backgrounds, Background, backgrounds->len-1); + if (!read_bg_color_hover) + memcpy(&bg->back_hover, &bg->back, sizeof(Color)); + if (!read_border_color_hover) + memcpy(&bg->border_hover, &bg->border, sizeof(Color)); + if (!read_bg_color_press) + memcpy(&bg->back_pressed, &bg->back, sizeof(Color)); + if (!read_border_color_press) + memcpy(&bg->border_pressed, &bg->border, sizeof(Color)); + } return 1; }
@@ -234,8 +234,8 @@ }
} if (panel_config.mouse_effects) { - launcherIcon->image_hover = adjust_icon(launcherIcon->image, 100, 0, 10); - launcherIcon->image_pressed = adjust_icon(launcherIcon->image, 100, 0, -10); + launcherIcon->image_hover = adjust_icon(launcherIcon->image, panel_config.mouse_over_alpha, panel_config.mouse_over_saturation, panel_config.mouse_over_brightness); + launcherIcon->image_pressed = adjust_icon(launcherIcon->image, panel_config.mouse_pressed_alpha, panel_config.mouse_pressed_saturation, panel_config.mouse_pressed_brightness); } }
@@ -97,6 +97,12 @@ mouse_left = TOGGLE_ICONIFY;
backgrounds = g_array_new(0, 0, sizeof(Background)); memset(&panel_config, 0, sizeof(Panel)); + panel_config.mouse_over_alpha = 100; + panel_config.mouse_over_saturation = 0; + panel_config.mouse_over_brightness = 10; + panel_config.mouse_pressed_alpha = 100; + panel_config.mouse_pressed_saturation = 0; + panel_config.mouse_pressed_brightness = -10; // append full transparency background Background transparent_bg;@@ -227,7 +233,7 @@ event_mask |= LeaveWindowMask|EnterWindowMask;
XChangeWindowAttributes(server.dsp, p->main_win, CWEventMask, &(XSetWindowAttributes){.event_mask=event_mask}); if (!server.gc) { - XGCValues gcv; + XGCValues gcv; server.gc = XCreateGC(server.dsp, p->main_win, 0, &gcv); } //printf("panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height);@@ -444,7 +450,7 @@ Window d2;
int d3; XGetGeometry(server.dsp, server.root_win, &d2, &d3, &d3, &screen_width, &screen_height, &d1, &d1); Monitor monitor = server.monitor[p->monitor]; - long struts [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + long struts [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; if (panel_horizontal) { int height = p->area.height + p->marginy; if (panel_strut_policy == STRUT_MINIMUM || (panel_strut_policy == STRUT_FOLLOW_SIZE && p->is_hidden))@@ -613,7 +619,7 @@ else {
get_root_pixmap(); // copy background (server.root_pmap) in panel.area.pix Window dummy; - int x, y; + int x, y; XTranslateCoordinates(server.dsp, p->main_win, server.root_win, 0, 0, &x, &y, &dummy); if (panel_autohide && p->is_hidden) { x -= xoff;
@@ -92,6 +92,13 @@ // location of the panel (monitor number)
int monitor; int font_shadow; int mouse_effects; + // Mouse effects for icons + int mouse_over_alpha; + int mouse_over_saturation; + int mouse_over_brightness; + int mouse_pressed_alpha; + int mouse_pressed_saturation; + int mouse_pressed_brightness; // -------------------------------------------------- // task and taskbar parameter per panel
@@ -61,6 +61,7 @@ }
else monitor = 0; Task new_tsk; + memset(&new_tsk, 0, sizeof(new_tsk)); new_tsk.area.mouse_over_effect = 1; new_tsk.area.mouse_press_effect = 1; new_tsk.win = win;@@ -271,7 +272,7 @@ #ifdef __x86_64__
DATA32 icon_data[w * h]; int length = w * h; for (i = 0; i < length; ++i) - icon_data[i] = tmp_data[i]; + icon_data[i] = tmp_data[i]; img = imlib_create_image_using_copied_data (w, h, icon_data); #else img = imlib_create_image_using_data (w, h, (DATA32*)tmp_data);@@ -284,7 +285,7 @@ if (hints) {
if (hints->flags & IconPixmapHint && hints->icon_pixmap != 0) { // get width, height and depth for the pixmap Window root; - int icon_x, icon_y; + int icon_x, icon_y; uint border_width, bpp; uint w, h;@@ -323,8 +324,8 @@ adjust_asb(data32, tsk->icon_width, tsk->icon_height, panel->g_task.alpha[k], (float)panel->g_task.saturation[k]/100, (float)panel->g_task.brightness[k]/100);
imlib_image_put_back_data(data32); } if (panel_config.mouse_effects) { - tsk->icon_hover[k] = adjust_icon(tsk->icon[k], 100, 0, 10); - tsk->icon_press[k] = adjust_icon(tsk->icon[k], 100, 0, -10); + tsk->icon_hover[k] = adjust_icon(tsk->icon[k], panel_config.mouse_over_alpha, panel_config.mouse_over_saturation, panel_config.mouse_over_brightness); + tsk->icon_press[k] = adjust_icon(tsk->icon[k], panel_config.mouse_pressed_alpha, panel_config.mouse_pressed_saturation, panel_config.mouse_pressed_brightness); } } imlib_context_set_image(orig_image);
@@ -596,21 +596,4 @@
void init_background(Background *bg) { memset(bg, 0, sizeof(Background)); - bg->back_hover.color[0] = 0.8; - bg->back_hover.color[1] = 0.8; - bg->back_hover.color[2] = 0.8; - bg->back_hover.alpha = 0.3; - bg->border_hover.color[0] = 0.8; - bg->border_hover.color[1] = 0.8; - bg->border_hover.color[2] = 0.8; - bg->border_hover.alpha = 0.5; - - bg->back_pressed.color[0] = 0.6; - bg->back_pressed.color[1] = 0.6; - bg->back_pressed.color[2] = 0.6; - bg->back_pressed.alpha = 0.3; - bg->border_pressed.color[0] = 0.8; - bg->border_pressed.color[1] = 0.8; - bg->border_pressed.color[2] = 0.8; - bg->border_pressed.alpha = 0.5; }