ignored show request for invalid window and override_redirect window. the wm only...
[platform/core/uifw/e17.git] / x-ui.sh
1 #!/usr/bin/env bash
2
3 DPI=${DPI:-142}
4 SCREEN=${SCREEN:-640x480}
5 PROFILE=${PROFILE:-standard}
6 VERBOSE=${VERBOSE:-0}
7 VALGRIND=${VALGRIND}
8 VALGRIND_LOG_FILE=${VALGRIND_LOG_FILE}
9 MASSIF=${MASSIF}
10 CALLGRIND=${CALLGRIND}
11 HOST_CURSOR=${HOST_CURSOR}
12 TEST_HOME=${TEST_HOME}
13
14 xinerama_auto_modes()
15 {
16     local x y screen_res screen_res_x screen_res_y div_x div_y single_res single_res_x single_res_y walker_x walker_y
17
18     div_x="${1%x*}"
19     div_y="${1#*x}"
20
21
22     # get your display resolution
23     screen_res="$( xdpyinfo | grep dimensions | awk '{print $2}' )"
24     screen_res_x="${screen_res%x*}"
25     screen_res_y="${screen_res#*x}"
26
27     # add some offset for your window-borders
28     screen_res_x="$(( ${screen_res_x} - 20 ))"
29     screen_res_y="$(( ${screen_res_y} - 40 ))"
30
31     # set size for xephir
32     SCREEN="${screen_res_x}x${screen_res_y}"
33
34
35     # which size per screen ?
36     single_res_x="$(( ${screen_res_x} / ${div_x} ))"
37     single_res_y="$(( ${screen_res_y} / ${div_y} ))"
38     single_res="${single_res_x}x${single_res_y}"
39
40
41     walker_x=0
42     walker_y=0
43
44
45     for (( y=0 ; $y < ${div_y} ; y++ )) ; do
46         for (( x=0 ; $x < ${div_x} ; x++ )) ; do
47             # add a new horizontal xinerama screen
48             xinerama_auto_args="${xinerama_auto_args} -fake-xinerama-screen ${single_res}+${walker_x}+${walker_y}"
49             walker_x="$(( ${walker_x} + ${single_res_x} ))"
50         done
51         # previous loop finished, set horizontal back to 0
52         walker_x=0
53         # add a new vertical xinerama screen
54         walker_y="$(( ${walker_y} + ${single_res_y} ))"
55     done
56
57     #echo "${xinerama_auto_args}"
58 }
59
60 show_help()
61 {
62     cat <<HELP_EOF
63 Usage:
64
65    $0 [options]
66
67 where options are:
68
69   -c, --host-cursor        Uses host-cursor, otherwise uses Xephyr's.
70   -d, --dpi=NUMBER         states the dots-per-inch to be used.
71   -s, --screen=SPEC        WIDTHxHEIGHT[xDEPTH] to be used.
72   -x, --fxs=WxH+X+Y        Fake xinerama screen resolution
73                            (can be applied repeatedly)
74   -ax 2x3                  Automatic set of fake xineramas, 2 horizontal
75                            screens per 3 of vertical ones
76   -p, --profile=NAME       Enlightenment profile name.
77   -e, --empty-home[=PATH]  Run with \$HOME being a new, empty directory at /tmp
78
79
80 Debugger options:
81
82   --valgrind=MODE      Run under valgrind to check for memory problems.
83                        Same value as enlightenment_start, mode is "OR" of:
84                           1 = plain valgrind to catch crashes (default)
85                           2 = trace children (thumbnailer, efm slaves, ...)
86                           4 = check leak
87                           8 = show reachable after processes finish.
88                         all = all of above
89   --valgrind-log-file=FILENAME
90                        Save valgrind log to file, see valgrind's
91                        --log-file for details.
92   --massif             Run under massif valgrind tool.
93   --callgrind          Run under callgrind valgrind tool.
94
95
96 Misc options:
97   -v, --verbose            Be verbose about what is being done.
98   -h, --help               Show this help.
99
100
101 Useful or common options:
102
103     --dpi=142 --screen=240x320x16
104     --dpi=142 --screen=320x240x16
105     --dpi=186 --screen=272x480x16
106     --dpi=186 --screen=480x272x16
107     --dpi=181 --screen=320x320x16
108     --dpi=183 --screen=320x480x16 --host-cursor
109     --dpi=183 --screen=480x320x16 --host-cursor
110     --dpi=183 --screen=480x800x16
111     --dpi=183 --screen=800x480x16
112     --dpi=284 --screen=480x640x16
113     --dpi=284 --screen=640x480x16 --host-cursor
114     --dpi=183 --screen=960x400x16 --host-cursor
115     --dpi=284 --screen=480x800 --host-cursor
116     --dpi=284 --screen=480x640
117     --dpi=284 --screen=640x480
118     --dpi=181 --screen=320x320
119     --dpi=186 --screen=272x480
120     --dpi=142 --screen=240x320
121     --dpi=142 --screen=240x240 --host-cursor
122
123 HELP_EOF
124 }
125
126 while [ $# -gt 0 ]; do
127     arg=$1
128     shift
129     option=`echo "'$arg'" | cut -d'=' -f1 | tr -d "'"`
130     value=`echo "'$arg'" | cut -d'=' -f2- | tr -d "'"`
131     if [ x"$value" = x"$option" ]; then
132         value=""
133     fi
134
135     case $option in
136         -h|-help|--help)
137             show_help
138             exit 0
139             ;;
140         -v|-verbose|--verbose)
141             VERBOSE=1
142             ;;
143         -e|-empty-home|--empty-home)
144             if [ -z "$value" ]; then
145                 TEST_HOME="/tmp/e-test-${USER:-$UID}"
146             else
147                 TEST_HOME="$value"
148             fi
149             ;;
150         -d|-dpi|--dpi)
151             if [ -z "$value" ]; then
152                 value=$1
153                 shift
154             fi
155             DPI=$value
156             ;;
157         -s|-screen|--screen)
158             if [ -z "$value" ]; then
159                 value=$1
160                 shift
161             fi
162             SCREEN=$value
163             ;;
164         -x|-fxs|--fxs)
165             if [ -z "$value" ]; then
166                 value=$1
167                 shift
168             fi
169             FAKE_XINERAMA_SCREEN="$FAKE_XINERAMA_SCREEN $value"
170             ;;
171         -p|-profile|--profile)
172             if [ -z "$value" ]; then
173                 value=$1
174                 shift
175             fi
176             PROFILE=$value
177             ;;
178         -c|-host-cursor|--host-cursor)
179             HOST_CURSOR="-host-cursor"
180             ;;
181         -valgrind|--valgrind)
182             if [ -z "$value" ]; then
183                 value=$1
184                 shift
185             fi
186             VALGRIND=$value
187             ;;
188         -valgrind-log-file|--valgrind-log-file)
189             if [ -z "$value" ]; then
190                 value=$1
191                 shift
192             fi
193             VALGRIND_LOG_FILE=$value
194             ;;
195         -massif|--massif)
196             MASSIF="1"
197             ;;
198         -callgrind|--callgrind)
199             CALLGRIND="1"
200             ;;
201         -ax|-auto-xinerama|--auto-xinerama)
202             if [ -z "$value" ]; then
203                 value=$1
204                 shift
205             fi
206             xinerama_auto_modes $value
207             ;;
208         *)
209             echo "Unknown option: $option" 1>&2
210             ;;
211     esac
212 done
213
214 debuggers=0
215
216 if [ ! -z "$MASSIF" ]; then
217     DEBUGGER="-massif"
218     ((debuggers++))
219 fi
220
221 if [ ! -z "$CALLGRIND" ]; then
222     DEBUGGER="-callgrind"
223     ((debuggers++))
224 fi
225
226 if [ ! -z "$VALGRIND" ]; then
227     DEBUGGER="-valgrind=$VALGRIND"
228     ((debuggers++))
229 fi
230
231 if [ $debuggers -gt 1 ]; then
232     echo "WARNING: more than one debugger specified. Using $DEBUGGER" 1>&2
233 fi
234
235 if [ ! -z "$FAKE_XINERAMA_SCREEN" ]; then
236         for fxsm in $FAKE_XINERAMA_SCREEN; do
237                 E_OPTIONS="$E_OPTIONS -fake-xinerama-screen $fxsm"
238         done
239 fi
240
241 if [ ! -z "$TEST_HOME" ]; then
242     if [ "${TEST_HOME#/tmp/}" != "$TEST_HOME" ]; then
243         # just delete if inside /tmp
244         rm -fr "$TEST_HOME/"
245     fi
246     mkdir -p "$TEST_HOME"
247 fi
248
249 unset E_RESTART E_START E_IPC_SOCKET E_START_TIME E_CONF_PROFILE E_PREFIX
250
251 if [ $VERBOSE -ne 0 ]; then
252     cat <<EOF
253 Using:
254
255    DPI=$DPI
256    SCREEN=$SCREEN
257    FAKE_XINERAMA_SCREEN=$FAKE_XINERAMA_SCREEN
258    PROFILE=$PROFILE
259    HOST_CURSOR=$HOST_CURSOR
260    DEBUGGER=$DEBUGGER
261       VALGRIND=$VALGRIND
262       VALGRIND_LOG_FILE=$VALGRIND_LOG_FILE
263       MASSIF=$MASSIF
264       CALLGRIND=$CALLGRIND
265    TEST_HOME=$TEST_HOME
266 EOF
267     set -x
268 fi
269
270 Xephyr :1 -nolisten tcp -noreset -ac -br -dpi $DPI -screen $SCREEN $HOST_CURSOR &
271
272 sleep 1
273 export DISPLAY=:1
274 [ ! -z "$TEST_HOME" ] && export HOME="$TEST_HOME"
275 enlightenment_start \
276     -no-precache \
277     -i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it \
278     -profile $PROFILE \
279         $E_OPTIONS $xinerama_auto_args \
280     $DEBUGGER