ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/EmulatorView.mm
(Generate patch)

Comparing BasiliskII/src/MacOSX/EmulatorView.mm (file contents):
Revision 1.7 by nigel, 2002-12-18T11:53:11Z vs.
Revision 1.8 by nigel, 2003-03-11T11:27:20Z

# Line 52 | Line 52
52          return self;
53   }
54  
55 + - (void) awakeFromNib
56 + {
57 +        // Here we store the height of the screen which the app was opened on.
58 +        // NSApplication's sendEvent: always uses that screen for its mouse co-ords
59 +        screen_height = (int) [[NSScreen mainScreen] frame].size.height;
60 + }
61 +
62 +
63   // Mouse click in this window. If window is not active,
64   // should the click be passed to this view?
65   - (BOOL) acceptsFirstMouse: (NSEvent *) event
# Line 60 | Line 68
68   }
69  
70  
71 + //
72 + // Key event processing.
73 + // OS X doesn't send us separate events for the modifier keys
74 + // (shift/control/command), so we need to monitor them separately
75 + //
76 +
77   #include <adb.h>
78  
79   static int prevFlags;
# Line 101 | Line 115 | static int prevFlags;
115          prevFlags = flags;
116   }
117  
118 + //
119 + // Windowed mode. We only send mouse/key events
120 + // if the OS X mouse is within the little screen
121 + //
122   - (BOOL) mouseInView: (NSEvent *) event
123   {
124          NSRect  box;
# Line 183 | Line 201 | static int prevFlags;
201                    imageWidth: (short) width
202                   imageHeight: (short) height
203   {
204 +        D(NSLog(@"readyToDraw: theBitmap=%lx\n", theBitmap));
205 +
206          bitmap = theBitmap;
207          numBytes = [theBitmap bytesPerRow] * height;
208   #endif
# Line 191 | Line 211 | static int prevFlags;
211                    imageWidth: (short) width
212                   imageHeight: (short) height
213   {
214 +        D(NSLog(@"readyToDraw: theBitmap=%lx\n", [cgImgRef bitmap]));
215 +
216          cgImgRep = image;
217 <        numBytes = CGImageGetBytesPerRow(image);
217 >        numBytes = CGImageGetBytesPerRow(image) * height;
218   #endif
219   #ifdef CGDRAWBITMAP
220   - (void) readyToDraw: (void *) theBitmap
# Line 205 | Line 227 | static int prevFlags;
227                          isPlanar: (BOOL)  planar
228                          hasAlpha: (BOOL)  alpha
229   {
230 +        D(NSLog(@"readyToDraw: theBitmap=%lx\n", theBitmap));
231 +
232          bitmap = theBitmap;
233          bps = bitsPerSample;
234          spp = samplesPerPixel;
# Line 216 | Line 240 | static int prevFlags;
240   #endif
241          x = width, y = height;
242          drawView = YES;
219
243          [[self window] setAcceptsMouseMovedEvents:      YES];
244   //      [[self window] setInitialFirstResponder:        self];
245          [[self window] makeFirstResponder:                      self];
# Line 233 | Line 256 | static int prevFlags;
256  
257          fullScreen = YES;
258          memcpy(&displayBox, &displayBounds, sizeof(displayBox));
236        screen_height = (int)displayBounds.size.height;
259   }
260  
261   - (short) width
# Line 298 | Line 320 | static int prevFlags;
320          }
321   }
322  
323 +
324 + - (void) fullscreenMouseMove
325 + {
326 +        NSPoint location = [NSEvent mouseLocation];
327 +
328 +        D(NSLog (@"%s - loc.x=%f, loc.y=%f",
329 +                                __PRETTY_FUNCTION__, location.x, location.y));
330 +        D(NSLog (@"%s - Sending ADBMouseMoved(%d,%d). (%d-%d)",
331 +                                        __PRETTY_FUNCTION__, (int)location.x,
332 +                                        screen_height - (int)location.y, screen_height, (int)location.y));
333 +        ADBMouseMoved((int)location.x, screen_height - (int)location.y);
334 + }
335 +
336   static NSPoint  mouse;                  // Previous/current mouse location
337  
338   - (BOOL) processMouseMove: (NSEvent *) event
# Line 305 | Line 340 | static NSPoint mouse;                  // Previous/curr
340          NSPoint location;
341  
342          if ( fullScreen )
343 <                location = [NSEvent mouseLocation];
344 <        else
345 <                location = [self convertPoint: [event locationInWindow] fromView:nil];
343 >        {
344 >                [self fullscreenMouseMove];
345 >                return YES;
346 >        }
347 >
348 >        location = [self convertPoint: [event locationInWindow] fromView:nil];
349 >
350 >        D(NSLog (@"%s - loc.x=%f, loc.y=%f",
351 >                                __PRETTY_FUNCTION__, location.x, location.y));
352  
353          if ( NSEqualPoints(location, mouse) )
354                  return NO;
355  
356          mouse = location;
357  
317        if ( fullScreen )
318        {
319                ADBMouseMoved((int)mouse.x, screen_height - (int)mouse.y);
320                return YES;
321        }
322
358   #ifdef CAN_RESIZE_VIEW
359          int     mouseY = y - y * mouse.y / [self height];
360          int     mouseX =         x * mouse.x / [self width];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines