You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

213 lines
5.1 KiB

#include "e.h"
static void _e_xinerama_clean(void);
static void _e_xinerama_update(void);
static int _e_xinerama_cb_screen_sort(const void *data1, const void *data2);
static Eina_List *all_screens = NULL;
static Eina_List *chosen_screens = NULL;
static Eina_List *fake_screens = NULL;
static void
_screen_free(E_Screen *scr)
{
free(scr->id);
free(scr);
}
EINTERN int
e_xinerama_init(void)
{
return 1;
}
EINTERN int
e_xinerama_shutdown(void)
{
_e_xinerama_clean();
return 1;
}
E_API void
e_xinerama_update(void)
{
_e_xinerama_clean();
_e_xinerama_update();
}
E_API const Eina_List *
e_xinerama_screens_get(void)
{
if (fake_screens) return fake_screens;
return chosen_screens;
}
E_API const Eina_List *
e_xinerama_screens_all_get(void)
{
if (fake_screens) return fake_screens;
return all_screens;
}
E_API void
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: ivan.briano@intel.com feature: new compositor removal: e_border, e_container, e_popup
9 years ago
e_xinerama_screens_set(Eina_List *screens)
{
E_FREE_LIST(all_screens, _screen_free);
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: ivan.briano@intel.com feature: new compositor removal: e_border, e_container, e_popup
9 years ago
chosen_screens = eina_list_free(chosen_screens);
all_screens = screens;
_e_xinerama_update();
}
EINTERN void
e_xinerama_fake_screen_del(int num)
{
Eina_List *l;
E_Screen *scr, *lscr;
int n = 0, x = 0;
/* this assumes X number of identical horizontal screens */
EINA_SAFETY_ON_NULL_RETURN(fake_screens);
l = eina_list_nth_list(fake_screens, num);
EINA_SAFETY_ON_NULL_RETURN(l);
scr = eina_list_data_get(l);
free(scr);
fake_screens = eina_list_remove_list(fake_screens, l);
EINA_LIST_FOREACH(fake_screens, l, lscr)
{
lscr->screen = n++;
lscr->x = x;
lscr->w = e_comp->w / eina_list_count(fake_screens);
x = lscr->x + lscr->w;
}
e_comp_canvas_update();
ecore_event_add(E_EVENT_RANDR_CHANGE, NULL, NULL, NULL);
}
EINTERN void
e_xinerama_fake_screen_append(void)
{
Eina_List *l;
E_Screen *lscr;
int n, x = 0;
/* this assumes X number of identical horizontal screens */
n = eina_list_count(fake_screens) + 1;
EINA_LIST_FOREACH(fake_screens, l, lscr)
{
lscr->x = x;
lscr->w = e_comp->w / n;
x = lscr->x + lscr->w;
}
e_xinerama_fake_screen_add(e_comp->w - (e_comp->w / n), 0, e_comp->w / n, e_comp->h);
e_comp_canvas_update();
ecore_event_add(E_EVENT_RANDR_CHANGE, NULL, NULL, NULL);
}
E_API void
e_xinerama_fake_screen_add(int x, int y, int w, int h)
{
E_Screen *scr;
scr = E_NEW(E_Screen, 1);
scr->screen = eina_list_count(fake_screens);
scr->escreen = scr->screen;
scr->x = x;
scr->y = y;
scr->w = w;
scr->h = h;
fake_screens = eina_list_append(fake_screens, scr);
}
E_API Eina_Bool
e_xinerama_fake_screens_exist(void)
{
return !!fake_screens;
}
/* local subsystem functions */
static void
_e_xinerama_clean(void)
{
E_FREE_LIST(all_screens, _screen_free);
chosen_screens = eina_list_free(chosen_screens);
E_FREE_LIST(fake_screens, _screen_free);
}
static void
_e_xinerama_update(void)
{
Eina_List *l;
E_Screen *scr;
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: ivan.briano@intel.com feature: new compositor removal: e_border, e_container, e_popup
9 years ago
unsigned int n = 0;
/* now go through all_screens... and build a list of chosen screens */
EINA_LIST_FOREACH(all_screens, l, scr)
{
Eina_List *ll;
E_Screen *scr2;
int add = 1;
Eina_List *removes;
removes = NULL;
/* does this screen intersect with any we have chosen? */
EINA_LIST_FOREACH(chosen_screens, ll, scr2)
{
/* if they intersect */
if (E_INTERSECTS(scr->x, scr->y, scr->w, scr->h,
scr2->x, scr2->y, scr2->w, scr2->h))
{
int sz, sz2;
/* calculate pixel area */
sz = scr->w * scr->h;
sz2 = scr2->w * scr2->h;
/* if the one we already have is bigger, DON'T add the new */
if (sz > sz2)
removes = eina_list_append(removes, scr2);
/* add the old to a list to remove */
else
add = 0;
}
}
/* if there are screens to remove - remove them */
EINA_LIST_FREE(removes, scr2)
{
chosen_screens = eina_list_remove(chosen_screens, scr2);
}
/* if this screen is to be added, add it */
if (add)
chosen_screens = eina_list_append(chosen_screens, scr);
}
chosen_screens = eina_list_sort(chosen_screens,
eina_list_count(chosen_screens),
_e_xinerama_cb_screen_sort);
INF("======================= screens:");
EINA_LIST_FOREACH(chosen_screens, l, scr)
{
INF("E INIT: XINERAMA CHOSEN: [%i][%i], %ix%i+%i+%i",
scr->screen, scr->escreen, scr->w, scr->h, scr->x, scr->y);
n++;
}
}
static int
_e_xinerama_cb_screen_sort(const void *data1, const void *data2)
{
const E_Screen *scr, *scr2;
int dif;
scr = data1;
scr2 = data2;
if (scr->x != scr2->x)
return scr->x - scr2->x;
else if (scr->y != scr2->y)
return scr->y - scr2->y;
else
{
dif = (scr2->w * scr2->h) - (scr->w * scr->h);
if (dif == 0) return scr->screen - scr2->screen;
}
return dif;
}