123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694 |
- === modified file 'fltk/jwm-keyboard.cxx'
- --- fltk/jwm-keyboard.cxx 2018-01-16 14:17:27 +0000
- +++ fltk/jwm-keyboard.cxx 2018-10-03 19:59:48 +0000
- @@ -1260,6 +1260,7 @@
- if(checkFlBrowserItem(key_browser)){
- debug_out("Configure callback");
- config_key_win()->show();
- + if(!Configure(key_browser,action_name1,current_key,current_mod1,current_mod2,current_mod3,old_action)){debug_out("Configure failed");}
- };
- }
- void KeyboardUI::cb_2(Fl_Button* o, void* v) {
- @@ -1428,7 +1429,7 @@
- } // Fl_Menu_Button* o
- debug_out("config_key_win()->show()");
- startup(o,jsm_keyboard_xpm);
- - if(!Configure(key_browser,action_name1,current_key,current_mod1,current_mod2,current_mod3,old_action)){debug_out("Configure failed");}
- + o->wait_for_expose();
- conf_key_win->xclass("jsm-keyboard");
- conf_key_win->end();
- } // Fl_Double_Window* conf_key_win
- @@ -1602,7 +1603,8 @@
- key_browser->labelfont(1);
- key_browser->align(Fl_Align(FL_ALIGN_TOP));
- static int widths[] = {50,175,105,0};o->column_widths(widths);
- - populateFLBrowser2Attr(key_browser,"Key","mask","key");
- + o->column_char(DELIM);
- + populateFLBrowser2Attr(key_browser,"Key","mask","key",DELIM);
- } // Fl_Browser* key_browser
- { Fl_Button* o = new Fl_Button(50, 260, 35, 30, gettext("-"));
- o->box(FL_FLAT_BOX);
- === modified file 'fltk/jwm-keyboard.fld'
- --- fltk/jwm-keyboard.fld 2018-01-16 14:17:27 +0000
- +++ fltk/jwm-keyboard.fld 2018-10-03 19:59:48 +0000
- @@ -110,13 +110,14 @@
- } {
- decl {int JWMVERSION;} {private local
- }
- - Function {config_key_win()} {} {
- + Function {config_key_win()} {open
- + } {
- Fl_Window conf_key_win {
- label {Configure Keyboard Shortcut} open
- - xywh {594 344 355 180} type Double hide
- + xywh {895 387 355 180} type Double
- code0 {debug_out("config_key_win()->show()");}
- code1 {startup(o,jsm_keyboard_xpm);}
- - code2 {if(!Configure(key_browser,action_name1,current_key,current_mod1,current_mod2,current_mod3,old_action)){debug_out("Configure failed");}} xclass {jsm-keyboard}
- + code2 {o->wait_for_expose();} xclass {jsm-keyboard} visible
- } {
- Fl_Button {} {
- label OK
- @@ -131,7 +132,7 @@
- xywh {285 145 65 30} box FLAT_BOX color 61 selection_color 58 labelcolor 7
- }
- Fl_Menu_Button {} {
- - label Action open
- + label Action
- xywh {220 110 130 30} box FLAT_BOX color 23 selection_color 80
- } {
- MenuItem next1 {
- @@ -443,7 +444,7 @@
- xywh {140 20 50 20} box FLAT_BOX color 45 textcolor 55 hide
- }
- Fl_Menu_Button {} {
- - label {Special Keys} open
- + label {Special Keys}
- tooltip {Picture button keys on the keyboard} xywh {220 75 130 30} box FLAT_BOX color 23 selection_color 80
- } {
- MenuItem {} {
- @@ -544,7 +545,7 @@
- xywh {280 115 65 30} box FLAT_BOX color 61 selection_color 58 labelcolor 7
- }
- Fl_Menu_Button {} {
- - label Action open
- + label Action
- xywh {210 80 135 30} box FLAT_BOX color 23 selection_color 80
- } {
- MenuItem next {
- @@ -839,7 +840,7 @@
- tooltip {Second keyboard modifier} xywh {270 5 75 30} box FLAT_BOX color 53
- }
- Fl_Menu_Button {} {
- - label {Special Keys} open
- + label {Special Keys}
- tooltip {Picture button keys on the keyboard} xywh {210 40 135 30} box FLAT_BOX color 23 selection_color 80
- } {
- MenuItem {} {
- @@ -925,8 +926,7 @@
- }
- }
- }
- - Function {layout_window()} {open
- - } {
- + Function {layout_window()} {} {
- Fl_Window layout_win {
- label Layout open
- xywh {561 233 490 310} type Double hide
- @@ -985,7 +985,7 @@
- //Fl::add_handler(handle);} {}
- Fl_Window keyboard_window {
- label {Keyboard Settings} open
- - xywh {676 429 480 295} type Double color 31 resizable
- + xywh {882 85 480 295} type Double color 31 resizable
- code0 {startup(o,jsm_keyboard_xpm);} xclass {jsm-keyboard} visible
- } {
- Fl_Scroll {} {open
- @@ -995,7 +995,8 @@
- label {Keyboard Shortcuts} selected
- xywh {5 20 470 235} type Hold box FLAT_BOX selection_color 80 labelfont 1 align 1
- code1 {static int widths[] = {50,175,105,0};o->column_widths(widths);}
- - code3 {populateFLBrowser2Attr(key_browser,"Key","mask","key");}
- + code2 {o->column_char(DELIM);}
- + code3 {populateFLBrowser2Attr(key_browser,"Key","mask","key",DELIM);}
- }
- Fl_Button {} {
- label {-}
- @@ -1022,6 +1023,7 @@
- callback {if(checkFlBrowserItem(key_browser)){
- debug_out("Configure callback");
- config_key_win()->show();
- + if(!Configure(key_browser,action_name1,current_key,current_mod1,current_mod2,current_mod3,old_action)){debug_out("Configure failed");}
- }}
- image {custom_buttons/gear16.png} xywh {100 260 30 30} box FLAT_BOX color 23 labelfont 1
- }
- === modified file 'fltk/jwm-shutdown.cxx'
- --- fltk/jwm-shutdown.cxx 2017-01-29 14:15:16 +0000
- +++ fltk/jwm-shutdown.cxx 2018-10-03 19:59:48 +0000
- @@ -71,7 +71,7 @@
- LOGOUT="torios-exit || jwm -exit";
- SHUTDOWN="torios-shutdown || dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop || systemctl poweroff";;
- RESTART="torios-reboot || dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart|| systemctl reboot";
- - { shutdown_window = new Fl_Double_Window(242, 230, gettext("Shutdown"));
- + { Fl_Double_Window* o = shutdown_window = new Fl_Double_Window(242, 230, gettext("Shutdown"));
- shutdown_window->color(FL_DARK2);
- shutdown_window->user_data((void*)(this));
- { Fl_Button* o = shut = new Fl_Button(10, 10, 105, 75, gettext("Shutdown"));
- @@ -112,6 +112,7 @@
- can->callback((Fl_Callback*)cb_can);
- } // Fl_Button* can
- window_bg();
- + if(!make_window_above(o)){std::cerr<<"Couldn't make window work"<<std::endl;}
- shutdown_window->clear_border();
- shutdown_window->xclass("system-shutdown");
- shutdown_window->end();
- @@ -142,3 +143,31 @@
- //can->labelcolor(color2);
- under_mouse(shutdown_window);
- }
- +
- +bool shutdown::make_window_above(Fl_Window *o) {
- + Atom wmStateAbove = XInternAtom( fl_display, "_NET_WM_STATE_ABOVE", 1 );
- + if( wmStateAbove == None )
- + return false;
- + Atom wmNetWmState = XInternAtom( fl_display, "_NET_WM_STATE", 1 );
- + if( wmNetWmState == None )
- + return false;
- +
- + XClientMessageEvent xclient;
- + memset( &xclient, 0, sizeof (xclient) );
- + xclient.type = ClientMessage;
- + xclient.window = fl_xid(o);
- + xclient.message_type = wmNetWmState;
- + xclient.format = 32;
- + xclient.data.l[0] = 1;//_NET_WM_STATE_ADD;
- + xclient.data.l[1] = wmStateAbove;
- + xclient.data.l[2] = 0;
- + xclient.data.l[3] = 0;
- + xclient.data.l[4] = 0;
- + Window root = DefaultRootWindow( fl_display );
- + XSendEvent( fl_display,
- + root,
- + False,
- + SubstructureRedirectMask | SubstructureNotifyMask,
- + (XEvent *)&xclient );
- + return true;
- +}
- === modified file 'fltk/jwm-shutdown.fld'
- --- fltk/jwm-shutdown.fld 2018-01-16 14:17:27 +0000
- +++ fltk/jwm-shutdown.fld 2018-10-03 19:59:48 +0000
- @@ -42,13 +42,19 @@
- decl {\#include <iostream>} {public global
- }
-
- +decl {\#include <FL/x.H>} {public global
- +}
- +
- +decl {\#include <X11/Xlib.h>} {public global
- +}
- +
- decl {\#include "../include/fltkfunctions.hpp"} {public global
- }
-
- decl {\#include "../include/jwmrc.hpp"} {public global
- }
-
- -class shutdown {open selected : {public FLTK_FUNCTIONS}
- +class shutdown {open : {public FLTK_FUNCTIONS}
- } {
- decl {std::string SUSPEND,LOGOUT,SHUTDOWN,RESTART;} {private local
- }
- @@ -62,7 +68,8 @@
- Fl_Window shutdown_window {
- label Shutdown open
- xywh {351 113 242 230} type Double color 45
- - code0 {window_bg();} noborder xclass {system-shutdown} visible
- + code0 {window_bg();}
- + code1 {if(!make_window_above(o)){std::cerr<<"Couldn't make window work"<<std::endl;}} noborder xclass {system-shutdown} visible
- } {
- Fl_Button shut {
- label Shutdown
- @@ -123,4 +130,33 @@
- //can->labelcolor(color2);
- under_mouse(shutdown_window);} {}
- }
- + Function {make_window_above(Fl_Window *o)} {open return_type bool
- + } {
- + code {Atom wmStateAbove = XInternAtom( fl_display, "_NET_WM_STATE_ABOVE", 1 );
- +if( wmStateAbove == None )
- + return false;
- +Atom wmNetWmState = XInternAtom( fl_display, "_NET_WM_STATE", 1 );
- +if( wmNetWmState == None )
- + return false;
- +
- +XClientMessageEvent xclient;
- +memset( &xclient, 0, sizeof (xclient) );
- +xclient.type = ClientMessage;
- +xclient.window = fl_xid(o);
- +xclient.message_type = wmNetWmState;
- +xclient.format = 32;
- +xclient.data.l[0] = 1;//_NET_WM_STATE_ADD;
- +xclient.data.l[1] = wmStateAbove;
- +xclient.data.l[2] = 0;
- +xclient.data.l[3] = 0;
- +xclient.data.l[4] = 0;
- +Window root = DefaultRootWindow( fl_display );
- +XSendEvent( fl_display,
- + root,
- + False,
- + SubstructureRedirectMask | SubstructureNotifyMask,
- + (XEvent *)&xclient );
- +return true;} {selected
- + }
- + }
- }
- === modified file 'fltk/jwm-shutdown.h'
- --- fltk/jwm-shutdown.h 2018-01-16 14:17:27 +0000
- +++ fltk/jwm-shutdown.h 2018-10-03 19:59:48 +0000
- @@ -30,6 +30,8 @@
- #include <string>
- #include <stdlib.h>
- #include <iostream>
- +#include <FL/x.H>
- +#include <X11/Xlib.h>
- #include "../include/fltkfunctions.hpp"
- #include "../include/jwmrc.hpp"
- #include <FL/Fl_Double_Window.H>
- @@ -66,5 +68,6 @@
- static void cb_can(Fl_Button*, void*);
- public:
- void window_bg();
- + bool make_window_above(Fl_Window *o);
- };
- #endif
- === modified file 'include/jwmrc.hpp'
- --- include/jwmrc.hpp 2018-01-16 14:17:27 +0000
- +++ include/jwmrc.hpp 2022-11-26 19:54:59 +0000
- @@ -136,7 +136,7 @@
- bool populateFLBrowser(Fl_Browser *o, std::string element, std::string attribute, std::string attribute_value, std::string attribute2, std::string optional_attribute);
- bool populateFLBrowser(Fl_Browser *o, std::string element, std::string subelement, unsigned int whichMainElement);
- bool populateFLBrowserElements(Fl_Browser *o, pugi::xml_node noder);
- - bool populateFLBrowser2Attr(Fl_Browser *o, std::string element, std::string attribute1, std::string attribute2);
- + bool populateFLBrowser2Attr(Fl_Browser *o, std::string element, std::string attribute1, std::string attribute2,char delim='\t');
- //R
- bool removeMenu(std::string value);
- //S
- === modified file 'include/keyboard.hpp'
- --- include/keyboard.hpp 2018-01-16 14:17:27 +0000
- +++ include/keyboard.hpp 2018-10-03 19:59:48 +0000
- @@ -54,12 +54,15 @@
- class JWM_Keyboard : public FLTK_FUNCTIONS
- {
- public:
- + char DELIM;
- + std::string DELIMITER;
- + JWM_Keyboard();
- //void
- void addKey(std::string key, std::string shortcut);
- void addKey(std::string keyMod, std::string key, std::string shortcut);
- void changemod(std::string mod,Fl_Output* Aout,Fl_Output* Bout);
- void changemod(std::string mod,Fl_Output* Aout,Fl_Output* Bout,Fl_Output* Cout);
- - void configureKey(std::string keyShortcut, std::string newmod1, std::string newmod2, std::string newmod3, std::string newkey, std::string newaction);
- + bool configureKey(std::string keyShortcut, std::string newmod1, std::string newmod2, std::string newmod3, std::string newkey, std::string newaction);
- void Choose_Action(Fl_Input* action_name);
- void deleteKey(std::string keyShortcut);
- void key_event(Fl_Input* o, Fl_Output* out, Fl_Output* modder);
- @@ -78,7 +81,7 @@
- std::string getAction(std::string keyShortcut);
- std::string getKey(std::string keyShortcut);
- std::string getLayout(Fl_Input *o,std::string whichOne);
- - std::string getMod(std::string keyShortcut);
- + std::string getMod(std::string keyShortcut,unsigned int which);
- std::string getMod1(std::string keyShortcut);
- std::string getMod2(std::string keyShortcut);
- std::string getMod3(std::string keyShortcut);
- @@ -96,7 +99,8 @@
- Fl_Output *mod3_output,
- Fl_Output *old_value);
- bool Configure_CB(Fl_Output* mod1_output, Fl_Output* mod2_output,Fl_Output* mod3_output, Fl_Input * keyshortcut,Fl_Input * action_name1,std::string CURRENT);
- + bool emptyString(std::string s);
- + bool getKeys(Fl_Browser* o);
- bool newpanel();
- - bool getKeys(Fl_Browser* o);
- };
- #endif
- === modified file 'src/fltkfunctions.cpp'
- --- src/fltkfunctions.cpp 2018-01-16 14:17:27 +0000
- +++ src/fltkfunctions.cpp 2018-10-03 19:59:48 +0000
- @@ -444,7 +444,8 @@
- delete(image);
- }
- else{return;}
- - widget->image(image2);
- + widget->image(image2->copy());
- + delete(image2);
- }
- //O
- /** set one Background element color
- === modified file 'src/jwmrc.cpp'
- --- src/jwmrc.cpp 2018-01-16 14:17:27 +0000
- +++ src/jwmrc.cpp 2022-11-26 21:09:14 +0000
- @@ -872,7 +872,7 @@
- }
- return true;
- }
- -bool JWMRC::populateFLBrowser2Attr(Fl_Browser *o,std::string element,std::string attribute1, std::string attribute2){
- +bool JWMRC::populateFLBrowser2Attr(Fl_Browser *o,std::string element,std::string attribute1, std::string attribute2, char delim){
- debug_out("bool populateFLBrowser2Attr(Fl_Browser *o,std::string "+element+",std::string "+attribute1+",std::string " + attribute2+")");
- if(element.compare("")==0){
- debug_out("Element NOT specified");
- === modified file 'src/keyboard.cpp'
- --- src/keyboard.cpp 2018-01-16 14:17:27 +0000
- +++ src/keyboard.cpp 2018-10-03 19:59:48 +0000
- @@ -1,5 +1,10 @@
- #include "../include/keyboard.hpp"
- //Void//////////////////////////////////////////////////////////////////
- +JWM_Keyboard::JWM_Keyboard ()
- +{
- + DELIM='@';
- + DELIMITER=DELIM;
- +}
- void JWM_Keyboard::addKey(std::string key, std::string shortcut){
- debug_out("void addKey(std::string "+ key+", std::string " +shortcut+ ")");
- if(!addElementWithTextAndAttribute("Key","key",key,shortcut)){debug_out("Add Key Failed");}
- @@ -19,9 +24,9 @@
- else if(OutputIsEmpty(Cout)){Cout->value(mod.c_str());}
- else{debug_out("All Mods are filled");}
- }
- -void JWM_Keyboard::configureKey(std::string keyShortcut, std::string newmod1, std::string newmod2, std::string newmod3, std::string newkey, std::string newaction){
- +bool JWM_Keyboard::configureKey(std::string keyShortcut, std::string newmod1, std::string newmod2, std::string newmod3, std::string newkey, std::string newaction){
- debug_out("void configureKey(std::string "+keyShortcut+", std::string "+newmod1+", std::string "+newmod2+", std::string "+newmod3+", std::string "+newkey+", std::string "+newaction+")");
- - if(keyShortcut.compare("")==0){return;}
- + if(keyShortcut.compare("")==0){return false;}
- std::string mod1FromProg,
- mod2FromProg,
- mod3FromProg,
- @@ -39,13 +44,20 @@
- pugi::xml_node node=compareNode("Key","key",keyFromProg,"mask",totalMod,actionFromProg);
- if(node){
- //found it!
- - if(!node.attribute("mask")){node.append_attribute("mask");}
- - node.attribute("mask").set_value(totalNewMod.c_str());
- + if(totalNewMod.compare("")!=0)
- + {
- + if(!node.attribute("mask")){node.append_attribute("mask");}
- + node.attribute("mask").set_value(totalNewMod.c_str());
- + }
- if(!node.attribute("key")){node.append_attribute("key");} //This should NEVER happen..
- node.attribute("key").set_value(keyShortcut.c_str());
- node.set_value(newaction.c_str());
- + return saveChangesTemp();
- }
- -
- + else{
- + debug_out("Didn't find node key="+keyFromProg+" mask="+totalMod+" text="+actionFromProg);
- + }
- + return false;
- }
- void JWM_Keyboard::Choose_Action(Fl_Input* action_name){
- debug_out("void Choose_Action(Fl_Input* action_name)");
- @@ -180,6 +192,7 @@
- debug_out("void setLayout(Fl_Input *layoutput, Fl_Input *modeloutput, Fl_Input *optionoutput)");
- someLayout(layoutput, modeloutput, optionoutput,true);
- }
- +
- void JWM_Keyboard::someLayout(Fl_Input *layoutput, Fl_Input *modeloutput, Fl_Input *optionoutput, bool save){
- std::string SAVE="Don't Save";
- if(save){SAVE="SAVE!";}
- @@ -239,6 +252,7 @@
- int retval=linuxcommon::run_a_program(command);
- if(retval!=0){errorOUT("Could not run "+command);}
- }
- +
- void JWM_Keyboard::testLayout(Fl_Input *layoutput, Fl_Input *modeloutput, Fl_Input *optionoutput){
- debug_out("void testLayout(Fl_Input *layoutput, Fl_Input *modeloutput, Fl_Input *optionoutput)");
- someLayout(layoutput, modeloutput, optionoutput,false);
- @@ -259,43 +273,19 @@
- }
- return retval;
- }
- +
- std::string JWM_Keyboard::getAction(std::string keyShortcut){
- debug_out("std::string getAction(std::string "+keyShortcut+")");
- if(keyShortcut.compare("")==0){return "";}
- - std::string fromProgram = keyShortcut;
- - //shortcut
- - unsigned length =fromProgram.length();
- - unsigned found = fromProgram.find_last_of("\t");
- - if(found < length){
- - fromProgram = fromProgram.erase(0,found+1);
- - debug_out("getAction: "+fromProgram);
- - return fromProgram;
- - }
- - return "";
- + return getMod(keyShortcut,4);
- }
- +
- std::string JWM_Keyboard::getKey(std::string keyShortcut){
- debug_out("std::string getKey(std::string "+keyShortcut+")");
- if(keyShortcut.compare("")==0){return "";}
- - std::string fromProgram = keyShortcut;
- - std::string keymod2 =keyShortcut;
- - //shortcut
- - unsigned length =fromProgram.length();
- - //recheck this code
- - unsigned found = fromProgram.find_last_of("\t");
- - unsigned found1 = fromProgram.find_first_of("\t");
- - unsigned found2 = fromProgram.find_first_of("\t",found1);
- - if(found < length){
- - fromProgram = fromProgram.erase(0,found+1);
- - //keymod 2
- - if(found2 < keymod2.length()){
- - keymod2 = keymod2.erase(found,std::string::npos);
- - keymod2 = keymod2.erase(0,found2+1);
- - debug_out("getKey: "+keymod2);
- - return keymod2;
- - }
- - }
- - return "";
- + return getMod(keyShortcut,0);
- }
- +
- std::string JWM_Keyboard::getLayout(Fl_Input *o,std::string whichOne){
- debug_out("std::string getLayout()");
- std::string test_command=linuxcommon::term_out("which localectl");
- @@ -318,7 +308,7 @@
- for( std::vector<std::string>::iterator it = STRING_VEC.begin();
- it!=STRING_VEC.end();
- ++it){
- - std::string tmp=*it;
- + std::string tmp=*it;
- std::transform(tmp.begin(),tmp.end(),tmp.begin(), ::tolower);
- unsigned int finder = tmp.find(whichOne);
- if(finder<tmp.length()){
- @@ -331,68 +321,64 @@
- }
- return layout;
- }
- -std::string JWM_Keyboard::getMod(std::string keyShortcut){
- +
- +std::string JWM_Keyboard::getMod(std::string keyShortcut,unsigned int which=1){
- debug_out("std::string getMod(std::string "+keyShortcut+")");
- - if(keyShortcut.compare("")==0){return "";}
- - std::string keymod =keyShortcut;
- - //shortcut
- - unsigned length =keyShortcut.length();
- - unsigned found = keyShortcut.find_first_of("\t");
- - if(found < length){
- - keymod = keymod.erase(found,std::string::npos);
- - return keymod;
- - }
- - return "";
- + if(keyShortcut.compare("")==0){return "";}
- + std::string keymod =keyShortcut;
- + std::vector<std::string> T= linuxcommon::delimiter_vector_from_string(keyShortcut,DELIMITER);
- + if(which>=T.size())
- + return "";
- + std::string tmp=T.at(which);
- + debug_out("Value="+tmp);
- }
- +
- std::string JWM_Keyboard::getMod1(std::string keyShortcut){
- debug_out("std::string getMod1(std::string "+keyShortcut+")");
- - if(keyShortcut.compare("")==0){return "";}
- - std::string result =getMod(keyShortcut);
- - unsigned int len = result.length();
- - if(len>1){result=result.erase(1,std::string::npos);}
- - debug_out("mod1:"+result);
- - return result;
- + if(keyShortcut.compare("")==0){return "";}
- + return getMod(keyShortcut,1);
-
- }
- +
- std::string JWM_Keyboard::getMod2(std::string keyShortcut){
- debug_out("std::string getMod2(std::string "+keyShortcut+")");
- - if(keyShortcut.compare("")==0){return "";}
- - std::string result =getMod(keyShortcut);
- - unsigned int len = result.length();
- - if(len>1){result=result.erase(0,1);}
- - len = result.length();
- - if(len>2){result=result.erase(1,std::string::npos);}
- - debug_out("mod2:"+result);
- - return result;
- + if(keyShortcut.compare("")==0){return "";}
- + return getMod(keyShortcut,2);
- }
- +
- std::string JWM_Keyboard::getMod3(std::string keyShortcut){
- debug_out("std::string getMod3(std::string "+keyShortcut+")");
- - if(keyShortcut.compare("")==0){return "";}
- - std::string result =getMod(keyShortcut);
- - unsigned int len = result.length();
- - if(len>2){result=result.erase(0,2);}
- - else{result="";}
- - debug_out("mod3:"+result);
- - return result;
- + if(keyShortcut.compare("")==0){return "";}
- + return getMod(keyShortcut,3);
- }
- +
- std::string JWM_Keyboard::getINPUT(Fl_Input *o){
- debug_out("std::string getINPUT(Fl_Input *o)");
- - if(o->visible()!=0){return "";}
- + if(!o->visible())
- + {
- + debug_out("input not visible");
- + return "";
- + }
- const char* out=o->value();
- - if(out==NULL){return "";}
- + if(out==NULL)
- + {
- + debug_out("input value is NULL");
- + return "";
- + }
- std::string outer=out;
- debug_out("INPUT="+outer);
- return outer;
- }
- std::string JWM_Keyboard::getOUTPUT(Fl_Output *o){
- debug_out("std::string getOUTPUT(Fl_Output *o)");
- - if(o->visible()!=0){return "";}
- + if(!o->visible()){return "";}
- const char* out=o->value();
- if(out==NULL){return "";}
- std::string outer=out;
- debug_out("OUTPUT="+outer);
- return outer;
- }
- +
- std::string JWM_Keyboard::grabbedKey(){
- struct termios oldSettings, newSettings;
- tcgetattr( fileno( stdin ), &oldSettings );
- @@ -433,6 +419,7 @@
- return result;
-
- }
- +
- std::string JWM_Keyboard::oldvalue(Fl_Output* old_action, Fl_Output* current_key,Fl_Output* current_mod1,Fl_Output* current_mod2,Fl_Output* current_mod3){
- std::string temp;
- const char* mod1=current_mod1->value();
- @@ -444,11 +431,14 @@
- const char* keychar=current_key->value();
- if(keychar!=NULL){
- std::string keycurrent=keychar;
- - if(temp.compare("")==0)temp="\t"+keycurrent;
- - else{temp=temp+"\t"+keycurrent;}
- + if(temp.compare("")==0)temp=" "+DELIMITER+keycurrent;
- + else{temp=temp+DELIMITER+keycurrent;}
- }
- + else{temp+=" "+DELIMITER;}
- const char* actionian=old_action->value();
- - if(actionian!=NULL){temp=temp+"\t"+ actionian;}
- + if(actionian!=NULL){temp=temp+DELIMITER+ actionian;}
- + else{temp+=(DELIMITER +" ");}
- + temp+=DELIMITER;
- return temp;
- }
- //Boolean///////////////////////////////////////////////////////////////
- @@ -469,8 +459,8 @@
- debug_out("No action chosen...");
- return false;
- }
- - if(keyInput.compare("")!=0){
- - if(mod.compare("")!=0){addKey(mod,keyInput,action);}
- + if(!emptyString(keyInput)){
- + if(!emptyString(mod)){addKey(mod,keyInput,action);}
- else{addKey(keyInput,action);}
- o->clear();
- getKeys(o);
- @@ -485,22 +475,25 @@
- Fl_Output *mod1_output,
- Fl_Output *mod2_output,
- Fl_Output *mod3_output,
- - Fl_Output *old_value) {
- + Fl_Output *old_value)
- +{
- debug_out("bool Configure(Fl_Browser *key_browser,Fl_Input *action_name1,Fl_Output *current_shortcut,Fl_Output *mod1_output,Fl_Output *mod2_output,Fl_Output *mod3_output,Fl_Output *old_value)");
- - if(!checkFlBrowserItem(key_browser)){
- - debug_out("Browser didn't have anything nice selected");
- - return false;
- - }
- const char* mykey = key_browser->text(key_browser->value());
- + if(mykey==NULL)
- + {
- + debug_out("Configure keyshortcut empty");
- + return false;
- + }
- std::string keyShortcut = mykey;
- - if (keyShortcut.compare("")!=0){
- + if(!emptyString(keyShortcut)){
- + debug_out("Configure line="+keyShortcut);
- std::string mod1,mod2,mod3,key,program;
- mod1=getMod1(keyShortcut);
- - if(mod1.compare("")!=0){mod1_output->value(mod1.c_str());}
- + if(!emptyString(mod1)){mod1_output->value(mod1.c_str());}
- mod2=getMod2(keyShortcut);
- - if(mod2.compare("")!=0){mod2_output->value(mod2.c_str());}
- + if(!emptyString(mod2)){mod2_output->value(mod2.c_str());}
- mod3=getMod3(keyShortcut);
- - if(mod3.compare("")!=0){mod3_output->value(mod3.c_str());}
- + if(!emptyString(mod3)){mod3_output->value(mod3.c_str());}
- key=getKey(keyShortcut);
- program=getAction(keyShortcut);
- action_name1->value(program.c_str());
- @@ -509,7 +502,7 @@
- getKeys(key_browser);
- return true;
- }
- - else{fl_message("Please click on an item to remove!");}
- + else{fl_message("Please click on an item to configure!");}
- return false;
- }
- bool JWM_Keyboard::Configure_CB(Fl_Output* mod1_output, Fl_Output* mod2_output,Fl_Output* mod3_output, Fl_Input * keyshortcut,Fl_Input * action_name1,std::string CURRENT){
- @@ -520,17 +513,31 @@
- MOD3=getOUTPUT(mod3_output);
- KEY=getINPUT(keyshortcut);
- ACTION=getINPUT(action_name1);
- - if(ACTION.compare("")==0){return false;}
- - if(CURRENT.compare("")==0){return false;}
- - configureKey(CURRENT,MOD1,MOD2,MOD3,KEY,ACTION);
- - return true;
- + if(emptyString(ACTION))
- + {
- + debug_out("No action chosen");
- + return false;
- + }
- + if(emptyString(CURRENT))
- + {
- + debug_out("CURRENT is empty");
- + return false;
- + }
- + if(!configureKey(CURRENT,MOD1,MOD2,MOD3,KEY,ACTION)){return false;}
- + return saveChanges();
- +}
- +bool JWM_Keyboard::emptyString(std::string s)
- +{
- + if ( (s.compare("")==0) || (s.compare("")==0) )
- + return true;
- + return false;
- +}
- +bool JWM_Keyboard::getKeys(Fl_Browser* o){
- + populateFLBrowser2Attr(o,"Key","key","mask");
- + return false;
- }
- bool JWM_Keyboard::newpanel(){
- debug_out("bool newpanel()");
- if(newStyle() == -1){return false;}
- return true;
- }
- -bool JWM_Keyboard::getKeys(Fl_Browser* o){
- - populateFLBrowser2Attr(o,"Key","key","mask");
- - return false;
- -}
|