From b06fb162dfa2e4571cef0ef390fc883fcb19f0a0 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 17 May 1999 01:31:16 +0000 Subject: [PATCH] Bug fixes related to global icons in Clip. --- src/dock.c | 62 +++++++++++++++++++++++++++++++++++++++++-------- src/dockedapp.c | 3 ++- src/screen.h | 1 + 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/src/dock.c b/src/dock.c index 0e3814a3..52ae14c3 100644 --- a/src/dock.c +++ b/src/dock.c @@ -2535,6 +2535,7 @@ wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos) { WScreen *scr = dock->screen_ptr; WAppIcon *btn; + WAppIconChain *chain; unsigned char *slot_map; int mwidth; int r; @@ -2542,10 +2543,14 @@ wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos) int i, done = False; int corner; int sx=0, sy=0, ex=scr->scr_width, ey=scr->scr_height; + int extra_count=0; + if (dock->type == WM_CLIP && + dock != scr->workspaces[scr->current_workspace]->clip) + extra_count = scr->global_icon_count; /* if the dock is full */ - if (dock->icon_count >= dock->max_icons) { + if (dock->icon_count+extra_count >= dock->max_icons) { return False; } @@ -2606,7 +2611,15 @@ wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos) vmap[btn->yindex] = 1; else if (btn->yindex==0 && btn->xindex>0 && btn->xindexxindex] = 1; - } + } + for (chain=scr->global_icons; chain!=NULL; chain=chain->next) { + btn = chain->aicon; + if (btn->xindex==0 && btn->yindex > 0 && btn->yindex < vcount) + vmap[btn->yindex] = 1; + else if (btn->yindex==0 && btn->xindex>0 && btn->xindexxindex] = 1; + } + break; case C_NW: for (i=0; imax_icons; i++) { btn = dock->icon_array[i]; @@ -2617,7 +2630,15 @@ wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos) vmap[btn->yindex] = 1; else if (btn->yindex==0 && btn->xindex<0 &&btn->xindex>-hcount) hmap[-btn->xindex] = 1; - } + } + for (chain=scr->global_icons; chain!=NULL; chain=chain->next) { + btn = chain->aicon; + if (btn->xindex==0 && btn->yindex > 0 && btn->yindex < vcount) + vmap[btn->yindex] = 1; + else if (btn->yindex==0 && btn->xindex<0 &&btn->xindex>-hcount) + hmap[-btn->xindex] = 1; + } + break; case C_SE: for (i=0; imax_icons; i++) { btn = dock->icon_array[i]; @@ -2628,7 +2649,15 @@ wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos) vmap[-btn->yindex] = 1; else if (btn->yindex==0 && btn->xindex>0 && btn->xindexxindex] = 1; - } + } + for (chain=scr->global_icons; chain!=NULL; chain=chain->next) { + btn = chain->aicon; + if (btn->xindex==0 && btn->yindex < 0 && btn->yindex > -vcount) + vmap[-btn->yindex] = 1; + else if (btn->yindex==0 && btn->xindex>0 && btn->xindexxindex] = 1; + } + break; case C_SW: default: for (i=0; imax_icons; i++) { @@ -2641,6 +2670,13 @@ wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos) else if (btn->yindex==0 && btn->xindex<0 &&btn->xindex>-hcount) hmap[-btn->xindex] = 1; } + for (chain=scr->global_icons; chain!=NULL; chain=chain->next) { + btn = chain->aicon; + if (btn->xindex==0 && btn->yindex < 0 && btn->yindex > -vcount) + vmap[-btn->yindex] = 1; + else if (btn->yindex==0 && btn->xindex<0 &&btn->xindex>-hcount) + hmap[-btn->xindex] = 1; + } } x=0; y=0; done = 0; @@ -2703,6 +2739,9 @@ wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos) if (btn) slot_map[XY2OFS(btn->xindex, btn->yindex)] = 1; } + for (chain=scr->global_icons; chain!=NULL; chain=chain->next) { + slot_map[XY2OFS(chain->aicon->xindex, chain->aicon->yindex)] = 1; + } /* Find closest slot from the center that is free by scanning the * map from the center to outward in circular passes. * This will not result in a neat layout, but will be optimal @@ -4191,7 +4230,6 @@ iconCanBeOmnipresent(WAppIcon *aicon) WDock *clip; WAppIcon *btn; int i, j; - Bool ocupied = False; for (i=0; iworkspace_count; i++) { clip = scr->workspaces[i]->clip; @@ -4199,16 +4237,17 @@ iconCanBeOmnipresent(WAppIcon *aicon) if (clip == aicon->dock) continue; + if (clip->icon_count + scr->global_icon_count >= clip->max_icons) + return False; /* Clip is full in some workspace */ + for (j=0; jmax_icons; j++) { btn = clip->icon_array[j]; - if(btn && btn->xindex==aicon->xindex && btn->yindex==aicon->yindex) { - ocupied = True; - break; - } + if(btn && btn->xindex==aicon->xindex && btn->yindex==aicon->yindex) + return False; } } - return !ocupied; + return True; } @@ -4240,6 +4279,7 @@ wClipMakeIconOmnipresent(WAppIcon *aicon, int omnipresent) tmp->next = new_entry; } + scr->global_icon_count++; } else { aicon->omnipresent = 0; status = WO_FAILED; @@ -4250,6 +4290,7 @@ wClipMakeIconOmnipresent(WAppIcon *aicon, int omnipresent) tmp = scr->global_icons->next; free(scr->global_icons); scr->global_icons = tmp; + scr->global_icon_count--; } else { tmp = scr->global_icons; while (tmp->next) { @@ -4257,6 +4298,7 @@ wClipMakeIconOmnipresent(WAppIcon *aicon, int omnipresent) tmp1 = tmp->next->next; free(tmp->next); tmp->next = tmp1; + scr->global_icon_count--; break; } tmp = tmp->next; diff --git a/src/dockedapp.c b/src/dockedapp.c index 57f047dd..a64b7946 100644 --- a/src/dockedapp.c +++ b/src/dockedapp.c @@ -252,7 +252,8 @@ panelBtnCallback(WMWidget *self, void *data) _("Sorry, icon cannot be made omnipresent. " "Please make sure that no other icon is " "docked in the same position on the other " - "workspaces, and try again."), + "workspaces, and the Clip is not full in " + "some workspace, then try again."), _("OK"), NULL, NULL); return; } diff --git a/src/screen.h b/src/screen.h index e3a83e5b..b1a3c119 100644 --- a/src/screen.h +++ b/src/screen.h @@ -236,6 +236,7 @@ typedef struct _WScreen { struct WMenu *clip_ws_menu; /* workspace menu for clip */ struct WDock *last_dock; WAppIconChain *global_icons; /* for omnipresent icons chain in clip */ + int global_icon_count; /* How many global icons do we have */ Window clip_balloon; /* window for workspace name */