Commits

Micah Nordland committed a803205

I changed the key binding for command mode to just Mod4 (aka Super_L)
Mod4+Escape was just too cumbersome for me.

  • Participants
  • Parent commits 7a9b3ff

Comments (0)

Files changed (8)

     'i' moves you into interact mode.
     'x' closes the currently focused window.
     'o' moves you into interact mode, and runs dmenu-launch
-    'q' quits Mirror.
+    'q' quits Mirror
+    Right and left arrow keys move you between tags
 
 In interact mode, you have one command:
-    "Mod4+Escape" moves you into command mode.
+    "Mod4" moves you into command mode.
 
 In interact mode all keystrokes go the the focused window.
 In command mode, no keystrokes go the the windows, but 

include/statusBar.h

         CairoXcbSurface surface;
         std::string text;
         std::string timeText;
-        Monitor &monitor;
+        int width;
         
 
         
 #ifndef WINDOW_H
 #define WINDOW_H
+#include <iostream>
 #include <string>
 
 #include <xcb/xcb.h>
         void handleTransient();
         void focus();
         void close();
-        void kill();
         void stackAbove();
         void stackBelow();
         void map();

src/keyHandlers.cpp

 
 void KeyHandler::grabKey(uint32_t mods, xcb_keysym_t keysym, KeyEventType type, KeyCallback callback)
 {
+    std::cerr << "starting grab key" << std::endl;
 	if (grab(mods, keysym))
 	{
       addCallback(mods, keysym, type, callback);
 
 void KeyHandler::ungrabKey(uint32_t mods, xcb_keysym_t keysym, KeyEventType type)
 {
+    if (not this)
+        std::cerr << "invalid keyHandler pointer" << std::endl;
     ungrab(keysym);
     auto key = std::make_pair(mods, keysym);
     if (type == Press)
             for (auto& statusBar: setup.statusBars)
                 statusBar.setText("Command"); 
             
-            keyHandler.ungrabKey(XCB_MOD_MASK_4, XK_Escape, Press);
+            keyHandler.ungrabKey(0, XK_Super_L, Press);
             keyHandler.grabKey(0, XK_i, Press, interactCallback);
             keyHandler.grabKey(0, XK_x, Press, [&]{
                 Monitor& monitor = setup.getCurrentMonitor();
             keyHandler.ungrabKey(0, XK_o, Press);
             keyHandler.ungrabKey(0, XK_Left, Press);
             keyHandler.ungrabKey(0, XK_Right, Press);
-            keyHandler.grabKey(XCB_MOD_MASK_4, XK_Escape, Press, commandCallback);
+            keyHandler.grabKey(0, XK_Super_L, Press, commandCallback);
             xcb_ungrab_keyboard(setup.conn, XCB_CURRENT_TIME);
         };
 
     }
 	std::cout << "numberOfTags is: " << numberOfTags << std::endl;
     getMonitors();
-
+    std::cerr << "There are this many monitors: " << monitors.size() << std::endl;
     for (auto& monitor : monitors)
     {
         statusBars.push_back(StatusBar(this, monitor));
     }
-
+    std::cerr << "there are this many statusbars: " << statusBars.size() << std::endl;
 }
 
 Setup::~Setup()

src/statusBar.cpp

 #include "monitor.h"
 
 StatusBar::StatusBar(Setup *setup, Monitor monitor):
-    setup(setup),
-	monitor(monitor)
+    setup(setup)
 {
     xcb_window_t id = xcb_generate_id(setup->conn);
-    int width = monitor.area.width;
+    width = monitor.area.width;
     uint32_t values[] = {XCB_EVENT_MASK_EXPOSURE};
     xcb_create_window( setup->conn, XCB_COPY_FROM_PARENT, id, setup->root, 
                         monitor.area.x, monitor.area.y-setup->statusBarHeight, width, setup->statusBarHeight, 1, XCB_WINDOW_CLASS_INPUT_OUTPUT, 
     surface =  Cairo::XcbSurface::create(setup->conn, id, visualType, width, setup->statusBarHeight);
     context = Cairo::Context::create(surface);
     
-    
     xcb_map_window(setup->conn, id);
     draw(); 
 
     context->set_source_rgb(1, 1, 1);
     context->set_font_size(12);
     context->show_text(text);
-	//context->move_to(monitor.area.width/2, 15);
+	context->move_to(width/2, 15);
 	context->show_text(timeText);
 	Cairo::TextExtents extents;
-    context->get_text_extents(" Mirror, reflecting you!", extents);
-	//std::cout << extents.width << std::endl;
-	//std::cout << extents.x_advance << std::endl;
-	//context->move_to(monitor.area.width - extents.width-5, 15);
-	context->show_text(" Mirror, reflecting you!");
+    context->get_text_extents("Mirror", extents);
+	context->move_to(width - extents.width-5, 15);
+	context->show_text("Mirror");
 	xcb_flush(setup->conn);
 }
 
    {
        sendTakeFocus();
    }
+
+   if (not inputHint)
+       return;
+
    xcb_set_input_focus(setup->conn, XCB_INPUT_FOCUS_POINTER_ROOT,
                        id, XCB_CURRENT_TIME);
 }
     }
     else
         return;
-    
-    clientMessage.response_type = XCB_CLIENT_MESSAGE;
-    clientMessage.window = id;
-    clientMessage.format = 32;
-    clientMessage.type = setup->ewmh->WM_PROTOCOLS;
-    clientMessage.data.data32[0] = WM_DELETE_WINDOW;
-    clientMessage.data.data32[1] = XCB_CURRENT_TIME;
+    xcb_icccm_get_wm_protocols_reply_t protoReply;
+    xcb_icccm_get_wm_protocols_reply(setup->conn, 
+    xcb_icccm_get_wm_protocols_unchecked(setup->conn, id, setup->ewmh->WM_PROTOCOLS),
+    &protoReply, nullptr);
+    if (protoReply.atoms_len>0)
+    {
+        std::cerr << "protoReply.atoms_len was greater than 0" << std::endl;
+        for (int i = 0; i < protoReply.atoms_len; i++)
+            if (protoReply.atoms[i] == WM_DELETE_WINDOW)
+            {
+                std::cerr << "this window has WM_DELETE_WINDOW in its WM_PROTOCOLS" << std::endl;
+                clientMessage.response_type = XCB_CLIENT_MESSAGE;
+                clientMessage.window = id;
+                clientMessage.format = 32;
+                clientMessage.type = setup->ewmh->WM_PROTOCOLS;
+                clientMessage.data.data32[0] = WM_DELETE_WINDOW;
+                clientMessage.data.data32[1] = XCB_CURRENT_TIME;
+                
+                xcb_send_event(setup->conn, false, id, XCB_EVENT_MASK_NO_EVENT, (char *) &clientMessage);
+                return;
+            }
+        std::cerr << "this window doesn't have WM_DELETE_WINDOW in its WM_PROTOCOLS" << std::endl;
+    }
 
-    xcb_send_event(setup->conn, false, id, XCB_EVENT_MASK_NO_EVENT, (char *) &clientMessage);
-}
+    xcb_kill_client(setup->conn, id);
 
-void Window::kill()
-{
-    xcb_kill_client(setup->conn, id);
 }
 
 void Window::setGeometry(xcb_rectangle_t rect)