Commits

Anonymous committed ed83c00 Merge

fixup commit for tag 'xwem-1_08'

Comments (0)

Files changed (41)

-2004-09-16  Norbert Koch  <viteno@xemacs.org>
-
-	* Makefile (VERSION): XEmacs package 1.18 released.
-
-2004-09-15  Steve Youngs  <steve@youngs.au.com>
-
-	* lisp/xwem-clients.el (xwem-client-info): Typo fix. car -> cdr.
-
-2004-09-15  Norbert Koch  <viteno@xemacs.org>
-
-	* Makefile (VERSION): XEmacs package 1.17 released.
-
-2004-09-15  Steve Youngs  <steve@youngs.au.com>
-
-	* lisp/xwem-icons.el (xwem-icons-cl-icon): Remove redundant `if' in
-	previous patch.
-
-2004-09-15  Norbert Koch  <viteno@xemacs.org>
-
-	* Makefile (VERSION): XEmacs package 1.16 released.
-
-2004-09-15  Steve Youngs  <steve@youngs.au.com>
-
-	* lisp/xwem-icons.el (xwem-icons-cl-icon): Allow for a user set
-	icon path.
-
-2004-09-13  Norbert Koch  <viteno@xemacs.org>
-
-	* Makefile (VERSION): XEmacs package 1.15 released.
-
-	* lisp/xwem-interactive.el (read-from-minibuffer-for-xwem): Fix
-	build, add missing closing paren.
-
-2004-09-13  Steve Youngs  <steve@youngs.au.com>
-
-	* lisp/xwem-interactive.el: Use `symbol-function' in the defalias
-	for `read-from-minibuffer-for-xwem'.
-	This fixes a "exceeds max-specpdl-size" error when doing things
-	like `H-x b', `H-!' etc.
-
-2004-09-13  Steve Youngs  <steve@youngs.au.com>
-
-	* xwem-clients.el: Don't autoload `subtract-time' from time-date
-	at compile time as it isn't needed anymore.
-	(xwem-cl-get-uptime-1): New.
-	(xwem-cl-get-uptime): Use it.
-	This fixes a bug that meant a client's uptime couldn't be measured
-	beyond 65535 seconds.
-
-	The fix was inspired by code
-	From Sebastian Freundt <freundt@math.tu-berlin.de>
-
-2004-07-14  Norbert Koch  <viteno@xemacs.org>
-
-	* Makefile (VERSION): XEmacs package 1.14 released.
-
-2004-07-14  Steve Youngs  <steve@youngs.au.com>
-
-	* lisp/xwem-weather.el: New file.
-
-2004-07-13  Jerry James  <james@xemacs.org>
-
-	* lisp/xwem-clients.el:
-	* lisp/xwem-compat.el:
-	* lisp/xwem-frame.el:
-	* lisp/xwem-framei.el:
-	* lisp/xwem-holer.el:
-	* lisp/xwem-interactive.el:
-	* lisp/xwem-keyboard.el:
-	* lisp/xwem-keydefs.el:
-	* lisp/xwem-keymacro.el:
-	* lisp/xwem-launcher.el:
-	* lisp/xwem-main.el:
-	* lisp/xwem-minibuffer.el:
-	* lisp/xwem-misc.el:
-	* lisp/xwem-root.el:
-	* lisp/xwem-rooter.el:
-	* lisp/xwem-smartmods.el:
-	* lisp/xwem-strokes.el:
-	* lisp/xwem-tabbing.el:
-	* lisp/xwem-tray.el:
-	* lisp/xwem-win.el:
-	* lisp/xwem-worklog.el: Remove many autoloads, replacing them with
-	require forms.  Fix a few typos.
-
-2004-05-19  Norbert Koch  <viteno@xemacs.org>
-
-	* Makefile (VERSION): XEmacs package 1.13 released.
-
-2004-05-15  Steve Youngs  <steve@youngs.au.com>
-
-	* lisp/xwem-keyboard.el (xwem-kbd-quote-command): Removed
-	temporarily because it is broken and if used will cause xwem to
-	hang. 
-
-	* lisp/xwem-keydefs.el: Comment out binding for `H-q' which is
-	currently broken.
-
-	* lisp/xwem-worklog.el (xwem-worklog-auto-continue): Typo fix.
-	(xwem-worklog-end-task): Ditto.
-	(xwem-worklog-pause-task): Ditto.
-	(xwem-worklog-auto-worklog-file): Slightly massage the docstring.
-	Add a `:link' for worklog package's URL.
-
-	* Makefile (DONTCOMPILE): Add auto-autoloads.el and custom-load.el
-	so that they don't appear twice in the package tarball.
-
-2004-05-14  Norbert Koch  <viteno@xemacs.org>
-
-	* Makefile (VERSION): XEmacs package 1.12 released.
-
-2004-05-14  Steve Youngs  <steve@youngs.au.com>
-
-	* lisp/xwem-minibuffer.el (xwem-minibuffer-init): Turn off the
-	gutter in xwem-minibuffer.
-
-2004-05-14  Norbert Koch  <viteno@xemacs.org>
-
-	* Makefile (VERSION): XEmacs package 1.11 released.
-
-2004-05-14  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* lisp/xwem-worklog.el (xwem-worklog-auto-worklog-file): [fix]
-	Comment fix.
-
-	* lisp/xwem-main.el (xwem-init): [addon] Common configuration
-	added for joe public.
-
-	* lisp/xwem-keyboard.el (xwem-kbd-quote-command): [hmm] marked as
-	non-workable.
-
-2004-05-12  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* lisp/xwem-frame.el (xwem-frame-config-dump): [fix] Use
-	expand-file-name.
-	* lisp/xwem-frame.el (xwem-frame-config-restore): [fix] Ditto.
-
-	* lisp/xwem-worklog.el (misc): [fix] Ditto.
-
-2004-05-12  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* lisp/xwem-tray.el (xwem-tray-delimiter): [new] Delimiter stuff
-	added.
-
-	* lisp/xwem-sound.el (xwem-sound-do-visible-bell): [fix] Don't use
-	`X-Dpy-events-excursion'.
-
-	* lisp/xwem-misc.el (xwem-misc-make-screenshot): [fix] Use
-	absolute pathname to import screenshot to.
-
-	* lisp/xwem-launcher.el (xwem-launch-dock): [new] Dockapp to
-	launch clients.
-
-	* lisp/xwem-keydefs.el (xwem-global-map): [addon]
-	`xwem-frame-imove' at Sh-C-button1, `xwem-frame-iresize' on
-	Sh-C-button3.
-
-2004-05-11  Norbert Koch  <viteno@xemacs.org>
-
-	* Makefile (VERSION): XEmacs package 1.10 released.
-
-2004-05-12  Steve Youngs  <steve@youngs.au.com>
-
-	* lisp/xwem-keymacro.el (xwem-keymacro-save-macros): Use
-	`expand-file-name'.
-	(xwem-keymacro-load-macros): Ditto.
-
-	* lisp/xwem-strokes.el (xwem-strokes-save-strokes): Use
-	`expand-file-name' to define `strokes-file'.
-	(xwem-strokes-load-strokes): Ditto.
-
-	* lisp/xwem-main.el (xwem-dir): Change to custom type `directory'
-	and use `file-name-as-directory' to define the default.
-	(xwem-init): Simplify the `expand-file-name' call on xwemrc.el.
-
-2004-05-11  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* lisp/xwem-frame.el (xwem-frame-config-dump): [fix] Save only
-	builtin frame properties, because others can reference to
-	unrestorable objects.
-
-2004-05-11  Steve Youngs  <steve@youngs.au.com>
-
-	* lisp/xwem-interactive.el (xwem-read-from-minibuffer): Add
-	`notused' argument to prevent `wrong number of ags' errors
-
-2004-05-06  Norbert Koch  <viteno@xemacs.org>
-
-	* Makefile (VERSION): XEmacs package 1.09 released.
-
-2004-05-06  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* Makefile (AUTHOR_VERSION): 0.1 -> 0.2
-
-	* lisp/xwem-load.el: Removed at last.
-
-	* lisp/xwem-worklog.el (general): Autoloads added, fixes due to
-	new events processing scheme.
-
-	* lisp/xwem-win.el (general): Tabbing stuff totally
-	removed. autoloads added, various fixes and new custom variables
-	added, also too many changes to list.
-
-	* lisp/xwem-time.el (general): Fixes, using backing store X
-	feature.
-	* lisp/xwem-time.el (xwem-time): [fix] Exposure waiting removed.
-
-	* lisp/xwem-tabbing.el (general): Tabbing now totally independed,
-	using hooks mechanism to do the job, and fixes too many to list.
-	* lisp/xwem-tabbing.el (xwem-tabber-map): [new] Tabber keymap,
-	default bindings is <button1> and <button3>.
-
-	* lisp/xwem-strokes.el (general): Autoloads added.
-	* lisp/xwem-strokes.el (xwem-strokes-go): [fix] Use `xwem-next-event'.
-	* lisp/xwem-strokes.el (xwem-strokes-gc-function): [fix] typo.
-
-	* lisp/xwem-special.el (general): Autoloads added, fixes. Using
-	safe way when destroing special frame.
-
-	* lisp/xwem-rooter.el (xwem-rooter-auto-raised-regexp): [new] Not
-	yet implemented, sorry.  Pretty complicated task, but possible.
-	
-	* lisp/xwem-root.el (general): Tiny fixes.
-	* lisp/xwem-root.el (xwem-root-keymap): [addon]
-	xwem-popup-clients-menu on <button1> by default.
-
-	* lisp/xwem-register.el (general): Autoloads added.
-
-	* lisp/xwem-osd.el (general): Various tiny bug fixes, cleanup, etc.
-	* lisp/xwem-osd.el (xwem-osd-create): [addon] Properties
-	support. OSD can have its own keymap now.
-	* lisp/xwem-osd.el (xwem-osd-dots-add): [new] To plot dots set.
-	* lisp/xwem-osd.el (xwem-osd-create-dock): [new] Dockapp that uses
-	OSD primitives, i.e. dockappable osd.
-	* lisp/xwem-osd.el (xwem-osd-XXX-prop): [new] osd supports user
-	props.
-
-	* lisp/xwem-mouse.el (general): Autoloads added, little cleanup.
-	* lisp/xwem-mouse.el (xwem-popup-clients-menu): [new] Popup
-	clients menu.
-	* lisp/xwem-mouse.el (xwem-gen-cl-menu): [new] Generate popup menu
-	for CL.
-
-	* lisp/xwem-misc.el (general): Autoloads added, little cleanup,
-	few usefull functions added.
-	* lisp/xwem-misc.el (xwem-misc-draw-shadow): [fix] Optimization.
-	* lisp/xwem-misc.el (xwem-misc-outline): [new] Function to outline
-	some rectangle.
-
-	* lisp/xwem-minibuffer.el (general): Autoloads, new commented code
-	added, its usage is under argue.
-
-	* lisp/xwem-manage.el (general): Autoloads added, cleanup, few
-	usefull wrappers added.
-
-	* lisp/xwem-main.el (general): Autoloads added, little fixes.
-	* lisp/xwem-main.el (xwem-before-init-wins-hook): [new]
-	* lisp/xwem-main.el (xwem-after-init-wins-hook): [new]
-	More hookenization all over the place.
-
-	* lisp/xwem-macros.el (general): Autoloads added, little cleanup.
-
-	* lisp/xwem-launcher.el (general): Autoloads added.
-
-	* lisp/xwem-keymacro.el (general): Autoloads added, tiny fixes.
-
-	* lisp/xwem-keyboard.el (general): Autoloads added, minor fixes.
-	* lisp/xwem-keyboard.el (xwem-universal-key): [fix] `xwem-kbd'
-	usage eliminated.
-	* lisp/xwem-keyboard.el (xwem-kbd-evilmasks): [new] Mask
-	constructed from `xwem-kbd-evillocks'.
-	* lisp/xwem-keyboard.el (xwem-kbd-evillocks): [new] Locks that
-	totaly skipped when processing input events.
-	
-	* lisp/xwem-help.el (general): Autoloads added.
-
-	* lisp/xwem-framei.el (xwem-framei-dockapp-XX): [new] Dockapp
-	support to show current frame in system tray.
-	* lisp/xwem-framei.el (xwem-framei-stop): [new] Destroy frame
-	indicator.
-
-	* lisp/xwem-frame.el (xwem-frame-imove): [new] Interactively move
-	frame.
-	* lisp/xwem-frame.el (xwem-frame-iresize): [new] Interactively
-	resize frame.
-	* lisp/xwem-frame.el (general): Tabbing stuff totally removed.
-	Various fixes: embedded frame fixes, autoloads added.
-	* lisp/xwem-frame.el (xwem-frame-XXX-hook): [new] More hookenization.
-	* lisp/xwem-frame.el (xwem-frame-omit-init-frame): [new] Non-nil
-	mean do not create frames at start time.  Usefull if you want to
-	restore saved frame configuration from file at start time.
-	* lisp/xwem-frame.el (xwem-frame-autoiconify-mode): [new] Non-nil
-	mean autoiconify overlapping frames, when switching.
-	* lisp/xwem-frame.el (xwem-frame-iresize-mode): [new] Mode for
-	interactive frame resizing.
-	* lisp/xwem-frame.el (xwem-frame-imove-mode): [new] Mode for
-	interactive frame moving.
-	* lisp/xwem-frame.el (xwem-frame-imoveresize-mode-function): [new]
-	* lisp/xwem-frame.el (xwem-frame-imoveresize-mode-function-default): [new]
-
-2004-05-05  Zajcev Evgeny  <zevlg@yandex.ru>
-
-	* lisp/xwem-focus.el (general): Various minor fixes.
-	* lisp/xwem-focus.el (xwem-focus-set): [fix] Do not push by
-	default.
-
-	* lisp/xwem-faces.el (xwem-eface-to-gc): [fix] :graphics-exposures
-	default value X-False now.
-
-	* lisp/xwem-events.el (general): Various fixes.
-	* lisp/xwem-events.el (xwem-parse-message-guess): [new] Events
-	processing restructured, due to reentrance bug in xlib.  xwem now
-	has its own parse-message-guess function to store input events,
-	such ass keypress/buttonpress/buttonrelease/motion separately from
-	dpy's events queue.
-	
-	* lisp/xwem-edmacro.el (general): Autoloads added.
-
-	* lisp/xwem-diagram.el (general): Autoloads added.
-	* lisp/xwem-diagram.el (xwem-diag-draw-3d-sector): [fix] Bug fix,
-	incorrect sector filling.
-
-	* lisp/xwem-compat.el (gerenal): Autoloads added.
-	
-	* lisp/xwem-clients.el (general): Tabbing stuff totally removed.
-	Some minor modifications, more hookenization, etc.
-	
-	* lisp/xwem-clients.el (xwem-cl-create-hook): [new]
-	* lisp/xwem-clients.el (xwem-cl-destroy-hook): [new]
-	* lisp/xwem-clients.el (xwem-cl-refit-hook): [new]
-	* lisp/xwem-clients.el (xwem-cl-iconify-hook): [new]
-	* lisp/xwem-clients.el (xwem-cl-change-hook): [new]
-	
-	* lisp/xwem-clients.el (xwem-cl-use-parent-xwin): [new] Non-nil to
-	reparent client to temporary window when client hides, aka mozilla
-	workaround.
-	
-
 2004-03-29  Norbert Koch  <viteno@xemacs.org>
 
 	* Makefile (VERSION): XEmacs package 1.08 released.
 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-VERSION = 1.18
-AUTHOR_VERSION = 0.2
+VERSION = 1.08
+AUTHOR_VERSION = 0.1
 MAINTAINER = Zajcev Evgeny <zevlg@yandex.ru>
 PACKAGE = xwem
 PKG_TYPE = regular
 REQUIRES = xwem xemacs-base xlib strokes edit-utils text-modes time slider
 CATEGORY = standard
 
-DONTCOMPILE = lisp/_pkg.el lisp/auto-autoloads.el lisp/custom-load.el
-
+DONTCOMPILE = lisp/_pkg.el
+ 
 ELCS = $(patsubst %.el,%.elc,$(filter-out $(DONTCOMPILE),$(wildcard lisp/*.el)))
 
 DATA_FILES = $(wildcard icons/*.x[bp]m) logo.xpm

lisp/xwem-clients.el

 
 ;;; Commentary:
 ;;
-;; This file used for generic X clients management.
+;; This file used to manage X clients windows(move/resize/configure).
 ;;
-;; Client state(`xwem-cl-state') is one of:
-;; 
-;;   'managed - Client has `xwem-cl-win' and in WIN's clients list, but
-;;              not current in WIN.
-;;   
-;;   'managed-current - As 'managed, but CL aslo current in WIN.
-;;   
-;;   '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.
-;;   
-;;   'unknown   - Not any of above.
+;; Client window is vector in form:
+;; 	[XWEM-Client (win) (xwem-win) (mw-hints-list) (cfg)
+;; 	(graphical contexts) manda-element state (transients-list)]
+;;
+;; STATE is one of: 'managed 'demanaged or 'unknown
+;;
+;;; Code
 
-;; 
-;; Hooks are:
-;; 
-;;   `xwem-cl-create-hook' - Called when new CL just created.
-;;
-;;   `xwem-cl-destroy-hook' - Called when CL destroyed.
-;;
-;;   `xwem-cl-state-change-hook' - Called when CL changes state to one
-;;                                 described above.
-;; 
-;;   `xwem-cl-manage-hook' - Called when CL just managed in some
-;;                           window.
-;;
-;;   `xwem-cl-demanage-hook' - Called when CL just demanaged from some
-;;                             window.
-;;
-;;   `xwem-cl-mark-hook' - Called when CL marked or unmarked.
-
-;;; Code:
-
 (eval-when-compile
   ;; Shutup compiler
-  (require 'xlib-xwin)
   (require 'xwem-macros)
-  (require 'iswitchb)
+  (defvar iswitchb-buflist nil)
+  (autoload 'subtract-time "time-date")
+  (autoload 'iswitchb-read-buffer "iswitchb")
   )
-(require 'xwem-frame)
 
 ;;; Variables
 (defgroup xwem-cl nil
   :prefix "xwem-cl-"
   :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."
-  :type 'boolean
-  :group 'xwem-cl)
-
 (defcustom xwem-cl-other-strategy 'samewin
   "*Strategy to be used to select other CL.
 One of 'any 'samewin 'sameframe.
   :type 'boolean
   :group 'xwem-cl)
 
+(defcustom xwem-cl-new-client-hook nil
+  "Hook to call when managing new client."
+  :type 'hook
+  :group 'xwem-cl)
+
 (defcustom xwem-cl-mark-ring-max 16
   "*Maximum size of `xwem-cl-mark-ring'.
 Start discarding off end if gets this big."
   :type 'number
   :group 'xwem-cl)
 
-(defcustom xwem-cl-create-hook nil
-  "Hook to call when creating new client."
-  :type 'hook
-  :group 'xwem-cl)
-
-(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-manage-hook nil
   "*Hooks to be called with just setuped CL as argument."
   :type 'hook
   :group 'xwem-hooks)
 
+;;;###autoload
 (defcustom xwem-cl-demanage-hook nil
   "*Hooks to be called with just desetuped CL as argument."
   :type 'hook
   :group 'xwem-hooks)
 
-(defcustom xwem-cl-refit-hook nil
-  "Hooks called when CL just refited."
-  :type 'hook
-  :group 'xwem-hooks)
-
-(defcustom xwem-cl-iconify-hook nil
-  "Hooks called when CL just iconified."
-  :type 'hook
-  :group 'xwem-hooks)
-
-(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)
 
-(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
 (defvar xwem-clients nil "Clients Windows list")
 
   wm-transient-for
   wm-protocols)
 
-(defconst xwem-client-ev-mask (Xmask-or XM-ColormapChange XM-PropertyChange
-					XM-FocusChange XM-EnterWindow XM-LeaveWindow
-					XM-StructureNotify XM-ResizeRedirect)
+;;;###autoload
+(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.")
 
 ;;;###autoload
   recency				; last time when CL was active
   translist				; list of transient-for windows for this client
 
+  tabitem				; reference to tab item
   plist					; user defined plist
   )
 
   (member cl xwem-cl-mark-ring))
 
 ;;;###autoload
-(defun xwem-cl-destroyed-p (cl)
-  "Return non-nil if CL has already destroyed xwin."
-  (eq (xwem-cl-state cl) 'destroyed))
-
 (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)
 
+;;;###autoload
 (defsubst xwem-cl-get-prop (cl prop)
   "From CL's property list get property PROP."
   (plist-get (xwem-cl-plist cl) prop))
 
+;;;###autoload
 (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)))
 ;;;###autoload
 (defun xwem-remove-client (cl)
   "Delete WIN from clients list."
+;  (when (X-Win-p (xwem-cl-xwin cl))
+;    (X-Win-invalidate (xwem-cl-xwin cl)))
   (setq xwem-clients (delete cl xwem-clients)))
 
 (defun xwem-cl-do-gravity (cl step)
-  "Change CL's gravity.
-NOT USED"
+  "Gravity changing."
   )
 
 ;;;###autoload
 
 ;; cl predicates
 ;;;###autoload
+(defun xwem-cl-inwin-p (cl)
+  "Return non-nil if CL is currently displayed in some xwem's window."
+  (xwem-cl-p cl 'xwem-cl-inwin-p)
+  (and (xwem-win-p (xwem-cl-win cl))
+       (eq cl (xwem-win-cl (xwem-cl-win cl)))))
+
+;;;###autoload
 (defun xwem-cl-alive-p (cl)
   "Return non-nil if CL is alive i.e. in `xwem-clients' list."
   (memq cl xwem-clients))
 	(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)))))
+		     (or visible (not (xwem-cl-inwin-p (car cll)))))
 		(progn
 		  (setq rcl (car cll))
 		  (setq cll nil))
 	(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.
   (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))
-  )
+  (let ((old-win (xwem-cl-win cl))
+	(xwem-win (or sfwin (xwem-win-selected))))
+    ;; XXX -- should we check is window already setuped?
+    (if (eq (xwem-win-cl xwem-win) cl)
+	;; CL already in XWEM-WIN - only refiting needed
+	(xwem-manda-fun-run (xwem-cl-manda cl) 'refit cl)
 
-(defun xwem-cl-demanage (cl &optional state)
+      ;; else CL in some other window
+      (let ((old-cl (xwem-win-cl xwem-win)))
+	;; When client moves from frame to other frame, state should
+	;; be unknown
+	(when (not (eq (xwem-cl-frame cl)
+		       (xwem-win-frame xwem-win)))
+	  (xwem-client-change-state cl 'unknown))
+
+	;; First of all demanage client CL
+	(unless (eq old-win xwem-win)
+	  (let ((xwem-cl-demanage-hook nil))
+	    (xwem-manda-fun-run (xwem-cl-manda cl) 'demanage cl)))
+
+	(setf (xwem-cl-win cl) xwem-win)
+	(setf (xwem-win-cl (xwem-cl-win cl)) cl)
+	(xwem-manda-fun-run (xwem-cl-manda cl) 'refit cl t)
+
+	(xwem-client-show cl)
+
+	;; Demanage client which is currently in XWEM-WIN
+	(when (xwem-cl-p old-cl)
+	  (xwem-manda-fun-run (xwem-cl-manda old-cl) 'demanage old-cl))
+
+	;; Regeom tabbers if client moves from other window
+	(unless (eq old-win xwem-win)
+	  (when (xwem-win-p old-win)
+	    (xwem-tabber-regeom-window old-win (xwem-win-selected-p old-win (xwem-win-frame old-win))))
+	  (when (xwem-win-p xwem-win)
+	    (xwem-tabber-regeom-window xwem-win (xwem-win-selected-p xwem-win (xwem-win-frame xwem-win)))))
+      ))
+
+    ;; 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-demanage (cl &optional winclr clclr)
   "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)))
+  (xwem-client-hide cl 'managed)
 
-  ;; 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))))
+  (when (and winclr (xwem-cl-win cl))
+    (setf (xwem-win-cl (xwem-cl-win cl)) nil))
+  (when (and clclr (xwem-cl-p cl))
+    (setf (xwem-cl-win cl) nil))
 
-  ;; Now run on-demanage hooks
+  ;; Try to manage other xwem-client
+  (let* ((vis-p (xwem-cl-inwin-p cl))
+	 (old-win (if vis-p (xwem-cl-win cl) nil))
+	 (oth-cl (if vis-p (xwem-cl-other cl) nil)))
+
+    ;; Switch to other client in old CL's window
+    (when (xwem-win-p old-win)
+      (setf (xwem-win-cl old-win) nil)
+      (if (xwem-cl-p oth-cl)
+	  (xwem-manda-fun-run (xwem-cl-manda oth-cl) 'manage oth-cl old-win)
+	(setf (xwem-win-cl old-win) nil))
+    ))
+
+  ;; Now run hooks
   (run-hook-with-args 'xwem-cl-demanage-hook 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)
+(defun xwem-cl-iconify (cl &optional clear)
   "Iconify CL. Used to handle Iconify ClientMessage from special CL."
-  (xwem-manda-demanage cl 'iconified)
+  ;; XXX
+  (xwem-manda-fun-run (xwem-cl-manda cl) 'demanage cl clear)
+  (xwem-client-change-state 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)))
 
   (if (xwem-cl-p cl)
-      (xwem-cl-iconify cl)
+      (let ((win (xwem-cl-win cl)))
+	(xwem-cl-iconify cl nil)
+	(setf (xwem-cl-win cl) nil)
+	(xwem-tabber-regeom-window win (xwem-win-selected-p win (xwem-win-frame win))))
 
     (xwem-message 'warn "No client in selected window.")))
 
        (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-CL: ")
 			       pred)))
     (when cl
-      (xwem-manda-manage cl))
+      (xwem-manda-fun-run (xwem-cl-manda cl) '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 focuse to that other window."
 	(setq wn (xwem-win-next (xwem-win-selected))))
 
       (when wn
-	(xwem-manda-manage cl wn)
+	(xwem-manda-fun-run (xwem-cl-manda cl) '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
   (let ((ofr (or (xwem-frame-other (xwem-frame-selected))
 		 (xwem-make-frame-1 arg nil nil t))))
 
-    (xwem-manda-manage cl (xwem-frame-selwin ofr))
+    (xwem-manda-fun-run (xwem-cl-manda cl) '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 (n &optional window)
   "Switch to other client."
   (xwem-interactive "p")
       (setq ocl (xwem-cl-other ocl))
       (setq n (- n 1)))
     (if (xwem-cl-p ocl)
-	(xwem-manda-manage ocl win)
+	(xwem-manda-fun-run (xwem-cl-manda ocl) 'manage ocl win)
       (xwem-message 'note "No other client available."))))
 
-;;;###autoload(autoload 'xwem-cl-switch-to-other-in-other-win "xwem-clients" "" t)
 (define-xwem-command xwem-cl-switch-to-other-in-other-win (n)
   "Like `xwem-cl-switch-to-other', but in other window."
   (xwem-interactive "p")
 
   (xwem-cl-switch-to-other n (xwem-window-other 1)))
 	 
-;;;###autoload(autoload 'xwem-kill-cl-and-window "xwem-clients" "" t)
 (define-xwem-command xwem-kill-cl-and-window (arg)
   "Kill selected client and window.
 If used with prefix ARG then kill client in other window and other
     (xwem-frame-redraw (xwem-win-frame win))
   ))
 
-;;;###autoload(autoload 'xwem-cl-transpose "xwem-clients" "" t)
-(define-xwem-command xwem-cl-transpose (arg &optional cl)
-  "Transpose CL with client at right in CL's WIN.
+(define-xwem-command xwem-cl-transpose (arg &optional win)
+  "Transpose client with client at right in WIN.
 If ARG is non-nil transpose with left client.
-If CL is ommited than selected client will be used."
+If WIN is ommited than selected window will be used."
   (xwem-interactive "P")
 
-  (let* ((cl (or cl (xwem-cl-selected)))
-         (sw (xwem-cl-win cl))
-	 (tai (cadr (member cl (funcall (if arg 'reverse 'identity) (xwem-win-make-cl-list sw))))))
+  (let* ((sw (or win (xwem-win-selected)))
+	 (cl (xwem-win-cl sw))
+	 (tai (cadr (member cl (funcall (if arg 'reverse 'identity)
+					(xwem-win-make-cl-list sw))))))
+
     (when (not (xwem-cl-p tai))
-      (setq tai (cadr (member cl (funcall (if arg 'identity 'reverse) (xwem-win-make-cl-list sw))))))
+      (setq tai (cadr (member cl (funcall (if arg 'identity 'reverse)
+					  (xwem-win-make-cl-list sw))))))
 
     (when (and (xwem-cl-p cl) (xwem-cl-p tai))
-      (xwem-list-exchange-els xwem-clients cl tai)
+      (xwem-list-exchange-els xwem-clients cl tai))
 
-      (run-hook-with-args 'xwem-win-clients-change-hook sw))
-    ))
+    (xwem-tabber-regeom-window sw (xwem-win-selected-p sw (xwem-win-frame sw)))))
 
 (defun xwem-client-rearrange-top (cl)
   "Move CL on top of `xwem-clients'."
 
   (setq xwem-clients nil)
 
-  ;; Gentle handling of window splitting
-  (add-hook 'xwem-win-after-split-hook 'xwem-cl-other-on-split)
+  (add-hook 'xwem-cl-manage-hook
+	    (lambda (cl)
+	      (when (and (xwem-win-p (xwem-cl-win cl))
+			 (xwem-win-selected-p (xwem-cl-win cl)))
+		(xwem-tab-item-draw-format (xwem-cl-tabitem cl)))))
+  (add-hook 'xwem-cl-demanage-hook
+	    (lambda (cl)
+	      (when (and (xwem-win-p (xwem-cl-win cl))
+			 (xwem-win-selected-p (xwem-cl-win cl)))
+		(xwem-tab-item-draw-format (xwem-cl-tabitem cl)))))
 
   (when xwem-cl-use-set-focus
     (add-hook 'xwem-cl-manage-hook 'xwem-client-focus))
     (add-hook 'xwem-cl-manage-hook 'xwem-client-rearrange-top))
 ;    (add-hook 'xwem-cl-demanage-hook 'xwem-cl-bury))
 
-  ;; Setup
-  (when xwem-cl-use-parent-xwin
-    (add-hook 'xwem-cl-create-hook 'xwem-cl-parent-on-creation)
-    (add-hook 'xwem-cl-destroy-hook 'xwem-cl-parent-on-destroy)
-    (add-hook 'xwem-cl-state-change-hook 'xwem-cl-parent-on-change-state))
+  ;; Gentle handling of window splitting
+  (add-hook 'xwem-win-after-split-hook 'xwem-cl-other-on-split)
   )
 
 ;;;###autoload
     (run-hook-with-args 'xwem-cl-state-change-hook cl old-state state)
     ))
 
-(defsubst xwem-cl-managed-p (cl &optional win)
+;;;###autoload
+(defsubst xwem-cl-managed-p (cl)
   "Return non-nil if client CL is managed, i.e. has 'managed or 'normal state."
-  (and (or (not win) (eq (xwem-cl-win cl) win))
-       (or (eq (xwem-cl-state cl) 'managed)
-           (eq (xwem-cl-state cl) 'managed-current))))
+  (or (eq (xwem-cl-state cl) 'managed)
+      (eq (xwem-cl-state cl) 'normal)))
 
 ;;; Creating new client
 (defun xwem-cl-presetup (cl)
   (let ((xwin (xwem-cl-xwin cl)))
 
     (if (not (xwem-frame-p (xwem-frame-find 'xwin xwin)))
-        (progn
-          ;; Normal client(not an embedded frame)
-          (XSelectInput (xwem-dpy) xwin (xwem-cl-ev-mask cl))
-          (X-Win-EventHandler-add-new xwin 'xwem-cl-events-handler 100))
+	;; Not an embedded frame
+	(XSelectInput (xwem-dpy) xwin (xwem-cl-ev-mask cl))
 
       ;; Embedded frame
-      (XSelectInput (xwem-dpy) xwin (Xmask-or xwem-frame-ev-mask (xwem-cl-ev-mask cl)))
-      (X-Win-EventHandler-add-new xwin 'xwem-cl-events-handler 100
-                                  (list X-PropertyNotify X-FocusIn X-FocusOut X-LeaveNotify X-EnterNotify)))
-    ;; XXX
+      (XSelectInput (xwem-dpy) xwin (Xmask-or xwem-frame-ev-mask
+					      (xwem-cl-ev-mask cl))))
+
+    ;; Add event handlers
+    (X-Win-EventHandler-add-new xwin 'xwem-cl-events-handler 100)
+    (X-Win-EventHandler-add-new xwin 'xwem-ev-property 0 (list X-PropertyNotify))
+
     (XSetWindowBorderWidth (xwem-dpy) xwin 0)
 
     ;; Fetch some window properties
     ))
 
 ;;;###autoload
-(defun xwem-make-client (win &optional props xwem-win)
-  "Make new client window.
-WIN   - X Window.
-PROPS - Properties list for new client.
-XWEM-WIN - xwem window where new client should be managed(if possible)."
+(defun xwem-make-client (win attrs &optional xwem-win)
+  "Make new client window."
 
-  (let (attrs new-cl)
-    (when (setq attrs (xwem-misc-xwin-valid-p win)) ; just to check that window still alive
-      (setq new-cl (make-xwem-cl :plist props))
+  (when (XGetWindowAttributes (xwem-dpy) win) ; just to check that window not destroyed
+    (let ((new-cl (make-xwem-cl)))
 
       (setf (xwem-cl-xwin new-cl) win)
-      (X-Win-put-prop win 'xwem-cl new-cl)
       (X-Dpy-log (xwem-dpy) "New Client making name=%s\n" '(XGetWMName (xwem-dpy) win))
 
       (xwem-cl-presetup new-cl)
 
+      (when (null attrs)
+	(setq attrs (XGetWindowAttributes (xwem-dpy) win)))
+
       (setf (xwem-cl-xattrs new-cl) attrs)
       (setf (xwem-cl-xgeom new-cl) (XGetGeometry (xwem-dpy) win))
       (setf (xwem-cl-start-time new-cl) (current-time))
       ;; it.
       (setq xwem-clients (cons new-cl xwem-clients))
 
+      ;; Make tab item for client
+      (setf (xwem-cl-tabitem new-cl)
+	    (make-xwem-tab-item :type 'client
+				:state 'unmapped :rect (make-X-Rect :y 0 :x 0 :width 0 :height 0)
+				:cl new-cl :format xwem-tab-default-format))
+
       ;; Walk manage database to find how to deal with this client
       (let ((mdis (xwem-manda-find-inst new-cl)))
-        (if (not mdis)
-            (progn
-              (xwem-message 'err "Client not in manage database")
-              (error "Client not described in manage database"))
+	(if (not mdis)
+	    (progn
+	      (xwem-message 'err "Client not in manage database")
+	      (error "Client not described in manage database"))
 
-          (setf (xwem-cl-manda new-cl) mdis)
+	  (setf (xwem-cl-manda new-cl) mdis)
 
-          ;; Check for Win's expectations
-          (let ((wmcmd (xwem-hints-wm-command (xwem-cl-hints new-cl)))
-                (dwin nil))		;destination win
+	  ;; Check for Win's expectations
+	  (let ((wmcmd (xwem-hints-wm-command (xwem-cl-hints new-cl)))
+		(dwin nil))		;destination win
 	      
-            ;; Find a window who expects NEW-CL
-            (setq dwin
-                  (catch 'dwin
-                    (mapc (lambda (fr)
-                            (xwem-win-map
-                             (lambda (win)
-                               (when (> (xwem-win-get-expt win wmcmd) 0)
-                                 (xwem-win-expt-dec win wmcmd)
-                                 (throw 'dwin win)))
-                             (xwem-frame-selwin fr)))
-                          xwem-frames-list)))
+	    ;; Find a window who expects NEW-CL
+	    (setq dwin
+		  (catch 'dwin
+		    (mapc (lambda (fr)
+			    (xwem-win-map
+			     (lambda (win)
+			       (when (> (xwem-win-get-expt win wmcmd) 0)
+				 (xwem-win-expt-dec win wmcmd)
+				 (throw 'dwin win)))
+			     (xwem-frame-selwin fr)))
+			  xwem-frames-list)))
 	    
-            ;; Setup focus mode
+	    ;; Setup focus mode
             (xwem-focus-mode-set new-cl xwem-default-focus-mode)
 
-            ;; Run new client hook
-            (run-hook-with-args 'xwem-cl-create-hook new-cl)
+	    ;; Run new client hook
+	    (run-hook-with-args 'xwem-cl-new-client-hook new-cl)
 
-            ;; Finnally manage new client
-            (if (xwem-win-p dwin)
-                (xwem-manda-manage new-cl dwin)
-              (xwem-manda-manage new-cl)))
-          )))
+	    (if (xwem-win-p dwin)
+		(xwem-manda-fun-run mdis 'manage new-cl dwin)
+	      (xwem-manda-fun-run mdis 'manage new-cl)))
+	  )))
     ))
 
 
   "Manage other client to CL in WIN."
   (let ((ocl (xwem-cl-other cl)))
     (when (xwem-cl-p ocl)
-      (xwem-manda-manage ocl win))))
+      (xwem-manda-fun-run (xwem-cl-manda ocl) 'manage ocl win))))
 
 (defun xwem-cl-other-on-split (win how new-size)
   "Manage current WIN's cl in othen window.
 
 
 ;; Commands
-;;;###autoload(autoload 'xwem-client-turn-on-other-on-split "xwem-clients" "" t)
 (define-xwem-command xwem-client-turn-on-other-on-split ()
   "Turn on `xwem-cl-other-on-split' minor mode."
   (xwem-interactive)
   (setq xwem-cl-other-on-split t)
   (xwem-message 'info "Other on split minor mode is ON."))
 
-;;;###autoload(autoload 'xwem-client-turn-off-other-on-split "xwem-clients" "" t)
 (define-xwem-command xwem-client-turn-off-other-on-split ()
   "Turn off `xwem-cl-other-on-split' minor mode."
   (xwem-interactive)
   (setq xwem-cl-other-on-split nil)
   (xwem-message 'info "Other on split minor mode is OFF."))
 
-;;;###autoload(autoload 'xwem-client-toggle-other-on-split "xwem-clients" "" t)
 (define-xwem-command xwem-client-toggle-other-on-split (arg)
   "Toggle `xwem-cl-other-on-split' minor mode.
 Negative ARG turns it off, positive turns it on."
       (xwem-client-turn-off-other-on-split)
     (xwem-client-turn-on-other-on-split)))
   
-;;;###autoload(autoload 'xwem-client-kill "xwem-clients" "" t)
 (define-xwem-command xwem-client-kill (arg &optional cl)
   "Kill xwem client CL. Also destroys CL's X window.
 If used with prefix ARG is given, force CL to die, by default WM_DELETE_WINDOW will be probed.
   (let ((client (or cl (xwem-cl-selected))))
     (if (xwem-cl-p client)
 	(if arg
-            ;; Force killing
-            (XDestroyWindow (xwem-dpy) (xwem-cl-xwin client))
-          ;; else try soft killing
+	    (progn
+;	      (xwem-remove-client client)
+	      (XDestroyWindow (xwem-dpy) (xwem-cl-xwin client)))
 	  (or (xwem-client-close client) (xwem-client-kill t client)))
-
       (xwem-message 'warn "No Active client found."))))
 
-;;;###autoload(autoload 'xwem-client-query-kill "xwem-clients" "" t)
 (define-xwem-command xwem-client-query-kill (arg client)
   "Kill CLIENT.
 Prefix ARG directly passed to `xwem-client-kill'."
     (xwem-client-kill arg client))
   )
 
-;;;###autoload(autoload 'xwem-client-demanage-others "xwem-clients" "" t)
 (define-xwem-command xwem-client-demanage-others (arg)
   "Demanage others then selected client in selected window.
 If ARG given, remain ARG most recent clients."
   (xwem-interactive "p")
 
-  (let* ((win (xwem-win-selected))
-         (rcls (nthcdr arg (xwem-win-make-cl-list-sort-by-recency win))))
+  (let ((rcls (nthcdr arg (xwem-win-make-cl-list-sort-by-recency (xwem-win-selected)))))
     ;; cls in RCLS already demanaged
     (mapc (lambda (cl)
-            (setf (xwem-cl-state cl) 'unknown))
-          rcls)
+	    (setf (xwem-cl-win cl) nil))
+	  rcls)
 
-    ;; If something changed, run on-change hooks
-    (when rcls
-      (run-hook-with-args 'xwem-win-clients-change-hook win))
+    ;; Redraw frame's tabber
+    (xwem-tabber-safe-regeom (xwem-frame-tabber (xwem-frame-selected)) t)
     ))
 
-;;;###autoload(autoload 'xwem-client-run-copy "xwem-clients" "" t)
-(define-xwem-command xwem-client-run-copy (arg &optional cl)
+(define-xwem-command xwem-client-run-copy (arg)
   "Run the same command as selected CL.
 With prefix arg run it in other window.
 With double prefix arg run in other window and select.
 With numeric prefix arg run ARG copies."
   (xwem-interactive "P")
   
-  (let* ((cl (or cl (xwem-cl-selected)))
-         (nw (and (xwem-cl-p cl) (xwem-cl-win cl))))
+  (let* ((nw (xwem-win-selected))
+	 (cl (xwem-win-cl nw)))
 
     (if (not (xwem-cl-p cl))
 	(xwem-message 'warn "No client selected to copy.")
-
       (let ((cmd (xwem-hints-wm-command (xwem-cl-hints cl)))
 	    (cnt (if (numberp arg) arg 1)) ;how many clients to start
 	    (i 0))
 		(xwem-win-expt-inc nw cmd cnt))
 
 	      (when (= (prefix-numeric-value arg) 16)
-		(xwem-window-select-maybe-redraw nw))))
+		(xwem-window-select nw))))
 
 	  (when (xwem-win-p nw)
 	    (while (< i cnt)
 	      (setq i (1+ i))))
     )))))
 
-;;;###autoload(autoload 'xwem-client-run-copy-other-win "xwem-clients" "" t)
-(define-xwem-command xwem-client-run-copy-other-win (arg &optional cl)
+(define-xwem-command xwem-client-run-copy-other-win (arg)
   "Run copy of selected client in other window.
 With prefix ARG, make horizontal split instead of vertical if split
 really needed."
   (xwem-interactive "P")
 
-  (let ((cl (or cl (xwem-cl-selected)))
-        (xwem-win-after-split-hook nil)  ; prevent hooks
-        cmd own)
-    (when (or (not (xwem-cl-p cl))
-              (not (xwem-win-p (xwem-cl-win cl))))
-      (error "Can't run copy of invalid client"))
-
-    (setq cmd (xwem-hints-wm-command (xwem-cl-hints cl)))
-    (setq own (xwem-window-other 1 (xwem-cl-win cl)))
+  (let ((cmd (xwem-hints-wm-command (xwem-cl-hints (xwem-cl-selected))))
+	(own (xwem-window-other 1))
+	(xwem-win-after-split-hook nil)) ; prevent hooks processing
 
     (when cmd
       ;; Check is there split needed
       (xwem-win-expt-inc own cmd)
 
       ;; Finnaly run command
-      (xwem-execute-program cmd))
-    ))
+      (xwem-execute-program cmd))))
 
-;;;###autoload(autoload 'xwem-client-run-copy-other-frame "xwem-clients" "" t)
-(define-xwem-command xwem-client-run-copy-other-frame (arg &optional cl)
+(define-xwem-command xwem-client-run-copy-other-frame (arg)
   "Run copy of selected client in other frame.
 If prefix ARG is specified, create embedded frame, if creation is
 needed at all."
   (xwem-interactive "P")
 
-  (let ((cl (or cl (xwem-cl-selected)))
-        cmd ofr)
+  (let ((cmd (xwem-hints-wm-command (xwem-cl-hints (xwem-cl-selected))))
+	(ofr (xwem-frame-other (xwem-frame-selected))))
+    (unless (xwem-frame-p ofr)
+      (setq ofr (xwem-make-frame-1 arg nil nil t)))
 
-    (when (or (not (xwem-cl-p cl))
-              (not (xwem-frame-p (xwem-cl-frame cl))))
-      (error "Can't run copy of invalide client"))
+    ;; Setup expectance
+    (xwem-win-expt-inc (xwem-frame-selwin ofr) cmd)
 
-    (setq cmd (xwem-hints-wm-command (xwem-cl-hints cl)))
-    (setq ofr (xwem-frame-other (xwem-cl-frame cl)))
-    (when cmd
-      (unless (xwem-frame-p ofr)
-        (setq ofr (xwem-make-frame-1 arg nil nil t)))
+    (xwem-frame-select ofr)
 
-      ;; Setup expectance
-      (xwem-win-expt-inc (xwem-frame-selwin ofr) cmd)
-
-      (xwem-frame-select ofr)
-
-      ;; Finnaly run command
-      (xwem-execute-program cmd))
-    ))
+    ;; Finnaly run command
+    (xwem-execute-program cmd)))
 
 (defun xwem-cl-prog-geom (cl)
   "Get program specified geometry for CL."
   (let ((gmt (xwem-cl-xgeom cl)))
     (cons (X-Geom-width gmt) (X-Geom-height gmt))))
 
-(defun xwem-cl-get-uptime-1 (cl)
-  (let ((ctime (current-time))
-        (stime (xwem-cl-start-time cl)))
-    (list (- (nth 0 ctime) (nth 0 stime))
-          (- (nth 1 ctime) (nth 1 stime))
-          (- (nth 2 ctime) (nth 2 stime)))))
+(unless (fboundp 'subtract-time)
+  (defun subtract-time (t1 t2)
+    "Subtract two internal times."
+    (let ((borrow (< (cadr t1) (cadr t2))))
+      (list (- (car t1) (car t2) (if borrow 1 0))
+	    (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2))))))
 
 ;;;###autoload
 (defun xwem-cl-get-uptime (cl &optional format)
 %m is replaced by the minutes
 %s is replaced by the seconds
 %A is replaced by autogenerated format."
-  (let* ((upt (xwem-cl-get-uptime-1 cl))
-	 (upt (+ (* (nth 0 upt) 65536) (mod (nth 1 upt) 65536)))
-	 (days (/ upt 86400))
-	 (hours (/ (mod upt 86400) 3600))
-	 (minutes (/ (mod upt 3600) 60))
-	 (seconds (mod upt 60))
-	 (fmt (or format "%A"))
-	 (rup ""))
+  (let ((upt (nth 1 (subtract-time (current-time) (xwem-cl-start-time cl))))
+	(fmt (or format "%A"))
+	(days 0)
+	(hours 0)
+	(minutes 0)
+	(seconds 0)
+	(rup ""))
     
+    (when (> upt (* 60 60 24))
+      (setq days (/ upt (* 60 60 24))))
+
+    (when (> upt (* 60 60))
+      (setq hours (% (/ upt (* 60 60)) 24)))
+
+    (when (> upt 60)
+      (setq minutes (% (/ upt 60) 60)))
+
+    (setq seconds (% upt 60))
+
     (let ((flst (string-to-list fmt))
 	  chr)
       (while flst
 		      (setq rup (concat rup (format "%d" seconds))))
 		     ((= chr ?A)
 		      (setq rup (concat
-				 (cond ((> days 0) (format "%dd %dh %dm %ds" days hours minutes seconds))
-				       ((> hours 0) (format "%dh %dm %ds" hours minutes seconds))
+				 (cond ((> days 0) (format "%dd %dh" days hours))
+				       ((> hours 0) (format "%dh %dm" hours minutes))
 				       ((> minutes 0) (format "%dm %ds" minutes seconds))
 				       ((> seconds 0) (format "%d seconds" seconds))
 				       (t "")))))
 	(setq flst (cdr flst))))
     rup))
 
-;;;###autoload(autoload 'xwem-client-info "xwem-clients" "" t)
+;;;###autoload
+(autoload 'xwem-client-info "xwem-clients")
 (define-xwem-command xwem-client-info (&optional cl)
   "Display info about xwem client CL."
   (xwem-interactive)
 	  (xwem-message 'info "id: 0x%d, usize: %dx%d, psize: %dx%d, uptime: %s, name: `%s'"
 			(X-Win-id (xwem-cl-xwin client))
 			(car usz) (cdr usz)
-			(car psz) (cdr psz)
+			(car psz) (car psz)
 			(xwem-cl-get-uptime client)
 			(xwem-client-name client)))
       (xwem-message 'warn "No active clients found.")))
   )
 
-;;;###autoload(autoload 'xwem-cl-pop-to-client "xwem-clients" "" t)
+;;;###autoload
+(autoload 'xwem-cl-pop-to-client "xwem-clients")
 (define-xwem-command xwem-cl-pop-to-client (cl &optional warp)
   "Pop to client CL, i.e. switch to its frame and manage it.
 If CL have no frame, popup it in current frame."
 	(xwem-frame-select fr))
       (when (not (xwem-win-selected-p clw))
 	(xwem-window-select-maybe-redraw clw))
-      (xwem-manda-manage cl clw)
+      (xwem-manda-fun-run (xwem-cl-manda cl) 'manage cl clw)
 
       (when warp
 	(XWarpPointer (xwem-dpy) X-None (xwem-cl-xwin cl) 0 0 0 0 10 10)))
 
     (xwem-message 'info "Can't jump to dead client ..")))
 
-;;;###autoload(autoload 'xwem-cl-set-title "xwem-clients" "" t)
 (define-xwem-command xwem-cl-set-title (title &optional cl)
   "Set new TITLE for client CL."
   (xwem-interactive "sNet title: ")
 	(error "No currently selected client.")
       (XSetWMName (xwem-dpy) (xwem-cl-xwin ccl) title))))
 
-;;;###autoload(autoload 'xwem-client-unset-mark "xwem-clients" "" t)
 (define-xwem-command xwem-client-unset-mark (&optional cl)
   "Uset mark on CL."
   (xwem-interactive (list (xwem-cl-selected)))
 
   (when (member cl xwem-cl-mark-ring)
     (setq xwem-cl-mark-ring (delete cl xwem-cl-mark-ring))
-
-    ;; Now run on-mark hooks
-    (run-hook-with-args 'xwem-cl-mark-hook cl 'unmark)))
+    ;; Tab maybe affected, so redraw it
+    (xwem-tab-item-draw-format (xwem-cl-tabitem cl))))
   
-;;;###autoload(autoload 'xwem-client-set-mark "xwem-clients" "" t)
 (define-xwem-command xwem-client-set-mark (arg &optional cl)
   "Mark selected client CL.
 If CL is ommited or `xwem-client-set-mark' called interactively then
     ;; `xwem-cl-mark-ring-max' value if needed.
     (when (= (length xwem-cl-mark-ring) xwem-cl-mark-ring-max)
       ;; Remove last item
-      (xwem-client-unset-mark (car (last xwem-cl-mark-ring))))
+      (let ((rcl (car (last xwem-cl-mark-ring))))
+	(setq xwem-cl-mark-ring (butlast xwem-cl-mark-ring))
+	;; Tab maybe affected, so redraw it
+	(xwem-tab-item-draw-format (xwem-cl-tabitem rcl))))
 
     (push cl xwem-cl-mark-ring)
-
-    ;; Now run on-mark hooks
-    (run-hook-with-args 'xwem-cl-mark-hook cl 'mark)
+    ;; Tab maybe affected, so redraw it
+    (xwem-tab-item-draw-format (xwem-cl-tabitem cl))
 
     (xwem-message 'info "Marking selected client, total ring size %d"
 		  (length xwem-cl-mark-ring))
     ;; TODO: finalize client in (car xwem-clients)
     (setq xwem-clients (cdr xwem-clients))))
 
-;;;###autoload
+;;; New stuff
 (defun xwem-client-hide (cl &optional new-state)
   "Hide CL's window. Optionally you may specify NEW-STATE."
   ;; Just move off the screen
   (xwem-client-change-state cl (or new-state 'iconified))
   )
 
-;;;###autoload
-(defun xwem-client-show (cl &optional new-state)
+(defun xwem-client-show (cl)
   "Show xwem client CL."
-  ;; Make sure CL's frame is CL's parent
-  (XReparentWindow (xwem-dpy) (xwem-cl-xwin cl)
-                   (xwem-frame-xwin (xwem-cl-frame cl))
-                   (X-Geom-width (xwem-rootgeom)) (X-Geom-height (xwem-rootgeom)))
-
   (if (xwem-cl-transient-for cl)
       (XRaiseWindow (xwem-dpy) (xwem-cl-xwin cl))
 
                (X-Geom-y (xwem-cl-xgeom cl)))
 
   (XMapWindow (xwem-dpy) (xwem-cl-xwin cl))
-  (xwem-client-change-state cl (or new-state 'managed-current))
+
+  (xwem-client-change-state cl 'normal)
   )
 
 
 ;;; Events handling for client windows
+(defun xwem-cl-hkeybutton (cl xev)
+  "KeyPress, ButtonPress or ButtonRelease event XEV."
+  (xwem-kbd-handle-keybutton xev)
+  )
+
 (defun xwem-cl-hproperty (cl xev)
   "PropertyNotify."
-  (let ((xwin (xwem-cl-xwin cl))
-        (atom-id (X-Atom-id (X-Event-xproperty-atom xev)))
-        (state (X-Event-xproperty-state xev))
-        rhook)
-
-    ;; Some CL's property changed
-    (X-Dpy-log (xwem-dpy) "CLIENT .. PropertyNotify: Atom-id = %d\n" 'atom-id)
-
-    (cond 
-     ((and (= atom-id (X-Atom-id XA-wm-normal-hints)) (= state X-PropertyNewValue))
-      (setf (xwem-hints-wm-normal-hints (xwem-cl-hints cl)) (XGetWMNormalHints (xwem-dpy) xwin))
-      (setq rhook 'xwem-cl-wmnh-change-hooks))
-
-     ((and (= atom-id (X-Atom-id XA-wm-hints)) (= state X-PropertyNewValue))
-      (setf (xwem-hints-wm-hints (xwem-cl-hints cl)) (XGetWMHints (xwem-dpy) xwin))
-      (setq rhook 'xwem-cl-wmh-change-hooks))
-
-     ((and (= atom-id (X-Atom-id XA-wm-class)) (= state X-PropertyNewValue))
-      (setf (xwem-hints-wm-class (xwem-cl-hints cl)) (XGetWMClass (xwem-dpy) xwin))
-      (setq rhook 'xwem-cl-wmclass-change-hooks))
-
-     ((and (= atom-id (X-Atom-id XA-wm-command)) (= state X-PropertyNewValue))
-      (setf (xwem-hints-wm-command (xwem-cl-hints cl)) (XGetWMCommand (xwem-dpy) xwin))
-      (setq rhook 'xwem-cl-wmcommand-chage-hooks))
-
-     ((and (= atom-id (X-Atom-id XA-wm-name)) (= state X-PropertyNewValue))
-      (setf (xwem-hints-wm-name (xwem-cl-hints cl)) (XGetWMName (xwem-dpy) xwin))
-      (unless (equal (xwem-hints-wm-name (xwem-cl-hints cl)) (xwem-cl-saved-name cl))
-        (setf (xwem-cl-saved-name cl) (xwem-hints-wm-name (xwem-cl-hints cl)))
-        (setq rhook 'xwem-cl-wmname-change-hooks)))
-     )
-
-    ;; Run RHOOK
-    (when rhook
-      (run-hook-with-args rhook cl))
-    ))
+  )
 
 (defun xwem-cl-hconfigure-request (cl xev)
   "ConfigureRequest event XEV."
   )
 
-;;;###autoload
 (defun xwem-cl-hdestroy-notify (cl xev)
   "DestroyNotify event XEV."
-  (setf (xwem-cl-state cl) 'destroyed)
-  (xwem-manda-demanage cl 'destroyed)
+  (let ((ocl (xwem-cl-other cl))
+	(owin (xwem-cl-win cl)))
 
-  (xwem-remove-client cl)
+;    (xwem-manda-fun-run (xwem-cl-manda cl) 'demanage cl)
+    (xwem-remove-client cl)
 
-  ;; Now run on-destroy hooks
-  (run-hook-with-args 'xwem-cl-destroy-hook cl)
+    (if (xwem-cl-transient-for cl)
+	(xwem-manda-fun-run (xwem-cl-manda cl) 'demanage cl)
 
-  ;; Make client not valid for futher referencing
-  (X-invalidate-cl-struct cl)
-  )
+      ;; Try to switch to other client
+      (when (xwem-cl-inwin-p cl)
+	(when (xwem-win-p owin)
+	  (setf (xwem-win-cl owin) nil)
+
+	  (when (xwem-cl-p ocl)
+	    (xwem-manda-fun-run (xwem-cl-manda ocl) 'manage ocl owin))))
+
+      (when (xwem-win-p owin)
+	(xwem-tabber-regeom-window owin (xwem-win-selected-p owin)))
+      )
+    ))
 
 (defun xwem-cl-hunmap-notify (cl xev)
   "UnmapNotify event XEV."
 
   (let ((cl (xwem-find-client (X-Event-win xev))))
     (if (xwem-cl-p cl)
-	(xwem-manda-manage cl)
+	(xwem-manda-fun-run (xwem-cl-manda cl) 'manage cl)
 
-      (xwem-make-client (X-Event-win xev)))
-    ))
+      (xwem-make-client (X-Event-win xev) nil)))
+  )
 
 (defun xwem-cl-hclient-message (cl xev)
   "ClientMessage event XEV."
-  (let ((type (length (X-Event-xclient-msg xev))))	; 5 -> 32, 10 -> 16, 20 -> 8
-
-    (X-Dpy-log (xwem-dpy) "XWEM-CLIENT: in ClientMessage: type=%S msg(0)=%S\n"
-               'type  '(car (nth 0 (X-Event-xclient-msg xev))))
-
-    (cond ((and (= type 5)
-                (= (car (nth 0 (X-Event-xclient-msg xev))) X-IconicState))
-           (xwem-manda-iconify cl))
-          )
-    ))
+  )
 
 (defun xwem-cl-events-handler (xdpy xwin xev)
   "Events handler for root window."
   (X-Dpy-log xdpy "CLIENT HANDLER: xev type=%S, win=%S\n" '(X-Event-name xev) '(X-Win-id (X-Event-win xev)))
 
-  (let ((cl (X-Win-get-prop xwin 'xwem-cl)))
-    (when (xwem-cl-p cl)
-      (X-Event-CASE xev
-        ((:X-KeyPress :X-ButtonPress :X-ButtonRelease)
-         (xwem-kbd-handle-keybutton xev))
+  (let ((cl (xwem-find-client xwin)))
 
-        ;; Focusing mode
-        (:X-FocusIn (xwem-focus-mode-invoke cl 'focus-in xev))
-        (:X-FocusOut (xwem-focus-mode-invoke cl 'focus-out xev))
-        (:X-EnterNotify (xwem-focus-mode-invoke cl 'enter xev))
-        (:X-LeaveNotify (xwem-focus-mode-invoke cl 'leave xev))
+    (X-Event-CASE xev
+      ((:X-KeyPress :X-ButtonPress :X-ButtonRelease)
+       (xwem-cl-hkeybutton cl xev))
 
-        ;; Various events
-        (:X-PropertyNotify (xwem-cl-hproperty cl xev))
-        (:X-MapRequest (xwem-cl-hmap-request cl xev))
-        (:X-ConfigureRequest (xwem-cl-hconfigure-request cl xev))
-        (:X-ClientMessage (xwem-cl-hclient-message cl xev))
+      ;; Focusing mode
+      (:X-FocusIn
+       (X-Dpy-log xdpy "CLIENT FOCUSIN: wm_name=%S, mode=%S, detail=%S\n"
+                  '(XGetWMName xdpy (X-Event-win xev)) '(X-Event-xfocus-mode xev) '(X-Event-detail xev))
+       (xwem-focus-mode-invoke cl 'focus-in xev))
+      (:X-FocusOut
+       (xwem-focus-mode-invoke cl 'focus-out xev))
+      (:X-EnterNotify
+       (xwem-focus-mode-invoke cl 'enter xev))
+      (:X-LeaveNotify
+       (xwem-focus-mode-invoke cl 'leave xev))
 
-        (:X-DestroyNotify
-         (setq cl (xwem-find-client (X-Event-xdestroywindow-window xev)))
-         (when (xwem-cl-p cl)
-           (xwem-cl-hdestroy-notify cl xev)))
+      (:X-PropertyNotify
+       (xwem-cl-hproperty cl xev))
 
-        ;; Not really used now, but ...
-        (:X-UnmapNotify (xwem-cl-hunmap-notify cl xev))
-        (:X-MapNotify (xwem-cl-hmap-notify cl xev))
-        )
+      (:X-ConfigureRequest
+       (xwem-cl-hconfigure-request cl xev))
+
+      (:X-DestroyNotify
+       (setq cl (xwem-find-client (X-Event-xdestroywindow-window xev)))
+       (when (xwem-cl-p cl)
+         (xwem-cl-hdestroy-notify cl xev)))
+
+      (:X-UnmapNotify
+       ;; Someone issued XUnmapWindow
+       (xwem-cl-hunmap-notify cl xev))
+   
+      (:X-MapNotify
+       ;; Someone issued XMapWindow
+       (xwem-cl-hmap-notify cl xev))
+
+      (:X-MapRequest
+       (xwem-cl-hmap-request cl xev))
+
+      (:X-ClientMessage
+       (xwem-cl-hclient-message cl xev))
+
       )))
 
-;;; CL's parent xwin hacks
-(defun xwem-cl-parent-on-creation (cl)
-  "CL just created."
-  (xwem-cl-put-prop cl 'parent-xwin
-    (XCreateWindow (xwem-dpy) nil 0 0 1 1 0 nil nil nil (make-X-Attr))))
-
-(defun xwem-cl-parent-on-change-state (cl old-state new-state)
-  "CL changed state."
-  (let ((pwin (xwem-cl-get-prop cl 'parent-xwin)))
-    (when (X-Win-p pwin)
-      (cond ((or (eq new-state 'managed)
-                 (eq new-state 'iconified)
-                 (eq new-state 'demanaged))
-             ;; 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.
-             (XReparentWindow (xwem-dpy) (xwem-cl-xwin cl) pwin 0 0)
-             (XLowerWindow (xwem-dpy) (xwem-cl-xwin cl)))
-            )
-      )))
-
-(defun xwem-cl-parent-on-destroy (cl)
-  "CL is about to be destroyed."
-  (let ((pwin (xwem-cl-get-prop cl 'parent-xwin)))
-    (when (X-Win-p pwin)
-      (XDestroyWindow (xwem-dpy) pwin))))
-
 
 (provide 'xwem-clients)
 

lisp/xwem-clswi.el

 	  (setq num (% (+ cclinx arg) (length cls)))
 	  (setq scl (nth (if (natnump num) num (+ (length cls) num)) cls))
 
-	  (xwem-manda-manage scl)
+	  (xwem-manda-fun-run (xwem-cl-manda scl) 'manage scl)
 
 	  (when xwem-clswi-show-info
 	    (xwem-client-info scl)))

lisp/xwem-compat.el

 
 ;;; Commentary:
 
-;; Compatibility layer betwean XEmacs and GNU Emacs.  However xwem
-;; still can't run on GNU Emacs.
+;; 
 
 ;;; Code:
 
-;;;###autoload
-(defvar xwem-gnuemacs-p (string-match "GNU Emacs" emacs-version)
-  "Non-nil when running under GNU Emacs.")
+(defvar xwem-gnuemacs-p nil "Non-nil when running under GNU Emacs.")
+
+(eval-and-compile
+  (setq xwem-gnuemacs-p (string-match "GNU Emacs" emacs-version)))
 
 ;;;###autoload
 (defun xwem-define-prefix-command (name &optional mapvar)

lisp/xwem-diagram.el

             (setq buta2 (- a2 (- buta1 a1))))
 
         (setq d0-buta1 180)
-        (setq d0-buta2 (- (+ a1 a2) 270 270)))
+        (setq d0-buta2 (- (+ a1 a2) 270)))
       )
 
     (when (> (+ (or buta1 a1) (or buta2 a2)) 360)
         (progn
           (when fill-gc
             (XFillArc (X-Win-dpy xwin) xwin fill-gc x (+ y sector-width) w h buta1 buta2))
-          (XDrawArc (X-Win-dpy xwin) xwin gc x (+ y sector-width) w h buta1 buta2)
-          )
+          (XDrawArc (X-Win-dpy xwin) xwin gc x (+ y sector-width) w h buta1 buta2))
 
-      (if (or (and d0-buta1 d0-buta2)
+      (if (or (and d0-buta1 d0-buta1)
               (and d2-buta1 d2-buta2))
           (progn
-            (when (and d0-buta1 d0-buta2)
+            (when (and d0-buta1 d0-buta1)
               (when fill-gc
                 (XFillArc (X-Win-dpy xwin) xwin fill-gc x (+ y sector-width) w h d0-buta1 d0-buta2))
-              (XDrawArc (X-Win-dpy xwin) xwin gc x (+ y sector-width) w h d0-buta1 d0-buta2)
-              )
+              (XDrawArc (X-Win-dpy xwin) xwin gc x (+ y sector-width) w h d0-buta1 d0-buta2))
             (when (and d2-buta1 d2-buta2)
               (when fill-gc
                 (XFillArc (X-Win-dpy xwin) xwin fill-gc x (+ y sector-width) w h d2-buta1 d2-buta2))
-              (XDrawArc (X-Win-dpy xwin) xwin gc x (+ y sector-width) w h d2-buta1 d2-buta2)
-              ))
+              (XDrawArc (X-Win-dpy xwin) xwin gc x (+ y sector-width) w h d2-buta1 d2-buta2)))
 
         (when (and (xwem-diag-dot->= 'y (nth 0 ds1) (nth 1 ds1))
                    (xwem-diag-dot->= 'y (nth 2 ds1) (nth 1 ds1)))
                 (list d1 dd1 dd2 dd3 d3 d4 d1 d2 d3 d2 dd2))
   ))
 
-;;;###autoload
 (defun xwem-diag-draw-percentage (type spec d edge-gc x y width height &optional sector-width label-factor label-font)
   "Draw percentage sector of TYPE.
 TYPE is one of 'plain or '3d.
       )))
 
 
-;;;###autoload
 (defun xwem-diag-plot-coordinates (d gc x y w h x-step y-step &rest params)
   "Draw coordinates system."
   (let ((notch-len (or (plist-get params :notch-len) 4))
                                     x-notches y-notches))
     ))
 
-;;;###autoload
 (defun xwem-diag-plot-points (point-type d gc dots &optional point-size)
   "Draw points of TYPE."
   (unless point-size
           )
     ))
 
-;;;###autoload
 (defun xwem-diag-plot-dots (type d gc x y dots &optional point-type point-size)
   "Draw dots in cartesian coordinate system which has 0 at X Y."
     
            ))
     ))
 
-;;;###autoload
 (defun xwem-diag-read-data-file (file &optional using x-scale y-scale)
   "Read data FILE and return list of dots lists.
 USING is cons cell that specifies which columns to use.

lisp/xwem-edmacro.el

   (setq xwem-edmacro-store-place nil)
   )
 
-;;;###autoload(autoload 'xwem-edmacro-edit-kbd-macro "xwem-edmacro" "" t)
 (define-xwem-command xwem-edmacro-edit-kbd-macro (xwem-keys &optional arg)
   "Edit XWEM keyboard macro specified by XWEM-KEYS.
 With a prefix ARG, format the macro in a more concise way."

lisp/xwem-events.el

 ;;
 ;;; Code
 
-(eval-when-compile
-  (require 'xlib-xwin))
+
+;; Property change hooks
+;;;###autoload
+(defvar xwem-wmnh-change-hooks nil "Hooks to be called when WM_NORMAL_HINTS changes.")
+;;;###autoload
+(defvar xwem-wmname-change-hooks nil "Hooks to be called when WM_NAME changes.")
+;;;###autoload
+(defvar xwem-wmcommand-chage-hooks nil "Hooks to be called when WM_COMMAND changes.")
+;;;###autoload
+(defvar xwem-wmclass-change-hooks nil "Hooks to be called when WM_CLASS changes.")
+;;;###autoload
+(defvar xwem-wmh-change-hooks nil "Hooks to be called when WM_HINTS changes.")
 
 (defun xwem-ev-defhnd (xdpy win xev)
   "Default X-Events handler."
 
-  (X-Event-CASE xev
-;   (:X-ClientMessage (xwem-ev-clnmsg xdpy win xev))
-;   (:X-PropertyNotify (xwem-ev-property xdpy win xev))
-   (:X-ConfigureRequest (xwem-ev-reconfig xdpy win xev))
-   (:X-MapRequest (xwem-ev-remap xdpy win xev))
-   (:X-DestroyNotify (xwem-ev-destroy xdpy win xev))
-   (:X-ResizeRequest (xwem-ev-reresize xdpy win xev)))
+  (X-Event-CASE
+   xev
+   (:X-ClientMessage
+    (xwem-ev-clnmsg xdpy win xev))
+   (:X-ConfigureRequest
+    (xwem-ev-reconfig xdpy win xev))
+   (:X-MapRequest
+    (xwem-ev-remap xdpy win xev))
+   (:X-DestroyNotify
+    (xwem-ev-destroy xdpy win xev))
+   (:X-PropertyNotify
+    (xwem-ev-property xdpy win xev))
+   (:X-ResizeRequest
+    (xwem-ev-reresize xdpy win xev)))
   )
 
+(defun xwem-ev-clnmsg (xdpy win xev)
+  "Handle ClientMessage event."
+  (X-Dpy-log (xwem-dpy) "XWEM-EVENTS: ClientMessage event: win=%s msg=%s\n"
+	     '(X-Win-id win) '(X-Event-xclient-msg xev))
+
+  (let ((cl (xwem-find-client win))
+	(type (length (X-Event-xclient-msg xev))))	; 5 -> 32, 10 -> 16, 20 -> 8
+
+    (when (xwem-cl-p cl)
+      (X-Dpy-log (xwem-dpy) "XWEM-EVENTS: in ClientMessage: type=%S (car (nth 0 (X-Event-xclient-msg xev)))=%S\n"
+		 'type  '(car (nth 0 (X-Event-xclient-msg xev))))
+      (if (and (= type 5)
+	       (= (car (nth 0 (X-Event-xclient-msg xev)))
+		  X-IconicState))
+	  (xwem-manda-fun-run (xwem-cl-manda cl) 'iconify cl))
+      )
+    nil))
+
 (defun xwem-ev-reconfig (xdpy win xev)
   "Common ConfigureRequest handler."
   (let* ((win (X-Event-xconfigurerequest-window xev))
-	 (cl (X-Win-get-prop win 'xwem-cl))
+	 (cl (xwem-find-client win))
 ;	 (clgeom (if (xwem-cl-p cl) (xwem-cl-xgeom cl) nil))
 	 (vmask (X-Event-xconfigurerequest-value-mask xev)))
 
 				       :border-width (X-Event-xconfigurerequest-border-width xev)))
 
       ;; [else] Client window already in air
-      (if (not (= 0 (Xmask-and vmask (Xmask-or X-CWWidth X-CWHeight X-CWBorderWidth))))
-          (xwem-manda-refit cl)
+      (progn
+	(if (not (= 0 (Xmask-and vmask (Xmask-or X-CWWidth X-CWHeight X-CWBorderWidth))))
+	    (xwem-manda-fun-run (xwem-cl-manda cl) 'refit cl)
 
-        (xwem-cl-send-config cl)))
+	  (xwem-cl-send-config cl))))
     nil))
 
 (defun xwem-ev-remap (xdpy win xev)
 
   (let ((cl (xwem-find-client win)))
     (if (xwem-cl-p cl)
-	(xwem-manda-manage cl)
-      (xwem-make-client win)))
+	(xwem-manda-fun-run (xwem-cl-manda cl) 'manage cl)
+      (xwem-make-client win nil)))
   nil)
 
 (defun xwem-ev-destroy (xdpy win xev)
   ;; TODO: - May this stuff should be moved to `xwem-xdestrnot-hooks'?
   (X-Dpy-log (xwem-dpy) "XWEM-EVENTS: DestroyNotify event handled for win=%s, evwin=%S\n"
 	     '(X-Win-id win) '(X-Win-id (X-Event-xdestroywindow-event xev)))
-  )
+
+  (let* ((cl (xwem-find-client win))
+	 (owin (and (xwem-cl-p cl) (xwem-cl-win cl))))
+    (when (xwem-cl-p cl)
+	(xwem-manda-fun-run (xwem-cl-manda cl) 'demanage cl)
+	(xwem-remove-client cl)
+
+	(when (xwem-cl-inwin-p cl)
+	  (when (xwem-win-p owin)
+	    (setf (xwem-win-cl owin) nil)))
+
+	(when (xwem-win-p owin)
+	  (xwem-tabber-regeom-window owin (xwem-win-selected-p owin (xwem-win-frame owin))))
+	))
+  nil)
+
+(defun xwem-ev-property (xdpy win xev)
+  "PropertyNotify handler."
+  ;; TODO: write me
+  (X-Dpy-log (xwem-dpy) "XWEM-EVENTS: PropertyNotify event win=%S, atom=%S, state=%S\n"
+	     '(X-Win-id (X-Event-win xev)) '(X-Atom-id (X-Event-xproperty-atom xev))
+	     '(X-Event-xproperty-state xev))
+
+  (let ((cl (xwem-find-client win))
+	(atom-id (X-Atom-id (X-Event-xproperty-atom xev)))
+	(state (X-Event-xproperty-state xev))
+	(rhook nil))			;hook to be runned after processing
+
+    (if (null cl)
+	;; hmm -- no such client
+	nil
+
+      (cond 
+       ((= atom-id (X-Atom-id XA-wm-normal-hints))
+	(setf (xwem-hints-wm-normal-hints (xwem-cl-hints cl))
+	      (if (= state X-PropertyNewValue)
+		  (XGetWMNormalHints (xwem-dpy) win)
+		nil))
+	(setq rhook 'xwem-wmnh-change-hooks))
+
+       ((= atom-id (X-Atom-id XA-wm-hints))
+	(setf (xwem-hints-wm-hints (xwem-cl-hints cl))
+	      (if (= state X-PropertyNewValue)
+		  (XGetWMHints (xwem-dpy) win)
+		nil))
+	(setq rhook 'xwem-wmh-change-hooks))
+
+       ((= atom-id (X-Atom-id XA-wm-class))
+	(setf (xwem-hints-wm-class (xwem-cl-hints cl))
+	      (if (= state X-PropertyNewValue)
+		  (XGetWMClass (xwem-dpy) win)
+		nil))
+	(setq rhook 'xwem-wmclass-change-hooks))
+
+       ((= atom-id (X-Atom-id XA-wm-command))
+	(setf (xwem-hints-wm-command (xwem-cl-hints cl))
+	      (if (= state X-PropertyNewValue)
+		  (XGetWMCommand (xwem-dpy) win)
+		nil))
+	(setq rhook 'xwem-wmcommand-chage-hooks))
+
+       ((= atom-id (X-Atom-id XA-wm-name))
+	(setf (xwem-hints-wm-name (xwem-cl-hints cl))
+	      (if (= state X-PropertyNewValue)
+		  (XGetWMName (xwem-dpy) win)
+		nil))
+	(setq rhook 'xwem-wmname-change-hooks))
+	     
+       (t (X-Dpy-log (xwem-dpy) "PropertyNotify: Atom-id = %d\n" 'atom-id)))
+      
+      (when rhook
+	(run-hook-with-args rhook cl)))
+
+    nil))
 
 (defun xwem-ev-reresize (xdpy win xev)
   "On display XDPY handler ResizeRequest for WIN."
 (defun xwem-fini-events ()
   )
 
-;;;###autoload
-(defvar xwem-events-queue nil)
-
-;; Current events execution depth
-(defvar xwem-events-depth 0)
-
-;;; Function to call when there data in XDPY, but noone reading it.
-;;;###autoload
-(defun xwem-parse-message-guess (xdpy)
-  "There is data waiting on XDPY, but no-one is reading it.
-Try to guess what it is."
-  (X-Dpy-p xdpy 'xwem-parse-message-guess)
-
-  (condition-case nil
-      ;; If no-one reading now, mean than error or event arrived.
-      (when (zerop (X-Dpy-readings xdpy))
-
-        (while (> (length (X-Dpy-message-buffer xdpy)) 0)
-          (X-Dpy-eval-error-or-event xdpy))
-
-        (flet ((evmatch (ev)
-                        (let ((evtype (X-Event-type ev)))
-                          (or (= evtype X-KeyPress)
-;                    (= evtype X-KeyRelease)
-                              (= evtype X-ButtonPress)
-                              (= evtype X-ButtonRelease)
-                              (= evtype X-MotionNotify)))))
-
-          (mapc (lambda (ev)
-                  (when (evmatch ev)
-                    (setq xwem-events-queue (append xwem-events-queue (list ev)))))
-                (X-Dpy-evq xdpy))
-
-          ;; Execute normal events
-          (when (zerop (X-Dpy-evq-protects xdpy))
-            (while (X-Dpy-evq xdpy)
-              (let ((ev (X-Dpy-event-dequeue xdpy)))
-                (unless (evmatch ev)
-                  (X-Dpy-event-dispatch ev))
-                ))))
-
-        ;; Execute covertable events
-        (when (>= (recursion-depth) xwem-events-depth)
-          (incf xwem-events-depth)
-          (unwind-protect
-              (while xwem-events-queue
-                (X-Dpy-event-dispatch (pop xwem-events-queue)))
-            (decf xwem-events-depth)))
-        )
-    (X-Error nil)))
-
-;;;###autoload
-(defun xwem-next-event (&optional timeout)
-  "Fetch next xwem keyboard or mouse event.
-If optional argument PEEK is non-nil than do not remove."
-  (incf xwem-events-depth)
-  (let (xev done)
-    (unwind-protect
-        (while (not done)
-          (if xwem-events-queue
-              (setq xev (pop xwem-events-queue)
-                    done t)
-
-            (when (and (not (accept-process-output (X-Dpy-proc (xwem-dpy)) (or timeout 1)))
-                       timeout)
-              (setq xev nil done t))))
-    (decf xwem-events-depth))
-    xev))
-
 (provide 'xwem-events)
 
 ;;; xwem-events.el ends here

lisp/xwem-faces.el

 
 ;;; Commentary:
 
-;; Faces support.  Main purpose of `xwem-faces' is easify interface to
-;; X-Gc.
+;; Faces support.
 
 ;;; Code:
 (require 'cus-face)			; for `custom-face-get-spec'
-(eval-when-compile
-  (require 'xlib-xlib)
-  (require 'xwem-misc))
 
 
 (defgroup xwem-faces nil
 (defun xwem-eface-to-gc (xdpy face &optional d)
   "On display XDPY convert Emacs FACE to X graphical context.
 Drawable D.
-TOOD: - maybe add support for domains?.
-
-NOTE: Default value for graphics-exposures is `X-False'."
+TOOD: - maybe add support for domains?."
   (let* ((cmap (XDefaultColormap xdpy))
 	 (fgcol (xwem-misc-colorspec->rgb-vector-safe (face-foreground-name face) [0 0 0]))
 	 (bgcol (xwem-misc-colorspec->rgb-vector-safe (face-background-name face) [0 0 0]))
 			 :join-style (or (xwem-face-tag face :join-style) X-JoinMiter)
 			 :function (or (xwem-face-tag face :function) X-GXCopy)
 			 :subwindow-mode (or (xwem-face-tag face :subwindow-mode) X-ClipByChildren)
-			 :graphics-exposures (or (xwem-face-tag face :graphics-exposures) X-False)
+			 :graphics-exposures (xwem-face-tag face :graphics-exposures)
 			 :foreground (XAllocColor xdpy cmap
 						  (make-X-Color :id (X-Dpy-get-id xdpy)
 								:cmap cmap
 ;;;###autoload
 (defun xwem-face-get-gc (name &optional xdpy d)
   "Return X-Gc with NAME.
-Name can be symbol or string.
-XDPY - X display.
-D    - X drawable."
+Name can be symbol or string."
   (let ((gc (get name 'xwem-face-gc)))
     (unless (X-Gc-p gc)
       (xwem-eface-to-gc (or xdpy (xwem-dpy)) name d)

lisp/xwem-focus.el

 
 ;;; Code:
 
-(eval-when-compile
-  (require 'xlib-xwin)
-  (require 'xwem-clients))
 
 ;;;###autoload
 (defvar xwem-focus-stack nil
 (defun xwem-focus-push-set (xwin)
   "Push current focus to `xwem-focus-stack' and set focus to XWIN."
   (xwem-focus-push)
-  (XSetInputFocus (xwem-dpy) xwin X-RevertToParent))
+  (XSetInputFocus (X-Win-dpy xwin) xwin X-RevertToParent))
 
 ;;;###autoload
 (defun xwem-focus-pop-set ()
   "Pop from `xwem-focus-stack' and set focus."
   (let ((xwin (xwem-focus-pop)))
     (when (X-Win-p xwin)
-      (XSetInputFocus (xwem-dpy) xwin X-RevertToParent))))
+      (XSetInputFocus (X-Win-dpy xwin) xwin X-RevertToParent))))
 
 ;;;###autoload
-(defun xwem-focus-set (thing &optional push)
+(defun xwem-focus-set (thing)
   "Set input focus to THING.
-THING - one of X-Win, xwem-frame, or xwem-client.
-PUSH  - Non-nil for pushing thing into `xwem-focus-stack'."
+THING is one of X-Win, xwem-frame, or xwem-client."
   (cond ((or (X-Win-p thing) (numberp thing)) ; X11 window
-         (when push
-           (xwem-focus-push))
-         (XSetInputFocus (xwem-dpy) thing X-RevertToParent))
+	 (xwem-focus-push-set thing))
 
 	;; xwem client
 	((xwem-cl-p thing)
 
 ;;;###autoload
 (defmacro xwem-focus-excursion (xwin &rest forms)
-  "Under XWIN focus do FORMS."
+  "Do FORMS, saving current input focus and under XWIN focus."
   `(prog2
      (xwem-focus-push-set ,xwin)
      ,@forms
      (xwem-focus-pop-set)))
+
 (put 'xwem-focus-excursion 'lisp-indent-function 1)
 
 

lisp/xwem-frame.el

 ;;; Code
 
 
-(eval-when-compile
-  (require 'xlib-xlib)
-  (require 'xwem-misc))
-(require 'xlib-xinerama)
+(autoload 'X-XIneramaQueryScreens "xlib-xinerama")
 
 ;;; Variables
 (defgroup xwem-frame nil
   :type '(restricted-sexp :match-alternatives ('nil xwem-misc-colorspec-valid-p))
   :group 'xwem-frame)
 
-(defconst xwem-frame-builtin-properties
-  '(inner-border-width otter-border-width title-height title-thickness)
-  "List of valid builtin frame properties.")
-
 (defcustom xwem-frame-defprops
   (list 'inner-border-width 0		;internal border of xwem's frame
 	'otter-border-width 0		;