forked from e16/e16
1
0
Fork 0

Merge windowmatches and icondefs.

SVN revision: 13207
This commit is contained in:
Kim Woelders 2005-02-06 19:13:34 +00:00
parent 47c947699e
commit 9fa632948e
19 changed files with 816 additions and 670 deletions

53
INSTALL
View File

@ -298,56 +298,3 @@ have enlightenment relaunch them as the preferred launch method. To do this,
once you have launched them by hand, alt-rightclick on them, select "Remember"
and then choose "Restart Application on Login".
About 0.16.8
============
Changes:
- "enlightenment" has been renamed to "e16".
- The default user configuration directory is "~/.e16".
- The data install path is "<somepath>/e16", e.g. "/usr/share/e16".
Thus, an e16.8 installation should not clash with any other versions.
- Various configuration file formats have changed and should be easier
to read and modify, if needed.
- The configuration is stored per display and per screen. E.g. for
DISPLAY=:1.0 the main configuration file is "~/.e16/e_config--1.0.cfg".
- Actions(used by menus, keybindings, etc.) and IPC functions(eesh) have
been merged.
- Many IPC(eesh) commands have been changed, possibly breaking compatibility
with a few epplets.
New features:
- Built-in composite manager.
- An iconbox can be configured to act as System Tray
(middle mouse->Desktop->Create Systray).
Notes:
imlib2 >= 1.2.0 is required.
All settings can be shown and set using eesh.
To get a full list of settings:
$ eesh show
To set some parameter:
$ eesh set <parameter> <value>
Some settings will not be effective until E is restarted.
To get a list of other eesh commands:
$ eesh help full
The composite manager only works on the root window (desktop 0) for now.
If window resize/shading is ugly try:
$ eesh set compmgr.resize_fix_enable 1
0.16.8 should still be compatible with any e16 theme. However, user installed
themes will have to be moved/linked to ~/.e16/themes/ or <datadir>/e16/themes/.
e16keyedit will work, but the "Action" field is no longer used. In stead, the
action (IPC command) must be specified in the "Parameters" field.
If used to change the keybindings, the modified settings will be stored in
~/.e16/e_config.bindings.
It should also be fairly straightforward to modify the key- and buttonbindings
by editing /usr/share/e16/config/bindings.cfg.
e16menuedit will no longer work. e16menuedit2 will.

122
README-0.16.8 Normal file
View File

@ -0,0 +1,122 @@
About 0.16.8
============
Changes:
- "enlightenment" has been renamed to "e16".
- The default user configuration directory is "~/.e16".
- The data install path is "<somepath>/e16", e.g. "/usr/share/e16".
Thus, an e16.8 installation should not clash with any other versions.
- Various configuration file formats have changed and should be easier
to read and modify, if needed.
- The configuration is stored per display and per screen. E.g. for
DISPLAY=:1.0 the main configuration file is "~/.e16/e_config--1.0.cfg".
- Actions(used by menus, keybindings, etc.) and IPC functions(eesh) have
been merged.
- Many IPC(eesh) commands have been changed, possibly breaking compatibility
with a few epplets.
- Window matches and icondefs have been merged (into matches.cfg), see below.
New features:
- Built-in composite manager.
- An iconbox can be configured to act as System Tray
(middle mouse->Desktop->Create Systray).
Notes:
imlib2 >= 1.2.0 is required.
All settings can be shown and set using eesh.
To get a full list of settings:
$ eesh show
To set some parameter:
$ eesh set <parameter> <value>
Some settings will not be effective until E is restarted.
To get a list of other eesh commands:
$ eesh help full
The composite manager only works on the root window (desktop 0) for now.
If window resize/shading is ugly try:
$ eesh set compmgr.resize_fix_enable 1
0.16.8 should still be compatible with any e16 theme. However, user installed
themes will have to be moved/linked to ~/.e16/themes/ or <datadir>/e16/themes/.
e16keyedit will work, but the "Action" field is no longer used. In stead, the
action (IPC command) must be specified in the "Parameters" field.
If used to change the keybindings, the modified settings will be stored in
~/.e16/e_config.bindings.
It should also be fairly straightforward to modify the key- and buttonbindings
by editing /usr/share/e16/config/bindings.cfg.
e16menuedit will no longer work. e16menuedit2 will.
Configuration files
-------------------
Skip this section unless you *really* want to know...
It is here assumed that --prefix is /usr, and that the default user
configuration directory (~/.e16) is used.
Localization is ignored for simplicity.
In general, the configuration search order for theme related configuration
files, say xyz.cfg, is:
1) User configuration directory, i.e. ~/.e16/xyz.cfg.
2) Theme directory, i.e. /usr/share/e16/themes/<theme>/xyz.cfg, or
~/.e16/themes/<theme>/xyz.cfg.
3) Default configuration directory, i.e. /usr/share/e16/config/xyz.cfg.
Mouse and keybindings are defined in bindings.cfg, and optionally in
~/.e16/e_config.bindings. The latter may be generated as a result of using
e16keyedit.
bindings.cfg is loaded first, and searched in
1) User configuration directory, i.e. ~/.e16/bindings.cfg.
2) Default configuration directory, i.e. /usr/share/e16/config/bindings.cfg.
~/.e16/e_config.bindings is loaded next, and will override settings
defined in bindings.cfg.
Window matches (border and icon associations) are defined in windowmatches.cfg
and matches.cfg.
windowmatches.cfg (deprecated, border associations only) is loaded first,
and should be found only in theme directories.
matches.cfg is loaded next, and searched in
1) User configuration directory, i.e. ~/.e16/matches.cfg.
2) Default configuration directory, i.e. /usr/share/e16/config/matches.cfg.
Window match items are appended to the window match list, in the order
in which they are read from the configuration files.
When doing border/icon matches, the window match list is searched from the
start, and the first matching item will be used.
Migrating from Enlightenment 0.16.7 to 0.16.8
---------------------------------------------
By Peter Hyman (pete4abw@comcast.net)
Users upgrading from enlightenment 0.16.7 need to read the following.
Several organizational changes have occurred that will require
some manual adjustments. Mainly these deal with changes to
configuration and shared directory names. This was done to avoid
collisions with the new enlightenment DR17.
1) home configuration directory is now ~/.e16, not ~/.enlightenment.
2) menu files have been moved to a subdirectory called menus
you will need to move customized menus and subdirectories to
~/.e16/menus. Note: because of this menu files will have to have
menus/ prepended to it in order to be located. Ex:
file.menu file...
"User Menus"
"User Application list" NULL menu "menus/user_apps.menu"
whereas the old menu version did not have menus/.
3) you will need to move ~/.enlightenment/backgrounds files to ~/.e16
and any themes as well.
4) $prefix/share/enlightenment has been changed to $prefix/share/e16
5) if installed E-docs and Epplet directories will have to be moved
to $prefix/share/e16
6) any additional themes that were added to the $prefix/share/enlightenment
directory will have to be moved to $prefix/share/e16
7) any startup scripts or Session scripts that reference the startup
executable `enlightenment` must be edited to the new e16 program.

View File

@ -1,31 +0,0 @@
Migrating from Enlightenment 0.16.7 to 0.16.8
Users upgrading from enlightenment 0.16.7 need to read the following.
Several organizational changes have occurred that will require
some manual adjustments. Mainly these deal with changes to
configuration and shared directory names. This was done to avoid
collisions with the new enlightenment DR17.
1) home configuration directory is now ~/.e16, not ~/.enlightenment.
2) menu files have been moved to a subdirectory called menus
you will need to move customized menus and subdirectories to
~/.e16/menus. Note: because of this menu files will have to have
menus/ prepended to it in order to be located. Ex:
file.menu file...
"User Menus"
"User Application list" NULL menu "menus/user_apps.menu"
whereas the old menu version did not have menus/.
3) you will need to move ~/.enlightenment/backgrounds files to ~/.e16
and any themes as well.
4) $prefix/share/enlightenment has been changed to $prefix/share/e16
5) if installed E-docs and Epplet directories will have to be moved
to $prefix/share/e16
6) any additional themes that were added to the $prefix/share/enlightenment
directory will have to be moved to $prefix/share/e16
7) any startup scripts or Session scripts that reference the startup
executable `enlightenment` must be edited to the new e16 program.
December 30 2004
Peter Hyman
pete4abw@comcast.net

View File

@ -10,8 +10,7 @@ backup-textclasses.cfg \
backup-tooltips.cfg \
bindings.cfg \
definitions \
control.cfg \
icondefs.cfg \
matches.cfg \
menus.cfg
configdatadir = $(ENLIGHTENMENT_ROOT)/config

View File

@ -1,94 +0,0 @@
#include <definitions>
/* NEW NEW ********* you have to revision your config fiels now - if things */
/* get incompatibel between config revisions the revsiison number in E */
/* will update - config files with non equal revisions will not work */
__E_CFG_VERSION 0
/*
******************************************************************************
* Enlightenment Config File
******************************************************************************
* Welcome to the user specific configuration file. This file
* should either end up residing in $ENLIGHTENMENT_ROOT/config
* or in ~/.enlightenment
* This is where you get to define stuff outside of the theme. :)
* exciting, isn't it? maybe I'll comment this some more later.
******************************************************************************
* Behavior control section
******************************************************************************
*
*
* This is by no means all the various things that can be defined here.
* There are TONS of things that can be defined here. Just about anything
* in setup.c can be overridden here. NOTE: you don't have to define
* everything here, because there are defaults that are initialized by
* the system in the middle of setup. But this should at least give
* you an idea of what all belongs here. This set is expected to
* eventually live in the user-specific configuration location.
* --Mandrake
*/
/*
__CONTROL __BGN
__FOCUS_MODE __SLOPPY
__MOVE_MODE __OPAQUE
__RESIZE_MODE __BOX
__GEOMINFO_MODE __CENTER_GEOMINFO
__SOUND __OFF
__TOOLTIPS __ON
__TOOLTIP_TIMEOUT 1.5
__AUTORAISE __OFF
__AUTORAISE_TIMEOUT 0.5
__USE_SAVEUNDERS __OFF
__DOCK_DIRECTION __DOWN
__START_POSITION_OF_DOCK 0 0
__SHADING_SPEED 8000
__ANIMATE_WINDOW_SHADING __ON
__BE_PARANOID_ABOUT_SAVING_MEMORY __ON
__MENUS_SLIDE_OUT __OFF
__MENUS_ONSCREEN __ON
__NUMBER_OF_DESKTOPS 2
__AUTOMATICALLY_SAVE_CONFIG __ON
__DESKTOP_AREA_SIZE 2 1
__ALL_NEW_WINDOWS_GET_FOCUS __OFF
__NEW_TRANSIENTS_GET_FOCUS __OFF
__NEW_TRANSIENTS_GET_FOCUS_IF_GROUP_IS_FOCUSED __ON
__MANUAL_WINDOW_PLACEMENT __OFF
__RAISE_WINDOW_ON_NEXT_FOCUS __ON
__WARP_POINTER_ON_NEXT_FOCUS __OFF
__EDGE_FLIP_RESISTANCE 25
__SHOW_ICONIFIED_ICONS __ON
__TRANSIENTS_FOLLOW_GROUP_LEADER __ON
__SLIDE_ON_MAP __OFF
__SLIDE_ON_CLEANUP __ON
__DESKTOPS_SLIDE_IN __ON
__SPEED_OF_DESKTOP_SLIDE 4000
__GROUP_BORDER __ON
__GROUP_KILL __OFF
__GROUP_MOVE __ON
__GROUP_RAISE __OFF
__GROUP_ICONIFY __ON
__GROUP_STICK __ON
__GROUP_SHADE __ON
__GROUP_MIRROR __ON
__END
*/
__EXTRAS __BGN
__ICONBOX __BGN
__NAME DEFAULT
__ORIENTATION __HORIZONTAL
__TRANSPARENCY __OFF
__SHOW_NAMES __ON
__ICON_SIZE 48
__ICON_MODE 2
__SCROLLBAR_SIDE __BAR_BOTTOM
__SCROLLBAR_ARROWS __BOTH
__AUTOMATIC_RESIZE __OFF
__SHOW_ICON_BASE __OFF
__SCROLLBAR_AUTOHIDE __OFF
__END
__END

View File

@ -1,18 +0,0 @@
"pix/mon.png" NULL "*term*" "Eterm"
"pix/mon.png" NULL "*term*" "XTerm"
"pix/mon.png" NULL "rxvt" "XTerm"
"pix/mon.png" NULL "GnomeTerminal" "GnomeTerminal"
"pix/note.png" NULL "*Player" "xmms"
"pix/note.png" NULL "*Playlist" "xmms"
"pix/note.png" NULL "*Player" "x11amp"
"pix/note.png" NULL "*Playlist" "x11amp"
"pix/note.png" NULL "main" "GQmpeg"
"pix/note.png" NULL "gmix" "Gmix"
"pix/world.png" NULL "tkrat" "Tkrat"
"pix/spider.png" NULL NULL "Netscape"
"pix/apple.png" NULL NULL "Gimp"
"pix/pawn.png" NULL "xchat" "Xchat"
"pix/pumpkin.png" "* Settings" NULL NULL
"pix/tv2.png" NULL NULL "Xawtv"
"pix/tv2.png" NULL NULL "Enlightenment_Pager"
"pix/dunny.png" NULL "gmc" NULL

50
config/matches.cfg Normal file
View File

@ -0,0 +1,50 @@
# Default window match rules
# Window match definition line:
# <Match type> <Match value> <Operation type> <Operation arguments>
#
# <Match type>:
# Title Match WM_NAME property
# Name Match name part of WM_CLASS property
# Class Match class part of WM_CLASS property
# Size Match window size
# Width Match window width
# Height Match window height
# Prop Match window "property"
#
# <Match value>:
# Title, Name, Class: String, may contain wildcards(*)
# Size: {>|<}<width>x<height>
# Width, Height: [!]<min>-<max>
# Prop: [!]{Transient|Shaped|Fixedsize|FixedWidth|FixedHeight}
#
# <Operation type>:
# Border: Use specified border
# Icon: Use specified icon
# Winop: Perform window operation(s) (NOT YET IMPLEMENTED)
#
# <Operation arguments>:
# Border: Border name
# Icon: Icon file name
# Winop: Window operation(s) (as in eesh wop <id> <operation>)
# Multiple may be given, e.g. "stick on:layer 5"
#
#
# Default borders
Prop Transient Border TRANSIENT
Prop Shaped Border SHAPED
Prop FixedSize Border FIXED_SIZE
Class Enlightenment_IconBox Border ICONBOX
Class Enlightenment_Dialog Border DIALOG
Class Enlightenment_Pager Border PAGER
# Default icons
Class Eterm Icon pix/mon.png
Class XTerm Icon pix/mon.png
Class GnomeTerminal Icon pix/mon.png
Class xmms Icon pix/note.png
Class Mozilla Icon pix/spider.png
Class Gimp Icon pix/apple.png
Class Xchat Icon pix/pawn.png
Class Enlightenment_Dialog Icon pix/pumpkin.png
Class Xawtv Icon pix/tv2.png
Class Enlightenment_Pager Icon pix/tv2.png

39
src/E.h
View File

@ -789,25 +789,6 @@ struct _group
GroupConfig cfg;
};
typedef struct _windowmatch
{
char *name;
char *win_title;
char *win_name;
char *win_class;
Constraints width;
Constraints height;
signed char transient;
signed char no_resize_h;
signed char no_resize_v;
signed char shaped;
Border *border;
ImageClass *icon;
int desk;
char make_sticky;
}
WindowMatch;
/* Configuration parameters */
typedef struct
{
@ -1238,6 +1219,9 @@ Background *BrackgroundCreateFromImage(const char *bgid,
/* borders.c */
Border *BorderCreate(const char *name);
void BorderDestroy(Border * b);
void BorderIncRefcount(const Border * b);
void BorderDecRefcount(const Border * b);
const char *BorderGetName(const Border * b);
int BorderConfigLoad(FILE * fs);
void BorderWinpartAdd(Border * b, ImageClass * ic,
ActionClass * aclass, TextClass * tclass,
@ -1343,7 +1327,7 @@ char *ConfigFileFind(const char *name, const char *themepath,
int ConfigFileLoad(const char *name, const char *themepath,
int (*parse) (FILE * fs));
int ThemeConfigLoad(void);
void SaveUserControlConfig(const char *file);
void SaveUserControlConfig(void);
void RecoverUserConfig(void);
/* coords.c */
@ -1500,7 +1484,7 @@ void ScaleLine(Pixmap dest, Window src, int dx, int dy, int sw,
void ScaleRect(Pixmap dest, Window src, int sx, int sy, int dx,
int dy, int sw, int sh, int dw, int dh);
Imlib_Image *ELoadImage(char *file);
Imlib_Image *ELoadImage(const char *file);
void DrawEwinShape(EWin * ewin, int md, int x, int y, int w,
int h, char firstlast);
void PropagateShapes(Window win);
@ -2199,14 +2183,11 @@ void EFont_draw_string(Display * disp, Drawable win, GC gc,
void WarpFocus(int delta);
/* windowmatch.c */
int WindowMatchConfigLoad(FILE * fs);
Border *MatchEwinBorder(EWin * ewin, WindowMatch * b);
ImageClass *MatchEwinIcon(EWin * ewin, WindowMatch * b);
int MatchEwinDesktop(EWin * ewin, WindowMatch * b);
void *MatchEwinByFunction(EWin * ewin,
void *(*FunctionToTest) (EWin *,
WindowMatch
*));
typedef struct _windowmatch WindowMatch;
void *WindowMatchEwin(EWin * ewin);
Border *WindowMatchEwinBorder(const EWin * ewin);
const char *WindowMatchEwinIcon(const EWin * ewin);
/* x.c */
Display *EDisplayOpen(const char *dstr);

View File

@ -618,7 +618,9 @@ AclassConfigLoad2(FILE * fs)
if (!ss)
break;
len = strcspn(s, "\r\n");
len = strcspn(s, "#\r\n");
if (len <= 0)
continue;
s[len] = '\0';
prm3[0] = '\0';
@ -1002,9 +1004,6 @@ AclassSighan(int sig, void *prm __UNUSED__)
{
case ESIGNAL_INIT:
AclassSetupFallback();
#if 0
ConfigFileLoad("keybindings.cfg", NULL, AclassConfigLoad);
#endif
AclassConfigLoadConfig();
AclassConfigLoadUser();
break;

View File

@ -471,18 +471,24 @@ HonorIclass(char *s, int id)
Efree(a);
}
static void
void
BorderIncRefcount(const Border * b)
{
((Border *) b)->ref_count++;
}
static void
void
BorderDecRefcount(const Border * b)
{
((Border *) b)->ref_count--;
}
const char *
BorderGetName(const Border * b)
{
return (b) ? b->name : NULL;
}
void
EwinBorderSelect(EWin * ewin)
{
@ -495,18 +501,14 @@ EwinBorderSelect(EWin * ewin)
ICCCM_GetShapeInfo(ewin);
if ((!ewin->client.mwm_decor_title) && (!ewin->client.mwm_decor_border))
b = (Border *) FindItem("BORDERLESS", 0, LIST_FINDBY_NAME,
LIST_TYPE_BORDER);
if ((!ewin->client.mwm_decor_title && !ewin->client.mwm_decor_border) ||
(Conf.dock.enable && ewin->docked))
b = FindItem("BORDERLESS", 0, LIST_FINDBY_NAME, LIST_TYPE_BORDER);
else
b = MatchEwinByFunction(ewin,
(void
*(*)(EWin *, WindowMatch *))(MatchEwinBorder));
if (Conf.dock.enable && ewin->docked)
b = (Border *) FindItem("BORDERLESS", 0, LIST_FINDBY_NAME,
LIST_TYPE_BORDER);
b = WindowMatchEwinBorder(ewin);
if (!b)
b = (Border *) FindItem("DEFAULT", 0, LIST_FINDBY_NAME, LIST_TYPE_BORDER);
b = FindItem("DEFAULT", 0, LIST_FINDBY_NAME, LIST_TYPE_BORDER);
if (!b)
b = FindItem("__FALLBACK_BORDER", 0, LIST_FINDBY_NAME, LIST_TYPE_BORDER);

View File

@ -351,11 +351,6 @@ ConfigFileRead(FILE * fs)
if (err)
ConfigAlertLoad(_("Background"));
break;
case CONFIG_WINDOWMATCH:
err = WindowMatchConfigLoad(fs);
if (err)
ConfigAlertLoad(_("Window match"));
break;
case CONFIG_COLORMOD:
#if 0 /* FIXME - ? */
Config_ColorModifier(fs);
@ -510,7 +505,6 @@ ThemeConfigLoad(void)
"slideouts.cfg",
"borders.cfg",
"backup-borders.cfg",
"windowmatches.cfg",
"tooltips.cfg",
"backup-tooltips.cfg",
"menustyles.cfg",
@ -552,7 +546,8 @@ ThemeConfigLoad(void)
FontConfigUnload();
/* Loose ends... */
ConfigFileLoad(EGetSavePrefix(), NULL, ConfigFileRead);
Esnprintf(s, sizeof(s), "%s.misc", EGetSavePrefix());
ConfigFileLoad(s, NULL, ConfigFileRead);
BordersSetupFallback();
@ -560,13 +555,17 @@ ThemeConfigLoad(void)
}
void
SaveUserControlConfig(const char *file)
SaveUserControlConfig(void)
{
char s[4096], s2[4096];
FILE *fs;
/* Save the configuration parameters */
ConfigurationSave();
fs = fopen(file, "w");
/* Save odd bits */
Etmp(s2);
fs = fopen(s2, "w");
if (!fs)
return;
@ -576,6 +575,12 @@ SaveUserControlConfig(const char *file)
ButtonsConfigSave(fs);
fclose(fs);
Esnprintf(s, sizeof(s), "%s.misc", EGetSavePrefix());
E_mv(s2, s);
if (!isfile(s))
Alert(_("There was an error saving your autosave data - filing\n"
"system problems.\n"));
}
void

View File

@ -1750,7 +1750,7 @@ DrawEwinShape(EWin * ewin, int md, int x, int y, int w, int h, char firstlast)
}
Imlib_Image *
ELoadImage(char *file)
ELoadImage(const char *file)
{
Imlib_Image *im;
char *f = NULL;

View File

@ -104,14 +104,6 @@ struct _iconbox
};
typedef struct
{
char *title_match;
char *name_match;
char *class_match;
char *icon_file;
} Icondef;
/* Silly hack to avoid name clash warning when using -Wshadow */
#define y1 y1_
@ -543,7 +535,7 @@ IconboxShow(Iconbox * ib)
HintsSetWindowName(ib->win, "Iconbox");
HintsSetWindowClass(ib->win, ib->name, "Enlightenment_IconBox");
ewin = AddInternalToFamily(ib->win, "ICONBOX", EWIN_TYPE_ICONBOX, ib,
ewin = AddInternalToFamily(ib->win, NULL, EWIN_TYPE_ICONBOX, ib,
IconboxEwinInit);
if (ewin)
{
@ -833,73 +825,18 @@ IB_GetAppIcon(EWin * ewin)
ewin->icon_type = EWIN_ICON_TYPE_APP;
}
static Icondef **
IB_ListIcondef(int *num)
{
return (Icondef **) ListItemType(num, LIST_TYPE_ICONDEF);
}
static Icondef *
IB_MatchIcondef(char *title, char *name, char *class)
{
/* return an icondef that matches the data given */
Icondef **il, *idef;
int i, num;
il = IB_ListIcondef(&num);
if (il)
{
for (i = 0; i < num; i++)
{
char match = 1;
if ((il[i]->title_match) && (!title))
match = 0;
if ((il[i]->name_match) && (!name))
match = 0;
if ((il[i]->class_match) && (!class))
match = 0;
if ((il[i]->title_match) && (title))
{
if (!matchregexp(il[i]->title_match, title))
match = 0;
}
if ((il[i]->name_match) && (name))
{
if (!matchregexp(il[i]->name_match, name))
match = 0;
}
if ((il[i]->class_match) && (class))
{
if (!matchregexp(il[i]->class_match, class))
match = 0;
}
if (match)
{
idef = il[i];
Efree(il);
return idef;
}
}
Efree(il);
}
return NULL;
}
static void
IB_GetEIcon(EWin * ewin)
{
/* get the icon defined for this window in E's iconf match file */
Icondef *idef;
const char *file;
Imlib_Image *im;
idef = IB_MatchIcondef(ewin->icccm.wm_name, ewin->icccm.wm_res_name,
ewin->icccm.wm_res_class);
if (!idef)
file = WindowMatchEwinIcon(ewin);
if (!file)
return;
im = ELoadImage(idef->icon_file);
im = ELoadImage(file);
if (!im)
return;
@ -907,175 +844,6 @@ IB_GetEIcon(EWin * ewin)
ewin->icon_type = EWIN_ICON_TYPE_IMG;
}
static void
IB_AddIcondef(char *title, char *name, char *class, char *file)
{
/* add match for a window pointing to an iconfile */
/* form: "*term*" "name*" "*class" "path/to_image.png" */
Icondef *idef;
idef = Emalloc(sizeof(Icondef));
if (!idef)
return;
idef->title_match = Estrdup(title);
idef->name_match = Estrdup(name);
idef->class_match = Estrdup(class);
idef->icon_file = Estrdup(file);
AddItem(idef, "", 0, LIST_TYPE_ICONDEF);
}
static void
IB_RemoveIcondef(Icondef * idef)
{
/* remove the pointed to icondef from our database */
Icondef *idef2;
idef2 = RemoveItem((char *)idef, 0, LIST_FINDBY_POINTER, LIST_TYPE_ICONDEF);
if (!idef2)
return;
if (idef->title_match)
Efree(idef->title_match);
if (idef->name_match)
Efree(idef->name_match);
if (idef->class_match)
Efree(idef->class_match);
if (idef->icon_file)
Efree(idef->icon_file);
Efree(idef);
}
static time_t last_icondefs_time = 0;
static void
IB_LoadIcondefs(void)
{
/* load the icon defs */
char *ff = NULL, s[1024], *s1, *s2, *s3, *s4;
FILE *f;
ff = ThemeFileFind("icondefs.cfg");
if (!ff)
return;
f = fopen(ff, "r");
while (fgets(s, 1024, f))
{
s[strlen(s) - 1] = 0;
/* file format : */
/* "icon/image.png" "*title*" "*name*" "*class*" */
/* any field except field 1 can be NULL if you dont care */
/* the default match is: */
/* "icon/defailt_image.png" NULL NULL NULL */
/* and must be first in the file */
s1 = field(s, 0);
s2 = field(s, 1);
s3 = field(s, 2);
s4 = field(s, 3);
if (s1)
IB_AddIcondef(s2, s3, s4, s1);
if (s1)
Efree(s1);
if (s2)
Efree(s2);
if (s3)
Efree(s3);
if (s4)
Efree(s4);
}
fclose(f);
last_icondefs_time = moddate(ff);
Efree(ff);
}
static void
IB_ReLoadIcondefs(void)
{
/* stat the icondefs and compare mod date to last known mod date - if */
/* modified, delete all icondefs and load again */
char *ff = NULL;
Icondef **idef;
int i, num;
ff = ThemeFileFind("icondefs.cfg");
if (!ff)
{
idef = IB_ListIcondef(&num);
if (idef)
{
for (i = 0; i < num; i++)
IB_RemoveIcondef(idef[i]);
Efree(idef);
}
return;
}
if (moddate(ff) > last_icondefs_time)
{
idef = IB_ListIcondef(&num);
if (idef)
{
for (i = 0; i < num; i++)
IB_RemoveIcondef(idef[i]);
Efree(idef);
}
IB_LoadIcondefs();
}
Efree(ff);
}
static void
IcondefChecker(int val __UNUSED__, void *data __UNUSED__)
{
IB_ReLoadIcondefs();
DoIn("ICONDEF_CHECK", 2.0, IcondefChecker, 0, NULL);
}
#if 0 /* Not used */
static void
IB_SaveIcondefs(void)
{
/* save the icondefs */
char s[1024];
FILE *f;
Esnprintf(s, sizeof(s), "%s/icondefs.cfg", EDirUser());
f = fopen(s, "w");
if (f)
{
Icondef **idef;
int i, num;
idef = IB_ListIcondef(&num);
for (i = num - 1; i >= 0; i--)
{
char *f1, *f2, *f3, *f4;
f1 = idef[i]->icon_file;
f2 = idef[i]->title_match;
f3 = idef[i]->name_match;
f4 = idef[i]->class_match;
if (f1)
{
fprintf(f, "\"%s\" ", f1);
if (f2)
fprintf(f, "\"%s\" ", f2);
else
fprintf(f, "NULL ");
if (f3)
fprintf(f, "\"%s\" ", f3);
else
fprintf(f, "NULL ");
if (f4)
fprintf(f, "\"%s\"\n", f4);
else
fprintf(f, "NULL\n");
}
}
fclose(f);
last_icondefs_time = moddate(s);
}
}
#endif
static Iconbox **
IconboxesList(int *num)
{
@ -2280,7 +2048,6 @@ IconboxesShow(void)
int i, num;
Iconbox **ibl;
IcondefChecker(0, NULL);
ibl = IconboxesList(&num);
if (ibl)
{
@ -3132,11 +2899,10 @@ IconboxesSighan(int sig, void *prm)
switch (sig)
{
case ESIGNAL_CONFIGURE:
IconboxesConfigLoad();
IconboxesShow();
break;
case ESIGNAL_START:
/* We should create one if enabled and none existing */
IconboxesConfigLoad();
IconboxesShow();
break;
#if 0
case ESIGNAL_EXIT:

View File

@ -473,18 +473,29 @@ IPC_WinList(const char *params, Client * c __UNUSED__)
case '\0':
IpcPrintf("%#lx : %s\n", e->client.win, SS(e->icccm.wm_name));
break;
default:
IpcPrintf("%#lx : %s :: %d : %d %d : %d %d %dx%d\n",
e->client.win, SS(e->icccm.wm_name),
(EoIsSticky(e)) ? -1 : EoGetDesk(e), e->area_x,
e->area_y, EoGetX(e), EoGetY(e), EoGetW(e), EoGetH(e));
break;
case 'a':
IpcPrintf("%#10lx : %4d %4d %4dx%4d :: %2d : %d %d : %s\n",
e->client.win, EoGetX(e), EoGetY(e), EoGetW(e),
EoGetH(e), (EoIsSticky(e)) ? -1 : EoGetDesk(e),
e->area_x, e->area_y, SS(e->icccm.wm_name));
break;
case 'p':
IpcPrintf("%#10lx : %4d %4d %4dx%4d :: %2d : \"%s\" \"%s\" %s\n",
e->client.win,
EoGetX(e), EoGetY(e), EoGetW(e), EoGetH(e),
(EoIsSticky(e)) ? -1 : EoGetDesk(e),
SS(e->icccm.wm_res_name), SS(e->icccm.wm_res_class),
SS(e->icccm.wm_name));
break;
}
}
if (num <= 0)

View File

@ -52,6 +52,7 @@ extern EModule ModTheme;
extern EModule ModTooltips;
extern EModule ModTransparency;
extern EModule ModWarplist;
extern EModule ModWindowMatch;
const EModule *p_modules[] = {
&ModDesktops,
@ -78,6 +79,7 @@ const EModule *p_modules[] = {
&ModTooltips,
&ModTransparency,
&ModWarplist,
&ModWindowMatch,
};
int n_modules = sizeof(p_modules) / sizeof(EModule *);

View File

@ -34,7 +34,6 @@ struct _pager
char visible;
int update_phase;
EWin *ewin;
char *border_name;
Window sel_win;
char hi_visible;
Window hi_win;
@ -97,7 +96,6 @@ PagerCreate(void)
p->visible = 0;
p->update_phase = 0;
p->ewin = NULL;
p->border_name = NULL;
p->sel_win = ECreateWindow(p->win, 0, 0, p->w / ax, p->h / ay, 0);
pq = Mode.queue_up;
Mode.queue_up = 0;
@ -125,8 +123,6 @@ PagerDestroy(Pager * p)
if (p->pmap)
ecore_x_pixmap_del(p->pmap);
FreePmapMask(&p->bgpmap);
if (p->border_name)
Efree(p->border_name);
Efree(p);
}
@ -605,8 +601,7 @@ PagerShow(Pager * p)
pq = Mode.queue_up;
Mode.queue_up = 0;
ewin = AddInternalToFamily(p->win, (p->border_name) ? p->border_name :
"PAGER", EWIN_TYPE_PAGER, p, PagerEwinInit);
ewin = AddInternalToFamily(p->win, NULL, EWIN_TYPE_PAGER, p, PagerEwinInit);
if (ewin)
{
int ax, ay, w, h;
@ -2190,6 +2185,8 @@ PagersSighan(int sig, void *prm)
EDirMake(EDirUserCache(), "cached/pager");
break;
case ESIGNAL_CONFIGURE:
break;
case ESIGNAL_START:
if (!Conf.pagers.enable)
break;
Conf.pagers.enable = 0;

View File

@ -296,22 +296,15 @@ MatchEwinToSM(EWin * ewin)
void
autosave(void)
{
char s[4096];
if (!Mode.wm.save_ok || !Conf.autosave)
return;
if (EventDebug(EDBUG_TYPE_SESSION))
Eprintf("autosave: save %s\n", EGetSavePrefix());
Eprintf("autosave\n");
Real_SaveSnapInfo(0, NULL);
Etmp(s);
SaveUserControlConfig(s);
E_mv(s, EGetSavePrefix());
if (!isfile(EGetSavePrefix()))
Alert(_("There was an error saving your autosave data - filing\n"
"system problems.\n"));
SaveUserControlConfig();
}
#ifdef HAVE_X11_SM_SMLIB_H

View File

@ -32,20 +32,15 @@ static const char *const theme_files[] = {
#if ENABLE_THEME_SANITY_CHECKING
"borders.cfg",
"buttons.cfg",
"colormodifiers.cfg",
"control.cfg",
"cursors.cfg",
"desktops.cfg",
"imageclasses.cfg",
#endif
"init.cfg",
#if ENABLE_THEME_SANITY_CHECKING
"menus.cfg",
"menustyles.cfg",
"slideouts.cfg",
"sound.cfg",
"tooltips.cfg",
"windowmatches.cfg",
#endif
NULL
};

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2000-2004 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2005 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -23,36 +24,80 @@
#include "E.h"
#include "conf.h"
struct _windowmatch
{
char *name;
/* Match criteria */
char match;
char op;
char prop;
char qual;
char *value;
Constraints width;
Constraints height;
/* Match actions */
char *args;
Border *border;
};
#define MATCH_TYPE_TITLE 1
#define MATCH_TYPE_WM_NAME 2
#define MATCH_TYPE_WM_CLASS 3
#define MATCH_TYPE_SIZE 4
#define MATCH_TYPE_SIZE_H 5
#define MATCH_TYPE_SIZE_V 6
#define MATCH_TYPE_PROP 7
#define MATCH_PROP_TRANSIENT 1
#define MATCH_PROP_SHAPED 2
#define MATCH_PROP_FIXEDSIZE 3
#define MATCH_PROP_FIXEDSIZE_H 4
#define MATCH_PROP_FIXEDSIZE_V 5
#define MATCH_OP_BORDER 1
#define MATCH_OP_ICON 2
#define MATCH_OP_WINOP 3
const char *MatchType[] = {
NULL, "Title", "Name", "Class", "Size", "Width", "Height", "Prop", NULL
};
const char *MatchProp[] = {
NULL, "Transient", "Shaped", "FixedSize", "FixedWidth", "FixedHeight", NULL
};
const char *MatchOp[] = {
NULL, "Border", "Icon", "Winop", NULL
};
static int
MatchFind(const char **list, const char *str)
{
int i;
for (i = 1; list[i]; i++)
if (!strcmp(str, list[i]))
return i;
return 0;
}
static WindowMatch *
WindowMatchCreate(const char *name)
{
WindowMatch *b;
b = Emalloc(sizeof(WindowMatch));
b = Ecalloc(1, sizeof(WindowMatch));
if (!b)
return NULL;
b->name = Estrdup(name);
b->win_title = NULL;
b->win_name = NULL;
b->win_class = NULL;
b->width.min = 0;
b->width.max = 99999;
b->height.min = 0;
b->height.max = 99999;
b->transient = -1;
b->no_resize_h = -1;
b->no_resize_v = -1;
b->shaped = -1;
b->border = NULL;
b->icon = NULL;
b->desk = 0;
b->make_sticky = 0;
return b;
}
#if 0
static void
WindowMatchDestroy(WindowMatch * wm)
{
@ -61,26 +106,23 @@ WindowMatchDestroy(WindowMatch * wm)
while (RemoveItemByPtr(wm, LIST_TYPE_WINDOWMATCH));
if (wm->icon)
wm->icon->ref_count--;
if (wm->border)
wm->border->ref_count--;
if (wm->name)
Efree(wm->name);
if (wm->win_title)
Efree(wm->win_title);
if (wm->win_name)
Efree(wm->win_name);
if (wm->win_class)
Efree(wm->win_class);
}
#endif
if (wm->value)
Efree(wm->value);
if (wm->border)
BorderDecRefcount(wm->border);
if (wm->args)
Efree(wm->args);
int
Efree(wm);
}
static int
WindowMatchConfigLoad(FILE * fs)
{
int err = 0;
WindowMatch *bm = 0;
WindowMatch *wm = 0;
char s[FILEPATH_LEN_MAX];
char s2[FILEPATH_LEN_MAX];
int i1;
@ -102,76 +144,135 @@ WindowMatchConfigLoad(FILE * fs)
else if (i1 != CONFIG_INVALID)
{
if (fields != 2)
{
Alert(_("CONFIG: missing required data in \"%s\"\n"), s);
}
Alert(_("CONFIG: missing required data in \"%s\"\n"), s);
}
switch (i1)
{
case CONFIG_CLOSE:
AddItem(bm, bm->name, 0, LIST_TYPE_WINDOWMATCH);
goto done;
case CONFIG_CLASSNAME:
bm = WindowMatchCreate(s2);
case CONFIG_VERSION:
case CONFIG_WINDOWMATCH:
err = -1;
break;
case CONFIG_BORDER:
case WINDOWMATCH_USEBORDER:
bm->border = FindItem(s2, 0, LIST_FINDBY_NAME, LIST_TYPE_BORDER);
if (bm->border)
bm->border->ref_count++;
case CONFIG_CLASSNAME:
wm = WindowMatchCreate(s2);
break;
case CONFIG_CLOSE:
if (!wm)
break;
if (wm->match && wm->op)
AddItemEnd(wm, wm->name, 0, LIST_TYPE_WINDOWMATCH);
else
{
WindowMatchDestroy(wm);
}
wm = NULL;
err = 0;
break;
case WINDOWMATCH_MATCHTITLE:
if (!wm)
break;
wm->match = MATCH_TYPE_TITLE;
wm->value = Estrdup(atword(s, 2));
break;
case WINDOWMATCH_MATCHNAME:
bm->win_name = Estrdup(atword(s, 2));
if (!wm)
break;
wm->match = MATCH_TYPE_WM_NAME;
wm->value = Estrdup(atword(s, 2));
break;
case WINDOWMATCH_MATCHCLASS:
bm->win_class = Estrdup(atword(s, 2));
break;
case WINDOWMATCH_MATCHTITLE:
bm->win_title = Estrdup(atword(s, 2));
if (!wm)
break;
wm->match = MATCH_TYPE_WM_CLASS;
wm->value = Estrdup(atword(s, 2));
break;
#if 0 /* FIXME */
case WINDOWMATCH_DESKTOP:
case CONFIG_DESKTOP:
bm->desk = atoi(s2);
wm->desk = atoi(s2);
break;
case WINDOWMATCH_ICON:
case CONFIG_ICONBOX:
bm->icon = ImageclassFind(s2, 0);
if (bm->icon)
bm->icon->ref_count++;
wm->icon = ImageclassFind(s2, 0);
if (wm->icon)
wm->icon->ref_count++;
break;
case WINDOWMATCH_WIDTH:
{
char s3[FILEPATH_LEN_MAX];
#endif
sscanf(s, "%*s %4000s %4000s", s2, s3);
bm->width.min = atoi(s2);
bm->width.max = atoi(s3);
}
case WINDOWMATCH_WIDTH:
if (!wm)
break;
if (wm->match == MATCH_TYPE_SIZE_V)
wm->match = MATCH_TYPE_SIZE;
else
wm->match = MATCH_TYPE_SIZE_H;
sscanf(s, "%*s %u %u", &(wm->width.min), &(wm->width.max));
break;
case WINDOWMATCH_HEIGHT:
{
char s3[FILEPATH_LEN_MAX];
if (!wm)
break;
if (wm->match == MATCH_TYPE_SIZE_H)
wm->match = MATCH_TYPE_SIZE;
else
wm->match = MATCH_TYPE_SIZE_V;
sscanf(s, "%*s %u %u", &(wm->height.min), &(wm->height.max));
break;
sscanf(s, "%*s %4000s %4000s", s2, s3);
bm->height.min = atoi(s2);
bm->height.max = atoi(s3);
}
break;
case WINDOWMATCH_TRANSIENT:
bm->transient = atoi(s2);
break;
case WINDOWMATCH_NO_RESIZE_H:
bm->no_resize_h = atoi(s2);
break;
case WINDOWMATCH_NO_RESIZE_V:
bm->no_resize_v = atoi(s2);
if (!wm)
break;
wm->match = MATCH_TYPE_PROP;
wm->prop = MATCH_PROP_TRANSIENT;
wm->qual = !atoi(s2);
break;
case WINDOWMATCH_SHAPED:
bm->shaped = atoi(s2);
if (!wm)
break;
wm->match = MATCH_TYPE_PROP;
wm->prop = MATCH_PROP_SHAPED;
wm->qual = !atoi(s2);
break;
case WINDOWMATCH_NO_RESIZE_H:
if (!wm)
break;
wm->match = MATCH_TYPE_PROP;
if (wm->prop == MATCH_PROP_FIXEDSIZE_V)
wm->prop = MATCH_PROP_FIXEDSIZE;
else
wm->prop = MATCH_PROP_FIXEDSIZE_H;
wm->qual = !atoi(s2);
break;
case WINDOWMATCH_NO_RESIZE_V:
if (!wm)
break;
wm->match = MATCH_TYPE_PROP;
if (wm->prop == MATCH_PROP_FIXEDSIZE_H)
wm->prop = MATCH_PROP_FIXEDSIZE;
else
wm->prop = MATCH_PROP_FIXEDSIZE_V;
wm->qual = !atoi(s2);
break;
case CONFIG_BORDER:
case WINDOWMATCH_USEBORDER:
if (!wm)
break;
wm->border = FindItem(s2, 0, LIST_FINDBY_NAME, LIST_TYPE_BORDER);
if (!wm->border)
break;
wm->op = MATCH_OP_BORDER;
BorderIncRefcount(wm->border);
break;
case WINDOWMATCH_MAKESTICKY:
bm->make_sticky = atoi(s2);
if (!wm)
break;
wm->args = Estrdupcat2(wm->args, ":", "stick");
break;
default:
Alert(_("Warning: unable to determine what to do with\n"
"the following text in the middle of current "
@ -180,119 +281,438 @@ WindowMatchConfigLoad(FILE * fs)
break;
}
}
err = -1;
done:
return err;
}
static int
WindowMatchTest(EWin * ewin, WindowMatch * b)
static WindowMatch *
WindowMatchDecode(const char *line)
{
char match[32], value[1024], op[32], args[1024];
WindowMatch *wm = NULL;
int err, num, a, b;
if ((b->win_title) && (ewin->icccm.wm_name)
&& (!matchregexp(b->win_title, ewin->icccm.wm_name)))
return 0;
match[0] = value[0] = op[0] = args[0] = '\0';
num = sscanf(line, "%32s %1024s %32s %1024s", match, value, op, args);
if (num < 4)
return NULL;
if ((b->win_name) && (ewin->icccm.wm_res_name)
&& (!matchregexp(b->win_name, ewin->icccm.wm_res_name)))
return 0;
#if 0
Eprintf("-- %s\n", s);
Eprintf("++ %s %s %s %s\n", match, value, op, args);
#endif
if ((b->win_class) && (ewin->icccm.wm_res_class)
&& (!matchregexp(b->win_class, ewin->icccm.wm_res_class)))
return 0;
err = 0;
if ((ewin->client.w > b->width.max) || (ewin->client.w < b->width.min))
return 0;
num = MatchFind(MatchType, match);
if (num <= 0)
{
Eprintf("WindowMatchDecode: Error (%s): %s\n", match, line);
err = 1;
goto done;
}
if ((ewin->client.h > b->height.max) || (ewin->client.h < b->height.min))
return 0;
wm = WindowMatchCreate(NULL);
if (!wm)
return NULL;
if ((b->transient >= 0) && (b->transient != ewin->client.transient))
return 0;
wm->match = num;
if ((b->no_resize_h >= 0) && (b->no_resize_h != ewin->client.no_resize_h))
return 0;
switch (wm->match)
{
case MATCH_TYPE_TITLE:
case MATCH_TYPE_WM_NAME:
case MATCH_TYPE_WM_CLASS:
wm->value = Estrdup(value);
break;
if ((b->no_resize_v >= 0) && (b->no_resize_v != ewin->client.no_resize_v))
return 0;
case MATCH_TYPE_SIZE:
num = sscanf(value, "%c%ux%u", match, &a, &b);
if (num < 3)
goto case_error;
if (*match == '<')
wm->qual = 1;
else if (*value == '>')
wm->qual = 0;
else
goto case_error;
wm->width.max = a;
wm->height.max = b;
break;
case MATCH_TYPE_SIZE_H:
num = sscanf(value, "%u-%u", &a, &b);
if (num < 2)
goto case_error;
wm->width.min = a;
wm->width.max = b;
break;
case MATCH_TYPE_SIZE_V:
num = sscanf(value, "%u-%u", &a, &b);
if (num < 2)
goto case_error;
wm->height.min = a;
wm->height.max = b;
break;
if ((b->shaped >= 0) && (b->shaped != ewin->client.shaped))
return 0;
case MATCH_TYPE_PROP:
num = 0;
if (*value == '!')
{
wm->qual = 1;
num = 1;
}
wm->prop = MatchFind(MatchProp, value + num);
if (wm->prop <= 0)
goto case_error;
break;
return 1;
case_error:
Eprintf("WindowMatchDecode: Error (%s): %s\n", value, line);
err = 1;
goto done;
}
wm->op = MatchFind(MatchOp, op);
if (wm->op <= 0)
{
Eprintf("WindowMatchDecode: Error (%s): %s\n", op, line);
err = 1;
goto done;
}
switch (wm->op)
{
case MATCH_OP_BORDER:
wm->border = FindItem(args, 0, LIST_FINDBY_NAME, LIST_TYPE_BORDER);
if (!wm->border)
{
err = 1;
goto done;
}
BorderIncRefcount(wm->border);
break;
case MATCH_OP_ICON:
wm->args = Estrdup(args);
break;
case MATCH_OP_WINOP:
wm->args = Estrdup(args);
break;
}
done:
if (err)
{
if (wm)
WindowMatchDestroy(wm);
}
else
{
AddItemEnd(wm, wm->name, 0, LIST_TYPE_WINDOWMATCH);
}
return wm;
}
static char *
WindowMatchEncode(WindowMatch * wm, char *buf, int len)
{
char s[1024];
const char *qual, *value, *args;
qual = " ";
switch (wm->match)
{
default:
value = wm->value;
break;
case MATCH_TYPE_SIZE:
value = s;
qual = (wm->qual) ? "<" : ">";
sprintf(s, "%ux%u", wm->width.max, wm->height.max);
break;
case MATCH_TYPE_SIZE_H:
value = s;
sprintf(s, "%u-%u", wm->width.min, wm->width.max);
break;
case MATCH_TYPE_SIZE_V:
value = s;
sprintf(s, "%u-%u", wm->height.min, wm->height.max);
break;
case MATCH_TYPE_PROP:
qual = (wm->qual) ? "!" : " ";
value = MatchProp[(int)wm->prop];
break;
}
switch (wm->op)
{
default:
args = wm->args;
break;
case MATCH_OP_BORDER:
args = BorderGetName(wm->border);
break;
}
Esnprintf(buf, len, "%-8s %s%-16s %s %s", MatchType[(int)wm->match],
qual, value, MatchOp[(int)wm->op], args);
return buf;
}
static void
WindowMatchConfigLoad2(FILE * fs)
{
char s[FILEPATH_LEN_MAX], *ss;
int len;
for (;;)
{
ss = fgets(s, sizeof(s), fs);
if (!ss)
break;
len = strcspn(s, "#\r\n");
if (len <= 0)
continue;
s[len] = '\0';
WindowMatchDecode(s);
}
}
static void
WindowMatchConfigLoadConfig(void)
{
char *file;
FILE *fs;
file = ConfigFileFind("matches.cfg", NULL, 0);
if (!file)
return;
fs = fopen(file, "r");
Efree(file);
if (!fs)
return;
WindowMatchConfigLoad2(fs);
fclose(fs);
}
static int
WindowMatchTest(const EWin * ewin, const WindowMatch * wm)
{
int match;
match = 0;
switch (wm->match)
{
case MATCH_TYPE_TITLE:
return matchregexp(wm->value, ewin->icccm.wm_name);
case MATCH_TYPE_WM_NAME:
return matchregexp(wm->value, ewin->icccm.wm_res_name);
case MATCH_TYPE_WM_CLASS:
return matchregexp(wm->value, ewin->icccm.wm_res_class);
case MATCH_TYPE_SIZE:
match = (ewin->client.w >= wm->width.min &&
ewin->client.w <= wm->width.max &&
ewin->client.h >= wm->height.min &&
ewin->client.h <= wm->height.max);
break;
case MATCH_TYPE_SIZE_H:
match = (ewin->client.w >= wm->width.min &&
ewin->client.w <= wm->width.max);
break;
case MATCH_TYPE_SIZE_V:
match = (ewin->client.h >= wm->height.min &&
ewin->client.h <= wm->height.max);
break;
case MATCH_TYPE_PROP:
switch (wm->prop)
{
case MATCH_PROP_TRANSIENT:
match = ewin->client.transient;
break;
case MATCH_PROP_SHAPED:
match = ewin->client.shaped;
break;
case MATCH_PROP_FIXEDSIZE:
match = ewin->client.no_resize_h && ewin->client.no_resize_v;
break;
case MATCH_PROP_FIXEDSIZE_H:
match = ewin->client.no_resize_h;
break;
case MATCH_PROP_FIXEDSIZE_V:
match = ewin->client.no_resize_v;
break;
}
}
if (wm->qual)
match = !match;
return match;
}
static WindowMatch *
WindowMatchType(const EWin * ewin, int type)
{
WindowMatch **lst, *wm;
int i, num;
lst = (WindowMatch **) ListItemType(&num, LIST_TYPE_WINDOWMATCH);
for (i = 0; i < num; i++)
{
wm = lst[i];
switch (type)
{
default:
continue;
case MATCH_OP_BORDER:
if (!wm->border)
continue;
break;
case MATCH_OP_ICON:
case MATCH_OP_WINOP:
if (!wm->args)
continue;
break;
}
if (!WindowMatchTest(ewin, lst[i]))
continue;
goto done;
}
wm = NULL;
done:
if (lst)
Efree(lst);
return wm;
}
Border *
MatchEwinBorder(EWin * ewin, WindowMatch * b)
WindowMatchEwinBorder(const EWin * ewin)
{
if (WindowMatchTest(ewin, b))
{
if (b->make_sticky)
EoSetSticky(ewin, 1);
WindowMatch *wm;
return b->border;
}
else
wm = WindowMatchType(ewin, MATCH_OP_BORDER);
#if 0
Eprintf("WindowMatchEwinBorder %s %s\n", EwinGetName(ewin),
(wm) ? BorderGetName(wm->border) : "???");
#endif
if (wm)
return wm->border;
return NULL;
}
const char *
WindowMatchEwinIcon(const EWin * ewin)
{
WindowMatch *wm;
wm = WindowMatchType(ewin, MATCH_OP_ICON);
#if 0
Eprintf("WindowMatchEwinIcon %s %s\n", EwinGetName(ewin),
(wm) ? wm->args : "???");
#endif
if (wm)
return wm->args;
return NULL;
}
/*
* Winmatch module
*/
static void
WindowMatchSighan(int sig, void *prm __UNUSED__)
{
switch (sig)
{
return 0;
case ESIGNAL_CONFIGURE:
#if 1
ConfigFileLoad("windowmatches.cfg", Mode.theme.path,
WindowMatchConfigLoad);
#endif
WindowMatchConfigLoadConfig();
#if 0
WindowMatchConfigLoadUser();
#endif
#if 0
IcondefChecker(0, NULL);
#endif
break;
case ESIGNAL_EXIT:
break;
}
}
ImageClass *
MatchEwinIcon(EWin * ewin, WindowMatch * b)
static void
WindowMatchIpc(const char *params, Client * c __UNUSED__)
{
if (WindowMatchTest(ewin, b))
{
if (b->make_sticky)
EoSetSticky(ewin, 1);
const char *p;
char cmd[128], prm[4096], buf[4096];
int i, len, num;
return b->icon;
cmd[0] = prm[0] = '\0';
p = params;
if (p)
{
len = 0;
sscanf(p, "%100s %4000s %n", cmd, prm, &len);
p += len;
}
else
if (!p || cmd[0] == '?')
{
return 0;
}
}
int
MatchEwinDesktop(EWin * ewin, WindowMatch * b)
{
if (WindowMatchTest(ewin, b))
else if (!strncmp(cmd, "list", 2))
{
if (b->make_sticky)
EoSetSticky(ewin, 1);
WindowMatch **lst;
return b->desk;
}
else
{
return 0;
}
}
void *
MatchEwinByFunction(EWin * ewin,
void *(*FunctionToTest) (EWin *, WindowMatch *))
{
WindowMatch **lst;
int i, num;
void *retval;
retval = 0;
lst = (WindowMatch **) ListItemType(&num, LIST_TYPE_WINDOWMATCH);
if (lst)
{
lst = (WindowMatch **) ListItemType(&num, LIST_TYPE_WINDOWMATCH);
for (i = 0; i < num; i++)
{
if ((retval = (*FunctionToTest) (ewin, lst[i])))
{
i = num;
}
}
Efree(lst);
IpcPrintf("%s\n", WindowMatchEncode(lst[i], buf, sizeof(buf)));
if (lst)
Efree(lst);
}
return retval;
}
IpcItem WindowMatchIpcArray[] = {
{
WindowMatchIpc,
"wmatch", "wma",
"Window match functions",
" wmatch list List window matches\n"}
,
};
#define N_IPC_FUNCS (sizeof(WindowMatchIpcArray)/sizeof(IpcItem))
/*
* Module descriptor
*/
EModule ModWindowMatch = {
"winmatch", NULL,
WindowMatchSighan,
{N_IPC_FUNCS, WindowMatchIpcArray}
,
{0, NULL}
};