Skip to content
Snippets Groups Projects
Commit 4d262c09 authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

Revert "TEST multiple outputs"

This reverts commit 92a1bd9d.
parent 92a1bd9d
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@
#define SLIDERS_WITH_BRACKETS
#define MAX_WIN 10
struct osd_state {
// Basic characteristics of current display and screen
......@@ -41,8 +42,8 @@ struct osd_state {
// Our window
Window win[MAX_WIN];
int win_len;
int win_width[MAX_WIN];
int win_height[MAX_WIN];
int win_width;
int win_height;
Pixmap mask_bitmap;
Pixmap image_pixmap;
GC gc;
......@@ -51,7 +52,7 @@ struct osd_state {
// Xft state
XftFont *font;
XftDraw *mask_draw;
XftDraw *image_draw[MAX_WIN];
XftDraw *image_draw;
// Contents of the display
struct osd_line *lines;
......@@ -207,7 +208,7 @@ struct osd_line *osd_add_line(struct osd_state *osd, enum osd_line_type type)
l->type = type;
l->fg_color = "green";
l->outline_color = "black";
l->outline_width = 30;
l->outline_width = 0;
switch (l->type)
{
......@@ -228,8 +229,6 @@ struct osd_line *osd_add_line(struct osd_state *osd, enum osd_line_type type)
static void osd_prepare_line(struct osd_state *osd, int i)
{
struct osd_line *line = &osd->lines[i];
for(int win=0;win<osd->win_len;win++)
{
switch (line->type)
{
case OSD_TYPE_TEXT:
......@@ -237,8 +236,8 @@ static void osd_prepare_line(struct osd_state *osd, int i)
XGlyphInfo gi;
XftTextExtentsUtf8(osd->dpy, osd->font, (unsigned char *) line->u.text, strlen(line->u.text), &gi);
DBG("Line #%d: Glyph info: (%d,%d)+(%d,%d) off (%d,%d)\n", i, gi.x, gi.y, gi.width, gi.height, gi.xOff, gi.yOff);
line->width[win] = gi.width + 2*line->outline_width;
line->height[win] = osd->line_distance + 2*line->outline_width;
line->width = gi.width + 2*line->outline_width;
line->height = osd->line_distance + 2*line->outline_width;
break;
}
case OSD_TYPE_PERCENTAGE:
......@@ -253,56 +252,50 @@ static void osd_prepare_line(struct osd_state *osd, int i)
#endif
if (!line->slider_space)
line->slider_space = line->slider_unit = 1;
int use_width = osd->screen_width[win] * 4 / 5;
int use_width = osd->screen_width[0] * 4 / 5;
int u = line->slider_unit + line->slider_space;
line->slider_units = (use_width + line->slider_space) / u;
if (line->slider_units < 3)
line->slider_units = 3;
line->width[win] = line->slider_units*u - line->slider_space + 2*line->outline_width;
line->height[win] = osd->line_height + 2*line->outline_width;
line->width = line->slider_units*u - line->slider_space + 2*line->outline_width;
line->height = osd->line_height + 2*line->outline_width;
break;
}
default:
die("osd_recalc_line: unknown type %d", line->type);
}
}
DBG("Line #%d: Width %d (outline %d)\n", i, line->width, line->outline_width);
}
static void osd_justify_line(struct osd_state *osd, int i)
{
for(int win=0;win<osd->win_len;win++)
{
// FIXME: Support more modes of justification
struct osd_line *line = &osd->lines[i];
line->x_pos[win] = (osd->win_width[win] - line->width[win]) / 2;
line->x_pos = (osd->win_width - line->width) / 2;
DBG("Line #%d: Position (%d,%d)\n", i, line->x_pos, line->y_pos);
}
}
static void osd_prepare(struct osd_state *osd)
{
for(int win=0;win<osd->win_len;win++)
{
osd->win_width[win] = 0;
osd->win_height[win] = 0;
osd->win_width = 0;
osd->win_height = 0;
for (int i=0; i < osd->num_lines; i++)
{
struct osd_line *line = &osd->lines[i];
osd_prepare_line(osd, i);
if (line->width[win] > osd->win_width[win])
osd->win_width[win] = line->width[win];
osd->win_height[win] += line->height[win];
if (line->width > osd->win_width)
osd->win_width = line->width;
osd->win_height += line->height;
if (i)
osd->win_height[win] += osd->line_skip;
osd->win_height += osd->line_skip;
}
if (osd->win_width[win] > osd->screen_width[0])
osd->win_width[win] = osd->screen_width[0];
if (osd->win_height[win] > osd->screen_height[0])
osd->win_height[win] = osd->screen_height[0];
DBG("Window size set to %dx%d\n", osd->win_width[win], osd->win_height[win]);
if (osd->win_width > osd->screen_width[0])
osd->win_width = osd->screen_width[0];
if (osd->win_height > osd->screen_height[0])
osd->win_height = osd->screen_height[0];
DBG("Window size set to %dx%d\n", osd->win_width, osd->win_height);
int y = 0;
for (int i=0; i < osd->num_lines; i++)
......@@ -310,14 +303,13 @@ static void osd_prepare(struct osd_state *osd)
struct osd_line *line = &osd->lines[i];
if (i)
y += osd->line_skip;
line->y_pos[win] = y;
line->y_pos = y;
osd_justify_line(osd, i);
y += line->height[win];
}
y += line->height;
}
}
static void osd_draw_box(struct osd_state *osd, struct osd_line *line, int x, int y, int w, int h,int win)
static void osd_draw_box(struct osd_state *osd, struct osd_line *line, int x, int y, int w, int h)
{
XftDrawRect(osd->mask_draw, &osd->mask_color,
x - line->outline_width, y - line->outline_width,
......@@ -372,9 +364,9 @@ static void osd_draw_line(struct osd_state *osd, int i)
units -= 2;
int hu = osd->line_height / 5;
int hd = 2*hu;
osd_draw_box(osd, line, x, y, su - su/3, 5*hu, win);
osd_draw_box(osd, line, x, y, su, hu, win);
osd_draw_box(osd, line, x, y + 4*hu, su, hu, win);
osd_draw_box(osd, line, x, y, su - su/3, 5*hu);
osd_draw_box(osd, line, x, y, su, hu);
osd_draw_box(osd, line, x, y + 4*hu, su, hu);
x += advance;
#else
int hu = osd->line_height / 3;
......@@ -391,15 +383,15 @@ static void osd_draw_line(struct osd_state *osd, int i)
for (int i=0; i < units; i++)
{
if (i >= min && i <= max)
osd_draw_box(osd, line, x, y, su, osd->line_height, win);
osd_draw_box(osd, line, x, y, su, osd->line_height);
else
osd_draw_box(osd, line, x, y + hd, su, hu, win);
osd_draw_box(osd, line, x, y + hd, su, hu);
x += advance;
}
#ifdef SLIDERS_WITH_BRACKETS
osd_draw_box(osd, line, x + su/3, y, su - su/3, 5*hu, win);
osd_draw_box(osd, line, x, y, su, hu, win);
osd_draw_box(osd, line, x, y + 4*hu, su, hu, win);
osd_draw_box(osd, line, x + su/3, y, su - su/3, 5*hu);
osd_draw_box(osd, line, x, y, su, hu);
osd_draw_box(osd, line, x, y + 4*hu, su, hu);
#endif
break;
}
......@@ -506,7 +498,7 @@ void osd_show(struct osd_state *osd)
osd->win[i] = XCreateWindow(osd->dpy,
osd->root,
osd->screen_x[i] + (osd->screen_width[i] - osd->win_width) / 2, osd->screen_y[i] + (osd->screen_height[i] - osd->win_height) / 2,
osd->win_width[i], osd->win_height[i],
osd->win_width, osd->win_height,
0,
osd->depth,
CopyFromParent,
......@@ -520,7 +512,7 @@ void osd_show(struct osd_state *osd)
// Create image pixmap and its graphic context
// osd->gc can be used for both osd->win and osd->image_bitmap as they have the same root and depth
for(int i=0;i<osd->win_len;i++)
osd->image_pixmap = XCreatePixmap(osd->dpy, osd->win[i], osd->win_width[i], osd->win_height[i], osd->depth);
osd->image_pixmap = XCreatePixmap(osd->dpy, osd->win[i], osd->win_width, osd->win_height, osd->depth);
XGCValues gcv = {
.graphics_exposures = 0,
};
......@@ -529,13 +521,13 @@ void osd_show(struct osd_state *osd)
// Create mask bitmap and its GC
for(int i=0;i<osd->win_len;i++)
osd->mask_bitmap = XCreatePixmap(osd->dpy, osd->win[i], osd->win_width[i], osd->win_height[i], 1);
osd->mask_bitmap = XCreatePixmap(osd->dpy, osd->win[i], osd->win_width, osd->win_height, 1);
osd->mask_gc = XCreateGC(osd->dpy, osd->mask_bitmap, GCGraphicsExposures, &gcv);
// Clear the mask bitmap
XSetBackground(osd->dpy, osd->mask_gc, WhitePixel(osd->dpy, osd->screen));
XSetForeground(osd->dpy, osd->mask_gc, BlackPixel(osd->dpy, osd->screen));
XFillRectangle(osd->dpy, osd->mask_bitmap, osd->mask_gc, 0, 0, osd->win_width[i], osd->win_height[i]);
XFillRectangle(osd->dpy, osd->mask_bitmap, osd->mask_gc, 0, 0, osd->win_width, osd->win_height);
// Create XftDraw for mask and image
osd->mask_draw = XftDrawCreateBitmap(osd->dpy, osd->mask_bitmap);
......
......@@ -11,8 +11,6 @@ struct osd_state;
#define OSD_MAX_LINE_LEN 256
#define MAX_WIN 10
enum osd_line_type {
OSD_TYPE_TEXT,
OSD_TYPE_PERCENTAGE,
......@@ -30,10 +28,10 @@ struct osd_line {
} u;
// Used internally
int width[MAX_WIN];
int height[MAX_WIN];
int x_pos[MAX_WIN];
int y_pos[MAX_WIN];
int width;
int height;
int x_pos;
int y_pos;
int slider_unit;
int slider_space;
int slider_units;
......
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment