File: wm.jl

package info (click to toggle)
sawfish 1%3A1.3.5.2-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 11,636 kB
  • ctags: 1,327
  • sloc: lisp: 22,765; ansic: 15,810; sh: 10,203; makefile: 675; perl: 19
file content (163 lines) | stat: -rw-r--r-- 5,807 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#| sawfish.wm bootstrap

   $Id: wm.jl,v 1.13 2002/05/07 03:35:59 jsh Exp $

   Copyright (C) 1999 John Harper <john@dcs.warwick.ac.uk>

   This file is part of sawmill.

   sawmill 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.

   sawmill 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 sawmill; see the file COPYING.  If not, write to
   the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|#

(declare (in-module sawfish.wm))

(open-structures '(rep rep.system rep.io.files))

;;(setq debug-on-error '(bad-arg missing-arg void-value invalid-function))

;; so modularised rep knows where to inherit specials and load from
;; this will be changed to 'user later
(setq *user-structure* 'sawfish.wm)

;; load always-present session-manager stuff
(require 'sawfish.wm.session.init)

;; set $DISPLAY so that any subprocesses inherit it
(setenv "DISPLAY" display-name)

;; load i18n support when necessary
(unless batch-mode
  (let ((lang (or (getenv "LANGUAGE") (getenv "LC_ALL")
		  (getenv "LC_MESSAGES") (getenv "LANG")))
	(disable-nls (get-command-line-option "--disable-nls")))

    (when (and lang (not disable-nls) (not (string= lang "C")))
      (require 'rep.i18n.gettext)
      (bindtextdomain "sawfish" sawfish-locale-directory)
      (when (boundp 'bindtextdomaincodeset)
	(bindtextdomaincodeset "sawfish" "UTF-8"))
      (textdomain "sawfish"))))

;; ignore file errors on stdio streams
(when (boundp 'set-file-ignore-errors)
  (set-file-ignore-errors (stdin-file) t)
  (set-file-ignore-errors (stdout-file) t)
  (set-file-ignore-errors (stderr-file) t))

;; used to mark variable declarations that need special attention
;; from the sawfish-xgettext script
(defmacro i18n-defvar args (cons 'defvar args))
(defmacro i18n-define args (cons 'define args))
(export-bindings '(i18n-defvar i18n-define))

;; add ~/.sawfish/lisp to load-path for user-code (canonicalize it
;; now to avoid calling tilde file-handler multiple times)
(setq load-path (cons (canonical-file-name "~/.sawfish/lisp") load-path))

;; import libraries that may be needed by autoload files
(require 'sawfish.wm.commands)
(require 'sawfish.wm.custom)
(require 'sawfish.wm.focus)
(require 'sawfish.wm.placement)
(require 'sawfish.wm.window-anim)

;; load standard libraries (but don't import them)
(mapc intern-structure '(sawfish.wm.keymaps
			 sawfish.wm.workspace
			 sawfish.wm.viewport
			 sawfish.wm.stacking
			 sawfish.wm.frames
			 sawfish.wm.swapper
			 sawfish.wm.state.configure
			 sawfish.wm.state.maximize
			 sawfish.wm.state.mwm
			 sawfish.wm.state.open-look
			 sawfish.wm.state.transient
			 sawfish.wm.state.shading
			 sawfish.wm.state.iconify
			 sawfish.wm.state.ignored
			 sawfish.wm.server))

;; create the exports from sawfish.wm
(open-structures '(sawfish.wm.colors
		   sawfish.wm.commands
		   sawfish.wm.cursors
		   sawfish.wm.custom
		   sawfish.wm.events
		   sawfish.wm.focus
		   sawfish.wm.fonts
		   sawfish.wm.frames
		   sawfish.wm.gaol
		   sawfish.wm.images
		   sawfish.wm.misc
		   sawfish.wm.placement
		   sawfish.wm.session.init
		   sawfish.wm.server
		   sawfish.wm.stacking
		   sawfish.wm.viewport
		   sawfish.wm.window-anim
		   sawfish.wm.windows
		   sawfish.wm.workspace
		   sawfish.wm.state.iconify
		   sawfish.wm.state.shading
		   sawfish.wm.state.transient
		   sawfish.wm.state.ignored))

(export-bindings (parse-interface
		  '(compound-interface
		    (structure-interface sawfish.wm.colors)
		    (structure-interface sawfish.wm.commands)
		    (structure-interface sawfish.wm.cursors)
		    (structure-interface sawfish.wm.custom)
		    (structure-interface sawfish.wm.events)
		    (structure-interface sawfish.wm.focus)
		    (structure-interface sawfish.wm.fonts)
		    (structure-interface sawfish.wm.frames)
		    (structure-interface sawfish.wm.gaol)
		    (structure-interface sawfish.wm.images)
		    (structure-interface sawfish.wm.misc)
		    (structure-interface sawfish.wm.placement)
		    (structure-interface sawfish.wm.session.init)
		    (structure-interface sawfish.wm.server)
		    (structure-interface sawfish.wm.stacking)
		    (structure-interface sawfish.wm.viewport)
		    (structure-interface sawfish.wm.window-anim)
		    (structure-interface sawfish.wm.windows)
		    (structure-interface sawfish.wm.workspace)
		    (structure-interface sawfish.wm.state.iconify)
		    (structure-interface sawfish.wm.state.shading)
		    (structure-interface sawfish.wm.state.transient)
		    (structure-interface sawfish.wm.state.ignored))))

(let ((sawfish-load-all (lambda (s)
			  ;; ensure files are loaded in the correct structure
			  (load-all s (lambda (f) (load f nil t))))))

  ;; all rep-based programs should do this
  (sawfish-load-all "sawfish/wm/autoload")
  (sawfish-load-all (concat "os-" (symbol-name operating-system))))

(let ((session-id (or (get-command-line-option "--sm-client-id" t)
		      ;; may be passed through from the default GNOME session
		      (get-command-line-option "-clientId" t)))
      (session-prefix (get-command-line-option "--sm-prefix" t)))

  ;; do user-level initialization
  (load "sawfish/wm/user")

  ;; now connect with the session manager; gsm requires that apps don't
  ;; connect until they're ready to handle the later priority levels
  (when (and (not batch-mode) (getenv "SESSION_MANAGER"))
    (sm-init session-id session-prefix)))