win: Implement unresizable mode (fixed size windows)

This sends a signal to the CSD frame to hide the bottom
bar and disable the resize borders.
This commit is contained in:
Jean-Philippe Andre 2016-11-21 15:48:09 +09:00
parent c31a70a4f5
commit 5f6673f623
3 changed files with 53 additions and 25 deletions

View File

@ -480,8 +480,18 @@ group { name: "elm/border/base/default";
color: 0 0 0 0;
}
}
rect { "elm.event.resize.tl";
rect { "top_resize_clip";
clip: "top_clip";
desc { "default";
rel.to: "top_clip";
}
desc { "hidden";
inherit: "default";
hid;
}
}
rect { "elm.event.resize.tl";
clip: "top_resize_clip";
desc { "default";
rel.to: "top_clip";
rel2.relative: 0.0 0.0;
@ -493,7 +503,7 @@ group { name: "elm/border/base/default";
desc { "hidden"; inherit: "default"; hid; }
}
rect { "elm.event.resize.t";
clip: "top_clip";
clip: "top_resize_clip";
desc { "default";
rel1.relative: 1.0 0.0;
rel1.to_y: "top_clip";
@ -509,7 +519,7 @@ group { name: "elm/border/base/default";
desc { "hidden"; inherit: "default"; hid; }
}
rect { "elm.event.resize.tr";
clip: "top_clip";
clip: "top_resize_clip";
desc { "default";
rel.to: "top_clip";
rel1.relative: 1.0 0.0;
@ -613,8 +623,9 @@ group { name: "elm/border/base/default";
}
}
#define BORDERLESS 1
#define MAXIMIZED 2
#define BORDERLESS 1
#define MAXIMIZED 2
#define UNRESIZABLE 4
#define SET_MODE(a) script { new m = get_int(border_mode); m |= (a); set_int(border_mode, m); eval_mode(m); }
#define UNSET_MODE(a) script { new m = get_int(border_mode); m &= ~(a); set_int(border_mode, m); eval_mode(m); }
@ -622,10 +633,12 @@ group { name: "elm/border/base/default";
script {
public border_mode;
public eval_mode(m) {
if (m & (BORDERLESS | MAXIMIZED)) {
if (m & (BORDERLESS | MAXIMIZED | UNRESIZABLE)) {
set_state(PART:"bottom_clip", "hidden", 0.0);
set_state(PART:"top_resize_clip", "hidden", 0.0);
} else {
set_state(PART:"bottom_clip", "default", 0.0);
set_state(PART:"top_resize_clip", "default", 0.0);
}
}
}
@ -643,6 +656,14 @@ group { name: "elm/border/base/default";
after: "borderless,off";
}
program { "borderless,off"; UNSET_MODE(BORDERLESS); }
program {
signal: "elm,state,unresizable,on"; source: "elm";
SET_MODE(UNRESIZABLE);
}
program {
signal: "elm,state,unresizable,off"; source: "elm";
UNSET_MODE(UNRESIZABLE);
}
program {
signal: "elm,state,shadow,on"; source: "elm";
action: STATE_SET "default";
@ -748,11 +769,8 @@ group { name: "elm/border/base/default";
}
program {
signal: "elm,state,maximize*"; source: "elm";
action: STATE_SET "hidden";
targets: "elm.event.resize.t" "elm.event.resize.tl" "elm.event.resize.tr" "bottom_clip";
after: "maximized,on";
SET_MODE(MAXIMIZED);
}
program { "maximized,on"; SET_MODE(MAXIMIZED); }
program {
signal: "elm,state,unmaximize*"; source: "elm";
action: STATE_SET "default";
@ -760,11 +778,8 @@ group { name: "elm/border/base/default";
}
program {
signal: "elm,state,unmaximize*"; source: "elm";
action: STATE_SET "default";
targets: "elm.event.resize.t" "elm.event.resize.tl" "elm.event.resize.tr" "bottom_clip";
after: "maximized,off";
UNSET_MODE(MAXIMIZED);
}
program { "maximized,off"; UNSET_MODE(MAXIMIZED); }
/* application desktop menu */
program { name: "show_menu";
@ -843,7 +858,7 @@ group { name: "elm/border/base/default";
signal: "mouse,out"; source: "elm.event.resize.t";
action: SIGNAL_EMIT "elm,action,resize,hide" "elm.event.resize.t";
}
program { name: "resize_t_down";
program {
signal: "mouse,down,1"; source: "elm.event.resize.t";
action: SIGNAL_EMIT "elm,action,resize,start" "elm.event.resize.t";
}
@ -914,6 +929,7 @@ group { name: "elm/border/base/default";
}
}
#undef UNRESIZABLE
#undef BORDERLESS
#undef MAXIMIZED
#undef SET_MODE

View File

@ -42,8 +42,8 @@ _bt2_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_
lb = efl_add(EFL_UI_TEXT_CLASS, dia,
efl_text_set(efl_added, "This is a non-resizable dialog."),
efl_gfx_size_hint_min_set(efl_added, 200, 150),
efl_gfx_size_hint_max_set(efl_added, 200, 150),
efl_gfx_size_hint_min_set(efl_added, 300, 150),
efl_gfx_size_hint_max_set(efl_added, 300, 150),
efl_gfx_size_hint_weight_set(efl_added, 0, 0));
// Swallow in the label as the default content, this will make it visible.

View File

@ -247,12 +247,14 @@ struct _Efl_Ui_Win_Data
Eina_Bool need_borderless : 1;
Eina_Bool need_bg_solid : 1;
Eina_Bool need_menu : 1;
Eina_Bool need_unresizable : 1;
Eina_Bool cur_borderless : 1;
Eina_Bool cur_shadow : 1;
Eina_Bool cur_focus : 1;
Eina_Bool cur_maximized : 1;
Eina_Bool cur_bg_solid : 1;
Eina_Bool cur_menu : 1;
Eina_Bool cur_unresizable : 1;
} csd;
struct {
@ -848,15 +850,15 @@ static void
_elm_win_obj_callback_changed_size_hints(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
ELM_WIN_DATA_GET(data, sd);
Evas_Coord w, h;
Evas_Coord minw, minh, maxw, maxh;
efl_gfx_size_hint_combined_min_get(obj, &w, &h);
TRAP(sd, size_min_set, w, h);
efl_gfx_size_hint_combined_min_get(obj, &minw, &minh);
efl_gfx_size_hint_max_get(obj, &maxw, &maxh);
if (maxw < 1) maxw = -1;
if (maxh < 1) maxh = -1;
evas_object_size_hint_max_get(obj, &w, &h);
if (w < 1) w = -1;
if (h < 1) h = -1;
TRAP(sd, size_max_set, w, h);
TRAP(sd, size_min_set, minw, minh);
TRAP(sd, size_max_set, maxw, maxh);
}
/* end of elm-win specific associate */
@ -3254,6 +3256,7 @@ _elm_win_resize_objects_eval(Evas_Object *obj)
{
ELM_WIN_DATA_GET(obj, sd);
Evas_Coord w, h, minw, minh, maxw, maxh;
Eina_Bool unresizable;
double wx, wy;
efl_gfx_size_hint_combined_min_get(sd->legacy.edje, &minw, &minh);
@ -3266,6 +3269,13 @@ _elm_win_resize_objects_eval(Evas_Object *obj)
if (!wy) maxh = minh;
else maxh = 32767;
unresizable = ((minw == maxw) && (minh == maxh));
if (sd->csd.need_unresizable != unresizable)
{
sd->csd.need_unresizable = unresizable;
_elm_win_frame_style_update(sd, 0, 1);
}
if (sd->frame_obj)
{
int fw, fh;
@ -4098,7 +4108,7 @@ _elm_win_frame_add(Efl_Ui_Win_Data *sd, const char *style)
static void
_elm_win_frame_style_update(Efl_Ui_Win_Data *sd, Eina_Bool force_emit, Eina_Bool calc)
{
Eina_Bool borderless, maximized, shadow, focus, bg_solid, menu;
Eina_Bool borderless, maximized, shadow, focus, bg_solid, menu, unresizable;
Eina_Bool changed = EINA_FALSE;
if (!sd->frame_obj)
@ -4116,6 +4126,7 @@ _elm_win_frame_style_update(Efl_Ui_Win_Data *sd, Eina_Bool force_emit, Eina_Bool
shadow = sd->csd.need_shadow && (!sd->fullscreen) && (!sd->maximized);
focus = ecore_evas_focus_get(sd->ee);
bg_solid = sd->csd.need_bg_solid;
unresizable = sd->csd.need_unresizable;
menu = sd->csd.need_menu;
#define STATE_SET(state, s1, s2) do { \
@ -4132,6 +4143,7 @@ _elm_win_frame_style_update(Efl_Ui_Win_Data *sd, Eina_Bool force_emit, Eina_Bool
STATE_SET(maximized, "elm,state,maximized", "elm,state,unmaximized");
STATE_SET(focus, "elm,action,focus", "elm,action,unfocus");
STATE_SET(bg_solid, "elm,state,background,solid,on", "elm,state,background,solid,off");
STATE_SET(unresizable, "elm,state,unresizable,on", "elm,state,unresizable,off");
STATE_SET(menu, "elm,action,show_menu", "elm,action,hide_menu");
#undef STATE_SET