Fixed rather embarrassing function naming conflict with low level RANDR library

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1120049 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 15 years ago
parent 3be8f38c82
commit 8949c3abab

@ -26,72 +26,72 @@
ScreenInfo* KRandrSimpleAPI::read_screen_info (Display *display) ScreenInfo* KRandrSimpleAPI::read_screen_info (Display *display)
{ {
return read_screen_info(display); return internal_read_screen_info(display);
} }
int KRandrSimpleAPI::set_screen_size (ScreenInfo *screen_info) int KRandrSimpleAPI::set_screen_size (ScreenInfo *screen_info)
{ {
return set_screen_size(screen_info); return internal_set_screen_size(screen_info);
} }
void KRandrSimpleAPI::output_auto (ScreenInfo *screen_info, OutputInfo *output_info) void KRandrSimpleAPI::output_auto (ScreenInfo *screen_info, OutputInfo *output_info)
{ {
output_auto (screen_info, output_info); internal_output_auto (screen_info, output_info);
} }
void KRandrSimpleAPI::output_off(ScreenInfo *screen_info, OutputInfo *output) void KRandrSimpleAPI::output_off(ScreenInfo *screen_info, OutputInfo *output)
{ {
output_off(screen_info, output); internal_output_off(screen_info, output);
} }
CrtcInfo* KRandrSimpleAPI::auto_find_crtc (ScreenInfo *screen_info, OutputInfo *output_info) CrtcInfo* KRandrSimpleAPI::auto_find_crtc (ScreenInfo *screen_info, OutputInfo *output_info)
{ {
return auto_find_crtc (screen_info, output_info); return internal_auto_find_crtc (screen_info, output_info);
} }
XRRModeInfo *KRandrSimpleAPI::find_mode_by_xid (ScreenInfo *screen_info, RRMode mode_id) XRRModeInfo *KRandrSimpleAPI::find_mode_by_xid (ScreenInfo *screen_info, RRMode mode_id)
{ {
return find_mode_by_xid (screen_info, mode_id); return internal_find_mode_by_xid (screen_info, mode_id);
} }
int KRandrSimpleAPI::mode_height (XRRModeInfo *mode_info, Rotation rotation) int KRandrSimpleAPI::mode_height (XRRModeInfo *mode_info, Rotation rotation)
{ {
return mode_height (mode_info, rotation); return internal_mode_height (mode_info, rotation);
} }
int KRandrSimpleAPI::mode_width (XRRModeInfo *mode_info, Rotation rotation) int KRandrSimpleAPI::mode_width (XRRModeInfo *mode_info, Rotation rotation)
{ {
return mode_width (mode_info, rotation); return internal_mode_width (mode_info, rotation);
} }
int KRandrSimpleAPI::get_width_by_output_id (ScreenInfo *screen_info, RROutput output_id) int KRandrSimpleAPI::get_width_by_output_id (ScreenInfo *screen_info, RROutput output_id)
{ {
return get_width_by_output_id (screen_info, output_id); return internal_get_width_by_output_id (screen_info, output_id);
} }
int KRandrSimpleAPI::get_height_by_output_id (ScreenInfo *screen_info, RROutput output_id) int KRandrSimpleAPI::get_height_by_output_id (ScreenInfo *screen_info, RROutput output_id)
{ {
return get_height_by_output_id (screen_info, output_id); return internal_get_height_by_output_id (screen_info, output_id);
} }
char *KRandrSimpleAPI::get_output_name (ScreenInfo *screen_info, RROutput id) char *KRandrSimpleAPI::get_output_name (ScreenInfo *screen_info, RROutput id)
{ {
return get_output_name (screen_info, id); return internal_get_output_name (screen_info, id);
} }
Status KRandrSimpleAPI::crtc_apply (CrtcInfo *crtc_info) Status KRandrSimpleAPI::crtc_apply (CrtcInfo *crtc_info)
{ {
return crtc_apply (crtc_info); return internal_crtc_apply (crtc_info);
} }
Status KRandrSimpleAPI::crtc_disable (CrtcInfo *crtc) Status KRandrSimpleAPI::crtc_disable (CrtcInfo *crtc)
{ {
return crtc_disable (crtc); return internal_crtc_disable (crtc);
} }
int KRandrSimpleAPI::main_low_apply (ScreenInfo *screen_info) int KRandrSimpleAPI::main_low_apply (ScreenInfo *screen_info)
{ {
return main_low_apply (screen_info); return internal_main_low_apply (screen_info);
} }
bool KRandrSimpleAPI::kRandrHasRandr(void) bool KRandrSimpleAPI::kRandrHasRandr(void)

@ -1,16 +1,17 @@
/* /*
* Copyright © 2010 Raptor Engineering
* Copyright © 2007 Intel Corporation * Copyright © 2007 Intel Corporation
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -24,32 +25,32 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
Status crtc_disable (struct CrtcInfo *crtc); Status internal_crtc_disable (struct CrtcInfo *crtc);
char * get_output_name (struct ScreenInfo *screen_info, RROutput id) char * internal_get_output_name (struct ScreenInfo *screen_info, RROutput id)
{ {
char *output_name = NULL; char *output_name = NULL;
int i; int i;
for (i = 0; i < screen_info->n_output; i++) { for (i = 0; i < screen_info->n_output; i++) {
if (id == screen_info->outputs[i]->id) { if (id == screen_info->outputs[i]->id) {
output_name = screen_info->outputs[i]->info->name; output_name = screen_info->outputs[i]->info->name;
} }
} }
if (!output_name) { if (!output_name) {
output_name = "Unknown"; output_name = "Unknown";
} }
return output_name; return output_name;
} }
XRRModeInfo * find_mode_by_xid (struct ScreenInfo *screen_info, RRMode mode_id) XRRModeInfo * internal_find_mode_by_xid (struct ScreenInfo *screen_info, RRMode mode_id)
{ {
XRRModeInfo *mode_info = NULL; XRRModeInfo *mode_info = NULL;
XRRScreenResources *res; XRRScreenResources *res;
int i; int i;
res = screen_info->res; res = screen_info->res;
for (i = 0; i < res->nmode; i++) { for (i = 0; i < res->nmode; i++) {
if (mode_id == res->modes[i].id) { if (mode_id == res->modes[i].id) {
@ -57,25 +58,25 @@ XRRModeInfo * find_mode_by_xid (struct ScreenInfo *screen_info, RRMode mode_id)
break; break;
} }
} }
return mode_info; return mode_info;
} }
static XRRCrtcInfo * find_crtc_by_xid (struct ScreenInfo *screen_info, RRCrtc crtc_id) static XRRCrtcInfo * internal_find_crtc_by_xid (struct ScreenInfo *screen_info, RRCrtc crtc_id)
{ {
XRRCrtcInfo *crtc_info; XRRCrtcInfo *crtc_info;
Display *dpy; Display *dpy;
XRRScreenResources *res; XRRScreenResources *res;
dpy = screen_info->dpy; dpy = screen_info->dpy;
res = screen_info->res; res = screen_info->res;
crtc_info = XRRGetCrtcInfo (dpy, res, crtc_id); crtc_info = XRRGetCrtcInfo (dpy, res, crtc_id);
return crtc_info; return crtc_info;
} }
int get_width_by_output_id (struct ScreenInfo *screen_info, RROutput output_id) int internal_get_width_by_output_id (struct ScreenInfo *screen_info, RROutput output_id)
{ {
struct OutputInfo *output_info; struct OutputInfo *output_info;
struct CrtcInfo *crtc_info; struct CrtcInfo *crtc_info;
@ -83,7 +84,7 @@ int get_width_by_output_id (struct ScreenInfo *screen_info, RROutput output_id)
XRRModeInfo *mode_info; XRRModeInfo *mode_info;
int i; int i;
int width = -1; int width = -1;
for (i = 0; i < screen_info->n_output; i++) { for (i = 0; i < screen_info->n_output; i++) {
if (output_id == screen_info->outputs[i]->id) { if (output_id == screen_info->outputs[i]->id) {
crtc_info = screen_info->outputs[i]->cur_crtc; crtc_info = screen_info->outputs[i]->cur_crtc;
@ -92,18 +93,18 @@ int get_width_by_output_id (struct ScreenInfo *screen_info, RROutput output_id)
break; break;
} }
mode_id = crtc_info->cur_mode_id; mode_id = crtc_info->cur_mode_id;
mode_info = find_mode_by_xid (screen_info, mode_id); mode_info = internal_find_mode_by_xid (screen_info, mode_id);
width = mode_width (mode_info, crtc_info->cur_rotation); width = internal_mode_width (mode_info, crtc_info->cur_rotation);
break; break;
} }
} }
return width; return width;
} }
int get_height_by_output_id (struct ScreenInfo *screen_info, RROutput output_id) int internal_get_height_by_output_id (struct ScreenInfo *screen_info, RROutput output_id)
{ {
struct OutputInfo *output_info; struct OutputInfo *output_info;
struct CrtcInfo *crtc_info; struct CrtcInfo *crtc_info;
@ -111,7 +112,7 @@ int get_height_by_output_id (struct ScreenInfo *screen_info, RROutput output_id)
XRRModeInfo *mode_info; XRRModeInfo *mode_info;
int i; int i;
int height = -1; int height = -1;
for (i = 0; i < screen_info->n_output; i++) { for (i = 0; i < screen_info->n_output; i++) {
if (output_id == screen_info->outputs[i]->id) { if (output_id == screen_info->outputs[i]->id) {
crtc_info = screen_info->outputs[i]->cur_crtc; crtc_info = screen_info->outputs[i]->cur_crtc;
@ -120,18 +121,18 @@ int get_height_by_output_id (struct ScreenInfo *screen_info, RROutput output_id)
break; break;
} }
mode_id = crtc_info->cur_mode_id; mode_id = crtc_info->cur_mode_id;
mode_info = find_mode_by_xid (screen_info, mode_id); mode_info = internal_find_mode_by_xid (screen_info, mode_id);
height = mode_height (mode_info, crtc_info->cur_rotation); height = internal_mode_height (mode_info, crtc_info->cur_rotation);
break; break;
} }
} }
return height; return height;
} }
int mode_height (XRRModeInfo *mode_info, Rotation rotation) int internal_mode_height (XRRModeInfo *mode_info, Rotation rotation)
{ {
switch (rotation & 0xf) { switch (rotation & 0xf) {
case RR_Rotate_0: case RR_Rotate_0:
@ -145,7 +146,7 @@ int mode_height (XRRModeInfo *mode_info, Rotation rotation)
} }
} }
int mode_width (XRRModeInfo *mode_info, Rotation rotation) int internal_mode_width (XRRModeInfo *mode_info, Rotation rotation)
{ {
switch (rotation & 0xf) { switch (rotation & 0xf) {
case RR_Rotate_0: case RR_Rotate_0:
@ -160,41 +161,41 @@ int mode_width (XRRModeInfo *mode_info, Rotation rotation)
} }
static struct CrtcInfo * find_crtc (struct ScreenInfo *screen_info, XRROutputInfo *output) static struct CrtcInfo * internal_find_crtc (struct ScreenInfo *screen_info, XRROutputInfo *output)
{ {
struct CrtcInfo *crtc_info = NULL; struct CrtcInfo *crtc_info = NULL;
int i; int i;
for (i = 0; i < screen_info->n_crtc; i++) { for (i = 0; i < screen_info->n_crtc; i++) {
if (screen_info->crtcs[i]->id == output->crtc) { if (screen_info->crtcs[i]->id == output->crtc) {
crtc_info = screen_info->crtcs[i]; crtc_info = screen_info->crtcs[i];
break; break;
} }
} }
return crtc_info; return crtc_info;
} }
struct CrtcInfo * auto_find_crtc (struct ScreenInfo *screen_info, struct OutputInfo *output_info) struct CrtcInfo * internal_auto_find_crtc (struct ScreenInfo *screen_info, struct OutputInfo *output_info)
{ {
struct CrtcInfo *crtc_info = NULL; struct CrtcInfo *crtc_info = NULL;
int i; int i;
for (i = 0; i < screen_info->n_crtc; i++) { for (i = 0; i < screen_info->n_crtc; i++) {
if (0 == screen_info->crtcs[i]->cur_noutput) { if (0 == screen_info->crtcs[i]->cur_noutput) {
crtc_info = screen_info->crtcs[i]; crtc_info = screen_info->crtcs[i];
break; break;
} }
} }
if (NULL == crtc_info) { if (NULL == crtc_info) {
crtc_info = screen_info->crtcs[0]; crtc_info = screen_info->crtcs[0];
} }
return crtc_info; return crtc_info;
} }
int set_screen_size (struct ScreenInfo *screen_info) int internal_set_screen_size (struct ScreenInfo *screen_info)
{ {
Display *dpy; Display *dpy;
int screen; int screen;
@ -205,22 +206,22 @@ int set_screen_size (struct ScreenInfo *screen_info)
int mmW, mmH; int mmW, mmH;
int max_width = 0, max_height = 0; int max_width = 0, max_height = 0;
int i; int i;
dpy = screen_info->dpy; dpy = screen_info->dpy;
screen = DefaultScreen (dpy); screen = DefaultScreen (dpy);
for (i = 0; i < screen_info->n_crtc; i++) { for (i = 0; i < screen_info->n_crtc; i++) {
crtc = screen_info->crtcs[i]; crtc = screen_info->crtcs[i];
if (!crtc->cur_mode_id) { if (!crtc->cur_mode_id) {
continue; continue;
} }
mode_info = find_mode_by_xid (screen_info, crtc->cur_mode_id); mode_info = internal_find_mode_by_xid (screen_info, crtc->cur_mode_id);
cur_x = crtc->cur_x; cur_x = crtc->cur_x;
cur_y = crtc->cur_y; cur_y = crtc->cur_y;
w = mode_width (mode_info, crtc->cur_rotation); w = internal_mode_width (mode_info, crtc->cur_rotation);
h = mode_height (mode_info, crtc->cur_rotation); h = internal_mode_height (mode_info, crtc->cur_rotation);
if (cur_x + w > max_width) { if (cur_x + w > max_width) {
max_width = cur_x + w; max_width = cur_x + w;
} }
@ -228,10 +229,10 @@ int set_screen_size (struct ScreenInfo *screen_info)
max_height = cur_y + h; max_height = cur_y + h;
} }
} }
if (max_width > screen_info->max_width) { if (max_width > screen_info->max_width) {
#if RANDR_GUI_DEBUG #if RANDR_GUI_DEBUG
fprintf (stderr, "user set screen width %d, larger than max width %d, set to max width\n", fprintf (stderr, "user set screen width %d, larger than max width %d, set to max width\n",
cur_x + w, screen_info->max_width); cur_x + w, screen_info->max_width);
#endif #endif
return 0; return 0;
@ -239,25 +240,25 @@ int set_screen_size (struct ScreenInfo *screen_info)
screen_info->cur_width = screen_info->min_width; screen_info->cur_width = screen_info->min_width;
} else { } else {
screen_info->cur_width = max_width; screen_info->cur_width = max_width;
} }
if (max_height > screen_info->max_height) { if (max_height > screen_info->max_height) {
#if RANDR_GUI_DEBUG #if RANDR_GUI_DEBUG
fprintf (stderr, "user set screen height %d, larger than max height %d, set to max height\n", fprintf (stderr, "user set screen height %d, larger than max height %d, set to max height\n",
cur_y + h, screen_info->max_height); cur_y + h, screen_info->max_height);
#endif #endif
return 0; return 0;
} else if (max_height < screen_info->min_height) { } else if (max_height < screen_info->min_height) {
screen_info->cur_height = screen_info->min_height; screen_info->cur_height = screen_info->min_height;
} else { } else {
screen_info->cur_height = max_height; screen_info->cur_height = max_height;
} }
/* calculate mmWidth, mmHeight */ /* calculate mmWidth, mmHeight */
if (screen_info->cur_width != DisplayWidth (dpy, screen) || if (screen_info->cur_width != DisplayWidth (dpy, screen) ||
screen_info->cur_height != DisplayHeight (dpy, screen) ) { screen_info->cur_height != DisplayHeight (dpy, screen) ) {
double dpi; double dpi;
dpi = (25.4 * DisplayHeight (dpy, screen)) / DisplayHeightMM(dpy, screen); dpi = (25.4 * DisplayHeight (dpy, screen)) / DisplayHeightMM(dpy, screen);
mmW = (25.4 * screen_info->cur_width) / dpi; mmW = (25.4 * screen_info->cur_width) / dpi;
mmH = (25.4 * screen_info->cur_height) / dpi; mmH = (25.4 * screen_info->cur_height) / dpi;
@ -268,11 +269,11 @@ int set_screen_size (struct ScreenInfo *screen_info)
screen_info->cur_mmWidth = mmW; screen_info->cur_mmWidth = mmW;
screen_info->cur_mmHeight = mmH; screen_info->cur_mmHeight = mmH;
return 1; return 1;
} }
void screen_apply (struct ScreenInfo *screen_info) void internal_screen_apply (struct ScreenInfo *screen_info)
{ {
int width, height; int width, height;
int mmWidth, mmHeight; int mmWidth, mmHeight;
@ -280,7 +281,7 @@ void screen_apply (struct ScreenInfo *screen_info)
Window window; Window window;
int screen; int screen;
static int first = 1; static int first = 1;
width = screen_info->cur_width; width = screen_info->cur_width;
height = screen_info->cur_height; height = screen_info->cur_height;
mmWidth = screen_info->cur_mmWidth; mmWidth = screen_info->cur_mmWidth;
@ -288,7 +289,7 @@ void screen_apply (struct ScreenInfo *screen_info)
dpy = screen_info->dpy; dpy = screen_info->dpy;
window = screen_info->window; window = screen_info->window;
screen = DefaultScreen (dpy); screen = DefaultScreen (dpy);
cur_dpy = XOpenDisplay (NULL); cur_dpy = XOpenDisplay (NULL);
if (width == DisplayWidth (cur_dpy, screen) && if (width == DisplayWidth (cur_dpy, screen) &&
@ -301,7 +302,7 @@ void screen_apply (struct ScreenInfo *screen_info)
} }
} }
Status crtc_apply (struct CrtcInfo *crtc_info) Status internal_crtc_apply (struct CrtcInfo *crtc_info)
{ {
struct ScreenInfo *screen_info; struct ScreenInfo *screen_info;
XRRCrtcInfo *rr_crtc_info; XRRCrtcInfo *rr_crtc_info;
@ -315,74 +316,74 @@ Status crtc_apply (struct CrtcInfo *crtc_info)
int noutput; int noutput;
Status s; Status s;
int i; int i;
/*if (!crtc_info->changed) { /*if (!crtc_info->changed) {
return RRSetConfigSuccess; return RRSetConfigSuccess;
}*/ }*/
screen_info = crtc_info->screen_info; screen_info = crtc_info->screen_info;
dpy = screen_info->dpy; dpy = screen_info->dpy;
res = screen_info->res; res = screen_info->res;
crtc_id = crtc_info->id; crtc_id = crtc_info->id;
x = crtc_info->cur_x; x = crtc_info->cur_x;
y = crtc_info->cur_y; y = crtc_info->cur_y;
mode_id = crtc_info->cur_mode_id; mode_id = crtc_info->cur_mode_id;
rotation = crtc_info->cur_rotation; rotation = crtc_info->cur_rotation;
noutput = crtc_info->cur_noutput; noutput = crtc_info->cur_noutput;
if (0 == noutput) { if (0 == noutput) {
return crtc_disable (crtc_info); return internal_crtc_disable (crtc_info);
} }
outputs = malloc (sizeof (RROutput) * noutput); outputs = malloc (sizeof (RROutput) * noutput);
noutput = 0; noutput = 0;
for (i = 0; i < screen_info->n_output; i++) { for (i = 0; i < screen_info->n_output; i++) {
struct OutputInfo *output_info = screen_info->outputs[i]; struct OutputInfo *output_info = screen_info->outputs[i];
if (output_info->cur_crtc && crtc_id == output_info->cur_crtc->id) { if (output_info->cur_crtc && crtc_id == output_info->cur_crtc->id) {
outputs[noutput++] = output_info->id; outputs[noutput++] = output_info->id;
} }
} }
s = XRRSetCrtcConfig (dpy, res, crtc_id, CurrentTime, s = XRRSetCrtcConfig (dpy, res, crtc_id, CurrentTime,
x, y, mode_id, rotation, x, y, mode_id, rotation,
outputs, noutput); outputs, noutput);
if (RRSetConfigSuccess == s) { if (RRSetConfigSuccess == s) {
crtc_info->changed = 0; crtc_info->changed = 0;
} }
free (outputs); free (outputs);
return s; return s;
} }
Status crtc_disable (struct CrtcInfo *crtc) Status internal_crtc_disable (struct CrtcInfo *crtc)
{ {
struct ScreenInfo *screen_info; struct ScreenInfo *screen_info;
screen_info = crtc->screen_info; screen_info = crtc->screen_info;
return XRRSetCrtcConfig (screen_info->dpy, screen_info->res, crtc->id, CurrentTime, return XRRSetCrtcConfig (screen_info->dpy, screen_info->res, crtc->id, CurrentTime,
0, 0, None, RR_Rotate_0, NULL, 0); 0, 0, None, RR_Rotate_0, NULL, 0);
} }
struct ScreenInfo* read_screen_info (Display *display) struct ScreenInfo* internal_read_screen_info (Display *display)
{ {
struct ScreenInfo *screen_info; struct ScreenInfo *screen_info;
int screen_num; int screen_num;
Window root_window; Window root_window;
XRRScreenResources *sr; XRRScreenResources *sr;
int i; int i;
screen_num = DefaultScreen (display); screen_num = DefaultScreen (display);
root_window = RootWindow (display, screen_num); root_window = RootWindow (display, screen_num);
sr = XRRGetScreenResources (display, root_window); sr = XRRGetScreenResources (display, root_window);
screen_info = malloc (sizeof (struct ScreenInfo)); screen_info = malloc (sizeof (struct ScreenInfo));
screen_info->dpy = display; screen_info->dpy = display;
screen_info->window = root_window; screen_info->window = root_window;
@ -396,16 +397,16 @@ struct ScreenInfo* read_screen_info (Display *display)
screen_info->outputs = malloc (sizeof (struct OutputInfo *) * sr->noutput); screen_info->outputs = malloc (sizeof (struct OutputInfo *) * sr->noutput);
screen_info->crtcs = malloc (sizeof (struct CrtcInfo *) * sr->ncrtc); screen_info->crtcs = malloc (sizeof (struct CrtcInfo *) * sr->ncrtc);
screen_info->clone = 0; screen_info->clone = 0;
XRRGetScreenSizeRange (display, root_window, &screen_info->min_width, &screen_info->min_height, &screen_info->max_width, &screen_info->max_height); XRRGetScreenSizeRange (display, root_window, &screen_info->min_width, &screen_info->min_height, &screen_info->max_width, &screen_info->max_height);
/* get crtc */ /* get crtc */
for (i = 0; i < sr->ncrtc; i++) { for (i = 0; i < sr->ncrtc; i++) {
struct CrtcInfo *crtc_info; struct CrtcInfo *crtc_info;
screen_info->crtcs[i] = malloc (sizeof (struct CrtcInfo)); screen_info->crtcs[i] = malloc (sizeof (struct CrtcInfo));
crtc_info = screen_info->crtcs[i]; crtc_info = screen_info->crtcs[i];
XRRCrtcInfo *xrr_crtc_info = XRRGetCrtcInfo (display, sr, sr->crtcs[i]); XRRCrtcInfo *xrr_crtc_info = XRRGetCrtcInfo (display, sr, sr->crtcs[i]);
crtc_info->id = sr->crtcs[i]; crtc_info->id = sr->crtcs[i];
crtc_info->info = xrr_crtc_info; crtc_info->info = xrr_crtc_info;
crtc_info->cur_x = xrr_crtc_info->x; crtc_info->cur_x = xrr_crtc_info->x;
@ -414,39 +415,39 @@ struct ScreenInfo* read_screen_info (Display *display)
crtc_info->cur_rotation = xrr_crtc_info->rotation; crtc_info->cur_rotation = xrr_crtc_info->rotation;
crtc_info->rotations = xrr_crtc_info->rotations; crtc_info->rotations = xrr_crtc_info->rotations;
crtc_info->cur_noutput = xrr_crtc_info->noutput; crtc_info->cur_noutput = xrr_crtc_info->noutput;
crtc_info->changed = 0; crtc_info->changed = 0;
crtc_info->screen_info = screen_info; crtc_info->screen_info = screen_info;
} }
/* get output */ /* get output */
for (i = 0; i < sr->noutput; i++) { for (i = 0; i < sr->noutput; i++) {
struct OutputInfo *output; struct OutputInfo *output;
screen_info->outputs[i] = malloc (sizeof (struct OutputInfo)); screen_info->outputs[i] = malloc (sizeof (struct OutputInfo));
output = screen_info->outputs[i]; output = screen_info->outputs[i];
output->id = sr->outputs[i]; output->id = sr->outputs[i];
output->info = XRRGetOutputInfo (display, sr, sr->outputs[i]); output->info = XRRGetOutputInfo (display, sr, sr->outputs[i]);
output->cur_crtc = find_crtc (screen_info, output->info); output->cur_crtc = internal_find_crtc (screen_info, output->info);
output->auto_set = 0; output->auto_set = 0;
if (output->cur_crtc) { if (output->cur_crtc) {
output->off_set = 0; output->off_set = 0;
} else { } else {
output->off_set = 1; output->off_set = 1;
} }
} }
/* set current crtc */ /* set current crtc */
screen_info->cur_crtc = screen_info->outputs[0]->cur_crtc; screen_info->cur_crtc = screen_info->outputs[0]->cur_crtc;
screen_info->primary_crtc = screen_info->cur_crtc; screen_info->primary_crtc = screen_info->cur_crtc;
screen_info->cur_output = screen_info->outputs[0]; screen_info->cur_output = screen_info->outputs[0];
return screen_info; return screen_info;
} }
void free_screen_info (struct ScreenInfo *screen_info) void internal_free_screen_info (struct ScreenInfo *screen_info)
{ {
free (screen_info->outputs); free (screen_info->outputs);
free (screen_info->crtcs); free (screen_info->crtcs);
@ -456,26 +457,26 @@ void free_screen_info (struct ScreenInfo *screen_info)
/*check if other outputs that connected to the same crtc support this mode*/ /*check if other outputs that connected to the same crtc support this mode*/
static int check_mode (struct ScreenInfo *screen_info, struct OutputInfo *output, RRMode mode_id) static int internal_check_mode (struct ScreenInfo *screen_info, struct OutputInfo *output, RRMode mode_id)
{ {
XRRCrtcInfo *crtc_info; XRRCrtcInfo *crtc_info;
/* XRR */ /* XRR */
int i, j; int i, j;
int mode_ok = 1; int mode_ok = 1;
if (!output->cur_crtc) { if (!output->cur_crtc) {
return 1; return 1;
} }
crtc_info = output->cur_crtc->info; crtc_info = output->cur_crtc->info;
for (i = 0; i < crtc_info->noutput; i++) { for (i = 0; i < crtc_info->noutput; i++) {
XRROutputInfo *output_info; XRROutputInfo *output_info;
int nmode; int nmode;
if (output->id == crtc_info->outputs[i]) { if (output->id == crtc_info->outputs[i]) {
continue; continue;
} }
mode_ok = 0; mode_ok = 0;
output_info = XRRGetOutputInfo (screen_info->dpy, screen_info->res, crtc_info->outputs[i]); output_info = XRRGetOutputInfo (screen_info->dpy, screen_info->res, crtc_info->outputs[i]);
nmode = output_info->nmode; nmode = output_info->nmode;
@ -489,15 +490,15 @@ static int check_mode (struct ScreenInfo *screen_info, struct OutputInfo *output
break; break;
} }
} }
return mode_ok; return mode_ok;
} }
static RRCrtc get_crtc_id_by_output_id (struct ScreenInfo *screen_info, RROutput output_id) static RRCrtc internal_get_crtc_id_by_output_id (struct ScreenInfo *screen_info, RROutput output_id)
{ {
int i; int i;
RRCrtc crtc_id = -1; RRCrtc crtc_id = -1;
for (i = 0; i < screen_info->n_output; i++) { for (i = 0; i < screen_info->n_output; i++) {
if (output_id == screen_info->outputs[i]->id) { if (output_id == screen_info->outputs[i]->id) {
if (screen_info->outputs[i]->cur_crtc) { if (screen_info->outputs[i]->cur_crtc) {
@ -508,28 +509,28 @@ static RRCrtc get_crtc_id_by_output_id (struct ScreenInfo *screen_info, RROutput
break; break;
} }
} }
return crtc_id; return crtc_id;
} }
static struct CrtcInfo * static struct CrtcInfo *
get_crtc_info_by_xid (struct ScreenInfo *screen_info, RRCrtc crtc_id) internal_get_crtc_info_by_xid (struct ScreenInfo *screen_info, RRCrtc crtc_id)
{ {
struct CrtcInfo *crtc_info = NULL; struct CrtcInfo *crtc_info = NULL;
int i; int i;
for (i = 0; i < screen_info->n_crtc; i++) { for (i = 0; i < screen_info->n_crtc; i++) {
if (crtc_id == screen_info->crtcs[i]->id) { if (crtc_id == screen_info->crtcs[i]->id) {
crtc_info = screen_info->crtcs[i]; crtc_info = screen_info->crtcs[i];
break; break;
} }
} }
return crtc_info; return crtc_info;
} }
static XRRModeInfo * static XRRModeInfo *
preferred_mode (struct ScreenInfo *screen_info, struct OutputInfo *output) internal_preferred_mode (struct ScreenInfo *screen_info, struct OutputInfo *output)
{ {
XRROutputInfo *output_info = output->info; XRROutputInfo *output_info = output->info;
Display *dpy; Display *dpy;
@ -543,7 +544,7 @@ preferred_mode (struct ScreenInfo *screen_info, struct OutputInfo *output)
best = NULL; best = NULL;
bestDist = 0; bestDist = 0;
for (m = 0; m < output_info->nmode; m++) { for (m = 0; m < output_info->nmode; m++) {
XRRModeInfo *mode_info = find_mode_by_xid (screen_info, output_info->modes[m]); XRRModeInfo *mode_info = internal_find_mode_by_xid (screen_info, output_info->modes[m]);
int dist; int dist;
if (m < output_info->npreferred) if (m < output_info->npreferred)
@ -563,85 +564,85 @@ preferred_mode (struct ScreenInfo *screen_info, struct OutputInfo *output)
return best; return best;
} }
int main_low_apply (struct ScreenInfo *screen_info) int internal_main_low_apply (struct ScreenInfo *screen_info)
{ {
int i; int i;
struct CrtcInfo *crtc_info; struct CrtcInfo *crtc_info;
/* set_positions (screen_info); */ /* set_positions (screen_info); */
if (!set_screen_size (screen_info)) { if (!internal_set_screen_size (screen_info)) {
printf("Screen Size FAILURE\n\r"); printf("Screen Size FAILURE\n\r");
return 0; return 0;
} }
for (i = 0; i < screen_info->n_crtc; i++) { for (i = 0; i < screen_info->n_crtc; i++) {
int old_x, old_y, old_w, old_h; int old_x, old_y, old_w, old_h;
XRRCrtcInfo *crtc_info = XRRGetCrtcInfo (screen_info->dpy, screen_info->res, screen_info->crtcs[i]->id); XRRCrtcInfo *crtc_info = XRRGetCrtcInfo (screen_info->dpy, screen_info->res, screen_info->crtcs[i]->id);
XRRModeInfo *old_mode = find_mode_by_xid (screen_info, crtc_info->mode); XRRModeInfo *old_mode = internal_find_mode_by_xid (screen_info, crtc_info->mode);
if (crtc_info->mode == None) { if (crtc_info->mode == None) {
continue; continue;
} }
old_x = crtc_info->x; old_x = crtc_info->x;
old_y = crtc_info->y; old_y = crtc_info->y;
old_w = mode_width (old_mode, crtc_info->rotation); old_w = internal_mode_width (old_mode, crtc_info->rotation);
old_h = mode_height (old_mode, crtc_info->rotation); old_h = internal_mode_height (old_mode, crtc_info->rotation);
if (old_x + old_w <= screen_info->cur_width && if (old_x + old_w <= screen_info->cur_width &&
old_y + old_h <= screen_info->cur_height ) { old_y + old_h <= screen_info->cur_height ) {
continue; continue;
} else { } else {
crtc_disable (screen_info->crtcs[i]); internal_crtc_disable (screen_info->crtcs[i]);
} }
} }
screen_apply (screen_info); internal_screen_apply (screen_info);
for (i = 0; i < screen_info->n_crtc; i++) { for (i = 0; i < screen_info->n_crtc; i++) {
Status s; Status s;
crtc_info = screen_info->crtcs[i]; crtc_info = screen_info->crtcs[i];
s = crtc_apply (crtc_info); s = internal_crtc_apply (crtc_info);
if (RRSetConfigSuccess != s) { if (RRSetConfigSuccess != s) {
fprintf (stderr, "crtc apply error\n"); fprintf (stderr, "crtc apply error\n");
} }
} }
return 1; return 1;
} }
void output_auto (struct ScreenInfo *screen_info, struct OutputInfo *output_info) void internal_output_auto (struct ScreenInfo *screen_info, struct OutputInfo *output_info)
{ {
XRRModeInfo *mode_info; XRRModeInfo *mode_info;
RRMode mode_id; RRMode mode_id;
struct CrtcInfo *crtc_info; struct CrtcInfo *crtc_info;
XRROutputInfo *probe_output_info; XRROutputInfo *probe_output_info;
if (RR_Disconnected == output_info->info->connection) { if (RR_Disconnected == output_info->info->connection) {
XRRScreenResources *cur_res; XRRScreenResources *cur_res;
cur_res = XRRGetScreenResources (screen_info->dpy, screen_info->window); cur_res = XRRGetScreenResources (screen_info->dpy, screen_info->window);
probe_output_info = XRRGetOutputInfo (screen_info->dpy, cur_res, output_info->id); probe_output_info = XRRGetOutputInfo (screen_info->dpy, cur_res, output_info->id);
if (RR_Disconnected != probe_output_info->connection) { if (RR_Disconnected != probe_output_info->connection) {
output_info->info = probe_output_info; output_info->info = probe_output_info;
output_info->cur_crtc = auto_find_crtc (screen_info, output_info); output_info->cur_crtc = internal_auto_find_crtc (screen_info, output_info);
} }
} }
mode_info = preferred_mode (screen_info, output_info); mode_info = internal_preferred_mode (screen_info, output_info);
if (!mode_info) { if (!mode_info) {
return; return;
} }
mode_id = mode_info->id; mode_id = mode_info->id;
crtc_info = output_info->cur_crtc; crtc_info = output_info->cur_crtc;
if (crtc_info) { if (crtc_info) {
crtc_info->cur_mode_id = mode_id; crtc_info->cur_mode_id = mode_id;
} else { } else {
crtc_info = auto_find_crtc (screen_info, output_info); crtc_info = internal_auto_find_crtc (screen_info, output_info);
if (!crtc_info) { if (!crtc_info) {
#if RANDR_GUI_DEBUG #if RANDR_GUI_DEBUG
fprintf (stderr, "Can not find usable CRTC\n"); fprintf (stderr, "Can not find usable CRTC\n");
@ -656,10 +657,10 @@ void output_auto (struct ScreenInfo *screen_info, struct OutputInfo *output_info
screen_info->cur_crtc->changed = 1; screen_info->cur_crtc->changed = 1;
} }
} }
} }
void output_off (struct ScreenInfo *screen_info, struct OutputInfo *output) void internal_output_off (struct ScreenInfo *screen_info, struct OutputInfo *output)
{ {
if (output->cur_crtc) { if (output->cur_crtc) {
output->cur_crtc->cur_noutput--; output->cur_crtc->cur_noutput--;

@ -1,16 +1,16 @@
/* /*
* Copyright © 2007 Intel Corporation * Copyright © 2007 Intel Corporation
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -34,9 +34,9 @@ struct CrtcInfo {
Rotation cur_rotation; Rotation cur_rotation;
Rotation rotations; Rotation rotations;
int cur_noutput; int cur_noutput;
int changed; int changed;
struct ScreenInfo *screen_info; struct ScreenInfo *screen_info;
}; };
@ -44,7 +44,7 @@ struct OutputInfo {
RROutput id; RROutput id;
XRROutputInfo *info; XRROutputInfo *info;
struct CrtcInfo *cur_crtc; struct CrtcInfo *cur_crtc;
int auto_set; int auto_set;
int off_set; int off_set;
}; };
@ -59,15 +59,15 @@ struct ScreenInfo {
int cur_height; int cur_height;
int cur_mmWidth; int cur_mmWidth;
int cur_mmHeight; int cur_mmHeight;
int n_output; int n_output;
int n_crtc; int n_crtc;
struct OutputInfo **outputs; struct OutputInfo **outputs;
struct CrtcInfo **crtcs; struct CrtcInfo **crtcs;
int clone; int clone;
struct CrtcInfo *primary_crtc; struct CrtcInfo *primary_crtc;
struct CrtcInfo *cur_crtc; struct CrtcInfo *cur_crtc;
struct OutputInfo *cur_output; struct OutputInfo *cur_output;
}; };
@ -80,22 +80,22 @@ extern "C" {
#endif #endif
void free_screen_info (struct ScreenInfo *screen_info); void free_screen_info (struct ScreenInfo *screen_info);
struct ScreenInfo* read_screen_info (Display *); struct ScreenInfo* internal_read_screen_info (Display *);
int set_screen_size (struct ScreenInfo *screen_info); int internal_set_screen_size (struct ScreenInfo *screen_info);
void output_auto (struct ScreenInfo *screen_info, struct OutputInfo *output_info); void internal_output_auto (struct ScreenInfo *screen_info, struct OutputInfo *output_info);
void output_off (struct ScreenInfo *screen_info, struct OutputInfo *output); void internal_output_off (struct ScreenInfo *screen_info, struct OutputInfo *output);
struct CrtcInfo* auto_find_crtc (struct ScreenInfo *screen_info, struct OutputInfo *output_info); struct CrtcInfo* internal_auto_find_crtc (struct ScreenInfo *screen_info, struct OutputInfo *output_info);
XRRModeInfo *find_mode_by_xid (struct ScreenInfo *screen_info, RRMode mode_id); XRRModeInfo *internal_find_mode_by_xid (struct ScreenInfo *screen_info, RRMode mode_id);
int mode_height (XRRModeInfo *mode_info, Rotation rotation); int internal_mode_height (XRRModeInfo *mode_info, Rotation rotation);
int mode_width (XRRModeInfo *mode_info, Rotation rotation); int internal_mode_width (XRRModeInfo *mode_info, Rotation rotation);
int get_width_by_output_id (struct ScreenInfo *screen_info, RROutput output_id); int internal_get_width_by_output_id (struct ScreenInfo *screen_info, RROutput output_id);
int get_height_by_output_id (struct ScreenInfo *screen_info, RROutput output_id); int internal_get_height_by_output_id (struct ScreenInfo *screen_info, RROutput output_id);
char *get_output_name (struct ScreenInfo *screen_info, RROutput id); char *internal_get_output_name (struct ScreenInfo *screen_info, RROutput id);
Status crtc_apply (struct CrtcInfo *crtc_info); Status internal_crtc_apply (struct CrtcInfo *crtc_info);
Status crtc_disable (struct CrtcInfo *crtc); Status internal_crtc_disable (struct CrtcInfo *crtc);
int main_low_apply (struct ScreenInfo *screen_info); int internal_main_low_apply (struct ScreenInfo *screen_info);
#ifdef __cplusplus #ifdef __cplusplus
} }

Loading…
Cancel
Save