Check-in [4dc459e610]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Some minor reorganization of the X event handlers:
  • Moved focus change event handlers from minx.core.xevents to minx.layout.base.
  • Removed reparent notification handler from minx.core.xevents in favour of handling the event entirely from minx.layout.base.

This should pretty much all the code that's needed for the 0.2.0 release. Now to tackle the documentation...

Timelines: family | ancestors | descendants | both | dev1.x
Files: files | file ages | folders
SHA1:4dc459e610440103855ba22c88f0be16c5445cd9
User & Date: manuv 2013-07-30 01:54:49
Context
2013-07-31
01:06
Minor updates to make doxygen work without warnings. check-in: 690640b8e9 user: manuv tags: dev1.x
2013-07-30
01:54
Some minor reorganization of the X event handlers:
  • Moved focus change event handlers from minx.core.xevents to minx.layout.base.
  • Removed reparent notification handler from minx.core.xevents in favour of handling the event entirely from minx.layout.base.

This should pretty much all the code that's needed for the 0.2.0 release. Now to tackle the documentation... check-in: 4dc459e610 user: manuv tags: dev1.x

00:21
Make full layout occupy entire area of its parent window. Until now, we were leaving a little space on each side for debugging; that doesn't seem necessary any more... check-in: b66fd70acf user: manuv tags: dev1.x
Changes

Changes to core/hooks.py.

591
592
593
594
595
596
597


598
599
600


601
602
603
604
605
606


607
608
609


610
611
612
613
614
615
616
           return True
        return False # priority queue already contains v

    # Priority of highest-priority item
    def max_priority(self):
        """Return priority of highest-priority item in priority queue.



        """
        # Each item in the priority queue is a 3-tuple, the first element
        # of which is the negated priority (for making a max heap).


        return -self._queue[0][0]

    # Priority of lowest-priority item
    def min_priority(self):
        """Return priority of lowest-priority item in priority queue.



        """
        # Each item in the priority queue is a 3-tuple, the first element
        # of which is the negated priority (for making a max heap).


        return -self._queue[-1][0]

    # Iterator interface
    def __iter__(self):
        """Iterator interface to priority queue.

        This function returns an iterator for accessing the priority







>
>



>
>






>
>



>
>







591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
           return True
        return False # priority queue already contains v

    # Priority of highest-priority item
    def max_priority(self):
        """Return priority of highest-priority item in priority queue.

        If the priority queue is empty, this function will return -1.

        """
        # Each item in the priority queue is a 3-tuple, the first element
        # of which is the negated priority (for making a max heap).
        if len(self._queue) <= 0:
           return -1
        return -self._queue[0][0]

    # Priority of lowest-priority item
    def min_priority(self):
        """Return priority of lowest-priority item in priority queue.

        If the priority queue is empty, this function will return -1.

        """
        # Each item in the priority queue is a 3-tuple, the first element
        # of which is the negated priority (for making a max heap).
        if len(self._queue) <= 0:
           return -1
        return -self._queue[-1][0]

    # Iterator interface
    def __iter__(self):
        """Iterator interface to priority queue.

        This function returns an iterator for accessing the priority

Changes to core/wm.py.

458
459
460
461
462
463
464


465
466
467
468
469
470
471
                logger.warning(e)

            # Some other exception: log it and keep going
            except:
                logger.warning('received {} exception'.
                               format(sys.exc_info()[0]))
                logger.debug(traceback.format_exc())




    # API to focus next window
    def focus_next(self):
        """Focus next window.

        This function passes input focus to the next window in the







>
>







458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
                logger.warning(e)

            # Some other exception: log it and keep going
            except:
                logger.warning('received {} exception'.
                               format(sys.exc_info()[0]))
                logger.debug(traceback.format_exc())

        logger.info('exiting event loop')


    # API to focus next window
    def focus_next(self):
        """Focus next window.

        This function passes input focus to the next window in the

Changes to core/xevents.py.

84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
    # subclasses being "x_something". Thus, the mapping between event
    # types and handlers uses strings as keys and functions as the
    # corresponding values.
    def _init_hooks(self):
        logger.debug('setting up X event handlers')
        h = self._wm.hooks
        h.add('x_create_notify',     self._on_create)
        h.add('x_reparent_notify',   self._on_reparent)
        h.add('x_configure_request', self._on_configure_request)
        h.add('x_map_request',       self._on_map_request)
        h.add('x_map_notify',        self._on_map)
        h.add('x_unmap_notify',      self._on_unmap)
        h.add('x_focus_in',          self._on_focus_in )
        h.add('x_focus_out',         self._on_focus_out)
        h.add('x_key_press',         self._on_key_press)

    # Whether or not window specified by x_create_notify event should
    # be managed by Minx or ignored.
    def _manage(self, e):
        prop = e.target.properties()
        logger.debug('window {} class = {}, name = {}'.
................................................................................
    # them on the focus list. This is because some applications (e.g.,
    # GNOME and XFCE terminal) create hidden top-level windows that
    # should never receive input focus.
    def _on_create(self, e):
        if self._manage (e):
           self._wm.layouts.receptive_layout(e.target).add(e.target)

    # When a Minx layout reparents a top-level window, the resulting
    # reparent notification should be routed to that particular layout.
    def _on_reparent(self, e):
        try:
            layout = self._wm.layouts.find(e.new_parent)
            layout.reparented(e.target)

        except layman.unknown_layout:
            logger.warning('no layout corresponding to window {}'.
                           format(e.new_parent))
            logger.debug('window {} not being managed (bogus reparent_notify?)'.
                         format(e.target.id))

    # What to do when a window wants to be configured: pass configure
    # request through as-is except for top-level windows, which have to
    # be resized according to their managing layout's policy.
    def _on_configure_request(self, e):
        logger.info ('configure request for window {}'.format(e.target.id))
        logger.debug('configure request details: ' +
                     'geom = {}x{}+{}+{}, bw = {}, mask = {:#010b}'.
................................................................................
            f = L.head()
            if f != None:
               logger.info('focusing {}'.format(f.id))
               window.focus(f, self._wm.config)
        except layman.unknown_layout: # not a top-level window
            pass

    # Whenever focus changes, inform the layouts managing the affected
    # windows (in case they need to readjust window geometries to take
    # un/focused border sizes into account).
    def _on_focus_in(self, e):
        try:
            parent = e.target.parent()
            layout = self._wm.layouts.find(parent)
            layout.focused(e.target)
        except layman.unknown_layout:
            pass

    def _on_focus_out(self, e):
        try:
            parent = e.target.parent()
            layout = self._wm.layouts.find(parent)
            layout.unfocused(e.target)
        except layman.unknown_layout:
            pass

    # What to do when a key is pressed.
    def _on_key_press(self, e):
        logger.info('keypress: {}, keycode: {}, mask: {:#06x}'.
                    format(e.key, e.keycode, e.mask))
        self._wm.hooks.trigger(e.key)

#-----------------------------------------------------------------------







<




<
<







 







<
<
<
<
<
<
<
<
<
<
<
<
<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







84
85
86
87
88
89
90

91
92
93
94


95
96
97
98
99
100
101
...
114
115
116
117
118
119
120













121
122
123
124
125
126
127
...
179
180
181
182
183
184
185



















186
187
188
189
190
191
192
    # subclasses being "x_something". Thus, the mapping between event
    # types and handlers uses strings as keys and functions as the
    # corresponding values.
    def _init_hooks(self):
        logger.debug('setting up X event handlers')
        h = self._wm.hooks
        h.add('x_create_notify',     self._on_create)

        h.add('x_configure_request', self._on_configure_request)
        h.add('x_map_request',       self._on_map_request)
        h.add('x_map_notify',        self._on_map)
        h.add('x_unmap_notify',      self._on_unmap)


        h.add('x_key_press',         self._on_key_press)

    # Whether or not window specified by x_create_notify event should
    # be managed by Minx or ignored.
    def _manage(self, e):
        prop = e.target.properties()
        logger.debug('window {} class = {}, name = {}'.
................................................................................
    # them on the focus list. This is because some applications (e.g.,
    # GNOME and XFCE terminal) create hidden top-level windows that
    # should never receive input focus.
    def _on_create(self, e):
        if self._manage (e):
           self._wm.layouts.receptive_layout(e.target).add(e.target)














    # What to do when a window wants to be configured: pass configure
    # request through as-is except for top-level windows, which have to
    # be resized according to their managing layout's policy.
    def _on_configure_request(self, e):
        logger.info ('configure request for window {}'.format(e.target.id))
        logger.debug('configure request details: ' +
                     'geom = {}x{}+{}+{}, bw = {}, mask = {:#010b}'.
................................................................................
            f = L.head()
            if f != None:
               logger.info('focusing {}'.format(f.id))
               window.focus(f, self._wm.config)
        except layman.unknown_layout: # not a top-level window
            pass




















    # What to do when a key is pressed.
    def _on_key_press(self, e):
        logger.info('keypress: {}, keycode: {}, mask: {:#06x}'.
                    format(e.key, e.keycode, e.mask))
        self._wm.hooks.trigger(e.key)

#-----------------------------------------------------------------------

Changes to layout/base.py.

67
68
69
70
71
72
73
74

75
76
77
78
79
80
81
82
83
84
85
86
87


88
89




90
91
92
93
94
95
96
...
106
107
108
109
110
111
112















113
114
115
116
117
118
119
...
158
159
160
161
162
163
164


165
166
167
168
169
170
171
# operation of things such as layout invisibility.

# Need the layout manager maintained by the main window manager object so
# that we can find the layouts for different windows.
_layouts = None

# When a window is reparented, show its layout if the layout isn't
# already visible.

def _on_reparent(e):
    try:
        logger.debug('window {} reparented by {}'.
                     format(e.target.id, e.new_parent.id))

        layout = _layouts.find(e.new_parent)
        logger.debug('window {} being managed by layout {}'.
                     format(e.target.id, layout))

        if not layout.window.is_mapped():
           logger.debug('showing layout {}'.format(layout))
           layout.window.show()



    except minx.core.layman.unknown_layout:
        pass





# When a window is unmapped, also unmap its layout if the layout has no
# more visible windows.
def _on_unmap(e):
    try:
        logger.debug('window {} unmapped'.format(e.target.id))

................................................................................

        logger.debug('hiding layout {} because it has no visible children'.
                     format(layout))
        layout.window.hide()

    except minx.core.layman.unknown_layout:
        pass
















#-------------------------------- CLASS ---------------------------------

class base:
    """A base class for Minx layouts.

    This class implements a base class from which all Minx layout classes
................................................................................

        """
        global _layouts
        if _layouts == None:
           _layouts = m.layouts
           m.hooks.add('x_reparent_notify', _on_reparent, m.hooks.MAX_PRIORITY)
           m.hooks.add(   'x_unmap_notify', _on_unmap,    m.hooks.MAX_PRIORITY)



        x, y, w, h = p.geometry()[:4] # don't need border width
        if r != None: # use supplied rectangle instead of entire parent window
           x, y, w, h = r

        self.window = m.display.create_window(p, x, y, w, h)








|
>













>
>

<
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>







67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

92
93
94
95
96
97
98
99
100
101
102
...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
...
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# operation of things such as layout invisibility.

# Need the layout manager maintained by the main window manager object so
# that we can find the layouts for different windows.
_layouts = None

# When a window is reparented, show its layout if the layout isn't
# already visible and then let the layout object know so it can readjust
# window geometries as required.
def _on_reparent(e):
    try:
        logger.debug('window {} reparented by {}'.
                     format(e.target.id, e.new_parent.id))

        layout = _layouts.find(e.new_parent)
        logger.debug('window {} being managed by layout {}'.
                     format(e.target.id, layout))

        if not layout.window.is_mapped():
           logger.debug('showing layout {}'.format(layout))
           layout.window.show()

        layout.reparented(e.target)

    except minx.core.layman.unknown_layout:

        logger.warning('no layout corresponding to window {}'.
                       format(e.new_parent))
        logger.debug('window {} not being managed (bogus reparent_notify?)'.
                     format(e.target.id))

# When a window is unmapped, also unmap its layout if the layout has no
# more visible windows.
def _on_unmap(e):
    try:
        logger.debug('window {} unmapped'.format(e.target.id))

................................................................................

        logger.debug('hiding layout {} because it has no visible children'.
                     format(layout))
        layout.window.hide()

    except minx.core.layman.unknown_layout:
        pass

# Whenever focus changes, inform the layouts managing the affected
# windows (in case they need to readjust window geometries to take
# un/focused border sizes into account).
def _on_focus_in(e):
    try:
        _layouts.find(e.target.parent()).focused(e.target)
    except minx.core.layman.unknown_layout:
        pass

def _on_focus_out(e):
    try:
        _layouts.find(e.target.parent()).unfocused(e.target)
    except minx.core.layman.unknown_layout:
        pass

#-------------------------------- CLASS ---------------------------------

class base:
    """A base class for Minx layouts.

    This class implements a base class from which all Minx layout classes
................................................................................

        """
        global _layouts
        if _layouts == None:
           _layouts = m.layouts
           m.hooks.add('x_reparent_notify', _on_reparent, m.hooks.MAX_PRIORITY)
           m.hooks.add(   'x_unmap_notify', _on_unmap,    m.hooks.MAX_PRIORITY)
           m.hooks.add('x_focus_in',  _on_focus_in )
           m.hooks.add('x_focus_out', _on_focus_out)

        x, y, w, h = p.geometry()[:4] # don't need border width
        if r != None: # use supplied rectangle instead of entire parent window
           x, y, w, h = r

        self.window = m.display.create_window(p, x, y, w, h)