File: xwindow.hpp

package info (click to toggle)
polybar 3.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,108 kB
  • sloc: cpp: 30,424; python: 3,750; sh: 284; makefile: 83
file content (59 lines) | stat: -rw-r--r-- 1,482 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once

#include "modules/meta/event_handler.hpp"
#include "modules/meta/static_module.hpp"
#include "modules/meta/types.hpp"
#include "x11/ewmh.hpp"
#include "x11/icccm.hpp"
#include "x11/window.hpp"

POLYBAR_NS

class connection;

namespace modules {
  class active_window : public non_copyable_mixin, public non_movable_mixin {
   public:
    explicit active_window(xcb_connection_t* conn, xcb_window_t win);
    ~active_window();

    bool match(xcb_window_t win) const;
    string title() const;
    string instance_name() const;
    string class_name() const;

   private:
    xcb_connection_t* m_connection{nullptr};
    xcb_window_t m_window{XCB_NONE};
  };

  /**
   * Module used to display information about the
   * currently active X window.
   */
  class xwindow_module : public static_module<xwindow_module>, public event_handler<evt::property_notify> {
   public:
    enum class state { NONE, ACTIVE, EMPTY };
    explicit xwindow_module(const bar_settings&, string, const config&);

    void update();
    bool build(builder* builder, const string& tag) const;

    static constexpr auto TYPE = XWINDOW_TYPE;

   protected:
    void handle(const evt::property_notify& evt) override;

    void reset_active_window();

   private:
    static constexpr const char* TAG_LABEL{"<label>"};

    connection& m_connection;
    unique_ptr<active_window> m_active;
    map<state, label_t> m_statelabels;
    label_t m_label;
  };
} // namespace modules

POLYBAR_NS_END