Commits

Micah Nordland committed 2bf0411

Lots of changes that I haven't bothered to commit before
The terminus fonts are used for the status bar, and xcb-util-cursor
is a new dependency. Tags are now shown in the status bar and are
highlighted. Also new are exempting, ignoring, and fullscreening windows.
exempting windows can be done both in a rule and with a keypress, fullscreen
is keypress only, and ignoring is rule only.

  • Participants
  • Parent commits 1f527f6

Comments (0)

Files changed (16)

+Copyright (c) 2013 Micah Nordland
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

File include/config.h

 
 
 typedef std::tuple<uint32_t, xcb_keysym_t, std::string> AppKeyBind;
-typedef std::tuple<std::string, std::string, std::string, bool> WindowRule;
+typedef std::tuple<std::string, std::string, std::string, bool, bool> WindowRule;
 
 class Config
 {

File include/cursor.h

+#ifndef CURSOR_H
+#define CURSOR_H
+#include <string>
+#include <cstdint>
+
+#include <xcb/xcb.h>
+#include <xcb/xcb_cursor.h>
+
+xcb_cursor_context_t *cursorContextInit(xcb_connection_t *conn, xcb_screen_t *screen);
+
+void setCursor(xcb_connection_t *conn, xcb_cursor_context_t *context, xcb_window_t window, std::string cursorName);
+
+void cursorContextDelete(xcb_cursor_context_t *context);
+
+#endif //CURSOR_H

File include/monitor.h

         int currentTag;
         xcb_rectangle_t area;
         StatusBar* statusBar;
+        void setStatusBar(StatusBar* newStatusBar);
         void nextTag();
         void prevTag();
         void layoutWindows();

File include/setup.h

 
 };
 
-typedef std::tuple<std::string, std::string, std::string, bool> Rule;
+typedef std::tuple<std::string, std::string, std::string, bool, bool> Rule;
 
 class Setup
 {

File include/statusBar.h

 #define STATUS_BAR_H
 #include <iostream>
 #include <ctime>
+#include <string>
+#include <vector>
 
 #include <xcb/xcb.h>
 #include <cairommconfig.h>
     public:
         StatusBar(Setup *setup, Monitor monitor);
         ~StatusBar();
-        void setText(std::string newText);
+        void setMode(std::string newText);
         void draw();
         void update();
         void handleExposeEvent(EventPtr event);
+        void setTagNames(std::vector<std::string> newTagNames);
+        void setActiveTag(std::string tagName);
 
     private:
         Setup *setup;
         xcb_pixmap_t pixmap;
         CairoContext context;
         CairoXcbSurface surface;
-        std::string text;
+        std::string mode;
         std::string timeText;
         int width;
-        
+        std::string activeTagName;
+        std::vector<std::string> tagNames;
 
         
 

File include/window.h

         xcb_window_t id;
         bool exempt;
         bool fullscreen;
+        bool ignore;
         std::string tagName;
         std::string name;
         StringPair wmClass;

File include/windowContainer.h

 #include <vector>
 #include <utility>
 #include <iostream>
+#include <stdexcept>
 
 #include <xcb/xcb.h>
 
 
     private:
         StackList stackList;
+        WindowList ignore;
         std::pair<int, int> focused;
         std::pair<int, int> lastFocused; 
 

File src/config.cpp

     
     //This many tags per monitor:
 
-    tags = {"web", "term", "other"};
+    tags = {"web", "term", "other", "skype"};
 
 
     /////////////////////////////////////////////
     fullscreenFocusedKey = XK_f;
 
     quitMods = 0;
-    quitKey = XK_Escape;
+    quitKey = XK_F7;
 
     //Here is where custom app launching keybinds are defined.
     
     /////////////////////////////////////////////
     
     //You can place windows on tags based upon their name or class
-    //you can also set them to be exempt from tiling.
+    //you can also set them to be exempt from tiling. Ignore means
+    //that the window manager will do absolutely nothing with that window
     //'*' 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", "unknown",  "other",   true};
-    WindowRule angel{"*",  "*",  "other",   false};
+    //                  Name        Class       Tag name   exempt   ignore
+    WindowRule windward{"Windward", "unknown",  "other",   true,    false};
+    WindowRule angel{   "*",        "*",        "other",   false,   false};
 
 
-    WindowRule term{    "*",   "Sakura",         "term",    false};
+    WindowRule term{    "*",        "Sakura",   "term",    false,   false};
 
-    WindowRule web{    "*",   "luakit",         "web",    false};
+    WindowRule web{     "*",        "luakit",   "web",     false,   false};
+    WindowRule skype{   "*",        "Skype",    "skype",   false,   false};
+    WindowRule tray{    "*",     "stalonetray", "skype",   false,   true};
 
     //add your rules to the list
-    rules = {angel, windward, term, web};
+    rules = {angel, windward, term, web, skype, tray};
 }
 
 Config::~Config()

File src/cursor.cpp

+#include "cursor.h"
+
+xcb_cursor_context_t *cursorContextInit(xcb_connection_t *conn, xcb_screen_t *screen)
+{
+    xcb_cursor_context_t *context;
+    if (xcb_cursor_context_new(conn, screen, &context)  < 0)
+    {
+        return nullptr;
+    }
+    return context;
+}
+
+void setCursor(xcb_connection_t *conn, xcb_cursor_context_t *context, xcb_window_t window, std::string cursorName)
+{
+    xcb_cursor_t cursorId = xcb_cursor_load_cursor(context, cursorName.c_str());
+    uint32_t values[] = {cursorId};
+    xcb_change_window_attributes(conn, window, XCB_CW_CURSOR, values);
+    xcb_flush(conn);
+}
+
+void cursorContextDelete(xcb_cursor_context_t* context)
+{
+    xcb_cursor_context_free(context);
+}

File src/main.cpp

         commandCallback = [&]{
             //set the status bar text
             for (auto& monitor: setup.monitors)
-                monitor.statusBar->setText("Command"); 
+                monitor.statusBar->setMode("[Command]"); 
             //ungrab the command transition keybind
             keyHandler.ungrabKey(config.commandMods, config.commandKey, Press);
 
 
         interactCallback = [&]{
             for (auto& monitor: setup.monitors)
-                monitor.statusBar->setText("Interact"); 
+                monitor.statusBar->setMode("[--Interact--]"); 
             //Ungrab all command keybinds
             keyHandler.ungrabKey(config.interactMods, config.interactKey, Press);
             keyHandler.ungrabKey(config.quitMods, config.quitKey, Press);

File src/monitor.cpp

     delete statusBar;
 }
 
+void Monitor::setStatusBar(StatusBar* newStatusBar)
+{
+    statusBar = newStatusBar;
+    std::vector<std::string> tagNames;
+    for (auto& tag : tagList)
+    {
+        tagNames.push_back(tag.name);
+    }
+    statusBar->setTagNames(tagNames);
+    statusBar->setActiveTag(tagList.at(currentTag).name);
+}
+
 void Monitor::nextTag()
 {
     xcb_rectangle_t rect = area;
         currentTag = 0;
 
     tagList.at(currentTag).windowContainer.layoutWindows(area);
-    //tagList.at(currentTag).windowContainer.raiseAll();
-    statusBar->setText(tagList.at(currentTag).name);
+    statusBar->setActiveTag(tagList.at(currentTag).name);
 }
 
 void Monitor::prevTag()
     }
 
     tagList.at(currentTag).windowContainer.layoutWindows(area);
-    //tagList.at(currentTag).windowContainer.raiseAll();
-    statusBar->setText(tagList.at(currentTag).name);
+    statusBar->setActiveTag(tagList.at(currentTag).name);
 
 }
 

File src/setup.cpp

     getMonitors();
     for (auto& monitor : monitors)
     {
-        monitor.statusBar = new StatusBar(this, monitor);
+        monitor.setStatusBar(new StatusBar(this, monitor));
     }
 }
 
             std::cerr << win.name << std::endl;
             win.tagName = std::get<2>(rule);
             win.exempt = std::get<3>(rule);
+            win.ignore = std::get<4>(rule);
         }
     }
 

File src/statusBar.cpp

 {
 }
 
-void StatusBar::setText(std::string newText)
+void StatusBar::setMode(std::string newMode)
 {
-    text = newText;
+    mode = newMode;
     draw();
 }
 
 
 void StatusBar::draw()
 {
-    context->set_source_rgb(0, 0, 0);
+    context->set_source_rgb(0.1, 0.1, 0.1);
     context->paint();
-    context->move_to(5, 15);
+    context->move_to(2, 15);
     context->set_source_rgb(1, 1, 1);
-    context->set_font_size(12);
-    context->show_text(text);
+    context->select_font_face("Terminus", Cairo::FontSlant::FONT_SLANT_NORMAL, Cairo::FontWeight::FONT_WEIGHT_BOLD);
+    context->set_font_size(15);
+    double x,y;
+    for (auto& name : tagNames)
+    {
+        
+        if (name == activeTagName)
+        {
+            context->get_current_point(x, y);
+            Cairo::TextExtents nameExtents;
+            context->get_text_extents(name, nameExtents);
+            context->rectangle(x-1, 0, nameExtents.x_advance+2,  15 + nameExtents.height);
+            context->set_source_rgb(0.31, 0.6, 0.795);
+            context->fill();
+            context->set_source_rgb(0, 0, 0);
+            context->move_to(x, y);
+        }
+        context->show_text(name);
+        context->show_text(" ");
+        context->set_source_rgb(1,1,1);
+    }
 	context->move_to(width/2, 15);
 	context->show_text(timeText);
 	Cairo::TextExtents extents;
-    context->get_text_extents("Mirror", extents);
+    context->get_text_extents(mode, extents);
 	context->move_to(width - extents.width-5, 15);
-	context->show_text("Mirror");
+	context->show_text(mode);
 	xcb_flush(setup->conn);
 }
 
 {
     draw();
 }
+
+void StatusBar::setTagNames(std::vector<std::string> newTagNames)
+{
+    tagNames = newTagNames;
+    draw();
+}
+
+void StatusBar::setActiveTag(std::string tagName)
+{
+    activeTagName = tagName;
+    draw(); 
+}

File src/window.cpp

     id(id),
     exempt(false),
     fullscreen(false),
+    ignore(false),
     setup(setup)
 {
     inputHint = false;

File src/windowContainer.cpp

 
 void WindowContainer::addWindow(Window window)
 {
+    if (window.ignore)
+    {
+        ignore.push_back(window);
+        return;
+    }
         for (auto& stack : stackList)
     {
         if (stack.empty())
 
 void WindowContainer::killFocused()
 {
-    if (stackList.at(focused.first).empty())
-        return;
-    Window &win = stackList.at(focused.first).at(focused.second);
-    win.close();
-    focused = lastFocused;
-    lastFocused = std::make_pair(0,0);
+    try
+    {
+       Window &win = stackList.at(focused.first).at(focused.second);
+    
+        win.close();
+        focused = lastFocused;
+        lastFocused = std::make_pair(0,0);
+    }
+    catch (std::out_of_range &e)
+    {
+    }
+
 }
 
 void WindowContainer::layoutWindows(xcb_rectangle_t area)