respect zones for resistance, window placement...

SVN revision: 12898
This commit is contained in:
Carsten Haitzler 2005-01-11 13:11:12 +00:00
parent 960fcb4bc4
commit 899d272ed5
7 changed files with 114 additions and 54 deletions

View File

@ -20,6 +20,7 @@
#include <Ecore_Job.h> #include <Ecore_Job.h>
#include <Ecore_Txt.h> #include <Ecore_Txt.h>
#include <Ecore_Config.h> #include <Ecore_Config.h>
#include <Ecore_X_Atoms.h>
#include <Eet.h> #include <Eet.h>
#include <Edje.h> #include <Edje.h>

View File

@ -3,7 +3,6 @@
*/ */
#include "e.h" #include "e.h"
#include <Ecore_X_Atoms.h>
#define RESIZE_NONE 0 #define RESIZE_NONE 0
#define RESIZE_TL 1 #define RESIZE_TL 1
@ -79,6 +78,8 @@ static void _e_border_event_border_move_free(void *data, void *ev);
static void _e_border_event_border_show_free(void *data, void *ev); static void _e_border_event_border_show_free(void *data, void *ev);
static void _e_border_event_border_hide_free(void *data, void *ev); static void _e_border_event_border_hide_free(void *data, void *ev);
static void _e_border_zone_update(E_Border *bd);
/* local subsystem globals */ /* local subsystem globals */
static Evas_List *handlers = NULL; static Evas_List *handlers = NULL;
static Evas_List *borders = NULL; static Evas_List *borders = NULL;
@ -153,7 +154,7 @@ e_border_new(E_Container *con, Ecore_X_Window win, int first_map)
bd = E_OBJECT_ALLOC(E_Border, _e_border_free); bd = E_OBJECT_ALLOC(E_Border, _e_border_free);
if (!bd) return NULL; if (!bd) return NULL;
e_object_del_func_set(bd, _e_border_del); e_object_del_func_set(E_OBJECT(bd), E_OBJECT_CLEANUP_FUNC(_e_border_del));
printf("##- NEW CLIENT 0x%x\n", win); printf("##- NEW CLIENT 0x%x\n", win);
bd->container = con; bd->container = con;
@ -365,7 +366,7 @@ e_border_move(E_Border *bd, int x, int y)
bd->y + bd->client_inset.t, bd->y + bd->client_inset.t,
bd->client.w, bd->client.w,
bd->client.h); bd->client.h);
_e_border_zone_update(bd);
ev = calloc(1, sizeof(E_Event_Border_Move)); ev = calloc(1, sizeof(E_Event_Border_Move));
ev->border = bd; ev->border = bd;
e_object_ref(E_OBJECT(bd)); e_object_ref(E_OBJECT(bd));
@ -389,7 +390,7 @@ e_border_resize(E_Border *bd, int w, int h)
bd->y + bd->client_inset.t, bd->y + bd->client_inset.t,
bd->client.w, bd->client.w,
bd->client.h); bd->client.h);
_e_border_zone_update(bd);
ev = calloc(1, sizeof(E_Event_Border_Resize)); ev = calloc(1, sizeof(E_Event_Border_Resize));
ev->border = bd; ev->border = bd;
e_object_ref(E_OBJECT(bd)); e_object_ref(E_OBJECT(bd));
@ -418,7 +419,7 @@ e_border_move_resize(E_Border *bd, int x, int y, int w, int h)
bd->y + bd->client_inset.t, bd->y + bd->client_inset.t,
bd->client.w, bd->client.w,
bd->client.h); bd->client.h);
_e_border_zone_update(bd);
mev = calloc(1, sizeof(E_Event_Border_Move)); mev = calloc(1, sizeof(E_Event_Border_Move));
mev->border = bd; mev->border = bd;
e_object_ref(E_OBJECT(bd)); e_object_ref(E_OBJECT(bd));
@ -781,6 +782,12 @@ e_border_find_by_client_window(Ecore_X_Window win)
return NULL; return NULL;
} }
E_Border *
e_border_focused_get(void)
{
return focused;
}
void void
e_border_idler_before(void) e_border_idler_before(void)
{ {
@ -2148,16 +2155,16 @@ _e_border_eval(E_Border *bd)
printf("##- AUTO POS 0x%x\n", bd->client.win); printf("##- AUTO POS 0x%x\n", bd->client.win);
if (bd->zone->w > bd->w) if (bd->zone->w > bd->w)
new_x = rand() % (bd->zone->w - bd->w); new_x = bd->zone->x + (rand() % (bd->zone->w - bd->w));
else else
new_x = 0; new_x = bd->zone->x;
if (bd->zone->h > bd->h) if (bd->zone->h > bd->h)
new_y = rand() % (bd->zone->h - bd->h); new_y = bd->zone->y + (rand() % (bd->zone->h - bd->h));
else else
new_y = 0; new_y = bd->zone->y;
skiplist = evas_list_append(skiplist, bd); skiplist = evas_list_append(skiplist, bd);
e_place_container_region_smart(bd->container, skiplist, e_place_zone_region_smart(bd->zone, skiplist,
bd->x, bd->y, bd->w, bd->h, bd->x, bd->y, bd->w, bd->h,
&new_x, &new_y); &new_x, &new_y);
evas_list_free(skiplist); evas_list_free(skiplist);
@ -2811,3 +2818,28 @@ _e_border_event_border_desk_set_free(void *data, void *ev)
free(e); free(e);
} }
static void
_e_border_zone_update(E_Border *bd)
{
E_Container *con;
Evas_List *l;
/* still within old zone - leave it there */
if (E_INTERSECTS(bd->x, bd->y, bd->w, bd->h,
bd->zone->x, bd->zone->y, bd->zone->w, bd->zone->h))
return;
/* find a new zone */
con = bd->zone->container;
for (l = con->zones; l; l = l->next)
{
E_Zone *zone;
zone = l->data;
if (E_INTERSECTS(bd->x, bd->y, bd->w, bd->h,
zone->x, zone->y, zone->w, zone->h))
{
bd->zone = zone;
return;
}
}
}

View File

@ -255,6 +255,7 @@ EAPI void e_border_stick(E_Border *bd);
EAPI void e_border_unstick(E_Border *bd); EAPI void e_border_unstick(E_Border *bd);
EAPI E_Border *e_border_find_by_client_window(Ecore_X_Window win); EAPI E_Border *e_border_find_by_client_window(Ecore_X_Window win);
EAPI E_Border *e_border_focused_get(void);
EAPI void e_border_idler_before(void); EAPI void e_border_idler_before(void);

View File

@ -1,7 +1,7 @@
#include "e.h" #include "e.h"
int int
e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int y, int w, int h, int *rx, int *ry) e_place_zone_region_smart(E_Zone *zone, Evas_List *skiplist, int x, int y, int w, int h, int *rx, int *ry)
{ {
int a_w = 0, a_h = 0; int a_w = 0, a_h = 0;
int *a_x = NULL, *a_y = NULL; int *a_x = NULL, *a_y = NULL;
@ -12,12 +12,15 @@ e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int
a_x = E_NEW(int, 2); a_x = E_NEW(int, 2);
a_y = E_NEW(int, 2); a_y = E_NEW(int, 2);
a_x[0] = 0; x -= zone->x;
a_x[1] = con->w; y -= zone->y;
a_y[0] = 0;
a_y[1] = con->h;
for (l = con->clients; l; l = l->next) a_x[0] = 0;
a_x[1] = zone->w;
a_y[0] = 0;
a_y[1] = zone->h;
for (l = zone->container->clients; l; l = l->next)
{ {
E_Border *bd; E_Border *bd;
int ok; int ok;
@ -34,8 +37,8 @@ e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int
} }
if ((ok) && (bd->visible)) if ((ok) && (bd->visible))
{ {
if (E_INTERSECTS(bd->x, bd->y, bd->w, bd->h, if (E_INTERSECTS((bd->x - zone->x), (bd->y - zone->y),
0, 0, con->w, con->h)) bd->w, bd->h, 0, 0, zone->w, zone->h))
{ {
int i, j; int i, j;
@ -43,18 +46,18 @@ e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int
{ {
int ok = 1; int ok = 1;
if (bd->x > 0) if ((bd->x - zone->x) > 0)
{ {
if (a_x[i] == bd->x) if (a_x[i] == (bd->x - zone->x))
ok = 0; ok = 0;
else if (a_x[i] > bd->x) else if (a_x[i] > (bd->x - zone->x))
{ {
a_w++; a_w++;
E_REALLOC(a_x, int, a_w); E_REALLOC(a_x, int, a_w);
for (j = a_w - 1; j > i; j--) for (j = a_w - 1; j > i; j--)
a_x[j] = a_x[j - 1]; a_x[j] = a_x[j - 1];
a_x[i] = bd->x; a_x[i] = (bd->x - zone->x);
ok = 0; ok = 0;
} }
} }
@ -65,18 +68,18 @@ e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int
{ {
int ok = 1; int ok = 1;
if (bd->x + bd->w < con->w) if ((bd->x - zone->x) + bd->w < zone->w)
{ {
if (a_x[i] == bd->x + bd->w) if (a_x[i] == (bd->x - zone->x) + bd->w)
ok = 0; ok = 0;
else if (a_x[i] > bd->x + bd->w) else if (a_x[i] > (bd->x - zone->x) + bd->w)
{ {
a_w++; a_w++;
E_REALLOC(a_x, int, a_w); E_REALLOC(a_x, int, a_w);
for (j = a_w - 1; j > i; j--) for (j = a_w - 1; j > i; j--)
a_x[j] = a_x[j - 1]; a_x[j] = a_x[j - 1];
a_x[i] = bd->x + bd->w; a_x[i] = (bd->x - zone->x) + bd->w;
ok = 0; ok = 0;
} }
} }
@ -87,18 +90,18 @@ e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int
{ {
int ok = 1; int ok = 1;
if (bd->y > 0) if ((bd->y - zone->y) > 0)
{ {
if (a_y[i] == bd->y) if (a_y[i] == (bd->y - zone->y))
ok = 0; ok = 0;
else if (a_y[i] > bd->y) else if (a_y[i] > (bd->y - zone->y))
{ {
a_h++; a_h++;
E_REALLOC(a_y, int, a_h); E_REALLOC(a_y, int, a_h);
for (j = a_h - 1; j > i; j--) for (j = a_h - 1; j > i; j--)
a_y[j] = a_y[j - 1]; a_y[j] = a_y[j - 1];
a_y[i] = bd->y; a_y[i] = (bd->y - zone->y);
ok = 0; ok = 0;
} }
} }
@ -109,18 +112,18 @@ e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int
{ {
int ok = 1; int ok = 1;
if (bd->y + bd->h < con->h) if ((bd->y - zone->y) + bd->h < zone->h)
{ {
if (a_y[i] == bd->y + bd->h) if (a_y[i] == (bd->y - zone->y) + bd->h)
ok = 0; ok = 0;
else if (a_y[i] > bd->y + bd->h) else if (a_y[i] > (bd->y - zone->y) + bd->h)
{ {
a_h++; a_h++;
E_REALLOC(a_y, int, a_h); E_REALLOC(a_y, int, a_h);
for (j = a_h - 1; j > i; j--) for (j = a_h - 1; j > i; j--)
a_y[j] = a_y[j - 1]; a_y[j] = a_y[j - 1];
a_y[i] = bd->y + bd->h; a_y[i] = (bd->y - zone->y) + bd->h;
ok = 0; ok = 0;
} }
} }
@ -138,12 +141,12 @@ e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int
{ {
for (i = 0; i < a_w - 1; i++) for (i = 0; i < a_w - 1; i++)
{ {
if ((a_x[i] < (con->w - w)) && if ((a_x[i] < (zone->w - w)) &&
(a_y[j] < (con->h - h))) (a_y[j] < (zone->h - h)))
{ {
int ar = 0; int ar = 0;
for (l = con->clients; l; l = l->next) for (l = zone->container->clients; l; l = l->next)
{ {
E_Border *bd; E_Border *bd;
int x1, y1, w1, h1, x2, y2, w2, h2; int x1, y1, w1, h1, x2, y2, w2, h2;
@ -155,8 +158,8 @@ e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int
y1 = a_y[j]; y1 = a_y[j];
w1 = w; w1 = w;
h1 = h; h1 = h;
x2 = bd->x; x2 = (bd->x - zone->x);
y2 = bd->y; y2 = (bd->y - zone->y);
w2 = bd->w; w2 = bd->w;
h2 = bd->h; h2 = bd->h;
for (ll = skiplist; ll; ll = ll->next) for (ll = skiplist; ll; ll = ll->next)
@ -201,11 +204,11 @@ e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int
goto done; goto done;
} }
} }
if ((a_x[i + 1] - w > 0) && (a_y[j] < (con->h - h))) if ((a_x[i + 1] - w > 0) && (a_y[j] < (zone->h - h)))
{ {
int ar = 0; int ar = 0;
for (l = con->clients; l; l = l->next) for (l = zone->container->clients; l; l = l->next)
{ {
E_Border *bd; E_Border *bd;
int x1, y1, w1, h1, x2, y2, w2, h2; int x1, y1, w1, h1, x2, y2, w2, h2;
@ -217,8 +220,8 @@ e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int
y1 = a_y[j]; y1 = a_y[j];
w1 = w; w1 = w;
h1 = h; h1 = h;
x2 = bd->x; x2 = (bd->x - zone->x);
y2 = bd->y; y2 = (bd->y - zone->y);
w2 = bd->w; w2 = bd->w;
h2 = bd->h; h2 = bd->h;
for (ll = skiplist; ll; ll = ll->next) for (ll = skiplist; ll; ll = ll->next)
@ -267,7 +270,7 @@ e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int
{ {
int ar = 0; int ar = 0;
for (l = con->clients; l; l = l->next) for (l = zone->container->clients; l; l = l->next)
{ {
E_Border *bd; E_Border *bd;
int x1, y1, w1, h1, x2, y2, w2, h2; int x1, y1, w1, h1, x2, y2, w2, h2;
@ -279,8 +282,8 @@ e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int
y1 = a_y[j + 1] - h; y1 = a_y[j + 1] - h;
w1 = w; w1 = w;
h1 = h; h1 = h;
x2 = bd->x; x2 = (bd->x - zone->x);
y2 = bd->y; y2 = (bd->y - zone->y);
w2 = bd->w; w2 = bd->w;
h2 = bd->h; h2 = bd->h;
for (ll = skiplist; ll; ll = ll->next) for (ll = skiplist; ll; ll = ll->next)
@ -325,11 +328,11 @@ e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int
goto done; goto done;
} }
} }
if ((a_x[i] < (con->w - w)) && (a_y[j + 1] - h > 0)) if ((a_x[i] < (zone->w - w)) && (a_y[j + 1] - h > 0))
{ {
int ar = 0; int ar = 0;
for (l = con->clients; l; l = l->next) for (l = zone->container->clients; l; l = l->next)
{ {
E_Border *bd; E_Border *bd;
int x1, y1, w1, h1, x2, y2, w2, h2; int x1, y1, w1, h1, x2, y2, w2, h2;
@ -341,8 +344,8 @@ e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int
y1 = a_y[j + 1] - h; y1 = a_y[j + 1] - h;
w1 = w; w1 = w;
h1 = h; h1 = h;
x2 = bd->x; x2 = (bd->x - zone->x);
y2 = bd->y; y2 = (bd->y - zone->y);
w2 = bd->w; w2 = bd->w;
h2 = bd->h; h2 = bd->h;
for (ll = skiplist; ll; ll = ll->next) for (ll = skiplist; ll; ll = ll->next)
@ -393,5 +396,7 @@ e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int
done: done:
E_FREE(a_x); E_FREE(a_x);
E_FREE(a_y); E_FREE(a_y);
*rx += zone->x;
*ry += zone->y;
return 1; return 1;
} }

View File

@ -1,6 +1,6 @@
#ifndef E_PLACE_H #ifndef E_PLACE_H
#define E_PLACE_H #define E_PLACE_H
EAPI int e_place_container_region_smart(E_Container *con, Evas_List *skiplist, int x, int y, int w, int h, int *rx, int *ry); EAPI int e_place_zone_region_smart(E_Zone *zone, Evas_List *skiplist, int x, int y, int w, int h, int *rx, int *ry);
#endif #endif

View File

@ -144,10 +144,31 @@ E_Zone *
e_zone_current_get(E_Container *con) e_zone_current_get(E_Container *con)
{ {
Evas_List *l; Evas_List *l;
E_Border *bd;
E_OBJECT_CHECK_RETURN(con, NULL); E_OBJECT_CHECK_RETURN(con, NULL);
bd = e_border_focused_get();
if (bd)
{
/* the current zone is whatever zone has the focused window */
return bd->zone;
}
else
{
int x, y;
ecore_x_pointer_last_xy_get(&x, &y);
for (l = con->zones; l; l = l->next)
{
E_Zone *zone;
zone = l->data;
if (E_INTERSECTS(x, y, 1, 1,
zone->x, zone->y, zone->w, zone->h))
return zone;
}
}
l = con->zones; l = con->zones;
/* FIXME: Should return the zone the pointer is currently in */
return (E_Zone *)l->data; return (E_Zone *)l->data;
} }