From 5b950fa2ef39d5fe61e19b1e1f697d625be1a606 Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Thu, 20 Nov 2003 16:24:57 +0000 Subject: [PATCH] fix shm screen image allocation. --- SheepShaver/src/Unix/video_x.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SheepShaver/src/Unix/video_x.cpp b/SheepShaver/src/Unix/video_x.cpp index d00a39c5..d834f42b 100644 --- a/SheepShaver/src/Unix/video_x.cpp +++ b/SheepShaver/src/Unix/video_x.cpp @@ -197,12 +197,16 @@ static bool open_window(int width, int height) XFree((char *)hints); } + // 1-bit mode is big-endian; if the X server is little-endian, we can't + // use SHM because that doesn't allow changing the image byte order + bool need_msb_image = (depth == 1 && XImageByteOrder(x_display) == LSBFirst); + // Try to create and attach SHM image have_shm = false; - if (local_X11 && depth != 1 && XShmQueryExtension(x_display)) { + if (local_X11 && !need_msb_image && XShmQueryExtension(x_display)) { // Create SHM image ("height + 2" for safety) - img = XShmCreateImage(x_display, vis, depth, depth == 1 ? XYBitmap : ZPixmap, 0, &shminfo, width, height); + img = XShmCreateImage(x_display, vis, depth == 1 ? 1 : xdepth, depth == 1 ? XYBitmap : ZPixmap, 0, &shminfo, width, height); shminfo.shmid = shmget(IPC_PRIVATE, (height + 2) * img->bytes_per_line, IPC_CREAT | 0777); the_buffer_copy = (uint8 *)shmat(shminfo.shmid, 0, 0); shminfo.shmaddr = img->data = (char *)the_buffer_copy;