1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-31 11:02:35 +01:00

- Fixed crashing bug when name and class were empty for a docked app.

- Removed MIN() and MAX() macros and replaced them with WMIN() and WMAX() from
  WINGs.
- Added a hint that Window Maker crashed, to allow windows to be placed
  in their correct previous positions after a crash situation and also to
  preserve their state before the crash (minimized, shaded, hidden, ...)
This commit is contained in:
dan
2001-04-18 00:25:58 +00:00
parent 10e7985961
commit c3d2a890d7
14 changed files with 124 additions and 88 deletions

View File

@@ -265,6 +265,11 @@ typedef enum {
}
/* Flags for the Window Maker state when restarting/crash situations */
#define WFLAGS_NONE (0)
#define WFLAGS_CRASHED (1<<0)
/* notifications */
#ifdef MAINFILE

View File

@@ -84,8 +84,7 @@ typedef struct _WBalloon {
#ifdef SHAPED_BALLOON
#define SPACE 12
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
static void
drawBalloon(Pixmap pix, GC gc, int x, int y, int w, int h, int side)

View File

@@ -2558,8 +2558,6 @@ wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y,
return False;
}
#define MIN(x, y) ((x) > (y) ? (y) : (x))
#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define ON_SCREEN(x, y, sx, ex, sy, ey) \
((((x)+ICON_SIZE/2) >= (sx)) && (((y)+ICON_SIZE/2) >= (sy)) && \
@@ -2633,8 +2631,8 @@ wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos)
char *hmap, *vmap;
int hcount, vcount;
hcount = MIN(dock->max_icons, scr->scr_width/ICON_SIZE);
vcount = MIN(dock->max_icons, scr->scr_height/ICON_SIZE);
hcount = WMIN(dock->max_icons, scr->scr_width/ICON_SIZE);
vcount = WMIN(dock->max_icons, scr->scr_height/ICON_SIZE);
hmap = wmalloc(hcount+1);
memset(hmap, 0, hcount+1);
vmap = wmalloc(vcount+1);
@@ -2722,7 +2720,7 @@ wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos)
x=0; y=0;
done = 0;
/* search a vacant slot */
for (i=1; i<MAX(vcount, hcount); i++) {
for (i=1; i<WMAX(vcount, hcount); i++) {
if (i < vcount && vmap[i]==0) {
/* found a slot */
x = 0;
@@ -2771,7 +2769,7 @@ wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos)
slot_map = wmalloc(mwidth*mwidth);
memset(slot_map, 0, mwidth*mwidth);
#define XY2OFS(x,y) (MAX(abs(x),abs(y)) > r) ? 0 : (((y)+r)*(mwidth)+(x)+r)
#define XY2OFS(x,y) (WMAX(abs(x),abs(y)) > r) ? 0 : (((y)+r)*(mwidth)+(x)+r)
/* mark used slots in the map. If the slot falls outside the map
* (for example, when all icons are placed in line), ignore them. */

View File

@@ -1100,7 +1100,7 @@ EscapeWM_CLASS(char *name, char *class)
if (name) {
l = strlen(name);
ename = wmalloc(l*2);
ename = wmalloc(l*2+1);
j = 0;
for (i=0; i<l; i++) {
if (name[i]=='\\') {
@@ -1114,7 +1114,7 @@ EscapeWM_CLASS(char *name, char *class)
}
if (class) {
l = strlen(class);
eclass = wmalloc(l*2);
eclass = wmalloc(l*2+1);
j = 0;
for (i=0; i<l; i++) {
if (class[i]=='\\') {

View File

@@ -144,9 +144,6 @@ static Shortcut *shortcutList = NULL;
*
*/
#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define M_QUICK 1
/* menu commands */
@@ -1610,7 +1607,7 @@ configureMenu(WScreen *scr, proplist_t definition)
menu = readMenuFile(scr, path);
if (menu)
menu->timestamp = MAX(stat_buf.st_mtime, WDRootMenu->timestamp);
menu->timestamp = WMAX(stat_buf.st_mtime, WDRootMenu->timestamp);
} else {
menu = NULL;
}

View File

@@ -1064,7 +1064,6 @@ wScreenRestoreState(WScreen *scr)
void
wScreenSaveState(WScreen *scr)
{
WWorkspaceState wstate;
WWindow *wwin;
char *str;
proplist_t path, old_state, foo;
@@ -1073,13 +1072,9 @@ wScreenSaveState(WScreen *scr)
make_keys();
/*
* Save current workspace, so can go back to it upon restart.
*/
wstate.workspace = scr->current_workspace;
data[0] = wstate.flags;
data[1] = wstate.workspace;
/* Save current workspace, so can go back to it upon restart. */
data[0] = scr->current_workspace;
data[1] = WFLAGS_NONE;
XChangeProperty(dpy, scr->root_win, _XA_WINDOWMAKER_STATE,
_XA_WINDOWMAKER_STATE, 32, PropModeReplace,

View File

@@ -159,7 +159,7 @@ static unsigned int _ScrollLockMask = 0;
static void manageAllWindows();
static void manageAllWindows(WScreen *scr, int crashed);
extern void NotifyDeadProcess(pid_t pid, unsigned char status);
@@ -353,8 +353,35 @@ handleSig(int sig)
XCloseDisplay(dpy);
dpy = XOpenDisplay("");
if (dpy) {
CARD32 data[2];
WWindow *wwin;
int i;
XGrabServer(dpy);
crashAction = wShowCrashingDialogPanel(sig);
/*
* Save current workspace, so can go back to it if restarting.
* Also add hint that we crashed, so that windows will be placed
* correctly upon restart.
*/
for (i=0; i<wScreenCount; i++) {
data[0] = wScreen[i]->current_workspace; /* workspace number */
data[1] = WFLAGS_CRASHED; /* signal that we crashed */
XChangeProperty(dpy, wScreen[i]->root_win,
_XA_WINDOWMAKER_STATE, _XA_WINDOWMAKER_STATE,
32, PropModeReplace, (unsigned char*) data, 2);
/* save state of windows */
wwin = wScreen[i]->focused_window;
while (wwin) {
wWindowSaveState(wwin);
wwin = wwin->prev;
}
}
XCloseDisplay(dpy);
dpy = NULL;
} else {
@@ -428,7 +455,7 @@ buryChild(int foo)
static int
getWorkspaceState(Window root, WWorkspaceState **state)
getWorkspaceState(Window root, WWorkspaceState **state)
{
Atom type_ret;
int fmt_ret;
@@ -440,19 +467,18 @@ getWorkspaceState(Window root, WWorkspaceState **state)
True, _XA_WINDOWMAKER_STATE,
&type_ret, &fmt_ret, &nitems_ret, &bytes_after_ret,
(unsigned char **)&data)!=Success || !data)
return 0;
return 0;
*state = wmalloc(sizeof(WWorkspaceState));
(*state)->workspace = data[0];
(*state)->flags = data[1];
*state = malloc(sizeof(WWorkspaceState));
if (*state) {
(*state)->flags = data[0];
(*state)->workspace = data[1];
}
XFree(data);
if (*state && type_ret==_XA_WINDOWMAKER_STATE)
return 1;
return 1;
else
return 0;
return 0;
}
@@ -674,16 +700,18 @@ static char *atomNames[] = {
"WM_CLIENT_LEADER",
"WM_COLORMAP_WINDOWS",
"WM_COLORMAP_NOTIFY",
GNUSTEP_WM_ATTR_NAME,
"_WINDOWMAKER_MENU",
"_WINDOWMAKER_MENU",
"_WINDOWMAKER_STATE",
"_WINDOWMAKER_WM_PROTOCOLS",
GNUSTEP_WM_MINIATURIZE_WINDOW,
"_WINDOWMAKER_WM_FUNCTION",
"_WINDOWMAKER_NOTICEBOARD",
"_WINDOWMAKER_COMMAND",
"_WINDOWMAKER_ICON_SIZE",
"_WINDOWMAKER_ICON_TILE",
GNUSTEP_WM_ATTR_NAME,
GNUSTEP_WM_MINIATURIZE_WINDOW,
GNUSTEP_TITLEBAR_STATE
};
@@ -749,24 +777,17 @@ StartUp(Bool defaultScreenOnly)
_XA_WM_COLORMAP_WINDOWS = atom[7];
_XA_WM_COLORMAP_NOTIFY = atom[8];
_XA_GNUSTEP_WM_ATTR = atom[9];
_XA_WINDOWMAKER_MENU = atom[10];
_XA_WINDOWMAKER_STATE = atom[11];
_XA_WINDOWMAKER_WM_PROTOCOLS = atom[12];
_XA_GNUSTEP_WM_MINIATURIZE_WINDOW = atom[13];
_XA_WINDOWMAKER_WM_FUNCTION = atom[14];
_XA_WINDOWMAKER_NOTICEBOARD = atom[15];
_XA_WINDOWMAKER_COMMAND = atom[16];
_XA_WINDOWMAKER_ICON_SIZE = atom[17];
_XA_WINDOWMAKER_ICON_TILE = atom[18];
_XA_WINDOWMAKER_MENU = atom[9];
_XA_WINDOWMAKER_STATE = atom[10];
_XA_WINDOWMAKER_WM_PROTOCOLS = atom[11];
_XA_WINDOWMAKER_WM_FUNCTION = atom[12];
_XA_WINDOWMAKER_NOTICEBOARD = atom[13];
_XA_WINDOWMAKER_COMMAND = atom[14];
_XA_WINDOWMAKER_ICON_SIZE = atom[15];
_XA_WINDOWMAKER_ICON_TILE = atom[16];
_XA_GNUSTEP_WM_ATTR = atom[17];
_XA_GNUSTEP_WM_MINIATURIZE_WINDOW = atom[18];
_XA_GNUSTEP_TITLEBAR_STATE = atom[19];
#ifdef OFFIX_DND
@@ -927,7 +948,9 @@ StartUp(Bool defaultScreenOnly)
/* initialize/restore state for the screens */
for (j = 0; j < wScreenCount; j++) {
/* restore workspace state */
int crashed;
/* restore workspace state */
if (!getWorkspaceState(wScreen[j]->root_win, &ws_state)) {
ws_state = NULL;
}
@@ -937,9 +960,14 @@ StartUp(Bool defaultScreenOnly)
/* manage all windows that were already here before us */
if (!wPreferences.flags.nodock && wScreen[j]->dock)
wScreen[j]->last_dock = wScreen[j]->dock;
manageAllWindows(wScreen[j]);
if (ws_state && (ws_state->flags & WFLAGS_CRASHED)!=0)
crashed = 1;
else
crashed = 0;
manageAllWindows(wScreen[j], crashed);
/* restore saved menus */
wMenuRestoreState(wScreen[j]);
@@ -1014,7 +1042,7 @@ windowInList(Window window, Window *list, int count)
*-----------------------------------------------------------------------
*/
static void
manageAllWindows(WScreen *scr)
manageAllWindows(WScreen *scr, int crashRecovery)
{
Window root, parent;
Window *children;
@@ -1077,7 +1105,16 @@ manageAllWindows(WScreen *scr)
wIconifyWindow(wwin);
} else {
wClientSetState(wwin, NormalState, None);
}
}
if (crashRecovery) {
int border;
border = (WFLAGP(wwin, no_border) ? 0 : FRAME_BORDER_WIDTH);
wWindowMove(wwin, wwin->frame_x - border,
wwin->frame_y - border -
wwin->frame->titlebar->height);
}
}
}
XUngrabServer(dpy);

View File

@@ -2394,28 +2394,27 @@ getSavedState(Window window, WSavedState **state)
True, _XA_WINDOWMAKER_STATE,
&type_ret, &fmt_ret, &nitems_ret, &bytes_after_ret,
(unsigned char **)&data)!=Success || !data)
return 0;
*state = malloc(sizeof(WSavedState));
return 0;
*state = wmalloc(sizeof(WSavedState));
(*state)->workspace = data[0];
(*state)->miniaturized = data[1];
(*state)->shaded = data[2];
(*state)->hidden = data[3];
(*state)->maximized = data[4];
(*state)->x = data[5];
(*state)->y = data[6];
(*state)->w = data[7];
(*state)->h = data[8];
(*state)->window_shortcuts = data[9];
if (*state) {
(*state)->workspace = data[0];
(*state)->miniaturized = data[1];
(*state)->shaded = data[2];
(*state)->hidden = data[3];
(*state)->maximized = data[4];
(*state)->x = data[5];
(*state)->y = data[6];
(*state)->w = data[7];
(*state)->h = data[8];
(*state)->window_shortcuts = data[9];
}
XFree(data);
if (*state && type_ret==_XA_WINDOWMAKER_STATE)
return 1;
return 1;
else
return 0;
return 0;
}