Commit 61a80b99 authored by o9000's avatar o9000

Add option to shrink panel (fixes issue #333)

parent 8c7f4cc8
......@@ -58,6 +58,7 @@ gboolean battery_found;
void battery_init_fonts();
char *battery_get_tooltip(void *obj);
int battery_compute_desired_size(void *obj);
void battery_dump_geometry(void *obj, int indent);
void default_battery()
......@@ -155,6 +156,7 @@ void init_battery_panel(void *p)
battery->area._draw_foreground = draw_battery;
battery->area.size_mode = LAYOUT_FIXED;
battery->area._resize = resize_battery;
battery->area._compute_desired_size = battery_compute_desired_size;
battery->area._is_under_mouse = full_width_area_is_under_mouse;
battery->area.on_screen = TRUE;
battery->area.resize_needed = 1;
......@@ -287,16 +289,61 @@ int update_battery()
return err;
}
int battery_compute_desired_size(void *obj)
{
Battery *battery = (Battery *)obj;
Panel *panel = (Panel *)battery->area.panel;
int bat_percentage_height, bat_percentage_width, bat_percentage_height_ink;
int bat_time_height, bat_time_width, bat_time_height_ink;
snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage);
if (battery_state.state == BATTERY_FULL) {
strcpy(buf_bat_time, "Full");
} else {
snprintf(buf_bat_time, sizeof(buf_bat_time), "%02d:%02d", battery_state.time.hours, battery_state.time.minutes);
}
get_text_size2(bat1_font_desc,
&bat_percentage_height_ink,
&bat_percentage_height,
&bat_percentage_width,
panel->area.height,
panel->area.width,
buf_bat_percentage,
strlen(buf_bat_percentage),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
get_text_size2(bat2_font_desc,
&bat_time_height_ink,
&bat_time_height,
&bat_time_width,
panel->area.height,
panel->area.width,
buf_bat_time,
strlen(buf_bat_time),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
if (panel_horizontal) {
int new_size = (bat_percentage_width > bat_time_width) ? bat_percentage_width : bat_time_width;
new_size += 2 * battery->area.paddingxlr + left_right_border_width(&battery->area);
return new_size;
} else {
int new_size = bat_percentage_height + bat_time_height + 2 * battery->area.paddingxlr +
top_bottom_border_width(&battery->area);
return new_size;
}
}
gboolean resize_battery(void *obj)
{
Battery *battery = obj;
Panel *panel = battery->area.panel;
Battery *battery = (Battery *)obj;
Panel *panel = (Panel *)battery->area.panel;
int bat_percentage_height, bat_percentage_width, bat_percentage_height_ink;
int bat_time_height, bat_time_width, bat_time_height_ink;
int ret = 0;
schedule_redraw(&battery->area);
snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage);
if (battery_state.state == BATTERY_FULL) {
strcpy(buf_bat_time, "Full");
......@@ -346,6 +393,8 @@ gboolean resize_battery(void *obj)
ret = 1;
}
}
schedule_redraw(&battery->area);
return ret;
}
......
......@@ -55,6 +55,7 @@ static timeout *clock_timeout;
void clock_init_fonts();
char *clock_get_tooltip(void *obj);
int clock_compute_desired_size(void *obj);
void clock_dump_geometry(void *obj, int indent);
void default_clock()
......@@ -184,11 +185,12 @@ void init_clock_panel(void *p)
snprintf(clock->area.name, sizeof(clock->area.name), "Clock");
clock->area._is_under_mouse = full_width_area_is_under_mouse;
clock->area.has_mouse_press_effect = clock->area.has_mouse_over_effect =
panel_config.mouse_effects && (clock_lclick_command || clock_mclick_command || clock_rclick_command ||
clock_uwheel_command || clock_dwheel_command);
panel_config.mouse_effects && (clock_lclick_command || clock_mclick_command || clock_rclick_command ||
clock_uwheel_command || clock_dwheel_command);
clock->area._draw_foreground = draw_clock;
clock->area.size_mode = LAYOUT_FIXED;
clock->area._resize = resize_clock;
clock->area._compute_desired_size = clock_compute_desired_size;
clock->area._dump_geometry = clock_dump_geometry;
// check consistency
if (!time1_format)
......@@ -240,46 +242,85 @@ void clock_default_font_changed()
panel_refresh = TRUE;
}
gboolean resize_clock(void *obj)
void clock_compute_text_geometry(Panel *panel,
int *time_height_ink,
int *time_height,
int *time_width,
int *date_height_ink,
int *date_height,
int *date_width)
{
Clock *clock = obj;
Panel *panel = clock->area.panel;
int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width;
gboolean result = FALSE;
schedule_redraw(&clock->area);
date_height = date_width = 0;
*date_height = *date_width = 0;
strftime(buf_time, sizeof(buf_time), time1_format, clock_gettime_for_tz(time1_timezone));
get_text_size2(time1_font_desc,
&time_height_ink,
&time_height,
&time_width,
panel->area.height,
panel->area.width,
buf_time,
strlen(buf_time),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
time_height_ink,
time_height,
time_width,
panel->area.height,
panel->area.width,
buf_time,
strlen(buf_time),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
if (time2_format) {
strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone));
get_text_size2(time2_font_desc,
&date_height_ink,
&date_height,
&date_width,
panel->area.height,
panel->area.width,
buf_date,
strlen(buf_date),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
date_height_ink,
date_height,
date_width,
panel->area.height,
panel->area.width,
buf_date,
strlen(buf_date),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
}
}
int clock_compute_desired_size(void *obj)
{
Clock *clock = (Clock *)obj;
Panel *panel = (Panel *)clock->area.panel;
int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width;
clock_compute_text_geometry(panel,
&time_height_ink,
&time_height,
&time_width,
&date_height_ink,
&date_height,
&date_width);
if (panel_horizontal) {
int new_size = (time_width > date_width) ? time_width : date_width;
new_size += 2 * clock->area.paddingxlr + left_right_border_width(&clock->area);
return new_size;
} else {
int new_size = time_height + date_height + 2 * clock->area.paddingxlr + top_bottom_border_width(&clock->area);
return new_size;
}
}
gboolean resize_clock(void *obj)
{
Clock *clock = (Clock *)obj;
Panel *panel = (Panel *)clock->area.panel;
gboolean result = FALSE;
schedule_redraw(&clock->area);
int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width;
clock_compute_text_geometry(panel,
&time_height_ink,
&time_height,
&time_width,
&date_height_ink,
&date_height,
&date_width);
int new_size = clock_compute_desired_size(clock);
if (panel_horizontal) {
if (new_size > clock->area.width || new_size < (clock->area.width - 6)) {
// we try to limit the number of resizes
clock->area.width = new_size + 1;
......@@ -291,7 +332,6 @@ gboolean resize_clock(void *obj)
result = TRUE;
}
} else {
int new_size = time_height + date_height + 2 * clock->area.paddingxlr + top_bottom_border_width(&clock->area);
if (new_size != clock->area.height) {
// we try to limit the number of resizes
clock->area.height = new_size;
......@@ -340,21 +380,10 @@ void draw_clock(void *obj, cairo_t *c)
void clock_dump_geometry(void *obj, int indent)
{
Clock *clock = (Clock *)obj;
fprintf(stderr,
"%*sText 1: y = %d, text = %s\n",
indent,
"",
clock->time1_posy,
buf_time);
fprintf(stderr, "%*sText 1: y = %d, text = %s\n", indent, "", clock->time1_posy, buf_time);
if (time2_format) {
fprintf(stderr,
"%*sText 2: y = %d, text = %s\n",
indent,
"",
clock->time2_posy,
buf_date);
fprintf(stderr, "%*sText 2: y = %d, text = %s\n", indent, "", clock->time2_posy, buf_date);
}
}
char *clock_get_tooltip(void *obj)
......
......@@ -431,6 +431,8 @@ void add_entry(char *key, char *value)
panel_config.monitor = config_get_monitor(value);
} else if (strcmp(key, "primary_monitor_first") == 0) {
primary_monitor_first = atoi(value);
} else if (strcmp(key, "panel_shrink") == 0) {
panel_shrink = atoi(value);
} else if (strcmp(key, "panel_size") == 0) {
extract_values(value, &value1, &value2, &value3);
......
......@@ -21,6 +21,7 @@
void execp_timer_callback(void *arg);
char *execp_get_tooltip(void *obj);
void execp_init_fonts();
int execp_compute_desired_size(void *obj);
void execp_dump_geometry(void *obj, int indent);
void default_execp()
......@@ -165,6 +166,7 @@ void init_execp_panel(void *p)
execp->area.parent = panel;
execp->area.panel = panel;
execp->area._dump_geometry = execp_dump_geometry;
execp->area._compute_desired_size = execp_compute_desired_size;
snprintf(execp->area.name,
sizeof(execp->area.name),
"Execp %s",
......@@ -288,15 +290,85 @@ gboolean reload_icon(Execp *execp)
return FALSE;
}
gboolean resize_execp(void *obj)
int execp_compute_desired_size(void *obj)
{
Execp *execp = obj;
Panel *panel = execp->area.panel;
Execp *execp = (Execp *)obj;
Panel *panel = (Panel *)execp->area.panel;
int horiz_padding = (panel_horizontal ? execp->area.paddingxlr : execp->area.paddingy);
int vert_padding = (panel_horizontal ? execp->area.paddingy : execp->area.paddingxlr);
int interior_padding = execp->area.paddingx;
schedule_redraw(&execp->area);
int icon_w, icon_h;
if (reload_icon(execp)) {
if (execp->backend->icon) {
imlib_context_set_image(execp->backend->icon);
icon_w = imlib_image_get_width();
icon_h = imlib_image_get_height();
} else {
icon_w = icon_h = 0;
}
} else {
icon_w = icon_h = 0;
}
int text_next_line = !panel_horizontal && icon_w > execp->area.width / 2;
int txt_height_ink, txt_height, txt_width;
if (panel_horizontal) {
get_text_size2(execp->backend->font_desc,
&txt_height_ink,
&txt_height,
&txt_width,
panel->area.height,
panel->area.width,
execp->backend->text,
strlen(execp->backend->text),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
execp->backend->has_markup);
} else {
get_text_size2(execp->backend->font_desc,
&txt_height_ink,
&txt_height,
&txt_width,
panel->area.height,
!text_next_line
? execp->area.width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding -
left_right_border_width(&execp->area)
: execp->area.width - 2 * horiz_padding - left_right_border_width(&execp->area),
execp->backend->text,
strlen(execp->backend->text),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
execp->backend->has_markup);
}
if (panel_horizontal) {
int new_size = txt_width;
if (icon_w)
new_size += interior_padding + icon_w;
new_size += 2 * horiz_padding + left_right_border_width(&execp->area);
return new_size;
} else {
int new_size;
if (!text_next_line) {
new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&execp->area));
} else {
new_size =
icon_h + interior_padding + txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
}
return new_size;
}
}
gboolean resize_execp(void *obj)
{
Execp *execp = (Execp *)obj;
Panel *panel = (Panel *)execp->area.panel;
int horiz_padding = (panel_horizontal ? execp->area.paddingxlr : execp->area.paddingy);
int vert_padding = (panel_horizontal ? execp->area.paddingy : execp->area.paddingxlr);
int interior_padding = execp->area.paddingx;
int icon_w, icon_h;
if (reload_icon(execp)) {
......@@ -406,6 +478,8 @@ gboolean resize_execp(void *obj)
}
}
schedule_redraw(&execp->area);
return result;
}
......
......@@ -30,6 +30,8 @@
#include "freespace.h"
#include "common.h"
int freespace_area_compute_desired_size(void *obj);
void init_freespace_panel(void *p)
{
Panel *panel = (Panel *)p;
......@@ -51,6 +53,7 @@ void init_freespace_panel(void *p)
freespace->area.resize_needed = 1;
freespace->area.on_screen = TRUE;
freespace->area._resize = resize_freespace;
freespace->area._compute_desired_size = freespace_area_compute_desired_size;
}
}
}
......@@ -64,6 +67,8 @@ void cleanup_freespace(Panel *panel)
int freespace_get_max_size(Panel *p)
{
if (panel_shrink)
return 0;
// Get space used by every element except the freespace
int size = 0;
int spacers = 0;
......@@ -91,6 +96,12 @@ int freespace_get_max_size(Panel *p)
return size / spacers;
}
int freespace_area_compute_desired_size(void *obj)
{
FreeSpace *freespace = (FreeSpace *) obj;
return freespace_get_max_size((Panel *)freespace->area.panel);
}
gboolean resize_freespace(void *obj)
{
FreeSpace *freespace = (FreeSpace *)obj;
......
......@@ -62,6 +62,7 @@ void launcher_reload_icon(Launcher *launcher, LauncherIcon *launcherIcon);
void launcher_reload_icon_image(Launcher *launcher, LauncherIcon *launcherIcon);
void launcher_reload_hidden_icons(Launcher *launcher);
void launcher_icon_on_change_layout(void *obj);
int launcher_compute_desired_size(void *obj);
void default_launcher()
{
......@@ -94,6 +95,7 @@ void init_launcher_panel(void *p)
launcher->area._draw_foreground = NULL;
launcher->area.size_mode = LAYOUT_FIXED;
launcher->area._resize = resize_launcher;
launcher->area._compute_desired_size = launcher_compute_desired_size;
launcher->area.resize_needed = 1;
schedule_redraw(&launcher->area);
if (!launcher->area.bg)
......@@ -161,21 +163,76 @@ void cleanup_launcher_theme(Launcher *launcher)
launcher->icon_theme_wrapper = NULL;
}
gboolean resize_launcher(void *obj)
int launcher_compute_icon_size(Launcher *launcher)
{
Launcher *launcher = obj;
int icons_per_column = 1, icons_per_row = 1, margin = 0;
int icon_size;
if (panel_horizontal) {
icon_size = launcher->area.height;
} else {
icon_size = launcher->area.width;
}
int icon_size = panel_horizontal ? launcher->area.height : launcher->area.width;
icon_size = icon_size - MAX(left_right_border_width(&launcher->area), top_bottom_border_width(&launcher->area)) -
(2 * launcher->area.paddingy);
if (launcher_max_icon_size > 0 && icon_size > launcher_max_icon_size)
icon_size = launcher_max_icon_size;
return icon_size;
}
void launcher_compute_geometry(Launcher *launcher,
int *size,
int *icon_size,
int *icons_per_column,
int *icons_per_row,
int *margin)
{
int count = 0;
for (GSList *l = launcher->list_icons; l; l = l->next) {
LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
if (launcherIcon->area.on_screen)
count++;
}
*icon_size = launcher_compute_icon_size(launcher);
*icons_per_column = 1;
*icons_per_row = 1;
*margin = 0;
if (panel_horizontal) {
if (!count) {
*size = 0;
} else {
int height = launcher->area.height - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy;
// here icons_per_column always higher than 0
*icons_per_column = (height + launcher->area.paddingx) / (*icon_size + launcher->area.paddingx);
*margin = height - (*icons_per_column - 1) * (*icon_size + launcher->area.paddingx) - *icon_size;
*icons_per_row = count / *icons_per_column + (count % *icons_per_column != 0);
*size = left_right_border_width(&launcher->area) + 2 * launcher->area.paddingxlr +
(*icon_size * *icons_per_row) + ((*icons_per_row - 1) * launcher->area.paddingx);
}
} else {
if (!count) {
*size = 0;
} else {
int width = launcher->area.width - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy;
// here icons_per_row always higher than 0
*icons_per_row = (width + launcher->area.paddingx) / (*icon_size + launcher->area.paddingx);
*margin = width - (*icons_per_row - 1) * (*icon_size + launcher->area.paddingx) - *icon_size;
*icons_per_column = count / *icons_per_row + (count % *icons_per_row != 0);
*size = top_bottom_border_width(&launcher->area) + 2 * launcher->area.paddingxlr +
(*icon_size * *icons_per_column) + ((*icons_per_column - 1) * launcher->area.paddingx);
}
}
}
int launcher_compute_desired_size(void *obj)
{
Launcher *launcher = (Launcher *)obj;
int size, icon_size, icons_per_column, icons_per_row, margin;
launcher_compute_geometry(launcher, &size, &icon_size, &icons_per_column, &icons_per_row, &margin);
return size;
}
gboolean resize_launcher(void *obj)
{
Launcher *launcher = (Launcher *)obj;
int size, icon_size, icons_per_column, icons_per_row, margin;
launcher_compute_geometry(launcher, &size, &icon_size, &icons_per_column, &icons_per_row, &margin);
// Resize icons if necessary
for (GSList *l = launcher->list_icons; l; l = l->next) {
......@@ -197,29 +254,13 @@ gboolean resize_launcher(void *obj)
}
if (panel_horizontal) {
if (!count) {
launcher->area.width = 0;
} else {
int height = launcher->area.height - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy;
// here icons_per_column always higher than 0
icons_per_column = (height + launcher->area.paddingx) / (icon_size + launcher->area.paddingx);
margin = height - (icons_per_column - 1) * (icon_size + launcher->area.paddingx) - icon_size;
icons_per_row = count / icons_per_column + (count % icons_per_column != 0);
launcher->area.width = left_right_border_width(&launcher->area) + 2 * launcher->area.paddingxlr +
(icon_size * icons_per_row) + ((icons_per_row - 1) * launcher->area.paddingx);
}
if (launcher->area.width == size)
return FALSE;
launcher->area.width = size;
} else {
if (!count) {
launcher->area.height = 0;
} else {
int width = launcher->area.width - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy;
// here icons_per_row always higher than 0
icons_per_row = (width + launcher->area.paddingx) / (icon_size + launcher->area.paddingx);
margin = width - (icons_per_row - 1) * (icon_size + launcher->area.paddingx) - icon_size;
icons_per_column = count / icons_per_row + (count % icons_per_row != 0);
launcher->area.height = top_bottom_border_width(&launcher->area) + 2 * launcher->area.paddingxlr +
(icon_size * icons_per_column) + ((icons_per_column - 1) * launcher->area.paddingx);
}
if (launcher->area.height == size)
return FALSE;
launcher->area.height = size;
}
int posx, posy;
......@@ -283,6 +324,12 @@ void launcher_icon_on_change_layout(void *obj)
launcherIcon->area.height = launcherIcon->icon_size;
}
int launcher_icon_compute_desired_size(void *obj)
{
LauncherIcon *icon = (LauncherIcon *)obj;
return icon->icon_size;
}
char *launcher_icon_get_tooltip_text(void *obj)
{
LauncherIcon *launcherIcon = (LauncherIcon *)obj;
......@@ -312,12 +359,7 @@ void draw_launcher_icon(void *obj, cairo_t *c)
void launcher_icon_dump_geometry(void *obj, int indent)
{
LauncherIcon *launcherIcon = (LauncherIcon *)obj;
fprintf(stderr,
"%*sIcon: w = h = %d, name = %s\n",
indent,
"",
launcherIcon->icon_size,
launcherIcon->icon_name);
fprintf(stderr, "%*sIcon: w = h = %d, name = %s\n", indent, "", launcherIcon->icon_size, launcherIcon->icon_name);
}
Imlib_Image scale_icon(Imlib_Image original, int icon_size)
......@@ -419,6 +461,8 @@ void launcher_action(LauncherIcon *icon, XEvent *evt)
free(cmd);
}
// Populates the list_icons list from the list_apps list
void launcher_load_icons(Launcher *launcher)
{
......@@ -432,6 +476,7 @@ void launcher_load_icons(Launcher *launcher)
launcherIcon->area._draw_foreground = draw_launcher_icon;
launcherIcon->area.size_mode = LAYOUT_FIXED;
launcherIcon->area._resize = NULL;
launcherIcon->area._compute_desired_size = launcher_icon_compute_desired_size;
sprintf(launcherIcon->area.name, "LauncherIcon %d", index);
launcherIcon->area.resize_needed = 0;
launcherIcon->area.has_mouse_over_effect = panel_config.mouse_effects;
......@@ -523,13 +568,13 @@ void launcher_reload_icon_image(Launcher *launcher, LauncherIcon *launcherIcon)
if (panel_config.mouse_effects) {
launcherIcon->image_hover = adjust_icon(launcherIcon->image,
panel_config.mouse_over_alpha,
panel_config.mouse_over_saturation,
panel_config.mouse_over_brightness);
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);
panel_config.mouse_pressed_alpha,
panel_config.mouse_pressed_saturation,
panel_config.mouse_pressed_brightness);
}
}
......
......@@ -62,6 +62,7 @@ gboolean panel_autohide;
int panel_autohide_show_timeout;
int panel_autohide_hide_timeout;
int panel_autohide_height;
gboolean panel_shrink;
Strut panel_strut_policy;
char *panel_items_order;
......@@ -92,6 +93,7 @@ void default_panel()
panel_autohide_show_timeout = 0;
panel_autohide_hide_timeout = 0;
panel_autohide_height = 5; // for vertical panels this is of course the width
panel_shrink = FALSE;
panel_strut_policy = STRUT_FOLLOW_SIZE;
panel_dock = FALSE; // default not in the dock
panel_layer = BOTTOM_LAYER; // default is bottom layer
......@@ -298,9 +300,8 @@ void init_panel()
update_all_taskbars_visibility();
}
void init_panel_size_and_position(Panel *panel)
void panel_compute_size(Panel *panel)
{
// detect panel size
if (panel_horizontal) {
if (panel->area.width == 0) {
panel->fractional_width = TRUE;
......@@ -353,17 +354,22 @@ void init_panel_size_and_position(Panel *panel)
if (panel->area.height + panel->marginy > server.monitors[panel->monitor].height)
panel->area.height = server.monitors[panel->monitor].height - panel->marginy;
panel->max_size = panel_horizontal ? panel->area.width : panel->area.height;
}
void panel_compute_position(Panel *panel)
{
// panel position determined here
if (panel_position & LEFT) {
panel->posx = server.monitors[panel->monitor].x + panel->marginx;
} else {
if (panel_position & RIGHT) {
panel->posx = server.monitors[panel->monitor].x + server.monitors[panel->monitor].width -
panel->area.width - panel->marginx;
panel->area.width - panel->marginx;
} else {
if (panel_horizontal)
panel->posx = server.monitors[panel->monitor].x +
((server.monitors[panel->monitor].width - panel->area.width) / 2);
((server.monitors[panel->monitor].width - panel->area.width) / 2);
else
panel->posx = server.monitors[panel->monitor].x + panel->marginx;
}
......@@ -373,10 +379,10 @@ void init_panel_size_and_position(Panel *panel)
} else {
if (panel_position & BOTTOM) {
panel->posy = server.monitors[panel->monitor].y + server.monitors[panel->monitor].height -
panel->area.height - panel->marginy;
panel->area.height - panel->marginy;
} else {
panel->posy =
server.monitors[panel->monitor].y + ((server.monitors[panel->monitor].height - panel->area.height) / 2);
server.monitors[panel->monitor].y + ((server.monitors[panel->monitor].height - panel->area.height) / 2);
}
}
......@@ -393,6 +399,12 @@ void init_panel_size_and_position(Panel *panel)
// panel->area.height);
}
void init_panel_size_and_position(Panel *panel)
{
panel_compute_size(panel);
panel_compute_position(panel);
}
gboolean resize_panel(void *obj)
{
Panel *panel = (Panel *)obj;
......@@ -660,6 +672,58 @@ void replace_panel_all_desktops(Panel *p)
XSync(server.display, False);
}
void set_panel_window_geometry(Panel *panel)
{
update_strut(panel);
// Fixed position and non-resizable window
// Allow panel move and resize when tint2 reload config file
int minwidth = panel_autohide ? panel->hidden_width : panel->area.width;
int minheight = panel_autohide ? panel->hidden_height : panel->area.height;
XSizeHints size_hints;
size_hints.flags = PPosition | PMinSize | PMaxSize;
size_hints.min_width = minwidth;
size_hints.max_width = panel->area.width;
size_hints.min_height = minheight;
size_hints.max_height = panel->area.height;
XSetWMNormalHints(server.display, panel->main_win, &size_hints);
if (!panel->is_hidden) {