;;File: mwm.gwm -- the main file for MWM emulation under GWM
;;Author: colas@mirsa.inria.fr (Colas NAHABOO) -- Bull Research FRANCE
;;Author: glen WHITNEY -- UCLA Math Department
;;Revision: 1.4 -- June 12 1989
;;Revision: 1.5 -- June 26 1992
;;State: Exp
;;GWM Version: 1.7l

;; this profile is monoscreen only

(if (> (length (list-of-screens)) 1)
    (progn
      (? "The mwm profile works only on one screen. Restarting with -1fmwm\n")
      (restart "gwm" "-1fmwm")))

; banner
; ======

(if (= display-name "unix:0")
    (if (: machine (getenv "machine"))
	(: display-name (+ machine ":0"))))

(if (= 0 gwm-quiet)
    (? display-name "." screen " " screen-width " x " screen-height " x " 
       screen-depth "\n"))
(if (= 0 gwm-quiet) (print "reading..."))
(: original-load load)
(if (= 0 gwm-quiet) (defun load (file) (? ".")(original-load file)))

; global switches
; ===============

(: property ())
(: borderwidth 1)

(: to-be-done-after-setup '(progn))
(: screen-opening '(progn))		; actions to be done before operation
(: screen-closing '(progn))		; actions to be done when ending

; per-screen data setting
; =======================

(defunq defname-in-screen-to args
    (with (value (eval (# 0 args))
		 vars (sublist 1 (length args) args))
	  (for var vars
	       (defname var screen. value))))

(defunq set-color (name value)
    (if (not (= screen. (namespace-of name))) {
	(defname name screen.)
	(for screen (list-of-screens)
	     (set name (color-make value)))
	}
    ))

(defunq set-pixmap args
    (with (name (# 0 args)
		pixmap-make-call (# 0 args 'pixmap-make))
	  (if (not (= screen. (namespace-of name))) {
	      (defname name screen.)
	      (for screen (list-of-screens)
		   (set name (eval pixmap-make-call)))
	      }
	  ))))

; per-screen data
; ===============

(defname-in-screen-to () tile screen-tile bordertile menu root-cursor)

(set-color black Black)
(set-color white White)
(set-color grey Grey)
(set-color darkgrey DarkSlateGrey)

(load "mwmrc")
(load "mwm-bindings")

(set-pixmap icon-pixmap "icon20")
    
(defname 'look-3d screen.)
(for screen (list-of-screens)
    (if (= 'mono screen-type)
	(: look-3d ())
	(: look-3d t)
    ))))

(load "mwm-utils.gwm")

; automatic placement
; ===================

(load "mwm-placements")

; Pop-ups
; =======

(: window-grabs
   (list (button any with-alt)
	 (button 1 (together with-shift with-alt))))

(: root-grabs
   (list (button any with-alt)
	 (button 1 (together with-shift with-alt))))

(load "mwm-menus.gwm")

; Menus and Bindings
;-------------------

; get the internal default versions of these.
(load "mwm-internal.gwmMwmrc")

; For now, get the menu, key, and buttonbindings in gwm format
; from .gwmMwmrc, or if that doesn't exist, from system.gwmMwmrc
; The next revision would be to fork a process which interprets
; the .mwmrc file into gwm code and then causes gwm to load it.

(if (not (load ".gwmMwmrc")) (load "system.gwmMwmrc"))

(: buttonBindings (eval buttonBindings))
(: keyBindings (eval keyBindings))

; Read what used to be the profile
(if (= 0 gwm-quiet) (? "["))
(for screen (list-of-screens) (load "mwmprofile.gwm"))
(if (= 0 gwm-quiet) (? "]"))
    
; Get the mwm window and icon description
(load "mwm-win")
(load "mwm-icon")

; DESCRIBE-SCREEN & DESCRIBE-WINDOW
; =================================

(de describe-screen ()
  (with (fsm root-fsm cursor root-cursor tile screen-tile
      grabs (+ (# 1 (# 'root keyBindings)) root-std-grabs)
      opening 
      '(progn (eval to-be-done-after-setup)
	(eval screen-opening)
	(if (= 0 gwm-quiet) (? "Screen #" screen " ready.\n")))
      closing '(eval screen-closing)
    )
    (window-make () () () () ())))

(de describe-window ()
    (list mwm-win mwm-icon))

;  Bye bye
; ========

(setq load original-load)
(if (= 0 gwm-quiet) (print "...done\n"))

(? "keyboardFocusPolicy = " keyboardFocusPolicy "\n")
(setq keyboardFocusPolicy 'pointer)
