mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 12:58:08 +01:00
make switchpanel configurable
This commit is contained in:
9
NEWS
9
NEWS
@@ -3,6 +3,15 @@ NEWS for veteran Window Maker users
|
|||||||
|
|
||||||
-- 0.95.9
|
-- 0.95.9
|
||||||
|
|
||||||
|
Configurable SwitchPanel
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
SwitchPanel is now more configurable: you can configure the switch panel icon
|
||||||
|
size by setting the "SwitchPanelIconSize" option to your preferred value in
|
||||||
|
~/GNUstep/Defaults/WindowMaker. The font size used in this panel now is also
|
||||||
|
sensible to changes in the system font.
|
||||||
|
|
||||||
|
|
||||||
New user configuration directory environment variable
|
New user configuration directory environment variable
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -488,6 +488,8 @@ extern struct WPreferences {
|
|||||||
/* Map table between w_cursor and actual X id */
|
/* Map table between w_cursor and actual X id */
|
||||||
Cursor cursor[WCUR_LAST];
|
Cursor cursor[WCUR_LAST];
|
||||||
|
|
||||||
|
int switch_panel_icon_size; /* icon size in switch panel */
|
||||||
|
|
||||||
} wPreferences;
|
} wPreferences;
|
||||||
|
|
||||||
/****** Global Variables ******/
|
/****** Global Variables ******/
|
||||||
|
|||||||
@@ -349,7 +349,9 @@ WDefaultEntry staticOptionList[] = {
|
|||||||
{"DisableMiniwindows", "NO", NULL,
|
{"DisableMiniwindows", "NO", NULL,
|
||||||
&wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL},
|
&wPreferences.disable_miniwindows, getBool, NULL, NULL, NULL},
|
||||||
{"EnableWorkspacePager", "NO", NULL,
|
{"EnableWorkspacePager", "NO", NULL,
|
||||||
&wPreferences.enable_workspace_pager, getBool, NULL, NULL, NULL}
|
&wPreferences.enable_workspace_pager, getBool, NULL, NULL, NULL},
|
||||||
|
{"SwitchPanelIconSize", "48", NULL,
|
||||||
|
&wPreferences.switch_panel_icon_size, getInt, NULL, NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NUM2STRING_(x) #x
|
#define NUM2STRING_(x) #x
|
||||||
|
|||||||
@@ -63,10 +63,14 @@ struct SwitchPanel {
|
|||||||
WMColor *white;
|
WMColor *white;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BORDER_SPACE 10
|
/* these values will be updated whenever the switch panel
|
||||||
#define ICON_SIZE 48
|
* is created to to match the size defined in switch_panel_icon_size
|
||||||
#define ICON_TILE_SIZE 64
|
* and the selected font size */
|
||||||
#define LABEL_HEIGHT 25
|
static short int icon_size;
|
||||||
|
static short int border_space;
|
||||||
|
static short int icon_tile_size;
|
||||||
|
static short int label_height;
|
||||||
|
|
||||||
#define SCREEN_BORDER_SPACING 2*20
|
#define SCREEN_BORDER_SPACING 2*20
|
||||||
|
|
||||||
#define ICON_SELECTED (1<<1)
|
#define ICON_SELECTED (1<<1)
|
||||||
@@ -146,8 +150,8 @@ static void changeImage(WSwitchPanel *panel, int idecks, int selected, Bool dim,
|
|||||||
back = panel->tileTmp;
|
back = panel->tileTmp;
|
||||||
if (panel->bg) {
|
if (panel->bg) {
|
||||||
RCopyArea(back, panel->bg,
|
RCopyArea(back, panel->bg,
|
||||||
BORDER_SPACE + pos.x - panel->firstVisible * ICON_TILE_SIZE,
|
border_space + pos.x - panel->firstVisible * icon_tile_size,
|
||||||
BORDER_SPACE + pos.y, back->width, back->height, 0, 0);
|
border_space + pos.y, back->width, back->height, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
RColor color;
|
RColor color;
|
||||||
WMScreen *wscr = WMWidgetScreen(icon);
|
WMScreen *wscr = WMWidgetScreen(icon);
|
||||||
@@ -184,7 +188,7 @@ static void addIconForWindow(WSwitchPanel *panel, WMWidget *parent, WWindow *wwi
|
|||||||
RImage *image = NULL;
|
RImage *image = NULL;
|
||||||
|
|
||||||
WMSetFrameRelief(icon, WRFlat);
|
WMSetFrameRelief(icon, WRFlat);
|
||||||
WMResizeWidget(icon, ICON_TILE_SIZE, ICON_TILE_SIZE);
|
WMResizeWidget(icon, icon_tile_size, icon_tile_size);
|
||||||
WMMoveWidget(icon, x, y);
|
WMMoveWidget(icon, x, y);
|
||||||
|
|
||||||
if (!WFLAGP(wwin, always_user_icon) && wwin->net_icon_image)
|
if (!WFLAGP(wwin, always_user_icon) && wwin->net_icon_image)
|
||||||
@@ -192,10 +196,10 @@ static void addIconForWindow(WSwitchPanel *panel, WMWidget *parent, WWindow *wwi
|
|||||||
|
|
||||||
/* get_icon_image() includes the default icon image */
|
/* get_icon_image() includes the default icon image */
|
||||||
if (!image)
|
if (!image)
|
||||||
image = get_icon_image(panel->scr, wwin->wm_instance, wwin->wm_class, ICON_TILE_SIZE);
|
image = get_icon_image(panel->scr, wwin->wm_instance, wwin->wm_class, icon_tile_size);
|
||||||
|
|
||||||
/* We must resize the icon size (~64) to the switch panel icon size (~48) */
|
/* We must resize the icon size (~64) to the switch panel icon size (~48) */
|
||||||
image = wIconValidateIconSize(image, ICON_SIZE);
|
image = wIconValidateIconSize(image, icon_size);
|
||||||
|
|
||||||
WMAddToArray(panel->images, image);
|
WMAddToArray(panel->images, image);
|
||||||
WMAddToArray(panel->icons, icon);
|
WMAddToArray(panel->icons, icon);
|
||||||
@@ -219,7 +223,7 @@ static void scrollIcons(WSwitchPanel *panel, int delta)
|
|||||||
if (nfirst == panel->firstVisible)
|
if (nfirst == panel->firstVisible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WMMoveWidget(panel->iconBox, -nfirst * ICON_TILE_SIZE, 0);
|
WMMoveWidget(panel->iconBox, -nfirst * icon_tile_size, 0);
|
||||||
|
|
||||||
panel->firstVisible = nfirst;
|
panel->firstVisible = nfirst;
|
||||||
|
|
||||||
@@ -306,7 +310,7 @@ static RImage *getTile(void)
|
|||||||
if (!wPreferences.swtileImage)
|
if (!wPreferences.swtileImage)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
stile = RScaleImage(wPreferences.swtileImage, ICON_TILE_SIZE, ICON_TILE_SIZE);
|
stile = RScaleImage(wPreferences.swtileImage, icon_tile_size, icon_tile_size);
|
||||||
if (!stile)
|
if (!stile)
|
||||||
return wPreferences.swtileImage;
|
return wPreferences.swtileImage;
|
||||||
|
|
||||||
@@ -320,23 +324,23 @@ static void drawTitle(WSwitchPanel *panel, int idecks, const char *title)
|
|||||||
int x;
|
int x;
|
||||||
|
|
||||||
if (title)
|
if (title)
|
||||||
ntitle = ShrinkString(panel->font, title, width - 2 * BORDER_SPACE);
|
ntitle = ShrinkString(panel->font, title, width - 2 * border_space);
|
||||||
else
|
else
|
||||||
ntitle = NULL;
|
ntitle = NULL;
|
||||||
|
|
||||||
if (panel->bg) {
|
if (panel->bg) {
|
||||||
if (ntitle) {
|
if (ntitle) {
|
||||||
if (strcmp(ntitle, title) != 0) {
|
if (strcmp(ntitle, title) != 0) {
|
||||||
x = BORDER_SPACE;
|
x = border_space;
|
||||||
} else {
|
} else {
|
||||||
int w = WMWidthOfString(panel->font, ntitle, strlen(ntitle));
|
int w = WMWidthOfString(panel->font, ntitle, strlen(ntitle));
|
||||||
|
|
||||||
x = BORDER_SPACE + (idecks - panel->firstVisible) * ICON_TILE_SIZE +
|
x = border_space + (idecks - panel->firstVisible) * icon_tile_size+
|
||||||
ICON_TILE_SIZE / 2 - w / 2;
|
icon_tile_size/ 2 - w / 2;
|
||||||
if (x < BORDER_SPACE)
|
if (x < border_space)
|
||||||
x = BORDER_SPACE;
|
x = border_space;
|
||||||
else if (x + w > width - BORDER_SPACE)
|
else if (x + w > width - border_space)
|
||||||
x = width - BORDER_SPACE - w;
|
x = width - border_space - w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,7 +350,7 @@ static void drawTitle(WSwitchPanel *panel, int idecks, const char *title)
|
|||||||
WMWidgetXID(panel->win),
|
WMWidgetXID(panel->win),
|
||||||
panel->white, panel->font,
|
panel->white, panel->font,
|
||||||
x,
|
x,
|
||||||
WMWidgetHeight(panel->win) - BORDER_SPACE - LABEL_HEIGHT +
|
WMWidgetHeight(panel->win) - border_space - label_height +
|
||||||
WMFontHeight(panel->font) / 2, ntitle, strlen(ntitle));
|
WMFontHeight(panel->font) / 2, ntitle, strlen(ntitle));
|
||||||
} else {
|
} else {
|
||||||
if (ntitle)
|
if (ntitle)
|
||||||
@@ -391,6 +395,14 @@ static WMArray *makeWindowFlagsArray(int count)
|
|||||||
|
|
||||||
WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, Bool class_only)
|
WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, Bool class_only)
|
||||||
{
|
{
|
||||||
|
int wmScaleWidth, wmScaleHeight;
|
||||||
|
WMGetScaleBaseFromSystemFont(scr->wmscreen, &wmScaleWidth, &wmScaleHeight);
|
||||||
|
|
||||||
|
icon_size = wPreferences.switch_panel_icon_size;
|
||||||
|
icon_tile_size = (short int)(((float)icon_size * (float)1.2) + 0.5);
|
||||||
|
border_space = WMScaleY(10);
|
||||||
|
label_height = WMScaleY(25);
|
||||||
|
|
||||||
WWindow *wwin;
|
WWindow *wwin;
|
||||||
WSwitchPanel *panel = wmalloc(sizeof(WSwitchPanel));
|
WSwitchPanel *panel = wmalloc(sizeof(WSwitchPanel));
|
||||||
WMFrame *viewport;
|
WMFrame *viewport;
|
||||||
@@ -409,12 +421,12 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, Bool class_only)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
width = ICON_TILE_SIZE * count;
|
width = icon_tile_size* count;
|
||||||
iconsThatFitCount = count;
|
iconsThatFitCount = count;
|
||||||
|
|
||||||
if (width > rect.size.width) {
|
if (width > (int)rect.size.width) {
|
||||||
iconsThatFitCount = (rect.size.width - SCREEN_BORDER_SPACING) / ICON_TILE_SIZE;
|
iconsThatFitCount = (rect.size.width - SCREEN_BORDER_SPACING) / icon_tile_size;
|
||||||
width = iconsThatFitCount * ICON_TILE_SIZE;
|
width = iconsThatFitCount * icon_tile_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
panel->visibleCount = iconsThatFitCount;
|
panel->visibleCount = iconsThatFitCount;
|
||||||
@@ -422,12 +434,12 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, Bool class_only)
|
|||||||
if (!wPreferences.swtileImage)
|
if (!wPreferences.swtileImage)
|
||||||
return panel;
|
return panel;
|
||||||
|
|
||||||
height = LABEL_HEIGHT + ICON_TILE_SIZE;
|
height = label_height + icon_tile_size;
|
||||||
|
|
||||||
panel->tileTmp = RCreateImage(ICON_TILE_SIZE, ICON_TILE_SIZE, 1);
|
panel->tileTmp = RCreateImage(icon_tile_size, icon_tile_size, 1);
|
||||||
panel->tile = getTile();
|
panel->tile = getTile();
|
||||||
if (panel->tile && wPreferences.swbackImage[8])
|
if (panel->tile && wPreferences.swbackImage[8])
|
||||||
panel->bg = createBackImage(width + 2 * BORDER_SPACE, height + 2 * BORDER_SPACE);
|
panel->bg = createBackImage(width + 2 * border_space, height + 2 * border_space);
|
||||||
|
|
||||||
if (!panel->tileTmp || !panel->tile) {
|
if (!panel->tileTmp || !panel->tile) {
|
||||||
if (panel->bg)
|
if (panel->bg)
|
||||||
@@ -442,7 +454,7 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, Bool class_only)
|
|||||||
}
|
}
|
||||||
|
|
||||||
panel->white = WMWhiteColor(scr->wmscreen);
|
panel->white = WMWhiteColor(scr->wmscreen);
|
||||||
panel->font = WMBoldSystemFontOfSize(scr->wmscreen, 12);
|
panel->font = WMBoldSystemFontOfSize(scr->wmscreen, WMScaleY(12));
|
||||||
panel->icons = WMCreateArray(count);
|
panel->icons = WMCreateArray(count);
|
||||||
panel->images = WMCreateArray(count);
|
panel->images = WMCreateArray(count);
|
||||||
|
|
||||||
@@ -455,8 +467,8 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, Bool class_only)
|
|||||||
WMSetViewExpandsToParent(WMWidgetView(frame), 0, 0, 0, 0);
|
WMSetViewExpandsToParent(WMWidgetView(frame), 0, 0, 0, 0);
|
||||||
|
|
||||||
panel->label = WMCreateLabel(panel->win);
|
panel->label = WMCreateLabel(panel->win);
|
||||||
WMResizeWidget(panel->label, width, LABEL_HEIGHT);
|
WMResizeWidget(panel->label, width, label_height);
|
||||||
WMMoveWidget(panel->label, BORDER_SPACE, BORDER_SPACE + ICON_TILE_SIZE + 5);
|
WMMoveWidget(panel->label, border_space, border_space + icon_tile_size+ 5);
|
||||||
WMSetLabelRelief(panel->label, WRSimple);
|
WMSetLabelRelief(panel->label, WRSimple);
|
||||||
WMSetWidgetBackgroundColor(panel->label, darkGray);
|
WMSetWidgetBackgroundColor(panel->label, darkGray);
|
||||||
WMSetLabelFont(panel->label, panel->font);
|
WMSetLabelFont(panel->label, panel->font);
|
||||||
@@ -466,20 +478,20 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, Bool class_only)
|
|||||||
height += 5;
|
height += 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
WMResizeWidget(panel->win, width + 2 * BORDER_SPACE, height + 2 * BORDER_SPACE);
|
WMResizeWidget(panel->win, width + 2 * border_space, height + 2 * border_space);
|
||||||
|
|
||||||
viewport = WMCreateFrame(panel->win);
|
viewport = WMCreateFrame(panel->win);
|
||||||
WMResizeWidget(viewport, width, ICON_TILE_SIZE);
|
WMResizeWidget(viewport, width, icon_tile_size);
|
||||||
WMMoveWidget(viewport, BORDER_SPACE, BORDER_SPACE);
|
WMMoveWidget(viewport, border_space, border_space);
|
||||||
WMSetFrameRelief(viewport, WRFlat);
|
WMSetFrameRelief(viewport, WRFlat);
|
||||||
|
|
||||||
panel->iconBox = WMCreateFrame(viewport);
|
panel->iconBox = WMCreateFrame(viewport);
|
||||||
WMMoveWidget(panel->iconBox, 0, 0);
|
WMMoveWidget(panel->iconBox, 0, 0);
|
||||||
WMResizeWidget(panel->iconBox, ICON_TILE_SIZE * count, ICON_TILE_SIZE);
|
WMResizeWidget(panel->iconBox, icon_tile_size* count, icon_tile_size);
|
||||||
WMSetFrameRelief(panel->iconBox, WRFlat);
|
WMSetFrameRelief(panel->iconBox, WRFlat);
|
||||||
|
|
||||||
WM_ITERATE_ARRAY(panel->windows, wwin, i) {
|
WM_ITERATE_ARRAY(panel->windows, wwin, i) {
|
||||||
addIconForWindow(panel, panel->iconBox, wwin, i * ICON_TILE_SIZE, 0);
|
addIconForWindow(panel, panel->iconBox, wwin, i * icon_tile_size, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
WMMapSubwidgets(panel->win);
|
WMMapSubwidgets(panel->win);
|
||||||
@@ -510,7 +522,7 @@ WSwitchPanel *wInitSwitchPanel(WScreen *scr, WWindow *curwin, Bool class_only)
|
|||||||
{
|
{
|
||||||
WMPoint center;
|
WMPoint center;
|
||||||
center = wGetPointToCenterRectInHead(scr, wGetHeadForPointerLocation(scr),
|
center = wGetPointToCenterRectInHead(scr, wGetHeadForPointerLocation(scr),
|
||||||
width + 2 * BORDER_SPACE, height + 2 * BORDER_SPACE);
|
width + 2 * border_space, height + 2 * border_space);
|
||||||
WMMoveWidget(panel->win, center.x, center.y);
|
WMMoveWidget(panel->win, center.x, center.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user