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.26 by cebix, 2000-10-27T17:01:40Z

# 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 335 | Line 345 | static bool init_window(int width, int h
345          the_win = XCreateWindow(x_display, rootwin, 0, 0, width, height, 0, xdepth,
346                  InputOutput, vis, CWEventMask | CWBackPixel | CWBorderPixel |
347                  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);
348  
349 <        // Set colormap
350 <        if (depth == 8) {
351 <                XSetWindowColormap(x_display, the_win, cmap[0]);
352 <                XSetWMColormapWindows(x_display, the_win, &the_win, 1);
349 >        // Indicate that we want keyboard input
350 >        {
351 >                XWMHints *hints = XAllocWMHints();
352 >                if (hints) {
353 >                        hints->input = True;
354 >                        hints->flags = InputHint;
355 >                        XSetWMHints(x_display, the_win, hints);
356 >                        XFree((char *)hints);
357 >                }
358          }
359  
360          // Make window unresizable
361 <        XSizeHints *hints;
362 <        if ((hints = XAllocSizeHints()) != NULL) {
363 <                hints->min_width = width;
364 <                hints->max_width = width;
365 <                hints->min_height = height;
366 <                hints->max_height = height;
367 <                hints->flags = PMinSize | PMaxSize;
368 <                XSetWMNormalHints(x_display, the_win, hints);
369 <                XFree((char *)hints);
361 >        {
362 >                XSizeHints *hints = XAllocSizeHints();
363 >                if (hints) {
364 >                        hints->min_width = width;
365 >                        hints->max_width = width;
366 >                        hints->min_height = height;
367 >                        hints->max_height = height;
368 >                        hints->flags = PMinSize | PMaxSize;
369 >                        XSetWMNormalHints(x_display, the_win, hints);
370 >                        XFree((char *)hints);
371 >                }
372          }
373          
374 +        // Set window title
375 +        {
376 +                XTextProperty title_prop;
377 +                const char *title = GetString(STR_WINDOW_TITLE);
378 +                XStringListToTextProperty((char **)&title, 1, &title_prop);
379 +                XSetWMName(x_display, the_win, &title_prop);
380 +                XFree(title_prop.value);
381 +        }
382 +
383 +        // Set window class
384 +        {
385 +                XClassHint *hints;
386 +                hints = XAllocClassHint();
387 +                if (hints) {
388 +                        hints->res_name = "BasiliskII";
389 +                        hints->res_class = "BasiliskII";
390 +                        XSetClassHint(x_display, the_win, hints);
391 +                        XFree((char *)hints);
392 +                }
393 +        }
394 +
395 +        // Show window
396 +        XSync(x_display, false);
397 +        XMapRaised(x_display, the_win);
398 +        XFlush(x_display);
399 +
400 +        // Set colormap
401 +        if (depth == 8)
402 +                XSetWindowColormap(x_display, the_win, cmap[0]);
403 +
404          // Try to create and attach SHM image
405          have_shm = false;
406          if (depth != 1 && local_X11 && XShmQueryExtension(x_display)) {
# Line 553 | Line 596 | static bool init_fbdev_dga(char *in_fb_n
596                  GrabModeAsync, GrabModeAsync, the_win, None, CurrentTime);
597          
598          // Set colormap
599 <        if (depth == 8) {
599 >        if (depth == 8)
600                  XSetWindowColormap(x_display, the_win, cmap[0]);
558                XSetWMColormapWindows(x_display, the_win, &the_win, 1);
559        }
601          
602          // Set VideoMonitor
603          int bytes_per_row = width;
# Line 669 | Line 710 | static bool init_xf86_dga(int width, int
710          // Set colormap
711          if (depth == 8) {
712                  XSetWindowColormap(x_display, the_win, cmap[current_dga_cmap = 0]);
672                XSetWMColormapWindows(x_display, the_win, &the_win, 1);
713                  XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]);
714          }
715  
# Line 804 | Line 844 | bool VideoInitBuffer()
844  
845                  mainBuffer.pageSize     = page_size;
846                  mainBuffer.pageCount    = (mainBuffer.memLength + page_mask)/mainBuffer.pageSize;
847 <                mainBuffer.pageBits     = int( log(mainBuffer.pageSize) / log(2.0) );
847 >                mainBuffer.pageBits     = log_base_2(mainBuffer.pageSize);
848  
849                  if (mainBuffer.dirtyPages != 0)
850                          free(mainBuffer.dirtyPages);
# Line 1617 | Line 1657 | static void handle_events(void)
1657                                                  memset(the_buffer_copy, 0, VideoMonitor.bytes_per_row * VideoMonitor.y);
1658                                  }
1659                                  break;
1660 +
1661 +                        case FocusIn:
1662 +                        case FocusOut:
1663 +                                break;
1664                  }
1665          }
1666   }
# Line 1766 | Line 1810 | static void update_display_static(void)
1810                                  for (i=(VideoMonitor.x>>3); i>(x2>>3); i--) {
1811                                          p--; p2--;
1812                                          if (*p != *p2) {
1813 <                                                x2 = i << 3;
1813 >                                                x2 = (i << 3) + 7;
1814                                                  break;
1815                                          }
1816                                  }
1817                          }
1818 <                        wide = x2 - x1;
1818 >                        wide = x2 - x1 + 1;
1819  
1820                          // Update copy of the_buffer
1821                          if (high && wide) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines