From: Eugene Doudine Date: Tue, 15 Apr 2014 15:39:43 +0000 (+0300) Subject: Fixes a small bug in grid registration: when an object is placed over another object... X-Git-Tag: 2.2.2~11 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a9dbe60805b2e7e8e196c868b7b36328ced77a97;p=oweals%2Fcde.git Fixes a small bug in grid registration: when an object is placed over another object (can be done manually) and then removed from there, the registration of the covered object is removed as well (that is it's cell is considered empty). The patch converts desktop_grid[] from Boolean array into array of counters of objects, which are placed on cells. When object is placed on /removed from the screen the counter gets incremented/decremented. --- diff --git a/cde/programs/dtfile/Desktop.c b/cde/programs/dtfile/Desktop.c index cc6afe5b..96b22241 100644 --- a/cde/programs/dtfile/Desktop.c +++ b/cde/programs/dtfile/Desktop.c @@ -149,7 +149,7 @@ static char DESKTOP_SAVE_NAME[] = ".!dtdesktop"; DesktopData *desktop_data; Widget widget_dragged; DesktopRec *sacredDesktop; -Boolean *desktop_grid; +unsigned char *desktop_grid; unsigned short int desktop_grid_size; @@ -2543,7 +2543,19 @@ RegisterInGrid( { for (j = (row > 0) ? row : 0; j <= rowHeight ; j++) { - desktop_grid[ desktop_grid_index + (i * numRows) + j] = type; + if (type) + { + /* increase count of objects at given cell */ + desktop_grid[ desktop_grid_index + (i * numRows) + j] ++; + } + else + { + /* decrease count of objects at given cell */ + if (desktop_grid[ desktop_grid_index + (i * numRows) + j] > 0) + { + desktop_grid[ desktop_grid_index + (i * numRows) + j] --; + } + } } } } @@ -2777,7 +2789,7 @@ CalculateRootCoordinates ( ws_num = ((ws_num - 1) * numColumns * numRows); while(1) { - if(desktop_grid[ws_num + (column * numRows) + row] == False) + if(desktop_grid[ws_num + (column * numRows) + row] == 0) { if(numGridsR == 1 && numGridsC == 1) { @@ -2798,8 +2810,7 @@ CalculateRootCoordinates ( { for(j = 0; j < numGridsC; j++) { - if(desktop_grid[ws_num + ((column + j) * numRows) + (row + i)] - == True) + if(desktop_grid[ws_num + ((column + j) * numRows) + (row + i)] > 0) { error = True; break; @@ -3627,7 +3638,7 @@ InitializeNewWorkspaces ( for(j = 0; j < numColumns; j++) for(k = 0; k < numRows; k++) desktop_grid[(i * numRows * numColumns) + - (j * numRows) + k] = False; + (j * numRows) + k] = 0; RegisterPanelInGrid( i + 1, DisplayWidth(display,screen),