From a3ea4f3eadde7d88d4ccc7d3dba03b4f1f38d6b7 Mon Sep 17 00:00:00 2001 From: cebix <> Date: Sat, 30 Jun 2001 20:18:36 +0000 Subject: [PATCH] - fixed compilation problems in fbdev DGA code - nicer "about" dialog in GTK prefs editor - display refresh is inhibited during mode switch if !HAVE_PTHREADS --- BasiliskII/src/Unix/prefs_editor_gtk.cpp | 18 +++++++++---- BasiliskII/src/Unix/video_x.cpp | 33 +++++++++++++----------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/BasiliskII/src/Unix/prefs_editor_gtk.cpp b/BasiliskII/src/Unix/prefs_editor_gtk.cpp index b28bee29..08fc1f97 100644 --- a/BasiliskII/src/Unix/prefs_editor_gtk.cpp +++ b/BasiliskII/src/Unix/prefs_editor_gtk.cpp @@ -227,13 +227,21 @@ static void mn_about(...) { GtkWidget *dialog, *label, *button; - char str[256]; - sprintf(str, GetString(STR_ABOUT_TEXT1), VERSION_MAJOR, VERSION_MINOR); - strncat(str, "\n", 255); - strncat(str, GetString(STR_ABOUT_TEXT2), 255); + char str[512]; + sprintf(str, + "Basilisk II\nVersion %d.%d\n\n" + "Copyright (C) 1997-2001 Christian Bauer et al.\n" + "E-mail: Christian.Bauer@uni-mainz.de\n" + "http://www.uni-mainz.de/~bauec002/B2Main.html\n\n" + "Basilisk II comes with ABSOLUTELY NO\n" + "WARRANTY. This is free software, and\n" + "you are welcome to redistribute it\n" + "under the terms of the GNU General\n" + "Public License.\n", + VERSION_MAJOR, VERSION_MINOR + ); dialog = gtk_dialog_new(); - gtk_widget_set_usize(GTK_WIDGET(dialog), strlen(GetString(STR_ABOUT_TEXT2)) + 200, 120); gtk_window_set_title(GTK_WINDOW(dialog), GetString(STR_ABOUT_TITLE)); gtk_container_border_width(GTK_CONTAINER(dialog), 5); gtk_widget_set_uposition(GTK_WIDGET(dialog), 100, 150); diff --git a/BasiliskII/src/Unix/video_x.cpp b/BasiliskII/src/Unix/video_x.cpp index 6238c60d..9b15477d 100644 --- a/BasiliskII/src/Unix/video_x.cpp +++ b/BasiliskII/src/Unix/video_x.cpp @@ -87,8 +87,8 @@ static bool local_X11; // Flag: X server running on local machine? static uint8 *the_buffer = NULL; // Mac frame buffer (where MacOS draws into) static uint8 *the_buffer_copy = NULL; // Copy of Mac frame buffer (for refreshed modes) -#ifdef HAVE_PTHREADS static bool redraw_thread_active = false; // Flag: Redraw thread installed +#ifdef HAVE_PTHREADS static volatile bool redraw_thread_cancel; // Flag: Cancel Redraw thread static pthread_t redraw_thread; // Redraw thread #endif @@ -345,15 +345,15 @@ driver_base::driver_base() driver_base::~driver_base() { - XFlush(x_display); - XSync(x_display, false); - if (w) { XUnmapWindow(x_display, w); wait_unmapped(w); XDestroyWindow(x_display, w); } + XFlush(x_display); + XSync(x_display, false); + // Free frame buffer(s) if (!use_vosf) { if (the_buffer) { @@ -446,7 +446,7 @@ driver_window::driver_window(const video_mode &mode) wait_mapped(w); // Try to create and attach SHM image - if (local_X11 && mode.depth != VDEPTH_1BIT && XShmQueryExtension(x_display)) { + if (local_X11 && XShmQueryExtension(x_display)) { // Create SHM image ("height + 2" for safety) img = XShmCreateImage(x_display, vis, mode.depth == VDEPTH_1BIT ? 1 : xdepth, mode.depth == VDEPTH_1BIT ? XYBitmap : ZPixmap, 0, &shminfo, width, height); @@ -659,14 +659,13 @@ void driver_dga::resume(void) * fbdev DGA display driver */ +const char FBDEVICES_FILE_NAME[] = DATADIR "/fbdevices"; +const char FBDEVICE_FILE_NAME[] = "/dev/fb"; + class driver_fbdev : public driver_dga { public: driver_fbdev(const video_mode &mode); ~driver_fbdev(); - -private: - const char FBDEVICES_FILE_NAME[] = DATADIR "/fbdevices"; - const char FBDEVICE_FILE_NAME[] = "/dev/fb"; }; // Open display @@ -799,7 +798,7 @@ driver_fbdev::driver_fbdev(const video_mode &mode) // Set VideoMonitor VideoModes[0].bytes_per_row = bytes_per_row; - VideoModes[0].depth = DepthModeForPixelDepth(); + VideoModes[0].depth = DepthModeForPixelDepth(fb_depth); VideoMonitor.mode = mode; set_mac_frame_buffer(mode.depth, true); @@ -1070,14 +1069,16 @@ static bool video_open(const video_mode &mode) XSync(x_display, false); LOCK_FRAME_BUFFER; -#ifdef HAVE_PTHREADS // Start redraw/input thread +#ifdef HAVE_PTHREADS redraw_thread_cancel = false; redraw_thread_active = (pthread_create(&redraw_thread, NULL, redraw_func, NULL) == 0); if (!redraw_thread_active) { printf("FATAL: cannot create redraw thread\n"); return false; } +#else + redraw_thread_active = true; #endif return true; @@ -1260,17 +1261,17 @@ bool VideoInit(bool classic) // Close display static void video_close(void) { -#ifdef HAVE_PTHREADS // Stop redraw thread +#ifdef HAVE_PTHREADS if (redraw_thread_active) { redraw_thread_cancel = true; #ifdef HAVE_PTHREAD_CANCEL pthread_cancel(redraw_thread); #endif pthread_join(redraw_thread, NULL); - redraw_thread_active = false; } #endif + redraw_thread_active = false; // Unlock frame buffer UNLOCK_FRAME_BUFFER; @@ -2051,8 +2052,10 @@ static void VideoRefreshInit(void) void VideoRefresh(void) { - // TODO: make main_unix/VideoRefresh call directly video_refresh() ? - video_refresh(); + // We need to check redraw_thread_active to inhibit refreshed during + // mode changes on non-threaded platforms + if (redraw_thread_active) + video_refresh(); } #ifdef HAVE_PTHREADS