add a small screen management interface to E_Comp, remove hardcoded x11 randr calls

this interface is extremely basic and should allow easy additions for other display
backends
This commit is contained in:
Mike Blumenkrantz 2015-04-22 18:14:55 -04:00
parent c9ff3b1434
commit a4ea6e7f23
6 changed files with 46 additions and 10 deletions

View File

@ -57,6 +57,20 @@ extern EAPI int E_EVENT_COMPOSITOR_ENABLE;
typedef void (*E_Comp_Grab_Cb)(void);
typedef struct E_Comp_Screen_Iface
{
/* can screen changes be made at all */
Eina_Bool (*available)(void);
/* begin listening for screen events */
void (*init)(void);
/* stop listening for screen events */
void (*shutdown)(void);
/* gather screen info */
E_Randr2 *(*create)(void);
/* apply current config */
void (*apply)(void);
} E_Comp_Screen_Iface;
struct _E_Comp
{
E_Object e_obj_inherit;
@ -98,6 +112,8 @@ struct _E_Comp
void *data;
} autoclose;
E_Comp_Screen_Iface *screen;
Eina_List *debug_rects;
Eina_List *ignore_wins;

View File

@ -4559,6 +4559,7 @@ _e_comp_x_xinerama_setup(int rw, int rh)
E_Randr2_Screen *s, *s2, *s_chosen;
Eina_Bool removed;
e_comp_x_randr_screen_iface_set();
if (!e_randr2_init()) return 0;
// put screens in tmp list

View File

@ -15,6 +15,14 @@ static Ecore_X_Randr_Mode _mode_screen_find(Ecore_X_Window root, E_Randr2_Screen
static Eina_List *handlers;
E_Comp_Screen_Iface xiface =
{
.available = e_comp_x_randr_available,
.init = e_comp_x_randr_init,
.shutdown = e_comp_x_randr_shutdown,
.create = e_comp_x_randr_create,
.apply = e_comp_x_randr_config_apply
};
static void
_e_comp_x_randr_pre_swap(void *data EINA_UNUSED, Evas *e EINA_UNUSED)
@ -818,6 +826,14 @@ e_comp_x_randr_create(void)
return r;
}
EAPI void
e_comp_x_randr_screen_iface_set(void)
{
if (e_comp->screen)
CRI("CANNOT SET XIFACE; IFACE ALREADY EXISTS!");
e_comp->screen = &xiface;
}
EAPI Eina_Bool
e_comp_x_randr_canvas_new(Ecore_Window parent, int w, int h)
{

View File

@ -7,5 +7,6 @@ EAPI void e_comp_x_randr_config_apply(void);
EAPI Eina_Bool e_comp_x_randr_available(void);
EAPI E_Randr2 *e_comp_x_randr_create(void);
EAPI void e_comp_x_randr_screen_iface_set(void);
EAPI Eina_Bool e_comp_x_randr_canvas_new(Ecore_Window parent, int w, int h);
#endif

View File

@ -7,10 +7,9 @@
#include "e_zone.h"
#include "e_desk.h"
#include "e_auth.h"
#include "e_randr2.h"
#ifdef NEED_X
# include "e_comp_x.h"
# include "e_randr2.h"
# include "e_comp_x_randr.h"
#endif
#include "e_pixmap.h"
#include "e_comp_object.h"
@ -149,6 +148,7 @@
#include "e_comp_canvas.h"
#include "e_utils.h"
#include "e_hints.h"
#include "e_comp_x_randr.h"
#if defined(HAVE_WAYLAND_CLIENTS) || defined(HAVE_WAYLAND_ONLY)
# include "e_comp_wl.h"

View File

@ -45,7 +45,7 @@ EINTERN Eina_Bool
e_randr2_init(void)
{
if (!E_EVENT_RANDR_CHANGE) E_EVENT_RANDR_CHANGE = ecore_event_type_new();
if (!e_comp_x_randr_available()) return EINA_FALSE;
if ((!e_comp->screen) || (!e_comp->screen->available) || (!e_comp->screen->available())) return EINA_FALSE;
// create data descriptors for config storage
_e_randr2_cfg_screen_edd =
E_CONFIG_DD_NEW("E_Config_Randr2_Screen", E_Config_Randr2_Screen);
@ -76,9 +76,10 @@ e_randr2_init(void)
E_CONFIG_VAL(D, T, ignore_acpi_events, UCHAR);
// set up events from the driver
e_comp_x_randr_init();
if (e_comp->screen->init)
e_comp->screen->init();
// get current screen info
e_randr2 = e_comp_x_randr_create();
e_randr2 = e_comp->screen->create();
// from screen info calculate screen max dimensions
_screen_config_maxsize();
// load config and apply it
@ -106,7 +107,8 @@ e_randr2_shutdown(void)
if (_screen_delay_timer) ecore_timer_del(_screen_delay_timer);
_screen_delay_timer = NULL;
// stop listening to driver info
e_comp_x_randr_shutdown();
if (e_comp->screen->shutdown)
e_comp->screen->shutdown();
// clear up all event handlers
E_FREE_LIST(_ev_handlers, ecore_event_handler_del);
// free up screen info
@ -138,7 +140,7 @@ e_randr2_screeninfo_update(void)
{
// re-fetch/update current screen info
_info_free(e_randr2);
e_randr2 = e_comp_x_randr_create();
e_randr2 = e_comp->screen->create();
_screen_config_maxsize();
}
@ -244,7 +246,7 @@ _do_apply(void)
// take current screen config and apply it to the driver
printf("RRR: re-get info before applying..\n");
_info_free(e_randr2);
e_randr2 = e_comp_x_randr_create();
e_randr2 = e_comp->screen->create();
_screen_config_maxsize();
printf("RRR: apply config...\n");
_config_apply(e_randr2, e_randr2_cfg);
@ -253,7 +255,7 @@ _do_apply(void)
printf("RRR: eval config...\n");
_screen_config_eval();
printf("RRR: really apply config...\n");
e_comp_x_randr_config_apply();
e_comp->screen->apply();
printf("RRR: done config...\n");
}
@ -525,7 +527,7 @@ _cb_screen_change_delay(void *data EINA_UNUSED)
Eina_Bool change = EINA_FALSE;
printf("RRR: reconfigure screens due to event...\n");
rtemp = e_comp_x_randr_create();
rtemp = e_comp->screen->create();
if (rtemp)
{
if (_screens_differ(e_randr2, rtemp)) change = EINA_TRUE;