Changeset 152

Show
Ignore:
Timestamp:
03/31/08 19:06:12 (9 months ago)
Author:
poillubo
Message:

* better debug message when a hook fails
* corrected various issues with client shading

+ iconification now works correctly again
+ resizing/maximizing support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pycawm/client.py

    r151 r152  
    2525import Image 
    2626 
     27from copy import copy 
    2728from Xlib import X, Xutil, protocol, error 
    2829from Xlib.error import BadDrawable, BadWindow, BadMatch, XError 
     
    154155        return self.window in self.parent.query_tree().children 
    155156 
     157    @property 
     158    def nonshaded_geometry(self): 
     159        if self.states.shaded: 
     160            geo = copy(self.geometry) 
     161            geo.height = (self.window.get_geometry().height + 
     162                          self.title_bar_height) 
     163        else: 
     164            geo = self.geometry 
     165        return geo 
     166 
    156167    def is_hidden(self): 
    157168        return (self.states.icccm_state == self.withdrawn or 
     
    482493            return 
    483494 
     495        iconified = self.states.icccm_state == self.iconified 
     496 
    484497        self.states.icccm_state = self.withdrawn 
    485498        # the 2 lines below will generate BadWindow errors 
     
    490503 
    491504        # iconified window disappearing? 
    492         if self.states.icccm_state == self.iconified: 
     505        if iconified: 
    493506            # do nothing... 
    494507            pass 
     
    621634 
    622635    def send_configure_notify(self): 
    623         # no need to send anything if we do not see the client 
    624         if self.is_hidden()
     636        # no need to send anything if we do not see the client or window 
     637        if self.is_hidden() or self.states.shaded
    625638            return 
    626639 
     
    664677 
    665678    def resize(self, coords, little=False): 
    666         if self.states.shaded: 
    667             # for now, do not resize a shaded client 
    668             return 
    669  
    670679        left = coords['left'] 
    671680        top = coords['top'] 
     
    681690        bottom = self.good_dy_increment(bottom, little) 
    682691 
    683         x = self.geometry.x + left 
    684         y = self.geometry.y + top 
    685         width = self.geometry.width - left + right 
    686         height = self.geometry.height - self.title_bar_height - top + bottom 
     692        geo = self.nonshaded_geometry 
     693        x = geo.x + left 
     694        y = geo.y + top 
     695        width = geo.width - left + right 
     696        height = geo.height - self.title_bar_height - top + bottom 
    687697 
    688698        if self.wm_normal_hints is not None: 
     
    699709                return 
    700710 
     711        self.window.configure(width=width, height=height) 
    701712        self.title_bar.configure(width=width, height=self.title_bar_height) 
    702         self.parent.configure(width=width, height=height+self.title_bar_height) 
    703         self.window.configure(width=width, height=height) 
     713        if self.states.shaded: 
     714            self.parent.configure(width=width, 
     715                                  height=self.title_bar_height) 
     716        else: 
     717            self.parent.configure(width=width, 
     718                                  height=height+self.title_bar_height) 
    704719        self.move(dict(x=x, y=y), send_event=False) 
    705720 
     
    808823        if horizontally and vertically: 
    809824            self.states.maximized = self.maximized_both 
    810         geo = self.geometry 
     825        geo = self.nonshaded_geometry 
    811826        self.coords_backup = (geo.x, geo.y, 
    812827                              geo.width, geo.height) 
     
    846861            self.window.configure(x=0, y=self.title_bar_height) 
    847862            self.title_bar.map() 
    848         geo = self.geometry 
     863        geo = self.nonshaded_geometry 
    849864        x, y = self.coords_backup[:2] 
    850865        right = self.coords_backup[2] - geo.width 
     
    864879                clients.append(client) 
    865880        geo = self.geometry 
    866         self.coords_backup = (geo.x, geo.y, 
    867                               geo.width, geo.height) 
    868881        if horizontally: 
    869882            x1, x2 = [-1], [self.screen.width_in_pixels] 
     
    890903                else: 
    891904                    y2.append(geo_client.y - 1) 
     905        geo = self.nonshaded_geometry 
     906        self.coords_backup = (geo.x, geo.y, 
     907                              geo.width, geo.height) 
    892908        self.move(dict(x=max(x1) + 1, y=max(y1) + 1)) 
    893909        self.resize( 
     
    912928    def fullscreen(self): 
    913929        # Warning: alpha code ;-) 
    914         if self.states.maximized
     930        if self.states.maximized or self.states.shaded
    915931            return 
    916932        geo = self.geometry 
     
    947963            return 
    948964 
    949         visible = False if self.is_hidden() else True 
     965        visible = not self.is_hidden() 
    950966        self.states.icccm_state = self.iconified 
    951967        self.window.set_wm_state(state=Xutil.IconicState, icon=0) 
     
    967983    def shade(self): 
    968984        if self.states.reparented and not self.states.shaded: 
    969             self.states.icccm_state = self.iconified 
    970             self.window.set_wm_state(state=Xutil.IconicState, icon=0) 
     985            # window will become invisible, we need to change its state 
     986            if not self.is_hidden(): 
     987                self.window.set_wm_state(state=Xutil.WithdrawnState, icon=0) 
     988                disable_method_for_instance(self.withdraw) 
     989                self.window.unmap() 
    971990            self.parent.configure(height=self.title_bar_height) 
    972991            self.geometry = self.parent.get_geometry() 
     
    975994    def unshade(self): 
    976995        if self.states.reparented and self.states.shaded: 
    977             self.states.icccm_state = self.normal 
    978             self.window.set_wm_state(state=Xutil.NormalState, icon=0) 
     996            # window will become visible again, change its state to reflect that 
     997            if not self.is_hidden(): 
     998                self.window.set_wm_state(state=Xutil.NormalState, icon=0) 
     999                self.window.map() 
     1000                # get the lost focus from the temporay unmapping 
     1001                if self.states.focused: 
     1002                    self.states.focused = False 
     1003                    self.take_focus() 
    9791004            geo = self.window.get_geometry() 
    9801005            self.parent.configure(height=self.title_bar_height + geo.height) 
  • trunk/pycawm/hookmanager.py

    r151 r152  
    6767                ret_args = hook(*args, **kwargs) 
    6868            except TypeError: 
    69                 print ('Cannot execute %s %s for %s, args: %s, %s' % 
     69                print ('Cannot execute %s %s for %s, args: %s, kwargs: %s' % 
    7070                       (get_hook_type(hooks), hook, key, args, kwargs)) 
    7171    return ret_args 
  • trunk/pycawm/pycawm.py

    r146 r152  
    617617                return ( 
    618618                    (ny < 0 and pointer.root_y < client.geometry.y + 
    619                      client.geometry.height + client.parent_border_width) or 
     619                     client.nonshaded_geometry.height + 
     620                     client.parent_border_width) or 
    620621                    (ny > 0 and pointer.root_y > client.geometry.y + 
    621                      client.geometry.height + (client.parent_border_width * 2))) 
     622                     client.nonshaded_geometry.height + 
     623                     (client.parent_border_width * 2))) 
    622624            elif edge == PycaWM.left: 
    623625                return (