ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/video_x.cpp
(Generate patch)

Comparing BasiliskII/src/Unix/video_x.cpp (file contents):
Revision 1.24 by cebix, 2000-10-11T17:55:06Z vs.
Revision 1.28 by cebix, 2000-11-03T12:23:49Z

# Line 53 | Line 53
53   #endif
54  
55   #ifdef ENABLE_VOSF
56 # include <math.h> // log()
56   # include <unistd.h>
57   # include <signal.h>
58   # include <fcntl.h>
# Line 123 | Line 122 | static Colormap cmap[2];                                                       // Two co
122   static XColor black, white;
123   static unsigned long black_pixel, white_pixel;
124   static int eventmask;
125 < static const int win_eventmask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | ExposureMask;
125 > static const int win_eventmask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | FocusChangeMask | ExposureMask;
126   static const int dga_eventmask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
127  
128   static XColor palette[256];                                                     // Color palette for 8-bit mode
# Line 219 | Line 218 | static struct sigaction vosf_sa;
218   static pthread_mutex_t Screen_draw_lock = PTHREAD_MUTEX_INITIALIZER;    // Mutex to protect frame buffer (dirtyPages in fact)
219   #endif
220  
221 + static int log_base_2(uint32 x)
222 + {
223 +        uint32 mask = 0x80000000;
224 +        int l = 31;
225 +        while (l >= 0 && (x & mask) == 0) {
226 +                mask >>= 1;
227 +                l--;
228 +        }
229 +        return l;
230 + }
231 +
232   #endif
233  
234   // VideoRefresh function
# Line 326 | Line 336 | static bool init_window(int width, int h
336          XSetWindowAttributes wattr;
337          wattr.event_mask = eventmask = win_eventmask;
338          wattr.background_pixel = black_pixel;
329        wattr.border_pixel = black_pixel;
330        wattr.backing_store = NotUseful;
331        wattr.save_under = false;
332        wattr.backing_planes = xdepth;
339  
340          XSync(x_display, false);
341          the_win = XCreateWindow(x_display, rootwin, 0, 0, width, height, 0, xdepth,
342 <                InputOutput, vis, CWEventMask | CWBackPixel | CWBorderPixel |
337 <                CWBackingStore | CWBackingPlanes, &wattr);
338 <        XSync(x_display, false);
339 <        XStoreName(x_display, the_win, GetString(STR_WINDOW_TITLE));
340 <        XMapRaised(x_display, the_win);
341 <        XSync(x_display, false);
342 >                InputOutput, vis, CWEventMask | CWBackPixel, &wattr);
343  
344 <        // Set colormap
345 <        if (depth == 8) {
346 <                XSetWindowColormap(x_display, the_win, cmap[0]);
347 <                XSetWMColormapWindows(x_display, the_win, &the_win, 1);
344 >        // Indicate that we want keyboard input
345 >        {
346 >                XWMHints *hints = XAllocWMHints();
347 >                if (hints) {
348 >                        hints->input = True;
349 >                        hints->flags = InputHint;
350 >                        XSetWMHints(x_display, the_win, hints);
351 >                        XFree((char *)hints);
352 >                }
353          }
354  
355          // Make window unresizable
356 <        XSizeHints *hints;
357 <        if ((hints = XAllocSizeHints()) != NULL) {
358 <                hints->min_width = width;
359 <                hints->max_width = width;
360 <                hints->min_height = height;
361 <                hints->max_height = height;
362 <                hints->flags = PMinSize | PMaxSize;
363 <                XSetWMNormalHints(x_display, the_win, hints);
364 <                XFree((char *)hints);
356 >        {
357 >                XSizeHints *hints = XAllocSizeHints();
358 >                if (hints) {
359 >                        hints->min_width = width;
360 >                        hints->max_width = width;
361 >                        hints->min_height = height;
362 >                        hints->max_height = height;
363 >                        hints->flags = PMinSize | PMaxSize;
364 >                        XSetWMNormalHints(x_display, the_win, hints);
365 >                        XFree((char *)hints);
366 >                }
367          }
368          
369 +        // Set window title
370 +        XStoreName(x_display, the_win, GetString(STR_WINDOW_TITLE));
371 +
372 +        // Set window class
373 +        {
374 +                XClassHint *hints;
375 +                hints = XAllocClassHint();
376 +                if (hints) {
377 +                        hints->res_name = "BasiliskII";
378 +                        hints->res_class = "BasiliskII";
379 +                        XSetClassHint(x_display, the_win, hints);
380 +                        XFree((char *)hints);
381 +                }
382 +        }
383 +
384 +        // Show window
385 +        XSync(x_display, false);
386 +        XMapRaised(x_display, the_win);
387 +        XFlush(x_display);
388 +
389 +        // Set colormap
390 +        if (depth == 8)
391 +                XSetWindowColormap(x_display, the_win, cmap[0]);
392 +
393          // Try to create and attach SHM image
394          have_shm = false;
395          if (depth != 1 && local_X11 && XShmQueryExtension(x_display)) {
# Line 529 | Line 561 | static bool init_fbdev_dga(char *in_fb_n
561          
562          // Create window
563          XSetWindowAttributes wattr;
532        wattr.override_redirect = True;
533        wattr.backing_store             = NotUseful;
534        wattr.background_pixel  = white_pixel;
535        wattr.border_pixel              = black_pixel;
564          wattr.event_mask                = eventmask = dga_eventmask;
565 +        wattr.background_pixel  = white_pixel;
566 +        wattr.override_redirect = True;
567          
568          XSync(x_display, false);
569          the_win = XCreateWindow(x_display, rootwin,
570                  0, 0, width, height,
571                  0, xdepth, InputOutput, vis,
572 <                CWEventMask|CWBackPixel|CWBorderPixel|CWOverrideRedirect|CWBackingStore,
572 >                CWEventMask | CWBackPixel | CWOverrideRedirect,
573                  &wattr);
574          XSync(x_display, false);
575          XMapRaised(x_display, the_win);
# Line 553 | Line 583 | static bool init_fbdev_dga(char *in_fb_n
583                  GrabModeAsync, GrabModeAsync, the_win, None, CurrentTime);
584          
585          // Set colormap
586 <        if (depth == 8) {
586 >        if (depth == 8)
587                  XSetWindowColormap(x_display, the_win, cmap[0]);
558                XSetWMColormapWindows(x_display, the_win, &the_win, 1);
559        }
588          
589          // Set VideoMonitor
590          int bytes_per_row = width;
# Line 643 | Line 671 | static bool init_xf86_dga(int width, int
671          // Create window
672          XSetWindowAttributes wattr;
673          wattr.event_mask = eventmask = dga_eventmask;
646        wattr.border_pixel = black_pixel;
674          wattr.override_redirect = True;
675  
676          XSync(x_display, false);
677          the_win = XCreateWindow(x_display, rootwin, 0, 0, width, height, 0, xdepth,
678 <                InputOutput, vis, CWEventMask | CWBorderPixel | CWOverrideRedirect, &wattr);
678 >                InputOutput, vis, CWEventMask | CWOverrideRedirect, &wattr);
679          XSync(x_display, false);
680          XStoreName(x_display, the_win, GetString(STR_WINDOW_TITLE));
681          XMapRaised(x_display, the_win);
# Line 669 | Line 696 | static bool init_xf86_dga(int width, int
696          // Set colormap
697          if (depth == 8) {
698                  XSetWindowColormap(x_display, the_win, cmap[current_dga_cmap = 0]);
672                XSetWMColormapWindows(x_display, the_win, &the_win, 1);
699                  XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]);
700          }
701  
# Line 804 | Line 830 | bool VideoInitBuffer()
830  
831                  mainBuffer.pageSize     = page_size;
832                  mainBuffer.pageCount    = (mainBuffer.memLength + page_mask)/mainBuffer.pageSize;
833 <                mainBuffer.pageBits     = int( log(mainBuffer.pageSize) / log(2.0) );
833 >                mainBuffer.pageBits     = log_base_2(mainBuffer.pageSize);
834  
835                  if (mainBuffer.dirtyPages != 0)
836                          free(mainBuffer.dirtyPages);
# Line 1199 | Line 1225 | void VideoInterrupt(void)
1225  
1226   void video_set_palette(uint8 *pal)
1227   {
1228 < #ifdef HAVE_PTHREDS
1228 > #ifdef HAVE_PTHREADS
1229          pthread_mutex_lock(&palette_lock);
1230   #endif
1231  
# Line 1256 | Line 1282 | static void suspend_emul(void)
1282                  XSetWindowAttributes wattr;
1283                  wattr.event_mask = KeyPressMask;
1284                  wattr.background_pixel = black_pixel;
1285 <                wattr.border_pixel = black_pixel;
1260 <                wattr.backing_store = Always;
1285 >                wattr.backing_store = WhenMapped;
1286                  wattr.backing_planes = xdepth;
1287                  wattr.colormap = DefaultColormap(x_display, screen);
1288                  
1289                  XSync(x_display, false);
1290                  suspend_win = XCreateWindow(x_display, rootwin, 0, 0, 512, 1, 0, xdepth,
1291 <                        InputOutput, vis, CWEventMask | CWBackPixel | CWBorderPixel |
1292 <                        CWBackingStore | CWBackingPlanes | (xdepth == 8 ? CWColormap : 0), &wattr);
1291 >                        InputOutput, vis, CWEventMask | CWBackPixel | CWBackingStore |
1292 >                        CWBackingPlanes | (xdepth == 8 ? CWColormap : 0), &wattr);
1293                  XSync(x_display, false);
1294                  XStoreName(x_display, suspend_win, GetString(STR_SUSPEND_WINDOW_TITLE));
1295                  XMapRaised(x_display, suspend_win);
# Line 1617 | Line 1642 | static void handle_events(void)
1642                                                  memset(the_buffer_copy, 0, VideoMonitor.bytes_per_row * VideoMonitor.y);
1643                                  }
1644                                  break;
1645 +
1646 +                        case FocusIn:
1647 +                        case FocusOut:
1648 +                                break;
1649                  }
1650          }
1651   }
# Line 1766 | Line 1795 | static void update_display_static(void)
1795                                  for (i=(VideoMonitor.x>>3); i>(x2>>3); i--) {
1796                                          p--; p2--;
1797                                          if (*p != *p2) {
1798 <                                                x2 = i << 3;
1798 >                                                x2 = (i << 3) + 7;
1799                                                  break;
1800                                          }
1801                                  }
1802                          }
1803 <                        wide = x2 - x1;
1803 >                        wide = x2 - x1 + 1;
1804  
1805                          // Update copy of the_buffer
1806                          if (high && wide) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines