History

20070831-0010

Charles.Forsyth committed 19 years ago

Commit 5bf0cee1 parent 526ea872 files · +116 −117Browse files

Unified · Split

2 files
  1. emu/MacOSX/win.c +115 −116
  2. include/version.h +1 −1
emu/MacOSX/win.c+115−116
@@ -38,7 +38,6 @@ · 37 unmodified lines
3838 extern void flushmemscreen(Rectangle);
3939
4040 Memimage *gscreen;
41−//Screeninfo screen;
4241
4342 static int readybit;
4443 static Rendez rend;
@@ -74,7 +73,7 @@ isready(void*a) · 29 unmodified lines
7473
7574 CGContextRef QuartzContext;
7675
77−void winproc(void *a);
76+static void winproc(void *a);
7877
7978 void
8079 screeninit(void)
@@ -115,16 +114,16 @@ screeninit(void) · 34 unmodified lines
115114 static OSStatus MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData);
116115 static OSStatus MainWindowCommandHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData);
117116
118−void
117+void
119118 window_resized(void)
120119 {
121− GetWindowBounds(theWindow, kWindowContentRgn, &winRect );
120+ GetWindowBounds(theWindow, kWindowContentRgn, &winRect);
122121
123122 bounds = CGRectMake(0, 0, winRect.right-winRect.left, winRect.bottom - winRect.top);
124123 }
125124
126125
127−void
126+static void
128127 winproc(void *a)
129128 {
130129 MenuItemIndex index;
@@ -152,7 +151,7 @@ winproc(void *a) · 21 unmodified lines
152151 AppendMenuItemTextWithCFString(viewMenu, CFSTR("Full Screen"), 0,
153152 kFullScreenCmd, &index);
154153 SetMenuItemCommandKey(viewMenu, index, 0, 'F');
155− AppendMenuItemTextWithCFString(viewMenu, CFSTR("ctrl-opt to return"),
154+ AppendMenuItemTextWithCFString(viewMenu, CFSTR("ctrl-opt to return"),
156155 kMenuItemAttrDisabled,
157156 kFullScreenCmd, &index);
158157 InsertMenu(viewMenu, GetMenuID(windMenu));
@@ -221,53 +220,53 @@ static int · 62 unmodified lines
221220 convert_key(UInt32 key, UInt32 charcode)
222221 {
223222 switch(key) {
224− case QZ_IBOOK_ENTER:
225− case QZ_RETURN: return '\n';
226− case QZ_ESCAPE: return 27;
227− case QZ_BACKSPACE: return '\b';
228− case QZ_LALT: return Kalt;
229− case QZ_LCTRL: return Kctl;
230− case QZ_LSHIFT: return Kshift;
231− case QZ_F1: return KF+1;
232− case QZ_F2: return KF+2;
233− case QZ_F3: return KF+3;
234− case QZ_F4: return KF+4;
235− case QZ_F5: return KF+5;
236− case QZ_F6: return KF+6;
237− case QZ_F7: return KF+7;
238− case QZ_F8: return KF+8;
239− case QZ_F9: return KF+9;
240− case QZ_F10: return KF+10;
241− case QZ_F11: return KF+11;
242− case QZ_F12: return KF+12;
243− case QZ_INSERT: return Kins;
244− case QZ_DELETE: return '0';
245− case QZ_HOME: return Khome;
246− case QZ_END: return Kend;
247− case QZ_KP_PLUS: return '+';
248− case QZ_KP_MINUS: return '-';
249− case QZ_TAB: return '\t';
250− case QZ_PAGEUP: return Kpgup;
251− case QZ_PAGEDOWN: return Kpgdown;
252− case QZ_UP: return Kup;
253− case QZ_DOWN: return Kdown;
254− case QZ_LEFT: return Kleft;
255− case QZ_RIGHT: return Kright;
256− case QZ_KP_MULTIPLY: return '*';
257− case QZ_KP_DIVIDE: return '/';
258− case QZ_KP_ENTER: return '\b';
259− case QZ_KP_PERIOD: return '.';
260− case QZ_KP0: return '0';
261− case QZ_KP1: return '1';
262− case QZ_KP2: return '2';
263− case QZ_KP3: return '3';
264− case QZ_KP4: return '4';
265− case QZ_KP5: return '5';
266− case QZ_KP6: return '6';
267− case QZ_KP7: return '7';
268− case QZ_KP8: return '8';
269− case QZ_KP9: return '9';
270− default: return charcode;
223+ case QZ_IBOOK_ENTER:
224+ case QZ_RETURN: return '\n';
225+ case QZ_ESCAPE: return 27;
226+ case QZ_BACKSPACE: return '\b';
227+ case QZ_LALT: return Kalt;
228+ case QZ_LCTRL: return Kctl;
229+ case QZ_LSHIFT: return Kshift;
230+ case QZ_F1: return KF+1;
231+ case QZ_F2: return KF+2;
232+ case QZ_F3: return KF+3;
233+ case QZ_F4: return KF+4;
234+ case QZ_F5: return KF+5;
235+ case QZ_F6: return KF+6;
236+ case QZ_F7: return KF+7;
237+ case QZ_F8: return KF+8;
238+ case QZ_F9: return KF+9;
239+ case QZ_F10: return KF+10;
240+ case QZ_F11: return KF+11;
241+ case QZ_F12: return KF+12;
242+ case QZ_INSERT: return Kins;
243+ case QZ_DELETE: return 0x7F;
244+ case QZ_HOME: return Khome;
245+ case QZ_END: return Kend;
246+ case QZ_KP_PLUS: return '+';
247+ case QZ_KP_MINUS: return '-';
248+ case QZ_TAB: return '\t';
249+ case QZ_PAGEUP: return Kpgup;
250+ case QZ_PAGEDOWN: return Kpgdown;
251+ case QZ_UP: return Kup;
252+ case QZ_DOWN: return Kdown;
253+ case QZ_LEFT: return Kleft;
254+ case QZ_RIGHT: return Kright;
255+ case QZ_KP_MULTIPLY: return '*';
256+ case QZ_KP_DIVIDE: return '/';
257+ case QZ_KP_ENTER: return '\n';
258+ case QZ_KP_PERIOD: return '.';
259+ case QZ_KP0: return '0';
260+ case QZ_KP1: return '1';
261+ case QZ_KP2: return '2';
262+ case QZ_KP3: return '3';
263+ case QZ_KP4: return '4';
264+ case QZ_KP5: return '5';
265+ case QZ_KP6: return '6';
266+ case QZ_KP7: return '7';
267+ case QZ_KP8: return '8';
268+ case QZ_KP9: return '9';
269+ default: return charcode;
271270 }
272271 }
273272
@@ -334,7 +333,7 @@ MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *us · 60 unmodified lines
334333 sizeof(macKeyModifiers), NULL, &macKeyModifiers);
335334 switch(kind) {
336335 case kEventRawKeyModifiersChanged:
337− if ( macKeyModifiers == 0x1800 ) leave_full_screen();
336+ if (macKeyModifiers == 0x1800) leave_full_screen();
338337 break;
339338 case kEventRawKeyDown:
340339 case kEventRawKeyRepeat: {
@@ -363,33 +362,35 @@ if(0 && key != -1)fprint(2, "[%C]", key); · 22 unmodified lines
363362 static uint32_t mousebuttons = 0; // bitmask of buttons currently down
364363
365364 switch (kind) {
366− case kEventMouseWheelMoved: {
367− int32_t wheeldelta;
368− GetEventParameter(event,kEventParamMouseWheelDelta,typeLongInteger,
369− 0,sizeof(EventMouseButton), 0, &wheeldelta);
370− sendbuttons((int16_t)wheeldelta>0 ? 8 : 16,
371− mousePos.h - winRect.left,
372− mousePos.v - winRect.top);
373− break;
374− }
375− case kEventMouseUp:
376− case kEventMouseDown: {
377− uint32_t buttons;
378− GetEventParameter(event, kEventParamMouseChord,
379− typeUInt32, 0, sizeof buttons, 0, &buttons);
380− mousebuttons = (buttons & 1)
381− | ((buttons & 2)<<1)
382− | ((buttons & 4)>>1);
383− } /* Fallthrough */
384− case kEventMouseMoved:
385− case kEventMouseDragged: {
386− sendbuttons(mousebuttons,
387− mousePos.h - winRect.left,
388− mousePos.v - winRect.top);
389− }
365+ case kEventMouseWheelMoved: {
366+ int32_t wheeldelta;
367+ GetEventParameter(event,kEventParamMouseWheelDelta,typeLongInteger,
368+ 0,sizeof(EventMouseButton), 0, &wheeldelta);
369+ sendbuttons((int16_t)wheeldelta>0 ? 8 : 16,
370+ mousePos.h - winRect.left,
371+ mousePos.v - winRect.top);
390372 break;
373+ }
374+ case kEventMouseUp:
375+ case kEventMouseDown: {
376+ uint32_t buttons;
377+ GetEventParameter(event, kEventParamMouseChord,
378+ typeUInt32, 0, sizeof buttons, 0, &buttons);
379+ mousebuttons = (buttons & 1)
380+ | ((buttons & 2)<<1)
381+ | ((buttons & 4)>>1);
382+ } /* Fallthrough */
383+ case kEventMouseMoved:
384+ case kEventMouseDragged: {
385+ sendbuttons(mousebuttons,
386+ mousePos.h - winRect.left,
387+ mousePos.v - winRect.top);
388+ }
389+ break;
391390
392− default:result = eventNotHandledErr;break;
391+ default:
392+ result = eventNotHandledErr;
393+ break;
393394 }
394395 }
395396 return result;
@@ -407,24 +408,23 @@ MainWindowCommandHandler(EventHandlerCallRef nextHandler, EventRef event, void * · 11 unmodified lines
407408
408409 if(class == kEventClassCommand){
409410 HICommand theHICommand;
410− GetEventParameter( event, kEventParamDirectObject, typeHICommand,
411− NULL, sizeof( HICommand ), NULL, &theHICommand );
411+ GetEventParameter(event, kEventParamDirectObject, typeHICommand,
412+ NULL, sizeof(HICommand), NULL, &theHICommand);
412413
413− switch ( theHICommand.commandID ){
414− case kHICommandQuit:
415− cleanexit(0);
416− break;
414+ switch(theHICommand.commandID){
415+ case kHICommandQuit:
416+ cleanexit(0);
417+ break;
417418
418− case kFullScreenCmd:
419− full_screen();
420− break;
419+ case kFullScreenCmd:
420+ full_screen();
421+ break;
421422
422− default:
423− result = eventNotHandledErr;
424− break;
423+ default:
424+ result = eventNotHandledErr;
425+ break;
425426 }
426− }
427− else if(class == kEventClassWindow){
427+ } else if(class == kEventClassWindow){
428428 WindowRef window;
429429 _Rect rectPort = {0,0,0,0};
430430
@@ -435,25 +435,25 @@ MainWindowCommandHandler(EventHandlerCallRef nextHandler, EventRef event, void * · 4 unmodified lines
435435 GetPortBounds(GetWindowPort(window), &rectPort);
436436
437437 switch (kind){
438− case kEventWindowClosed:
439− theWindow = NULL;
440− cleanexit(0); // only one window
441− break;
442−
443− //resize window
444− case kEventWindowBoundsChanged:
445− window_resized();
446− Rectangle rect = { { 0, 0 },
438+ case kEventWindowClosed:
439+ theWindow = NULL;
440+ cleanexit(0); // only one window
441+ break;
442+
443+ //resize window
444+ case kEventWindowBoundsChanged:
445+ window_resized();
446+ Rectangle rect = { { 0, 0 },
447447 { bounds.size.width,
448448 bounds.size.height} };
449− drawqlock();
450− flushmemscreen(rect);
451− drawqunlock();
452− break;
449+ drawqlock();
450+ flushmemscreen(rect);
451+ drawqunlock();
452+ break;
453453
454− default:
455− result = eventNotHandledErr;
456− break;
454+ default:
455+ result = eventNotHandledErr;
456+ break;
457457 }
458458 }
459459
@@ -477,7 +477,7 @@ flushmemscreen(Rectangle r) · 17 unmodified lines
477477 if(rbounds.size.width <= 0 || rbounds.size.height <= 0)
478478 return;
479479
480− QDBeginCGContext( GetWindowPort(theWindow), &context);
480+ QDBeginCGContext(GetWindowPort(theWindow), &context);
481481
482482 // The sub-image is relative to our whole screen image.
483483 CGImageRef subimg = CGImageCreateWithImageInRect(fullScreenImage, rbounds);
@@ -487,7 +487,7 @@ flushmemscreen(Rectangle r) · 3 unmodified lines
487487 CGContextDrawImage(context, rbounds, subimg);
488488 CGContextFlush(context);
489489 CGImageRelease(subimg);
490− QDEndCGContext( GetWindowPort(theWindow), &context);
490+ QDEndCGContext(GetWindowPort(theWindow), &context);
491491 }
492492
493493 uchar*
@@ -536,19 +536,19 @@ clipread(void) · 42 unmodified lines
536536 {
537537 CFDataRef cfdata;
538538 OSStatus err = noErr;
539− ItemCount nItems;
539+ ItemCount nitems;
540540 int i;
541541 char *s;
542542
543543 // Wow. This is ridiculously complicated.
544544 PasteboardSynchronize(appleclip);
545− if((err = PasteboardGetItemCount(appleclip, &nItems)) != noErr) {
545+ if((err = PasteboardGetItemCount(appleclip, &nitems)) != noErr) {
546546 fprint(2, "apple pasteboard GetItemCount failed - Error %d\n", err);
547547 return 0;
548548 }
549549
550550 // Yes, based at 1. Silly API.
551− for(i = 1; i <= nItems; i++) {
551+ for(i = 1; i <= nitems; i++) {
552552 PasteboardItemID itemID;
553553 CFArrayRef flavorTypeArray;
554554 CFIndex flavorCount;
@@ -577,7 +577,7 @@ clipread(void) · 22 unmodified lines
577577 CFIndex length = CFDataGetLength(cfdata);
578578 if (length > sizeof rsnarf) length = sizeof rsnarf;
579579 CFDataGetBytes(cfdata, CFRangeMake(0, length), (uint8_t *)rsnarf);
580− snprint(snarf, sizeof snarf, "%S", rsnarf);
580+ snprint(snarf, sizeof snarf, "%.*S", length/sizeof(Rune), rsnarf);
581581 for(s = snarf; *s; s++)
582582 if(*s == '\r')
583583 *s = '\n';
@@ -589,7 +589,6 @@ clipread(void) · 5 unmodified lines
589589 return 0;
590590 }
591591
592−// TO DO: check that the return value is correct
593592 int
594593 clipwrite(char *snarf)
595594 {
include/version.h+1−1
@@ -1 +1 @@
1−#define VERSION "Fourth Edition (20070817)"
1+#define VERSION "Fourth Edition (20070831)"