forked from enlightenment/enlightenment
Tiling2: Fixed coding conventions using efl_indent.
This commit is contained in:
parent
05df3290dc
commit
ee587a37b0
|
@ -25,21 +25,20 @@ _open_browser_help_cb(void *data EINA_UNUSED, void *obj EINA_UNUSED)
|
|||
free(sb);
|
||||
}
|
||||
|
||||
/* Some defines to make coding with the e_widget_* easier for
|
||||
* configuration panel */
|
||||
/* Some defines to make coding with the e_widget_* easier for configuration
|
||||
* panel */
|
||||
#define RADIO(title, value, radiogroup) \
|
||||
e_widget_radio_add(evas, _(title), value, radiogroup)
|
||||
#define LIST_ADD(list, object) \
|
||||
e_widget_list_object_append(list, object, 1, 1, 0.5)
|
||||
|
||||
struct _Config_vdesk *
|
||||
get_vdesk(Eina_List *vdesks,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int zone_num)
|
||||
get_vdesk(Eina_List * vdesks, int x, int y, unsigned int zone_num)
|
||||
{
|
||||
Eina_List *l;
|
||||
for (l = vdesks; l; l = l->next) {
|
||||
|
||||
for (l = vdesks; l; l = l->next)
|
||||
{
|
||||
struct _Config_vdesk *vd = l->data;
|
||||
|
||||
if (!vd)
|
||||
|
@ -58,28 +57,29 @@ get_vdesk(Eina_List *vdesks,
|
|||
*
|
||||
*/
|
||||
static void *
|
||||
_create_data(E_Config_Dialog *cfd EINA_UNUSED)
|
||||
_create_data(E_Config_Dialog * cfd EINA_UNUSED)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
Eina_List *l;
|
||||
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||
|
||||
/* Because we save a lot of lines here by using memcpy,
|
||||
* the structs have to be ordered the same */
|
||||
/* Because we save a lot of lines here by using memcpy, the structs have to
|
||||
* be ordered the same */
|
||||
memcpy(cfdata, tiling_g.config, sizeof(Config));
|
||||
|
||||
/* Handle things which can't be easily memcpy'd */
|
||||
cfdata->config.vdesks = NULL;
|
||||
|
||||
for (l = tiling_g.config->vdesks; l; l = l->next) {
|
||||
struct _Config_vdesk *vd = l->data,
|
||||
*newvd;
|
||||
for (l = tiling_g.config->vdesks; l; l = l->next)
|
||||
{
|
||||
struct _Config_vdesk *vd = l->data, *newvd;
|
||||
|
||||
if (!vd)
|
||||
continue;
|
||||
|
||||
newvd = E_NEW(struct _Config_vdesk, 1);
|
||||
|
||||
newvd->x = vd->x;
|
||||
newvd->y = vd->y;
|
||||
newvd->zone_num = vd->zone_num;
|
||||
|
@ -92,16 +92,14 @@ _create_data(E_Config_Dialog *cfd EINA_UNUSED)
|
|||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd EINA_UNUSED,
|
||||
E_Config_Dialog_Data *cfdata)
|
||||
_free_data(E_Config_Dialog * cfd EINA_UNUSED, E_Config_Dialog_Data * cfdata)
|
||||
{
|
||||
eina_list_free(cfdata->config.vdesks);
|
||||
free(cfdata);
|
||||
}
|
||||
|
||||
static void
|
||||
_fill_zone_config(E_Zone *zone,
|
||||
E_Config_Dialog_Data *cfdata)
|
||||
_fill_zone_config(E_Zone * zone, E_Config_Dialog_Data * cfdata)
|
||||
{
|
||||
Evas *evas;
|
||||
int i;
|
||||
|
@ -113,7 +111,8 @@ _fill_zone_config(E_Zone *zone,
|
|||
|
||||
cfdata->o_desklist = e_widget_list_add(evas, 1, 0);
|
||||
|
||||
for (i = 0; i < zone->desk_y_count * zone->desk_x_count; i++) {
|
||||
for (i = 0; i < zone->desk_y_count * zone->desk_x_count; i++)
|
||||
{
|
||||
E_Desk *desk = zone->desks[i];
|
||||
struct _Config_vdesk *vd;
|
||||
Evas_Object *list, *slider;
|
||||
|
@ -122,8 +121,10 @@ _fill_zone_config(E_Zone *zone,
|
|||
continue;
|
||||
|
||||
vd = get_vdesk(cfdata->config.vdesks, desk->x, desk->y, zone->num);
|
||||
if (!vd) {
|
||||
if (!vd)
|
||||
{
|
||||
vd = E_NEW(struct _Config_vdesk, 1);
|
||||
|
||||
vd->x = desk->x;
|
||||
vd->y = desk->y;
|
||||
vd->zone_num = zone->num;
|
||||
|
@ -146,8 +147,7 @@ _fill_zone_config(E_Zone *zone,
|
|||
}
|
||||
|
||||
static void
|
||||
_cb_zone_change(void *data,
|
||||
Evas_Object *obj EINA_UNUSED)
|
||||
_cb_zone_change(void *data, Evas_Object * obj EINA_UNUSED)
|
||||
{
|
||||
int n;
|
||||
E_Config_Dialog_Data *cfdata = data;
|
||||
|
@ -164,9 +164,8 @@ _cb_zone_change(void *data,
|
|||
}
|
||||
|
||||
static Evas_Object *
|
||||
_basic_create_widgets(E_Config_Dialog *cfd EINA_UNUSED,
|
||||
Evas *evas,
|
||||
E_Config_Dialog_Data *cfdata)
|
||||
_basic_create_widgets(E_Config_Dialog * cfd EINA_UNUSED, Evas * evas,
|
||||
E_Config_Dialog_Data * cfdata)
|
||||
{
|
||||
Evas_Object *o, *oc, *of;
|
||||
E_Comp *comp;
|
||||
|
@ -179,18 +178,15 @@ _basic_create_widgets(E_Config_Dialog *cfd EINA_UNUSED,
|
|||
|
||||
/* General settings */
|
||||
of = e_widget_framelist_add(evas, _("General"), 0);
|
||||
e_widget_framelist_object_append(of,
|
||||
e_widget_check_add(evas, _("Show window titles"),
|
||||
&cfdata->config.show_titles));
|
||||
e_widget_framelist_object_append(of,
|
||||
e_widget_check_add(evas, _("Tile dialog windows"),
|
||||
&cfdata->config.tile_dialogs));
|
||||
e_widget_framelist_object_append(of, e_widget_check_add(evas,
|
||||
_("Show window titles"), &cfdata->config.show_titles));
|
||||
e_widget_framelist_object_append(of, e_widget_check_add(evas,
|
||||
_("Tile dialog windows"), &cfdata->config.tile_dialogs));
|
||||
|
||||
LIST_ADD(o, of);
|
||||
|
||||
/* Virtual desktop settings */
|
||||
of = e_widget_label_add(evas,
|
||||
_("Enable/disable tiling per desktop."));
|
||||
of = e_widget_label_add(evas, _("Enable/disable tiling per desktop."));
|
||||
LIST_ADD(o, of);
|
||||
of = e_widget_framelist_add(evas, _("Virtual Desktops"), 0);
|
||||
cfdata->osf = e_widget_list_add(evas, 0, 1);
|
||||
|
@ -200,10 +196,12 @@ _basic_create_widgets(E_Config_Dialog *cfd EINA_UNUSED,
|
|||
e_widget_ilist_multi_select_set(cfdata->o_zonelist, false);
|
||||
e_widget_size_min_set(cfdata->o_zonelist, 100, 100);
|
||||
e_widget_on_change_hook_set(cfdata->o_zonelist, _cb_zone_change, cfdata);
|
||||
for (l = comp->zones; l; l = l->next) {
|
||||
for (l = comp->zones; l; l = l->next)
|
||||
{
|
||||
if (!(zone = l->data))
|
||||
continue;
|
||||
e_widget_ilist_append(cfdata->o_zonelist, NULL, zone->name, NULL, zone, NULL);
|
||||
e_widget_ilist_append(cfdata->o_zonelist, NULL, zone->name, NULL, zone,
|
||||
NULL);
|
||||
}
|
||||
e_widget_ilist_go(cfdata->o_zonelist);
|
||||
e_widget_ilist_thaw(cfdata->o_zonelist);
|
||||
|
@ -229,8 +227,8 @@ _basic_create_widgets(E_Config_Dialog *cfd EINA_UNUSED,
|
|||
}
|
||||
|
||||
static int
|
||||
_basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED,
|
||||
E_Config_Dialog_Data *cfdata)
|
||||
_basic_apply_data(E_Config_Dialog * cfd EINA_UNUSED,
|
||||
E_Config_Dialog_Data * cfdata)
|
||||
{
|
||||
struct _Config_vdesk *vd;
|
||||
Eina_List *l;
|
||||
|
@ -239,49 +237,52 @@ _basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED,
|
|||
tiling_g.config->show_titles = cfdata->config.show_titles;
|
||||
|
||||
/* Check if the layout for one of the vdesks has changed */
|
||||
for (l = tiling_g.config->vdesks; l; l = l->next) {
|
||||
for (l = tiling_g.config->vdesks; l; l = l->next)
|
||||
{
|
||||
struct _Config_vdesk *newvd;
|
||||
|
||||
vd = l->data;
|
||||
|
||||
if (!vd)
|
||||
continue;
|
||||
if (!(newvd = get_vdesk(cfdata->config.vdesks,
|
||||
vd->x, vd->y, vd->zone_num))) {
|
||||
if (!(newvd =
|
||||
get_vdesk(cfdata->config.vdesks, vd->x, vd->y, vd->zone_num)))
|
||||
{
|
||||
change_desk_conf(vd);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (newvd->nb_stacks != vd->nb_stacks) {
|
||||
DBG("number of columns for (%d, %d, %d) changed from %d"
|
||||
" to %d",
|
||||
vd->x, vd->y, vd->zone_num,
|
||||
vd->nb_stacks,
|
||||
newvd->nb_stacks);
|
||||
if (newvd->nb_stacks != vd->nb_stacks)
|
||||
{
|
||||
DBG("number of columns for (%d, %d, %d) changed from %d" " to %d",
|
||||
vd->x, vd->y, vd->zone_num, vd->nb_stacks, newvd->nb_stacks);
|
||||
change_desk_conf(newvd);
|
||||
free(vd);
|
||||
l->data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (l = cfdata->config.vdesks; l; l = l->next) {
|
||||
for (l = cfdata->config.vdesks; l; l = l->next)
|
||||
{
|
||||
vd = l->data;
|
||||
|
||||
if (!vd)
|
||||
continue;
|
||||
if (!get_vdesk(tiling_g.config->vdesks,
|
||||
vd->x, vd->y, vd->zone_num)) {
|
||||
if (!get_vdesk(tiling_g.config->vdesks, vd->x, vd->y, vd->zone_num))
|
||||
{
|
||||
change_desk_conf(vd);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
EINA_LIST_FREE(tiling_g.config->vdesks, vd) {
|
||||
EINA_LIST_FREE(tiling_g.config->vdesks, vd)
|
||||
{
|
||||
free(vd);
|
||||
}
|
||||
tiling_g.config->vdesks = NULL;
|
||||
|
||||
for (l = cfdata->config.vdesks; l; l = l->next) {
|
||||
for (l = cfdata->config.vdesks; l; l = l->next)
|
||||
{
|
||||
struct _Config_vdesk *newvd;
|
||||
|
||||
vd = l->data;
|
||||
|
@ -289,6 +290,7 @@ _basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED,
|
|||
continue;
|
||||
|
||||
newvd = E_NEW(struct _Config_vdesk, 1);
|
||||
|
||||
newvd->x = vd->x;
|
||||
newvd->y = vd->y;
|
||||
newvd->zone_num = vd->zone_num;
|
||||
|
@ -305,8 +307,7 @@ _basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED,
|
|||
}
|
||||
|
||||
E_Config_Dialog *
|
||||
e_int_config_tiling_module(E_Comp *comp,
|
||||
const char *params EINA_UNUSED)
|
||||
e_int_config_tiling_module(E_Comp * comp, const char *params EINA_UNUSED)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_View *v;
|
||||
|
@ -324,9 +325,8 @@ e_int_config_tiling_module(E_Comp *comp,
|
|||
|
||||
snprintf(buf, sizeof(buf), "%s/e-module-tiling.edj",
|
||||
e_module_dir_get(tiling_g.module));
|
||||
cfd = e_config_dialog_new(comp,
|
||||
_("Tiling Configuration"),
|
||||
"E", "windows/tiling",
|
||||
buf, 0, v, NULL);
|
||||
cfd =
|
||||
e_config_dialog_new(comp, _("Tiling Configuration"), "E",
|
||||
"windows/tiling", buf, 0, v, NULL);
|
||||
return cfd;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,13 +1,13 @@
|
|||
#ifndef E_MOD_TILING_H
|
||||
#define E_MOD_TILING_H
|
||||
# define E_MOD_TILING_H
|
||||
|
||||
#include <e.h>
|
||||
# include <e.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
# include <stdbool.h>
|
||||
|
||||
#include <assert.h>
|
||||
# include <assert.h>
|
||||
|
||||
#include "window_tree.h"
|
||||
# include "window_tree.h"
|
||||
|
||||
typedef struct _Config Config;
|
||||
typedef struct _Tiling_Info Tiling_Info;
|
||||
|
@ -20,12 +20,12 @@ struct tiling_g
|
|||
};
|
||||
extern struct tiling_g tiling_g;
|
||||
|
||||
#undef ERR
|
||||
#undef DBG
|
||||
#define ERR(...) EINA_LOG_DOM_ERR(tiling_g.log_domain, __VA_ARGS__)
|
||||
#define DBG(...) EINA_LOG_DOM_DBG(tiling_g.log_domain, __VA_ARGS__)
|
||||
# undef ERR
|
||||
# undef DBG
|
||||
# define ERR(...) EINA_LOG_DOM_ERR(tiling_g.log_domain, __VA_ARGS__)
|
||||
# define DBG(...) EINA_LOG_DOM_DBG(tiling_g.log_domain, __VA_ARGS__)
|
||||
|
||||
#define TILING_MAX_STACKS 8
|
||||
# define TILING_MAX_STACKS 8
|
||||
|
||||
struct _Config_vdesk
|
||||
{
|
||||
|
@ -43,9 +43,9 @@ struct _Config
|
|||
|
||||
struct _Tiling_Info
|
||||
{
|
||||
/* The desk for which this _Tiling_Info is used. Needed because
|
||||
* (for example) on e restart all desks are shown on all zones but no
|
||||
* change events are triggered */
|
||||
/* The desk for which this _Tiling_Info is used. Needed because (for
|
||||
* example) on e restart all desks are shown on all zones but no change
|
||||
* events are triggered */
|
||||
const E_Desk *desk;
|
||||
|
||||
struct _Config_vdesk *conf;
|
||||
|
@ -62,38 +62,31 @@ struct _E_Config_Dialog_Data
|
|||
Evas *evas;
|
||||
};
|
||||
|
||||
E_Config_Dialog *e_int_config_tiling_module(E_Comp *comp,
|
||||
const char *params);
|
||||
E_Config_Dialog *e_int_config_tiling_module(E_Comp * comp, const char *params);
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
||||
EAPI void *e_modapi_init(E_Module *m);
|
||||
EAPI int e_modapi_shutdown(E_Module *m);
|
||||
EAPI int e_modapi_save(E_Module *m);
|
||||
EAPI void *e_modapi_init(E_Module * m);
|
||||
EAPI int e_modapi_shutdown(E_Module * m);
|
||||
EAPI int e_modapi_save(E_Module * m);
|
||||
|
||||
void change_desk_conf(struct _Config_vdesk *newconf);
|
||||
|
||||
void e_tiling_update_conf(void);
|
||||
|
||||
struct _Config_vdesk *
|
||||
get_vdesk(Eina_List *vdesks,
|
||||
int x,
|
||||
int y,
|
||||
struct _Config_vdesk *get_vdesk(Eina_List * vdesks, int x, int y,
|
||||
unsigned int zone_num);
|
||||
|
||||
void tiling_e_client_move_resize_extra(E_Client *ec,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
void tiling_e_client_move_resize_extra(E_Client * ec, int x, int y, int w,
|
||||
int h);
|
||||
#define EINA_LIST_IS_IN(_list, _el) \
|
||||
# define EINA_LIST_IS_IN(_list, _el) \
|
||||
(eina_list_data_find(_list, _el) == _el)
|
||||
#define EINA_LIST_APPEND(_list, _el) \
|
||||
# define EINA_LIST_APPEND(_list, _el) \
|
||||
_list = eina_list_append(_list, _el)
|
||||
#define EINA_LIST_REMOVE(_list, _el) \
|
||||
# define EINA_LIST_REMOVE(_list, _el) \
|
||||
_list = eina_list_remove(_list, _el)
|
||||
|
||||
#define _TILE_MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define _TILE_MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
# define _TILE_MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
# define _TILE_MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
#include "e_mod_tiling.h"
|
||||
|
||||
void
|
||||
tiling_window_tree_walk(Window_Tree *root, void (*func)(void *))
|
||||
tiling_window_tree_walk(Window_Tree * root, void (*func) (void *))
|
||||
{
|
||||
Eina_Inlist *itr_safe;
|
||||
Window_Tree *itr;
|
||||
|
||||
if (!root)
|
||||
return;
|
||||
|
||||
|
@ -19,16 +20,17 @@ tiling_window_tree_walk(Window_Tree *root, void (*func)(void *))
|
|||
}
|
||||
|
||||
void
|
||||
tiling_window_tree_free(Window_Tree *root)
|
||||
tiling_window_tree_free(Window_Tree * root)
|
||||
{
|
||||
tiling_window_tree_walk(root, free);
|
||||
}
|
||||
|
||||
static void
|
||||
_tiling_window_tree_split_add(Window_Tree *parent, Window_Tree *new_node)
|
||||
_tiling_window_tree_split_add(Window_Tree * parent, Window_Tree * new_node)
|
||||
{
|
||||
/* Make a new node for the parent client and split the weights in half. */
|
||||
Window_Tree *new_parent_client = calloc(1, sizeof(*new_node));
|
||||
|
||||
new_node->parent = parent;
|
||||
new_parent_client->parent = parent;
|
||||
new_parent_client->client = parent->client;
|
||||
|
@ -36,14 +38,14 @@ _tiling_window_tree_split_add(Window_Tree *parent, Window_Tree *new_node)
|
|||
new_parent_client->weight = 0.5;
|
||||
new_node->weight = 0.5;
|
||||
|
||||
parent->children = eina_inlist_append(parent->children,
|
||||
EINA_INLIST_GET(new_parent_client));
|
||||
parent->children = eina_inlist_append(parent->children,
|
||||
EINA_INLIST_GET(new_node));
|
||||
parent->children =
|
||||
eina_inlist_append(parent->children, EINA_INLIST_GET(new_parent_client));
|
||||
parent->children =
|
||||
eina_inlist_append(parent->children, EINA_INLIST_GET(new_node));
|
||||
}
|
||||
|
||||
static void
|
||||
_tiling_window_tree_parent_add(Window_Tree *parent, Window_Tree *new_node)
|
||||
_tiling_window_tree_parent_add(Window_Tree * parent, Window_Tree * new_node)
|
||||
{
|
||||
/* Adjust existing children's weights */
|
||||
Window_Tree *itr;
|
||||
|
@ -59,14 +61,15 @@ _tiling_window_tree_parent_add(Window_Tree *parent, Window_Tree *new_node)
|
|||
itr->weight *= weight;
|
||||
}
|
||||
|
||||
parent->children = eina_inlist_append(parent->children,
|
||||
EINA_INLIST_GET(new_node));
|
||||
parent->children =
|
||||
eina_inlist_append(parent->children, EINA_INLIST_GET(new_node));
|
||||
}
|
||||
|
||||
static int
|
||||
_tiling_window_tree_split_type_get(Window_Tree *node)
|
||||
_tiling_window_tree_split_type_get(Window_Tree * node)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
while (node->parent)
|
||||
{
|
||||
ret++;
|
||||
|
@ -77,22 +80,22 @@ _tiling_window_tree_split_type_get(Window_Tree *node)
|
|||
}
|
||||
|
||||
Window_Tree *
|
||||
tiling_window_tree_add(Window_Tree *root, Window_Tree *parent, E_Client *client, Tiling_Split_Type split_type)
|
||||
tiling_window_tree_add(Window_Tree * root, Window_Tree * parent,
|
||||
E_Client * client, Tiling_Split_Type split_type)
|
||||
{
|
||||
Window_Tree *new_node = calloc(1, sizeof(*new_node));
|
||||
|
||||
new_node->client = client;
|
||||
Tiling_Split_Type parent_split_type;
|
||||
|
||||
if (split_type > TILING_SPLIT_VERTICAL)
|
||||
{
|
||||
return root;
|
||||
}
|
||||
else if (!root)
|
||||
} else if (!root)
|
||||
{
|
||||
new_node->weight = 1.0;
|
||||
return new_node;
|
||||
}
|
||||
else if (!parent)
|
||||
} else if (!parent)
|
||||
{
|
||||
parent = root;
|
||||
parent_split_type = _tiling_window_tree_split_type_get(parent);
|
||||
|
@ -109,26 +112,24 @@ tiling_window_tree_add(Window_Tree *root, Window_Tree *parent, E_Client *client,
|
|||
if (parent->children)
|
||||
{
|
||||
_tiling_window_tree_parent_add(parent, new_node);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
_tiling_window_tree_split_add(parent, new_node);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
Window_Tree *grand_parent = parent->parent;
|
||||
|
||||
if (grand_parent && grand_parent->children)
|
||||
{
|
||||
_tiling_window_tree_parent_add(grand_parent, new_node);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
root = calloc(1, sizeof(*root));
|
||||
_tiling_window_tree_split_add(parent, new_node);
|
||||
root->weight = 1.0;
|
||||
root->children = eina_inlist_append(root->children,
|
||||
EINA_INLIST_GET(parent));
|
||||
root->children =
|
||||
eina_inlist_append(root->children, EINA_INLIST_GET(parent));
|
||||
parent->parent = root;
|
||||
}
|
||||
}
|
||||
|
@ -137,20 +138,18 @@ tiling_window_tree_add(Window_Tree *root, Window_Tree *parent, E_Client *client,
|
|||
}
|
||||
|
||||
Window_Tree *
|
||||
tiling_window_tree_remove(Window_Tree *root, Window_Tree *item)
|
||||
tiling_window_tree_remove(Window_Tree * root, Window_Tree * item)
|
||||
{
|
||||
if (root == item)
|
||||
{
|
||||
free(item);
|
||||
return NULL;
|
||||
}
|
||||
else if (!item->client)
|
||||
} else if (!item->client)
|
||||
{
|
||||
ERR("Tried deleting node %p that doesn't have a client.", item);
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
Window_Tree *parent = item->parent;
|
||||
int children_count = eina_inlist_count(item->parent->children);
|
||||
|
||||
|
@ -158,6 +157,7 @@ tiling_window_tree_remove(Window_Tree *root, Window_Tree *item)
|
|||
{
|
||||
Window_Tree *grand_parent = parent->parent;
|
||||
Window_Tree *item_keep = NULL;
|
||||
|
||||
/* Adjust existing children's weights */
|
||||
EINA_INLIST_FOREACH(parent->children, item_keep)
|
||||
{
|
||||
|
@ -171,15 +171,13 @@ tiling_window_tree_remove(Window_Tree *root, Window_Tree *item)
|
|||
free(item);
|
||||
free(root);
|
||||
return NULL;
|
||||
}
|
||||
else if (!item_keep->children)
|
||||
} else if (!item_keep->children)
|
||||
{
|
||||
parent->client = item_keep->client;
|
||||
parent->children = NULL;
|
||||
|
||||
free(item_keep);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
if (grand_parent)
|
||||
{
|
||||
|
@ -188,7 +186,8 @@ tiling_window_tree_remove(Window_Tree *root, Window_Tree *item)
|
|||
Eina_Inlist *itr_safe;
|
||||
Window_Tree *itr;
|
||||
|
||||
EINA_INLIST_FOREACH_SAFE(item_keep->children, itr_safe, itr)
|
||||
EINA_INLIST_FOREACH_SAFE(item_keep->children, itr_safe,
|
||||
itr)
|
||||
{
|
||||
/* We are prepending to double-reverse the order. */
|
||||
grand_parent->children =
|
||||
|
@ -198,28 +197,28 @@ tiling_window_tree_remove(Window_Tree *root, Window_Tree *item)
|
|||
itr->parent = grand_parent;
|
||||
}
|
||||
|
||||
grand_parent->children = eina_inlist_remove(grand_parent->children,
|
||||
grand_parent->children =
|
||||
eina_inlist_remove(grand_parent->children,
|
||||
EINA_INLIST_GET(parent));
|
||||
free(parent);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
/* This is fine, as this is a child of the root so we allow two
|
||||
* levels. */
|
||||
/* This is fine, as this is a child of the root so we allow
|
||||
* two levels. */
|
||||
item_keep->weight = 1.0;
|
||||
}
|
||||
|
||||
parent->children = eina_inlist_remove(parent->children, EINA_INLIST_GET(item));
|
||||
parent->children =
|
||||
eina_inlist_remove(parent->children, EINA_INLIST_GET(item));
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
Window_Tree *itr;
|
||||
float weight = 1.0 - item->weight;
|
||||
|
||||
parent->children = eina_inlist_remove(parent->children,
|
||||
EINA_INLIST_GET(item));
|
||||
parent->children =
|
||||
eina_inlist_remove(parent->children, EINA_INLIST_GET(item));
|
||||
|
||||
/* Adjust existing children's weights */
|
||||
EINA_INLIST_FOREACH(parent->children, itr)
|
||||
|
@ -233,7 +232,7 @@ tiling_window_tree_remove(Window_Tree *root, Window_Tree *item)
|
|||
}
|
||||
|
||||
Window_Tree *
|
||||
tiling_window_tree_client_find(Window_Tree *root, E_Client *client)
|
||||
tiling_window_tree_client_find(Window_Tree * root, E_Client * client)
|
||||
{
|
||||
Window_Tree *itr;
|
||||
|
||||
|
@ -246,6 +245,7 @@ tiling_window_tree_client_find(Window_Tree *root, E_Client *client)
|
|||
EINA_INLIST_FOREACH(root->children, itr)
|
||||
{
|
||||
Window_Tree *ret;
|
||||
|
||||
ret = tiling_window_tree_client_find(itr, client);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
@ -255,7 +255,7 @@ tiling_window_tree_client_find(Window_Tree *root, E_Client *client)
|
|||
}
|
||||
|
||||
void
|
||||
_tiling_window_tree_level_apply(Window_Tree *root, Evas_Coord x, Evas_Coord y,
|
||||
_tiling_window_tree_level_apply(Window_Tree * root, Evas_Coord x, Evas_Coord y,
|
||||
Evas_Coord w, Evas_Coord h, int level)
|
||||
{
|
||||
Window_Tree *itr;
|
||||
|
@ -273,16 +273,17 @@ _tiling_window_tree_level_apply(Window_Tree *root, Evas_Coord x, Evas_Coord y,
|
|||
EINA_INLIST_FOREACH(root->children, itr)
|
||||
{
|
||||
Evas_Coord itw = w * itr->weight;
|
||||
|
||||
total_weight += itr->weight;
|
||||
_tiling_window_tree_level_apply(itr, x, y, itw, h, level + 1);
|
||||
x += itw;
|
||||
}
|
||||
}
|
||||
else if (split_type == TILING_SPLIT_VERTICAL)
|
||||
} else if (split_type == TILING_SPLIT_VERTICAL)
|
||||
{
|
||||
EINA_INLIST_FOREACH(root->children, itr)
|
||||
{
|
||||
Evas_Coord ith = h * itr->weight;
|
||||
|
||||
total_weight += itr->weight;
|
||||
_tiling_window_tree_level_apply(itr, x, y, w, ith, level + 1);
|
||||
y += ith;
|
||||
|
@ -294,46 +295,44 @@ _tiling_window_tree_level_apply(Window_Tree *root, Evas_Coord x, Evas_Coord y,
|
|||
}
|
||||
|
||||
void
|
||||
tiling_window_tree_apply(Window_Tree *root, Evas_Coord x, Evas_Coord y,
|
||||
tiling_window_tree_apply(Window_Tree * root, Evas_Coord x, Evas_Coord y,
|
||||
Evas_Coord w, Evas_Coord h)
|
||||
{
|
||||
_tiling_window_tree_level_apply(root, x, y, w, h, 0);
|
||||
}
|
||||
|
||||
static Window_Tree *
|
||||
_inlist_next(Window_Tree *it)
|
||||
_inlist_next(Window_Tree * it)
|
||||
{
|
||||
return (Window_Tree *) EINA_INLIST_GET(it)->next;
|
||||
}
|
||||
|
||||
static Window_Tree *
|
||||
_inlist_prev(Window_Tree *it)
|
||||
_inlist_prev(Window_Tree * it)
|
||||
{
|
||||
return (Window_Tree *) EINA_INLIST_GET(it)->prev;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_tiling_window_tree_node_resize_direction(Window_Tree *node, Window_Tree *parent,
|
||||
double dir_diff, int dir)
|
||||
_tiling_window_tree_node_resize_direction(Window_Tree * node,
|
||||
Window_Tree * parent, double dir_diff, int dir)
|
||||
{
|
||||
double weight = 0.0;
|
||||
double weight_diff;
|
||||
Window_Tree *children_start;
|
||||
Window_Tree *itr;
|
||||
Window_Tree *(*itr_func)(Window_Tree *);
|
||||
Window_Tree *(*itr_func) (Window_Tree *);
|
||||
|
||||
if (dir > 0)
|
||||
{
|
||||
itr_func = _inlist_prev;
|
||||
children_start = (Window_Tree *) parent->children->last;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
itr_func = _inlist_next;
|
||||
children_start = (Window_Tree *) parent->children;
|
||||
}
|
||||
|
||||
|
||||
itr = (Window_Tree *) children_start;
|
||||
while (itr != node)
|
||||
{
|
||||
|
@ -348,8 +347,7 @@ _tiling_window_tree_node_resize_direction(Window_Tree *node, Window_Tree *parent
|
|||
if (parent->parent && parent->parent->parent)
|
||||
{
|
||||
return _tiling_window_tree_node_resize_direction(parent->parent,
|
||||
parent->parent->parent,
|
||||
1.0 + ((dir_diff - 1.) * node->weight),
|
||||
parent->parent->parent, 1.0 + ((dir_diff - 1.) * node->weight),
|
||||
dir);
|
||||
}
|
||||
return EINA_FALSE;
|
||||
|
@ -360,7 +358,7 @@ _tiling_window_tree_node_resize_direction(Window_Tree *node, Window_Tree *parent
|
|||
weight_diff -= itr->weight;
|
||||
weight_diff /= weight;
|
||||
|
||||
for (itr = children_start ; itr != node ; itr = itr_func(itr))
|
||||
for (itr = children_start; itr != node; itr = itr_func(itr))
|
||||
{
|
||||
itr->weight += itr->weight * weight_diff;
|
||||
}
|
||||
|
@ -369,7 +367,8 @@ _tiling_window_tree_node_resize_direction(Window_Tree *node, Window_Tree *parent
|
|||
}
|
||||
|
||||
Eina_Bool
|
||||
tiling_window_tree_node_resize(Window_Tree *node, int w_dir, double w_diff, int h_dir, double h_diff)
|
||||
tiling_window_tree_node_resize(Window_Tree * node, int w_dir, double w_diff,
|
||||
int h_dir, double h_diff)
|
||||
{
|
||||
Window_Tree *parent = node->parent;
|
||||
Window_Tree *w_parent, *h_parent;
|
||||
|
@ -380,15 +379,15 @@ tiling_window_tree_node_resize(Window_Tree *node, int w_dir, double w_diff, int
|
|||
return EINA_FALSE;
|
||||
|
||||
Window_Tree *grand_parent = parent->parent;
|
||||
Tiling_Split_Type parent_split_type = _tiling_window_tree_split_type_get(parent);
|
||||
Tiling_Split_Type parent_split_type =
|
||||
_tiling_window_tree_split_type_get(parent);
|
||||
|
||||
/* w_diff related changes. */
|
||||
if (parent_split_type == TILING_SPLIT_HORIZONTAL)
|
||||
{
|
||||
w_parent = parent;
|
||||
h_parent = grand_parent;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
w_parent = grand_parent;
|
||||
h_parent = parent;
|
||||
|
@ -397,60 +396,70 @@ tiling_window_tree_node_resize(Window_Tree *node, int w_dir, double w_diff, int
|
|||
if ((h_diff != 1.0) && h_parent)
|
||||
{
|
||||
Window_Tree *tmp_node = (h_parent == parent) ? node : parent;
|
||||
ret = ret || _tiling_window_tree_node_resize_direction(tmp_node, h_parent, h_diff, h_dir);
|
||||
|
||||
ret = ret ||
|
||||
_tiling_window_tree_node_resize_direction(tmp_node, h_parent,
|
||||
h_diff, h_dir);
|
||||
}
|
||||
|
||||
if ((w_diff != 1.0) && w_parent)
|
||||
{
|
||||
Window_Tree *tmp_node = (w_parent == parent) ? node : parent;
|
||||
ret = ret || _tiling_window_tree_node_resize_direction(tmp_node, w_parent, w_diff, w_dir);
|
||||
|
||||
ret = ret ||
|
||||
_tiling_window_tree_node_resize_direction(tmp_node, w_parent,
|
||||
w_diff, w_dir);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
_tiling_window_tree_edges_get_helper(Window_Tree *node, Tiling_Split_Type split_type, Eina_Bool gave_up_this,
|
||||
_tiling_window_tree_edges_get_helper(Window_Tree * node,
|
||||
Tiling_Split_Type split_type, Eina_Bool gave_up_this,
|
||||
Eina_Bool gave_up_parent)
|
||||
{
|
||||
int ret = TILING_WINDOW_TREE_EDGE_LEFT | TILING_WINDOW_TREE_EDGE_RIGHT |
|
||||
int ret =
|
||||
TILING_WINDOW_TREE_EDGE_LEFT | TILING_WINDOW_TREE_EDGE_RIGHT |
|
||||
TILING_WINDOW_TREE_EDGE_TOP | TILING_WINDOW_TREE_EDGE_BOTTOM;
|
||||
if (!node->parent)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
else if (gave_up_this && gave_up_parent)
|
||||
} else if (gave_up_this && gave_up_parent)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (gave_up_this)
|
||||
} else if (gave_up_this)
|
||||
{
|
||||
/* Mixed the gave_up vals on purpose, we do it on every call. */
|
||||
return _tiling_window_tree_edges_get_helper(node->parent, !split_type ,gave_up_parent,
|
||||
gave_up_this);
|
||||
return _tiling_window_tree_edges_get_helper(node->parent, !split_type,
|
||||
gave_up_parent, gave_up_this);
|
||||
}
|
||||
|
||||
if (EINA_INLIST_GET(node)->prev)
|
||||
{
|
||||
gave_up_this = EINA_TRUE;
|
||||
ret ^= (split_type == TILING_SPLIT_HORIZONTAL) ?
|
||||
TILING_WINDOW_TREE_EDGE_LEFT : TILING_WINDOW_TREE_EDGE_TOP;
|
||||
ret ^=
|
||||
(split_type ==
|
||||
TILING_SPLIT_HORIZONTAL) ? TILING_WINDOW_TREE_EDGE_LEFT :
|
||||
TILING_WINDOW_TREE_EDGE_TOP;
|
||||
}
|
||||
|
||||
if (EINA_INLIST_GET(node)->next)
|
||||
{
|
||||
gave_up_this = EINA_TRUE;
|
||||
ret ^= (split_type == TILING_SPLIT_HORIZONTAL) ?
|
||||
TILING_WINDOW_TREE_EDGE_RIGHT : TILING_WINDOW_TREE_EDGE_BOTTOM;
|
||||
ret ^=
|
||||
(split_type ==
|
||||
TILING_SPLIT_HORIZONTAL) ? TILING_WINDOW_TREE_EDGE_RIGHT :
|
||||
TILING_WINDOW_TREE_EDGE_BOTTOM;
|
||||
}
|
||||
|
||||
/* Mixed the gave_up vals on purpose, we do it on every call. */
|
||||
return ret & _tiling_window_tree_edges_get_helper(node->parent, !split_type ,gave_up_parent,
|
||||
gave_up_this);
|
||||
return ret & _tiling_window_tree_edges_get_helper(node->parent, !split_type,
|
||||
gave_up_parent, gave_up_this);
|
||||
}
|
||||
|
||||
int
|
||||
tiling_window_tree_edges_get(Window_Tree *node)
|
||||
tiling_window_tree_edges_get(Window_Tree * node)
|
||||
{
|
||||
Tiling_Split_Type split_type = _tiling_window_tree_split_type_get(node);
|
||||
|
||||
|
@ -459,7 +468,8 @@ tiling_window_tree_edges_get(Window_Tree *node)
|
|||
}
|
||||
|
||||
/* Node move */
|
||||
static struct _Node_Move_Context {
|
||||
static struct _Node_Move_Context
|
||||
{
|
||||
Window_Tree *node;
|
||||
Window_Tree *ret;
|
||||
int cross_edge;
|
||||
|
@ -474,7 +484,7 @@ static struct _Node_Move_Context {
|
|||
CNODE->client->x, CNODE->client->w, node->client->x, node->client->w)
|
||||
|
||||
static void
|
||||
_tiling_window_tree_node_move_if_match_set(Window_Tree *node, Evas_Coord cx,
|
||||
_tiling_window_tree_node_move_if_match_set(Window_Tree * node, Evas_Coord cx,
|
||||
Evas_Coord cw, Evas_Coord ox, Evas_Coord ow)
|
||||
{
|
||||
Evas_Coord leftx, rightx;
|
||||
|
@ -528,11 +538,12 @@ _tiling_window_tree_node_move_walker(void *_node)
|
|||
#undef IF_MATCH_SET_TB
|
||||
|
||||
void
|
||||
tiling_window_tree_node_move(Window_Tree *node, int cross_edge)
|
||||
tiling_window_tree_node_move(Window_Tree * node, int cross_edge)
|
||||
{
|
||||
Window_Tree *root = node;
|
||||
/* FIXME: This is very slow and possibly buggy. Can be done much better,
|
||||
* but is very easy to implement. */
|
||||
|
||||
/* FIXME: This is very slow and possibly buggy. Can be done much better, but
|
||||
* is very easy to implement. */
|
||||
|
||||
while (root->parent)
|
||||
root = root->parent;
|
||||
|
@ -547,21 +558,23 @@ tiling_window_tree_node_move(Window_Tree *node, int cross_edge)
|
|||
if (_node_move_ctx.ret)
|
||||
{
|
||||
E_Client *ec = node->client;
|
||||
|
||||
node->client = _node_move_ctx.ret->client;
|
||||
_node_move_ctx.ret->client = ec;
|
||||
}
|
||||
}
|
||||
|
||||
/* End Node move. */
|
||||
|
||||
void
|
||||
tiling_window_tree_dump(Window_Tree *root, int level)
|
||||
tiling_window_tree_dump(Window_Tree * root, int level)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!root)
|
||||
return;
|
||||
|
||||
for (i = 0 ; i < level ; i++)
|
||||
for (i = 0; i < level; i++)
|
||||
printf(" ");
|
||||
|
||||
if (root->children)
|
||||
|
@ -572,6 +585,7 @@ tiling_window_tree_dump(Window_Tree *root, int level)
|
|||
printf("%f (%p)\n", root->weight, root->client);
|
||||
|
||||
Window_Tree *itr;
|
||||
|
||||
EINA_INLIST_FOREACH(root->children, itr)
|
||||
{
|
||||
tiling_window_tree_dump(itr, level + 1);
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#ifndef WINDOW_TREE_H
|
||||
#define WINDOW_TREE_H
|
||||
#include <e.h>
|
||||
# define WINDOW_TREE_H
|
||||
# include <e.h>
|
||||
|
||||
/* XXX: First two have to be 0 and 1 because I use them with modulo. */
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
TILING_SPLIT_HORIZONTAL = 0,
|
||||
TILING_SPLIT_VERTICAL = 1,
|
||||
TILING_SPLIT_FLOAT,
|
||||
|
@ -23,26 +24,30 @@ struct _Window_Tree
|
|||
double weight;
|
||||
};
|
||||
|
||||
#define TILING_WINDOW_TREE_EDGE_LEFT (1 << 0)
|
||||
#define TILING_WINDOW_TREE_EDGE_RIGHT (1 << 1)
|
||||
#define TILING_WINDOW_TREE_EDGE_TOP (1 << 2)
|
||||
#define TILING_WINDOW_TREE_EDGE_BOTTOM (1 << 3)
|
||||
# define TILING_WINDOW_TREE_EDGE_LEFT (1 << 0)
|
||||
# define TILING_WINDOW_TREE_EDGE_RIGHT (1 << 1)
|
||||
# define TILING_WINDOW_TREE_EDGE_TOP (1 << 2)
|
||||
# define TILING_WINDOW_TREE_EDGE_BOTTOM (1 << 3)
|
||||
|
||||
int tiling_window_tree_edges_get(Window_Tree *node);
|
||||
int tiling_window_tree_edges_get(Window_Tree * node);
|
||||
|
||||
void tiling_window_tree_free(Window_Tree *root);
|
||||
void tiling_window_tree_walk(Window_Tree *root, void (*func)(void *));
|
||||
void tiling_window_tree_free(Window_Tree * root);
|
||||
void tiling_window_tree_walk(Window_Tree * root, void (*func) (void *));
|
||||
|
||||
Window_Tree *tiling_window_tree_add(Window_Tree *root, Window_Tree *parent, E_Client *client, Tiling_Split_Type split_type);
|
||||
Window_Tree *tiling_window_tree_add(Window_Tree * root, Window_Tree * parent,
|
||||
E_Client * client, Tiling_Split_Type split_type);
|
||||
|
||||
Window_Tree *tiling_window_tree_remove(Window_Tree *root, Window_Tree *item);
|
||||
Window_Tree *tiling_window_tree_remove(Window_Tree * root, Window_Tree * item);
|
||||
|
||||
Window_Tree *tiling_window_tree_client_find(Window_Tree *root, E_Client *client);
|
||||
Window_Tree *tiling_window_tree_client_find(Window_Tree * root,
|
||||
E_Client * client);
|
||||
|
||||
void tiling_window_tree_apply(Window_Tree *root, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
|
||||
void tiling_window_tree_apply(Window_Tree * root, Evas_Coord x, Evas_Coord y,
|
||||
Evas_Coord w, Evas_Coord h);
|
||||
|
||||
Eina_Bool tiling_window_tree_node_resize(Window_Tree *node, int w_dir, double w_diff, int h_dir, double h_diff);
|
||||
Eina_Bool tiling_window_tree_node_resize(Window_Tree * node, int w_dir,
|
||||
double w_diff, int h_dir, double h_diff);
|
||||
|
||||
void tiling_window_tree_node_move(Window_Tree *node, int cross_edge);
|
||||
void tiling_window_tree_node_move(Window_Tree * node, int cross_edge);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue