kranewl

A wlroots-based dynamic Wayland compositor, written in C++, configurable with Lua
git clone git://git.deurzen.net/kranewl
Log | Files | Refs | LICENSE

layer.hh (2939B)


      1 #pragma once
      2 
      3 #include <kranewl/common.hh>
      4 #include <kranewl/geometry.hh>
      5 #include <kranewl/scene-layer.hh>
      6 #include <kranewl/tree/node.hh>
      7 
      8 extern "C" {
      9 #include <wayland-server-core.h>
     10 }
     11 
     12 #include <chrono>
     13 #include <vector>
     14 
     15 typedef class Server* Server_ptr;
     16 typedef class Model* Model_ptr;
     17 typedef class Seat* Seat_ptr;
     18 typedef class Output* Output_ptr;
     19 typedef struct LayerPopup* LayerPopup_ptr;
     20 
     21 typedef struct Layer final : public Node {
     22     Layer(
     23         struct wlr_layer_surface_v1*,
     24         Server_ptr,
     25         Model_ptr,
     26         Seat_ptr,
     27         Output_ptr,
     28         SceneLayer
     29     );
     30 
     31     ~Layer();
     32 
     33     void format_uid() override;
     34 
     35     pid_t pid();
     36 
     37     static void handle_map(struct wl_listener*, void*);
     38     static void handle_unmap(struct wl_listener*, void*);
     39     static void handle_surface_commit(struct wl_listener*, void*);
     40     static void handle_new_popup(struct wl_listener*, void*);
     41     static void handle_destroy(struct wl_listener*, void*);
     42 
     43     bool mapped() const { return m_mapped; }
     44     void set_mapped(bool);
     45 
     46     Region const& region() { return m_region; }
     47     void set_region(Region const&);
     48 
     49     Server_ptr mp_server;
     50     Model_ptr mp_model;
     51     Seat_ptr mp_seat;
     52 
     53     Output_ptr mp_output;
     54 
     55 	struct wlr_scene_node* mp_scene;
     56     SceneLayer m_scene_layer;
     57 	struct wlr_layer_surface_v1* mp_layer_surface;
     58 
     59     std::vector<LayerPopup_ptr> m_popups;
     60 
     61     pid_t m_pid;
     62 
     63     struct wl_listener ml_map;
     64     struct wl_listener ml_unmap;
     65     struct wl_listener ml_surface_commit;
     66     struct wl_listener ml_new_popup;
     67     struct wl_listener ml_destroy;
     68 
     69 private:
     70     Region m_region;
     71     int m_mapped;
     72     std::chrono::time_point<std::chrono::steady_clock> m_managed_since;
     73 
     74 }* Layer_ptr;
     75 
     76 typedef struct LayerPopup final {
     77     LayerPopup(
     78         struct wlr_xdg_popup*,
     79         Layer_ptr,
     80         Server_ptr,
     81         Model_ptr,
     82         Seat_ptr
     83     );
     84 
     85     LayerPopup(
     86         struct wlr_xdg_popup*,
     87         LayerPopup_ptr,
     88         Layer_ptr,
     89         Server_ptr,
     90         Model_ptr,
     91         Seat_ptr
     92     );
     93 
     94     ~LayerPopup();
     95 
     96     Region const& region() { return m_region; }
     97     void set_region(Region const&);
     98 
     99     static void handle_map(struct wl_listener*, void*);
    100     static void handle_unmap(struct wl_listener*, void*);
    101     static void handle_surface_commit(struct wl_listener*, void*);
    102     static void handle_new_popup(struct wl_listener*, void*);
    103     static void handle_destroy(struct wl_listener*, void*);
    104 
    105     Server_ptr mp_server;
    106     Model_ptr mp_model;
    107     Seat_ptr mp_seat;
    108 
    109 	Layer_ptr mp_root;
    110 	LayerPopup_ptr mp_parent;
    111 
    112 	struct wlr_scene_node* mp_scene;
    113     SceneLayer m_scene_layer;
    114     struct wlr_xdg_popup* mp_wlr_popup;
    115 
    116     std::vector<LayerPopup_ptr> m_popups;
    117 
    118     struct wl_listener ml_map;
    119     struct wl_listener ml_unmap;
    120     struct wl_listener ml_surface_commit;
    121     struct wl_listener ml_new_popup;
    122     struct wl_listener ml_destroy;
    123 
    124 private:
    125     Region m_region;
    126 
    127 }* LayerPopup_ptr;