mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 21:08:08 +01:00
enhanced icon highlighting in window switcher
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
defsdatadir = $(pkgdatadir)/Pixmaps
|
defsdatadir = $(pkgdatadir)/Pixmaps
|
||||||
|
|
||||||
defsdata_DATA = tile.tiff \
|
defsdata_DATA = tile.tiff \
|
||||||
tile.xpm
|
tile.xpm \
|
||||||
|
swtile.png
|
||||||
|
|
||||||
EXTRA_DIST = $(defsdata_DATA)
|
EXTRA_DIST = $(defsdata_DATA)
|
||||||
|
|||||||
BIN
WindowMaker/Pixmaps/swtile.png
Normal file
BIN
WindowMaker/Pixmaps/swtile.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 607 B |
@@ -131,6 +131,7 @@ int MonitorLoop(int argc, char **argv)
|
|||||||
(WTERMSIG(status) == SIGSEGV ||
|
(WTERMSIG(status) == SIGSEGV ||
|
||||||
WTERMSIG(status) == SIGBUS ||
|
WTERMSIG(status) == SIGBUS ||
|
||||||
WTERMSIG(status) == SIGILL ||
|
WTERMSIG(status) == SIGILL ||
|
||||||
|
WTERMSIG(status) == SIGABRT ||
|
||||||
WTERMSIG(status) == SIGFPE))
|
WTERMSIG(status) == SIGFPE))
|
||||||
{
|
{
|
||||||
/* If so, we check when was the last restart.
|
/* If so, we check when was the last restart.
|
||||||
|
|||||||
@@ -31,6 +31,78 @@
|
|||||||
#include "defaults.h"
|
#include "defaults.h"
|
||||||
#include "switchpanel.h"
|
#include "switchpanel.h"
|
||||||
#include "funcs.h"
|
#include "funcs.h"
|
||||||
|
#include "xinerama.h"
|
||||||
|
|
||||||
|
|
||||||
|
static char * tile_xpm[] = {
|
||||||
|
"64 64 2 1",
|
||||||
|
" c None",
|
||||||
|
". c #FFFFFF",
|
||||||
|
" ................................................. ",
|
||||||
|
" ...................................................... ",
|
||||||
|
" ......................................................... ",
|
||||||
|
" ........................................................... ",
|
||||||
|
" ............................................................ ",
|
||||||
|
" .............................................................. ",
|
||||||
|
" .............................................................. ",
|
||||||
|
"............................................................... ",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
"................................................................",
|
||||||
|
" .............................................................. ",
|
||||||
|
" .............................................................. ",
|
||||||
|
" .............................................................. ",
|
||||||
|
" ............................................................ ",
|
||||||
|
" .......................................................... ",
|
||||||
|
" ........................................................ ",
|
||||||
|
" ...................................................... ",
|
||||||
|
" ................................................ "};
|
||||||
|
|
||||||
|
|
||||||
struct SwitchPanel {
|
struct SwitchPanel {
|
||||||
WScreen *scr;
|
WScreen *scr;
|
||||||
@@ -38,64 +110,57 @@ struct SwitchPanel {
|
|||||||
WMBox *hbox;
|
WMBox *hbox;
|
||||||
WMLabel *label;
|
WMLabel *label;
|
||||||
WMArray *icons;
|
WMArray *icons;
|
||||||
|
WMArray *images;
|
||||||
WMArray *windows;
|
WMArray *windows;
|
||||||
int current;
|
int current;
|
||||||
|
|
||||||
WMColor *normalColor;
|
WMColor *normalColor;
|
||||||
WMColor *selectColor;
|
WMColor *selectColor;
|
||||||
|
|
||||||
WMPixmap *defIcon;
|
RImage *defIcon;
|
||||||
|
|
||||||
|
RImage *tile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern WPreferences wPreferences;
|
extern WPreferences wPreferences;
|
||||||
|
|
||||||
#define ICON_IDEAL_SIZE 64
|
#define ICON_IDEAL_SIZE 48
|
||||||
#define ICON_EXTRASPACE 4
|
#define ICON_EXTRASPACE 16
|
||||||
|
|
||||||
static void addIconForWindow(WSwitchPanel *panel, WWindow *wwin, int iconWidth)
|
static void changeImage(WSwitchPanel *panel, int index, int selected)
|
||||||
{
|
{
|
||||||
WMLabel *label= WMCreateLabel(panel->hbox);
|
WMPixmap *pixmap= NULL;
|
||||||
WMAddBoxSubviewAtEnd(panel->hbox, WMWidgetView(label), False, True, iconWidth + ICON_EXTRASPACE, 0, 0);
|
WMLabel *label = WMGetFromArray(panel->icons, index);
|
||||||
RImage *image = NULL;
|
RImage *image= WMGetFromArray(panel->images, index);
|
||||||
WMPixmap *pixmap;
|
|
||||||
WMScreen *wscr = WMWidgetScreen(label);
|
WMScreen *wscr = WMWidgetScreen(label);
|
||||||
|
|
||||||
if (!WFLAGP(wwin, always_user_icon) && wwin->net_icon_image)
|
|
||||||
image = RRetainImage(wwin->net_icon_image);
|
|
||||||
if (!image)
|
|
||||||
image = wDefaultGetImage(panel->scr, wwin->wm_instance, wwin->wm_class);
|
|
||||||
|
|
||||||
if (image && (abs(image->width - iconWidth) > 2 || abs(image->height - iconWidth) > 2)) {
|
|
||||||
RImage *nimage;
|
|
||||||
nimage= RScaleImage(image, iconWidth, (image->height * iconWidth / image->width));
|
|
||||||
RReleaseImage(image);
|
|
||||||
image= nimage;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (image) {
|
if (image) {
|
||||||
pixmap= WMCreatePixmapFromRImage(wscr, image, 100);
|
RColor bgColor;
|
||||||
RReleaseImage(image);
|
RImage *back;
|
||||||
} else {
|
|
||||||
if (!panel->defIcon)
|
|
||||||
{
|
|
||||||
char *file = wDefaultGetIconFile(panel->scr, NULL, NULL, False);
|
|
||||||
if (file) {
|
|
||||||
char *path = FindImage(wPreferences.icon_path, file);
|
|
||||||
if (path) {
|
|
||||||
image = RLoadImage(panel->scr->rcontext, path, 0);
|
|
||||||
wfree(path);
|
|
||||||
|
|
||||||
panel->defIcon= WMCreatePixmapFromRImage(wscr, image, 100);
|
|
||||||
RReleaseImage(image);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (panel->defIcon)
|
if (selected) {
|
||||||
pixmap= WMRetainPixmap(panel->defIcon);
|
back= RCloneImage(panel->tile);
|
||||||
else
|
RCombineArea(back, image, 0, 0, image->width, image->height,
|
||||||
pixmap= NULL;
|
(back->width - image->width)/2, (back->height - image->height)/2);
|
||||||
|
|
||||||
|
pixmap= WMCreatePixmapFromRImage(wscr, back, -1);
|
||||||
|
RReleaseImage(back);
|
||||||
|
} else {
|
||||||
|
bgColor.alpha= 100;
|
||||||
|
bgColor.red = WMRedComponentOfColor(WMGrayColor(wscr))>>8;
|
||||||
|
bgColor.green = WMGreenComponentOfColor(WMGrayColor(wscr))>>8;
|
||||||
|
bgColor.blue = WMBlueComponentOfColor(WMGrayColor(wscr))>>8;
|
||||||
|
|
||||||
|
image= RCloneImage(image);
|
||||||
|
RCombineImageWithColor(image, &bgColor);
|
||||||
|
|
||||||
|
pixmap= WMCreatePixmapFromRImage(wscr, image, -1);
|
||||||
|
RReleaseImage(image);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixmap) {
|
if (pixmap) {
|
||||||
@@ -103,7 +168,42 @@ static void addIconForWindow(WSwitchPanel *panel, WWindow *wwin, int iconWidth)
|
|||||||
WMSetLabelImagePosition(label, WIPImageOnly);
|
WMSetLabelImagePosition(label, WIPImageOnly);
|
||||||
WMReleasePixmap(pixmap);
|
WMReleasePixmap(pixmap);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void addIconForWindow(WSwitchPanel *panel, WWindow *wwin, int iconWidth)
|
||||||
|
{
|
||||||
|
WMLabel *label= WMCreateLabel(panel->hbox);
|
||||||
|
WMAddBoxSubviewAtEnd(panel->hbox, WMWidgetView(label), False, True, iconWidth + ICON_EXTRASPACE, 0, 0);
|
||||||
|
RImage *image = NULL;
|
||||||
|
|
||||||
|
if (!WFLAGP(wwin, always_user_icon) && wwin->net_icon_image)
|
||||||
|
image = RRetainImage(wwin->net_icon_image);
|
||||||
|
if (!image)
|
||||||
|
image = wDefaultGetImage(panel->scr, wwin->wm_instance, wwin->wm_class);
|
||||||
|
|
||||||
|
if (!image && !panel->defIcon)
|
||||||
|
{
|
||||||
|
char *file = wDefaultGetIconFile(panel->scr, NULL, NULL, False);
|
||||||
|
if (file) {
|
||||||
|
char *path = FindImage(wPreferences.icon_path, file);
|
||||||
|
if (path) {
|
||||||
|
image = RLoadImage(panel->scr->rcontext, path, 0);
|
||||||
|
wfree(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!image && panel->defIcon)
|
||||||
|
image= RRetainImage(panel->defIcon);
|
||||||
|
|
||||||
|
if (image && (abs(image->width - iconWidth) > 2 || abs(image->height - iconWidth) > 2)) {
|
||||||
|
RImage *nimage;
|
||||||
|
nimage= RScaleImage(image, iconWidth, (image->height * iconWidth / image->width));
|
||||||
|
RReleaseImage(image);
|
||||||
|
image= nimage;
|
||||||
|
}
|
||||||
|
|
||||||
|
WMAddToArray(panel->images, image);
|
||||||
WMAddToArray(panel->icons, label);
|
WMAddToArray(panel->icons, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,6 +253,7 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, int workspace)
|
|||||||
height= iconWidth + 20 + 10 + ICON_EXTRASPACE;
|
height= iconWidth + 20 + 10 + ICON_EXTRASPACE;
|
||||||
|
|
||||||
panel->icons= WMCreateArray(WMGetArrayItemCount(panel->windows));
|
panel->icons= WMCreateArray(WMGetArrayItemCount(panel->windows));
|
||||||
|
panel->images= WMCreateArray(WMGetArrayItemCount(panel->windows));
|
||||||
|
|
||||||
panel->win = WMCreateWindow(scr->wmscreen, "");
|
panel->win = WMCreateWindow(scr->wmscreen, "");
|
||||||
WMResizeWidget(panel->win, width + 10, height);
|
WMResizeWidget(panel->win, width + 10, height);
|
||||||
@@ -189,37 +290,73 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, int workspace)
|
|||||||
WMReleaseFont(boldFont);
|
WMReleaseFont(boldFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
RImage *tmp= NULL;
|
||||||
|
RColor bgColor;
|
||||||
|
char *path = FindImage(wPreferences.pixmap_path, "swtile.png");
|
||||||
|
if (path) {
|
||||||
|
tmp = RLoadImage(panel->scr->rcontext, path, 0);
|
||||||
|
wfree(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tmp)
|
||||||
|
tmp= RGetImageFromXPMData(scr->rcontext, tile_xpm);
|
||||||
|
|
||||||
|
panel->tile = RScaleImage(tmp, iconWidth+ICON_EXTRASPACE, iconWidth+ICON_EXTRASPACE);
|
||||||
|
|
||||||
|
bgColor.alpha = 255;
|
||||||
|
bgColor.red = WMRedComponentOfColor(WMGrayColor(scr->wmscreen))>>8;
|
||||||
|
bgColor.green = WMGreenComponentOfColor(WMGrayColor(scr->wmscreen))>>8;
|
||||||
|
bgColor.blue = WMBlueComponentOfColor(WMGrayColor(scr->wmscreen))>>8;
|
||||||
|
|
||||||
|
RCombineImageWithColor(panel->tile, &bgColor);
|
||||||
|
|
||||||
|
RReleaseImage(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
panel->hbox = WMCreateBox(vbox);
|
panel->hbox = WMCreateBox(vbox);
|
||||||
WMSetBoxHorizontal(panel->hbox, True);
|
WMSetBoxHorizontal(panel->hbox, True);
|
||||||
WMAddBoxSubviewAtEnd(vbox, WMWidgetView(panel->hbox), True, True, 20, 0, 2);
|
WMAddBoxSubviewAtEnd(vbox, WMWidgetView(panel->hbox), True, True, 20, 0, 2);
|
||||||
|
|
||||||
WM_ITERATE_ARRAY(panel->windows, wwin, i) {
|
WM_ITERATE_ARRAY(panel->windows, wwin, i) {
|
||||||
addIconForWindow(panel, wwin, iconWidth);
|
addIconForWindow(panel, wwin, iconWidth);
|
||||||
|
changeImage(panel, i, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
WMMapSubwidgets(panel->win);
|
WMMapSubwidgets(panel->win);
|
||||||
WMRealizeWidget(panel->win);
|
WMRealizeWidget(panel->win);
|
||||||
WMMapWidget(panel->win);
|
WMMapWidget(panel->win);
|
||||||
WMMoveWidget(panel->win,
|
{
|
||||||
(WMScreenWidth(scr->wmscreen) - (width+10))/2,
|
WMPoint center;
|
||||||
(WMScreenHeight(scr->wmscreen) - height)/2);
|
|
||||||
|
|
||||||
WMSetWidgetBackgroundColor(WMGetFromArray(panel->icons, 0),
|
center= wGetPointToCenterRectInHead(scr, wGetHeadForPointerLocation(scr),
|
||||||
panel->selectColor);
|
width+10, height);
|
||||||
|
WMMoveWidget(panel->win, center.x, center.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
changeImage(panel, 0, 1);
|
||||||
|
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wSwitchPanelDestroy(WSwitchPanel *panel)
|
void wSwitchPanelDestroy(WSwitchPanel *panel)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
RImage *image;
|
||||||
|
WM_ITERATE_ARRAY(panel->images, image, i) {
|
||||||
|
if (image)
|
||||||
|
RReleaseImage(image);
|
||||||
|
}
|
||||||
WMDestroyWidget(panel->win);
|
WMDestroyWidget(panel->win);
|
||||||
WMFreeArray(panel->icons);
|
WMFreeArray(panel->icons);
|
||||||
WMFreeArray(panel->windows);
|
WMFreeArray(panel->windows);
|
||||||
|
WMFreeArray(panel->images);
|
||||||
WMReleaseColor(panel->selectColor);
|
WMReleaseColor(panel->selectColor);
|
||||||
WMReleaseColor(panel->normalColor);
|
WMReleaseColor(panel->normalColor);
|
||||||
if (panel->defIcon)
|
if (panel->defIcon)
|
||||||
WMReleasePixmap(panel->defIcon);
|
RReleaseImage(panel->defIcon);
|
||||||
|
RReleaseImage(panel->tile);
|
||||||
wfree(panel);
|
wfree(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,12 +365,9 @@ WWindow *wSwitchPanelSelectNext(WSwitchPanel *panel, int back)
|
|||||||
{
|
{
|
||||||
WWindow *wwin;
|
WWindow *wwin;
|
||||||
int count = WMGetArrayItemCount(panel->windows);
|
int count = WMGetArrayItemCount(panel->windows);
|
||||||
WMLabel *label;
|
|
||||||
|
|
||||||
label= WMGetFromArray(panel->icons, panel->current);
|
|
||||||
WMSetWidgetBackgroundColor(label, panel->normalColor);
|
|
||||||
WMSetLabelRelief(label, WRFlat);
|
|
||||||
|
|
||||||
|
changeImage(panel, panel->current, 0);
|
||||||
|
|
||||||
if (!back)
|
if (!back)
|
||||||
panel->current = (count + panel->current - 1) % count;
|
panel->current = (count + panel->current - 1) % count;
|
||||||
else
|
else
|
||||||
@@ -243,9 +377,7 @@ WWindow *wSwitchPanelSelectNext(WSwitchPanel *panel, int back)
|
|||||||
|
|
||||||
WMSetLabelText(panel->label, wwin->frame->title);
|
WMSetLabelText(panel->label, wwin->frame->title);
|
||||||
|
|
||||||
label= WMGetFromArray(panel->icons, panel->current);
|
changeImage(panel, panel->current, 1);
|
||||||
WMSetWidgetBackgroundColor(label, panel->selectColor);
|
|
||||||
WMSetLabelRelief(label, WRSimple);
|
|
||||||
|
|
||||||
return wwin;
|
return wwin;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user