| @@ -38,7 +38,6 @@ · 37 unmodified lines |
| 38 | extern void flushmemscreen(Rectangle); | 38 | extern void flushmemscreen(Rectangle); |
| 39 | | 39 | |
| 40 | Memimage *gscreen; | 40 | Memimage *gscreen; |
| 41 | //Screeninfo screen; | | |
| 42 | | 41 | |
| 43 | static int readybit; | 42 | static int readybit; |
| 44 | static Rendez rend; | 43 | static Rendez rend; |
| @@ -74,7 +73,7 @@ isready(void*a) · 29 unmodified lines |
| 74 | | 73 | |
| 75 | CGContextRef QuartzContext; | 74 | CGContextRef QuartzContext; |
| 76 | | 75 | |
| 77 | void winproc(void *a); | 76 | static void winproc(void *a); |
| 78 | | 77 | |
| 79 | void | 78 | void |
| 80 | screeninit(void) | 79 | screeninit(void) |
| @@ -115,16 +114,16 @@ screeninit(void) · 34 unmodified lines |
| 115 | static OSStatus MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData); | 114 | static OSStatus MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData); |
| 116 | static OSStatus MainWindowCommandHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData); | 115 | static OSStatus MainWindowCommandHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData); |
| 117 | | 116 | |
| 118 | void | 117 | void |
| 119 | window_resized(void) | 118 | window_resized(void) |
| 120 | { | 119 | { |
| 121 | GetWindowBounds(theWindow, kWindowContentRgn, &winRect ); | 120 | GetWindowBounds(theWindow, kWindowContentRgn, &winRect); |
| 122 | | 121 | |
| 123 | bounds = CGRectMake(0, 0, winRect.right-winRect.left, winRect.bottom - winRect.top); | 122 | bounds = CGRectMake(0, 0, winRect.right-winRect.left, winRect.bottom - winRect.top); |
| 124 | } | 123 | } |
| 125 | | 124 | |
| 126 | | 125 | |
| 127 | void | 126 | static void |
| 128 | winproc(void *a) | 127 | winproc(void *a) |
| 129 | { | 128 | { |
| 130 | MenuItemIndex index; | 129 | MenuItemIndex index; |
| @@ -152,7 +151,7 @@ winproc(void *a) · 21 unmodified lines |
| 152 | AppendMenuItemTextWithCFString(viewMenu, CFSTR("Full Screen"), 0, | 151 | AppendMenuItemTextWithCFString(viewMenu, CFSTR("Full Screen"), 0, |
| 153 | kFullScreenCmd, &index); | 152 | kFullScreenCmd, &index); |
| 154 | SetMenuItemCommandKey(viewMenu, index, 0, 'F'); | 153 | SetMenuItemCommandKey(viewMenu, index, 0, 'F'); |
| 155 | AppendMenuItemTextWithCFString(viewMenu, CFSTR("ctrl-opt to return"), | 154 | AppendMenuItemTextWithCFString(viewMenu, CFSTR("ctrl-opt to return"), |
| 156 | kMenuItemAttrDisabled, | 155 | kMenuItemAttrDisabled, |
| 157 | kFullScreenCmd, &index); | 156 | kFullScreenCmd, &index); |
| 158 | InsertMenu(viewMenu, GetMenuID(windMenu)); | 157 | InsertMenu(viewMenu, GetMenuID(windMenu)); |
| @@ -221,53 +220,53 @@ static int · 62 unmodified lines |
| 221 | convert_key(UInt32 key, UInt32 charcode) | 220 | convert_key(UInt32 key, UInt32 charcode) |
| 222 | { | 221 | { |
| 223 | switch(key) { | 222 | switch(key) { |
| 224 | case QZ_IBOOK_ENTER: | 223 | case QZ_IBOOK_ENTER: |
| 225 | case QZ_RETURN: return '\n'; | 224 | case QZ_RETURN: return '\n'; |
| 226 | case QZ_ESCAPE: return 27; | 225 | case QZ_ESCAPE: return 27; |
| 227 | case QZ_BACKSPACE: return '\b'; | 226 | case QZ_BACKSPACE: return '\b'; |
| 228 | case QZ_LALT: return Kalt; | 227 | case QZ_LALT: return Kalt; |
| 229 | case QZ_LCTRL: return Kctl; | 228 | case QZ_LCTRL: return Kctl; |
| 230 | case QZ_LSHIFT: return Kshift; | 229 | case QZ_LSHIFT: return Kshift; |
| 231 | case QZ_F1: return KF+1; | 230 | case QZ_F1: return KF+1; |
| 232 | case QZ_F2: return KF+2; | 231 | case QZ_F2: return KF+2; |
| 233 | case QZ_F3: return KF+3; | 232 | case QZ_F3: return KF+3; |
| 234 | case QZ_F4: return KF+4; | 233 | case QZ_F4: return KF+4; |
| 235 | case QZ_F5: return KF+5; | 234 | case QZ_F5: return KF+5; |
| 236 | case QZ_F6: return KF+6; | 235 | case QZ_F6: return KF+6; |
| 237 | case QZ_F7: return KF+7; | 236 | case QZ_F7: return KF+7; |
| 238 | case QZ_F8: return KF+8; | 237 | case QZ_F8: return KF+8; |
| 239 | case QZ_F9: return KF+9; | 238 | case QZ_F9: return KF+9; |
| 240 | case QZ_F10: return KF+10; | 239 | case QZ_F10: return KF+10; |
| 241 | case QZ_F11: return KF+11; | 240 | case QZ_F11: return KF+11; |
| 242 | case QZ_F12: return KF+12; | 241 | case QZ_F12: return KF+12; |
| 243 | case QZ_INSERT: return Kins; | 242 | case QZ_INSERT: return Kins; |
| 244 | case QZ_DELETE: return '0'; | 243 | case QZ_DELETE: return 0x7F; |
| 245 | case QZ_HOME: return Khome; | 244 | case QZ_HOME: return Khome; |
| 246 | case QZ_END: return Kend; | 245 | case QZ_END: return Kend; |
| 247 | case QZ_KP_PLUS: return '+'; | 246 | case QZ_KP_PLUS: return '+'; |
| 248 | case QZ_KP_MINUS: return '-'; | 247 | case QZ_KP_MINUS: return '-'; |
| 249 | case QZ_TAB: return '\t'; | 248 | case QZ_TAB: return '\t'; |
| 250 | case QZ_PAGEUP: return Kpgup; | 249 | case QZ_PAGEUP: return Kpgup; |
| 251 | case QZ_PAGEDOWN: return Kpgdown; | 250 | case QZ_PAGEDOWN: return Kpgdown; |
| 252 | case QZ_UP: return Kup; | 251 | case QZ_UP: return Kup; |
| 253 | case QZ_DOWN: return Kdown; | 252 | case QZ_DOWN: return Kdown; |
| 254 | case QZ_LEFT: return Kleft; | 253 | case QZ_LEFT: return Kleft; |
| 255 | case QZ_RIGHT: return Kright; | 254 | case QZ_RIGHT: return Kright; |
| 256 | case QZ_KP_MULTIPLY: return '*'; | 255 | case QZ_KP_MULTIPLY: return '*'; |
| 257 | case QZ_KP_DIVIDE: return '/'; | 256 | case QZ_KP_DIVIDE: return '/'; |
| 258 | case QZ_KP_ENTER: return '\b'; | 257 | case QZ_KP_ENTER: return '\n'; |
| 259 | case QZ_KP_PERIOD: return '.'; | 258 | case QZ_KP_PERIOD: return '.'; |
| 260 | case QZ_KP0: return '0'; | 259 | case QZ_KP0: return '0'; |
| 261 | case QZ_KP1: return '1'; | 260 | case QZ_KP1: return '1'; |
| 262 | case QZ_KP2: return '2'; | 261 | case QZ_KP2: return '2'; |
| 263 | case QZ_KP3: return '3'; | 262 | case QZ_KP3: return '3'; |
| 264 | case QZ_KP4: return '4'; | 263 | case QZ_KP4: return '4'; |
| 265 | case QZ_KP5: return '5'; | 264 | case QZ_KP5: return '5'; |
| 266 | case QZ_KP6: return '6'; | 265 | case QZ_KP6: return '6'; |
| 267 | case QZ_KP7: return '7'; | 266 | case QZ_KP7: return '7'; |
| 268 | case QZ_KP8: return '8'; | 267 | case QZ_KP8: return '8'; |
| 269 | case QZ_KP9: return '9'; | 268 | case QZ_KP9: return '9'; |
| 270 | default: return charcode; | 269 | default: return charcode; |
| 271 | } | 270 | } |
| 272 | } | 271 | } |
| 273 | | 272 | |
| @@ -334,7 +333,7 @@ MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *us · 60 unmodified lines |
| 334 | sizeof(macKeyModifiers), NULL, &macKeyModifiers); | 333 | sizeof(macKeyModifiers), NULL, &macKeyModifiers); |
| 335 | switch(kind) { | 334 | switch(kind) { |
| 336 | case kEventRawKeyModifiersChanged: | 335 | case kEventRawKeyModifiersChanged: |
| 337 | if ( macKeyModifiers == 0x1800 ) leave_full_screen(); | 336 | if (macKeyModifiers == 0x1800) leave_full_screen(); |
| 338 | break; | 337 | break; |
| 339 | case kEventRawKeyDown: | 338 | case kEventRawKeyDown: |
| 340 | case kEventRawKeyRepeat: { | 339 | case kEventRawKeyRepeat: { |
| @@ -363,33 +362,35 @@ if(0 && key != -1)fprint(2, "[%C]", key); · 22 unmodified lines |
| 363 | static uint32_t mousebuttons = 0; // bitmask of buttons currently down | 362 | static uint32_t mousebuttons = 0; // bitmask of buttons currently down |
| 364 | | 363 | |
| 365 | switch (kind) { | 364 | switch (kind) { |
| 366 | case kEventMouseWheelMoved: { | 365 | case kEventMouseWheelMoved: { |
| 367 | int32_t wheeldelta; | 366 | int32_t wheeldelta; |
| 368 | GetEventParameter(event,kEventParamMouseWheelDelta,typeLongInteger, | 367 | GetEventParameter(event,kEventParamMouseWheelDelta,typeLongInteger, |
| 369 | 0,sizeof(EventMouseButton), 0, &wheeldelta); | 368 | 0,sizeof(EventMouseButton), 0, &wheeldelta); |
| 370 | sendbuttons((int16_t)wheeldelta>0 ? 8 : 16, | 369 | sendbuttons((int16_t)wheeldelta>0 ? 8 : 16, |
| 371 | mousePos.h - winRect.left, | 370 | mousePos.h - winRect.left, |
| 372 | mousePos.v - winRect.top); | 371 | 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 | } | | |
| 390 | break; | 372 | 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; |
| 391 | | 390 | |
| 392 | default:result = eventNotHandledErr;break; | 391 | default: |
| | 392 | result = eventNotHandledErr; |
| | 393 | break; |
| 393 | } | 394 | } |
| 394 | } | 395 | } |
| 395 | return result; | 396 | return result; |
| @@ -407,24 +408,23 @@ MainWindowCommandHandler(EventHandlerCallRef nextHandler, EventRef event, void * · 11 unmodified lines |
| 407 | | 408 | |
| 408 | if(class == kEventClassCommand){ | 409 | if(class == kEventClassCommand){ |
| 409 | HICommand theHICommand; | 410 | HICommand theHICommand; |
| 410 | GetEventParameter( event, kEventParamDirectObject, typeHICommand, | 411 | GetEventParameter(event, kEventParamDirectObject, typeHICommand, |
| 411 | NULL, sizeof( HICommand ), NULL, &theHICommand ); | 412 | NULL, sizeof(HICommand), NULL, &theHICommand); |
| 412 | | 413 | |
| 413 | switch ( theHICommand.commandID ){ | 414 | switch(theHICommand.commandID){ |
| 414 | case kHICommandQuit: | 415 | case kHICommandQuit: |
| 415 | cleanexit(0); | 416 | cleanexit(0); |
| 416 | break; | 417 | break; |
| 417 | | 418 | |
| 418 | case kFullScreenCmd: | 419 | case kFullScreenCmd: |
| 419 | full_screen(); | 420 | full_screen(); |
| 420 | break; | 421 | break; |
| 421 | | 422 | |
| 422 | default: | 423 | default: |
| 423 | result = eventNotHandledErr; | 424 | result = eventNotHandledErr; |
| 424 | break; | 425 | break; |
| 425 | } | 426 | } |
| 426 | } | 427 | } else if(class == kEventClassWindow){ |
| 427 | else if(class == kEventClassWindow){ | | |
| 428 | WindowRef window; | 428 | WindowRef window; |
| 429 | _Rect rectPort = {0,0,0,0}; | 429 | _Rect rectPort = {0,0,0,0}; |
| 430 | | 430 | |
| @@ -435,25 +435,25 @@ MainWindowCommandHandler(EventHandlerCallRef nextHandler, EventRef event, void * · 4 unmodified lines |
| 435 | GetPortBounds(GetWindowPort(window), &rectPort); | 435 | GetPortBounds(GetWindowPort(window), &rectPort); |
| 436 | | 436 | |
| 437 | switch (kind){ | 437 | switch (kind){ |
| 438 | case kEventWindowClosed: | 438 | case kEventWindowClosed: |
| 439 | theWindow = NULL; | 439 | theWindow = NULL; |
| 440 | cleanexit(0); // only one window | 440 | cleanexit(0); // only one window |
| 441 | break; | 441 | break; |
| 442 | | 442 | |
| 443 | //resize window | 443 | //resize window |
| 444 | case kEventWindowBoundsChanged: | 444 | case kEventWindowBoundsChanged: |
| 445 | window_resized(); | 445 | window_resized(); |
| 446 | Rectangle rect = { { 0, 0 }, | 446 | Rectangle rect = { { 0, 0 }, |
| 447 | { bounds.size.width, | 447 | { bounds.size.width, |
| 448 | bounds.size.height} }; | 448 | bounds.size.height} }; |
| 449 | drawqlock(); | 449 | drawqlock(); |
| 450 | flushmemscreen(rect); | 450 | flushmemscreen(rect); |
| 451 | drawqunlock(); | 451 | drawqunlock(); |
| 452 | break; | 452 | break; |
| 453 | | 453 | |
| 454 | default: | 454 | default: |
| 455 | result = eventNotHandledErr; | 455 | result = eventNotHandledErr; |
| 456 | break; | 456 | break; |
| 457 | } | 457 | } |
| 458 | } | 458 | } |
| 459 | | 459 | |
| @@ -477,7 +477,7 @@ flushmemscreen(Rectangle r) · 17 unmodified lines |
| 477 | if(rbounds.size.width <= 0 || rbounds.size.height <= 0) | 477 | if(rbounds.size.width <= 0 || rbounds.size.height <= 0) |
| 478 | return; | 478 | return; |
| 479 | | 479 | |
| 480 | QDBeginCGContext( GetWindowPort(theWindow), &context); | 480 | QDBeginCGContext(GetWindowPort(theWindow), &context); |
| 481 | | 481 | |
| 482 | // The sub-image is relative to our whole screen image. | 482 | // The sub-image is relative to our whole screen image. |
| 483 | CGImageRef subimg = CGImageCreateWithImageInRect(fullScreenImage, rbounds); | 483 | CGImageRef subimg = CGImageCreateWithImageInRect(fullScreenImage, rbounds); |
| @@ -487,7 +487,7 @@ flushmemscreen(Rectangle r) · 3 unmodified lines |
| 487 | CGContextDrawImage(context, rbounds, subimg); | 487 | CGContextDrawImage(context, rbounds, subimg); |
| 488 | CGContextFlush(context); | 488 | CGContextFlush(context); |
| 489 | CGImageRelease(subimg); | 489 | CGImageRelease(subimg); |
| 490 | QDEndCGContext( GetWindowPort(theWindow), &context); | 490 | QDEndCGContext(GetWindowPort(theWindow), &context); |
| 491 | } | 491 | } |
| 492 | | 492 | |
| 493 | uchar* | 493 | uchar* |
| @@ -536,19 +536,19 @@ clipread(void) · 42 unmodified lines |
| 536 | { | 536 | { |
| 537 | CFDataRef cfdata; | 537 | CFDataRef cfdata; |
| 538 | OSStatus err = noErr; | 538 | OSStatus err = noErr; |
| 539 | ItemCount nItems; | 539 | ItemCount nitems; |
| 540 | int i; | 540 | int i; |
| 541 | char *s; | 541 | char *s; |
| 542 | | 542 | |
| 543 | // Wow. This is ridiculously complicated. | 543 | // Wow. This is ridiculously complicated. |
| 544 | PasteboardSynchronize(appleclip); | 544 | PasteboardSynchronize(appleclip); |
| 545 | if((err = PasteboardGetItemCount(appleclip, &nItems)) != noErr) { | 545 | if((err = PasteboardGetItemCount(appleclip, &nitems)) != noErr) { |
| 546 | fprint(2, "apple pasteboard GetItemCount failed - Error %d\n", err); | 546 | fprint(2, "apple pasteboard GetItemCount failed - Error %d\n", err); |
| 547 | return 0; | 547 | return 0; |
| 548 | } | 548 | } |
| 549 | | 549 | |
| 550 | // Yes, based at 1. Silly API. | 550 | // Yes, based at 1. Silly API. |
| 551 | for(i = 1; i <= nItems; i++) { | 551 | for(i = 1; i <= nitems; i++) { |
| 552 | PasteboardItemID itemID; | 552 | PasteboardItemID itemID; |
| 553 | CFArrayRef flavorTypeArray; | 553 | CFArrayRef flavorTypeArray; |
| 554 | CFIndex flavorCount; | 554 | CFIndex flavorCount; |
| @@ -577,7 +577,7 @@ clipread(void) · 22 unmodified lines |
| 577 | CFIndex length = CFDataGetLength(cfdata); | 577 | CFIndex length = CFDataGetLength(cfdata); |
| 578 | if (length > sizeof rsnarf) length = sizeof rsnarf; | 578 | if (length > sizeof rsnarf) length = sizeof rsnarf; |
| 579 | CFDataGetBytes(cfdata, CFRangeMake(0, length), (uint8_t *)rsnarf); | 579 | 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); |
| 581 | for(s = snarf; *s; s++) | 581 | for(s = snarf; *s; s++) |
| 582 | if(*s == '\r') | 582 | if(*s == '\r') |
| 583 | *s = '\n'; | 583 | *s = '\n'; |
| @@ -589,7 +589,6 @@ clipread(void) · 5 unmodified lines |
| 589 | return 0; | 589 | return 0; |
| 590 | } | 590 | } |
| 591 | | 591 | |
| 592 | // TO DO: check that the return value is correct | | |
| 593 | int | 592 | int |
| 594 | clipwrite(char *snarf) | 593 | clipwrite(char *snarf) |
| 595 | { | 594 | { |