Fix focuslist icons interfering with iconbox ones.

SVN revision: 14937
This commit is contained in:
Kim Woelders 2005-05-25 21:42:59 +00:00
parent de75c9efd8
commit 664095e0d6
7 changed files with 300 additions and 249 deletions

View File

@ -745,7 +745,7 @@ struct _ewin
PmapMask mini_pmm;
int mini_w, mini_h;
Snapshot *snap;
Imlib_Image *icon_image;
Imlib_Image *icon_image[3];
int icon_type;
int head;
struct
@ -1887,9 +1887,6 @@ void ITApply(Window win, ImageClass * ic, ImageState * is, int w,
char expose, int image_type, TextClass * tc,
TextState * ts, const char *text);
/* iconify.c */
void UpdateAppIcon(EWin * ewin, int imode);
/* ipc.c */
void __PRINTF__ IpcPrintf(const char *fmt, ...);
int HandleIPC(const char *params, Client * c);

View File

@ -22,6 +22,7 @@ e16_SOURCES = \
ecore-e16.h \
emodule.h \
ewin-ops.h \
icons.h \
snaps.h \
timestamp.h \
aclass.c \
@ -63,6 +64,7 @@ e16_SOURCES = \
icccm.c \
iclass.c \
iconify.c \
icons.c \
ipc.c \
lang.c \
lists.c \

View File

@ -23,6 +23,7 @@
*/
#include "E.h"
#include "ecompmgr.h"
#include "icons.h"
#include "snaps.h"
#include <sys/time.h>
@ -249,11 +250,7 @@ EwinDestroy(EWin * ewin)
if (ewin->session_id)
Efree(ewin->session_id);
FreePmapMask(&ewin->mini_pmm);
if (ewin->icon_image)
{
imlib_context_set_image(ewin->icon_image);
imlib_free_image_and_decache();
}
EwinIconImageFree(ewin);
GroupsEwinRemove(ewin);
Efree(ewin);
}

View File

@ -23,15 +23,9 @@
*/
#include "E.h"
#include "ecore-e16.h"
#include "icons.h"
#include <math.h>
typedef enum
{
EWIN_ICON_TYPE_APP,
EWIN_ICON_TYPE_IMG,
EWIN_ICON_TYPE_SNAP
} ewin_icon_e;
typedef struct _iconbox Iconbox;
static void IconboxesConfigSave(void);
@ -675,13 +669,14 @@ IconboxesEwinIconify(EWin * ewin)
SoundPlay("SOUND_ICONIFY");
ib = SelectIconboxForEwin(ewin);
if (ib)
{
if (ib->animate && !ewin->st.showingdesk)
IB_Animate(1, ewin, ib->ewin);
UpdateAppIcon(ewin, ib->icon_mode);
IconboxObjEwinAdd(ib, ewin);
}
if (!ib)
return;
EwinIconImageGet(ewin, ib->iconsize, ib->icon_mode, 1);
IconboxObjEwinAdd(ib, ewin);
if (ib->animate && !ewin->st.showingdesk)
IB_Animate(1, ewin, ib->ewin);
}
static void
@ -710,130 +705,6 @@ RemoveMiniIcon(EWin * ewin)
IconboxObjEwinDel(ib, ewin);
}
static void
IB_SnapEWin(EWin * ewin)
{
/* Make snapshot of window */
int w, h, ww, hh, scale;
Iconbox *ib;
Imlib_Image *im;
Drawable draw;
if (!EwinIsMapped(ewin))
return;
ww = EoGetW(ewin);
hh = EoGetH(ewin);
if (ww <= 0 || hh <= 0)
return;
w = 40;
h = 40;
ib = SelectIconboxForEwin(ewin);
if (ib)
{
w = ib->iconsize;
h = ib->iconsize;
}
/* Oversample for nicer snapshots */
scale = 4;
w *= scale;
h *= scale;
if (ww > hh)
h = (w * hh) / ww;
else
w = (h * ww) / hh;
if (w < 4)
w = 4;
if (h < 4)
h = 4;
if (w > ww || h > hh)
{
w = ww;
h = hh;
}
#if USE_COMPOSITE
draw = EoGetPixmap(ewin);
if (draw != None)
{
Pixmap mask;
mask = EWindowGetShapePixmap(EoGetWin(ewin));
imlib_context_set_drawable(draw);
im = imlib_create_scaled_image_from_drawable(mask, 0, 0, ww, hh,
w, h, !EServerIsGrabbed(),
0);
imlib_context_set_image(im);
imlib_image_set_has_alpha(1); /* Should be set by imlib? */
}
else
#endif
{
draw = EoGetWin(ewin);
imlib_context_set_drawable(draw);
im = imlib_create_scaled_image_from_drawable(None, 0, 0, ww, hh,
w, h, !EServerIsGrabbed(),
1);
imlib_context_set_image(im);
imlib_image_set_has_alpha(1); /* Should be set by imlib? */
}
ewin->icon_image = im;
ewin->icon_type = EWIN_ICON_TYPE_SNAP;
}
static void
IB_GetAppIcon(EWin * ewin)
{
/* Get the applications icon pixmap/mask */
int x, y;
unsigned int w, h, depth, bw;
Window rt;
Imlib_Image im;
if (!ewin->client.icon_pmap)
return;
w = 0;
h = 0;
XGetGeometry(disp, ewin->client.icon_pmap, &rt, &x, &y, &w, &h, &bw, &depth);
if (w < 1 || h < 1)
return;
imlib_context_set_colormap(None);
imlib_context_set_drawable(ewin->client.icon_pmap);
im = imlib_create_image_from_drawable(ewin->client.icon_mask, 0, 0, w, h,
!EServerIsGrabbed());
imlib_context_set_image(im);
imlib_image_set_has_alpha(1); /* Should be set by imlib? */
imlib_context_set_colormap(VRoot.cmap);
imlib_context_set_drawable(VRoot.win);
ewin->icon_image = im;
ewin->icon_type = EWIN_ICON_TYPE_APP;
}
static void
IB_GetEIcon(EWin * ewin)
{
/* get the icon defined for this window in E's iconf match file */
const char *file;
Imlib_Image *im;
file = WindowMatchEwinIcon(ewin);
if (!file)
return;
im = ELoadImage(file);
if (!im)
return;
ewin->icon_image = im;
ewin->icon_type = EWIN_ICON_TYPE_IMG;
}
static Iconbox **
IconboxesList(int *num)
{
@ -915,7 +786,7 @@ IconboxUpdateEwinIcon(Iconbox * ib, EWin * ewin, int icon_mode)
if (IconboxObjEwinFind(ib, ewin) < 0)
return;
UpdateAppIcon(ewin, icon_mode);
EwinIconImageGet(ewin, ib->iconsize, icon_mode, 1);
IconboxRedraw(ib);
}
@ -934,80 +805,6 @@ IconboxesUpdateEwinIcon(EWin * ewin, int icon_mode)
Efree(ib);
}
void
UpdateAppIcon(EWin * ewin, int imode)
{
/* free whatever we had before */
if (ewin->icon_image)
{
imlib_context_set_image(ewin->icon_image);
imlib_free_image();
ewin->icon_image = NULL;
}
switch (imode)
{
case 0:
/* snap first - if fails try app, then e */
if (!ewin->icon_image)
{
if (ewin->shaded)
EwinInstantUnShade(ewin);
RaiseEwin(ewin);
IB_SnapEWin(ewin);
}
if (!ewin->icon_image)
IB_GetAppIcon(ewin);
if (!ewin->icon_image)
IB_GetEIcon(ewin);
break;
case 1:
/* try app first, then e, then snap */
if (!ewin->icon_image)
IB_GetAppIcon(ewin);
if (!ewin->icon_image)
IB_GetEIcon(ewin);
if (!ewin->icon_image)
{
if (ewin->shaded)
EwinInstantUnShade(ewin);
RaiseEwin(ewin);
IB_SnapEWin(ewin);
}
break;
case 2:
/* try E first, then snap, then app */
if (!ewin->icon_image)
IB_GetEIcon(ewin);
if (!ewin->icon_image)
{
if (ewin->shaded)
EwinInstantUnShade(ewin);
RaiseEwin(ewin);
IB_SnapEWin(ewin);
}
if (!ewin->icon_image)
IB_GetAppIcon(ewin);
break;
case 3:
/* try E first, then app */
if (!ewin->icon_image)
IB_GetEIcon(ewin);
if (!ewin->icon_image)
IB_GetAppIcon(ewin);
break;
case 4:
/* try app first, then E */
if (!ewin->icon_image)
IB_GetAppIcon(ewin);
if (!ewin->icon_image)
IB_GetEIcon(ewin);
break;
default:
break;
}
}
static void
IconboxFindIconSize(Imlib_Image * im, int *pw, int *ph, int size)
{
@ -1091,13 +888,13 @@ IconboxLayoutImageWin(Iconbox * ib)
if (ib->type == IB_TYPE_ICONBOX)
{
EWin *ewin;
Imlib_Image *im;
ewin = ibo->u.ewin;
if (!ewin->icon_image)
UpdateAppIcon(ewin, ib->icon_mode);
im = EwinIconImageGet(ewin, ib->iconsize, ib->icon_mode, 0);
wi = hi = 8;
if (ewin->icon_image)
IconboxFindIconSize(ewin->icon_image, &wi, &hi, ib->iconsize);
if (im)
IconboxFindIconSize(im, &wi, &hi, ib->iconsize);
}
else
{
@ -1857,19 +1654,20 @@ IconboxDraw(Iconbox * ib)
if (ib->type == IB_TYPE_ICONBOX)
{
EWin *ewin;
Imlib_Image *ii;
ewin = ib->objs[i].u.ewin;
if (ewin->icon_image)
ii = EwinIconImageGet(ewin, ib->iconsize, ib->icon_mode, 0);
if (ii)
{
imlib_context_set_image(ewin->icon_image);
imlib_context_set_image(ii);
ww = imlib_image_get_width();
hh = imlib_image_get_height();
imlib_context_set_image(im);
imlib_context_set_anti_alias(1);
imlib_context_set_blend(1);
imlib_blend_image_onto_image(ewin->icon_image, 1,
0, 0, ww, hh,
imlib_blend_image_onto_image(ii, 1, 0, 0, ww, hh,
ibo->xi, ibo->yi, ibo->wi,
ibo->hi);
imlib_context_set_blend(0);

218
src/icons.c Normal file
View File

@ -0,0 +1,218 @@
/*
* 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
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies of the Software, its documentation and marketing & publicity
* materials, and acknowledgment shall be given in the documentation, materials
* and software packages that this Software was used.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "E.h"
#include "icons.h"
static Imlib_Image *
IB_SnapEWin(EWin * ewin, int size)
{
/* Make snapshot of window */
int w, h, ww, hh, scale;
Imlib_Image *im;
Drawable draw;
if (!EwinIsMapped(ewin))
return NULL;
ww = EoGetW(ewin);
hh = EoGetH(ewin);
if (ww <= 0 || hh <= 0)
return NULL;
if (ewin->shaded)
EwinInstantUnShade(ewin);
RaiseEwin(ewin);
w = h = size;
/* Oversample for nicer snapshots */
scale = 4;
w *= scale;
h *= scale;
if (ww > hh)
h = (w * hh) / ww;
else
w = (h * ww) / hh;
if (w < 4)
w = 4;
if (h < 4)
h = 4;
if (w > ww || h > hh)
{
w = ww;
h = hh;
}
#if USE_COMPOSITE
draw = EoGetPixmap(ewin);
if (draw != None)
{
Pixmap mask;
mask = EWindowGetShapePixmap(EoGetWin(ewin));
imlib_context_set_drawable(draw);
im = imlib_create_scaled_image_from_drawable(mask, 0, 0, ww, hh,
w, h, !EServerIsGrabbed(),
0);
imlib_context_set_image(im);
imlib_image_set_has_alpha(1); /* Should be set by imlib? */
}
else
#endif
{
draw = EoGetWin(ewin);
imlib_context_set_drawable(draw);
im = imlib_create_scaled_image_from_drawable(None, 0, 0, ww, hh,
w, h, !EServerIsGrabbed(),
1);
imlib_context_set_image(im);
imlib_image_set_has_alpha(1); /* Should be set by imlib? */
}
return im;
}
static Imlib_Image *
IB_GetAppIcon(EWin * ewin)
{
/* Get the applications icon pixmap/mask */
int x, y;
unsigned int w, h, depth, bw;
Window rt;
Imlib_Image im;
if (!ewin->client.icon_pmap)
return NULL;
w = 0;
h = 0;
XGetGeometry(disp, ewin->client.icon_pmap, &rt, &x, &y, &w, &h, &bw, &depth);
if (w < 1 || h < 1)
return NULL;
imlib_context_set_colormap(None);
imlib_context_set_drawable(ewin->client.icon_pmap);
im = imlib_create_image_from_drawable(ewin->client.icon_mask, 0, 0, w, h,
!EServerIsGrabbed());
imlib_context_set_image(im);
imlib_image_set_has_alpha(1); /* Should be set by imlib? */
imlib_context_set_colormap(VRoot.cmap);
imlib_context_set_drawable(VRoot.win);
return im;
}
static Imlib_Image *
IB_GetEIcon(EWin * ewin)
{
/* get the icon defined for this window in E's iconf match file */
const char *file;
Imlib_Image *im;
file = WindowMatchEwinIcon(ewin);
if (!file)
return NULL;
im = ELoadImage(file);
return im;
}
#define N_MODES 5
#define N_TYPES 3
static const char ewin_icon_modes[N_MODES][N_TYPES] = {
{EWIN_ICON_TYPE_SNAP, EWIN_ICON_TYPE_APP, EWIN_ICON_TYPE_IMG},
{EWIN_ICON_TYPE_APP, EWIN_ICON_TYPE_IMG, EWIN_ICON_TYPE_SNAP},
{EWIN_ICON_TYPE_IMG, EWIN_ICON_TYPE_SNAP, EWIN_ICON_TYPE_APP},
{EWIN_ICON_TYPE_IMG, EWIN_ICON_TYPE_APP, EWIN_ICON_TYPE_NONE},
{EWIN_ICON_TYPE_APP, EWIN_ICON_TYPE_IMG, EWIN_ICON_TYPE_NONE},
};
Imlib_Image *
EwinIconImageGet(EWin * ewin, int size, int mode, int update)
{
Imlib_Image *im = NULL;
int i, type;
if (mode < 0 || mode >= N_MODES)
mode = 4;
for (i = 0; i < N_TYPES; i++)
{
type = ewin_icon_modes[mode][i];
if (type >= N_TYPES)
continue;
im = ewin->icon_image[type];
if (im)
{
if (!update)
return im;
imlib_context_set_image(im);
imlib_free_image();
im = NULL;
}
switch (type)
{
default:
goto done;
case EWIN_ICON_TYPE_SNAP:
im = IB_SnapEWin(ewin, size);
break;
case EWIN_ICON_TYPE_APP:
im = IB_GetAppIcon(ewin);
break;
case EWIN_ICON_TYPE_IMG:
im = IB_GetEIcon(ewin);
break;
}
if (im)
goto done;
}
done:
if (im)
ewin->icon_image[type] = im;
return im;
}
void
EwinIconImageFree(EWin * ewin)
{
unsigned int i;
for (i = 0; i < sizeof(ewin->icon_image) / sizeof(Imlib_Image *); i++)
{
imlib_context_set_image(ewin->icon_image[i]);
imlib_free_image_and_decache();
ewin->icon_image[i] = NULL;
}
}

35
src/icons.h Normal file
View File

@ -0,0 +1,35 @@
/*
* 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
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies of the Software, its documentation and marketing & publicity
* materials, and acknowledgment shall be given in the documentation, materials
* and software packages that this Software was used.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
typedef enum
{
EWIN_ICON_TYPE_APP,
EWIN_ICON_TYPE_IMG,
EWIN_ICON_TYPE_SNAP,
EWIN_ICON_TYPE_NONE,
} ewin_icon_e;
Imlib_Image *EwinIconImageGet(EWin * ewin, int size, int mode,
int update);
void EwinIconImageFree(EWin * ewin);

View File

@ -37,6 +37,7 @@
* selected one.
*/
#include "E.h"
#include "icons.h"
#include <X11/keysym.h>
typedef struct
@ -65,6 +66,7 @@ WarpFocusShow(EWin * ewin)
int i, x, y, w, h, num, ww, hh;
static int mw, mh, tw, th;
char s[1024];
WarplistItem *wl;
tc = TextclassFind("WARPFOCUS", 0);
if (!tc)
@ -106,13 +108,13 @@ WarpFocusShow(EWin * ewin)
warplist_num++;
warplist = Erealloc(warplist,
warplist_num * sizeof(WarplistItem));
warplist[warplist_num - 1].win =
ECreateWindow(warpFocusWindow->win, 0, 0, 1, 1, 0);
EMapWindow(warplist[warplist_num - 1].win);
warplist[warplist_num - 1].ewin = lst[i];
wl = warplist + warplist_num - 1;
wl->win = ECreateWindow(warpFocusWindow->win, 0, 0, 1, 1, 0);
EMapWindow(wl->win);
wl->ewin = lst[i];
Esnprintf(s, sizeof(s), (lst[i]->iconified) ? "[%s]" : "%s",
EwinGetName(lst[i]));
warplist[warplist_num - 1].txt = strdup(s);
wl->txt = strdup(s);
TextSize(tc, 0, 0, 0, warplist[warplist_num - 1].txt, &ww,
&hh, 17);
if (ww > w)
@ -161,33 +163,35 @@ WarpFocusShow(EWin * ewin)
for (i = 0; i < warplist_num; i++)
{
if (!FindItem((char *)warplist[i].ewin, 0, LIST_FINDBY_POINTER,
LIST_TYPE_EWIN))
warplist[i].ewin = NULL;
if (warplist[i].ewin)
wl = warplist + i;
if (!FindItem((char *)wl->ewin, 0, LIST_FINDBY_POINTER, LIST_TYPE_EWIN))
wl->ewin = NULL;
if (wl->ewin)
{
int state;
state = (ewin == warplist[i].ewin) ? STATE_CLICKED : STATE_NORMAL;
state = (ewin == wl->ewin) ? STATE_CLICKED : STATE_NORMAL;
ImageclassApply(ic, warplist[i].win, mw, mh, 0, 0, state, 0,
ST_WARPLIST);
ImageclassApply(ic, wl->win, mw, mh, 0, 0, state, 0, ST_WARPLIST);
/* New icon stuff */
if (Conf.warplist.icon_mode != 0)
{
int icon_size = mh - 2 * ICON_PAD;
Imlib_Image *im;
TextDraw(tc, warplist[i].win, 0, 0, state, warplist[i].txt,
TextDraw(tc, wl->win, 0, 0, state, wl->txt,
ic->padding.left + mh, ic->padding.top,
tw, th, 0, 0);
UpdateAppIcon(warplist[i].ewin, Conf.warplist.icon_mode);
if (!warplist[i].ewin->icon_image)
im = EwinIconImageGet(wl->ewin, icon_size,
Conf.warplist.icon_mode, 1);
if (!im)
continue;
imlib_context_set_image(warplist[i].ewin->icon_image);
imlib_context_set_drawable(warplist[i].win);
imlib_context_set_image(im);
imlib_context_set_drawable(wl->win);
imlib_context_set_blend(1);
imlib_render_image_on_drawable_at_size(ic->padding.left +
ICON_PAD, ICON_PAD,
@ -196,8 +200,8 @@ WarpFocusShow(EWin * ewin)
}
else
{
TextclassApply(ic, warplist[i].win, mw, mh, 0, 0, state, 0,
tc, warplist[i].txt);
TextclassApply(ic, wl->win, mw, mh, 0, 0, state, 0,
tc, wl->txt);
}
}
}