Commits

youngs  committed 04ec7c4

reverting to last released package so Norbert can release sumos

  • Participants
  • Parent commits 96254cc

Comments (0)

Files changed (61)

-2004-12-11  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* lisp/xwem-events.el (xwem-ev-reconfig): [fix] Correct way to
-		  handle opera issue.
-
-2004-12-11  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* lisp/xwem-main.el (xwem-debug-routines): [addon] X routines
-		  added.
-
-	* lisp/xwem-events.el (xwem-ev-reconfig): [fix] Do not handle
-		  ConfigureRequest events for non-xwem-clients
-		  aka [opera issue].
-
-2004-12-08  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* lisp/xwem-minibuffer.el: [addon] Define
-		  x-emacs-application-class at compile time.
-	* lisp/xwem-special.el: Ditto.
-
-2004-12-08  Steve Youngs  <steve@youngs.au.com>
-
-	* lisp/xwem-misc.el (xwem-misc-find-cl-by-emacs-frame): Fix
-	logic... a when statement was closed too soon.
-
-2004-12-07  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* lisp/xwem-keyboard.el (xwem-kbd-xksym->emacs):
-	(xwem-kbd-emacs->xksym): support for all the special X keysyms like
-	multimedia keys in /usr/X11R6/lib/X11/XKeysymDB.
-
-2004-12-08  Richard Klinda  <ignotus@hixsplit.hu>
-
-	* lisp/xwem-misc.el: (xwem-misc-find-cl-by-emacs-frame):
-	[fix] use x-emacs-application-class nstead of hardcoded
-	"Emacs" string.
-
-2004-12-06  Zajcev Evgeny <zevlg@yandex.ru>
-
-	* extra/xwem-frametrans.el (Repository): initial import of frame
-		  transparency code.  Not yet fully functional however.
-
-	* dockapp/xwem-pager.el:
-	* dockapp/xwem-pager.el (requires): [fix] xwem-load, xlib-xshape
-		  added.
-
-2004-12-06  Zajcev Evgeny <zevlg@yandex.ru>
-
-	* *.el (Author): Fixes.
-	
-2004-12-06  Zajcev Evgeny <zevlg@yandex.ru>
-
-	* dockapp/xwem-pager.el (Repository): Initial import of xwem-pager
-		  code done by Richard Klinda <ignotus@hixsplit.hu>
-
-2004-12-06  Zajcev Evgeny <zevlg@yandex.ru>
-
-	* lisp/xwem-keyboard.el (xwem-hyper-modifier): [addon] Alt 
-	* lisp/xwem-keyboard.el (xwem-meta-modifier): Ditto.
-	* lisp/xwem-keyboard.el (xwem-control-modifier): Ditto.
-
-	Alt modifier added, however not yet supported in keys resolution
-	code.
-	
-	* lisp/xwem-misc.el:
-	* lisp/xwem-misc.el (xwem-misc-mask-pixmap): New.
-	* lisp/xwem-misc.el (xwem-misc-mask-fgc): New.
-	* lisp/xwem-misc.el (xwem-misc-mask-bgc): New.
-	* lisp/xwem-misc.el (xwem-misc-init): [addon] common masking
-		  initialisation.
-
-	Masking fg/bg X-Gc's added for common use.
-	
-	* dockapp/xwem-battery.el:
-	* dockapp/xwem-battery.el (apm-battery): New.  Emacs lisp version
-		  of apm-battery.  It is not required to have apm-battery
-		  DSO loaded to use xwem-battery dockapp.
-
-	* dockapp/xwem-framei.el:
-	* dockapp/xwem-framei.el (xwem-frame):
-	* dockapp/xwem-framei.el (xwem-framei-default-format):
-	* dockapp/xwem-framei.el (xwem-framei-dockapp-keymap):
-	* dockapp/xwem-framei.el (xwem-framei-dockapp-default-format):
-	* dockapp/xwem-framei.el (xwem-framei-stop-dockapp):
-	* dockapp/xwem-framei.el (xwem-framei-dockapp):
-	* dockapp/xwem-framei.el (xwem-framei-dockapp-popup-menu):
-	* dockapp/xwem-framei.el (xwem-framei-dockapp-popup-alt-menu):
-		  New.  Alternative menu.
-
-	Fixes due to race condition, when killing client in dedicated
-	frame.
-
-	* utils/xwem-osd.el (xwem-osd-event-handler): [fix] use
-		  xwem-override-local-map
-
-	* lisp/xwem-help.el (xwem-help-where-is): [fix] use
-		  xwem-global-keymap.
-
-	* lisp/xwem-clients.el (xwem-cl-apply-new-xgeom): [arguments]
-		  HOLD-SIZE argument added.
-	* lisp/xwem-clients.el (xwem-refit-dedicated): [fix] Use
-		  HOLD-SIZE.
-
-	* extra/xwem-recover.el (xwem-recover-real-recover): [fix] xdpy ->
-		  xwem-dpy
-
-2004-12-06  Steve Youngs  <steve@youngs.au.com>
-
-	From Richard Klinda <ignotus@hixsplit.hu>
-	* lisp/xwem-manage.el (xwem-cl-match-p): Guard against buffers
-	that don't have filenames assoctiated with them.
-
-2004-12-05  Steve Youngs  <steve@youngs.au.com>
-
-	* lisp/xwem-report.el: Autoload xwem-dpy, X-Dpy at compile time.
-	(xwem-report-debug): Don't include
-	xwem-loaddefs.el in the files to snoop for changed variables.
-	(xwem-prepare-report): Include xwem and xlib version strings.
-
-2004-12-05  Steve Youngs  <steve@youngs.au.com>
-
-	* utils/xwem-holer.el:
-	* utils/xwem-osd.el:
-	* utils/xwem-worklog.el:
-	* lisp/xwem-clgen.el:
-	* lisp/xwem-clients.el:
-	* lisp/xwem-clswi.el:
-	* lisp/xwem-desktop.el:
-	* lisp/xwem-edmacro.el:
-	* lisp/xwem-faces.el:
-	* lisp/xwem-focus.el:
-	* lisp/xwem-frame.el:
-	* lisp/xwem-icons.el:
-	* lisp/xwem-interactive.el:
-	* lisp/xwem-keyboard.el:
-	* lisp/xwem-keymacro.el:
-	* lisp/xwem-launcher.el:
-	* lisp/xwem-main.el:
-	* lisp/xwem-manage.el:
-	* lisp/xwem-minibuffer.el:
-	* lisp/xwem-misc.el:
-	* lisp/xwem-mouse.el:
-	* lisp/xwem-netwm.el:
-	* lisp/xwem-register.el:
-	* lisp/xwem-report.el: New file.
-	* lisp/xwem-root.el:
-	* lisp/xwem-rooter.el:
-	* lisp/xwem-rooticon.el:
-	* lisp/xwem-selections.el:
-	* lisp/xwem-sound.el:
-	* lisp/xwem-special.el:
-	* lisp/xwem-strokes.el:
-	* lisp/xwem-tabbing.el:
-	* lisp/xwem-theme.el:
-	* lisp/xwem-transient.el:
-	* lisp/xwem-tray.el:
-	* lisp/xwem-win.el:
-	* extra/ixwem.el:
-	* extra/xwem-recover.el:
-	* extra/xwem-smartmods.el:
-	* dockapp/xwem-battery.el:
-	* dockapp/xwem-framei.el:
-	* dockapp/xwem-time.el:
-	* dockapp/xwem-weather.el:
-
-	Add a bug-reporting module.  All files that have user configurable
-	variables have been touched to accomodate the bug-reporter.
-	Basically all the defcustoms were grouped together and a magic
-	cookie `;;; Internal variables' was added to each of these files.
-
-2004-12-04  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* lisp/xwem-misc.el (xwem-misc-find-emacs-frame): [fix] window-id
-		  stringp error
-	* lisp/xwem-misc.el (xwem-misc-find-cl-by-emacs-frame): [fix]
-		  window-id stringp error
-
-	Also multidevicing fixes.
-
-2004-12-04  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* lisp/xwem-special.el (xwem-special-make-frame):
-
-	* lisp/xwem-ratanot.el (xwem-rnt-create-frame):
-
-	* lisp/xwem-mouse.el (xwem-applications-submenu):
-
-	* lisp/xwem-minibuffer.el (xwem-minib-create):
-
-	Use default x device to create XEmacs frames.  AKA multidevicing
-	patch.
-
-2004-12-04  Steve Youngs  <steve@youngs.au.com>
-
-	* lisp/xwem-main.el (xwem-init): Don't set print-level, it breaks
-	BBDB. 
-
-2004-12-04  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* lisp/xwem-rooticon.el (xwem-rooticon-select-place): [fix]
-		  debugging stuff removed.
-
-2004-12-04  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* lisp/xwem-desktop.el (xwem-desktop-save): [fix] Set print-length
-	and print-level to nil, before printing values to buffer.  Note:
-	Other code which performes similiar functionality also need to be
-	fixed this way.
-
-2004-12-04  Steve Youngs  <steve@youngs.au.com>
-
-	From Richard Klinda <ignotus@hixsplit.hu>
-	* utils/xwem-worklog.el (xwem-worklog-meaning-update-time): Take
-	into account the situation where the day's end hour can be smaller
-	than the day's start hour.
-	(xwem-worklog-generate-percentage-spec): Ditto.
-
-2004-12-04  Steve Youngs  <steve@youngs.au.com>
-
-	* lisp/xwem-main.el (xwem-init): Remove a `setq' as it is inside a
-	`setf'.
-
-2004-12-03  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* lisp/xwem-clients.el (xwem-dummy-client-init): [fix] Set event
-		  mask to receive key/button events.  Thanks to Richard
-		  Klinda for finding this.
-
-	* lisp/xwem-frame.el (xwem-frame-imove-internal): [fix] Unneded
-		  call to `xwem-frame-set-size' removed.
-
-	* lisp/xwem-main.el (xwem-init): [addon] set print-level to 2 if
-		  using presetup.  This solves xwem objects printing
-		  problem.
-
-2004-12-03  Steve Youngs  <steve@youngs.au.com>
-
-	* lisp/xwem-gamma.el (xwem-gamma-corector): Call `XFlush' on
-	`xwem-gamma-display'. 
-
-	* lisp/xwem-events.el (xwem-event-as-command): Make sure we're not
-	in xwem's global keymap.
-
-2004-12-03  Steve Youngs  <steve@youngs.au.com>
-
-	* utils/xwem-osd.el: Update my commented example OSD.
-
-2004-12-03  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* lisp/xwem-rooticon.el (xwem-rooticon-select-place):
-	* lisp/xwem-rooticon.el (xwem-rooticon-apply-state):
-
-	Position selection fixes.
-
-2004-12-02  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* utils/xwem-worklog.el (xwem-worklog-history-init): [fix]
-
-	Patch from Richard Klinda applied.
-
-2004-12-01  Steve Youngs  <steve@youngs.au.com>
-
-	* Makefile (REQUIRES): Add mail-lib.
-
-	* lisp/.cvsignore: New.  Add generated file `xwem-loaddefs.el'.
-
-2004-12-01  Zajcev Evgeny <zevlg@yandex.ru>
-
-	* dockapp/xwem-framei.el:
-	* dockapp/xwem-framei.el (xwem-framei-face):
-	* dockapp/xwem-framei.el (xwem-framei-default-sff):
-	* dockapp/xwem-framei.el (xwem-framei-show-osd): New.
-
-	Fixes to make it work.
-
-	* lisp/xwem-rooticon.el:
-	* lisp/xwem-rooticon.el (xwem-rooticon-default-icon): New.
-	* lisp/xwem-rooticon.el (xwem-rooticon-default-show-label): New.
-	* lisp/xwem-rooticon.el (xwem-rooticon-default-pixmap): New.
-	* lisp/xwem-rooticon.el (xwem-rooticon-icons): New.
-	* lisp/xwem-rooticon.el (xwem-rooticon-create):
-	* lisp/xwem-rooticon.el (xwem-rooticon-draw):
-	* lisp/xwem-rooticon.el (xwem-rooticon-apply-state):
-
-	Fixes to show rooticon for client that does not their own icon.
-
-	* lisp/xwem-keydefs.el: H-z - xwem-client-iconify
-
-	* lisp/xwem-faces.el:
-	* lisp/xwem-faces.el (xwem-custom-declare-face): [fix] Support for
-		  :size and :family face attributes added.
-	* lisp/xwem-faces.el (xwem-set-face-font-attribute): New.
-	* lisp/xwem-faces.el (xwem-set-face-font-family): New.
-	* lisp/xwem-faces.el (xwem-set-face-font-size): New.
-	* lisp/xwem-faces.el (xwem-set-face-bold): New.
-	* lisp/xwem-faces.el (xwem-set-face-italic): New.
-
-	* lisp/xwem-clients.el:
-	* lisp/xwem-clients.el (xwem-cl-noicon-name): New.
-	* lisp/xwem-clients.el (xwem-cl-presetup): cleanup
-	* lisp/xwem-clients.el (xwem-cl-hproperty): Ditto.
-
-	* utils/xwem-diagram.el (xwem-diag-plot-coordinates): tiny cleanup.
-	* utils/xwem-diagram.el (xwem-diag-plot-points): Ditto.
-	* utils/xwem-diagram.el (xwem-diag-plot-dots): Ditto.
-
-	* utils/xwem-worklog.el (xwem-worklog-tasks-description): [fix]
-		  Unknown task has grey color.
-
-	* package-info.in (requires): xwem-macros removed.
-
-2004-11-30  Zajcev Evgeny <zevlg@yandex.ru>
-
-	* TODO: Steve Youngs's proposal to click and drag client tab.
-
-	* lisp/xwem-frame.el (xwem-frame-showroot): [fix] select dummy
-		  client after all frames unmapped.
-
-2004-11-29  Zajcev Evgeny <zevlg@yandex.ru>
-
-	* xwem: Initial import of 2.0 release candidate 2.
-
-	To many fixes to describe here.  There was no posibilities to add
-	entries to this changelog file while developing 2.0 :(
-
 2004-09-16  Norbert Koch  <viteno@xemacs.org>
 
 	* Makefile (VERSION): XEmacs package 1.18 released.
 # Boston, MA 02111-1307, USA.
 
 VERSION = 1.18
-AUTHOR_VERSION = 2.0rc2
+AUTHOR_VERSION = 0.2
 MAINTAINER = Zajcev Evgeny <zevlg@yandex.ru>
 PACKAGE = xwem
 PKG_TYPE = regular
-REQUIRES = xwem xemacs-base xlib strokes edit-utils text-modes time slider \
-		ilisp elib mail-lib
+REQUIRES = xwem xemacs-base xlib strokes edit-utils text-modes time slider
 CATEGORY = standard
 
-PRELOADS= -l lpath.el
-
 DONTCOMPILE = lisp/_pkg.el lisp/auto-autoloads.el lisp/custom-load.el
 
-ELCS = $(patsubst %.el,%.elc,$(filter-out $(DONTCOMPILE),$(wildcard lisp/*.el extra/*.el utils/*.el dockapp/*.el)))
+ELCS = $(patsubst %.el,%.elc,$(filter-out $(DONTCOMPILE),$(wildcard lisp/*.el)))
 
 DATA_FILES = $(wildcard icons/*.x[bp]m) logo.xpm
 DATA_DEST = $(PACKAGE)
 
 EXPLICIT_DOCS = man/xwem.texi
 
-GENERATED_LISP = lisp/xwem-loaddefs.el
-
 include ../../XEmacs.rules
-
-lisp/xwem-loaddefs.el:  $(filter-out lisp/xwem-loaddefs.el,$(ELCS:.elc=.el))
-	$(XEMACS) $(BATCH) -no-autoloads -l lpath.el -f xwem-batch-update-directory
-Mon Nov 30 01:07:00 MSK 2004:
-
-     - H-<button1> on tab to drag tab to some other place.
-
 Thu Feb 19 09:16:05 MSK 2004:
 
-     - Focusing manage (according to ICCCM)! very needed. DONE!
+     - Focusing manage (according to ICCCM)! very needed. (mostly done)
 
      - More ICCCM stuff to support, like WM_PROTOCOL, DELETE_WINDOW,
-       etc. DONE!
+       etc. (mostly done)
      
-     - Write some documentation. 
+     - Write some documentation.
 
-     - Configuration file handling. DONE!
+     - Configuration file handling. (I think it is done).
 
      - More hookenization.
 
      - Session management. save-window-configuration,
        set-window-configuration, save-frame-configuration,
-       set-frame-configuration, etc. DONE!
+       set-frame-configuration, etc. (window configurations done)
 
      - kbd macros. i.e. save keypress sequence and then play it with
-       XSendEvent. DONE!
+       XSendEvent. (Done, using xtest extension)
 
      - Strokes:
          * Support for dymanic strokes types. i.e. you can register
 
          * Kanji strokes database
 
-     - CL switcher, something like `iswitchb' or `buqis'. DONE!
+     - CL switcher, something like `iswitchb' or `buqis'.(Done mostly)
 
-     - Programs launcher. DONE!
+     - Programs launcher.(done)
 
      - Summarize mode. i.e. make buffer with xwem information like
        frames setup, clients online, etc.(Done `xwem-help')
 
      - Multiple visible frames(partly done), frame should reguard his
        properties changes on fly, i.e. resize x window, when frame-width
-       and such changes. DONE!
+       and such changes.
 
      - Extensions support:
           * Xinerama

File icons/README

       * "};" must be on its own line at the end of file.
 
       * ' ' must be used for None color.
-      
-      * Do not use ',' character to denote color.
-
-      * No trailing spaces in any line.
 
 
     Recommended, but not required:

File icons/mini-display.xpm

Old
Old image
New
New image

File icons/mini-graph.xpm

Old
Old image
New
New image

File icons/mini-xv.xpm

Old
Old image
New
New image

File lisp/xwem-clgen.el

-;;; xwem-clgen.el --- Generic model to manage clients.
-
-;; Copyright (C) 2004 by Free Software Foundation, Inc.
-
-;; Author: Zajcev Evgeny <zevlg@yandex.ru>
-;;         Steve Youngs  <steve@youngs.au.com>
-;; Created: Sat Aug 28 14:31:39 MSD 2004
-;; Keywords: xwem
-;; X-CVS: $Id$
-
-;; This file is part of XWEM.
-
-;; XWEM is free software; you can redistribute it and/or modify it
-;; under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
-
-;; XWEM is distributed in the hope that it will be useful, but WITHOUT
-;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
-;; License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with XEmacs; see the file COPYING.  If not, write to the Free
-;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-;; 02111-1307, USA.
-
-;;; Synched up with: Not in FSF
-
-;;; Commentary:
-
-;; Generic managing model.
-
-;;; Code:
-
-(require 'xwem-load)
-(require 'xwem-manage)
-
-;;; Customisation
-(defgroup xwem-clgen nil
-  "Group to customise management of generic clients."
-  :prefix "xwem-clgen-"
-  :group 'xwem-modes)
-
-(defcustom xwem-clgen-other-strategy 'samewin
-  "*Strategy used when searching for other client in window.
-Possible values are:
-  
-  `samewin'   - Search for client managed in window.
-
-  `sameframe-nonactive' - Search for nonactive client managed
-                          in window's frame.
-
-  `sameframe-any'       - Search for any client managed in window's
-                          frame.
-
-  `samemanda-nonactive' - Search for any nonactive client with same
-                          manage entry as other client.
-
-  `any-nonactive'       - Search for any nonactive client."
-  :type '(choice (const :tag "Same Window" samewin)
-                 (const :tag "Inactive in same frame" sameframe-nonactive)
-                 (const :tag "Any in same frame" sameframe-any)
-                 (const :tag "Inactive with same manda" samemanda-nonactive)
-                 (const :tag "Any inactive" any-nonactive))
-  :group 'xwem-clgen)
-
-(defcustom xwem-clgen-other-on-split t
-  "*Non-nil mean activate client in other window when doing window split."
-  :type 'boolean
-  :group 'xwem-clgen)
-
-(defcustom xwem-clgen-other-split-type 'vertical
-  "*Split type."
-  :type '(choice (const :tag "Vertical" vertical)
-                 (const :tag "Horizontal" horizontal))
-  :group 'xwem-clgen)
-
-(defcustom xwem-clgen-activate-new t
-  "*Non-nil mean newly managed generic clients are activated in their windows."
-  :type 'boolean
-  :group 'xwem-clgen)
-
-(defcustom xwem-clgen-select-new t
-  "*Non-nil mean, select new clients managed in selected window.
-This value overrides `xwem-clgen-activate-new' if window is selected."
-  :type 'boolean
-  :group 'xwem-clgen)
-
-(defcustom xwem-clgen-allow-make-frame t
-  "*Non-nil mean, clgen permited to make frame if there no frame where client can be managed."
-  :type 'boolean
-  :group 'xwem-clgen)
-
-;;; Internal variables
-
-;;;###autoload
-(defvar xwem-clgen-map 
-  (let ((map (make-sparse-keymap)))
-    (define-key map (kbd "H-c H-o") 'xwem-clgen-toggle-other-on-split)
-    map)
-  "Local keymap for generic clients.")
-
-;;; Macros
-(defmacro xwem-cl-xparent (cl)
-  `(xwem-cl-get-sys-prop ,cl 'parent-xwin))
-(defsetf xwem-cl-xparent (cl) (parent)
-  `(xwem-cl-put-sys-prop ,cl 'parent-xwin ,parent))
-
-(defun xwem-clgen-other-client (cl &optional clients-list visible)
-  "Search client other then CL in CLIENTS-LIST.
-Default CLIENTS-LIST is win's clients where CL managed.
-Note that at least one CL or CLIENTS-LIST should be non-nil, otherwise
-nil will be returned."
-  (when (or (and (xwem-cl-p cl) (xwem-win-p (xwem-cl-win cl)))
-            clients-list)
-    ;; XXX 
-    (unless clients-list
-      (setq clients-list (xwem-win-clients (xwem-cl-win cl))))
-      
-    ;; XXX sort clients by recency
-    (setq clients-list
-          (xwem-cl-list-sort-by-recency clients-list))
-
-    (let (rcl notgoodcl)
-      (while clients-list
-        (when (not (eq (car clients-list) cl)) ; skip ourself
-          (if (and (not (xwem-dummy-client-p (car clients-list))) ; exclude dummy clients
-                   (or visible (not (xwem-win-cl-current-p (car clients-list)))))
-              (progn
-                (setq rcl (car clients-list))
-                (setq clients-list nil))
-
-            (when (and visible (null notgoodcl))
-              (setq notgoodcl (car clients-list)))))
-        (setq clients-list (cdr clients-list)))
-    
-      (or rcl notgoodcl))))
-
-(define-xwem-deffered xwem-clgen-activate-other (cl win)
-  "Activate other client in WIN.
-Clients list is either WIN's clients list or CL's win clients list if
-WIN's clients list is empty."
-  (when (and (xwem-win-alive-p win)
-             (not (xwem-cl-alive-p (xwem-win-cl win))))
-    ;; WIN is valid and no clients yet managed in WIN
-    (let ((ocl (xwem-clgen-other-client cl (xwem-win-clients win)))
-          (need-select (or (and (xwem-cl-selected-p cl)
-                                (not (xwem-cl-active-p cl)))
-                           (xwem-cl-selected-p (xwem-dummy-client)))))
-      (when (xwem-cl-alive-p ocl)
-        (xwem-win-set-cl win ocl)
-        (when (and (xwem-win-selected-p win) need-select)
-          (xwem-select-client ocl)))
-
-      ;; If OCL wasnt selected, try last or other client
-      (when (and (xwem-win-selected-p win)
-                 (not (xwem-cl-selected-p ocl))
-                 need-select)
-        (setq ocl (xwem-clgen-other-client
-                   cl (xwem-frame-clients (xwem-win-frame win)) t))
-        (if (xwem-cl-alive-p ocl)
-            (xwem-select-client ocl)
-          (xwem-select-some-client))))))
-  
-(defun xwem-clgen-other-on-split (sp-win nwin)
-  "NWIN has been created as a result of split.
-Probably we want to manage some client in newly created window."
-  (xwem-clgen-activate-other (xwem-cl-selected) nwin))
-
-;;; Othen-on-Split commands
-
-;;;###autoload(autoload 'xwem-clgen-turn-on-other-on-split "xwem-clgen" "" t)
-(define-xwem-command xwem-clgen-turn-on-other-on-split ()
-  "Turn on `xwem-clgen-other-on-split' minor mode."
-  (xwem-interactive)
-
-  (setq xwem-clgen-other-on-split t)
-  (add-hook 'xwem-win-split-hook 'xwem-clgen-other-on-split)
-
-  (xwem-message 'info "Other on split minor mode is ON."))
-
-;;;###autoload(autoload 'xwem-clgen-turn-off-other-on-split "xwem-clgen" "" t)
-(define-xwem-command xwem-clgen-turn-off-other-on-split ()
-  "Turn off `xwem-clgen-other-on-split' minor mode."
-  (xwem-interactive)
-
-  (setq xwem-clgen-other-on-split nil)
-  (remove-hook 'xwem-win-split-hook 'xwem-clgen-other-on-split)
-
-  (xwem-message 'info "Other on split minor mode is OFF."))
-
-;;;###autoload(autoload 'xwem-clgen-toggle-other-on-split "xwem-clgen" "" t)
-(define-xwem-command xwem-clgen-toggle-other-on-split (arg)
-  "Toggle `xwem-clgen-other-on-split' minor mode.
-Negative ARG turns it off, positive turns it on."
-  (xwem-interactive "P")
-
-  (if (numberp arg)
-      (if (> arg 0)
-	  (setq xwem-clgen-other-on-split nil)
-	(setq xwem-clgen-other-on-split t)))
-
-  (if xwem-clgen-other-on-split
-      (xwem-clgen-turn-off-other-on-split)
-    (xwem-clgen-turn-on-other-on-split)))
-
-;;; Initialisation stuff
-(defun xwem-clgen-init ()
-  "Initialise clgen stuff."
-  (xwem-message 'init "Initializing generic clients ...")
-
-  (add-hook 'xwem-win-split-hook 'xwem-clgen-other-on-split)
-
-  (xwem-message 'init "Initializing generic clients ... done"))
-
-;;;; ---- Generic methods ----
-(define-xwem-client-property expect-win generic
-  "Expectance window."
-  :type 'window
-  :get 'xwem-cl-get-sys-prop
-  :set 'xwem-cl-put-sys-prop)
-
-;;;###autoload
-(defun xwem-manage-generic (cl)
-  "Manage method for generic clients."
-
-  ;; Put this to notify `xwem-manage' that we will handle initial
-  ;; state.
-  (xwem-client-set-property cl 'skip-initial-state t)
-
-  (let ((dwin (and (xwem-cl-was-expected-p cl)
-                   (xwem-client-property cl 'expect-win))))
-    (if dwin
-        (xwem-client-set-property cl 'expect-win nil)
-      (if (xwem-frame-alive-p (xwem-frame-selected))
-          (setq dwin (xwem-win-selected))
-        (when xwem-clgen-allow-make-frame
-          ;; Selected window is kinda dead
-          (xwem-frame-fit-screen (xwem-make-frame-1 'desktop))
-          (setq dwin (xwem-win-selected)))))
-
-    (unless (xwem-win-alive-p dwin)
-      (error 'xwem-error "Can't manage in dead window"))
-
-    ;; Create parent window.
-    ;; NOTE:
-    ;;   Some applications, such as mozilla, when running with
-    ;;   -remote tries to find another mozilla instance to run
-    ;;   in it, it seaches lowerest client, but it is not
-    ;;   guarantied, because xwem frame holds many clients.
-    (unless (xwem-cl-xparent cl)
-      (setf (xwem-cl-xparent cl)
-            (XCreateWindow (xwem-dpy) nil 0 0 1 1 0 nil nil nil
-                           (make-X-Attr :override-redirect t :event-mask 0.0))))
-
-    ;; Set CL's window
-    (xwem-cl-set-win cl dwin)
-
-    ;; Install local keymap
-    (xwem-use-local-map xwem-clgen-map cl)
-
-    ;; Select newly managed client, if needed
-    (if (eql (xwem-cl-get-init-state cl) X-IconicState)
-        (xwem-iconify cl)
-
-      (when xwem-clgen-activate-new
-        (xwem-win-set-cl (xwem-cl-win cl) cl))
-      (when (and xwem-clgen-select-new
-                 (xwem-win-selected-p dwin))
-        (xwem-win-set-cl (xwem-cl-win cl) cl)
-        (xwem-select-client cl)))
-    ))
-
-(defun xwem-clgen-refit (cl)
-  "Refit generic client CL."
-  (let* ((xwem-win (xwem-cl-win cl))
-         (hthi (xwem-win-border-width xwem-win)))
-    (when (and (xwem-cl-new-xgeom cl)
-               (X-Geom-border-width (xwem-cl-new-xgeom cl)))
-      ;; Border width changed
-      (setf (X-Geom-border-width (xwem-cl-xgeom cl))
-            (X-Geom-border-width (xwem-cl-new-xgeom cl))))
-
-    (xwem-cl-correct-size-for-size cl
-       (make-X-Geom :x (+ (xwem-win-x xwem-win) hthi)
-                    :y (+ (xwem-win-y xwem-win) hthi)
-                    :width (- (xwem-win-width xwem-win) (* 2 hthi))
-                    :height (- (xwem-win-height xwem-win) (* 2 hthi))
-                    :border-width (X-Geom-border-width (xwem-cl-xgeom cl))))))
-  
-(defun xwem-refit-generic (cl)
-  "Refit method for generic client CL.
-Correct CL geometry to fit into CL's window."
-  (xwem-clgen-refit cl)
-  (xwem-cl-apply-xgeom cl))
-
-(define-xwem-deffered xwem-clgen-apply-state (cl)
-  "Apply CL's state to life for generic client CL."
-  (when (and (xwem-cl-p cl)
-             (eq (xwem-cl-manage-type cl) 'generic))
-    (cond ((eq (xwem-cl-state cl) 'active)
-           (xwem-clgen-refit cl)
-           (when (xwem-cl-frame cl)
-             (XReparentWindow (xwem-dpy) (xwem-cl-xwin cl)
-                              (xwem-frame-xwin (xwem-cl-frame cl))
-                              (X-Geom-x (xwem-cl-xgeom cl))
-                              (X-Geom-y (xwem-cl-xgeom cl))))
-           (xwem-cl-apply-xgeom-1 cl)
-           (XLowerWindow (xwem-dpy) (xwem-cl-xwin cl))
-           (XMapWindow (xwem-dpy) (xwem-cl-xwin cl)))
-
-          ((eq (xwem-cl-state cl) 'inactive)
-           (XReparentWindow (xwem-dpy) (xwem-cl-xwin cl) (xwem-cl-xparent cl) 0 0)
-           (XLowerWindow (xwem-dpy) (xwem-cl-xwin cl))
-           (XUnmapWindow (xwem-dpy) (xwem-cl-xwin cl)))
-
-          ((eq (xwem-cl-state cl) 'iconified)
-           (XReparentWindow (xwem-dpy) (xwem-cl-xwin cl) (xwem-cl-xparent cl) 0 0)
-           (XLowerWindow (xwem-dpy) (xwem-cl-xwin cl))
-           (XUnmapWindow (xwem-dpy) (xwem-cl-xwin cl))))
-    ))
-
-(defun xwem-activate-generic (cl &optional type)
-  "Activate method for CL."
-  (cond ((eq type 'select)
-         (xwem-select-window (xwem-cl-win cl)))
-
-        ((eq type 'activate)
-         (cond ((xwem-win-cl-current-p cl)
-                (xwem-clgen-apply-state cl))
-
-               ((xwem-win-alive-p (xwem-cl-win cl))
-                (xwem-client-change-state cl 'inactive)
-                (xwem-win-set-cl (xwem-cl-win cl) cl))))))
-
-(defun xwem-deactivate-generic (cl &optional type)
-  "Deactivate method for generic client CL."
-  (cond ((eq type 'deactivate)
-         (xwem-clgen-activate-other cl (xwem-cl-win cl))
-         (xwem-clgen-apply-state cl))))
-
-(defun xwem-iconify-generic (cl)
-  "Iconify method for generic client CL."
-  (xwem-win-rem-cl (xwem-cl-win cl) cl))
-
-(defun xwem-withdraw-generic (cl)
-  "Withdraw method for generic client CL."
-  (let* ((xwin (xwem-cl-xwin cl))
-         (tpnt (car (XTranslateCoordinates
-                     (xwem-dpy) xwin (xwem-rootwin)
-                     (X-Geom-x (xwem-cl-xgeom cl))
-                     (X-Geom-y (xwem-cl-xgeom cl)))))
-         (win (xwem-cl-win cl)))
-
-    (when tpnt
-      ;; We must unmap CL's window according to ICCCM.
-      (XReparentWindow (xwem-dpy) xwin (xwem-rootwin)
-                       (X-Point-x tpnt) (X-Point-y tpnt)))
-
-    (when win
-      (xwem-win-rem-cl win cl)
-      (xwem-cl-set-win cl nil)
-
-      ;; Activate other client in CL's window WIN
-      ;; NOTE: Deffered
-      (xwem-clgen-activate-other nil win))))
-
-;;; Additional methods
-(define-xwem-method on-type-change generic (cl &optional new)
-  "Called when CL is about to change manda from generic."
-  (xwem-cl-set-win cl nil))
-
-(define-xwem-method on-kill generic (cl)
-  "Called when CL is killed."
-  (let ((win (xwem-cl-win cl)))
-    ;; Destroy parent window
-    (XDestroyWindow (xwem-dpy) (xwem-cl-xparent cl))
-
-    ;; Activate other client in WIN
-    (xwem-clgen-activate-other cl win)
-
-    ;; Remove CL from WIN's clients list
-    (when (xwem-win-alive-p win)
-      (xwem-win-rem-cl win cl))
-    ))
-
-(define-xwem-method other-client generic (cl)
-  "Method to return xwem generic client other then CL."
-  (xwem-clgen-other-client cl))
-
-
-(provide 'xwem-clgen)
-
-;;;; On-load actions:
-;; Register generic manage type.  Use APPEND because 'generic manage
-;; type is most non-privileged and matches any client.
-(define-xwem-manage-model generic
-  "Generic manage model.
-Manage clients that no-one elso wants to manage."
-  :match-spec '(eval t)
-  :append t
-
-  :manage-method 'xwem-manage-generic
-  :activate-method 'xwem-activate-generic
-  :deactivate-method 'xwem-deactivate-generic
-  :refit-method 'xwem-refit-generic
-  :iconify-method 'xwem-iconify-generic
-  :withdraw-method 'xwem-withdraw-generic)
-
-(if xwem-started
-    (xwem-clgen-init)
-  (add-hook 'xwem-before-init-wins-hook 'xwem-clgen-init))
-
-;;; xwem-clgen.el ends here

File lisp/xwem-clients.el

 ;; Copyright (C) 2003 by Free Software Foundation, Inc.
 
 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
-;;         Steve Youngs  <steve@youngs.au.com>
-;;         Richard Klinda <ignotus@hixsplit.hu>
 ;; Created: 2 Mar 2003
 ;; Keywords: xlib, xwem
 ;; X-CVS: $Id$
 ;;
 ;; Client state(`xwem-cl-state') is one of:
 ;; 
-;;   'active    - Client managed and activated.
+;;   'managed - Client has `xwem-cl-win' and in WIN's clients list, but
+;;              not current in WIN.
 ;;   
-;;   'inactive  - CL managed, but not viewable.
+;;   'managed-current - As 'managed, but CL aslo current in WIN.
 ;;   
-;;   'iconified - CL iconified, not viewable.
+;;   'demanaged - CL may have valid `xwem-cl-win', but not in WIN's
+;;                clients list and not current in any window.
+;;   
+;;   'iconified - Same as 'demanaged
 ;;   
 ;;   'destroyed - CL's x window destroyed.
 ;;   
 ;;   `xwem-cl-state-change-hook' - Called when CL changes state to one
 ;;                                 described above.
 ;; 
-;;   `xwem-cl-manage-hook' - Called when CL just managed.
-;; 
-;;   `xwem-cl-activate-hook' - Called when CL is activated in its context.
+;;   `xwem-cl-manage-hook' - Called when CL just managed in some
+;;                           window.
 ;;
-;;   `xwem-cl-deactivate-hook' - Called when CL is deactivated in its context.
-;; 
-;;   `xwem-cl-withdraw-hook' - Called when CL is about to move to withdrawn state.
+;;   `xwem-cl-demanage-hook' - Called when CL just demanaged from some
+;;                             window.
 ;;
-
-;; 
-;; Supported client properties:
-;; 
-;;   `noselect'  - Non-nil to make client non-selectable.
-
+;;   `xwem-cl-mark-hook' - Called when CL marked or unmarked.
 
 ;;; Code:
 
 (eval-when-compile
   ;; Shutup compiler
-  (autoload 'subtract-time "time-date")
-  (defvar xwem-frame-ev-mask)
+  (require 'xlib-xwin)
+  (require 'xwem-macros)
+  (require 'iswitchb)
   )
-
-(require 'xwem-load)
-(require 'xwem-manage)
-(require 'xwem-misc)
+(require 'xwem-frame)
 
 ;;; Variables
 (defgroup xwem-cl nil
   :prefix "xwem-cl-"
   :group 'xwem)
 
-(defgroup xwem-modes nil
-  "Group to customize XWEM managing modes."
-  :prefix "xwem-"
-  :group 'xwem)
-
 (defcustom xwem-cl-use-parent-xwin t
   "*Non-nil mean that CL will use some X window, where it(CL) lowered.
-This is need to fullish some X applications, which accuire clients in
-such evil manner."
+This is need to fullish some X applications, which accuire clients in such evil manner."
   :type 'boolean
   :group 'xwem-cl)
 
-(defcustom xwem-cl-noname-name "<noname>"
-  "*Name for clients which does not have name."
-  :type 'string
-  :group 'xwem-cl)
-
-(defcustom xwem-cl-noicon-name "<noname>"
-  "*Icon name for clients which does not have their own."
-  :type 'string
-  :group 'xwem-cl)
-
 (defcustom xwem-cl-other-strategy 'samewin
   "*Strategy to be used to select other CL.
 One of 'any 'samewin 'sameframe.
 		 (const :tag "Any" any))
   :group 'xwem-cl)
 
-(defcustom xwem-frame-iresize-mode 'normal
-  "*Default type of drawing outlines when resizing frame interactively.
-It is not recommeded to use 'opaque resize mode."
-  :type '(choice (const :tag "Normal border" normal)
-                 (const :tag "Contiguous borders" contiguous)
-                 (const :tag "Outline Corners" corners)
-                 (const :tag "Grid" grid)
-                 (const :tag "Opaque" opaque)
-                 )
-  :group 'xwem-frame)
-
-(defcustom xwem-frame-imove-mode 'normal
-  "*Default type of drawing outlines when moving frame interactively."
-  :type '(choice (const :tag "Normal border" normal)
-                 (const :tag "Contiguous border" contiguous)
-                 (const :tag "Outline Corners" corners)
-                 (const :tag "Grid" grid)
-                 (const :tag "Opaque" opaque)
-                 )
-  :group 'xwem-frame)
-
-(defcustom xwem-imove-visible t
-  "*Non-nil mean `xwem-client-imove' will info you about new position."
+(defcustom xwem-cl-other-on-split t
+  "Non-nil mean manage other client when split occurs in new window.
+Minor mode."
   :type 'boolean
   :group 'xwem-cl)
 
-(defcustom xwem-iresize-visible t
-  "*Non-nil mean `xwem-client-iresize' will info you about new size."
+(defcustom xwem-cl-use-set-focus t
+  "*Non-nil mean that managed clients takes focus.
+NOTE: installs hook into `xwem-cl-manage-hook'."
   :type 'boolean
   :group 'xwem-cl)
 
-(define-xwem-face x-border-face
-  `(((selected) (:foreground "green"))
-    (t (:foreground "gray80")))
-  "Face for client's X border."
-  :group 'xwem-cl
-  :group 'xwem-faces)
-
-;;;###xwem-autoload
-(defcustom xwem-client-focusing 'advanced
-  "Clients focusing type.
-One of:
-
-  'advanced -  Any client can be selected, even if it has broken focus model.
-  'standard -  Strictly follow ICCCM, hoping everything will be ok.
-
-You should change default value only in very rare circumstances.  You
-should fully understand how focusing works in xwem to change default
-value."
-  :type '(choice (const :tag "Advanced" advanced)
-                 (const :tag "Standard" standard))
-  :group 'xwem-cl)
-
-;;;###autoload
-(defcustom xwem-client-default-properties
-  '(x-border-width 2)
-  "*Default properties for newly managed clients."
-  :type 'list
-  :group 'xwem-cl)
-
-(defcustom xwem-client-selected-border-color "green"
-  "*Border color when client is selected."
-  :type 'color
-  :group 'xwem-cl)
-
-(defcustom xwem-client-nonselected-border-color "gray"
-  "*Border color when client is not selected."
-  :type 'color
+(defcustom xwem-cl-use-recent-cl-on-top nil
+  "*Non-nil mean that most recent client is on top in `xwem-clients' list."
+  :type 'boolean
   :group 'xwem-cl)
 
 (defcustom xwem-cl-mark-ring-max 16
   :type 'number
   :group 'xwem-cl)
 
-;;;###autoload
 (defcustom xwem-cl-create-hook nil
   "Hook to call when creating new client."
   :type 'hook
   :group 'xwem-cl)
 
-;;;###autoload
 (defcustom xwem-cl-destroy-hook nil
   "Hooks called with one argument - cl, when cl destroyed.
 NOT USED YET."
   :type 'hook
   :group 'xwem-hooks)
 
-;;;###autoload
-(defcustom xwem-cl-activate-hook nil
+(defcustom xwem-cl-manage-hook nil
   "*Hooks to be called with just setuped CL as argument."
   :type 'hook
   :group 'xwem-hooks)
 
-;;;###autoload
-(defcustom xwem-cl-deactivate-hook nil
+(defcustom xwem-cl-demanage-hook nil
   "*Hooks to be called with just desetuped CL as argument."
   :type 'hook
   :group 'xwem-hooks)
 
-;;;###autoload
 (defcustom xwem-cl-refit-hook nil
   "Hooks called when CL just refited."
   :type 'hook
   :group 'xwem-hooks)
 
-;;;###autoload
 (defcustom xwem-cl-iconify-hook nil
   "Hooks called when CL just iconified."
   :type 'hook
   :group 'xwem-hooks)
 
-;;;###autoload
-(defcustom xwem-cl-withdraw-hook nil
-  "*Hooks to call when CL moved to withdrawn state."
-  :type 'hook
-  :group 'xwem-hooks)
-
-;;;###autoload
 (defcustom xwem-cl-change-hook nil
   "Hooks called when something changed in CL."
   :type 'hook
   :group 'xwem-hooks)
 
-;;;###autoload
 (defcustom xwem-cl-state-change-hook nil
   "*Hooks to run when state of client changes.
 Every hook called with three args - CL OLD-STATE NEW-STATE."
   :type 'hook
   :group 'xwem-hooks)
 
-;;;###autoload
-(defcustom xwem-client-select-hook nil
-  "*Hooks called when new client just selected.
-It is pretty guarantied that `xwem-selected-client' is valid xwem-cl
-structure at time of hook execution."
+(defcustom xwem-cl-mark-hook nil
+  "*Hooks to run when marking client.
+Hooks called with two args - CL STATE.
+Where STATE is one of 'mark or 'unmark."
+  :type 'hook
+  :group 'xwem-hooks)
+
+;;; CL property change hooks
+(defcustom xwem-cl-wmnh-change-hooks nil
+  "Hooks to be called when WM_NORMAL_HINTS changes."
+  :type 'hook
+  :group 'xwem-hooks)
+
+(defcustom xwem-cl-wmname-change-hooks nil
+  "Hooks to be called when WM_NAME changes."
+  :type 'hook
+  :group 'xwem-hooks)
+
+(defcustom xwem-cl-wmcommand-chage-hooks nil
+  "Hooks to be called when WM_COMMAND changes."
+  :type 'hook
+  :group 'xwem-hooks)
+
+(defcustom xwem-cl-wmclass-change-hooks nil
+  "Hooks to be called when WM_CLASS changes."
+  :type 'hook
+  :group 'xwem-hooks)
+
+(defcustom xwem-cl-wmh-change-hooks nil
+  "Hooks to be called when WM_HINTS changes."
   :type 'hook
   :group 'xwem-hooks)
 
 ;;;###autoload
-(defcustom xwem-client-deselect-hook nil
-  "Hooks called with one arg - cl, when cl deselected.
-It is pretty guarantied that `xwem-selected-client' is valid xwem-cl
-structure at time of hook execution."
-  :type 'hook
-  :group 'xwem-hooks)
-
-;;; Internal variables
-
-
-(defconst xwem-client-ev-mask
-  (Xmask-or XM-ColormapChange XM-PropertyChange
-            XM-FocusChange XM-EnterWindow XM-LeaveWindow
-            XM-StructureNotify XM-ResizeRedirect)
-  "Event mask for xwem's client.")
-
-;;;###xwem-autoload
-(defvar xwem-clients nil
-  "List of all managed clients.")
-
-;;;###xwem-autoload
-(defvar xwem-current-cl nil
-  "Internal variable.
-Use `xwem-cl-selected' to get selected client.")
-
-;;;###xwem-autoload
-(defvar xwem-last-cl nil
-  "Last selected client.
-Use `(xwem-last-client)' to get last selected client.")
+(defvar xwem-clients nil "Clients Windows list")
 
 ;;;###autoload
 (defvar xwem-cl-mark-ring nil
   "The list of marked clients.")
 
-;;;###xwem-autoload
-(defmacro xwem-cl-marked-p (cl)
-  "Return non-nil if client CL is marked, i.e. in `xwem-cl-mark-ring' list."
-  `(memq ,cl xwem-cl-mark-ring))
+;;;###autoload
+(defstruct xwem-hints
+  ;; TODO: add more
+  wm-normal-hints
+  wm-hints
+  wm-class
+  wm-command
+  wm-name
+  wm-transient-for
+  wm-protocols)
 
-;;; Client properties
-;;;###xwem-autoload
-(defvar xwem-supported-client-properties nil
-  "List of supported client's properties definitions.
-Property definition is list in form:
-\(NAME . (MANAGE-TYPE (KEYWORD VAL ...) ...)).
+(defconst xwem-client-ev-mask (Xmask-or XM-ColormapChange XM-PropertyChange
+					XM-FocusChange XM-EnterWindow XM-LeaveWindow
+					XM-StructureNotify XM-ResizeRedirect)
+  "Event mask for xwem's client.")
 
-Valid KEYWORD are:
+;;;###autoload
+(defstruct (xwem-cl (:predicate xwem-iscl-p))
+  xwin					; X-Win
+  saved-name				; saved WM_NAME
+  xgeom					; X-Geom etry for cl
+  xattrs				; X-Attr ibutes
+  
+  win					; xwem-win dow
+  hints					; xwem-hints
+  manda					; xwem-manda entry
+  transient-for				; non-nil if client is transient for window
+  (ev-mask xwem-client-ev-mask)		; event mask for certain client
 
-   `:type' - Same as for `defcustom'.  eval composite type added.
+  (state 'unknown)			; state of client, 'managed, 'iconified, 'unknown, etc
+  start-time				; start-time
+  recency				; last time when CL was active
+  translist				; list of transient-for windows for this client
 
-   `:set' - Function to call when setting this property. Default is
-            `xwem-cl-put-prop'.  Function called with three
-            arguments - CL PROP VAL.
-
-   `:get'  - Function to call in order to fetch property value. Default
-             is `xwem-cl-get-prop'. Function called with two
-             arguments - CL PROP.
-")
-
-;;;###xwem-autoload
-(defmacro define-xwem-client-property (name manage-type doc &rest keys-vals)
-  "Define new xwem client property NAME."
-  `(xwem-support-cl-property (quote ,name) (quote ,manage-type)
-                             (list :doc ,doc ,@keys-vals)))
-
-;;;###xwem-autoload
-(defun xwem-property-supported-p (prop)
-  "Return non-nil if client property PROP is supported."
-  (assq prop xwem-supported-client-properties))
-
-;;;###xwem-autoload
-(defun xwem-support-cl-property (prop-name manage-type keys-val)
-  "Add supported client property."
-  (let ((pdef (assq prop-name xwem-supported-client-properties)))
-    (unless pdef
-      (setq pdef (cons prop-name nil))
-      (setq xwem-supported-client-properties
-            (cons pdef xwem-supported-client-properties)))
-
-    (setcdr pdef (plist-put (cdr pdef) manage-type keys-val))))
-
-;;;###xwem-autoload
-(defun xwem-unsupport-cl-property (prop-name manage-type)
-  "Remove PROP-NAME from supported property for MANAGE-TYPE."
-  (let ((pdef (assq prop-name xwem-supported-client-properties)))
-    (when pdef
-      (setcdr pdef (plist-remprop (cdr pdef) manage-type))
-      (when (null (cdr pdef))
-        (setq xwem-supported-client-properties
-              (delq pdef xwem-supported-client-properties))))))
-
-(defun xwem-clprop-get-keyword (cl prop keyword &optional default)
-  "Return CL's property KEYWORD value.
-If no KEYWORD for such CL, return default KEYWORD value.
-Return DEFAULT if KEYWORD not found."
-  (let ((prop-def (assq prop xwem-supported-client-properties)))
-    (or (plist-get (plist-get (cdr prop-def) (xwem-cl-manage-type cl)) keyword)
-        (plist-get (plist-get (cdr prop-def) nil) keyword default))))
-  
-;;;###xwem-autoload
-(defun xwem-client-set-property (cl prop val)
-  "Set client property."
-  (funcall (xwem-clprop-get-keyword cl prop :set 'xwem-cl-put-prop)
-           cl prop val))
-
-;;;###xwem-autoload
-(defun xwem-client-property (cl prop)
-  "Return CL's property PROP."
-  (funcall (xwem-clprop-get-keyword cl prop :get 'xwem-cl-get-prop)
-           cl prop))
-
-(defun xwem-client-properties (cl)
-  "Return CL's properties list."
-  (let ((cplist (xwem-cl-plist cl))
-        (rplist nil))
-    (while cplist
-      (when (xwem-property-supported-p (car cplist))
-        (setq rplist (plist-put rplist (car cplist) (cadr cplist))))
-      (setq cplist (cddr cplist)))
-    rplist))
-
-(define-xwem-client-property x-border-width nil
-  "CL's xwin border width."
-  :type 'number
-  :set 'xwem-client-set-x-border-width)
-
-(define-xwem-client-property x-border-color nil
-  "CL's xwin border color."
-  :type 'color
-  :set 'xwem-client-set-x-border-color)
-
-(define-xwem-client-property noselect nil
-  "Non-nil mean CL can't be selected."
-  :type 'boolean)
-
-(define-xwem-client-property skip-deselect nil
-  "CL skips deselecting."
-  :type 'boolean)
-
-(define-xwem-client-property override-skip-deselect nil
-  "CL overrides skip-deselect property of selected client."
-  :type 'boolean)
-
-(define-xwem-client-property skip-initial-state nil
-  "Non-nil mean skip CL's initial state hint."
-  :type 'boolean)
+  plist					; user defined plist
+  )
 
 
 ;;; Functions
-(defun xwem-client-set-x-border-width (cl bprop width)
-  "Change CL's border with to WIDTH.
-Default WIDTH is 0."
-  (xwem-cl-put-prop cl bprop width) ; save it in props
+;;;###autoload
+(defun xwem-cl-p (cl &optional sig)
+  "Returns t if CL is XWEM client window."
+  (let ((iscl (xwem-iscl-p cl)))
+    (if (and (not iscl) sig)
+	(signal 'wrong-type-argument (list sig 'xwem-cl-p cl))
+      iscl)))
 
-  (unless (numberp width)
-    (setq width 0))                     ; XXX
+;;;###autoload
+(defun xwem-cl-marked-p (cl)
+  "Return non-nil if client CL is marked, i.e. in `xwem-cl-mark-ring' list."
+  (member cl xwem-cl-mark-ring))
 
-  (setf (xwem-cl-new-xgeom cl) (make-X-Geom :border-width width))
-  (xwem-refit cl))
+;;;###autoload
+(defun xwem-cl-destroyed-p (cl)
+  "Return non-nil if CL has already destroyed xwin."
+  (eq (xwem-cl-state cl) 'destroyed))
 
-(defun xwem-client-set-x-border-color (cl bprop col)
-  "Change CL's border color to COL."
-  (xwem-cl-put-prop cl bprop col) ; save it in props
+(defsubst xwem-cl-put-prop (cl prop val)
+  "In CL's property list put property PROP with value VAL."
+  (setf (xwem-cl-plist cl) (plist-put (xwem-cl-plist cl) prop val)))
+(put 'xwem-cl-put-prop 'lisp-indent-function 2)
 
-  (unless col
-    (setq col "black"))                 ; XXX
+(defsubst xwem-cl-get-prop (cl prop)
+  "From CL's property list get property PROP."
+  (plist-get (xwem-cl-plist cl) prop))
 
-  (XSetWindowBorder (xwem-dpy) (xwem-cl-xwin cl)
-                    (XAllocColor (xwem-dpy) (XDefaultColormap (xwem-dpy))
-                                 (xwem-make-color col))))
+(defsubst xwem-cl-rem-prop (cl prop)
+  "From CL's property list remove property PROP."
+  (setf (xwem-cl-plist cl) (plist-remprop (xwem-cl-plist cl) prop)))
 
-(defun xwem-cl-focus-selected ()
-  "If CL is selected, set focus on it.
-Used in `xwem-post-deffering-hook'."
-  (xwem-focus-set (xwem-cl-selected)))
-
-;;;###xwem-autoload
-(defun xwem-cl-select (cl)
-  "Set CL to be current cl."
-  (xwem-client-local-variables-import (xwem-cl-selected))
-
-  ;; Set CL to be current client
-  (setf (xwem-last-client) (xwem-cl-selected))
-  (setf (xwem-cl-selected) cl)
-
-  (xwem-client-local-variables-export cl))
-
-(define-xwem-client-property ignore-has-input-p nil
-  "Ignore No Input/Globally Active input model and force focusing."
-  :type 'boolean)
-
-(defun xwem-cl-can-be-selected-p (cl)
-  "Return non-nil if CL can be selected.
-If `xwem-client-focusing' is not 'advanced `xwem-cl-can-be-selected-p'
-can return nil in situations where you expecting t.  When changing
-default value of `xwem-client-focusing' be sure your xwem configured
-properly to handle applications with broken focus models."
-  (and (not (xwem-client-property cl 'noselect))
-       (or (xwem-client-property cl 'ignore-has-input-p)
-           (eq xwem-client-focusing 'advanced)
-           (X-WMHints-input-p (xwem-hints-wm-hints (xwem-cl-hints cl)))
-           (XWMProtocol-set-p (xwem-dpy)
-                              (xwem-hints-wm-protocols (xwem-cl-hints cl))
-                              "WM_TAKE_FOCUS"))))
-
-(define-xwem-deffered xwem-cl-apply-x-border-color (cl)
-  "Apply CL's x border color to life."
-  (when (xwem-cl-managed-p cl)
-    (XSetWindowBorder (xwem-dpy) (xwem-cl-xwin cl)
-                      (X-Gc-foreground (xwem-face-get-gc 'x-border-face
-                                         (and (xwem-cl-selected-p cl) '(selected))
-                                         cl)))))
-
-(defun xwem-client-default-select-hook ()
-  "Default hook to be added to `xwem-client-select-hook'."
-  (xwem-cl-apply-x-border-color (xwem-cl-selected)))
-
-(defun xwem-client-default-deselect-hook ()
-  "Default hook to be added to `xwem-client-deselect-hook'."
-  (xwem-cl-apply-x-border-color (xwem-cl-selected)))
-
-;;;###xwem-autoload
-(defun xwem-select-client (cl)
-  "Select new client CL.
-CL will not be selected if currently selected client has property
-`skip-deselect', unless CL has property `override-skip-deselect'.
-If CL is not selected because of above condition, last client is
-updated however.
-If CL is non-client, dummy client will be selected."
-  (unless (xwem-cl-p cl)
-    (setq cl (xwem-dummy-client)))
-
-  ;; Update CL's recency
-  (setf (xwem-cl-recency cl) (current-time))
-
-  ;; Skip clients that can't be selected
-  (when (xwem-cl-can-be-selected-p cl)
-    (cond ((and (not (xwem-cl-selected-p cl))
-                (xwem-cl-active-p (xwem-cl-selected))
-                (xwem-client-property (xwem-cl-selected) 'skip-deselect)
-                (not (xwem-client-property cl 'override-skip-deselect)))
-           ;; If client has such property it mean that no other client
-           ;; can be selected untill CL will unset this property.
-           ;; Good example of using it is xwem minibuffer.  When it is
-           ;; active, no other clients can be selected.
-           (setf (xwem-last-client) cl))
-
-          (t
-           (unless (xwem-cl-selected-p cl)
-             (xwem-deactivate (xwem-cl-selected) 'deselect)
-             (run-hooks 'xwem-client-deselect-hook)
-             (xwem-cl-select cl)
-             (run-hooks 'xwem-client-select-hook))
-       
-           (xwem-activate cl 'select)
-           (xwem-add-hook-post-deffering 'xwem-cl-focus-selected)))
-    ))
-
-(defmacro xwem-with-current-client (cl &rest forms)
-  "Make CL to be current and exectute FORMS.
-After execution restore current client."
-  `(let ((xwem-saved-current-client (xwem-cl-selected))
-         (xwem-saved-last-client (xwem-cl-selected)))
-     (xwem-cl-select ,cl)
-     (prog1
-         (progn ,@forms)
-       (xwem-cl-select xwem-saved-current-client)
-       (setf (xwem-last-client) xwem-saved-last-client))))
-
-;;;###xwem-autoload
+;;;###autoload
 (defun xwem-client-name (cl &optional clist)
   "Returns unique name for CL.
 If CLIST is ommited, `xwem-clients' will be used.
 	  (format "%s<%d>" cln cnt)
 	cln))))
 
-;;;###xwem-autoload
+;;;###autoload
 (defun xwem-find-client (win-or-id)
   "Find WIN-OR-ID in client windows list.
 WIN-OR-ID can be X-Win or id of window."
 	(setq cl (cdr cl))))
     rc))
 
+;;;###autoload
 (defun xwem-remove-client (cl)
   "Delete WIN from clients list."
   (setq xwem-clients (delete cl xwem-clients)))
 NOT USED"
   )
 
-;;;###xwem-autoload(autoload 'xwem-cl-send-config "xwem-clients")
-(define-xwem-deffered xwem-cl-send-config (cl)
+;;;###autoload
+(defun xwem-cl-send-config (cl)
   "Send config info to window."
+  (xwem-cl-p cl 'xwem-cl-send-config)
+
   (let ((clgeom (xwem-cl-xgeom cl))
 	(win (xwem-cl-xwin cl)))
+
     (XSendEvent (xwem-dpy) win nil XM-StructureNotify
 		(X-Create-message
 		 (list [1 X-ConfigureNotify] ;type
     ))
 
 
-;;;###xwem-autoload
-(defun xwem-clients-list (&optional predict include-dummy states)
-  "Return xwem clients list.
+;; cl predicates
+;;;###autoload
+(defun xwem-cl-alive-p (cl)
+  "Return non-nil if CL is alive i.e. in `xwem-clients' list."
+  (memq cl xwem-clients))
 
-PREDICT is function passed with one argument - CL and must return
-non-nil if CL must be included in resulting list.  If PREDICT not
-specified - all clients are included.
+;;;###autoload
+(defun xwem-cl-exclude-p (cl)
+  "Return non-nil if CL should be excluded from clients list."
+  (and (xwem-cl-manda cl) (xwem-manda-exclude-p (xwem-cl-manda cl))))
 
-If INCLUDE-DUMMY is non-nil also include dummy clients(clients for
-which `xwem-dummy-client-p' returns non-nil).
+
+;;;###autoload
+(defun xwem-cl-normal-list (clients &optional predic)
+  "Return list of normal clients.
+CLIENTS is list of xwem clients frome which we should exclude.
+If PREDIC given it will be called on each client and should return nil to exclude client."
+  (let ((cls nil))
+    (while clients
+      (when (and (not (xwem-cl-exclude-p (car clients)))
+		 (if predic (funcall predic (car clients)) t))
+	(setq cls (nconc cls (list (car clients)))))
+      (setq clients (cdr clients)))
+    cls))
 
-STATES is a list of valid states for client or 'any."
-  (delq nil
-        (mapcar (lambda (cl)
-                  (and (or (eq states 'any)
-                           (xwem-cl-managed-p cl states))
-                       (or include-dummy (not (xwem-dummy-client-p cl)))
-                       (or (not predict) (funcall predict cl))
-                       cl))
-                xwem-clients)))
-
-;;;###xwem-autoload
-(defun xwem-cl-list-sort-by-recency (cl-list)
-  "Sort clients in CL-LIST by their recency."
-  (sort (copy-list cl-list)
-        (lambda (cl1 cl2)
-          (let ((rc1 (xwem-cl-recency cl1))
-                (rc2 (xwem-cl-recency cl2)))
-
-            (if (or (not rc1) (not rc2))
-                (not (null rc1))
-		    
-              (cond ((> (nth 0 rc1) (nth 0 rc2))
-                     t)
-                    ((< (nth 0 rc1) (nth 0 rc2))
-                     nil)
-                    (t (cond ((> (nth 1 rc1) (nth 1 rc2))
-                              t)
-                             ((< (nth 1 rc1) (nth 1 rc2))
-                              nil)
-                             (t (cond ((> (nth 2 rc1) (nth 2 rc2))
-                                       t)
-                                      ((< (nth 2 rc1) (nth 2 rc2))
-                                       nil)
-                                      (t t)))))))))))
-
-;;;###xwem-autoload
-(defun xwem-cl-other (cl &optional clients-list also-active no-sort)
-  "Return xwem client other then CL selecting from CLIENTS-LIST.
-Default CLIENTS-LIST is what is returned by `xwem-clients-list'.
-Deactivated clients are preferred to activated, unless ALSO-ACTIVE
+(defun xwem-cl-other (cl &optional visible)
+  "Return other xwem's client from list of clients where is CL.
+Clients not visible in window are preferred to visible, unless VISIBLE
 is non-nil. Special clients excluded.
 
-Use `(xwem-cl-other cl nil t)' form to fetch most recent
-client, other then CL.
+If CL is not actually xwem client, nil returned."
+  (if (xwem-cl-p cl)
+      (let ((cll (cond ((eq xwem-cl-other-strategy 'any) xwem-clients)
 
-CLIENTS-LIST is sorted by recency unless NO-SORT is non-nil."
-  (unless clients-list
-    (setq clients-list (xwem-clients-list)))
+		       ((eq xwem-cl-other-strategy 'samewin)
+			(xwem-win-make-cl-list-sort-by-recency (xwem-cl-win cl)))
 
-  (unless no-sort
-    (setq clients-list
-          (xwem-cl-list-sort-by-recency clients-list)))
+		       ((eq xwem-cl-other-strategy 'sameframe)
+			(xwem-frame-make-cl-list (xwem-cl-frame cl)))
 
-  (let ((rcl nil)
-        (notgoodcl nil))		;not so good candidate as rcl
+		       (t xwem-clients)))
+	    (rcl nil)
+	    (notgoodcl nil))		;not so good candidate as rcl
 
-    (while clients-list
-      (when (and (xwem-cl-p (car clients-list)) ; skip non-clients
-                 (not (eq (car clients-list) cl))) ; skip ourself
-        (if (or also-active (not (eq (xwem-cl-state (car clients-list)) 'active)))
-            ;; Found pretty good candidate
-            (setq rcl (car clients-list)
-                  clients-list nil)
+	(while cll
+	  (when (not (eq (car cll) cl))	;skip ourself
+	    (if (and (not (xwem-cl-exclude-p (car cll)))
+		     (or visible (not (xwem-win-cl-current-p (car cll)))))
+		(progn
+		  (setq rcl (car cll))
+		  (setq cll nil))
 
-          (when (and also-active (null notgoodcl))
-            (setq notgoodcl (car clients-list)))))
-      (setq clients-list (cdr clients-list)))
+	      (when (and visible (null notgoodcl))
+		(setq notgoodcl (car cll)))))
+	  (setq cll (cdr cll)))
     
-    ;; Return
-    (or rcl notgoodcl)))
+	(or rcl notgoodcl))
 
-;;;###xwem-autoload
-(defun xwem-select-some-client ()
-  (unless (and (xwem-cl-alive-p (xwem-cl-selected))
-               (eq (xwem-cl-state (xwem-cl-selected)) 'active))
-    (xwem-select-client nil)))
+    ;; [else] invalid CL
+    nil))
 
-;;;###xwem-autoload
-(defun xwem-select-last-or-other-client (cl &optional force allow-dummy)
-  "Select last or other client according to CL.
-New client selected only if CL is current selected or FORCE is non-nil
-or dummy client currently selected.
-
-`xwem-select-last-or-other-client' tries to avoid selecting dummy
-clients, unless ALLOW-DUMMY is non-nil."
-  (when (or force
-            (xwem-cl-selected-p cl)
-            (xwem-cl-selected-p (xwem-dummy-client)))
-    (if (and (xwem-cl-alive-p (xwem-last-client))
-             (not (eq (xwem-last-client) cl))
-             (or allow-dummy
-                 (not (xwem-dummy-client-p (xwem-last-client)))))
-        (xwem-select-client (xwem-last-client))
-      (xwem-select-client (xwem-cl-other cl nil t)))))
+(defun xwem-cl-bury (cl)
+  "Put CL to the and of clients list.
+Maybe used in `xwem-cl-manage-hook' or `xwem-cl-demanage-hook'."
+  (setq xwem-clients
+	(nconc (delete cl xwem-clients) (list cl)))
+  nil)					; continue hooks processing
 
 
-;;;###xwem-autoload
+;;; Manda functions begin
+;;;###autoload
 (defun xwem-cl-correct-size-for-size (cl new-geom &optional x-type y-type)
   "Make CL's geometry as close to NEW-GEOM as possible.
 X-TYPE is one of 'center 'left or 'right, default is 'center.
 Y-TYPE is one of 'center 'top or 'bottom, default is 'center."
-  (let* ((hthi (or (X-Geom-border-width new-geom) 0))
-         (he (X-Geom-height new-geom))
-         (wi (X-Geom-width new-geom))
+  (let* ((hthi (X-Geom-border-width new-geom))
 	 (clgmt (xwem-cl-xgeom cl))
-         (wmnh (xwem-hints-wm-normal-hints (xwem-cl-hints cl)))
 	 (wi-rmd 0)
 	 (he-rmd 0)
-	 bw bh wi-st he-st)
+	 wmnh bw bh wi-st he-st wi he)
+
+    (setq he (- (X-Geom-height new-geom) (* 2 hthi)))
+    (setq wi (- (X-Geom-width new-geom) (* 2 hthi)))
+
+    (setq wmnh (xwem-hints-wm-normal-hints (xwem-cl-hints cl)))
 
     (when wmnh
-      (setq bw (X-WMSize-base-width wmnh))
-      (setq bh (X-WMSize-base-height wmnh))
+      (setq bw (X-WMSize-width wmnh))
+      (setq bh (X-WMSize-height wmnh))
 
       (when (X-WMSize-presizeinc-p wmnh)
-	(setq wi-st (X-WMSize-width-inc wmnh)) ; width step
-	(setq he-st (X-WMSize-height-inc wmnh))) ; height step
+	(setq wi-st (X-WMSize-width-inc wmnh)) ;width step
+	(setq he-st (X-WMSize-height-inc wmnh)) ;height step
+	)
 
       ;; - Calculate size reminders
       ;; - Adjust wi-rmd and he-rmd if needed
       (when wi-st
-	(setq wi-rmd (% (abs (- wi bw (* 2 hthi))) wi-st))
+	(setq wi-rmd (% (abs (- wi bw)) wi-st))
 	(when (> bw wi)
 	  (setq wi-rmd (- wi-st wi-rmd))))
 
       (when he-st
-	(setq he-rmd (% (abs (- he bh (* 2 hthi))) he-st))
+	(setq he-rmd (% (abs (- he bh)) he-st))
 	(when (> bh he)
 	  (setq he-rmd (- he-st he-rmd)))))
 
     (cond ((eq x-type 'left)
 	   (setf (X-Geom-x clgmt) (X-Geom-x new-geom)))
 	  ((eq x-type 'right)
-	   (setf (X-Geom-x clgmt) (+ (X-Geom-x new-geom) wi-rmd)))
+	   (setf (X-Geom-x clgmt) (+ (X-Geom-x new-geom) hthi wi-rmd)))
 	  (t				; 'center or any other
-	   (setf (X-Geom-x clgmt) (+ (X-Geom-x new-geom) (/ wi-rmd 2)))))
+	   (setf (X-Geom-x clgmt) (+ (X-Geom-x new-geom) hthi (/ wi-rmd 2)))))
     (cond ((eq y-type 'top)
 	   (setf (X-Geom-y clgmt) (X-Geom-y new-geom)))
 	  ((eq y-type 'bottom)
-	   (setf (X-Geom-y clgmt) (+ (X-Geom-y new-geom) he-rmd)))
+	   (setf (X-Geom-y clgmt) (+ (X-Geom-y new-geom) hthi he-rmd)))
 	  (t
-	   (setf (X-Geom-y clgmt) (+ (X-Geom-y new-geom) (/ he-rmd 2)))))
+	   (setf (X-Geom-y clgmt) (+ (X-Geom-y new-geom) hthi (/ he-rmd 2)))))
+    (setf (X-Geom-width clgmt) (- wi wi-rmd))
+    (setf (X-Geom-height clgmt) (- he he-rmd))))
 
-    (setf (X-Geom-width clgmt) (- wi (* 2 hthi) wi-rmd))
-    (setf (X-Geom-height clgmt) (- he (* 2 hthi) he-rmd))))
+(defun xwem-cl-correct-size (cl)
+  "Corect CL's xgeom according to WM_NORMAL_HINTS and other stuff."
+  (let ((wmnh (xwem-hints-wm-normal-hints (xwem-cl-hints cl)))
+	(clgeom (xwem-cl-xgeom cl)))
+    (when (xwem-cl-transient-for cl)
+      ;; Program specified size
+      (when (X-WMSize-ussize-p wmnh)
+	(setf (X-Geom-width clgeom) (X-WMSize-width wmnh))
+	(setf (X-Geom-height clgeom) (X-WMSize-height wmnh)))
+
+      ;; Program specified position
+      (when (X-WMSize-uspos-p wmnh)
+	(setf (X-Geom-x clgeom) (X-WMSize-x wmnh))
+	(setf (X-Geom-y clgeom) (X-WMSize-y wmnh)))
+      )))
+
+(defun xwem-cl-domanage (cl &optional sfwin)
+  "Real manage job."
+  (let* ((old-win (xwem-cl-win cl))
+         (new-win (or sfwin (xwem-win-selected)))
+         (old-cl (and (xwem-win-p new-win) (xwem-win-cl new-win))))
+    ;; When there no xwem window to manage CL, just demanage it
+    (if (not (xwem-win-p new-win))
+        (xwem-manda-demanage cl)
+
+      (if (xwem-win-cl-current-p cl new-win)
+          ;; CL already in NEW-WIN - only refiting needed
+          (xwem-manda-refit cl)
+
+        ;; When client moves from frame to other frame, state should
+        ;; be unknown.  [Hmm, why]?
+;        (when (not (eq (xwem-cl-frame cl)
+;                       (xwem-win-frame new-win)))
+;          (xwem-client-change-state cl 'unknown))
+
+        ;; First of all demanage client CL
+        (when (and (xwem-win-p old-win)
+                   (not (eq old-win new-win)))
+          (xwem-manda-demanage cl))
+
+        (setf (xwem-win-cl new-win) cl)
+        (setf (xwem-cl-win cl) new-win)
+        (xwem-manda-refit cl t)
+        (xwem-client-show cl 'managed-current)
+        
+        ;; Hide OLD-CL
+        (when (xwem-cl-p old-cl)
+          (xwem-client-hide old-cl 'managed))
+        ))
+
+    ;; Update recency field
+    (setf (xwem-cl-recency cl) (current-time))
+
+    ;; Finally run hooks
+    (run-hook-with-args 'xwem-cl-manage-hook cl)
+    ))
+  
+(defun xwem-cl-manage (cl &optional sfwin)
+  "Setup CL to be used in SFWIN.
+If SFWIWN is ommited `xwem-win-selected' will be used.
+TODO: Handle special clients in different way."
+  (xwem-cl-p cl 'xwem-cl-manage)
+  (when sfwin
+    (xwem-win-p sfwin 'xwem-cl-manage))
+
+  (if (not (xwem-misc-xwin-valid-p (xwem-cl-xwin cl)))
+      ;; CL suddenly died
+      (xwem-cl-hdestroy-notify cl nil)
+        
+    (xwem-cl-domanage cl sfwin))
+  )
+
+(defun xwem-cl-demanage (cl &optional state)
+  "Desetup CL from xwem win.
+Used when deleting window or frame.
+When CLEAR is non-nil then xwem window client for CL will be setted to nil."
+  (if (eq state 'destroyed)
+      (setf (xwem-cl-state cl) 'destroyed)
+    (xwem-client-hide cl (or state 'demanaged)))
+
+  ;; If demanaged CL is current in it's window try to manage other
+  ;; client.
+  (let ((owin (xwem-cl-win cl))
+        ocl)
+    (when (xwem-win-cl-current-p cl)
+      (setf (xwem-win-cl owin) nil)
+      (when (xwem-cl-p (setq ocl (xwem-cl-other cl)))
+        (xwem-manda-manage ocl owin))))
+
+  ;; Now run on-demanage hooks
+  (run-hook-with-args 'xwem-cl-demanage-hook cl)
+  )
+
+(defun xwem-cl-refit (cl &optional need-reparent)
+  "Refit CL in its window frame.
+If NEED-REPARENT is non-nil than also reparent it to some frame."
+  (xwem-win-p (xwem-cl-win cl) 'xwem-cl-refit)
+
+  (let* ((frame (xwem-cl-frame cl))
+	 (xwem-win (xwem-cl-win cl))
+	 (swwidth (xwem-face-tag 'xwem-face-frame-selected-win-selected :line-width))
+	 (nwwidth (xwem-face-tag 'xwem-face-frame-selected-win-nonselected :line-width))
+	 (hthi (max (if (numberp swwidth) swwidth 0)
+		    (if (numberp nwwidth) nwwidth 0)))
+	 (clgmt (xwem-cl-xgeom cl))
+	 (wi-rmd 0)
+	 (he-rmd 0)
+	 wmnh bw bh wi-st he-st wi he)
+
+    (setq he (- (xwem-win-height xwem-win) (* 2 hthi)))
+    (setq wi (- (xwem-win-width xwem-win) (* 2 hthi)))
+
+    (setq wmnh (xwem-hints-wm-normal-hints (xwem-cl-hints cl)))
+    (X-Dpy-log (xwem-dpy) "Get wmnh = %S\n" 'wmnh)
+    (when wmnh
+      (setq bw (X-WMSize-width wmnh))
+      (setq bh (X-WMSize-height wmnh))
+
+      (when (X-WMSize-presizeinc-p wmnh)
+	(setq wi-st (X-WMSize-width-inc wmnh)) ;width step
+	(setq he-st (X-WMSize-height-inc wmnh)) ;height step
+	)
+
+      ;; - Calculate size reminders
+      ;; - Adjust wi-rmd and he-rmd if needed
+      (when wi-st
+	(setq wi-rmd (% (abs (- wi bw)) wi-st))
+	(when (> bw wi)
+	  (setq wi-rmd (- wi-st wi-rmd))))
+
+      (when he-st
+	(setq he-rmd (% (abs (- he bh)) he-st))
+	(when (> bh he)
+	  (setq he-rmd (- he-st he-rmd)))))
+
+    (unless (X-Geom-p clgmt)
+      (setf (xwem-cl-xgeom cl) (make-X-Geom))
+      (setq clgmt (xwem-cl-xgeom cl)))
+
+    (setf (X-Geom-x clgmt) (+ (xwem-win-x xwem-win) hthi (/ wi-rmd 2)))
+    (setf (X-Geom-y clgmt) (+ (xwem-win-y xwem-win) hthi (/ he-rmd 2)))
+    (setf (X-Geom-width clgmt) (- wi wi-rmd))
+    (setf (X-Geom-height clgmt) (- he he-rmd))
+
+    (if need-reparent
+      (XReparentWindow (xwem-dpy) (xwem-cl-xwin cl) 
+		       (xwem-frame-xwin frame)
+		       (X-Geom-x clgmt) (X-Geom-y clgmt))
+
+      (XMoveWindow (xwem-dpy) (xwem-cl-xwin cl) (X-Geom-x clgmt) (X-Geom-y clgmt)))
+
+    (X-Dpy-log (xwem-dpy) "Get size: wi=%d,%d he=%d,%d\n" 'wi '(X-Geom-width clgmt) 'he '(X-Geom-height clgmt))
+    (XResizeWindow (xwem-dpy) (xwem-cl-xwin cl)
+		   (X-Geom-width clgmt) (X-Geom-height clgmt))
+
+    (xwem-cl-send-config cl)
+  ))
+
+;; I think special CLs should be handled in very different way then
+;; normals. It is the one of things TODO.
+;;
+(defun xwem-cl-iconify (cl)
+  "Iconify CL. Used to handle Iconify ClientMessage from special CL."
+  (xwem-manda-demanage cl 'iconified)
+  )
 
 ;;;###autoload(autoload 'xwem-client-iconify "xwem-clients" "" t)
 (define-xwem-command xwem-client-iconify (cl)
   "Iconifies selected client."
   (xwem-interactive (list (xwem-cl-selected)))
 
-  (unless (xwem-cl-alive-p cl)
-    (error 'xwem-error "Invalid client"))
+  (if (xwem-cl-p cl)
+      (xwem-cl-iconify cl)
 
-  (xwem-iconify cl))
+    (xwem-message 'warn "No client in selected window.")))
 
-;;;###autoload(autoload 'xwem-switch-client "xwem-clients" "" t)
-(define-xwem-command xwem-switch-client (arg)
-  "Interactively switch to client.
-When used with prefix ARG, then filter to clients of same managing
-model as selected client."
+;;; Manda functions ends here
+
+(defun xwem-cl-query-cl (prompt &optional predic)
+  "Query for CL, using XWEM's minibuffer.
+PREDIC is function, wich passed with cl as argument and must return
+non-nil to make cl be in listing."
+  (xwem-under-minib-focus
+   (let* ((rcl nil)
+	  (clsnl (xwem-cl-normal-list xwem-clients predic))
+	  (clns (mapcar
+		 (lambda (cl)
+		   (cons (xwem-client-name cl clsnl) cl))
+		 clsnl))
+	  (name (flet ((iswitchb-make-buflist
+			(default)
+			(setq iswitchb-buflist (mapcar (lambda (cl) (car cl)) clns))))
+		  (iswitchb-read-buffer prompt))))
+
+     (while clns
+       (when (string= (caar clns) name)
+	 (setq rcl (cdar clns))
+	 (setq clns nil))
+       (setq clns (cdr clns)))
+     rcl)))
+
+;;;###autoload(autoload 'xwem-cl-switch "xwem-clients" "" t)
+(define-xwem-command xwem-cl-switch (arg)
+  "Interactively switch to some client window, using 'iswitchb.
+When used with prefix ARG, then filter clients to selected widow only."
   (xwem-interactive "P")
 
   (let* ((pred (when arg
-                 (let ((mt (and (xwem-cl-p (xwem-cl-selected))
-                                (xwem-cl-manage-type (xwem-cl-selected)))))
-                   `(lambda (cl)
-                      (eq (xwem-cl-manage-type cl) (quote ,mt))))))
-         (clients (xwem-cl-list-sort-by-recency
-                   (xwem-clients-list pred arg)))
-         (cl (xwem-read-client (if arg (format "XWEM-CL (%S): "
-                                               (and (xwem-cl-p (xwem-cl-selected))
-                                                    (xwem-cl-manage-type (xwem-cl-selected))))
-                                 "XWEM-CL: ") clients)))
-
-    (unless (xwem-cl-alive-p cl)
-      (error 'xwem-error "Invalid client"))
-
-    (xwem-select-client cl)))
-
-;;;###autoload(autoload 'xwem-switch-other-client "xwem-clients" "" t)
-(define-xwem-command xwem-switch-other-client (arg)
-  "Switch to client other then selected.
-This command differs from `xwem-cl-switch-to-other' command,
-'other-client' method is not examined, but most recent client is
-selected, so pressing `\\<xwem-global-map>\\[xwem-switch-other-client]'
-twice will select selected client, what is not guarantied by
-`xwem-cl-switch-to-other'."
-  (xwem-interactive "p")
-
-  (let ((ocl (xwem-cl-selected)))
-    (while (> arg 0)
-      (setq ocl (xwem-cl-other ocl nil t))
-      (decf arg))
-    
-    (unless (xwem-cl-p ocl)
-      (error 'xwem-error "Invalid other client"))
-
-    (xwem-select-client ocl)))
-
-;;;###autoload(autoload 'xwem-attach-client "xwem-clients" "" t)
-(define-xwem-command xwem-attach-client (arg)
-  "Attach client to current window.
-When used with prefix ARG, select also clients that are already in
-current window."
-  (xwem-interactive "P")
-
-  (let* ((pred (lambda (cl)
-                 (and (xwem-manage-property (xwem-cl-manage-type cl) 'win-support)
-                      (or arg
-                          (eq (xwem-cl-win cl) (xwem-win-selected))))))
-         (cl (xwem-read-client (if arg "XWEM-CL any: " "XWEM-CL: ")
-                               (xwem-cl-list-sort-by-recency
-                                (xwem-clients-list pred)))))
-
-    (unless (xwem-cl-alive-p cl)
-      (error 'xwem-error "Invalid client"))
-
-    (xwem-win-set-cl (xwem-win-selected) cl)
-    (xwem-select-client cl)))
+		 (lambda (cl)
+		   (eq (xwem-cl-win cl) (xwem-win-selected)))))
+	 (cl (xwem-read-client (if arg "XWEM-CL win: "
+				 "XWEM-CL: ")
+			       pred)))
+    (when cl
+      (xwem-manda-manage cl))
+  ))
 
 ;;;###autoload(autoload 'xwem-cl-switch-other-win "xwem-clients" "" t)
 (define-xwem-command xwem-cl-switch-other-win (cl &optional arg)
   "Switch to CL in other window.
-When used with prefix ARG, then focus to that other window."
+When used with prefix ARG, then focuse to that other window."
   (xwem-interactive "cXWEM-CL Other: \nP")
 
-  (let (nwin)
-    (when (xwem-win-only-one-p (xwem-win-selected))
-      (xwem-window-split-vertically nil)) ; XXX
-    (setq nwin (xwem-win-next (xwem-win-selected)))
+  (let ((wn (xwem-win-next (xwem-win-selected)))
+	(xwem-cl-manage-hook nil))	; skip setup hooks
 
-    (xwem-win-set-cl nwin cl)
-    (when arg
-      (xwem-select-window nwin))))
+    (when cl
+      (when (xwem-win-only-one-p (xwem-win-selected))
+	(xwem-frame-split-vert nil)
+	(setq wn (xwem-win-next (xwem-win-selected))))
+
+      (when wn
+	(xwem-manda-manage cl wn)
+
+	(when arg
+	  (xwem-window-select wn)))
+      )))
 
 ;;;###autoload(autoload 'xwem-cl-switch-other-frame "xwem-clients" "" t)
 (define-xwem-command xwem-cl-switch-other-frame (cl &optional arg)
   "Switch to CL in other XWEM frame.
 When used with prefix ARG, then create embedded frame, if creation is
 needed at all."
-  (xwem-interactive
-   (list (xwem-read-client
-          "XWEM-CL Other frame: "
-          (xwem-cl-list-sort-by-recency
-           (xwem-clients-list
-            (lambda (cl)
-              (xwem-manage-property (xwem-cl-manage-type cl) 'win-support)))))
-         xwem-prefix-arg))
+  (xwem-interactive "cXWEM-CL Other frame: \nP")
 
   (let ((ofr (or (xwem-frame-other (xwem-frame-selected))
-		 (xwem-make-frame-1 (or (and arg 'embedded) 'desktop)
-                                    :noselect t))))
+		 (xwem-make-frame-1 arg nil nil t))))
 
-    (xwem-cl-change-window cl (xwem-frame-selwin ofr))
-    (xwem-select-client cl)))
+    (xwem-manda-manage cl (xwem-frame-selwin ofr))
+    (xwem-frame-select ofr))
+  )
 
 ;;;###autoload(autoload 'xwem-cl-switch-to-other "xwem-clients" "" t)
-(define-xwem-command xwem-cl-switch-to-other (cl &optional n)
-  "Switch to xwem client other then CL.
-Default CL is selected client.
-If prefix argument N is specified, switch to N's other client."
-  (xwem-interactive (list (xwem-cl-selected)