avoid size creep during font options changes by remembering size at

start and any "suspected" real resizing by the user.



SVN revision: 73156
This commit is contained in:
Carsten Haitzler 2012-07-02 12:06:44 +00:00
parent 5ecbbb7f23
commit 4fd2814c02
2 changed files with 105 additions and 7 deletions

View File

@ -168,11 +168,15 @@ static const Ecore_Getopt options = {
"Use the named edje theme or path to theme file."),
ECORE_GETOPT_STORE_STR('b', "background",
"Use the named file as a background wallpaper."),
ECORE_GETOPT_CHOICE(0, "video-module",
ECORE_GETOPT_STORE_STR('g', "geometry",
"Terminal geometry to use (eg 80x24 or 80x24+50+20 etc.)."),
ECORE_GETOPT_CHOICE('v', "video-module",
"Set emotion module to use.",
emotion_choices),
ECORE_GETOPT_STORE_BOOL(0, "video-mute",
ECORE_GETOPT_STORE_BOOL('m', "video-mute",
"Set mute mode for video playback."),
ECORE_GETOPT_STORE_BOOL('F', "fullscreen",
"Go into fullscreen mode from start."),
ECORE_GETOPT_VERSION('V', "version"),
ECORE_GETOPT_COPYRIGHT('C', "copyright"),
ECORE_GETOPT_LICENSE('L', "license"),
@ -187,15 +191,19 @@ elm_main(int argc, char **argv)
char *cmd = NULL;
char *theme = NULL;
char *background = NULL;
char *geometry = NULL;
char *video_module = NULL;
Eina_Bool video_mute = 0xff; /* unset */
Eina_Bool fullscreen = 0xff; /* unset */
Eina_Bool quit_option = EINA_FALSE;
Ecore_Getopt_Value values[] = {
ECORE_GETOPT_VALUE_STR(cmd),
ECORE_GETOPT_VALUE_STR(theme),
ECORE_GETOPT_VALUE_STR(background),
ECORE_GETOPT_VALUE_STR(geometry),
ECORE_GETOPT_VALUE_STR(video_module),
ECORE_GETOPT_VALUE_BOOL(video_mute),
ECORE_GETOPT_VALUE_BOOL(fullscreen),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
@ -205,6 +213,9 @@ elm_main(int argc, char **argv)
int args, retval = EXIT_SUCCESS;
Config *config;
Evas_Object *o;
int pos_set = 0, size_set = 0;
int pos_x = 0, pos_y = 0;
int size_w = 1, size_h = 1;
_log_domain = eina_log_domain_register("terminology", NULL);
if (_log_domain < 0)
@ -280,11 +291,67 @@ elm_main(int argc, char **argv)
config->temporary = EINA_TRUE;
}
if (geometry)
{
if (sscanf(geometry,"%ix%i+%i+%i", &size_w, &size_h, &pos_x, &pos_y) == 4)
{
pos_set = 1;
size_set = 1;
}
else if (sscanf(geometry,"%ix%i-%i+%i", &size_w, &size_h, &pos_x, &pos_y) == 4)
{
pos_set = 1;
size_set = 1;
}
else if (sscanf(geometry,"%ix%i-%i-%i", &size_w, &size_h, &pos_x, &pos_y) == 4)
{
pos_set = 1;
size_set = 1;
}
else if (sscanf(geometry,"%ix%i+%i-%i", &size_w, &size_h, &pos_x, &pos_y) == 4)
{
pos_set = 1;
size_set = 1;
}
else if (sscanf(geometry,"%ix%i", &size_w, &size_h) == 2)
{
size_set = 1;
}
else if (sscanf(geometry,"+%i+%i", &pos_x, &pos_y) == 2)
{
pos_set = 1;
}
else if (sscanf(geometry,"-%i+%i", &pos_x, &pos_y) == 2)
{
pos_set = 1;
}
else if (sscanf(geometry,"+%i-%i", &pos_x, &pos_y) == 2)
{
pos_set = 1;
}
else if (sscanf(geometry,"-%i-%i", &pos_x, &pos_y) == 2)
{
pos_set = 1;
}
}
if (!size_set)
{
size_w = 80;
size_h = 24;
}
// set an env so terminal apps can detect they are in terminology :)
putenv("TERMINOLOGY=1");
win = tg_win_add();
elm_win_conformant_set(win, EINA_TRUE);
if (fullscreen != 0xff)
{
if (fullscreen) elm_win_fullscreen_set(win, EINA_TRUE);
}
conform = o = elm_conformant_add(win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
@ -304,7 +371,9 @@ elm_main(int argc, char **argv)
elm_object_content_set(conform, o);
evas_object_show(o);
term = o = termio_add(win, config, cmd, 80, 24);
if (pos_set) evas_object_move(win, pos_x, pos_y);
term = o = termio_add(win, config, cmd, size_w, size_h);
termio_win_set(o, win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);

View File

@ -21,22 +21,24 @@ struct _Font
static Eina_List *fonts = NULL;
static Eina_Hash *fonthash = NULL;
static Evas_Coord tsize_w = 0, tsize_h = 0;
static int expecting_resize = 0;
static void
_update_sizing(Evas_Object *term)
{
Evas_Coord ow = 0, oh = 0, mw = 1, mh = 1, w, h;
Evas_Coord mw = 1, mh = 1, w, h;
evas_object_data_del(term, "sizedone");
termio_config_update(term);
evas_object_geometry_get(term, NULL, NULL, &ow, &oh);
evas_object_size_hint_min_get(term, &mw, &mh);
if (mw < 1) mw = 1;
if (mh < 1) mh = 1;
w = ow / mw;
h = oh / mh;
w = tsize_w / mw;
h = tsize_h / mh;
evas_object_data_del(term, "sizedone");
evas_object_size_hint_request_set(term, w * mw, h * mh);
expecting_resize = 1;
}
static void
@ -166,6 +168,26 @@ _cb_op_font_group_text_get(void *data, Evas_Object *obj __UNUSED__, const char *
return strdup(data);
}
static void
_cb_term_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
{
Evas_Object *term = data;
if (expecting_resize)
{
expecting_resize = 0;
return;
}
evas_object_geometry_get(term, NULL, NULL, &tsize_w, &tsize_h);
}
static void
_cb_font_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
{
Evas_Object *term = data;
evas_object_event_callback_del_full(term, EVAS_CALLBACK_RESIZE,
_cb_term_resize, term);
}
void
options_font_clear(void)
{
@ -331,4 +353,11 @@ options_font(Evas_Object *opbox, Evas_Object *term)
evas_object_size_hint_weight_set(opbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(opbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(o);
expecting_resize = 0;
evas_object_geometry_get(term, NULL, NULL, &tsize_w, &tsize_h);
evas_object_event_callback_add(term, EVAS_CALLBACK_RESIZE,
_cb_term_resize, term);
evas_object_event_callback_add(opbox, EVAS_CALLBACK_DEL,
_cb_font_del, term);
}