Skip to content

Commit

Permalink
Set display depths based on the actual screen color space.
Browse files Browse the repository at this point in the history
Fixes #10.
  • Loading branch information
waddlesplash committed Mar 21, 2022
1 parent 8b70705 commit 8eda2dc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
17 changes: 17 additions & 0 deletions xlib/Color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ _x_color_space_for(Visual* v, int bits_per_pixel)
}
}

int
_x_depth_for_color_space(color_space space)
{
switch (space) {
case B_GRAY1: return 1;
case B_GRAY8: return 8;
case B_RGB15: return 15;
case B_RGB16: return 16;
case B_RGB24: return 24;
case B_RGB32: return 32;
case B_RGBA32: return 32;
default:
debugger("Unsupported color space!");
return 24;
}
}

static int
FindColor(const char *name, XColor *def)
{
Expand Down
1 change: 1 addition & 0 deletions xlib/Color.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ _x_pixel_to_rgb(unsigned long color, bool alpha = false)
}

color_space _x_color_space_for(Visual* v, int bits_per_pixel);
int _x_depth_for_color_space(color_space space);
4 changes: 2 additions & 2 deletions xlib/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ set_display(Display* dpy)

memset(slist, 0, sizeof(Screen));

dlist[0].depth = 24;
dlist[0].depth = _x_depth_for_color_space(screen.ColorSpace());
dlist[0].nvisuals = 1;
dlist[0].visuals = vlist;

vlist[0].ext_data = NULL;
vlist[0].visualid = 0;
vlist[0].c_class = TrueColor;
vlist[0].bits_per_rgb = 24;
vlist[0].bits_per_rgb = dlist[0].depth;
vlist[0].map_entries = 256;
_x_get_rgb_masks(&vlist[0]);

Expand Down

0 comments on commit 8eda2dc

Please sign in to comment.