Skip to content

Commit

Permalink
Add constructors to WMKey.
Browse files Browse the repository at this point in the history
  • Loading branch information
gijsbers committed Aug 3, 2024
1 parent 080c828 commit 293bb51
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/bindkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@
#define defgKeySysCollapseTaskBar 'h', kfAlt+kfCtrl, "Alt+Ctrl+h"

#ifdef CFGDEF
#define DEF_WMKEY(k) WMKey k = { def##k, true }
#define DEF_WMKEY(k) WMKey k( def##k )
#else

#define DEF_WMKEY(k) extern WMKey k
#define DEF_WMKEY(k) extern WMKey k
#define IS_WMKEY(k,m,b) b.eq(k,m)
#define KEY_NAME(k) k.name
#endif
Expand Down
5 changes: 5 additions & 0 deletions src/wmkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ struct WMKey {
const char* name;
bool initial;

WMKey() : key(NoSymbol), mod(0), name(""), initial(true) { }
WMKey(char* s) : key(NoSymbol), mod(0), name(s), initial(false) { parse(); }
WMKey(KeySym k, unsigned m, const char* s) :
key(k), mod(m), name(s), initial(true) { }

bool eq(KeySym k, unsigned m) const { return key == k && mod == m; }
bool operator==(const WMKey& o) const { return eq(o.key, o.mod); }
bool operator!=(const WMKey& o) const { return !eq(o.key, o.mod); }
Expand Down
6 changes: 5 additions & 1 deletion src/wmmenu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ char* MenuLoader::parseKey(char *word, char *p)
command.cstr(),
args);

if (prog) new KProgram(key, prog, switchkey);
if (prog) {
KProgram* kp = new KProgram(key, prog, switchkey);
if (kp)
keyProgs += kp;
}

return p;
}
Expand Down
7 changes: 1 addition & 6 deletions src/wmprog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,11 @@ DProgram *DProgram::newProgram(
KProgramArrayType keyProgs;

KProgram::KProgram(const char *key, DProgram *prog, bool bIsDynSwitchMenuProg) :
wm(newstr(key)),
bIsDynSwitchMenu(bIsDynSwitchMenuProg),
fProg(prog),
pSwitchWindow(nullptr)
{
wm.name = newstr(key);
wm.initial = false;
wm.key = NoSymbol;
wm.mod = 0;
wm.parse();
keyProgs += this;
}

KProgram::~KProgram() {
Expand Down

0 comments on commit 293bb51

Please sign in to comment.