Changed keygrab constants to upper-case

This commit is contained in:
fluxgen 2001-12-29 10:32:04 +00:00
parent e0dce8166c
commit c79fb75a3b
2 changed files with 88 additions and 82 deletions

View file

@ -24,6 +24,12 @@
# include "config.h" # include "config.h"
#endif #endif
#include "Keys.hh"
#ifndef _FLUXBOX_HH_
# include "fluxbox.hh"
#endif
#ifdef HAVE_STDIO_H #ifdef HAVE_STDIO_H
# include <stdio.h> # include <stdio.h>
#endif // HAVE_STDIO_H #endif // HAVE_STDIO_H
@ -62,61 +68,58 @@
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include "Keys.hh"
#include "fluxbox.hh"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
using namespace std; using namespace std;
Keys::t_actionstr Keys::m_actionlist[] = { Keys::t_actionstr Keys::m_actionlist[] = {
{"Minimize", grabIconify}, {"Minimize", ICONIFY},
{"Raise", grabRaise}, {"Raise", RAISE},
{"Lower", grabLower}, {"Lower", LOWER},
{"Close", grabClose}, {"Close", CLOSE},
{"AbortKeychain", grabAbortKeychain}, {"AbortKeychain", ABORTKEYCHAIN},
{"Workspace1", grabWorkspace1}, {"Workspace1", WORKSPACE1},
{"Workspace2", grabWorkspace2}, {"Workspace2", WORKSPACE2},
{"Workspace3", grabWorkspace3}, {"Workspace3", WORKSPACE3},
{"Workspace4", grabWorkspace4}, {"Workspace4", WORKSPACE4},
{"Workspace5", grabWorkspace5}, {"Workspace5", WORKSPACE5},
{"Workspace6", grabWorkspace6}, {"Workspace6", WORKSPACE6},
{"Workspace7", grabWorkspace7}, {"Workspace7", WORKSPACE7},
{"Workspace8", grabWorkspace8}, {"Workspace8", WORKSPACE8},
{"Workspace9", grabWorkspace9}, {"Workspace9", WORKSPACE9},
{"Workspace10", grabWorkspace10}, {"Workspace10", WORKSPACE10},
{"Workspace11", grabWorkspace11}, {"Workspace11", WORKSPACE11},
{"Workspace12", grabWorkspace12}, {"Workspace12", WORKSPACE12},
{"NextWorkspace", grabNextWorkspace}, {"NextWorkspace", NEXTWORKSPACE},
{"PrevWorkspace", grabPrevWorkspace}, {"PrevWorkspace", PREVWORKSPACE},
{"LeftWorkspace", grabLeftWorkspace}, {"LeftWorkspace", LEFTWORKSPACE},
{"RightWorkspace", grabRightWorkspace}, {"RightWorkspace", RIGHTWORKSPACE},
{"KillWindow", grabKillWindow}, {"KillWindow", KILLWINDOW},
{"NextWindow", grabNextWindow}, {"NextWindow", NEXTWINDOW},
{"PrevWindow", grabPrevWindow}, {"PrevWindow", PREVWINDOW},
{"NextTab", grabNextTab}, {"NextTab", NEXTTAB},
{"PrevTab", grabPrevTab}, {"PrevTab", PREVTAB},
{"ShadeWindow", grabShade}, {"ShadeWindow", SHADE},
{"MaximizeWindow", grabMaximize}, {"MaximizeWindow", MAXIMIZE},
{"StickWindow", grabStick}, {"StickWindow", STICK},
{"ExecCommand", grabExecute}, {"ExecCommand", EXECUTE},
{"MaximizeVertical", grabVertMax}, {"MaximizeVertical", VERTMAX},
{"MaximizeHorizontal", grabHorizMax}, {"MaximizeHorizontal", HORIZMAX},
{"NudgeRight", grabNudgeRight}, {"NudgeRight", NUDGERIGHT},
{"NudgeLeft", grabNudgeLeft}, {"NudgeLeft", NUDGELEFT},
{"NudgeUp", grabNudgeUp}, {"NudgeUp", NUDGEUP},
{"NudgeDown", grabNudgeDown}, {"NudgeDown", NUDGEDOWN},
{"BigNudgeRight", grabBigNudgeRight}, {"BigNudgeRight", BIGNUDGERIGHT},
{"BigNudgeLeft", grabBigNudgeLeft}, {"BigNudgeLeft", BIGNUDGELEFT},
{"BigNudgeUp", grabBigNudgeUp}, {"BigNudgeUp", BIGNUDGEUP},
{"BigNudgeDown", grabBigNudgeDown}, {"BigNudgeDown", BIGNUDGEDOWN},
{"HorizontalIncrement", grabHorizInc}, {"HorizontalIncrement", HORIZINC},
{"VerticalIncrement", grabVertInc}, {"VerticalIncrement", VERTINC},
{"HorizontalDecrement", grabHorizDec}, {"HorizontalDecrement", HORIZDEC},
{"VerticalDecrement", grabVertDec}, {"VerticalDecrement", VERTDEC},
{"ToggleDecor", grabToggleDecor}, {"ToggleDecor", TOGGLEDECOR},
{0, lastKeygrab} {0, LASTKEYGRAB}
}; };
Keys::Keys(char *filename) { Keys::Keys(char *filename) {
@ -127,6 +130,7 @@ Keys::Keys(char *filename) {
Keys::~Keys() { Keys::~Keys() {
deleteTree(); deleteTree();
} }
//--------- deleteTree ----------- //--------- deleteTree -----------
// Destroys the keytree and m_abortkey // Destroys the keytree and m_abortkey
//-------------------------------- //--------------------------------
@ -141,11 +145,12 @@ void Keys::deleteTree() {
m_abortkey=0; m_abortkey=0;
} }
} }
//-------------- load ---------------- //-------------- load ----------------
// Load and grab keys // Load and grab keys
// Returns true on success else false // Returns true on success else false
// TODO: error checking and nls on them? // TODO: error checking and (nls on them? )
// and possible replacement of strtok // possible replacement of strtok
//------------------------------------ //------------------------------------
bool Keys::load(char *filename) { bool Keys::load(char *filename) {
if (!filename) if (!filename)
@ -220,12 +225,12 @@ bool Keys::load(char *filename) {
unsigned int i=0; unsigned int i=0;
for (i=0; i< lastKeygrab; i++) { for (i=0; i< LASTKEYGRAB; i++) {
if (strcasecmp(m_actionlist[i].string, val) == 0) if (strcasecmp(m_actionlist[i].string, val) == 0)
break; break;
} }
if (i < lastKeygrab ) { if (i < LASTKEYGRAB ) {
if (!current_key) { if (!current_key) {
cerr<<"Error on line: "<<line<<endl; cerr<<"Error on line: "<<line<<endl;
cerr<<linebuffer<<endl; cerr<<linebuffer<<endl;
@ -236,13 +241,13 @@ bool Keys::load(char *filename) {
} }
//special case for grabAbortKeychain //special case for grabAbortKeychain
if (m_actionlist[i].action == grabAbortKeychain) { if (m_actionlist[i].action == ABORTKEYCHAIN) {
if (last_key!=current_key) if (last_key!=current_key)
cerr<<"Keys: "<<m_actionlist[i].string<<" cant be in chained mode"<<endl; cerr<<"Keys: "<<m_actionlist[i].string<<" cant be in chained mode"<<endl;
else if (m_abortkey) else if (m_abortkey)
cerr<<"Keys: "<<m_actionlist[i].string<<" is already bound."<<endl; cerr<<"Keys: "<<m_actionlist[i].string<<" is already bound."<<endl;
else else
m_abortkey = new t_key(current_key->key, current_key->mod, grabAbortKeychain); m_abortkey = new t_key(current_key->key, current_key->mod, ABORTKEYCHAIN);
delete current_key; delete current_key;
current_key = 0; current_key = 0;
@ -251,7 +256,7 @@ bool Keys::load(char *filename) {
} }
last_key->action = m_actionlist[i].action; last_key->action = m_actionlist[i].action;
if (last_key->action == grabExecute) if (last_key->action == Keys::EXECUTE)
last_key->execcommand = &linebuffer[linepos]; last_key->execcommand = &linebuffer[linepos];
//add the keychain to list //add the keychain to list
@ -259,7 +264,7 @@ bool Keys::load(char *filename) {
cerr<<"Keys: Faild to merge keytree!"<<endl; cerr<<"Keys: Faild to merge keytree!"<<endl;
#ifdef DEBUG #ifdef DEBUG
if (m_actionlist[i].action == Keys::grabExecute) { if (m_actionlist[i].action == Keys::EXECUTE) {
cerr<<"linepos:"<<linepos<<endl; cerr<<"linepos:"<<linepos<<endl;
cerr<<"buffer:"<<&linebuffer[linepos]<<endl; cerr<<"buffer:"<<&linebuffer[linepos]<<endl;
@ -424,7 +429,7 @@ Keys::KeyAction Keys::getAction(XKeyEvent *ke) {
next_key = m_keylist[i]; next_key = m_keylist[i];
break; //end for-loop break; //end for-loop
} else { } else {
if (m_keylist[i]->action == grabExecute) if (m_keylist[i]->action == Keys::EXECUTE)
m_execcmdstring = m_keylist[i]->execcommand; //update execcmdstring if action is grabExecute m_execcmdstring = m_keylist[i]->execcommand; //update execcmdstring if action is grabExecute
return m_keylist[i]->action; return m_keylist[i]->action;
} }
@ -438,21 +443,21 @@ Keys::KeyAction Keys::getAction(XKeyEvent *ke) {
next_key = temp_key; next_key = temp_key;
} else { } else {
next_key = 0; next_key = 0;
if (temp_key->action == grabExecute) if (temp_key->action == Keys::EXECUTE)
m_execcmdstring = temp_key->execcommand; //update execcmdstring if action is grabExecute m_execcmdstring = temp_key->execcommand; //update execcmdstring if action is grabExecute
return temp_key->action; return temp_key->action;
} }
} else { } else {
temp_key = next_key; temp_key = next_key;
next_key = 0; next_key = 0;
if (temp_key->action == grabExecute) if (temp_key->action == Keys::EXECUTE)
m_execcmdstring = temp_key->execcommand; //update execcmdstring if action is grabExecute m_execcmdstring = temp_key->execcommand; //update execcmdstring if action is grabExecute
return temp_key->action; return temp_key->action;
} }
} }
return lastKeygrab; return Keys::LASTKEYGRAB;
} }
//--------- reconfigure ------------- //--------- reconfigure -------------
@ -520,7 +525,7 @@ bool Keys::mergeTree(t_key *newtree, t_key *basetree) {
for (; baselist_i<m_keylist.size(); baselist_i++) { for (; baselist_i<m_keylist.size(); baselist_i++) {
if (m_keylist[baselist_i]->mod == newtree->mod && if (m_keylist[baselist_i]->mod == newtree->mod &&
m_keylist[baselist_i]->key == newtree->key) { m_keylist[baselist_i]->key == newtree->key) {
if (newtree->keylist.size() && m_keylist[baselist_i]->action == lastKeygrab) { if (newtree->keylist.size() && m_keylist[baselist_i]->action == LASTKEYGRAB) {
//assumes the newtree only have one branch //assumes the newtree only have one branch
return mergeTree(newtree->keylist[0], m_keylist[baselist_i]); return mergeTree(newtree->keylist[0], m_keylist[baselist_i]);
} else } else

View file

@ -23,29 +23,30 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <X11/Xlib.h>
class Keys class Keys
{ {
public: public:
enum KeyAction{ enum KeyAction{
grabIconify=0, ICONIFY=0,
grabRaise, RAISE,
grabLower, LOWER,
grabClose, CLOSE,
grabAbortKeychain, ABORTKEYCHAIN,
grabWorkspace1, grabWorkspace2, grabWorkspace3, grabWorkspace4, grabWorkspace5, WORKSPACE1, WORKSPACE2, WORKSPACE3, WORKSPACE4, WORKSPACE5,
grabWorkspace6, grabWorkspace7, grabWorkspace8, grabWorkspace9, grabWorkspace10, WORKSPACE6, WORKSPACE7, WORKSPACE8, WORKSPACE9, WORKSPACE10,
grabWorkspace11, grabWorkspace12, grabNextWorkspace, grabPrevWorkspace, WORKSPACE11, WORKSPACE12, NEXTWORKSPACE, PREVWORKSPACE,
grabLeftWorkspace, grabRightWorkspace, LEFTWORKSPACE, RIGHTWORKSPACE,
grabKillWindow, grabNextWindow, grabPrevWindow, KILLWINDOW, NEXTWINDOW, PREVWINDOW,
grabNextTab, grabPrevTab, NEXTTAB, PREVTAB,
grabShade, grabMaximize, grabStick, grabExecute, grabVertMax, SHADE, MAXIMIZE, STICK, EXECUTE, VERTMAX,
grabHorizMax, grabNudgeRight, grabNudgeLeft,grabNudgeUp, HORIZMAX, NUDGERIGHT, NUDGELEFT,NUDGEUP,
grabNudgeDown, grabBigNudgeRight, grabBigNudgeLeft, NUDGEDOWN, BIGNUDGERIGHT, BIGNUDGELEFT,
grabBigNudgeUp, grabBigNudgeDown, BIGNUDGEUP, BIGNUDGEDOWN,
grabHorizInc, grabVertInc, grabHorizDec, grabVertDec, HORIZINC, VERTINC, HORIZDEC, VERTDEC,
grabToggleDecor, TOGGLEDECOR,
lastKeygrab LASTKEYGRAB
}; };
Keys(char *filename); Keys(char *filename);
@ -66,7 +67,7 @@ private:
class t_key { class t_key {
public: public:
t_key(unsigned int key, unsigned int mod, KeyAction action_ = lastKeygrab); t_key(unsigned int key, unsigned int mod, KeyAction action_ = Keys::LASTKEYGRAB);
t_key(t_key *k); t_key(t_key *k);
~t_key(); ~t_key();