@@ -47,17 +47,6 @@ static std::string spawnKittyActivating(const std::string& class_ = "kitty_activ
4747 return tmpFilename;
4848}
4949
50- static std::string getWindowAttribute (const std::string& winInfo, const std::string& attr) {
51- auto pos = winInfo.find (attr);
52- if (pos == std::string::npos) {
53- NLog::log (" {}Wrong window attribute" , Colors::RED);
54- ret = 1 ;
55- return " Wrong window attribute" ;
56- }
57- auto pos2 = winInfo.find (' \n ' , pos);
58- return winInfo.substr (pos, pos2 - pos);
59- }
60-
6150static std::string getWindowAddress (const std::string& winInfo) {
6251 auto pos = winInfo.find (" Window " );
6352 auto pos2 = winInfo.find (" -> " );
@@ -92,7 +81,7 @@ static void testSwapWindow() {
9281 // Test swapwindow by direction
9382 {
9483 getFromSocket (" /dispatch focuswindow class:kitty_A" );
95- auto pos = getWindowAttribute (getFromSocket (" /activewindow" ), " at:" );
84+ auto pos = Tests:: getWindowAttribute (getFromSocket (" /activewindow" ), " at:" );
9685 NLog::log (" {}Testing kitty_A {}, swapwindow with direction 'l'" , Colors::YELLOW, pos);
9786
9887 OK (getFromSocket (" /dispatch swapwindow l" ));
@@ -104,7 +93,7 @@ static void testSwapWindow() {
10493 // Test swapwindow by class
10594 {
10695 getFromSocket (" /dispatch focuswindow class:kitty_A" );
107- auto pos = getWindowAttribute (getFromSocket (" /activewindow" ), " at:" );
96+ auto pos = Tests:: getWindowAttribute (getFromSocket (" /activewindow" ), " at:" );
10897 NLog::log (" {}Testing kitty_A {}, swapwindow with class:kitty_B" , Colors::YELLOW, pos);
10998
11099 OK (getFromSocket (" /dispatch swapwindow class:kitty_B" ));
@@ -118,7 +107,7 @@ static void testSwapWindow() {
118107 getFromSocket (" /dispatch focuswindow class:kitty_B" );
119108 auto addr = getWindowAddress (getFromSocket (" /activewindow" ));
120109 getFromSocket (" /dispatch focuswindow class:kitty_A" );
121- auto pos = getWindowAttribute (getFromSocket (" /activewindow" ), " at:" );
110+ auto pos = Tests:: getWindowAttribute (getFromSocket (" /activewindow" ), " at:" );
122111 NLog::log (" {}Testing kitty_A {}, swapwindow with address:0x{}(kitty_B)" , Colors::YELLOW, pos, addr);
123112
124113 OK (getFromSocket (std::format (" /dispatch swapwindow address:0x{}" , addr)));
@@ -141,7 +130,7 @@ static void testSwapWindow() {
141130 {
142131 getFromSocket (" /dispatch focuswindow class:kitty_B" );
143132 auto addr = getWindowAddress (getFromSocket (" /activewindow" ));
144- auto ws = getWindowAttribute (getFromSocket (" /activewindow" ), " workspace:" );
133+ auto ws = Tests:: getWindowAttribute (getFromSocket (" /activewindow" ), " workspace:" );
145134 NLog::log (" {}Sending address:0x{}(kitty_B) to workspace \" swapwindow2\" " , Colors::YELLOW, addr);
146135
147136 OK (getFromSocket (" /dispatch movetoworkspacesilent name:swapwindow2" ));
@@ -222,8 +211,8 @@ static void testGroupRules() {
222211
223212static bool isActiveWindow (const std::string& class_, char fullscreen = ' 0' , bool log = true ) {
224213 std::string activeWin = getFromSocket (" /activewindow" );
225- auto winClass = getWindowAttribute (activeWin, " class:" );
226- auto winFullscreen = getWindowAttribute (activeWin, " fullscreen:" ).back ();
214+ auto winClass = Tests:: getWindowAttribute (activeWin, " class:" );
215+ auto winFullscreen = Tests:: getWindowAttribute (activeWin, " fullscreen:" ).back ();
227216 if (winClass.substr (strlen (" class: " )) == class_ && winFullscreen == fullscreen)
228217 return true ;
229218 else {
0 commit comments