kranewm

An ICCCM & EWMH compliant X11 reparenting, dynamic window manager, written in C++
git clone git://git.deurzen.net/kranewm
Log | Files | Refs | LICENSE

partition.hh (1459B)


      1 #ifndef __PARTITION_H_GUARD__
      2 #define __PARTITION_H_GUARD__
      3 
      4 #include "../winsys/common.hh"
      5 #include "../winsys/screen.hh"
      6 #include "context.hh"
      7 
      8 typedef class Partition final
      9 {
     10 public:
     11     Partition(winsys::Screen screen, Index index)
     12         : m_screen(screen),
     13           m_index(index),
     14           mp_context(nullptr)
     15     {}
     16 
     17     winsys::Screen&
     18     screen()
     19     {
     20         return m_screen;
     21     }
     22 
     23     winsys::Screen const&
     24     screen() const
     25     {
     26         return m_screen;
     27     }
     28 
     29     Index
     30     index() const
     31     {
     32         return m_index;
     33     }
     34 
     35     void
     36     set_context(Context_ptr context)
     37     {
     38         Util::assert(context != nullptr,
     39             "partition must contain a valid context");
     40 
     41         if (mp_context)
     42             mp_context->set_partition(nullptr);
     43 
     44         context->set_partition(this);
     45         mp_context = context;
     46     }
     47 
     48     Context_ptr
     49     context() const
     50     {
     51         return mp_context;
     52     }
     53 
     54     winsys::Region
     55     full_region() const
     56     {
     57         return m_screen.full_region();
     58     }
     59 
     60     winsys::Region
     61     placeable_region() const
     62     {
     63         return m_screen.placeable_region();
     64     }
     65 
     66     bool
     67     contains(winsys::Pos pos) const
     68     {
     69         return m_screen.contains(pos);
     70     }
     71 
     72     bool
     73     contains(winsys::Region region) const
     74     {
     75         return m_screen.contains(region);
     76     }
     77 
     78 private:
     79     winsys::Screen m_screen;
     80     Index m_index;
     81 
     82     Context_ptr mp_context;
     83 
     84 }* Partition_ptr;
     85 
     86 #endif//__PARTITION_H_GUARD__