Rename: monitor -> monitors

This commit is contained in:
o9000 2015-12-22 23:16:01 +01:00
parent c56ca2fe61
commit da0c52ecff
8 changed files with 75 additions and 75 deletions

View file

@ -141,12 +141,12 @@ int config_get_monitor(char *monitor)
// monitor specified by name, not by index
int i, j;
for (i = 0; i < server.num_monitors; ++i) {
if (server.monitor[i].names == 0)
if (server.monitors[i].names == 0)
// xrandr can't identify monitors
continue;
j = 0;
while (server.monitor[i].names[j] != 0) {
if (strcmp(monitor, server.monitor[i].names[j++]) == 0)
while (server.monitors[i].names[j] != 0) {
if (strcmp(monitor, server.monitors[i].names[j++]) == 0)
return i;
}
}

View file

@ -270,11 +270,11 @@ void init_panel_size_and_position(Panel *panel)
// detect panel size
if (panel_horizontal) {
if (panel->fractional_width)
panel->area.width = (float)server.monitor[panel->monitor].width * panel->area.width / 100;
panel->area.width = (float)server.monitors[panel->monitor].width * panel->area.width / 100;
if (panel->fractional_height)
panel->area.height = (float)server.monitor[panel->monitor].height * panel->area.height / 100;
if (panel->area.width + panel->marginx > server.monitor[panel->monitor].width)
panel->area.width = server.monitor[panel->monitor].width - panel->marginx;
panel->area.height = (float)server.monitors[panel->monitor].height * panel->area.height / 100;
if (panel->area.width + panel->marginx > server.monitors[panel->monitor].width)
panel->area.width = server.monitors[panel->monitor].width - panel->marginx;
if (panel->area.bg->border.radius > panel->area.height / 2) {
printf("panel_background_id rounded is too big... please fix your tint2rc\n");
g_array_append_val(backgrounds, *panel->area.bg);
@ -284,17 +284,17 @@ void init_panel_size_and_position(Panel *panel)
} else {
int old_panel_height = panel->area.height;
if (panel->fractional_width)
panel->area.height = (float)server.monitor[panel->monitor].height * panel->area.width / 100;
panel->area.height = (float)server.monitors[panel->monitor].height * panel->area.width / 100;
else
panel->area.height = panel->area.width;
if (panel->fractional_height)
panel->area.width = (float)server.monitor[panel->monitor].width * old_panel_height / 100;
panel->area.width = (float)server.monitors[panel->monitor].width * old_panel_height / 100;
else
panel->area.width = old_panel_height;
if (panel->area.height + panel->marginy > server.monitor[panel->monitor].height)
panel->area.height = server.monitor[panel->monitor].height - panel->marginy;
if (panel->area.height + panel->marginy > server.monitors[panel->monitor].height)
panel->area.height = server.monitors[panel->monitor].height - panel->marginy;
if (panel->area.bg->border.radius > panel->area.width / 2) {
printf("panel_background_id rounded is too big... please fix your tint2rc\n");
@ -306,28 +306,28 @@ void init_panel_size_and_position(Panel *panel)
// panel position determined here
if (panel_position & LEFT) {
panel->posx = server.monitor[panel->monitor].x + panel->marginx;
panel->posx = server.monitors[panel->monitor].x + panel->marginx;
} else {
if (panel_position & RIGHT) {
panel->posx = server.monitor[panel->monitor].x + server.monitor[panel->monitor].width - panel->area.width -
panel->posx = server.monitors[panel->monitor].x + server.monitors[panel->monitor].width - panel->area.width -
panel->marginx;
} else {
if (panel_horizontal)
panel->posx =
server.monitor[panel->monitor].x + ((server.monitor[panel->monitor].width - panel->area.width) / 2);
server.monitors[panel->monitor].x + ((server.monitors[panel->monitor].width - panel->area.width) / 2);
else
panel->posx = server.monitor[panel->monitor].x + panel->marginx;
panel->posx = server.monitors[panel->monitor].x + panel->marginx;
}
}
if (panel_position & TOP) {
panel->posy = server.monitor[panel->monitor].y + panel->marginy;
panel->posy = server.monitors[panel->monitor].y + panel->marginy;
} else {
if (panel_position & BOTTOM) {
panel->posy = server.monitor[panel->monitor].y + server.monitor[panel->monitor].height -
panel->posy = server.monitors[panel->monitor].y + server.monitors[panel->monitor].height -
panel->area.height - panel->marginy;
} else {
panel->posy =
server.monitor[panel->monitor].y + ((server.monitor[panel->monitor].height - panel->area.height) / 2);
server.monitors[panel->monitor].y + ((server.monitors[panel->monitor].height - panel->area.height) / 2);
}
}
@ -457,7 +457,7 @@ void update_strut(Panel *p)
Window d2;
int d3;
XGetGeometry(server.dsp, server.root_win, &d2, &d3, &d3, &screen_width, &screen_height, &d1, &d1);
Monitor monitor = server.monitor[p->monitor];
Monitor monitor = server.monitors[p->monitor];
long struts[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
if (panel_horizontal) {
int height = p->area.height + p->marginy;

View file

@ -126,13 +126,13 @@ void cleanup_server()
if (server.colormap32)
XFreeColormap(server.dsp, server.colormap32);
server.colormap32 = 0;
if (server.monitor) {
if (server.monitors) {
for (int i = 0; i < server.num_monitors; ++i) {
g_strfreev(server.monitor[i].names);
server.monitor[i].names = NULL;
g_strfreev(server.monitors[i].names);
server.monitors[i].names = NULL;
}
free(server.monitor);
server.monitor = NULL;
free(server.monitors);
server.monitors = NULL;
}
if (server.gc)
XFreeGC(server.dsp, server.gc);
@ -310,43 +310,43 @@ void get_monitors()
}
printf("xRandr: Found crtc's: %d\n", res->ncrtc);
server.monitor = calloc(res->ncrtc, sizeof(Monitor));
server.monitors = calloc(res->ncrtc, sizeof(Monitor));
for (int i = 0; i < res->ncrtc; ++i) {
XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(server.dsp, res, res->crtcs[i]);
server.monitor[i].x = crtc_info->x;
server.monitor[i].y = crtc_info->y;
server.monitor[i].width = crtc_info->width;
server.monitor[i].height = crtc_info->height;
server.monitor[i].names = calloc((crtc_info->noutput + 1), sizeof(gchar *));
server.monitors[i].x = crtc_info->x;
server.monitors[i].y = crtc_info->y;
server.monitors[i].width = crtc_info->width;
server.monitors[i].height = crtc_info->height;
server.monitors[i].names = calloc((crtc_info->noutput + 1), sizeof(gchar *));
for (int j = 0; j < crtc_info->noutput; ++j) {
XRROutputInfo *output_info = XRRGetOutputInfo(server.dsp, res, crtc_info->outputs[j]);
printf("xRandr: Linking output %s with crtc %d\n", output_info->name, i);
server.monitor[i].names[j] = g_strdup(output_info->name);
server.monitors[i].names[j] = g_strdup(output_info->name);
XRRFreeOutputInfo(output_info);
}
server.monitor[i].names[crtc_info->noutput] = NULL;
server.monitors[i].names[crtc_info->noutput] = NULL;
XRRFreeCrtcInfo(crtc_info);
}
num_monitors = res->ncrtc;
} else if (info && num_monitors > 0) {
server.monitor = calloc(num_monitors, sizeof(Monitor));
server.monitors = calloc(num_monitors, sizeof(Monitor));
for (int i = 0; i < num_monitors; i++) {
server.monitor[i].x = info[i].x_org;
server.monitor[i].y = info[i].y_org;
server.monitor[i].width = info[i].width;
server.monitor[i].height = info[i].height;
server.monitor[i].names = 0;
server.monitors[i].x = info[i].x_org;
server.monitors[i].y = info[i].y_org;
server.monitors[i].width = info[i].width;
server.monitors[i].height = info[i].height;
server.monitors[i].names = 0;
}
}
// ordered monitor
qsort(server.monitor, num_monitors, sizeof(Monitor), monitor_includes_monitor);
// Sort monitors by inclusion
qsort(server.monitors, num_monitors, sizeof(Monitor), monitor_includes_monitor);
// remove monitor included into another one
// Remove monitors included in other ones
int i = 0;
while (i < num_monitors) {
for (int j = 0; j < i; j++) {
if (monitor_includes_monitor(&server.monitor[i], &server.monitor[j]) > 0) {
if (monitor_includes_monitor(&server.monitors[i], &server.monitors[j]) > 0) {
goto next;
}
}
@ -354,11 +354,11 @@ void get_monitors()
}
next:
for (int j = i; j < num_monitors; ++j)
if (server.monitor[j].names)
g_strfreev(server.monitor[j].names);
if (server.monitors[j].names)
g_strfreev(server.monitors[j].names);
server.num_monitors = i;
server.monitor = realloc(server.monitor, server.num_monitors * sizeof(Monitor));
qsort(server.monitor, server.num_monitors, sizeof(Monitor), compare_monitor_pos);
server.monitors = realloc(server.monitors, server.num_monitors * sizeof(Monitor));
qsort(server.monitors, server.num_monitors, sizeof(Monitor), compare_monitor_pos);
if (res)
XRRFreeScreenResources(res);
@ -367,11 +367,11 @@ void get_monitors()
if (!server.num_monitors) {
server.num_monitors = 1;
server.monitor = calloc(1, sizeof(Monitor));
server.monitor[0].x = server.monitor[0].y = 0;
server.monitor[0].width = DisplayWidth(server.dsp, server.screen);
server.monitor[0].height = DisplayHeight(server.dsp, server.screen);
server.monitor[0].names = 0;
server.monitors = calloc(1, sizeof(Monitor));
server.monitors[0].x = server.monitors[0].y = 0;
server.monitors[0].width = DisplayWidth(server.dsp, server.screen);
server.monitors[0].height = DisplayHeight(server.dsp, server.screen);
server.monitors[0].names = 0;
}
}
@ -382,10 +382,10 @@ void print_monitors()
fprintf(stderr,
"Monitor %d: x = %d, y = %d, w = %d, h = %d\n",
i + 1,
server.monitor[i].x,
server.monitor[i].y,
server.monitor[i].width,
server.monitor[i].height);
server.monitors[i].x,
server.monitors[i].y,
server.monitors[i].width,
server.monitors[i].height);
}
}

View file

@ -122,7 +122,7 @@ typedef struct Server {
// Non-null only if WM uses viewports (compiz) and number of viewports > 1.
// In that case there are num_desktops viewports.
Viewport *viewports;
Monitor *monitor;
Monitor *monitors;
gboolean got_root_win;
Visual *visual;
Visual *visual32;

View file

@ -260,7 +260,7 @@ void init_taskbar_panel(void *p)
FALSE);
if (!panel->g_task.maximum_width && panel_horizontal)
panel->g_task.maximum_width = server.monitor[panel->monitor].width;
panel->g_task.maximum_width = server.monitors[panel->monitor].width;
panel->g_task.text_posx = panel->g_task.background[0]->border.width + panel->g_task.area.paddingxlr;
panel->g_task.text_height = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);

View file

@ -349,8 +349,8 @@ void get_snapshot(const char *path)
{
Panel *panel = &panels[0];
if (panel->area.width > server.monitor[0].width)
panel->area.width = server.monitor[0].width;
if (panel->area.width > server.monitors[0].width)
panel->area.width = server.monitors[0].width;
panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth);
render_panel(panel);

View file

@ -180,34 +180,34 @@ void tooltip_adjust_geometry()
int min_x, min_y, max_width, max_height;
Panel *panel = g_tooltip.panel;
int screen_width = server.monitor[panel->monitor].x + server.monitor[panel->monitor].width;
int screen_height = server.monitor[panel->monitor].y + server.monitor[panel->monitor].height;
if (x + width <= screen_width && y + height <= screen_height && x >= server.monitor[panel->monitor].x &&
y >= server.monitor[panel->monitor].y)
int screen_width = server.monitors[panel->monitor].x + server.monitors[panel->monitor].width;
int screen_height = server.monitors[panel->monitor].y + server.monitors[panel->monitor].height;
if (x + width <= screen_width && y + height <= screen_height && x >= server.monitors[panel->monitor].x &&
y >= server.monitors[panel->monitor].y)
return; // no adjustment needed
if (panel_horizontal) {
min_x = 0;
max_width = server.monitor[panel->monitor].width;
max_height = server.monitor[panel->monitor].height - panel->area.height;
max_width = server.monitors[panel->monitor].width;
max_height = server.monitors[panel->monitor].height - panel->area.height;
if (panel_position & BOTTOM)
min_y = 0;
else
min_y = panel->area.height;
} else {
max_width = server.monitor[panel->monitor].width - panel->area.width;
max_width = server.monitors[panel->monitor].width - panel->area.width;
min_y = 0;
max_height = server.monitor[panel->monitor].height;
max_height = server.monitors[panel->monitor].height;
if (panel_position & LEFT)
min_x = panel->area.width;
else
min_x = 0;
}
if (x + width > server.monitor[panel->monitor].x + server.monitor[panel->monitor].width)
x = server.monitor[panel->monitor].x + server.monitor[panel->monitor].width - width;
if (y + height > server.monitor[panel->monitor].y + server.monitor[panel->monitor].height)
y = server.monitor[panel->monitor].y + server.monitor[panel->monitor].height - height;
if (x + width > server.monitors[panel->monitor].x + server.monitors[panel->monitor].width)
x = server.monitors[panel->monitor].x + server.monitors[panel->monitor].width - width;
if (y + height > server.monitors[panel->monitor].y + server.monitors[panel->monitor].height)
y = server.monitors[panel->monitor].y + server.monitors[panel->monitor].height - height;
if (x < min_x)
x = min_x;

View file

@ -169,10 +169,10 @@ int get_window_monitor(Window win)
// There is an ambiguity when a window is right on the edge between screens.
// In that case, prefer the monitor which is on the right and bottom of the window's top-left corner.
for (i = 0; i < server.num_monitors; i++) {
if (x >= server.monitor[i].x && x <= (server.monitor[i].x + server.monitor[i].width) &&
y >= server.monitor[i].y && y <= (server.monitor[i].y + server.monitor[i].height)) {
int current_right = x < (server.monitor[i].x + server.monitor[i].width);
int current_bottom = y < (server.monitor[i].y + server.monitor[i].height);
if (x >= server.monitors[i].x && x <= (server.monitors[i].x + server.monitors[i].width) &&
y >= server.monitors[i].y && y <= (server.monitors[i].y + server.monitors[i].height)) {
int current_right = x < (server.monitors[i].x + server.monitors[i].width);
int current_bottom = y < (server.monitors[i].y + server.monitors[i].height);
if (best_match < 0 || (!match_right && current_right) || (!match_bottom && current_bottom)) {
best_match = i;
}