From: Leif Middelschulte <leif.middelschulte@gmail.com>

patch for ecore-x xrandr 1.3 support - breaks previous api. final api
change (i know about) before we go alpha. in to svn we go.



SVN revision: 51109
This commit is contained in:
Leif Middelschulte 2010-08-14 10:21:03 +00:00 committed by Carsten Haitzler
parent 966810eedb
commit e7e09623ef
8 changed files with 2753 additions and 377 deletions

View File

@ -70,6 +70,7 @@ typedef Ecore_X_ID Ecore_X_Randr_Output;
typedef Ecore_X_ID Ecore_X_Randr_Crtc;
typedef Ecore_X_ID Ecore_X_Randr_Mode;
typedef unsigned short Ecore_X_Randr_Size_ID;
typedef int Ecore_X_Randr_Screen;
typedef Ecore_X_ID Ecore_X_Device;
@ -167,20 +168,34 @@ typedef enum _Ecore_X_Window_Stack_Mode {
ECORE_X_WINDOW_STACK_OPPOSITE = 4
} Ecore_X_Window_Stack_Mode;
typedef enum _Ecore_X_Randr_Rotation {
ECORE_X_RANDR_ROT_0 = (1 << 0),
ECORE_X_RANDR_ROT_90 = (1 << 1),
ECORE_X_RANDR_ROT_180 = (1 << 2),
ECORE_X_RANDR_ROT_270 = (1 << 3),
ECORE_X_RANDR_FLIP_X = (1 << 4),
ECORE_X_RANDR_FLIP_Y = (1 << 5)
} Ecore_X_Randr_Rotation;
typedef enum _Ecore_X_Randr_Orientation {
ECORE_X_RANDR_ORIENTATION_ROT_0 = (1 << 0),
ECORE_X_RANDR_ORIENTATION_ROT_90 = (1 << 1),
ECORE_X_RANDR_ORIENTATION_ROT_180 = (1 << 2),
ECORE_X_RANDR_ORIENTATION_ROT_270 = (1 << 3),
ECORE_X_RANDR_ORIENTATION_FLIP_X = (1 << 4),
ECORE_X_RANDR_ORIENTATION_FLIP_Y = (1 << 5)
} Ecore_X_Randr_Orientation;
typedef enum _Ecore_X_Randr_Connection {
ECORE_X_RANDR_CONNECTED = 0,
ECORE_X_RANDR_DISCONNECTED = 1,
ECORE_X_RANDR_UNKNOWN_CONNECTION = 2
} Ecore_X_Randr_Connection;
typedef enum _Ecore_X_Randr_Connection_Status {
ECORE_X_RANDR_CONNECTION_STATUS_CONNECTED = 0,
ECORE_X_RANDR_CONNECTION_STATUS_DISCONNECTED = 1,
ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN = 2
} Ecore_X_Randr_Connection_Status;
typedef enum _Ecore_X_Randr_Output_Policy {
ECORE_X_RANDR_OUTPUT_POLICY_ABOVE = 1,
ECORE_X_RANDR_OUTPUT_POLICY_RIGHT = 2,
ECORE_X_RANDR_OUTPUT_POLICY_BELOW = 3,
ECORE_X_RANDR_OUTPUT_POLICY_LEFT = 4,
ECORE_X_RANDR_OUTPUT_POLICY_CLONE = 5
} Ecore_X_Randr_Output_Policy;
typedef enum _Ecore_X_Randr_Relative_Alignment {
ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE = 0,
ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL = 1,
ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR = 2
} Ecore_X_Randr_Relative_Alignment;
typedef enum _Ecore_X_Render_Subpixel_Order {
ECORE_X_RENDER_SUBPIXEL_ORDER_UNKNOWN = 0,
@ -360,6 +375,9 @@ typedef struct _Ecore_X_Event_Startup_Sequence Ecore_X_Event_Startup_Sequence;
typedef struct _Ecore_X_Event_Generic Ecore_X_Event_Generic;
typedef struct _Ecore_X_Randr_Screen_Size Ecore_X_Randr_Screen_Size;
typedef struct _Ecore_X_Randr_Screen_Size_MM Ecore_X_Randr_Screen_Size_MM;
struct _Ecore_X_Event_Mouse_In
{
int modifiers;
@ -697,42 +715,46 @@ struct _Ecore_X_Event_Sync_Alarm
Ecore_X_Sync_Alarm alarm;
};
struct _Ecore_X_Randr_Screen_Size
{
int width, height;
};
struct _Ecore_X_Randr_Screen_Size_MM
{
int width, height, width_mm, height_mm;
};
struct _Ecore_X_Event_Screen_Change
{
Ecore_X_Window win;
Ecore_X_Window root;
int width;
int height;
Ecore_X_Randr_Screen_Size_MM size; /* in pixel and millimeters */
Ecore_X_Time time;
Ecore_X_Time config_time;
int mm_width; /* in millimeters */
int mm_height; /* in millimeters */
Ecore_X_Randr_Rotation rotation;
Ecore_X_Randr_Orientation orientation;
Ecore_X_Render_Subpixel_Order subpixel_order;
Ecore_X_Randr_Size_ID size_id;
};
struct _Ecore_X_Event_Randr_Crtc_Change
{
Ecore_X_Window win;
Ecore_X_Randr_Crtc crtc;
Ecore_X_Randr_Mode mode;
Ecore_X_Randr_Rotation rotation;
int x;
int y;
int width;
int height;
Ecore_X_Window win;
Ecore_X_Randr_Crtc crtc;
Ecore_X_Randr_Mode mode;
Ecore_X_Randr_Orientation orientation;
Eina_Rectangle geo;
};
struct _Ecore_X_Event_Randr_Output_Change
{
Ecore_X_Window win;
Ecore_X_Randr_Output output;
Ecore_X_Randr_Crtc crtc;
Ecore_X_Randr_Mode mode;
Ecore_X_Randr_Rotation rotation;
Ecore_X_Randr_Connection connection;
Ecore_X_Render_Subpixel_Order subpixel_order;
Ecore_X_Window win;
Ecore_X_Randr_Output output;
Ecore_X_Randr_Crtc crtc;
Ecore_X_Randr_Mode mode;
Ecore_X_Randr_Orientation orientation;
Ecore_X_Randr_Connection_Status connection;
Ecore_X_Render_Subpixel_Order subpixel_order;
};
struct _Ecore_X_Event_Randr_Output_Property_Notify
@ -2451,52 +2473,339 @@ EAPI int ecore_x_xregion_rect_contain(Ecore_X_XRegion *region
Ecore_X_Rectangle *rect);
/* ecore_x_randr.c */
typedef struct _Ecore_X_Screen_Size Ecore_X_Screen_Size;
struct _Ecore_X_Screen_Size
/* The usage of 'Ecore_X_Randr_None' or 'Ecore_X_Randr_Unset'
* depends on the context. In most cases 'Ecore_X_Randr_Unset'
* can be used, but in some cases -1 is a special value to
* functions, thus 'Ecore_X_Randr_None' (=0) musst be used.
*/
typedef short Ecore_X_Randr_Refresh_Rate;
typedef int Ecore_X_Randr_Crtc_Gamma;
typedef int Ecore_X_Randr_Signal_Format;
typedef int Ecore_X_Randr_Signal_Property;
typedef int Ecore_X_Randr_Connector_Type;
typedef struct _Ecore_X_Randr_Mode_Info
{
int width, height;
};
Ecore_X_ID xid;
unsigned int width;
unsigned int height;
unsigned long dotClock;
unsigned int hSyncStart;
unsigned int hSyncEnd;
unsigned int hTotal;
unsigned int hSkew;
unsigned int vSyncStart;
unsigned int vSyncEnd;
unsigned int vTotal;
char *name;
unsigned int nameLength;
unsigned long modeFlags;
} Ecore_X_Randr_Mode_Info;
typedef struct _Ecore_X_Screen_Refresh_Rate Ecore_X_Screen_Refresh_Rate;
struct _Ecore_X_Screen_Refresh_Rate
{
int rate;
};
EAPI int ecore_x_randr_version_get(
void);
EAPI const Eina_Bool ecore_x_randr_query(void);
EAPI int ecore_x_randr_query(void);
EAPI int ecore_x_randr_events_select(
Ecore_X_Window win,
int on);
EAPI void ecore_x_randr_get_screen_info_prefetch(
Ecore_X_Window window);
EAPI void ecore_x_randr_get_screen_info_fetch(void);
EAPI Ecore_X_Randr_Rotation ecore_x_randr_screen_rotations_get(
/* ecore_x_randr_11.c */
EAPI Ecore_X_Randr_Orientation
ecore_x_randr_screen_primary_output_orientations_get(
Ecore_X_Window root);
EAPI Ecore_X_Randr_Rotation ecore_x_randr_screen_rotation_get(
EAPI Ecore_X_Randr_Orientation
ecore_x_randr_screen_primary_output_orientation_get(
Ecore_X_Window root);
EAPI void ecore_x_randr_screen_rotation_set(
Ecore_X_Window root,
Ecore_X_Randr_Rotation rot);
EAPI Ecore_X_Screen_Size * ecore_x_randr_screen_sizes_get(
EAPI Eina_Bool
ecore_x_randr_screen_primary_output_orientation_set(
Ecore_X_Window root,
int *num);
EAPI Ecore_X_Screen_Size ecore_x_randr_current_screen_size_get(
Ecore_X_Window root);
EAPI int ecore_x_randr_screen_size_set(
Ecore_X_Window root,
Ecore_X_Screen_Size size);
EAPI Ecore_X_Screen_Refresh_Rate * ecore_x_randr_screen_refresh_rates_get(
Ecore_X_Randr_Orientation
orientation);
EAPI Ecore_X_Randr_Screen_Size_MM *
ecore_x_randr_screen_primary_output_sizes_get(
Ecore_X_Window root,
int size_id,
int *num);
EAPI Ecore_X_Screen_Refresh_Rate ecore_x_randr_current_screen_refresh_rate_get(
int *num);
EAPI void
ecore_x_randr_screen_primary_output_current_size_get(
Ecore_X_Window root,
int *w,
int *h,
int *w_mm,
int *h_mm,
int *size_index);
EAPI Eina_Bool
ecore_x_randr_screen_primary_output_size_set(Ecore_X_Window root,
int size_index);
EAPI Ecore_X_Randr_Refresh_Rate
ecore_x_randr_screen_primary_output_current_refresh_rate_get(
Ecore_X_Window root);
EAPI Ecore_X_Randr_Refresh_Rate *
ecore_x_randr_screen_primary_output_refresh_rates_get(Ecore_X_Window root,
int size_index,
int *num);
EAPI Eina_Bool
ecore_x_randr_screen_primary_output_refresh_rate_set(
Ecore_X_Window root,
int size_index,
Ecore_X_Randr_Refresh_Rate
rate);
EAPI int ecore_x_randr_screen_refresh_rate_set(
Ecore_X_Window root,
Ecore_X_Screen_Size size,
Ecore_X_Screen_Refresh_Rate rate);
/* ecore_x_randr_12.c */
EAPI void
ecore_x_randr_events_select(Ecore_X_Window win,
Eina_Bool on);
EAPI void
ecore_x_randr_screen_current_size_get(Ecore_X_Window root,
int *w,
int *h,
int *w_mm,
int *h_mm);
EAPI void
ecore_x_randr_screen_size_range_get(Ecore_X_Window root,
int *wmin,
int *hmin,
int *wmax,
int *hmax);
EAPI void ecore_x_randr_screen_reset(
Ecore_X_Window root);
EAPI Eina_Bool
ecore_x_randr_screen_current_size_set(Ecore_X_Window root,
int w,
int h,
int w_mm,
int h_mm);
EAPI Ecore_X_Randr_Mode_Info **
ecore_x_randr_modes_info_get(Ecore_X_Window root,
int *num);
EAPI Ecore_X_Randr_Mode_Info *
ecore_x_randr_mode_info_get(Ecore_X_Window root,
Ecore_X_Randr_Mode mode);
EAPI void
ecore_x_randr_mode_info_free(
Ecore_X_Randr_Mode_Info *mode_info);
EAPI Ecore_X_Randr_Crtc * ecore_x_randr_crtcs_get(
Ecore_X_Window root,
int *num);
EAPI Ecore_X_Randr_Output *ecore_x_randr_outputs_get(
Ecore_X_Window root,
int *num);
EAPI Ecore_X_Randr_Output *
ecore_x_randr_current_output_get(
Ecore_X_Window window,
int *num);
EAPI Ecore_X_Randr_Crtc *
ecore_x_randr_current_crtc_get(Ecore_X_Window window,
int *num);
EAPI Ecore_X_Randr_Output *
ecore_x_randr_crtc_outputs_get(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc,
int *num);
EAPI Ecore_X_Randr_Output *
ecore_x_randr_crtc_possible_outputs_get(
Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc,
int *num);
EAPI void
ecore_x_randr_crtc_geometry_get(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc,
int *x,
int *y,
int *w,
int *h);
EAPI void
ecore_x_randr_crtc_pos_get(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc,
int *x,
int *y);
EAPI Eina_Bool
ecore_x_randr_crtc_pos_set(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc,
int x,
int y);
EAPI Ecore_X_Randr_Mode
ecore_x_randr_crtc_mode_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc);
EAPI Eina_Bool
ecore_x_randr_crtc_mode_set(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc,
Ecore_X_Randr_Output *outputs,
int noutputs,
Ecore_X_Randr_Mode mode);
EAPI void
ecore_x_randr_crtc_size_get(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc,
int *w,
int *h);
EAPI Ecore_X_Randr_Refresh_Rate
ecore_x_randr_crtc_refresh_rate_get(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc,
Ecore_X_Randr_Mode mode);
EAPI Ecore_X_Randr_Orientation
ecore_x_randr_crtc_orientations_get(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc);
EAPI Ecore_X_Randr_Orientation
ecore_x_randr_crtc_orientation_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc);
EAPI Eina_Bool
ecore_x_randr_crtc_orientation_set(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc,
const Ecore_X_Randr_Orientation orientation);
EAPI Eina_Bool
ecore_x_randr_crtc_clone_set(Ecore_X_Window root,
Ecore_X_Randr_Crtc original,
Ecore_X_Randr_Crtc clone);
EAPI Eina_Bool
ecore_x_randr_crtc_settings_set(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc,
Ecore_X_Randr_Output *outputs,
int noutputs,
int x,
int y,
Ecore_X_Randr_Mode mode,
Ecore_X_Randr_Orientation orientation);
EAPI Eina_Bool
ecore_x_randr_crtc_pos_relative_set(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc_r1,
Ecore_X_Randr_Crtc crtc_r2,
Ecore_X_Randr_Output_Policy policy,
Ecore_X_Randr_Relative_Alignment alignment);
EAPI Ecore_X_Randr_Mode *
ecore_x_randr_output_modes_get(Ecore_X_Window root,
Ecore_X_Randr_Output output,
int *num,
int *npreferred);
EAPI Ecore_X_Randr_Output * ecore_x_randr_output_clones_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num);
EAPI Ecore_X_Randr_Crtc * ecore_x_randr_output_possible_crtcs_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num);
EAPI Ecore_X_Randr_Crtc
ecore_x_randr_output_crtc_get(Ecore_X_Window root,
Ecore_X_Randr_Output output);
EAPI char *
ecore_x_randr_output_name_get(Ecore_X_Window root,
Ecore_X_Randr_Output output,
int *len);
EAPI int
ecore_x_randr_crtc_gamma_ramp_size_get(
Ecore_X_Randr_Crtc crtc);
EAPI Ecore_X_Randr_Crtc_Gamma **
ecore_x_randr_crtc_gamma_ramps_get(Ecore_X_Randr_Crtc crtc);
EAPI Eina_Bool
ecore_x_randr_crtc_gamma_ramps_set(Ecore_X_Randr_Crtc crtc,
const Ecore_X_Randr_Crtc_Gamma *red,
const Ecore_X_Randr_Crtc_Gamma *green,
const Ecore_X_Randr_Crtc_Gamma *blue);
EAPI Eina_Bool
ecore_x_randr_move_all_crtcs_but(Ecore_X_Window root,
const Ecore_X_Randr_Crtc *not_moved,
int nnot_moved,
int dx,
int dy);
EAPI Eina_Bool ecore_x_randr_move_crtcs(
Ecore_X_Window root,
const Ecore_X_Randr_Crtc *crtcs,
int ncrtc,
int dx,
int dy);
EAPI void
ecore_x_randr_mode_size_get(Ecore_X_Window root,
Ecore_X_Randr_Mode mode,
int *w,
int *h);
EAPI Ecore_X_Randr_Connection_Status
ecore_x_randr_output_connection_status_get(Ecore_X_Window root,
Ecore_X_Randr_Output output);
EAPI void
ecore_x_randr_output_size_mm_get(Ecore_X_Window root,
Ecore_X_Randr_Output output,
int *w,
int *h);
EAPI Eina_Bool
ecore_x_randr_output_crtc_set(Ecore_X_Window root,
Ecore_X_Randr_Output output,
const Ecore_X_Randr_Crtc crtc);
/* ecore_x_randr_13.c */
EAPI void
ecore_x_randr_screen_backlight_level_set(Ecore_X_Window root, double level);
EAPI double
ecore_x_randr_output_backlight_level_get(Ecore_X_Window root,
Ecore_X_Randr_Output output);
EAPI Eina_Bool
ecore_x_randr_output_backlight_level_set(Ecore_X_Window root,
Ecore_X_Randr_Output output,
double level);
EAPI Ecore_X_Randr_Output
ecore_x_randr_primary_output_get(Ecore_X_Window root);
EAPI void
ecore_x_randr_primary_output_set(Ecore_X_Window root,
Ecore_X_Randr_Output output);
EAPI Ecore_X_Render_Subpixel_Order
ecore_x_randr_output_subpixel_order_get(Ecore_X_Window root,
Ecore_X_Randr_Output output);
EAPI unsigned char *
ecore_x_randr_output_edid_get(Ecore_X_Window root,
Ecore_X_Randr_Output output,
unsigned long *length);
EAPI Ecore_X_Randr_Output *
ecore_x_randr_output_wired_clones_get(Ecore_X_Window root,
Ecore_X_Randr_Output output,
int *num);
EAPI Ecore_X_Randr_Output **
ecore_x_randr_output_compatibility_list_get(Ecore_X_Window root,
Ecore_X_Randr_Output output,
int *num);
EAPI Ecore_X_Randr_Signal_Format *
ecore_x_randr_output_signal_formats_get(Ecore_X_Window root,
Ecore_X_Randr_Output output,
int *num);
EAPI Eina_Bool
ecore_x_randr_output_signal_format_set(Ecore_X_Window root,
Ecore_X_Randr_Output output,
Ecore_X_Randr_Signal_Format *signal);
EAPI Ecore_X_Randr_Signal_Property *
ecore_x_randr_output_signal_properties_get(Ecore_X_Window root,
Ecore_X_Randr_Output output,
int *num);
EAPI int
ecore_x_randr_output_connector_number_get(Ecore_X_Window root,
Ecore_X_Randr_Output output);
EAPI Ecore_X_Randr_Connector_Type
ecore_x_randr_output_connector_type_get(Ecore_X_Window root,
Ecore_X_Randr_Output output);
EAPI Eina_Rectangle *
ecore_x_randr_crtc_panning_area_get(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc,
int *x,
int *y,
int *w,
int *h);
EAPI Eina_Bool
ecore_x_randr_crtc_panning_area_set(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc,
int x,
const int y,
const int w,
const int h);
EAPI Eina_Rectangle *
ecore_x_randr_crtc_tracking_area_get(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc,
int *x,
int *y,
int *w,
int *h);
EAPI Eina_Bool
ecore_x_randr_crtc_tracking_area_set(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc,
int x,
const int y,
const int w,
const int h);
EAPI Eina_Rectangle *
ecore_x_randr_crtc_border_area_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc);
EAPI Eina_Bool
ecore_x_randr_crtc_border_area_set(Ecore_X_Window root,
Ecore_X_Randr_Crtc crtc,
int left,
const int top,
const int right,
const int bottom);
/* XRender Support (horrendously incomplete) */
typedef Ecore_X_ID Ecore_X_Picture;

View File

@ -34,6 +34,9 @@ ecore_x.c \
ecore_x_dnd.c \
ecore_x_sync.c \
ecore_x_randr.c \
ecore_x_randr_11.c \
ecore_x_randr_12.c \
ecore_x_randr_13.c \
ecore_x_fixes.c \
ecore_x_damage.c \
ecore_x_composite.c \

View File

@ -2246,13 +2246,13 @@ _ecore_x_event_handle_randr_change(XEvent *xevent)
e->win = randr_event->window;
e->root = randr_event->root;
e->width = randr_event->width;
e->height = randr_event->height;
e->size.width = randr_event->width;
e->size.height = randr_event->height;
e->time = randr_event->timestamp;
e->config_time = randr_event->config_timestamp;
e->mm_width = randr_event->mwidth;
e->mm_height = randr_event->mheight;
e->rotation = randr_event->rotation;
e->size.width_mm = randr_event->mwidth;
e->size.height_mm = randr_event->mheight;
e->orientation = randr_event->rotation;
e->subpixel_order = randr_event->subpixel_order;
ecore_event_add(ECORE_X_EVENT_SCREEN_CHANGE, e, NULL, NULL);
} /* _ecore_x_event_handle_randr_change */
@ -2272,11 +2272,11 @@ _ecore_x_event_handle_randr_notify_crtc_change(const XRRNotifyEvent *xevent)
e->win = randr_event->window;
e->crtc = randr_event->crtc;
e->mode = randr_event->mode;
e->rotation = randr_event->rotation;
e->x = randr_event->x;
e->y = randr_event->y;
e->width = randr_event->width;
e->height = randr_event->height;
e->orientation = randr_event->rotation;
e->geo.x = randr_event->x;
e->geo.y = randr_event->y;
e->geo.w = randr_event->width;
e->geo.h = randr_event->height;
ecore_event_add(ECORE_X_EVENT_RANDR_CRTC_CHANGE, e, NULL, NULL);
} /* _ecore_x_event_handle_randr_notify_crtc_change */
@ -2296,7 +2296,7 @@ _ecore_x_event_handle_randr_notify_output_change(const XRRNotifyEvent *xevent)
e->output = randr_event->output;
e->crtc = randr_event->crtc;
e->mode = randr_event->mode;
e->rotation = randr_event->rotation;
e->orientation = randr_event->rotation;
e->connection = randr_event->connection;
e->subpixel_order = randr_event->subpixel_order;
ecore_event_add(ECORE_X_EVENT_RANDR_OUTPUT_CHANGE, e, NULL, NULL);

View File

@ -0,0 +1,7 @@
#ifndef ECORE_X_INLINE_X
#define ECORE_X_INLINE_X
inline Eina_Bool _ecore_x_randr_root_validate(Ecore_X_Window root);
inline Eina_Bool _ecore_x_randr_output_validate(Ecore_X_Window root,
Ecore_X_Randr_Output
output);
#endif

View File

@ -2,15 +2,27 @@
# include <config.h>
#endif /* ifdef HAVE_CONFIG_H */
#include <stdlib.h>
#include "ecore_x_private.h"
#include "ecore_x_inline.x"
static int _randr_available = 0;
static Eina_Bool _randr_available = EINA_FALSE;
#ifdef ECORE_XRANDR
static int _randr_major, _randr_minor, _randr_version;
static int _randr_major, _randr_minor;
int _randr_version;
#define RANDR_1_1 ((1 << 16) | 1)
#define RANDR_1_2 ((1 << 16) | 2)
#define RANDR_1_3 ((1 << 16) | 3)
#define RANDR_VALIDATE_ROOT(screen, \
root) ((screen = \
XRRRootToScreen(_ecore_x_disp, \
root)) != -1)
#define Ecore_X_Randr_Unset -1
XRRScreenResources * (*_ecore_x_randr_get_screen_resources)(Display * dpy,
Window window);
#endif /* ifdef ECORE_XRANDR */
void
@ -21,313 +33,69 @@ _ecore_x_randr_init(void)
_randr_minor = 3;
_randr_version = 0;
_ecore_x_disp = _ecore_x_disp;
_ecore_x_randr_get_screen_resources = NULL;
if (XRRQueryVersion(_ecore_x_disp, &_randr_major, &_randr_minor))
{
_randr_version = (_randr_major << 16) | _randr_minor;
_randr_available = 1;
}
{
_randr_version = (_randr_major << 16) | _randr_minor;
if (_randr_version >= RANDR_1_3)
_ecore_x_randr_get_screen_resources = XRRGetScreenResourcesCurrent;
else if (_randr_version == RANDR_1_2)
_ecore_x_randr_get_screen_resources = XRRGetScreenResources;
_randr_available = EINA_TRUE;
}
else
_randr_available = 0;
_randr_available = EINA_FALSE;
#else /* ifdef ECORE_XRANDR */
_randr_available = 0;
#endif /* ifdef ECORE_XRANDR */
} /* _ecore_x_randr_init */
#else
_randr_available = EINA_FALSE;
#endif
}
EAPI int
/*
* @brief query whether randr is available or not
* @return EINA_TRUE, if extension is available, else EINA_FALSE
*/
EAPI const Eina_Bool
ecore_x_randr_query(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
return _randr_available;
} /* ecore_x_randr_query */
}
/*
* @return version of the RandRR extension supported by the server or,
* in case RandRR extension is not available, Ecore_X_Randr_Unset (=-1).
* bit version information: 31 MAJOR 16 | 15 MINOR 0
*/
EAPI int
ecore_x_randr_events_select(Ecore_X_Window win, int on)
ecore_x_randr_version_get(void)
{
#ifdef ECORE_XRANDR
int mask;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!on)
mask = 0;
if (_randr_available)
{
return _randr_version;
}
else
{
mask = RRScreenChangeNotifyMask;
if (_randr_version >= RANDR_1_2)
mask |= (RRCrtcChangeNotifyMask |
RROutputChangeNotifyMask |
RROutputPropertyNotifyMask);
}
{
return Ecore_X_Randr_Unset;
}
XRRSelectInput(_ecore_x_disp, win, mask);
#endif
}
return 1;
#else /* ifdef ECORE_XRANDR */
return 0;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_events_select */
EAPI Ecore_X_Randr_Rotation
ecore_x_randr_screen_rotations_get(Ecore_X_Window root)
inline Eina_Bool
_ecore_x_randr_root_validate(Ecore_X_Window root)
{
#ifdef ECORE_XRANDR
Rotation rot, crot;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
rot = XRRRotations(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
root), &crot);
return rot;
#else /* ifdef ECORE_XRANDR */
return 0;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_rotations_get */
EAPI Ecore_X_Randr_Rotation
ecore_x_randr_screen_rotation_get(Ecore_X_Window root)
{
#ifdef ECORE_XRANDR
Rotation crot = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
XRRRotations(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp, root), &crot);
return crot;
#else /* ifdef ECORE_XRANDR */
return 0;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_rotation_get */
EAPI void
ecore_x_randr_screen_rotation_set(Ecore_X_Window root,
Ecore_X_Randr_Rotation rot)
{
#ifdef ECORE_XRANDR
XRRScreenConfiguration *xrrcfg;
SizeID sizeid;
Rotation crot;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
xrrcfg = XRRGetScreenInfo(_ecore_x_disp, root);
if (!xrrcfg)
return;
sizeid = XRRConfigCurrentConfiguration(xrrcfg, &crot);
XRRSetScreenConfig(_ecore_x_disp, xrrcfg, root, sizeid, rot, CurrentTime);
XRRFreeScreenConfigInfo(xrrcfg);
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_rotation_set */
EAPI Ecore_X_Screen_Size *
ecore_x_randr_screen_sizes_get(Ecore_X_Window root, int *num)
{
#ifdef ECORE_XRANDR
Ecore_X_Screen_Size *ret;
XRRScreenSize *sizes;
int i, n;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (num)
*num = 0;
/* we don't have to free sizes, no idea why not */
sizes = XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp, root), &n);
ret = calloc(n, sizeof(Ecore_X_Screen_Size));
if (!ret)
return NULL;
if (num)
*num = n;
for (i = 0; i < n; i++)
{
ret[i].width = sizes[i].width;
ret[i].height = sizes[i].height;
}
return ret;
#else /* ifdef ECORE_XRANDR */
if (num)
*num = 0;
return NULL;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_sizes_get */
EAPI Ecore_X_Screen_Size
ecore_x_randr_current_screen_size_get(Ecore_X_Window root)
{
Ecore_X_Screen_Size ret = { -1, -1 };
#ifdef ECORE_XRANDR
XRRScreenSize *sizes;
XRRScreenConfiguration *sc;
SizeID size_index;
Rotation rotation;
int n;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
sc = XRRGetScreenInfo(_ecore_x_disp, root);
if (!sc)
{
ERR("Couldn't get screen information for %d", root);
return ret;
}
size_index = XRRConfigCurrentConfiguration(sc, &rotation);
sizes = XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp, root), &n);
if (size_index < n)
{
ret.width = sizes[size_index].width;
ret.height = sizes[size_index].height;
}
XRRFreeScreenConfigInfo(sc);
#endif /* ifdef ECORE_XRANDR */
return ret;
} /* ecore_x_randr_current_screen_size_get */
EAPI int
ecore_x_randr_screen_size_set(Ecore_X_Window root, Ecore_X_Screen_Size size)
{
#ifdef ECORE_XRANDR
XRRScreenConfiguration *sc;
XRRScreenSize *sizes;
int i, n, size_index = -1;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
sizes = XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp, root), &n);
for (i = 0; i < n; i++)
{
if ((sizes[i].width == size.width) && (sizes[i].height == size.height))
{
size_index = i;
break;
}
}
if (size_index == -1)
return 0;
sc = XRRGetScreenInfo(_ecore_x_disp, root);
if (XRRSetScreenConfig(_ecore_x_disp, sc,
root, size_index,
RR_Rotate_0, CurrentTime))
{
ERR("Can't set new screen size!");
XRRFreeScreenConfigInfo(sc);
return 0;
}
XRRFreeScreenConfigInfo(sc);
return 1;
#else /* ifdef ECORE_XRANDR */
return 0;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_size_set */
EAPI Ecore_X_Screen_Refresh_Rate
ecore_x_randr_current_screen_refresh_rate_get(Ecore_X_Window root)
{
Ecore_X_Screen_Refresh_Rate ret = { -1 };
#ifdef ECORE_XRANDR
XRRScreenConfiguration *sc;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
sc = XRRGetScreenInfo(_ecore_x_disp, root);
if (!sc)
{
ERR("Couldn't get screen information for %d", root);
return ret;
}
ret.rate = XRRConfigCurrentRate(sc);
XRRFreeScreenConfigInfo(sc);
#endif /* ifdef ECORE_XRANDR */
return ret;
} /* ecore_x_randr_current_screen_refresh_rate_get */
EAPI Ecore_X_Screen_Refresh_Rate *
ecore_x_randr_screen_refresh_rates_get(Ecore_X_Window root,
int size_id,
int *num)
{
#ifdef ECORE_XRANDR
Ecore_X_Screen_Refresh_Rate *ret = NULL;
XRRScreenConfiguration *sc;
short *rates;
int i, n;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (num)
*num = 0;
sc = XRRGetScreenInfo(_ecore_x_disp, root);
if (!sc)
{
ERR("Couldn't get screen information for %d", root);
return ret;
}
rates = XRRRates(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
root), size_id, &n);
ret = calloc(n, sizeof(Ecore_X_Screen_Refresh_Rate));
if (!ret)
{
XRRFreeScreenConfigInfo(sc);
return NULL;
}
if (num)
*num = n;
for (i = 0; i < n; i++)
{
ret[i].rate = rates[i];
}
XRRFreeScreenConfigInfo(sc);
return ret;
#else /* ifdef ECORE_XRANDR */
if (num)
*num = 0;
return NULL;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_refresh_rates_get */
EAPI int
ecore_x_randr_screen_refresh_rate_set(Ecore_X_Window root,
Ecore_X_Screen_Size size,
Ecore_X_Screen_Refresh_Rate rate)
{
#ifdef ECORE_XRANDR
XRRScreenConfiguration *sc;
XRRScreenSize *sizes;
int i, n, size_index = -1;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
sizes = XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp, root), &n);
for (i = 0; i < n; i++)
{
if ((sizes[i].width == size.width) && (sizes[i].height == size.height))
{
size_index = i;
break;
}
}
if (size_index == -1)
return 0;
sc = XRRGetScreenInfo(_ecore_x_disp, root);
if (XRRSetScreenConfigAndRate(_ecore_x_disp, sc,
root, size_index,
RR_Rotate_0, rate.rate, CurrentTime))
{
ERR("Can't set new screen size and refresh rate!");
XRRFreeScreenConfigInfo(sc);
return 0;
}
XRRFreeScreenConfigInfo(sc);
return 1;
#else /* ifdef ECORE_XRANDR */
return 1;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_refresh_rate_set */
Ecore_X_Randr_Screen scr = -1;
if (root && RANDR_VALIDATE_ROOT(scr, root))
return EINA_TRUE;
else
return EINA_FALSE;
#else
return EINA_FALSE;
#endif
}

View File

@ -0,0 +1,329 @@
/*
* vim:ts=8:sw=3:sts=8:expandtab:cino=>5n-3f0^-2{2
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif /* ifdef HAVE_CONFIG_H */
#include "ecore_x_private.h"
#include "ecore_x_inline.x"
#define Ecore_X_Randr_None 0
#ifdef ECORE_XRANDR
#define RANDR_1_1 ((1 << 16) | 1)
#define RANDR_VALIDATE_ROOT(screen,\
root) ((screen =\
XRRRootToScreen(_ecore_x_disp,\
root)) != -1)
#define RANDR_CHECK_1_1_RET(ret) if(_randr_version < RANDR_1_1) return ret
extern XRRScreenResources * (*_ecore_x_randr_get_screen_resources)(Display *
dpy,
Window
window);
extern int _randr_version;
#endif /* ifdef ECORE_XRANDR */
/*
* @param root window which's primary output will be queried
*/
EAPI Ecore_X_Randr_Orientation
ecore_x_randr_screen_primary_output_orientations_get(Ecore_X_Window root)
{
#ifdef ECORE_XRANDR
Rotation rot = Ecore_X_Randr_None, crot;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
rot =
XRRRotations(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
root), &crot);
return rot;
#else /* ifdef ECORE_XRANDR */
return Ecore_X_Randr_None;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_primary_output_orientations_get */
/*
* @param root window which's primary output will be queried
* @return the current orientation of the root window's screen primary output
*/
EAPI Ecore_X_Randr_Orientation
ecore_x_randr_screen_primary_output_orientation_get(Ecore_X_Window root)
{
#ifdef ECORE_XRANDR
Rotation crot = Ecore_X_Randr_None;
XRRRotations(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
root), &crot);
return crot;
#else /* ifdef ECORE_XRANDR */
return Ecore_X_Randr_None;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_primary_output_orientation_get */
/*
* @brief sets a given screen's primary output's orientation
* @param root window which's screen's primary output will be queried
* @param orientation orientation which should be set for the root window's screen primary output
* @return EINA_TRUE if the primary output's orientation could be successfully altered
*/
EAPI Eina_Bool
ecore_x_randr_screen_primary_output_orientation_set(
Ecore_X_Window root,
Ecore_X_Randr_Orientation
orientation)
{
#ifdef ECORE_XRANDR
XRRScreenConfiguration *xrr_screen_cfg = NULL;
int sizeid;
Rotation crot;
Eina_Bool ret = EINA_FALSE;
if (!(xrr_screen_cfg = XRRGetScreenInfo(_ecore_x_disp, root)))
return EINA_FALSE;
sizeid = XRRConfigCurrentConfiguration(xrr_screen_cfg, &crot);
if (!XRRSetScreenConfig(_ecore_x_disp, xrr_screen_cfg, root, sizeid,
orientation, CurrentTime))
ret = EINA_TRUE;
if (xrr_screen_cfg)
XRRFreeScreenConfigInfo(xrr_screen_cfg);
return ret;
#else /* ifdef ECORE_XRANDR */
return EINA_FALSE;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_primary_output_orientation_set */
/*
* @brief gets a screen's primary output's possible sizes
* @param root window which's primary output will be queried
* @param num number of sizes reported as supported by the screen's primary output
* @return an array of sizes reported as supported by the screen's primary output or - if query failed - NULL
*/
EAPI Ecore_X_Randr_Screen_Size_MM *
ecore_x_randr_screen_primary_output_sizes_get(Ecore_X_Window root, int *num)
{
#ifdef ECORE_XRANDR
Ecore_X_Randr_Screen_Size_MM *ret = NULL;
XRRScreenSize *sizes;
int i, n;
/* we don't have to free sizes, because they're hold in a cache inside X*/
sizes =
XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
root), &n);
ret = calloc(n, sizeof(Ecore_X_Randr_Screen_Size_MM));
if (!ret)
return NULL;
if (num)
*num = n;
for (i = 0; i < n; i++)
{
ret[i].width = sizes[i].width;
ret[i].height = sizes[i].height;
ret[i].width_mm = sizes[i].mwidth;
ret[i].height_mm = sizes[i].mheight;
}
return ret;
#else /* ifdef ECORE_XRANDR */
return NULL;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_primary_output_sizes_get */
/*
* @brief get the current set size of a given screen's primary output
* @param root window which's primary output will be queried
* @param w the current size's width
* @param h the current size's height
* @param w_mm the current size's width in mm
* @param h_mm the current size's height in mm
* @param size_index of current set size to be used with ecore_x_randr_primary_output_size_set()
*/
EAPI void
ecore_x_randr_screen_primary_output_current_size_get(Ecore_X_Window root,
int *w,
int *h,
int *w_mm,
int *h_mm,
int *size_index)
{
#ifdef ECORE_XRANDR
XRRScreenSize *sizes;
XRRScreenConfiguration *sc = NULL;
int index;
Rotation orientation;
int n;
if (!(sc = XRRGetScreenInfo(_ecore_x_disp, root)))
{
ERR("Couldn't get screen information for %d", root);
return;
}
index = XRRConfigCurrentConfiguration(sc, &orientation);
sizes =
XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
root), &n);
if ((index < n) && (index >= 0))
{
if (w)
*w = sizes[index].width;
if (h)
*h = sizes[index].height;
if (w_mm)
*w_mm = sizes[index].mwidth;
if (h_mm)
*h_mm = sizes[index].mheight;
if (size_index)
*size_index = index;
}
XRRFreeScreenConfigInfo(sc);
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_primary_output_current_size_get */
/*
* @brief sets a given screen's primary output size, but disables all other outputs at the same time
* @param root window which's primary output will be queried
* @param size_index within the list of sizes reported as supported by the root window's screen primary output
* @return EINA_TRUE on success, EINA_FALSE on failure due to e.g. invalid times
*/
EAPI Eina_Bool
ecore_x_randr_screen_primary_output_size_set(Ecore_X_Window root,
int size_index)
{
#ifdef ECORE_XRANDR
XRRScreenConfiguration *sc = NULL;
XRRScreenSize *sizes;
Eina_Bool ret = EINA_FALSE;
int nsizes = 0;
if (size_index >= 0 && _ecore_x_randr_root_validate(root))
{
sizes =
XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
root), &nsizes);
if (size_index < nsizes)
{
sc = XRRGetScreenInfo(_ecore_x_disp, root);
if (!XRRSetScreenConfig(_ecore_x_disp, sc,
root, size_index,
ECORE_X_RANDR_ORIENTATION_ROT_0, CurrentTime))
{
ret = EINA_TRUE;
}
if (sc)
XRRFreeScreenConfigInfo(sc);
}
}
return ret;
#else /* ifdef ECORE_XRANDR */
return EINA_FALSE;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_primary_output_size_set */
/*
* @param root window which's primary output will be queried
* @return currently used refresh rate or - if request failed or RandRR is not available - 0.0
*/
EAPI Ecore_X_Randr_Refresh_Rate
ecore_x_randr_screen_primary_output_current_refresh_rate_get(
Ecore_X_Window root)
{
#ifdef ECORE_XRANDR
Ecore_X_Randr_Refresh_Rate ret = 0.0;
XRRScreenConfiguration *sc = NULL;
if (!_ecore_x_randr_root_validate(root) ||
!(sc = XRRGetScreenInfo(_ecore_x_disp, root)))
return ret;
ret = XRRConfigCurrentRate(sc);
if (sc)
XRRFreeScreenConfigInfo(sc);
return ret;
#else /* ifdef ECORE_XRANDR */
return 0.0;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_primary_output_current_refresh_rate_get */
/*
* @param root window which's primary output will be queried
* @param size_index referencing the size to query valid refresh rates for
* @return currently used refresh rate or - if request failed or RandRR is not available - NULL
*/
EAPI Ecore_X_Randr_Refresh_Rate *
ecore_x_randr_screen_primary_output_refresh_rates_get(Ecore_X_Window root,
int size_index,
int *num)
{
#ifdef ECORE_XRANDR
Ecore_X_Randr_Refresh_Rate *ret = NULL, *rates = NULL;
Ecore_X_Randr_Screen scr;
int n;
if (num
&& RANDR_VALIDATE_ROOT(scr, root)
&& (rates = XRRRates(_ecore_x_disp, scr, size_index, &n)))
{
if (rates && (ret = malloc(sizeof(Ecore_X_Randr_Refresh_Rate) * n)))
{
memcpy(ret, rates, (sizeof(Ecore_X_Randr_Refresh_Rate) * n));
*num = n;
}
}
return ret;
#else /* ifdef ECORE_XRANDR */
return NULL;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_primary_output_refresh_rates_get */
//>= 1.1
/*
* @brief sets the current primary output's refresh rate
* @param root window which's primary output will be queried
* @param size_index referencing the size to be set
* @param rate the refresh rate to be set
* @return EINA_TRUE on success else EINA_FALSE
*/
EAPI Eina_Bool
ecore_x_randr_screen_primary_output_refresh_rate_set(
Ecore_X_Window root,
int size_index,
Ecore_X_Randr_Refresh_Rate
rate)
{
#ifdef ECORE_XRANDR
RANDR_CHECK_1_1_RET(EINA_FALSE);
Eina_Bool ret = EINA_FALSE;
XRRScreenConfiguration *sc = NULL;
if (!(sc = XRRGetScreenInfo(_ecore_x_disp, root)))
return ret;
if (!XRRSetScreenConfigAndRate(_ecore_x_disp, sc,
root, size_index,
RR_Rotate_0, rate, CurrentTime))
ret = EINA_TRUE;
XRRFreeScreenConfigInfo(sc);
return ret;
#else /* ifdef ECORE_XRANDR */
return EINA_FALSE;
#endif /* ifdef ECORE_XRANDR */
} /* ecore_x_randr_screen_primary_output_refresh_rate_set */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,62 @@
/*
* vim:ts=8:sw=3:sts=8:expandtab:cino=>5n-3f0^-2{2
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "ecore_x_private.h"
#include "ecore_x_inline.x"
#define Ecore_X_Randr_None 0
#define Ecore_X_Randr_Unset -1
#ifdef ECORE_XRANDR
#define RANDR_1_3 ((1 << 16) | 3)
#define RANDR_CHECK_1_3_RET(ret) if(_randr_version < RANDR_1_3) return ret
extern XRRScreenResources * (*_ecore_x_randr_get_screen_resources)(Display *
dpy,
Window
window);
extern int _randr_version;
#endif
/*
* @param root window which's screen should be queried
* @return Ecore_X_Randr_Ouptut_Id or - if query failed or none is set - Ecore_X_Randr_None
*/
EAPI Ecore_X_Randr_Output
ecore_x_randr_primary_output_get(Ecore_X_Window root)
{
#ifdef ECORE_XRANDR
RANDR_CHECK_1_3_RET(Ecore_X_Randr_None);
if (!_ecore_x_randr_root_validate(root))
return Ecore_X_Randr_None;
return XRRGetOutputPrimary(_ecore_x_disp, root);
#else
return Ecore_X_Randr_None;
#endif
}
/*
* @param root window which's screen should be queried
* @param output that should be set as given root window's screen primary output
*/
EAPI void
ecore_x_randr_primary_output_set(Ecore_X_Window root,
Ecore_X_Randr_Output output)
{
#ifdef ECORE_XRANDR
RANDR_CHECK_1_3_RET();
if (_ecore_x_randr_output_validate(root, output))
{
XRRSetOutputPrimary(_ecore_x_disp, root, output);
}
#endif
}