revisions_287.patch 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. === modified file 'fltk/jwm-keyboard.cxx'
  2. --- fltk/jwm-keyboard.cxx 2018-01-16 14:17:27 +0000
  3. +++ fltk/jwm-keyboard.cxx 2018-10-03 19:59:48 +0000
  4. @@ -1260,6 +1260,7 @@
  5. if(checkFlBrowserItem(key_browser)){
  6. debug_out("Configure callback");
  7. config_key_win()->show();
  8. + if(!Configure(key_browser,action_name1,current_key,current_mod1,current_mod2,current_mod3,old_action)){debug_out("Configure failed");}
  9. };
  10. }
  11. void KeyboardUI::cb_2(Fl_Button* o, void* v) {
  12. @@ -1428,7 +1429,7 @@
  13. } // Fl_Menu_Button* o
  14. debug_out("config_key_win()->show()");
  15. startup(o,jsm_keyboard_xpm);
  16. - if(!Configure(key_browser,action_name1,current_key,current_mod1,current_mod2,current_mod3,old_action)){debug_out("Configure failed");}
  17. + o->wait_for_expose();
  18. conf_key_win->xclass("jsm-keyboard");
  19. conf_key_win->end();
  20. } // Fl_Double_Window* conf_key_win
  21. @@ -1602,7 +1603,8 @@
  22. key_browser->labelfont(1);
  23. key_browser->align(Fl_Align(FL_ALIGN_TOP));
  24. static int widths[] = {50,175,105,0};o->column_widths(widths);
  25. - populateFLBrowser2Attr(key_browser,"Key","mask","key");
  26. + o->column_char(DELIM);
  27. + populateFLBrowser2Attr(key_browser,"Key","mask","key",DELIM);
  28. } // Fl_Browser* key_browser
  29. { Fl_Button* o = new Fl_Button(50, 260, 35, 30, gettext("-"));
  30. o->box(FL_FLAT_BOX);
  31. === modified file 'fltk/jwm-keyboard.fld'
  32. --- fltk/jwm-keyboard.fld 2018-01-16 14:17:27 +0000
  33. +++ fltk/jwm-keyboard.fld 2018-10-03 19:59:48 +0000
  34. @@ -110,13 +110,14 @@
  35. } {
  36. decl {int JWMVERSION;} {private local
  37. }
  38. - Function {config_key_win()} {} {
  39. + Function {config_key_win()} {open
  40. + } {
  41. Fl_Window conf_key_win {
  42. label {Configure Keyboard Shortcut} open
  43. - xywh {594 344 355 180} type Double hide
  44. + xywh {895 387 355 180} type Double
  45. code0 {debug_out("config_key_win()->show()");}
  46. code1 {startup(o,jsm_keyboard_xpm);}
  47. - code2 {if(!Configure(key_browser,action_name1,current_key,current_mod1,current_mod2,current_mod3,old_action)){debug_out("Configure failed");}} xclass {jsm-keyboard}
  48. + code2 {o->wait_for_expose();} xclass {jsm-keyboard} visible
  49. } {
  50. Fl_Button {} {
  51. label OK
  52. @@ -131,7 +132,7 @@
  53. xywh {285 145 65 30} box FLAT_BOX color 61 selection_color 58 labelcolor 7
  54. }
  55. Fl_Menu_Button {} {
  56. - label Action open
  57. + label Action
  58. xywh {220 110 130 30} box FLAT_BOX color 23 selection_color 80
  59. } {
  60. MenuItem next1 {
  61. @@ -443,7 +444,7 @@
  62. xywh {140 20 50 20} box FLAT_BOX color 45 textcolor 55 hide
  63. }
  64. Fl_Menu_Button {} {
  65. - label {Special Keys} open
  66. + label {Special Keys}
  67. tooltip {Picture button keys on the keyboard} xywh {220 75 130 30} box FLAT_BOX color 23 selection_color 80
  68. } {
  69. MenuItem {} {
  70. @@ -544,7 +545,7 @@
  71. xywh {280 115 65 30} box FLAT_BOX color 61 selection_color 58 labelcolor 7
  72. }
  73. Fl_Menu_Button {} {
  74. - label Action open
  75. + label Action
  76. xywh {210 80 135 30} box FLAT_BOX color 23 selection_color 80
  77. } {
  78. MenuItem next {
  79. @@ -839,7 +840,7 @@
  80. tooltip {Second keyboard modifier} xywh {270 5 75 30} box FLAT_BOX color 53
  81. }
  82. Fl_Menu_Button {} {
  83. - label {Special Keys} open
  84. + label {Special Keys}
  85. tooltip {Picture button keys on the keyboard} xywh {210 40 135 30} box FLAT_BOX color 23 selection_color 80
  86. } {
  87. MenuItem {} {
  88. @@ -925,8 +926,7 @@
  89. }
  90. }
  91. }
  92. - Function {layout_window()} {open
  93. - } {
  94. + Function {layout_window()} {} {
  95. Fl_Window layout_win {
  96. label Layout open
  97. xywh {561 233 490 310} type Double hide
  98. @@ -985,7 +985,7 @@
  99. //Fl::add_handler(handle);} {}
  100. Fl_Window keyboard_window {
  101. label {Keyboard Settings} open
  102. - xywh {676 429 480 295} type Double color 31 resizable
  103. + xywh {882 85 480 295} type Double color 31 resizable
  104. code0 {startup(o,jsm_keyboard_xpm);} xclass {jsm-keyboard} visible
  105. } {
  106. Fl_Scroll {} {open
  107. @@ -995,7 +995,8 @@
  108. label {Keyboard Shortcuts} selected
  109. xywh {5 20 470 235} type Hold box FLAT_BOX selection_color 80 labelfont 1 align 1
  110. code1 {static int widths[] = {50,175,105,0};o->column_widths(widths);}
  111. - code3 {populateFLBrowser2Attr(key_browser,"Key","mask","key");}
  112. + code2 {o->column_char(DELIM);}
  113. + code3 {populateFLBrowser2Attr(key_browser,"Key","mask","key",DELIM);}
  114. }
  115. Fl_Button {} {
  116. label {-}
  117. @@ -1022,6 +1023,7 @@
  118. callback {if(checkFlBrowserItem(key_browser)){
  119. debug_out("Configure callback");
  120. config_key_win()->show();
  121. + if(!Configure(key_browser,action_name1,current_key,current_mod1,current_mod2,current_mod3,old_action)){debug_out("Configure failed");}
  122. }}
  123. image {custom_buttons/gear16.png} xywh {100 260 30 30} box FLAT_BOX color 23 labelfont 1
  124. }
  125. === modified file 'fltk/jwm-shutdown.cxx'
  126. --- fltk/jwm-shutdown.cxx 2017-01-29 14:15:16 +0000
  127. +++ fltk/jwm-shutdown.cxx 2018-10-03 19:59:48 +0000
  128. @@ -71,7 +71,7 @@
  129. LOGOUT="torios-exit || jwm -exit";
  130. SHUTDOWN="torios-shutdown || dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop || systemctl poweroff";;
  131. RESTART="torios-reboot || dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart|| systemctl reboot";
  132. - { shutdown_window = new Fl_Double_Window(242, 230, gettext("Shutdown"));
  133. + { Fl_Double_Window* o = shutdown_window = new Fl_Double_Window(242, 230, gettext("Shutdown"));
  134. shutdown_window->color(FL_DARK2);
  135. shutdown_window->user_data((void*)(this));
  136. { Fl_Button* o = shut = new Fl_Button(10, 10, 105, 75, gettext("Shutdown"));
  137. @@ -112,6 +112,7 @@
  138. can->callback((Fl_Callback*)cb_can);
  139. } // Fl_Button* can
  140. window_bg();
  141. + if(!make_window_above(o)){std::cerr<<"Couldn't make window work"<<std::endl;}
  142. shutdown_window->clear_border();
  143. shutdown_window->xclass("system-shutdown");
  144. shutdown_window->end();
  145. @@ -142,3 +143,31 @@
  146. //can->labelcolor(color2);
  147. under_mouse(shutdown_window);
  148. }
  149. +
  150. +bool shutdown::make_window_above(Fl_Window *o) {
  151. + Atom wmStateAbove = XInternAtom( fl_display, "_NET_WM_STATE_ABOVE", 1 );
  152. + if( wmStateAbove == None )
  153. + return false;
  154. + Atom wmNetWmState = XInternAtom( fl_display, "_NET_WM_STATE", 1 );
  155. + if( wmNetWmState == None )
  156. + return false;
  157. +
  158. + XClientMessageEvent xclient;
  159. + memset( &xclient, 0, sizeof (xclient) );
  160. + xclient.type = ClientMessage;
  161. + xclient.window = fl_xid(o);
  162. + xclient.message_type = wmNetWmState;
  163. + xclient.format = 32;
  164. + xclient.data.l[0] = 1;//_NET_WM_STATE_ADD;
  165. + xclient.data.l[1] = wmStateAbove;
  166. + xclient.data.l[2] = 0;
  167. + xclient.data.l[3] = 0;
  168. + xclient.data.l[4] = 0;
  169. + Window root = DefaultRootWindow( fl_display );
  170. + XSendEvent( fl_display,
  171. + root,
  172. + False,
  173. + SubstructureRedirectMask | SubstructureNotifyMask,
  174. + (XEvent *)&xclient );
  175. + return true;
  176. +}
  177. === modified file 'fltk/jwm-shutdown.fld'
  178. --- fltk/jwm-shutdown.fld 2018-01-16 14:17:27 +0000
  179. +++ fltk/jwm-shutdown.fld 2018-10-03 19:59:48 +0000
  180. @@ -42,13 +42,19 @@
  181. decl {\#include <iostream>} {public global
  182. }
  183. +decl {\#include <FL/x.H>} {public global
  184. +}
  185. +
  186. +decl {\#include <X11/Xlib.h>} {public global
  187. +}
  188. +
  189. decl {\#include "../include/fltkfunctions.hpp"} {public global
  190. }
  191. decl {\#include "../include/jwmrc.hpp"} {public global
  192. }
  193. -class shutdown {open selected : {public FLTK_FUNCTIONS}
  194. +class shutdown {open : {public FLTK_FUNCTIONS}
  195. } {
  196. decl {std::string SUSPEND,LOGOUT,SHUTDOWN,RESTART;} {private local
  197. }
  198. @@ -62,7 +68,8 @@
  199. Fl_Window shutdown_window {
  200. label Shutdown open
  201. xywh {351 113 242 230} type Double color 45
  202. - code0 {window_bg();} noborder xclass {system-shutdown} visible
  203. + code0 {window_bg();}
  204. + code1 {if(!make_window_above(o)){std::cerr<<"Couldn't make window work"<<std::endl;}} noborder xclass {system-shutdown} visible
  205. } {
  206. Fl_Button shut {
  207. label Shutdown
  208. @@ -123,4 +130,33 @@
  209. //can->labelcolor(color2);
  210. under_mouse(shutdown_window);} {}
  211. }
  212. + Function {make_window_above(Fl_Window *o)} {open return_type bool
  213. + } {
  214. + code {Atom wmStateAbove = XInternAtom( fl_display, "_NET_WM_STATE_ABOVE", 1 );
  215. +if( wmStateAbove == None )
  216. + return false;
  217. +Atom wmNetWmState = XInternAtom( fl_display, "_NET_WM_STATE", 1 );
  218. +if( wmNetWmState == None )
  219. + return false;
  220. +
  221. +XClientMessageEvent xclient;
  222. +memset( &xclient, 0, sizeof (xclient) );
  223. +xclient.type = ClientMessage;
  224. +xclient.window = fl_xid(o);
  225. +xclient.message_type = wmNetWmState;
  226. +xclient.format = 32;
  227. +xclient.data.l[0] = 1;//_NET_WM_STATE_ADD;
  228. +xclient.data.l[1] = wmStateAbove;
  229. +xclient.data.l[2] = 0;
  230. +xclient.data.l[3] = 0;
  231. +xclient.data.l[4] = 0;
  232. +Window root = DefaultRootWindow( fl_display );
  233. +XSendEvent( fl_display,
  234. + root,
  235. + False,
  236. + SubstructureRedirectMask | SubstructureNotifyMask,
  237. + (XEvent *)&xclient );
  238. +return true;} {selected
  239. + }
  240. + }
  241. }
  242. === modified file 'fltk/jwm-shutdown.h'
  243. --- fltk/jwm-shutdown.h 2018-01-16 14:17:27 +0000
  244. +++ fltk/jwm-shutdown.h 2018-10-03 19:59:48 +0000
  245. @@ -30,6 +30,8 @@
  246. #include <string>
  247. #include <stdlib.h>
  248. #include <iostream>
  249. +#include <FL/x.H>
  250. +#include <X11/Xlib.h>
  251. #include "../include/fltkfunctions.hpp"
  252. #include "../include/jwmrc.hpp"
  253. #include <FL/Fl_Double_Window.H>
  254. @@ -66,5 +68,6 @@
  255. static void cb_can(Fl_Button*, void*);
  256. public:
  257. void window_bg();
  258. + bool make_window_above(Fl_Window *o);
  259. };
  260. #endif
  261. === modified file 'include/jwmrc.hpp'
  262. --- include/jwmrc.hpp 2018-01-16 14:17:27 +0000
  263. +++ include/jwmrc.hpp 2022-11-26 19:54:59 +0000
  264. @@ -136,7 +136,7 @@
  265. bool populateFLBrowser(Fl_Browser *o, std::string element, std::string attribute, std::string attribute_value, std::string attribute2, std::string optional_attribute);
  266. bool populateFLBrowser(Fl_Browser *o, std::string element, std::string subelement, unsigned int whichMainElement);
  267. bool populateFLBrowserElements(Fl_Browser *o, pugi::xml_node noder);
  268. - bool populateFLBrowser2Attr(Fl_Browser *o, std::string element, std::string attribute1, std::string attribute2);
  269. + bool populateFLBrowser2Attr(Fl_Browser *o, std::string element, std::string attribute1, std::string attribute2,char delim='\t');
  270. //R
  271. bool removeMenu(std::string value);
  272. //S
  273. === modified file 'include/keyboard.hpp'
  274. --- include/keyboard.hpp 2018-01-16 14:17:27 +0000
  275. +++ include/keyboard.hpp 2018-10-03 19:59:48 +0000
  276. @@ -54,12 +54,15 @@
  277. class JWM_Keyboard : public FLTK_FUNCTIONS
  278. {
  279. public:
  280. + char DELIM;
  281. + std::string DELIMITER;
  282. + JWM_Keyboard();
  283. //void
  284. void addKey(std::string key, std::string shortcut);
  285. void addKey(std::string keyMod, std::string key, std::string shortcut);
  286. void changemod(std::string mod,Fl_Output* Aout,Fl_Output* Bout);
  287. void changemod(std::string mod,Fl_Output* Aout,Fl_Output* Bout,Fl_Output* Cout);
  288. - void configureKey(std::string keyShortcut, std::string newmod1, std::string newmod2, std::string newmod3, std::string newkey, std::string newaction);
  289. + bool configureKey(std::string keyShortcut, std::string newmod1, std::string newmod2, std::string newmod3, std::string newkey, std::string newaction);
  290. void Choose_Action(Fl_Input* action_name);
  291. void deleteKey(std::string keyShortcut);
  292. void key_event(Fl_Input* o, Fl_Output* out, Fl_Output* modder);
  293. @@ -78,7 +81,7 @@
  294. std::string getAction(std::string keyShortcut);
  295. std::string getKey(std::string keyShortcut);
  296. std::string getLayout(Fl_Input *o,std::string whichOne);
  297. - std::string getMod(std::string keyShortcut);
  298. + std::string getMod(std::string keyShortcut,unsigned int which);
  299. std::string getMod1(std::string keyShortcut);
  300. std::string getMod2(std::string keyShortcut);
  301. std::string getMod3(std::string keyShortcut);
  302. @@ -96,7 +99,8 @@
  303. Fl_Output *mod3_output,
  304. Fl_Output *old_value);
  305. 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);
  306. + bool emptyString(std::string s);
  307. + bool getKeys(Fl_Browser* o);
  308. bool newpanel();
  309. - bool getKeys(Fl_Browser* o);
  310. };
  311. #endif
  312. === modified file 'src/fltkfunctions.cpp'
  313. --- src/fltkfunctions.cpp 2018-01-16 14:17:27 +0000
  314. +++ src/fltkfunctions.cpp 2018-10-03 19:59:48 +0000
  315. @@ -444,7 +444,8 @@
  316. delete(image);
  317. }
  318. else{return;}
  319. - widget->image(image2);
  320. + widget->image(image2->copy());
  321. + delete(image2);
  322. }
  323. //O
  324. /** set one Background element color
  325. === modified file 'src/jwmrc.cpp'
  326. --- src/jwmrc.cpp 2018-01-16 14:17:27 +0000
  327. +++ src/jwmrc.cpp 2022-11-26 21:09:14 +0000
  328. @@ -872,7 +872,7 @@
  329. }
  330. return true;
  331. }
  332. -bool JWMRC::populateFLBrowser2Attr(Fl_Browser *o,std::string element,std::string attribute1, std::string attribute2){
  333. +bool JWMRC::populateFLBrowser2Attr(Fl_Browser *o,std::string element,std::string attribute1, std::string attribute2, char delim){
  334. debug_out("bool populateFLBrowser2Attr(Fl_Browser *o,std::string "+element+",std::string "+attribute1+",std::string " + attribute2+")");
  335. if(element.compare("")==0){
  336. debug_out("Element NOT specified");
  337. === modified file 'src/keyboard.cpp'
  338. --- src/keyboard.cpp 2018-01-16 14:17:27 +0000
  339. +++ src/keyboard.cpp 2018-10-03 19:59:48 +0000
  340. @@ -1,5 +1,10 @@
  341. #include "../include/keyboard.hpp"
  342. //Void//////////////////////////////////////////////////////////////////
  343. +JWM_Keyboard::JWM_Keyboard ()
  344. +{
  345. + DELIM='@';
  346. + DELIMITER=DELIM;
  347. +}
  348. void JWM_Keyboard::addKey(std::string key, std::string shortcut){
  349. debug_out("void addKey(std::string "+ key+", std::string " +shortcut+ ")");
  350. if(!addElementWithTextAndAttribute("Key","key",key,shortcut)){debug_out("Add Key Failed");}
  351. @@ -19,9 +24,9 @@
  352. else if(OutputIsEmpty(Cout)){Cout->value(mod.c_str());}
  353. else{debug_out("All Mods are filled");}
  354. }
  355. -void JWM_Keyboard::configureKey(std::string keyShortcut, std::string newmod1, std::string newmod2, std::string newmod3, std::string newkey, std::string newaction){
  356. +bool JWM_Keyboard::configureKey(std::string keyShortcut, std::string newmod1, std::string newmod2, std::string newmod3, std::string newkey, std::string newaction){
  357. debug_out("void configureKey(std::string "+keyShortcut+", std::string "+newmod1+", std::string "+newmod2+", std::string "+newmod3+", std::string "+newkey+", std::string "+newaction+")");
  358. - if(keyShortcut.compare("")==0){return;}
  359. + if(keyShortcut.compare("")==0){return false;}
  360. std::string mod1FromProg,
  361. mod2FromProg,
  362. mod3FromProg,
  363. @@ -39,13 +44,20 @@
  364. pugi::xml_node node=compareNode("Key","key",keyFromProg,"mask",totalMod,actionFromProg);
  365. if(node){
  366. //found it!
  367. - if(!node.attribute("mask")){node.append_attribute("mask");}
  368. - node.attribute("mask").set_value(totalNewMod.c_str());
  369. + if(totalNewMod.compare("")!=0)
  370. + {
  371. + if(!node.attribute("mask")){node.append_attribute("mask");}
  372. + node.attribute("mask").set_value(totalNewMod.c_str());
  373. + }
  374. if(!node.attribute("key")){node.append_attribute("key");} //This should NEVER happen..
  375. node.attribute("key").set_value(keyShortcut.c_str());
  376. node.set_value(newaction.c_str());
  377. + return saveChangesTemp();
  378. }
  379. -
  380. + else{
  381. + debug_out("Didn't find node key="+keyFromProg+" mask="+totalMod+" text="+actionFromProg);
  382. + }
  383. + return false;
  384. }
  385. void JWM_Keyboard::Choose_Action(Fl_Input* action_name){
  386. debug_out("void Choose_Action(Fl_Input* action_name)");
  387. @@ -180,6 +192,7 @@
  388. debug_out("void setLayout(Fl_Input *layoutput, Fl_Input *modeloutput, Fl_Input *optionoutput)");
  389. someLayout(layoutput, modeloutput, optionoutput,true);
  390. }
  391. +
  392. void JWM_Keyboard::someLayout(Fl_Input *layoutput, Fl_Input *modeloutput, Fl_Input *optionoutput, bool save){
  393. std::string SAVE="Don't Save";
  394. if(save){SAVE="SAVE!";}
  395. @@ -239,6 +252,7 @@
  396. int retval=linuxcommon::run_a_program(command);
  397. if(retval!=0){errorOUT("Could not run "+command);}
  398. }
  399. +
  400. void JWM_Keyboard::testLayout(Fl_Input *layoutput, Fl_Input *modeloutput, Fl_Input *optionoutput){
  401. debug_out("void testLayout(Fl_Input *layoutput, Fl_Input *modeloutput, Fl_Input *optionoutput)");
  402. someLayout(layoutput, modeloutput, optionoutput,false);
  403. @@ -259,43 +273,19 @@
  404. }
  405. return retval;
  406. }
  407. +
  408. std::string JWM_Keyboard::getAction(std::string keyShortcut){
  409. debug_out("std::string getAction(std::string "+keyShortcut+")");
  410. if(keyShortcut.compare("")==0){return "";}
  411. - std::string fromProgram = keyShortcut;
  412. - //shortcut
  413. - unsigned length =fromProgram.length();
  414. - unsigned found = fromProgram.find_last_of("\t");
  415. - if(found < length){
  416. - fromProgram = fromProgram.erase(0,found+1);
  417. - debug_out("getAction: "+fromProgram);
  418. - return fromProgram;
  419. - }
  420. - return "";
  421. + return getMod(keyShortcut,4);
  422. }
  423. +
  424. std::string JWM_Keyboard::getKey(std::string keyShortcut){
  425. debug_out("std::string getKey(std::string "+keyShortcut+")");
  426. if(keyShortcut.compare("")==0){return "";}
  427. - std::string fromProgram = keyShortcut;
  428. - std::string keymod2 =keyShortcut;
  429. - //shortcut
  430. - unsigned length =fromProgram.length();
  431. - //recheck this code
  432. - unsigned found = fromProgram.find_last_of("\t");
  433. - unsigned found1 = fromProgram.find_first_of("\t");
  434. - unsigned found2 = fromProgram.find_first_of("\t",found1);
  435. - if(found < length){
  436. - fromProgram = fromProgram.erase(0,found+1);
  437. - //keymod 2
  438. - if(found2 < keymod2.length()){
  439. - keymod2 = keymod2.erase(found,std::string::npos);
  440. - keymod2 = keymod2.erase(0,found2+1);
  441. - debug_out("getKey: "+keymod2);
  442. - return keymod2;
  443. - }
  444. - }
  445. - return "";
  446. + return getMod(keyShortcut,0);
  447. }
  448. +
  449. std::string JWM_Keyboard::getLayout(Fl_Input *o,std::string whichOne){
  450. debug_out("std::string getLayout()");
  451. std::string test_command=linuxcommon::term_out("which localectl");
  452. @@ -318,7 +308,7 @@
  453. for( std::vector<std::string>::iterator it = STRING_VEC.begin();
  454. it!=STRING_VEC.end();
  455. ++it){
  456. - std::string tmp=*it;
  457. + std::string tmp=*it;
  458. std::transform(tmp.begin(),tmp.end(),tmp.begin(), ::tolower);
  459. unsigned int finder = tmp.find(whichOne);
  460. if(finder<tmp.length()){
  461. @@ -331,68 +321,64 @@
  462. }
  463. return layout;
  464. }
  465. -std::string JWM_Keyboard::getMod(std::string keyShortcut){
  466. +
  467. +std::string JWM_Keyboard::getMod(std::string keyShortcut,unsigned int which=1){
  468. debug_out("std::string getMod(std::string "+keyShortcut+")");
  469. - if(keyShortcut.compare("")==0){return "";}
  470. - std::string keymod =keyShortcut;
  471. - //shortcut
  472. - unsigned length =keyShortcut.length();
  473. - unsigned found = keyShortcut.find_first_of("\t");
  474. - if(found < length){
  475. - keymod = keymod.erase(found,std::string::npos);
  476. - return keymod;
  477. - }
  478. - return "";
  479. + if(keyShortcut.compare("")==0){return "";}
  480. + std::string keymod =keyShortcut;
  481. + std::vector<std::string> T= linuxcommon::delimiter_vector_from_string(keyShortcut,DELIMITER);
  482. + if(which>=T.size())
  483. + return "";
  484. + std::string tmp=T.at(which);
  485. + debug_out("Value="+tmp);
  486. }
  487. +
  488. std::string JWM_Keyboard::getMod1(std::string keyShortcut){
  489. debug_out("std::string getMod1(std::string "+keyShortcut+")");
  490. - if(keyShortcut.compare("")==0){return "";}
  491. - std::string result =getMod(keyShortcut);
  492. - unsigned int len = result.length();
  493. - if(len>1){result=result.erase(1,std::string::npos);}
  494. - debug_out("mod1:"+result);
  495. - return result;
  496. + if(keyShortcut.compare("")==0){return "";}
  497. + return getMod(keyShortcut,1);
  498. }
  499. +
  500. std::string JWM_Keyboard::getMod2(std::string keyShortcut){
  501. debug_out("std::string getMod2(std::string "+keyShortcut+")");
  502. - if(keyShortcut.compare("")==0){return "";}
  503. - std::string result =getMod(keyShortcut);
  504. - unsigned int len = result.length();
  505. - if(len>1){result=result.erase(0,1);}
  506. - len = result.length();
  507. - if(len>2){result=result.erase(1,std::string::npos);}
  508. - debug_out("mod2:"+result);
  509. - return result;
  510. + if(keyShortcut.compare("")==0){return "";}
  511. + return getMod(keyShortcut,2);
  512. }
  513. +
  514. std::string JWM_Keyboard::getMod3(std::string keyShortcut){
  515. debug_out("std::string getMod3(std::string "+keyShortcut+")");
  516. - if(keyShortcut.compare("")==0){return "";}
  517. - std::string result =getMod(keyShortcut);
  518. - unsigned int len = result.length();
  519. - if(len>2){result=result.erase(0,2);}
  520. - else{result="";}
  521. - debug_out("mod3:"+result);
  522. - return result;
  523. + if(keyShortcut.compare("")==0){return "";}
  524. + return getMod(keyShortcut,3);
  525. }
  526. +
  527. std::string JWM_Keyboard::getINPUT(Fl_Input *o){
  528. debug_out("std::string getINPUT(Fl_Input *o)");
  529. - if(o->visible()!=0){return "";}
  530. + if(!o->visible())
  531. + {
  532. + debug_out("input not visible");
  533. + return "";
  534. + }
  535. const char* out=o->value();
  536. - if(out==NULL){return "";}
  537. + if(out==NULL)
  538. + {
  539. + debug_out("input value is NULL");
  540. + return "";
  541. + }
  542. std::string outer=out;
  543. debug_out("INPUT="+outer);
  544. return outer;
  545. }
  546. std::string JWM_Keyboard::getOUTPUT(Fl_Output *o){
  547. debug_out("std::string getOUTPUT(Fl_Output *o)");
  548. - if(o->visible()!=0){return "";}
  549. + if(!o->visible()){return "";}
  550. const char* out=o->value();
  551. if(out==NULL){return "";}
  552. std::string outer=out;
  553. debug_out("OUTPUT="+outer);
  554. return outer;
  555. }
  556. +
  557. std::string JWM_Keyboard::grabbedKey(){
  558. struct termios oldSettings, newSettings;
  559. tcgetattr( fileno( stdin ), &oldSettings );
  560. @@ -433,6 +419,7 @@
  561. return result;
  562. }
  563. +
  564. 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){
  565. std::string temp;
  566. const char* mod1=current_mod1->value();
  567. @@ -444,11 +431,14 @@
  568. const char* keychar=current_key->value();
  569. if(keychar!=NULL){
  570. std::string keycurrent=keychar;
  571. - if(temp.compare("")==0)temp="\t"+keycurrent;
  572. - else{temp=temp+"\t"+keycurrent;}
  573. + if(temp.compare("")==0)temp=" "+DELIMITER+keycurrent;
  574. + else{temp=temp+DELIMITER+keycurrent;}
  575. }
  576. + else{temp+=" "+DELIMITER;}
  577. const char* actionian=old_action->value();
  578. - if(actionian!=NULL){temp=temp+"\t"+ actionian;}
  579. + if(actionian!=NULL){temp=temp+DELIMITER+ actionian;}
  580. + else{temp+=(DELIMITER +" ");}
  581. + temp+=DELIMITER;
  582. return temp;
  583. }
  584. //Boolean///////////////////////////////////////////////////////////////
  585. @@ -469,8 +459,8 @@
  586. debug_out("No action chosen...");
  587. return false;
  588. }
  589. - if(keyInput.compare("")!=0){
  590. - if(mod.compare("")!=0){addKey(mod,keyInput,action);}
  591. + if(!emptyString(keyInput)){
  592. + if(!emptyString(mod)){addKey(mod,keyInput,action);}
  593. else{addKey(keyInput,action);}
  594. o->clear();
  595. getKeys(o);
  596. @@ -485,22 +475,25 @@
  597. Fl_Output *mod1_output,
  598. Fl_Output *mod2_output,
  599. Fl_Output *mod3_output,
  600. - Fl_Output *old_value) {
  601. + Fl_Output *old_value)
  602. +{
  603. 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)");
  604. - if(!checkFlBrowserItem(key_browser)){
  605. - debug_out("Browser didn't have anything nice selected");
  606. - return false;
  607. - }
  608. const char* mykey = key_browser->text(key_browser->value());
  609. + if(mykey==NULL)
  610. + {
  611. + debug_out("Configure keyshortcut empty");
  612. + return false;
  613. + }
  614. std::string keyShortcut = mykey;
  615. - if (keyShortcut.compare("")!=0){
  616. + if(!emptyString(keyShortcut)){
  617. + debug_out("Configure line="+keyShortcut);
  618. std::string mod1,mod2,mod3,key,program;
  619. mod1=getMod1(keyShortcut);
  620. - if(mod1.compare("")!=0){mod1_output->value(mod1.c_str());}
  621. + if(!emptyString(mod1)){mod1_output->value(mod1.c_str());}
  622. mod2=getMod2(keyShortcut);
  623. - if(mod2.compare("")!=0){mod2_output->value(mod2.c_str());}
  624. + if(!emptyString(mod2)){mod2_output->value(mod2.c_str());}
  625. mod3=getMod3(keyShortcut);
  626. - if(mod3.compare("")!=0){mod3_output->value(mod3.c_str());}
  627. + if(!emptyString(mod3)){mod3_output->value(mod3.c_str());}
  628. key=getKey(keyShortcut);
  629. program=getAction(keyShortcut);
  630. action_name1->value(program.c_str());
  631. @@ -509,7 +502,7 @@
  632. getKeys(key_browser);
  633. return true;
  634. }
  635. - else{fl_message("Please click on an item to remove!");}
  636. + else{fl_message("Please click on an item to configure!");}
  637. return false;
  638. }
  639. 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){
  640. @@ -520,17 +513,31 @@
  641. MOD3=getOUTPUT(mod3_output);
  642. KEY=getINPUT(keyshortcut);
  643. ACTION=getINPUT(action_name1);
  644. - if(ACTION.compare("")==0){return false;}
  645. - if(CURRENT.compare("")==0){return false;}
  646. - configureKey(CURRENT,MOD1,MOD2,MOD3,KEY,ACTION);
  647. - return true;
  648. + if(emptyString(ACTION))
  649. + {
  650. + debug_out("No action chosen");
  651. + return false;
  652. + }
  653. + if(emptyString(CURRENT))
  654. + {
  655. + debug_out("CURRENT is empty");
  656. + return false;
  657. + }
  658. + if(!configureKey(CURRENT,MOD1,MOD2,MOD3,KEY,ACTION)){return false;}
  659. + return saveChanges();
  660. +}
  661. +bool JWM_Keyboard::emptyString(std::string s)
  662. +{
  663. + if ( (s.compare("")==0) || (s.compare("")==0) )
  664. + return true;
  665. + return false;
  666. +}
  667. +bool JWM_Keyboard::getKeys(Fl_Browser* o){
  668. + populateFLBrowser2Attr(o,"Key","key","mask");
  669. + return false;
  670. }
  671. bool JWM_Keyboard::newpanel(){
  672. debug_out("bool newpanel()");
  673. if(newStyle() == -1){return false;}
  674. return true;
  675. }
  676. -bool JWM_Keyboard::getKeys(Fl_Browser* o){
  677. - populateFLBrowser2Attr(o,"Key","key","mask");
  678. - return false;
  679. -}