summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-07-02 12:06:44 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-07-02 12:06:44 +0000
commit4fd2814c02e21c40b92bb2b47477a2c410d7d52b (patch)
treee3c63cc3913810c6ed138477318c714e32cc15b2 /src/bin
parent5ecbbb7f2315650b13a1b41b94aee20a3f003f3c (diff)
avoid size creep during font options changes by remembering size at
start and any "suspected" real resizing by the user. SVN revision: 73156
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/main.c75
-rw-r--r--src/bin/options_font.c37
2 files changed, 105 insertions, 7 deletions
diff --git a/src/bin/main.c b/src/bin/main.c
index a17a0bd..52ea464 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -168,11 +168,15 @@ static const Ecore_Getopt options = {
168 "Use the named edje theme or path to theme file."), 168 "Use the named edje theme or path to theme file."),
169 ECORE_GETOPT_STORE_STR('b', "background", 169 ECORE_GETOPT_STORE_STR('b', "background",
170 "Use the named file as a background wallpaper."), 170 "Use the named file as a background wallpaper."),
171 ECORE_GETOPT_CHOICE(0, "video-module", 171 ECORE_GETOPT_STORE_STR('g', "geometry",
172 "Terminal geometry to use (eg 80x24 or 80x24+50+20 etc.)."),
173 ECORE_GETOPT_CHOICE('v', "video-module",
172 "Set emotion module to use.", 174 "Set emotion module to use.",
173 emotion_choices), 175 emotion_choices),
174 ECORE_GETOPT_STORE_BOOL(0, "video-mute", 176 ECORE_GETOPT_STORE_BOOL('m', "video-mute",
175 "Set mute mode for video playback."), 177 "Set mute mode for video playback."),
178 ECORE_GETOPT_STORE_BOOL('F', "fullscreen",
179 "Go into fullscreen mode from start."),
176 ECORE_GETOPT_VERSION('V', "version"), 180 ECORE_GETOPT_VERSION('V', "version"),
177 ECORE_GETOPT_COPYRIGHT('C', "copyright"), 181 ECORE_GETOPT_COPYRIGHT('C', "copyright"),
178 ECORE_GETOPT_LICENSE('L', "license"), 182 ECORE_GETOPT_LICENSE('L', "license"),
@@ -187,15 +191,19 @@ elm_main(int argc, char **argv)
187 char *cmd = NULL; 191 char *cmd = NULL;
188 char *theme = NULL; 192 char *theme = NULL;
189 char *background = NULL; 193 char *background = NULL;
194 char *geometry = NULL;
190 char *video_module = NULL; 195 char *video_module = NULL;
191 Eina_Bool video_mute = 0xff; /* unset */ 196 Eina_Bool video_mute = 0xff; /* unset */
197 Eina_Bool fullscreen = 0xff; /* unset */
192 Eina_Bool quit_option = EINA_FALSE; 198 Eina_Bool quit_option = EINA_FALSE;
193 Ecore_Getopt_Value values[] = { 199 Ecore_Getopt_Value values[] = {
194 ECORE_GETOPT_VALUE_STR(cmd), 200 ECORE_GETOPT_VALUE_STR(cmd),
195 ECORE_GETOPT_VALUE_STR(theme), 201 ECORE_GETOPT_VALUE_STR(theme),
196 ECORE_GETOPT_VALUE_STR(background), 202 ECORE_GETOPT_VALUE_STR(background),
203 ECORE_GETOPT_VALUE_STR(geometry),
197 ECORE_GETOPT_VALUE_STR(video_module), 204 ECORE_GETOPT_VALUE_STR(video_module),
198 ECORE_GETOPT_VALUE_BOOL(video_mute), 205 ECORE_GETOPT_VALUE_BOOL(video_mute),
206 ECORE_GETOPT_VALUE_BOOL(fullscreen),
199 ECORE_GETOPT_VALUE_BOOL(quit_option), 207 ECORE_GETOPT_VALUE_BOOL(quit_option),
200 ECORE_GETOPT_VALUE_BOOL(quit_option), 208 ECORE_GETOPT_VALUE_BOOL(quit_option),
201 ECORE_GETOPT_VALUE_BOOL(quit_option), 209 ECORE_GETOPT_VALUE_BOOL(quit_option),
@@ -205,6 +213,9 @@ elm_main(int argc, char **argv)
205 int args, retval = EXIT_SUCCESS; 213 int args, retval = EXIT_SUCCESS;
206 Config *config; 214 Config *config;
207 Evas_Object *o; 215 Evas_Object *o;
216 int pos_set = 0, size_set = 0;
217 int pos_x = 0, pos_y = 0;
218 int size_w = 1, size_h = 1;
208 219
209 _log_domain = eina_log_domain_register("terminology", NULL); 220 _log_domain = eina_log_domain_register("terminology", NULL);
210 if (_log_domain < 0) 221 if (_log_domain < 0)
@@ -279,12 +290,68 @@ elm_main(int argc, char **argv)
279 config->mute = video_mute; 290 config->mute = video_mute;
280 config->temporary = EINA_TRUE; 291 config->temporary = EINA_TRUE;
281 } 292 }
293
294 if (geometry)
295 {
296 if (sscanf(geometry,"%ix%i+%i+%i", &size_w, &size_h, &pos_x, &pos_y) == 4)
297 {
298 pos_set = 1;
299 size_set = 1;
300 }
301 else if (sscanf(geometry,"%ix%i-%i+%i", &size_w, &size_h, &pos_x, &pos_y) == 4)
302 {
303 pos_set = 1;
304 size_set = 1;
305 }
306 else if (sscanf(geometry,"%ix%i-%i-%i", &size_w, &size_h, &pos_x, &pos_y) == 4)
307 {
308 pos_set = 1;
309 size_set = 1;
310 }
311 else if (sscanf(geometry,"%ix%i+%i-%i", &size_w, &size_h, &pos_x, &pos_y) == 4)
312 {
313 pos_set = 1;
314 size_set = 1;
315 }
316 else if (sscanf(geometry,"%ix%i", &size_w, &size_h) == 2)
317 {
318 size_set = 1;
319 }
320 else if (sscanf(geometry,"+%i+%i", &pos_x, &pos_y) == 2)
321 {
322 pos_set = 1;
323 }
324 else if (sscanf(geometry,"-%i+%i", &pos_x, &pos_y) == 2)
325 {
326 pos_set = 1;
327 }
328 else if (sscanf(geometry,"+%i-%i", &pos_x, &pos_y) == 2)
329 {
330 pos_set = 1;
331 }
332 else if (sscanf(geometry,"-%i-%i", &pos_x, &pos_y) == 2)
333 {
334 pos_set = 1;
335 }
336 }
337 if (!size_set)
338 {
339 size_w = 80;
340 size_h = 24;
341 }
282 342
283 // set an env so terminal apps can detect they are in terminology :) 343 // set an env so terminal apps can detect they are in terminology :)
284 putenv("TERMINOLOGY=1"); 344 putenv("TERMINOLOGY=1");
285 345
286 win = tg_win_add(); 346 win = tg_win_add();
287 347
348 elm_win_conformant_set(win, EINA_TRUE);
349
350 if (fullscreen != 0xff)
351 {
352 if (fullscreen) elm_win_fullscreen_set(win, EINA_TRUE);
353 }
354
288 conform = o = elm_conformant_add(win); 355 conform = o = elm_conformant_add(win);
289 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 356 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
290 evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); 357 evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
@@ -304,7 +371,9 @@ elm_main(int argc, char **argv)
304 elm_object_content_set(conform, o); 371 elm_object_content_set(conform, o);
305 evas_object_show(o); 372 evas_object_show(o);
306 373
307 term = o = termio_add(win, config, cmd, 80, 24); 374 if (pos_set) evas_object_move(win, pos_x, pos_y);
375
376 term = o = termio_add(win, config, cmd, size_w, size_h);
308 termio_win_set(o, win); 377 termio_win_set(o, win);
309 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 378 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
310 evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); 379 evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
diff --git a/src/bin/options_font.c b/src/bin/options_font.c
index 4f4b644..5c93e2a 100644
--- a/src/bin/options_font.c
+++ b/src/bin/options_font.c
@@ -21,22 +21,24 @@ struct _Font
21 21
22static Eina_List *fonts = NULL; 22static Eina_List *fonts = NULL;
23static Eina_Hash *fonthash = NULL; 23static Eina_Hash *fonthash = NULL;
24static Evas_Coord tsize_w = 0, tsize_h = 0;
25static int expecting_resize = 0;
24 26
25static void 27static void
26_update_sizing(Evas_Object *term) 28_update_sizing(Evas_Object *term)
27{ 29{
28 Evas_Coord ow = 0, oh = 0, mw = 1, mh = 1, w, h; 30 Evas_Coord mw = 1, mh = 1, w, h;
29 31
30 evas_object_data_del(term, "sizedone"); 32 evas_object_data_del(term, "sizedone");
31 termio_config_update(term); 33 termio_config_update(term);
32 evas_object_geometry_get(term, NULL, NULL, &ow, &oh);
33 evas_object_size_hint_min_get(term, &mw, &mh); 34 evas_object_size_hint_min_get(term, &mw, &mh);
34 if (mw < 1) mw = 1; 35 if (mw < 1) mw = 1;
35 if (mh < 1) mh = 1; 36 if (mh < 1) mh = 1;
36 w = ow / mw; 37 w = tsize_w / mw;
37 h = oh / mh; 38 h = tsize_h / mh;
38 evas_object_data_del(term, "sizedone"); 39 evas_object_data_del(term, "sizedone");
39 evas_object_size_hint_request_set(term, w * mw, h * mh); 40 evas_object_size_hint_request_set(term, w * mw, h * mh);
41 expecting_resize = 1;
40} 42}
41 43
42static void 44static void
@@ -166,6 +168,26 @@ _cb_op_font_group_text_get(void *data, Evas_Object *obj __UNUSED__, const char *
166 return strdup(data); 168 return strdup(data);
167} 169}
168 170
171static void
172_cb_term_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
173{
174 Evas_Object *term = data;
175 if (expecting_resize)
176 {
177 expecting_resize = 0;
178 return;
179 }
180 evas_object_geometry_get(term, NULL, NULL, &tsize_w, &tsize_h);
181}
182
183static void
184_cb_font_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
185{
186 Evas_Object *term = data;
187 evas_object_event_callback_del_full(term, EVAS_CALLBACK_RESIZE,
188 _cb_term_resize, term);
189}
190
169void 191void
170options_font_clear(void) 192options_font_clear(void)
171{ 193{
@@ -331,4 +353,11 @@ options_font(Evas_Object *opbox, Evas_Object *term)
331 evas_object_size_hint_weight_set(opbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 353 evas_object_size_hint_weight_set(opbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
332 evas_object_size_hint_align_set(opbox, EVAS_HINT_FILL, EVAS_HINT_FILL); 354 evas_object_size_hint_align_set(opbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
333 evas_object_show(o); 355 evas_object_show(o);
356
357 expecting_resize = 0;
358 evas_object_geometry_get(term, NULL, NULL, &tsize_w, &tsize_h);
359 evas_object_event_callback_add(term, EVAS_CALLBACK_RESIZE,
360 _cb_term_resize, term);
361 evas_object_event_callback_add(opbox, EVAS_CALLBACK_DEL,
362 _cb_font_del, term);
334} 363}