46 |
|
#include "about_window.h" |
47 |
|
#include "video.h" |
48 |
|
#include "video_defs.h" |
49 |
+ |
#include "video_blit.h" |
50 |
|
|
51 |
|
#define DEBUG 0 |
52 |
|
#include "debug.h" |
66 |
|
static int16 mouse_wheel_lines; |
67 |
|
static bool redraw_thread_active = false; // Flag: Redraw thread installed |
68 |
|
static pthread_attr_t redraw_thread_attr; // Redraw thread attributes |
69 |
+ |
static volatile bool redraw_thread_cancel; // Flag: Cancel Redraw thread |
70 |
|
static pthread_t redraw_thread; // Redraw thread |
71 |
|
|
72 |
|
static bool local_X11; // Flag: X server running on local machine? |
102 |
|
static Window rootwin, the_win; // Root window and our window |
103 |
|
static int num_depths = 0; // Number of available X depths |
104 |
|
static int *avail_depths = NULL; // List of available X depths |
105 |
+ |
static VisualFormat visualFormat; |
106 |
|
static XVisualInfo visualInfo; |
107 |
|
static Visual *vis; |
108 |
|
static int color_class; |
542 |
|
native_byte_order = (XImageByteOrder(x_display) == LSBFirst); |
543 |
|
#endif |
544 |
|
#ifdef ENABLE_VOSF |
545 |
< |
Screen_blitter_init(&visualInfo, native_byte_order, depth); |
545 |
> |
Screen_blitter_init(visualFormat, native_byte_order, depth); |
546 |
|
#endif |
547 |
|
|
548 |
|
// Set bytes per row |
616 |
|
#if REAL_ADDRESSING || DIRECT_ADDRESSING |
617 |
|
// Screen_blitter_init() returns TRUE if VOSF is mandatory |
618 |
|
// i.e. the framebuffer update function is not Blit_Copy_Raw |
619 |
< |
use_vosf = Screen_blitter_init(&visualInfo, native_byte_order, depth); |
619 |
> |
use_vosf = Screen_blitter_init(visualFormat, native_byte_order, depth); |
620 |
|
|
621 |
|
if (use_vosf) { |
622 |
|
// Allocate memory for frame buffer (SIZE is extended to page-boundary) |
653 |
|
return false; |
654 |
|
} |
655 |
|
|
656 |
+ |
// Build up visualFormat structure |
657 |
+ |
visualFormat.depth = visualInfo.depth; |
658 |
+ |
visualFormat.Rmask = visualInfo.red_mask; |
659 |
+ |
visualFormat.Gmask = visualInfo.green_mask; |
660 |
+ |
visualFormat.Bmask = visualInfo.blue_mask; |
661 |
+ |
|
662 |
|
// Create color maps |
663 |
|
if (color_class == PseudoColor || color_class == DirectColor) { |
664 |
|
cmap[0] = XCreateColormap(x_display, rootwin, vis, AllocAll); |
892 |
|
|
893 |
|
// Search for server vendor string, then read keycodes |
894 |
|
const char *vendor = ServerVendor(x_display); |
895 |
+ |
#if (defined(__APPLE__) && defined(__MACH__)) |
896 |
+ |
// Force use of MacX mappings on MacOS X with Apple's X server |
897 |
+ |
int dummy; |
898 |
+ |
if (XQueryExtension(x_display, "Apple-DRI", &dummy, &dummy, &dummy)) |
899 |
+ |
vendor = "MacX"; |
900 |
+ |
#endif |
901 |
|
bool vendor_found = false; |
902 |
|
char line[256]; |
903 |
|
while (fgets(line, 255, f)) { |
1208 |
|
// Start periodic thread |
1209 |
|
XSync(x_display, false); |
1210 |
|
Set_pthread_attr(&redraw_thread_attr, 0); |
1211 |
+ |
redraw_thread_cancel = false; |
1212 |
|
redraw_thread_active = (pthread_create(&redraw_thread, &redraw_thread_attr, redraw_func, NULL) == 0); |
1213 |
|
D(bug("Redraw thread installed (%ld)\n", redraw_thread)); |
1214 |
|
return true; |
1223 |
|
{ |
1224 |
|
// Stop redraw thread |
1225 |
|
if (redraw_thread_active) { |
1226 |
+ |
redraw_thread_cancel = true; |
1227 |
|
pthread_cancel(redraw_thread); |
1228 |
|
pthread_join(redraw_thread, NULL); |
1229 |
|
redraw_thread_active = false; |
2312 |
|
int64 ticks = 0; |
2313 |
|
uint64 next = GetTicks_usec() + VIDEO_REFRESH_DELAY; |
2314 |
|
|
2315 |
< |
for (;;) { |
2315 |
> |
while (!redraw_thread_cancel) { |
2316 |
|
|
2317 |
|
// Pause if requested (during video mode switches) |
2318 |
|
while (thread_stop_req) |
2379 |
|
// Set new cursor image if it was changed |
2380 |
|
if (hw_mac_cursor_accl && cursor_changed) { |
2381 |
|
cursor_changed = false; |
2382 |
< |
memcpy(cursor_image->data, MacCursor + 4, 32); |
2383 |
< |
memcpy(cursor_mask_image->data, MacCursor + 36, 32); |
2382 |
> |
uint8 *x_data = (uint8 *)cursor_image->data; |
2383 |
> |
uint8 *x_mask = (uint8 *)cursor_mask_image->data; |
2384 |
> |
for (int i = 0; i < 32; i++) { |
2385 |
> |
x_mask[i] = MacCursor[4 + i] | MacCursor[36 + i]; |
2386 |
> |
x_data[i] = MacCursor[4 + i]; |
2387 |
> |
} |
2388 |
|
XDisplayLock(); |
2389 |
|
XFreeCursor(x_display, mac_cursor); |
2390 |
|
XPutImage(x_display, cursor_map, cursor_gc, cursor_image, 0, 0, 0, 0, 16, 16); |