From ca95571f534ea2a66057f8206dd48155e5c9e4c6 Mon Sep 17 00:00:00 2001 From: Bert Gijsbers Date: Mon, 19 Dec 2022 23:56:03 +0100 Subject: [PATCH] Add preference ToolTipIcon=1 for issue #637. --- man/icewm-preferences.pod | 4 ++++ src/default.h | 1 + src/themes.cc | 10 ++++++---- src/yprefs.h | 1 + src/ytooltip.cc | 10 ++++++---- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/man/icewm-preferences.pod b/man/icewm-preferences.pod index f33520da7..2dc6a8ef0 100644 --- a/man/icewm-preferences.pod +++ b/man/icewm-preferences.pod @@ -821,6 +821,10 @@ Delay before activating menu items. Delay before activating menu submenus. +=item B=1 + +Show an application icon in toolbar and tray tooltips. + =item B=1000 [0-5000] Delay before tooltip window is displayed. diff --git a/src/default.h b/src/default.h index 0fac17c55..2d0225485 100644 --- a/src/default.h +++ b/src/default.h @@ -389,6 +389,7 @@ cfoption icewm_preferences[] = { OIV("MenuActivateDelay", &MenuActivateDelay, 0, 5000, "Delay in ms before activating menu items"), OIV("SubmenuMenuActivateDelay", &SubmenuActivateDelay, 0, 5000, "Delay in ms before activating menu submenus"), OIV("MenuMaximalWidth", &MenuMaximalWidth, 0, 16384, "Maximal width of popup menus, 2/3 of the screen's width if set to zero"), + OBV("ToolTipIcon", &ToolTipIcon, "Show an application icon in toolbar and tray tooltips"), OIV("ToolTipDelay", &ToolTipDelay, 0, 5000, "Delay in ms before tooltip window is displayed"), OIV("ToolTipTime", &ToolTipTime, 0, 60000, "Time in ms before tooltip window is hidden (0 means never)"), OIV("AutoHideDelay", &autoHideDelay, 0, 5000, "Delay in ms before task bar is hidden"), diff --git a/src/themes.cc b/src/themes.cc index 3ba0a9280..49a21c425 100644 --- a/src/themes.cc +++ b/src/themes.cc @@ -48,10 +48,12 @@ void DTheme::open() { smActionListener->handleSMAction(ICEWM_ACTION_RESTARTWM); } -ThemesMenu::ThemesMenu(IApp *app, YSMListener *smActionListener, YActionListener *wmActionListener, YWindow *parent): ObjectMenu(wmActionListener, parent) { - themeCount = 0; - this->app = app; - this->smActionListener = smActionListener; +ThemesMenu::ThemesMenu(IApp *app, YSMListener *smActionListener, YActionListener *wmActionListener, YWindow *parent) + : ObjectMenu(wmActionListener, parent) + , themeCount(0) + , smActionListener(smActionListener) + , app(app) +{ } void ThemesMenu::updatePopup() { diff --git a/src/yprefs.h b/src/yprefs.h index 91eee10a4..fb7797dc9 100644 --- a/src/yprefs.h +++ b/src/yprefs.h @@ -29,6 +29,7 @@ XIV(int, autoScrollStartDelay, 500) XIV(int, autoScrollDelay, 60) XIV(int, ToolTipDelay, 500) XIV(int, ToolTipTime, 0) +XIV(bool, ToolTipIcon, true) ///#warning "move this one back to WM" XIV(bool, grabRootWindow, true) diff --git a/src/ytooltip.cc b/src/ytooltip.cc index fac13933a..4f9b38f5b 100644 --- a/src/ytooltip.cc +++ b/src/ytooltip.cc @@ -50,7 +50,7 @@ void YToolTipWindow::paint(Graphics& g, const YRect& /*r*/) { g.setColor(toolTipFg); g.drawStringMultiline(fText, TTXMargin, y, width() - 2 * TTXMargin); } - if (fIcon != null) { + if (ToolTipIcon && fIcon != null) { int y = int(height() - hugeIconSize) - TTYMargin; int x = int(width() - hugeIconSize) / 2; fIcon->draw(g, x, y, hugeIconSize); @@ -59,14 +59,15 @@ void YToolTipWindow::paint(Graphics& g, const YRect& /*r*/) { void YToolTipWindow::setText(mstring tip, ref icon) { fText = tip; - fIcon = icon; + if (ToolTipIcon) + fIcon = icon; unsigned w = 0, h = 0; if (toolTipFont) { YDimension size(toolTipFont->multilineAlloc(fText)); w += size.w; h += size.h + 3; } - if (fIcon != null) { + if (ToolTipIcon && fIcon != null) { h += hugeIconSize; w = max(w, hugeIconSize); } @@ -77,7 +78,8 @@ void YToolTipWindow::setText(mstring tip, ref icon) { void YToolTip::setText(mstring tip, ref icon) { fText = tip; - fIcon = icon; + if (ToolTipIcon) + fIcon = icon; if (fWindow) { fWindow->setText(tip, icon); fWindow->locate(fLocate);