Commits

Micah Nordland committed 8194afe

Fixed placement of windows that are added to tags with rules

Comments (0)

Files changed (3)

     
     //You can place windows on tags based upon their name or class
     //you can also set them to be exempt from tiling.
+    //'*' will match anything. If the class or name of the window
+    //was not set, it will be "unknown"
 
     //                  Name        Class       Tag name   exempt
-    WindowRule windward{"Windward","", "other", true}; 
-    
-    rules = {windward};
+    WindowRule windward{"Windward", "unknown",         "other",   true};
+
+    WindowRule term{    "*",   "Sakura",         "term",    false};
+
+    //add your rules to the list
+    rules = {windward, term};
 }
 
 Config::~Config()
     Window win(this, window);
     for (auto &rule : windowRules)
     {
-        if (std::get<0>(rule) == win.name
+        if ((std::get<0>(rule) == win.name or std::get<0>(rule) == "*" )
             and (std::get<1>(rule) == win.wmClass.first 
-            or std::get<1>(rule) == win.wmClass.second))
+            or std::get<1>(rule) == win.wmClass.second or std::get<1>(rule) == "*"))
         {
+            std::cerr << win.name << std::endl;
             win.tagName = std::get<2>(rule);
             win.exempt = std::get<3>(rule);
         }
 {
     Monitor &monitor = getCurrentMonitor();
     monitor.tagList.at(monitor.currentTag).windowContainer.layoutWindows(monitor.area);
+    xcb_rectangle_t offscreenRect = monitor.area;
+    offscreenRect.y = 0 - monitor.area.height;
+    offscreenRect.x = 0 - monitor.area.width;
+    for (auto &tag : monitor.tagList)
+    {
+        if (tag.name == monitor.tagList.at(monitor.currentTag).name)
+        {
+            continue;
+        }
+        tag.windowContainer.layoutWindows(offscreenRect);
+    }
 }
 
 Monitor& Setup::getCurrentMonitor()
     handleGeometry();
     handleTransient();
     handleName();
+    handleClass();
 
     uint32_t event_mask[] = {XCB_EVENT_MASK_ENTER_WINDOW};
     xcb_change_window_attributes(setup->conn, id, XCB_CW_EVENT_MASK, event_mask);
     xcb_icccm_get_text_property_reply_wipe(&namePropReply);
 }
 
+void Window::handleClass()
+{
+    xcb_icccm_get_wm_class_reply_t prop;
+    if(xcb_icccm_get_wm_class_reply(setup->conn, xcb_icccm_get_wm_class_unchecked(setup->conn, id), 
+        &prop, nullptr))
+    {
+        wmClass.first = prop.class_name;
+        wmClass.second = prop.instance_name;
+        return;
+    }
+    wmClass = std::make_pair("unknown", "unknown");
+}
+
 void Window::focus()
 {
    if (takeFocus)