Changeset 172

Show
Ignore:
Timestamp:
04/26/2005 10:28:02 AM (4 years ago)
Author:
petli
Message:

Added ClientIconified? and ClientDeiconified? events. Used these for an experimental tool to trace the subject lines of clients, typically instant message programs, to be able to monitor them even when they are iconified. Should be moved to a real module when it gets a better name and maybe a bit more configurability. Will probably wreak havoc on my productivity, too.

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/NEWS

    r156 r172  
    11-*-outline-*- 
     2 
     3* Version ?.? (? ??? ????) 
     4 
     5** New synthetic events for iconification 
     6 
     7When a client window is iconified or deiconified, the synthetic events 
     8wmevents.ClientIconified and wmevents.ClientDeiconified is sent, 
     9respectively.  
     10 
    211 
    312* Version 2.6a (7 Apr 2004) 
  • trunk/examples/petliwm.py

    r170 r172  
    11#!/usr/bin/env python 
     2# -*- coding: iso-8859-1 -*- 
    23# 
    34# petliwm.py -- My PLWM "configuration" 
     
    5556            w, h = self.follow_size_hints(w, h) 
    5657            self.configure(x = x, y = y, width = w, height = h) 
     58 
     59 
     60class TraceIMClient: 
     61 
     62    """Trace IM clients which alter their window title when there's 
     63    new/unread messages. 
     64 
     65    Do this by reacting to WM_NAME and iconification changes, applying 
     66    a filter each time. 
     67    """ 
     68 
     69    # A list of tuples (filter_enable_tracing, filter_unseen_im, message) 
     70     
     71    traceim_clients = () 
     72     
     73    def __client_init__(self): 
     74        for enable, unseen, message in self.traceim_clients: 
     75            if enable(self): 
     76                self.traceim_unseen = unseen 
     77                self.traceim_message = message 
     78                self.dispatch.add_handler(X.PropertyNotify, self.traceim_handle_property) 
     79                self.dispatch.add_handler(wmevents.ClientIconified, self.traceim_handle_iconified) 
     80                self.dispatch.add_handler(wmevents.ClientDeiconified, self.traceim_handle_iconified) 
     81                break 
     82 
     83 
     84    def traceim_handle_property(self, evt): 
     85        if evt.atom == Xatom.WM_NAME: 
     86            self.traceim_update() 
     87 
     88    def traceim_handle_iconified(self, evt): 
     89        self.traceim_update() 
     90 
     91    def traceim_update(self): 
     92        if self.traceim_unseen(self): 
     93            self.wm.traceim_add_message(self.traceim_message) 
     94        else: 
     95            self.wm.traceim_remove_message(self.traceim_message) 
    5796             
     97 
     98class ModeWindowTraceIM: 
     99    mw_traceim_position = 0.1 
     100    mw_traceim_justification = modewindow.LEFT 
     101     
     102    def __wm_init__(self): 
     103        self.mw_traceim_messages = [] 
     104        self.mw_traceim_message = modewindow.Message(self.mw_traceim_position, 
     105                                                     self.mw_traceim_justification) 
     106        for s in self.screens: 
     107            s.modewindow_add_message(self.mw_traceim_message) 
     108             
     109    def traceim_add_message(self, message): 
     110        if message not in self.mw_traceim_messages: 
     111            self.mw_traceim_messages.append(message) 
     112            self.mw_traceim_message.set_text(' '.join(self.mw_traceim_messages)) 
     113 
     114    def traceim_remove_message(self, message): 
     115        try: 
     116            self.mw_traceim_messages.remove(message) 
     117        except ValueError: 
     118            return 
     119         
     120        self.mw_traceim_message.set_text(' '.join(self.mw_traceim_messages)) 
     121         
     122 
    58123class MyClient(wmanager.Client, 
    59124               outline.XorOutlineClient, 
     
    62127               misc.InitialKeepOnScreenClient, 
    63128               focus.JumpstartClient, 
     129               TraceIMClient, 
    64130               ): 
    65131     
     
    73139    border_color_name = "grey20" 
    74140    border_focuscolor_name = "grey60" 
     141 
     142    traceim_clients = [ 
     143        (And(name('Emacs'), re_title('KOM')), # only KOM client Emacs 
     144         And(iconified, re_title('Olästa')),  # only when iconified and unread 
     145         'Olästa') 
     146        ] 
     147 
    75148 
    76149class MyScreen(wmanager.Screen, 
     
    88161    def __wm_init__(self): 
    89162        BasicKeys(self) 
    90         self.dispatch.add_handler('cmdevent', cmdhandler) 
    91163 
    92164         
     
    98170           mw_acpi.ModeWindowACPI, 
    99171           inspect.InspectServer, 
     172           ModeWindowTraceIM, 
    100173           WMConfig): 
    101174 
     
    106179    screen_class = MyScreen 
    107180     
    108 def cmdhandler(evt): 
    109     print 'Exit:', evt.exitstatus(), 'Signal:', evt.termsig() 
    110181     
    111182class BasicKeys(keys.KeyHandler): 
     
    210281 
    211282    def F3(self, evt): 
    212         self.wm.current_screen.view_find_with_client(Or(name('Mozilla'), 
     283        self.wm.current_screen.view_find_with_client(Or(name('Gecko'), 
     284                                                        name('Mozilla'), 
    213285                                                        name('Netscape'), 
    214286                                                        name('Mozilla-bin'))) 
  • trunk/plwm/wmanager.py

    r137 r172  
    1 # $Id: wmanager.py,v 1.25 2002-07-12 22:19:34 petli Exp $ 
     1# $Id: wmanager.py,v 1.26 2005-04-26 15:28:02 petli Exp $ 
    22# 
    33# wmanager.py -- core window manager functionality 
     
    561561        self.mapped = 0 
    562562        self.window.set_wm_state(state = Xutil.IconicState, icon = 0) 
    563  
     563        self.wm.events.put_event(wmevents.ClientIconified(self)) 
    564564 
    565565    def deiconify(self): 
     
    582582        self.mapped = 1 
    583583        self.window.set_wm_state(state = Xutil.NormalState, icon = 0) 
     584        self.wm.events.put_event(wmevents.ClientDeiconified(self)) 
    584585 
    585586 
  • trunk/plwm/wmevents.py

    r60 r172  
    1 # $Id: wmevents.py,v 1.1 2001-12-06 11:08:09 petli Exp $ 
     1# $Id: wmevents.py,v 1.2 2005-04-26 15:28:02 petli Exp $ 
    22# 
    33# Internal events generated by the window manager core. 
     
    5151        self.client = client 
    5252 
     53class ClientIconified: 
     54    def __init__(self, client): 
     55        self.type = ClientIconified 
     56        self.client = client 
     57 
     58class ClientDeiconified: 
     59    def __init__(self, client): 
     60        self.type = ClientDeiconified 
     61        self.client = client 
     62 
    5363class CommandEvent: 
    5464    def __init__(self, type):