From 80a1b3b57db9d9330967db29af88ee7a7687e819 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Fri, 17 May 2002 11:52:29 +0000 Subject: [PATCH] r1485: Options to set iconification layout policy. --- ROX-Filer/Help/Changes | 4 +++ ROX-Filer/Options.xml | 17 ++++++++--- ROX-Filer/src/pinboard.c | 79 ++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 84 insertions(+), 16 deletions(-) diff --git a/ROX-Filer/Help/Changes b/ROX-Filer/Help/Changes index 4884dc99..3ce989c6 100644 --- a/ROX-Filer/Help/Changes +++ b/ROX-Filer/Help/Changes @@ -2,6 +2,10 @@ A RISC OS-like filer for X by Thomas Leonard +17-May-2002 +~~~~~~~~~~~ +Options to set iconification layout policy. + 16-May-2002 ~~~~~~~~~~~ Pinboard background colour option works again. diff --git a/ROX-Filer/Options.xml b/ROX-Filer/Options.xml index 55382ac1..aa63b6d9 100644 --- a/ROX-Filer/Options.xml +++ b/ROX-Filer/Options.xml @@ -101,10 +101,7 @@ If on, ignores case and punctuation and handles numbers properly: file8, File9,
- + @@ -125,6 +122,18 @@ See the manual for information about using the pinboard. Most window managers provide a way to iconify (or 'minimise') windows, and various programs, including ROX-Filer, can be used to display the iconified windows. If this option is on, the filer will show each iconified window as a small button on the screen. Requires a compatible window manager. + + + + + + + + + + + +
diff --git a/ROX-Filer/src/pinboard.c b/ROX-Filer/src/pinboard.c index 857bfc3b..e3e8ed30 100644 --- a/ROX-Filer/src/pinboard.c +++ b/ROX-Filer/src/pinboard.c @@ -104,6 +104,15 @@ struct _PinIcon { #define GRID_STEP_MED 16 #define GRID_STEP_COARSE 32 +/* Used in options */ +#define CORNER_TOP_LEFT 0 +#define CORNER_TOP_RIGHT 1 +#define CORNER_BOTTOM_LEFT 2 +#define CORNER_BOTTOM_RIGHT 3 + +#define DIR_HORZ 0 +#define DIR_VERT 1 + static PinIcon *current_wink_icon = NULL; static gint wink_timeout; @@ -128,6 +137,7 @@ typedef enum { static Option o_pinboard_clamp_icons, o_pinboard_grid_step; static Option o_pinboard_fg_colour, o_pinboard_bg_colour; static Option o_pinboard_tasklist, o_forward_button_3; +static Option o_iconify_start, o_iconify_dir; /* Static prototypes */ static GType pin_icon_get_type(void); @@ -220,6 +230,9 @@ void pinboard_init(void) option_add_int(&o_pinboard_tasklist, "pinboard_tasklist", TRUE); option_add_int(&o_forward_button_3, "pinboard_forward_button_3", FALSE); + option_add_int(&o_iconify_start, "iconify_start", CORNER_TOP_RIGHT); + option_add_int(&o_iconify_dir, "iconify_dir", DIR_VERT); + option_add_notify(pinboard_check_options); gdk_color_parse(o_pinboard_fg_colour.value, &pin_text_fg_col); @@ -1968,6 +1981,31 @@ static void set_backdrop(const gchar *path, BackdropStyle style) pinboard_save(); } +#define SEARCH_STEP 32 + +static void search_free(GdkRectangle *rect, GdkRegion *used, + int *outer, int od, int omax, + int *inner, int id, int imax) +{ + *outer = od > 0 ? 0 : omax; + while (*outer >= 0 && *outer <= omax) + { + *inner = id > 0 ? 0 : imax; + while (*inner >= 0 && *inner <= imax) + { + if (gdk_region_rect_in(used, rect) == + GDK_OVERLAP_RECTANGLE_OUT) + return; + *inner += id; + } + + *outer += od; + } + + rect->x = -1; + rect->y = -1; +} + /* Finds a free area on the pinboard large enough for the width and height * of the given rectangle, by filling in the x and y fields of 'rect'. * The search order respects user preferences. @@ -1977,6 +2015,8 @@ static void find_free_rect(Pinboard *pinboard, GdkRectangle *rect) { GdkRegion *used; GList *next; + GdkRectangle used_rect; + int dx = SEARCH_STEP, dy = SEARCH_STEP; used = gdk_region_new(); @@ -1988,7 +2028,6 @@ static void find_free_rect(Pinboard *pinboard, GdkRectangle *rect) for (; next; next = next->next) { GtkFixedChild *fix = (GtkFixedChild *) next->data; - GdkRectangle used_rect; if (!GTK_WIDGET_VISIBLE(fix->widget)) continue; @@ -2005,18 +2044,34 @@ static void find_free_rect(Pinboard *pinboard, GdkRectangle *rect) * it works). If you know a better (fast!) algorithm, let me know! */ - for (rect->y = 0; rect->y < screen_height; rect->y += 32) + + if (o_iconify_start.int_value == CORNER_TOP_RIGHT || + o_iconify_start.int_value == CORNER_BOTTOM_RIGHT) + dx = -SEARCH_STEP; + + if (o_iconify_start.int_value == CORNER_BOTTOM_LEFT || + o_iconify_start.int_value == CORNER_BOTTOM_RIGHT) + dy = -SEARCH_STEP; + + if (o_iconify_dir.int_value == DIR_VERT) { - for (rect->x = 0; rect->x < screen_width; rect->x += 32) - { - if (gdk_region_rect_in(used, rect) == - GDK_OVERLAP_RECTANGLE_OUT) - goto out; - } + search_free(rect, used, + &rect->x, dx, screen_width - rect->width, + &rect->y, dy, screen_height - rect->height); } - - rect->x = 0; - rect->y = 0; -out: + else + { + search_free(rect, used, + &rect->y, dy, screen_height - rect->height, + &rect->x, dx, screen_width - rect->width); + } + gdk_region_destroy(used); + + if (rect->x == -1) + { + rect->x = 0; + rect->y = 0; + } } + -- 2.11.4.GIT