Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: E.h ewins.c ewins.h ipc.c main.c mod-misc.c session.c snaps.c snaps.h Log Message: Provide control over match conditions for saved settings. =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v retrieving revision 1.492 retrieving revision 1.493 diff -u -3 -r1.492 -r1.493 --- E.h 18 Sep 2005 06:35:37 -0000 1.492 +++ E.h 23 Sep 2005 16:12:13 -0000 1.493 @@ -326,7 +326,6 @@ typedef struct _ewin EWin; typedef struct _dialog Dialog; typedef struct _ditem DItem; -typedef struct _snapshot Snapshot; typedef struct _group Group; typedef struct _background Background; typedef struct _ecursor ECursor; @@ -1627,19 +1626,6 @@ /* slideouts.c */ int SlideoutsConfigLoad(FILE * fs); -/* snaps.c */ -void Real_SaveSnapInfo(int dumval, void *dumdat); -void LoadSnapInfo(void); -void SaveSnapInfo(void); -void SpawnSnappedCmds(void); -void SnapshotEwinMatch(EWin * ewin); -void SnapshotEwinUnmatch(EWin * ewin); -void SnapshotEwinUpdate(EWin * ewin, unsigned int flags); -void SnapshotEwinParse(EWin * ewin, const char *params); -void SettingsRemember(void); -extern const char SnapIpcText[]; -void SnapIpcFunc(const char *params, Client * c); - /* sound.c */ void SoundPlay(const char *name); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/ewins.c,v retrieving revision 1.107 retrieving revision 1.108 diff -u -3 -r1.107 -r1.108 --- ewins.c 18 Sep 2005 06:35:37 -0000 1.107 +++ ewins.c 23 Sep 2005 16:12:13 -0000 1.108 @@ -563,7 +563,7 @@ MatchEwinToSM(ewin); #endif WindowMatchEwinOps(ewin); /* Window matches */ - SnapshotEwinMatch(ewin); /* Saved settings */ + SnapshotsApplyToEwin(ewin); /* Saved settings */ if (!EwinIsInternal(ewin) && Mode.wm.startup) EHintsGetInfo(ewin); /* E restart hints */ =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/ewins.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -3 -r1.13 -r1.14 --- ewins.h 18 Sep 2005 06:35:37 -0000 1.13 +++ ewins.h 23 Sep 2005 16:12:13 -0000 1.14 @@ -32,6 +32,8 @@ typedef struct _ewin EWin; #endif +struct _snapshot; + struct _ewin { EObj o; @@ -186,7 +188,7 @@ int shape_x, shape_y, shape_w, shape_h; int req_x, req_y; - Snapshot *snap; + struct _snapshot *snap; int head; /* Unused? */ int vx, vy; /* Position in virtual root */ =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/ipc.c,v retrieving revision 1.236 retrieving revision 1.237 diff -u -3 -r1.236 -r1.237 --- ipc.c 19 Sep 2005 16:05:19 -0000 1.236 +++ ipc.c 23 Sep 2005 16:12:13 -0000 1.237 @@ -27,6 +27,7 @@ #include "eobj.h" #include "ewins.h" #include "ewin-ops.h" +#include "snaps.h" #include "xwin.h" #include <ctype.h> =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/main.c,v retrieving revision 1.131 retrieving revision 1.132 diff -u -3 -r1.131 -r1.132 --- main.c 4 Sep 2005 07:27:20 -0000 1.131 +++ main.c 23 Sep 2005 16:12:13 -0000 1.132 @@ -24,6 +24,7 @@ #include "E.h" #include "desktops.h" #include "emodule.h" +#include "snaps.h" #include "timestamp.h" #include "xwin.h" #include <sys/utsname.h> =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/mod-misc.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -3 -r1.20 -r1.21 --- mod-misc.c 16 Jul 2005 16:57:43 -0000 1.20 +++ mod-misc.c 23 Sep 2005 16:12:13 -0000 1.21 @@ -22,6 +22,7 @@ */ #include "E.h" #include "emodule.h" +#include "snaps.h" /*********************************************************************** * *** should all go elsewhere *** =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/session.c,v retrieving revision 1.104 retrieving revision 1.105 diff -u -3 -r1.104 -r1.105 --- session.c 4 Aug 2005 16:02:01 -0000 1.104 +++ session.c 23 Sep 2005 16:12:13 -0000 1.105 @@ -25,6 +25,7 @@ #include "ecore-e16.h" #include "emodule.h" #include "ewins.h" +#include "snaps.h" #include "xwin.h" #include <errno.h> #include <fcntl.h> =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/snaps.c,v retrieving revision 1.97 retrieving revision 1.98 diff -u -3 -r1.97 -r1.98 --- snaps.c 4 Sep 2005 07:27:20 -0000 1.97 +++ snaps.c 23 Sep 2005 16:12:13 -0000 1.98 @@ -1,5 +1,6 @@ /* - * Copyright (C) 2000-2005 Carsten Haitzler, Geoff Harrison and various contributors + * Copyright (C) 2000-2005 Carsten Haitzler, Geoff Harrison + * and various contributors * Copyright (C) 2004-2005 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -33,8 +34,10 @@ char *win_title; char *win_name; char *win_class; + char *win_role; EWin *used; char track_changes; + unsigned int match_flags; unsigned int use_flags; char *border_name; @@ -65,7 +68,7 @@ sn = Ecalloc(1, sizeof(Snapshot)); sn->name = Estrdup(name); - AddItemEnd(sn, sn->name, 0, LIST_TYPE_SNAPSHOT); + AddItemEnd(sn, NULL, 0, LIST_TYPE_SNAPSHOT); return sn; } @@ -89,6 +92,8 @@ Efree(sn->win_name); if (sn->win_class) Efree(sn->win_class); + if (sn->win_role) + Efree(sn->win_role); if (sn->border_name) Efree(sn->border_name); if (sn->cmd) @@ -103,15 +108,24 @@ * a <name>-<pid>-<something>-<time> like thing. * Is this even ICCCM compliant? */ -static const char * +static char * SnapGetRole(const char *role, char *buf, int len) { int l1, l2; + if (!role) + return NULL; + l1 = strlen(role); if (l1 >= len) l1 = len - 1; - l2 = strcspn(role, "-0123456789"); + + for (l2 = l1; l2 > 0; l2--) + { + if (role[l2 - 1] != '-' && + !(role[l2 - 1] >= '0' && role[l2 - 1] <= '9')) + break; + } if (l1 - l2 > 8) l1 = l2; memcpy(buf, role, l1); @@ -120,82 +134,124 @@ return buf; } -/* Format the window identifier string */ +#define SEQ(s1, s2) ((s1) && (s2) && !strcmp(s1, s2)) + static int -SnapEwinMakeID(EWin * ewin, char *buf, int len) +SnapshotEwinMatch(Snapshot * sn, EWin * ewin) { - char s[256]; + char buf[256], *s; - if ((ewin->icccm.wm_role) && (ewin->icccm.wm_res_name) - && (ewin->icccm.wm_res_class)) - Esnprintf(buf, len, "%s.%s:%s", ewin->icccm.wm_res_name, - ewin->icccm.wm_res_class, - SnapGetRole(ewin->icccm.wm_role, s, sizeof(s))); - else if ((ewin->icccm.wm_res_name) && (ewin->icccm.wm_res_class)) - Esnprintf(buf, len, "%s.%s", ewin->icccm.wm_res_name, - ewin->icccm.wm_res_class); - else if (ewin->icccm.wm_name) - Esnprintf(buf, len, "TITLE.%s", ewin->icccm.wm_name); - else - return -1; + /* Don't allow matching anything */ + if (!sn->match_flags) + return 0; + + if (sn->match_flags & SNAP_MATCH_TITLE + && !SEQ(sn->win_title, ewin->icccm.wm_name)) + return 0; + + if (sn->match_flags & SNAP_MATCH_NAME + && !SEQ(sn->win_name, ewin->icccm.wm_res_name)) + return 0; + + if (sn->match_flags & SNAP_MATCH_CLASS + && !SEQ(sn->win_class, ewin->icccm.wm_res_class)) + return 0; + + if (sn->match_flags & SNAP_MATCH_ROLE) + { + s = SnapGetRole(ewin->icccm.wm_role, buf, sizeof(buf)); + if (!SEQ(sn->win_role, s)) + return 0; + } - return 0; + /* Match! */ + return 1; } /* find a snapshot state that applies to this ewin */ static Snapshot * SnapshotEwinFind(EWin * ewin) { - Snapshot *sn; - char buf[4096]; + Snapshot **lst, *sn; + int i, num; if (ewin->snap) return ewin->snap; - if (SnapEwinMakeID(ewin, buf, sizeof(buf))) + lst = (Snapshot **) ListItemType(&num, LIST_TYPE_SNAPSHOT); + if (!lst) return NULL; - sn = FindItem(buf, 0, LIST_FINDBY_BOTH, LIST_TYPE_SNAPSHOT); - if (sn) + for (i = 0; i < num; i++) { - ListChangeItemID(LIST_TYPE_SNAPSHOT, sn, 1); - sn->used = ewin; + sn = lst[i]; + + if (sn->used) + continue; + + if (!SnapshotEwinMatch(sn, ewin)) + continue; + + if (!(sn->match_flags & SNAP_MATCH_MULTIPLE)) + sn->used = ewin; + goto done; } + sn = NULL; + done: + Efree(lst); return sn; } +#define ST(s) ((s) ? (s) : "") + /* find a snapshot state that applies to this ewin Or if that doesnt exist */ /* create a new one */ static Snapshot * -SnapshotEwinGet(EWin * ewin) +SnapshotEwinGet(EWin * ewin, unsigned int match_flags) { Snapshot *sn; - char buf[4096]; + char buf[1024], *s; sn = SnapshotEwinFind(ewin); if (sn) return sn; - if (SnapEwinMakeID(ewin, buf, sizeof(buf))) + /* Fix me - put back the old window ID string */ + sn = SnapshotCreate(NULL); + if (!sn) return NULL; - sn = SnapshotCreate(buf); - ListChangeItemID(LIST_TYPE_SNAPSHOT, sn, 1); - if ((ewin->icccm.wm_res_name) && (ewin->icccm.wm_res_class)) - { - sn->win_title = NULL; - sn->win_name = Estrdup(ewin->icccm.wm_res_name); - sn->win_class = Estrdup(ewin->icccm.wm_res_class); - } - else + sn->match_flags = match_flags; + if (match_flags & SNAP_MATCH_TITLE) + sn->win_title = Estrdup(ewin->icccm.wm_name); + if (match_flags & SNAP_MATCH_NAME) + sn->win_name = Estrdup(ewin->icccm.wm_res_name); + if (match_flags & SNAP_MATCH_CLASS) + sn->win_class = Estrdup(ewin->icccm.wm_res_class); + if (match_flags & SNAP_MATCH_ROLE) + { + s = SnapGetRole(ewin->icccm.wm_role, buf, sizeof(buf)); + sn->win_role = Estrdup(s); + } + + /* Set the snap name. Has no particular significance. */ + if ((sn->win_name || sn->win_class) && sn->win_role) + Esnprintf(buf, sizeof(buf), "%s.%s:%s", ST(sn->win_name), + ST(sn->win_class), sn->win_role); + else if (sn->win_name || sn->win_class) + Esnprintf(buf, sizeof(buf), "%s.%s", ST(sn->win_name), ST(sn->win_class)); + else if (sn->win_title) + Esnprintf(buf, sizeof(buf), "TITLE.%s", sn->win_title); + else /* We should not go here */ + Esnprintf(buf, sizeof(buf), "TITLE.%s", ewin->icccm.wm_name); + sn->name = Estrdup(buf); + + if (!(sn->match_flags & SNAP_MATCH_MULTIPLE)) { - sn->win_title = Estrdup(ewin->icccm.wm_name); - sn->win_name = NULL; - sn->win_class = NULL; + sn->used = ewin; + ewin->snap = sn; } - sn->used = ewin; - ewin->snap = sn; return sn; } @@ -318,7 +374,7 @@ { sn = gwins[i]->snap; if (!sn) - sn = SnapshotEwinGet(gwins[i]); + sn = SnapshotEwinGet(gwins[i], SNAP_MATCH_DEFAULT); if (sn) { if (sn->groups) @@ -405,23 +461,24 @@ } static void -SnapshotEwinSet(EWin * ewin, unsigned int flags) +SnapshotEwinSet(EWin * ewin, unsigned int match_flags, unsigned int use_flags) { Snapshot *sn; /* Quit if nothing to be saved */ - if (!(flags & SNAP_USE_ALL)) + if (!match_flags || !(use_flags & SNAP_USE_ALL)) return; - sn = SnapshotEwinGet(ewin); + sn = SnapshotEwinGet(ewin, match_flags); if (!sn) return; - if (flags & SNAP_AUTO) + if (use_flags & SNAP_AUTO) sn->track_changes = 1; - sn->use_flags = flags & SNAP_USE_ALL; - SnapEwinUpdate(sn, ewin, flags); + sn->use_flags = use_flags & SNAP_USE_ALL; + + SnapEwinUpdate(sn, ewin, use_flags); } void @@ -456,6 +513,15 @@ typedef struct { Window client; + + struct + { + char title; + char name; + char class; + char role; + } match; + char track_changes; char snap_border; char snap_desktop; @@ -481,7 +547,7 @@ { EWin *ewin; SnapDlgData *sd = DialogGetData(d); - unsigned int use_flags; + unsigned int match_flags, use_flags; if (val >= 2 || !sd) goto done; @@ -492,6 +558,19 @@ SnapshotEwinRemove(ewin); + match_flags = 0; + if (sd->match.title) + match_flags |= SNAP_MATCH_TITLE; + if (sd->match.name) + match_flags |= SNAP_MATCH_NAME; + if (sd->match.class) + match_flags |= SNAP_MATCH_CLASS; + if (sd->match.role) + match_flags |= SNAP_MATCH_ROLE; + + if (!match_flags) + goto done; + use_flags = 0; if (sd->track_changes) use_flags |= SNAP_AUTO; @@ -524,7 +603,10 @@ if (sd->snap_group) use_flags |= SNAP_USE_GROUPS; - SnapshotEwinSet(ewin, use_flags); + if (!use_flags) + goto done; + + SnapshotEwinSet(ewin, match_flags, use_flags); done: if (sd && val == 2) @@ -587,6 +669,11 @@ sn = ewin->snap; if (sn) { + sd->match.title = (sn->match_flags & SNAP_MATCH_TITLE) != 0; + sd->match.name = (sn->match_flags & SNAP_MATCH_NAME) != 0; + sd->match.class = (sn->match_flags & SNAP_MATCH_CLASS) != 0; + sd->match.role = (sn->match_flags & SNAP_MATCH_ROLE) != 0; + if (sn->track_changes) sd->track_changes = 1; if (sn->use_flags & SNAP_USE_BORDER) @@ -618,12 +705,26 @@ if (sn->use_flags & SNAP_USE_GROUPS) sd->snap_group = 1; } + else + { + if (ewin->icccm.wm_res_name) + { + sd->match.name = 1; + sd->match.class = 1; + sd->match.role = ewin->icccm.wm_role != NULL; + } + else + { + sd->match.title = ewin->icccm.wm_name != NULL; + } + } - di = DialogAddItem(table, DITEM_TEXT); + di = DialogAddItem(table, DITEM_CHECKBUTTON); DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetAlign(di, 0, 512); DialogItemSetText(di, _("Title:")); + DialogItemCheckButtonSetPtr(di, &sd->match.title); di = DialogAddItem(table, DITEM_TEXT); DialogItemSetColSpan(di, 3); @@ -634,11 +735,12 @@ if (ewin->icccm.wm_res_name) { - di = DialogAddItem(table, DITEM_TEXT); + di = DialogAddItem(table, DITEM_CHECKBUTTON); DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetAlign(di, 0, 512); DialogItemSetText(di, _("Name:")); + DialogItemCheckButtonSetPtr(di, &sd->match.name); di = DialogAddItem(table, DITEM_TEXT); DialogItemSetColSpan(di, 3); @@ -650,11 +752,12 @@ if (ewin->icccm.wm_res_class) { - di = DialogAddItem(table, DITEM_TEXT); + di = DialogAddItem(table, DITEM_CHECKBUTTON); DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetAlign(di, 0, 512); DialogItemSetText(di, _("Class:")); + DialogItemCheckButtonSetPtr(di, &sd->match.class); di = DialogAddItem(table, DITEM_TEXT); DialogItemSetColSpan(di, 3); @@ -664,6 +767,23 @@ DialogItemSetText(di, ewin->icccm.wm_res_class); } + if (ewin->icccm.wm_role) + { + di = DialogAddItem(table, DITEM_CHECKBUTTON); + DialogItemSetPadding(di, 2, 2, 2, 2); + DialogItemSetFill(di, 1, 0); + DialogItemSetAlign(di, 0, 512); + DialogItemSetText(di, _("Role:")); + DialogItemCheckButtonSetPtr(di, &sd->match.role); + + di = DialogAddItem(table, DITEM_TEXT); + DialogItemSetColSpan(di, 3); + DialogItemSetPadding(di, 2, 2, 2, 2); + DialogItemSetFill(di, 1, 0); + DialogItemSetAlign(di, 1024, 512); + DialogItemSetText(di, ewin->icccm.wm_role); + } + if (ewin->icccm.wm_command) { di = DialogAddItem(table, DITEM_TEXT); @@ -718,7 +838,6 @@ DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetText(di, _("Track Changes")); - DialogItemCheckButtonSetState(di, sd->track_changes); DialogItemCheckButtonSetPtr(di, &sd->track_changes); di = DialogAddItem(table, DITEM_CHECKBUTTON); @@ -726,7 +845,6 @@ DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetText(di, _("Location")); - DialogItemCheckButtonSetState(di, sd->snap_location); DialogItemCheckButtonSetPtr(di, &sd->snap_location); di = DialogAddItem(table, DITEM_CHECKBUTTON); @@ -734,7 +852,6 @@ DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetText(di, _("Border style")); - DialogItemCheckButtonSetState(di, sd->snap_border); DialogItemCheckButtonSetPtr(di, &sd->snap_border); di = DialogAddItem(table, DITEM_CHECKBUTTON); @@ -742,7 +859,6 @@ DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetText(di, _("Size")); - DialogItemCheckButtonSetState(di, sd->snap_size); DialogItemCheckButtonSetPtr(di, &sd->snap_size); di = DialogAddItem(table, DITEM_CHECKBUTTON); @@ -750,7 +866,6 @@ DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetText(di, _("Desktop")); - DialogItemCheckButtonSetState(di, sd->snap_desktop); DialogItemCheckButtonSetPtr(di, &sd->snap_desktop); di = DialogAddItem(table, DITEM_CHECKBUTTON); @@ -758,7 +873,6 @@ DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetText(di, _("Shaded state")); - DialogItemCheckButtonSetState(di, sd->snap_shaded); DialogItemCheckButtonSetPtr(di, &sd->snap_shaded); di = DialogAddItem(table, DITEM_CHECKBUTTON); @@ -766,7 +880,6 @@ DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetText(di, _("Sticky state")); - DialogItemCheckButtonSetState(di, sd->snap_sticky); DialogItemCheckButtonSetPtr(di, &sd->snap_sticky); di = DialogAddItem(table, DITEM_CHECKBUTTON); @@ -774,7 +887,6 @@ DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetText(di, _("Stacking layer")); - DialogItemCheckButtonSetState(di, sd->snap_layer); DialogItemCheckButtonSetPtr(di, &sd->snap_layer); di = DialogAddItem(table, DITEM_CHECKBUTTON); @@ -782,7 +894,6 @@ DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetText(di, _("Window List Skip")); - DialogItemCheckButtonSetState(di, sd->snap_skiplists); DialogItemCheckButtonSetPtr(di, &sd->snap_skiplists); #if USE_COMPOSITE @@ -791,7 +902,6 @@ DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetText(di, _("Opacity")); - DialogItemCheckButtonSetState(di, sd->snap_opacity); DialogItemCheckButtonSetPtr(di, &sd->snap_opacity); di = DialogAddItem(table, DITEM_CHECKBUTTON); @@ -799,7 +909,6 @@ DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetText(di, _("Shadowing")); - DialogItemCheckButtonSetState(di, sd->snap_shadow); DialogItemCheckButtonSetPtr(di, &sd->snap_shadow); #endif @@ -809,7 +918,6 @@ DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetText(di, _("Never Focus")); - DialogItemCheckButtonSetState(di, sd->snap_neverfocus); DialogItemCheckButtonSetPtr(di, &sd->snap_neverfocus); #endif if (ewin->icccm.wm_command) @@ -828,7 +936,6 @@ DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetText(di, _("Restart application on login")); - DialogItemCheckButtonSetState(di, sd->snap_cmd); DialogItemCheckButtonSetPtr(di, &sd->snap_cmd); } else @@ -850,7 +957,6 @@ DialogItemSetPadding(di, 2, 2, 2, 2); DialogItemSetFill(di, 1, 0); DialogItemSetText(di, _("Remember this window's group(s)")); - DialogItemCheckButtonSetState(di, sd->snap_group); DialogItemCheckButtonSetPtr(di, &sd->snap_group); } @@ -908,18 +1014,6 @@ } static void -CB_ApplyRememberEscape(Dialog * d, int val __UNUSED__, void *data __UNUSED__) -{ - DialogClose(d); - - if (rd_ewin_list) - { - Efree(rd_ewin_list); - rd_ewin_list = NULL; - } -} - -static void CB_RememberWindowSettings(Dialog * d __UNUSED__, int val __UNUSED__, void *data) { RememberWinList *rd; @@ -1017,7 +1111,6 @@ s = buf; } DialogItemSetText(di, s); - DialogItemCheckButtonSetState(di, rd_ewin_list[i].remove); DialogItemCheckButtonSetPtr(di, &(rd_ewin_list[i].remove)); if (sn->used) @@ -1063,7 +1156,7 @@ DialogAddButton(d, _("OK"), CB_ApplyRemember, 1, DIALOG_BUTTON_OK); DialogAddButton(d, _("Close"), CB_ApplyRemember, 1, DIALOG_BUTTON_CLOSE); DialogSetExitFunction(d, CB_ApplyRemember, 2); - DialogBindKey(d, "Escape", CB_ApplyRememberEscape, 0); + DialogBindKey(d, "Escape", DialogCallbackClose, 0); DialogBindKey(d, "Return", CB_ApplyRemember, 0); ShowDialog(d); @@ -1101,12 +1194,14 @@ { sn = lst[i]; fprintf(f, "NEW: %s\n", sn->name); - if (sn->win_title) + if ((sn->match_flags & SNAP_MATCH_TITLE) && sn->win_title) fprintf(f, "TITLE: %s\n", sn->win_title); - if (sn->win_name) + if ((sn->match_flags & SNAP_MATCH_NAME) && sn->win_name) fprintf(f, "NAME: %s\n", sn->win_name); - if (sn->win_class) + if ((sn->match_flags & SNAP_MATCH_CLASS) && sn->win_class) fprintf(f, "CLASS: %s\n", sn->win_class); + if ((sn->match_flags & SNAP_MATCH_ROLE) && sn->win_role) + fprintf(f, "ROLE: %s\n", sn->win_role); if (sn->track_changes) fprintf(f, "AUTO: yes\n"); if ((sn->use_flags & SNAP_USE_BORDER) && sn->border_name) @@ -1177,7 +1272,8 @@ for (i = 0; i < num; i++) { sn = lst[i]; - if ((sn->use_flags & SNAP_USE_COMMAND) && (sn->cmd) && !sn->used) + if ((sn->use_flags & SNAP_USE_COMMAND) && (sn->cmd) && + !sn->used && !(sn->match_flags & SNAP_MATCH_MULTIPLE)) EspawnCmd(sn->cmd); } Efree(lst); @@ -1214,11 +1310,25 @@ else if (sn) { if (!strcmp(s, "TITLE:")) - sn->win_title = Estrdup(atword(buf, 2)); + { + sn->win_title = Estrdup(atword(buf, 2)); + sn->match_flags |= SNAP_MATCH_TITLE; + } else if (!strcmp(s, "NAME:")) - sn->win_name = Estrdup(atword(buf, 2)); + { + sn->win_name = Estrdup(atword(buf, 2)); + sn->match_flags |= SNAP_MATCH_NAME; + } else if (!strcmp(s, "CLASS:")) - sn->win_class = Estrdup(atword(buf, 2)); + { + sn->win_class = Estrdup(atword(buf, 2)); + sn->match_flags |= SNAP_MATCH_CLASS; + } + else if (!strcmp(s, "ROLE:")) + { + sn->win_role = Estrdup(atword(buf, 2)); + sn->match_flags |= SNAP_MATCH_ROLE; + } else if (!strcmp(s, "AUTO:")) sn->track_changes = 1; else if (!strcmp(s, "BORDER:")) @@ -1369,7 +1479,7 @@ /* make a client window conform to snapshot info */ void -SnapshotEwinMatch(EWin * ewin) +SnapshotsApplyToEwin(EWin * ewin) { Snapshot *sn; int i, ax, ay; @@ -1378,12 +1488,11 @@ if (!sn) { if (ewin->props.autosave) - SnapshotEwinSet(ewin, SNAP_USE_ALL | SNAP_AUTO); + SnapshotEwinSet(ewin, SNAP_MATCH_DEFAULT, SNAP_USE_ALL | SNAP_AUTO); return; } ewin->snap = sn; - ListChangeItemID(LIST_TYPE_SNAPSHOT, ewin->snap, 1); if (ewin->props.autosave) sn->track_changes = 1; @@ -1485,16 +1594,17 @@ ewin->snap = NULL; sn->used = NULL; - ListChangeItemID(LIST_TYPE_SNAPSHOT, sn, 0); } void SnapshotEwinParse(EWin * ewin, const char *params) { char param[FILEPATH_LEN_MAX]; - unsigned int use_flags; + unsigned int match_flags, use_flags; + match_flags = SNAP_MATCH_DEFAULT; use_flags = 0; + for (; params;) { param[0] = 0; @@ -1542,8 +1652,12 @@ } if (ewin->snap) - use_flags |= ewin->snap->use_flags; - SnapshotEwinSet(ewin, use_flags); + { + match_flags = ewin->snap->match_flags; + use_flags |= ewin->snap->use_flags; + } + + SnapshotEwinSet(ewin, match_flags, use_flags); SaveSnapInfo(); } @@ -1566,7 +1680,7 @@ Snapshot **lst, *sn; int i, num, full; char param[FILEPATH_LEN_MAX]; - const char *name, nstr[] = "null"; + const char *name; lst = (Snapshot **) ListItemType(&num, LIST_TYPE_SNAPSHOT); if (!lst) @@ -1601,16 +1715,23 @@ continue; } - IpcPrintf(" Name: %s %s\n" - " Window Title: %s\n" - " Window Name: %s\n" - " Window Class: %s\n", - name, (sn->used) ? "" : "*** Unused ***", - sn->win_title ? sn->win_title : nstr, - sn->win_name ? sn->win_name : nstr, - sn->win_class ? sn->win_class : nstr); +#define SU(sn, item) ((sn->match_flags & item) ? '>' : ':') + IpcPrintf(" Snapshot Name: %s %s\n", + name, (sn->used) ? "" : "*** Unused ***"); + if (sn->win_title) + IpcPrintf(" Window Title%c %s\n", SU(sn, SNAP_MATCH_TITLE), + sn->win_title); + if (sn->win_name) + IpcPrintf(" Window Name%c %s\n", SU(sn, SNAP_MATCH_NAME), + sn->win_name); + if (sn->win_class) + IpcPrintf(" Window Class%c %s\n", SU(sn, SNAP_MATCH_CLASS), + sn->win_class); + if (sn->win_role) + IpcPrintf(" Window Role%c %s\n", SU(sn, SNAP_MATCH_ROLE), + sn->win_role); - if (sn->use_flags & SNAP_AUTO) + if (sn->track_changes) IpcPrintf(" Tracking changes\n"); if (sn->use_flags & SNAP_USE_BORDER) IpcPrintf(" Border Name: %s\n", SS(sn->border_name)); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/snaps.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- snaps.h 15 Feb 2005 22:19:52 -0000 1.1 +++ snaps.h 23 Sep 2005 16:12:13 -0000 1.2 @@ -23,6 +23,17 @@ #ifndef _SNAPS_H_ #define _SNAPS_H_ +typedef struct _snapshot Snapshot; + +#define SNAP_MATCH_TITLE (1 << 0) +#define SNAP_MATCH_NAME (1 << 1) +#define SNAP_MATCH_CLASS (1 << 2) +#define SNAP_MATCH_ROLE (1 << 3) +#define SNAP_MATCH_ROLE (1 << 3) +#define SNAP_MATCH_MULTIPLE (1 << 8) + +#define SNAP_MATCH_DEFAULT (SNAP_MATCH_NAME | SNAP_MATCH_CLASS | SNAP_MATCH_ROLE) + #define SNAP_AUTO (1 << 0) #define SNAP_USE_BORDER (1 << 1) #define SNAP_USE_COMMAND (1 << 2) @@ -40,4 +51,16 @@ #define SNAP_USE_ALL (~1) +void Real_SaveSnapInfo(int dumval, void *dumdat); +void LoadSnapInfo(void); +void SaveSnapInfo(void); +void SpawnSnappedCmds(void); +void SnapshotEwinUnmatch(EWin * ewin); +void SnapshotEwinUpdate(EWin * ewin, unsigned int flags); +void SnapshotEwinParse(EWin * ewin, const char *params); +void SnapshotsApplyToEwin(EWin * ewin); +void SettingsRemember(void); +extern const char SnapIpcText[]; +void SnapIpcFunc(const char *params, Client * c); + #endif /* _SNAPS_H_ */ ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs