Skip to content

Commit

Permalink
Keyboard layout icon names can be longer than 2 letters for issue ice…
Browse files Browse the repository at this point in the history
…-wm/icewm#161.
  • Loading branch information
gijsbers committed May 9, 2024
1 parent 5bad4b0 commit 5b44cc1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion man/icewm.pod
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ in the XPM image is the sensitive point for the mouse pointer.
=item F<icons>

Contains icons for applications and keyboard layouts. These can be in
XPM, PNG or SVG format. The names of an application icon files may
XPM, PNG or SVG format. The filename of an I<application icon> may
follow a specific naming pattern, like F<app_32x32.xpm>. They start
with a base name, which usually is just a single word. Then follows
an underscore, followed by a size specification, as in C<SIZExSIZE>.
Expand Down
27 changes: 19 additions & 8 deletions src/akeyboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "ytrace.h"
#include "yapp.h"
#include "wmmgr.h"
#include "ascii.h"
#include "intl.h"
#include <unistd.h>
#include <sys/wait.h>
Expand All @@ -29,9 +30,7 @@ KeyboardStatus::KeyboardStatus(IApp* app, IAppletContainer* tb, YWindow* parent)
setSize(w, h);
}
setTitle("Keyboard");
if (fKeyboard != null) {
fIcon = YIcon::getIcon(fKeyboard.substring(0, 2));
}
getIcon();
}

KeyboardStatus::~KeyboardStatus() {
Expand All @@ -53,11 +52,7 @@ void KeyboardStatus::updateKeyboard(mstring keyboard) {
break;
}
}
if (fKeyboard != null) {
fIcon = YIcon::getIcon(fKeyboard.substring(0, 2));
} else {
fIcon = null;
}
getIcon();
repaint();
if (toolTipVisible())
updateToolTip();
Expand Down Expand Up @@ -241,4 +236,20 @@ void KeyboardStatus::draw(Graphics& g) {
}
}

void KeyboardStatus::getIcon() {
fIcon = null;
if (fKeyboard != null) {
size_t k = 0;
while (k < fKeyboard.length() && ASCII::isLower(fKeyboard[k])) {
k++;
}
if (k) {
fIcon = YIcon::getIcon(fKeyboard.substring(0, k));
}
if (fIcon == null && k != 2) {
fIcon = YIcon::getIcon(fKeyboard.substring(0, 2));
}
}
}

// vim: set sw=4 ts=4 et:
1 change: 1 addition & 0 deletions src/akeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class KeyboardStatus:
mstring detectLayout();
void fill(Graphics& g);
void draw(Graphics& g);
void getIcon();

IApp* app;
IAppletContainer* taskBar;
Expand Down

0 comments on commit 5b44cc1

Please sign in to comment.