/* * PositionVerticalScrollThumb - draw the scroll thumb on the screen */ void PositionVerticalScrollThumb( window_id wn, linenum curr, linenum last ) { wind *w; int height; int newpos; w = AccessWindow( wn ); if( !w->has_gadgets || !w->has_border ) { ReleaseWindow( w ); return; } height = w->y2 - w->y1 - THUMB_START * 2; if( height <= 0 ) { newpos = 0; } else if( curr == 1 ) { newpos = THUMB_START; } else { newpos = (int)(((long) (height - 1) * curr) / last) + THUMB_START + 1; } if( w->vert_scroll_pos != newpos ) { DrawVerticalThumb( w, EditVars.GadgetString[WB_RIGHTSIDE] ); } w->vert_scroll_pos = newpos; DrawVerticalThumb( w, EditVars.GadgetString[WB_THUMB] ); ReleaseWindow( w ); } /* PositionVerticalScrollThumb */
/* * MarkOverlap - mark who a "new" window has overlapped */ void MarkOverlap( window_id wn ) { wind *w, *wo; int i, j, k; char *whoover, *img; w = AccessWindow( wn ); whoover = w->whooverlapping; for( j = w->y1; j <= w->y2; j++ ) { img = &ScreenImage[w->x1 + j * WindMaxWidth]; for( i = w->x1; i <= w->x2; i++ ) { /* * if there is a character under us, * mark the window it belongs to as being overlapped, * and mark us as overlapping it */ if( *img != NO_CHAR ) { wo = AccessWindow( *img ); k = (i - wo->x1) + (j - wo->y1) * wo->width; wo->overlap[k] = (char) wn; wo->overcnt[j - wo->y1]++; ReleaseWindow( wo ); } *whoover = *img; *img = (char) wn; img++; whoover++; } } ReleaseWindow( w ); } /* MarkOverlap */
COSXScreen::~COSXScreen() { disable(); m_events->adoptBuffer(NULL); m_events->removeHandler(CEvent::kSystem, m_events->getSystemTarget()); if (m_pmWatchThread) { // make sure the thread has setup the runloop. { CLock lock(m_pmMutex); while (!(bool)*m_pmThreadReady) { m_pmThreadReady->wait(); } } // now exit the thread's runloop and wait for it to exit LOG((CLOG_DEBUG "stopping watchSystemPowerThread")); CFRunLoopStop(m_pmRunloop); m_pmWatchThread->wait(); delete m_pmWatchThread; m_pmWatchThread = NULL; } delete m_pmThreadReady; delete m_pmMutex; m_events->removeHandler(m_events->forCOSXScreen().confirmSleep(), getEventTarget()); RemoveEventHandler(m_switchEventHandlerRef); #if defined(MAC_OS_X_VERSION_10_5) CGDisplayRemoveReconfigurationCallback(displayReconfigurationCallback, this); #else DMRemoveExtendedNotifyProc(m_displayManagerNotificationUPP, NULL, &m_PSN, 0); if (m_hiddenWindow) { ReleaseWindow(m_hiddenWindow); m_hiddenWindow = NULL; } if (m_userInputWindow) { ReleaseWindow(m_userInputWindow); m_userInputWindow = NULL; } #endif delete m_keyState; delete m_screensaver; }
void _glfwPlatformCloseWindow( void ) { if( _glfwWin.WindowFunctions != NULL ) { if( _glfwWin.WindowUPP != NULL ) { DisposeEventHandlerUPP( _glfwWin.WindowUPP ); _glfwWin.WindowUPP = NULL; } _glfwWin.WindowFunctions->CloseWindow(); if( _glfwWin.AGLContext != NULL ) { aglSetCurrentContext( NULL ); aglSetDrawable( _glfwWin.AGLContext, NULL ); aglDestroyContext( _glfwWin.AGLContext ); _glfwWin.AGLContext = NULL; } if( _glfwWin.MacWindow != NULL ) { ReleaseWindow( _glfwWin.MacWindow ); _glfwWin.MacWindow = NULL; } _glfwWin.WindowFunctions = NULL; } }
void CL_DisplayWindow_OpenGL::destroy_window() { install_event_handler(0, 1); if (context) aglSetCurrentContext(0); if (fs_context) { aglDestroyContext(fs_context); fs_context = 0; } if (win_context) { aglDestroyContext(win_context); win_context = 0; } keyboard = CL_InputDevice(); mouse = CL_InputDevice(); get_ic()->clear(); if (window_ref) ReleaseWindow(window_ref); window_ref = 0; }
void compzillaWindow::Resized (PRInt32 x, PRInt32 y, PRInt32 width, PRInt32 height, PRInt32 border) { if (width != mAttr.width || height != mAttr.height || border != mAttr.border_width || mAttr.override_redirect) { if (mIsRedirected) { ReleaseWindow (); mPixmap = XCompositeNameWindowPixmap (mDisplay, mWindow); if (mPixmap == None) return; for (PRUint32 i = mContentNodes.Count() - 1; i != PRUint32(-1); --i) { nsIDOMHTMLCanvasElement *aContent = mContentNodes.ObjectAt (i); aContent->SetWidth (width); aContent->SetHeight (height); } Damaged (NULL); } } mAttr.x = x; mAttr.y = y; mAttr.width = width; mAttr.height = height; mAttr.border_width = border; }
/* * ShiftWindowUpDown - shift the stuff in a window in an up/down direction */ void ShiftWindowUpDown( window_id id, int diff ) { wind *w; int start, spl, i, j; int sline, eline, add; char_info _FAR *scr_d; char_info *txt_s, *txt_d; if( EditFlags.DisplayHold || EditFlags.Quiet ) { return; } w = AccessWindow( id ); if( w->has_border ) { start = 1; spl = 0; } else { start = 0; spl = -1; } if( diff < 0 ) { sline = w->text_lines + diff; eline = 1; add = -1; } else { sline = diff + 1; eline = w->text_lines; add = 1; } /* * current window is never overlapped, so we can just blast away */ sline += spl; eline += spl; i = sline; while( 1 ) { txt_s = (char_info *) &w->text[(i * w->width + start) * sizeof( char_info )]; txt_d = (char_info *) &w->text[((i - diff) * w->width + start) * sizeof( char_info )]; scr_d = (char_info _FAR *) &Scrn[(w->x1 + start + (w->y1 + i - diff) * WindMaxWidth) * sizeof( char_info )]; for( j = 0; j < w->text_cols; j++ ) { WRITE_SCREEN( scr_d[j], txt_s[j] ); WRITE_SCREEN_DATA( txt_d[j], txt_s[j] ); } #ifdef __VIO__ MyVioShowBuf( (unsigned)((char *) scr_d - Scrn), w->text_cols ); #endif if( i == eline ) { break; } i += add; } ReleaseWindow( w ); } /* ShiftWindowUpDown */
void compzillaWindow::UnredirectWindow () { if (!mIsRedirected) return; ReleaseWindow (); XCompositeUnredirectWindow (mDisplay, mWindow, CompositeRedirectManual); mIsRedirected = false; }
/* * ResizeWindow - give a window a new size */ vi_rc ResizeWindow( window_id wid, windim x1, windim y1, windim x2, windim y2, bool scrflag ) { window *oldw; // int bt, k; // char *txt, *tptr; // char *ot; // int i, j; oldw = WINDOW_FROM_ID( wid ); AccessWindow( oldw ); if( !ValidDimension( x1, y1, x2, y2, oldw->has_border ) ) { ReleaseWindow( oldw ); return( ERR_WIND_INVALID ); } RestoreOverlap( wid, scrflag ); AllocWindow( wid, x1, y1, x2, y2, oldw->has_border, oldw->has_gadgets, true, oldw->border_color1, oldw->border_color2, oldw->text_color, oldw->background_color ); MarkOverlap( wid ); /* * display the new text */ ClearWindow( wid ); if( oldw->title != NULL ) { WindowTitle( wid, oldw->title ); } else { DrawBorder( wid ); } DCResize( CurrentInfo ); DCDisplayAllLines(); DCUpdate(); FreeWindow( oldw ); ReleaseWindow( WINDOW_FROM_ID( wid ) ); return( ERR_NO_ERR ); } /* ResizeWindow */
void OpenGLApp::exitAPI(){ delete renderer; aglSetCurrentContext(NULL); aglSetDrawable(glContext, NULL); aglDestroyContext(glContext); ReleaseWindow(window); if (fullscreen){ CGReleaseAllDisplays(); CGDisplaySwitchToMode(kCGDirectMainDisplay, initialMode); } }
// -------------------------------------------------------------------------------------- static pascal OSStatus listBoxControlEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *prefsDialog) { OSStatus result = eventNotHandledErr; UInt32 eventClass, eventKind; DialogRef dialog; WindowRef dialogWindow; eventClass = GetEventClass(event); eventKind = GetEventKind(event); switch (eventClass) { case kEventClassTextInput: switch (eventKind) { case kEventTextInputUnicodeForKeyEvent: /* The strategy here is to first let the default handler handle the event (i.e. change the selected cell in the category list box control), then react to that change by showing the correct category panel. However the key pressed could potentially cause the default or cancel button to get hit. In this case, our window handler will be called which will dispose of the dialog. If this is the case, we need to not postprocess the event. We will test for this by getting the dialog's window, retaining it, calling the default handler, then getting the window's retain count. If the retain count is back to 1, then we know the dialog is already disposed. */ dialog = (DialogRef)prefsDialog; dialogWindow = GetDialogWindow(dialog); RetainWindow(dialogWindow); // hold onto the dialog's window result = CallNextEventHandler(nextHandler, event); if (result == noErr) // we don't need to postprocess if nothing happened { ItemCount retainCount; retainCount = GetWindowRetainCount(dialogWindow); if (retainCount > 1) // if we're the last one holding the window handleDialogItemHit(dialog, iIconList); // then there's no } // need to postprocess anything because it's about to go away ReleaseWindow(dialogWindow); break; } break; } return result; }
void compzillaWindow::Unmapped () { if (mAttr.map_state != IsViewable) return; mAttr.map_state = IsUnmapped; ReleaseWindow (); for (PRUint32 i = mObservers.Count() - 1; i != PRUint32(-1); --i) { nsCOMPtr<compzillaIWindowObserver> observer = mObservers.ObjectAt(i); observer->Unmap (); } }
void Shell::CloseWindow() { // Shutdown OpenGL if necessary. if (opengl_attached) { aglSetCurrentContext(NULL); aglSetDrawable(gl_context, NULL); aglDestroyContext(gl_context); gl_context = NULL; } // Close the window. HideWindow(window); ReleaseWindow(window); }
/* * ClearWindow - do just that */ void ClearWindow( window_id wn ) { wind *w; window_id *over; char_info *txt; char_info _FAR *scr; unsigned oscr; int j, i, shift, addr; char_info what = {0, 0}; if( EditFlags.Quiet ) { return; } w = AccessWindow( wn ); /* * clear text area */ what.cinfo_char = ' '; what.cinfo_attr = MAKE_ATTR( w, w->text_color, w->background_color ); shift = 0; addr = 0; if( w->has_border ) { shift = 1; addr = w->width + shift; } for( j = w->y1 + shift; j <= w->y2 - shift; j++ ) { oscr = w->x1 + shift + j * EditVars.WindMaxWidth; scr = &Scrn[oscr]; txt = &(w->text[addr]); over = &(w->overlap[addr]); for( i = w->x1 + shift; i <= w->x2 - shift; i++ ) { WRITE_SCREEN_DATA( *txt++, what ); if( *over++ == NO_WINDOW ) { WRITE_SCREEN( *scr, what ); } scr++; } #ifdef __VIO__ MyVioShowBuf( oscr, w->width - 2 * shift ); // inside of window only #endif addr += w->width; } ReleaseWindow( w ); } /* ClearWindow */
/* * ResetOverlap - set so no overlap of window */ void ResetOverlap( wind *w ) { char *over, *whoover; int i, j; AccessWindow( w->id ); over = w->overlap; whoover = w->whooverlapping; for( j = w->y1; j <= w->y2; j++ ) { for( i = w->x1; i <= w->x2; i++ ) { *over++ = NO_CHAR; *whoover++ = NO_CHAR; } } for( i = 0; i < w->height; i++ ) { w->overcnt[i] = 0; } ReleaseWindow( w ); } /* ResetOverlap */
/* * reDisplayWindow - redisplay the saved window text */ static void reDisplayWindow( window_id wn ) { wind *w; char_info *txt; window_id *over; char_info _FAR *scr; unsigned oscr; int j, i; if( EditFlags.Quiet ) { return; } w = AccessWindow( wn ); /* * re-display text area */ txt = w->text; over = w->overlap; for( j = w->y1; j <= w->y2; j++ ) { oscr = w->x1 + j * EditVars.WindMaxWidth; scr = &Scrn[oscr]; for( i = w->x1; i <= w->x2; i++ ) { if( *over++ == NO_WINDOW ) { WRITE_SCREEN( *scr, *txt ); } scr++; txt++; } #ifdef __VIO__ MyVioShowBuf( oscr, w->width ); #endif } DrawBorder( wn ); ReleaseWindow( w ); } /* reDisplayWindow */
//This boolean returns the hwnd when the window is released. bool WindowManager::ReleaseWindow(HWND hwnd) { return ReleaseWindow(GetWindowByHandle(hwnd)); }
OSStatus _Growl_ShowUpdatePromptForVersion(CFStringRef updateVersion) { OSStatus err = noErr; if (_checkOSXVersion()) { CFBundleRef bundle = CFBundleGetBundleWithIdentifier(GROWL_WITHINSTALLER_FRAMEWORK_IDENTIFIER); if (!bundle) NSLog(CFSTR("GrowlInstallationPrompt: could not locate framework bundle (forget about installing Growl); had looked for bundle with identifier '%@'"), GROWL_WITHINSTALLER_FRAMEWORK_IDENTIFIER); else { IBNibRef nib = NULL; err = CreateNibReferenceWithCFBundle(bundle, CFSTR("GrowlInstallationPrompt-Carbon"), &nib); if (err != noErr) { NSLog(CFSTR("GrowlInstallationPrompt: could not obtain nib: CreateNibReferenceWithCFBundle(%@, %@) returned %li"), bundle, CFSTR("GrowlInstallationPrompt-Carbon"), (long)err); } else { WindowRef window = NULL; err = CreateWindowFromNib(nib, CFSTR("Installation prompt"), &window); DisposeNibReference(nib); if (err != noErr) { NSLog(CFSTR("GrowlInstallationPrompt: could not obtain window from nib: CreateWindowFromNib(%p, %@) returned %li"), nib, CFSTR("Installation prompt"), (long)err); } else { OSStatus fillOutTextErr = _fillOutTextInWindow(window, (updateVersion != nil)); OSStatus fillOutIconErr = _fillOutIconInWindow(window); err = (fillOutTextErr != noErr) ? fillOutTextErr : (fillOutIconErr != noErr) ? fillOutIconErr : noErr; if (err == noErr) { if (updateVersion) { //store the update version on the window. updateVersion = CFRetain(updateVersion); err = SetWindowProperty(window, GROWL_SIGNATURE, GIPC_UPDATE_VERSION, sizeof(updateVersion), &updateVersion); if (err != noErr) NSLog(CFSTR("GrowlInstallationPrompt: SetWindowProperty returned %li"), (long)err); } EventHandlerUPP handlerUPP = NewEventHandlerUPP(_handleCommandInWindow); struct EventTypeSpec types[] = { { .eventClass = kEventClassCommand, .eventKind = kEventCommandProcess }, }; EventHandlerRef handler = NULL; err = InstallWindowEventHandler(window, handlerUPP, GetEventTypeCount(types), types, /*refcon*/ window, &handler); if (err != noErr) NSLog(CFSTR("GrowlInstallationPrompt: InstallWindowEventHandler returned %li"), (long)err); else { HIViewID chasingArrowsID = { GROWL_SIGNATURE, chasingArrowsIDNumber }; HIViewRef chasingArrows = NULL; //stop and hide the chasing arrows, until the user clicks Install. OSStatus chasingArrowsErr = HIViewFindByID(HIViewGetRoot(window), chasingArrowsID, &chasingArrows); if (chasingArrowsErr == noErr) { Boolean truth = false; SetControlData(chasingArrows, kControlEntireControl, kControlChasingArrowsAnimatingTag, sizeof(truth), &truth); HIViewSetVisible(chasingArrows, false); } SelectWindow(window); ShowWindow(window); err = RunAppModalLoopForWindow(window); if (err != noErr) NSLog(CFSTR("GrowlInstallationPrompt: RunAppModalLoopForWindow(%p) returned %li"), window, (long)err); RemoveEventHandler(handler); } DisposeEventHandlerUPP(handlerUPP); } ReleaseWindow(window); } } } }
void MusicBoxDialog(void) { OSStatus err; IBNibRef nibRef; if (!cartOpen) return; err = CreateNibReference(kMacS9XCFString, &nibRef); if (err == noErr) { CFURLRef iconURL; FSRef iconFSRef; IconRef actIcon; WindowRef tWindowRef; actIcon = nil; if (musicboxmode == kMBXSoundEmulation) iconURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("musicbox_ledoff"), CFSTR("icns"), nil); else iconURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("musicbox_ledon" ), CFSTR("icns"), nil); if (iconURL) { if (CFURLGetFSRef(iconURL, &iconFSRef)) err = RegisterIconRefFromFSRef('~9X~', 'micn', &iconFSRef, &actIcon); CFRelease(iconURL); } err = CreateWindowFromNib(nibRef, CFSTR("MusicBox"), &tWindowRef); if (err == noErr) { EventHandlerRef mboxRef, paneRef; EventHandlerUPP mboxUPP, paneUPP; EventLoopTimerRef timeRef; EventLoopTimerUPP timeUPP; EventTypeSpec mboxEvents[] = { { kEventClassCommand, kEventCommandProcess }, { kEventClassCommand, kEventCommandUpdateStatus } }, paneEvents[] = { { kEventClassControl, kEventControlDraw } }; CFStringRef sref; CGDataProviderRef prov; CGImageRef ipng; CFURLRef iurl; HIViewRef ctl, root, paneView, imageView, contentView; HIViewID cid; HIRect bounds; Rect windowRect, barRect; char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; mboxPause = false; mbxFinished = false; showIndicator = false; so.stereo_switch = ~0; for (int i = 0; i < MAC_MAX_PLAYERS; i++) controlPad[i] = 0; switch (drawingMethod) { case kDrawingOpenGL: Settings.OpenGLEnable = true; break; case kDrawingDirect: case kDrawingBlitGL: Settings.OpenGLEnable = false; } // 107's enhanced SPC player root = HIViewGetRoot(tWindowRef); cid.id = 0; if (musicboxmode == kMBXSoundEmulation) { cid.signature = 'HEAD'; HIViewFindByID(root, cid, &ctl); EnableControl(ctl); StoredAPU = new SAPU; StoredAPURegisters = new SAPURegisters; StoredSoundData = new SSoundData; StoredIAPURAM = new uint8 [0x10000]; SPCPlayFreeze(); } else MusicBoxForceFreeze(); cid.signature = 'Kart'; HIViewFindByID(root, cid, &ctl); SetStaticTextTrunc(ctl, truncEnd, false); _splitpath(Memory.ROMFilename, drive, dir, fname, ext); sref = CFStringCreateWithCString(kCFAllocatorDefault, fname, MAC_PATH_ENCODING); if (sref) { SetStaticTextCFString(ctl, sref, false); CFRelease(sref); } ipng = nil; iurl = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("musicbox_indicator"), CFSTR("png"), nil); if (iurl) { prov = CGDataProviderCreateWithURL(iurl); if (prov) { ipng = CGImageCreateWithPNGDataProvider(prov, nil, false, kCGRenderingIntentDefault); CGDataProviderRelease(prov); } CFRelease(iurl); } imageView = nil; if (ipng) { HIViewFindByID(root, kHIViewWindowContentID, &contentView); err = HIImageViewCreate(ipng, &imageView); if (err == noErr) { bounds = CGRectMake(30, 64, CGImageGetWidth(ipng), CGImageGetHeight(ipng)); HIViewSetFrame(imageView, &bounds); HIImageViewSetOpaque(imageView, false); HIViewSetVisible(imageView, true); HIViewAddSubview(contentView, imageView); cid.signature = 'iMaG'; SetControlID(imageView, &cid); } CGImageRelease(ipng); } cid.signature = 'Pane'; HIViewFindByID(root, cid, &paneView); HIViewGetBounds(paneView, &bounds); mbxViewWidth = bounds.size.width; mbxViewHeight = bounds.size.height; mbxMarginY = (mbxViewHeight - mbxBarHeight) / 2.0; mbxMarginX = (mbxViewWidth - ((mbxBarWidth * 8.0 + mbxBarSpace * 7.0) * 2.0 + mbxLRSpace)) / 2.0; if (imageView) { HIViewSetZOrder(imageView, kHIViewZOrderBelow, paneView); HIViewAddSubview(imageView, paneView); } cid.signature = 'Tr_i'; HIViewFindByID(root, cid, &ctl); HIViewGetFrame(ctl, &bounds); GetWindowBounds(tWindowRef, kWindowTitleBarRgn, &barRect); mbxClosedHeight = (short) (bounds.origin.y + bounds.size.height + 7.0) + (barRect.bottom - barRect.top); GetWindowBounds(tWindowRef, kWindowStructureRgn, &windowRect); mbxOpenedHeight = windowRect.bottom - windowRect.top; windowRect.bottom = windowRect.top + mbxClosedHeight; SetWindowBounds(tWindowRef, kWindowStructureRgn, &windowRect); paneUPP = NewEventHandlerUPP(IndicatorEventHandler); err = InstallControlEventHandler(paneView, paneUPP, GetEventTypeCount(paneEvents), paneEvents, (void *) paneView, &paneRef); mboxUPP = NewEventHandlerUPP(MusicBoxEventHandler); err = InstallWindowEventHandler(tWindowRef, mboxUPP, GetEventTypeCount(mboxEvents), mboxEvents, (void *) tWindowRef, &mboxRef); timeUPP = NewEventLoopTimerUPP(MusicBoxTimerHandler); err = InstallEventLoopTimer(GetCurrentEventLoop(), kEventDurationNoWait, kEventDurationSecond * 2.0 / (double) Memory.ROMFramesPerSecond, timeUPP, (void *) paneView, &timeRef); MusicBoxInitIndicator(); stopNow = false; MacStartSound(); pthread_create(&mbxThread, nil, SoundTask, nil); MoveWindowPosition(tWindowRef, kWindowMusicBox, true); GetWindowBounds(tWindowRef, kWindowStructureRgn, &windowRect); if (windowRect.bottom - windowRect.top > mbxClosedHeight) { showIndicator = true; SetControl32BitValue(ctl, 1); // Tr_i } ShowWindow(tWindowRef); err = RunAppModalLoopForWindow(tWindowRef); HideWindow(tWindowRef); SaveWindowPosition(tWindowRef, kWindowMusicBox); stopNow = true; pthread_join(mbxThread, nil); MacStopSound(); err = RemoveEventLoopTimer(timeRef); DisposeEventLoopTimerUPP(timeUPP); err = RemoveEventHandler(mboxRef); DisposeEventHandlerUPP(mboxUPP); err = RemoveEventHandler(paneRef); DisposeEventHandlerUPP(paneUPP); ReleaseWindow(tWindowRef); so.stereo_switch = ~0; mbxFinished = true; if (musicboxmode == kMBXSoundEmulation) { SPCPlayDefrost(); delete StoredAPU; delete StoredAPURegisters; delete StoredSoundData; delete [] StoredIAPURAM; } else MusicBoxForceDefrost(); Settings.OpenGLEnable = false; } if (actIcon) err = UnregisterIconRef('~9X~', 'micn'); DisposeNibReference(nibRef); } }
bool OpenGLApp::initAPI(){ initialMode = CGDisplayCurrentMode(kCGDirectMainDisplay); dmodes = CGDisplayAvailableModes(kCGDirectMainDisplay); int count = CFArrayGetCount(dmodes); Array <DispRes> modes; int foundMode = -1; for (int i = 0; i < count; i++){ CFDictionaryRef mode = (CFDictionaryRef) CFArrayGetValueAtIndex(dmodes, i); long bitsPerPixel = GetDictionaryLong(mode, kCGDisplayBitsPerPixel); Boolean safeForHardware = GetDictionaryBoolean(mode, kCGDisplayModeIsSafeForHardware); Boolean stretched = GetDictionaryBoolean(mode, kCGDisplayModeIsStretched); if (bitsPerPixel < colorBits || !safeForHardware || stretched) continue; long width = GetDictionaryLong(mode, kCGDisplayWidth); long height = GetDictionaryLong(mode, kCGDisplayHeight); long refreshRate = GetDictionaryLong(mode, kCGDisplayRefreshRate); // printf("Mode: %dx%dx%d @ %d\n", width, height, bitsPerPixel, refreshRate); if (width >= 640 && height >= 480){ modes.add(newRes(width, height, i)); if (width == fullscreenWidth && height == fullscreenHeight){ foundMode = i; } } } resolution->clear(); modes.sort(dComp); char str[64]; for (uint i = 0; i < modes.getCount(); i++){ sprintf(str, "%dx%d", modes[i].w, modes[i].h); int index = resolution->addItemUnique(str); if (modes[i].index == foundMode) resolution->selectItem(index); } if (fullscreen){ if (foundMode < 0 || CGDisplaySwitchToMode(kCGDirectMainDisplay, (CFDictionaryRef) CFArrayGetValueAtIndex(dmodes, foundMode)) != kCGErrorSuccess){ sprintf(str, "Couldn't set fullscreen to %dx%d.", fullscreenWidth, fullscreenHeight); ErrorMsg(str); fullscreen = false; } } Rect rect; if (fullscreen){ rect.left = 0; rect.top = 0; } else { long w = GetDictionaryLong(initialMode, kCGDisplayWidth); long h = GetDictionaryLong(initialMode, kCGDisplayHeight); rect.left = (w - width) / 2; rect.top = (h - height) / 2; } rect.right = rect.left + width; rect.bottom = rect.top + height; WindowAttributes attributes = fullscreen? (kWindowNoTitleBarAttribute | kWindowNoShadowAttribute) : (kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute); OSStatus error = CreateNewWindow(kDocumentWindowClass, attributes, &rect, &window); if (error != noErr || window == NULL){ ErrorMsg("Couldn't create window"); return false; } GDHandle screen = GetGWorldDevice(GetWindowPort(window)); if (screen == NULL){ ErrorMsg("Couldn't get device"); ReleaseWindow(window); return false; } AGLPixelFormat pixelFormat; while (true){ GLint attributes[] = { fullscreen? AGL_FULLSCREEN : AGL_WINDOW, AGL_RGBA, AGL_DOUBLEBUFFER, AGL_RED_SIZE, 8, AGL_GREEN_SIZE, 8, AGL_BLUE_SIZE, 8, AGL_ALPHA_SIZE, (colorBits > 24)? 8 : 0, AGL_DEPTH_SIZE, depthBits, AGL_STENCIL_SIZE, stencilBits, AGL_SAMPLE_BUFFERS_ARB, (antiAliasSamples > 0), AGL_SAMPLES_ARB, antiAliasSamples, AGL_NONE }; pixelFormat = aglChoosePixelFormat(&screen, 1, attributes); if (pixelFormat != NULL) break; antiAliasSamples -= 2; if (antiAliasSamples < 0){ ErrorMsg("No suitable pixel format"); ReleaseWindow(window); return false; } } glContext = aglCreateContext(pixelFormat, NULL); aglDestroyPixelFormat(pixelFormat); if (glContext == NULL){ ErrorMsg("Couldn't create context"); ReleaseWindow(window); return false; } if (fullscreen){ CGCaptureAllDisplays(); aglSetFullScreen(glContext, 0, 0, 0, 0); } else { if (!aglSetDrawable(glContext, GetWindowPort(window))){ ErrorMsg("Couldn't set drawable"); aglDestroyContext(glContext); ReleaseWindow(window); return false; } } if (!aglSetCurrentContext(glContext)){ ErrorMsg("Couldn't make context current"); aglDestroyContext(glContext); ReleaseWindow(window); return false; } setWindowTitle(getTitle()); ShowWindow(window); initExtensions(); if (antiAliasSamples > 0){ glEnable(GL_MULTISAMPLE_ARB); } if (fullscreen) captureMouse(!configDialog->isVisible()); renderer = new OpenGLRenderer(glContext); renderer->setViewport(width, height); antiAlias->selectItem(antiAliasSamples / 2); linearClamp = renderer->addSamplerState(LINEAR, CLAMP, CLAMP, CLAMP); defaultFont = renderer->addFont("../Textures/Fonts/Future.dds", "../Textures/Fonts/Future.font", linearClamp); blendSrcAlpha = renderer->addBlendState(SRC_ALPHA, ONE_MINUS_SRC_ALPHA); noDepthTest = renderer->addDepthState(false, false); noDepthWrite = renderer->addDepthState(true, false); cullNone = renderer->addRasterizerState(CULL_NONE); cullBack = renderer->addRasterizerState(CULL_BACK); cullFront = renderer->addRasterizerState(CULL_FRONT); return true; }
/* * RestoreOverlap - restore overlap information from a window that is * "going away" - either relocating or dying */ void RestoreOverlap( window_id wn, bool scrflag ) { wind *w, *wo, *o; int i, j, k, l; char *whoover, *over, *img; char_info _FAR *scr; #ifdef __VIO__ unsigned oscr; #endif if( EditFlags.Quiet ) { scrflag = FALSE; } w = AccessWindow( wn ); whoover = w->whooverlapping; over = w->overlap; for( j = w->y1; j <= w->y2; j++ ) { if( scrflag ) { scr = (char_info _FAR *) &Scrn[(w->x1 + j * WindMaxWidth) * sizeof( char_info )]; #ifdef __VIO__ oscr = (unsigned) ((char *)scr - Scrn); #endif } img = &ScreenImage[w->x1 + j * WindMaxWidth]; for( i = w->x1; i <= w->x2; i++ ) { /* * if we are over someone, then reset the screen * with the proper information * * if we are not over someone, check for over us */ if( *whoover != NO_CHAR ) { wo = AccessWindow( *whoover ); k = (i - wo->x1) + (j - wo->y1) * wo->width; /* * if we are being overlapped at the same * spot, then point the guy overlapping us * at the guy we are overlapping * * otherwise, mark the guy we are overlapping * as not being overlapped, and restore his * text to the screen */ if( *over != NO_CHAR ) { o = AccessWindow( *over ); l = (i - o->x1) + (j - o->y1) * o->width; o->whooverlapping[l] = *whoover; wo->overlap[k] = *over; ReleaseWindow( o ); } else { wo->overlap[k] = NO_CHAR; wo->overcnt[j - wo->y1]--; if( scrflag ) { WRITE_SCREEN( *scr, ((char_info *)wo->text)[k] ); } *img = *whoover; } ReleaseWindow( wo ); } else { /* * we are not overlapping anyone, so * see if anyone is overlapping us; * if so, reset them to be not overlapping * anyone * * if not, clear the screen */ if( *over != NO_CHAR ) { o = AccessWindow( *over ); l = (i - o->x1) + (j - o->y1) * o->width; o->whooverlapping[l] = NO_CHAR; ReleaseWindow( o ); } else { if( scrflag ) { WRITE_SCREEN( *scr, WindowNormalAttribute ); } *img = NO_CHAR; } } img++; over++; whoover++; if( scrflag ) { scr++; } } #ifdef __VIO__ if( scrflag ) { MyVioShowBuf( oscr, w->width ); } #endif } ReleaseWindow( w ); } /* RestoreOverlap */
nsresult Downscaler::BeginFrame(const nsIntSize& aOriginalSize, uint8_t* aOutputBuffer, bool aHasAlpha) { MOZ_ASSERT(aOutputBuffer); MOZ_ASSERT(mTargetSize != aOriginalSize, "Created a downscaler, but not downscaling?"); MOZ_ASSERT(mTargetSize.width <= aOriginalSize.width, "Created a downscaler, but width is larger"); MOZ_ASSERT(mTargetSize.height <= aOriginalSize.height, "Created a downscaler, but height is larger"); MOZ_ASSERT(aOriginalSize.width > 0 && aOriginalSize.height > 0, "Invalid original size"); mOriginalSize = aOriginalSize; mOutputBuffer = aOutputBuffer; mHasAlpha = aHasAlpha; ResetForNextProgressivePass(); ReleaseWindow(); auto resizeMethod = skia::ImageOperations::RESIZE_LANCZOS3; skia::resize::ComputeFilters(resizeMethod, mOriginalSize.width, mTargetSize.width, 0, mTargetSize.width, mXFilter.get()); skia::resize::ComputeFilters(resizeMethod, mOriginalSize.height, mTargetSize.height, 0, mTargetSize.height, mYFilter.get()); // Allocate the buffer, which contains scanlines of the original image. mRowBuffer = MakeUnique<uint8_t[]>(mOriginalSize.width * sizeof(uint32_t)); if (MOZ_UNLIKELY(!mRowBuffer)) { return NS_ERROR_OUT_OF_MEMORY; } // Allocate the window, which contains horizontally downscaled scanlines. (We // can store scanlines which are already downscale because our downscaling // filter is separable.) mWindowCapacity = mYFilter->max_filter(); mWindow = MakeUnique<uint8_t*[]>(mWindowCapacity); if (MOZ_UNLIKELY(!mWindow)) { return NS_ERROR_OUT_OF_MEMORY; } bool anyAllocationFailed = false; const int rowSize = mTargetSize.width * sizeof(uint32_t); for (int32_t i = 0; i < mWindowCapacity; ++i) { mWindow[i] = new uint8_t[rowSize]; anyAllocationFailed = anyAllocationFailed || mWindow[i] == nullptr; } if (MOZ_UNLIKELY(anyAllocationFailed)) { // We intentionally iterate through the entire array even if an allocation // fails, to ensure that all the pointers in it are either valid or nullptr. // That in turn ensures that ReleaseWindow() can clean up correctly. return NS_ERROR_OUT_OF_MEMORY; } return NS_OK; }
/* * ResizeWindow - give a window a new size */ vi_rc ResizeWindow( window_id wn, int x1, int y1, int x2, int y2, int scrflag ) { wind *tmp, *w; int bt, k; // char *txt, *tptr; // char *ot; // int i, j; w = AccessWindow( wn ); if( !ValidDimension( x1, y1, x2, y2, w->has_border ) ) { ReleaseWindow( w ); return( ERR_WIND_INVALID ); } tmp = AllocWindow( x1, y1, x2, y2, w->has_border, w->border_color1, w->border_color2, w->text_color, w->background_color ); tmp->id = wn; tmp->has_gadgets = w->has_gadgets; // txt = MemAlloc( w->width + 1 ); // tptr = txt; RestoreOverlap( wn, scrflag ); Windows[wn] = tmp; tmp->accessed = TRUE; ResetOverlap( tmp ); MarkOverlap( wn ); /* * display the new text */ k = 1; bt = (int) w->has_border; ClearWindow( wn ); if( w->title != NULL ) { WindowTitle( wn, w->title ); } else { DrawBorder( wn ); } #if 0 for( j = bt; j < w->height - bt; j++ ) { ot = &(w->text[(j * w->width) * sizeof( char_info )]); for( i = bt; i < w->width - bt; i++ ) { *txt++ = ot[i * sizeof( char_info )]; } *txt = 0; DisplayLineInWindow( wn, k++, tptr ); txt = tptr; } #else DCResize( CurrentInfo ); DCDisplayAllLines(); DCUpdate(); #endif FreeWindow( w ); ReleaseWindow( tmp ); return( ERR_NO_ERR ); } /* ResizeWindow */
Downscaler::~Downscaler() { ReleaseWindow(); }
/* * DisplayCrossLineInWindow - do just that, using given colors */ void DisplayCrossLineInWindow( window_id wn, int line ) { wind *w; char *over; char_info *txt; char_info _FAR *scr; #ifdef __VIO__ unsigned oscr; #endif int addr, i; char_info what; if( EditFlags.Quiet ) { return; } w = Windows[wn]; /* * find dimensions of line */ if( !w->has_border ) { return; } if( line < 1 || line > w->height - 2 ) { return; } line--; /* * initialize */ w = AccessWindow( wn ); addr = 1 + (1 + line) * w->width; txt = (char_info *) &(w->text[sizeof( char_info ) * addr]); scr = (char_info _FAR *) &Scrn[(w->x1 + (1 + line + w->y1) * WindMaxWidth) * sizeof( char_info )]; #ifdef __VIO__ oscr = (unsigned) ((char _FAR *) (scr) - Scrn); #endif what.attr = MAKE_ATTR( w, w->border_color1, w->border_color2 ); what.ch = WindowBordersNG[WB_LEFTT]; over = &(w->overlap[addr]); if( *over++ == NO_CHAR ) { WRITE_SCREEN( *scr, what ); } WRITE_SCREEN_DATA( *txt, what ); txt++; scr++; what.ch = WindowBordersNG[WB_TOPBOTTOM]; for( i = w->x1 + 1; i < w->x2; i++ ) { if( *over++ == NO_CHAR ) { WRITE_SCREEN( *scr, what ); } WRITE_SCREEN_DATA( *txt, what ); txt++; scr++; } if( line != w->height - 3 && line != 0 ) { what.ch = WindowBordersNG[WB_RIGHTT]; WRITE_SCREEN_DATA( *txt, what ); if( *over == NO_CHAR ) { WRITE_SCREEN( *scr, what ); } scr++; txt++; } #ifdef __VIO__ MyVioShowBuf( oscr, w->width ); #endif ReleaseWindow( w ); } /* DisplayCrossLineInWindow */
/* * changeColorOfDisplayLine - do just that, using given colors and column range */ static void changeColorOfDisplayLine( int line, int scol, int ecol, type_style *s ) { wind *w; char *over; char_info _FAR *scr; char_info what; #ifdef __VIO__ unsigned oscr; unsigned onscr; #endif int attr, t, end, spend, cnt1, cnt2, sscol, spl; if( EditFlags.Quiet ) { return; } w = AccessWindow( CurrentWindow ); /* * find dimensions of line */ if( w->has_border ) { if( line < 1 || line > w->height - 2 ) { ReleaseWindow( w ); return; } spl = line; sscol = 1 + scol; spend = end = ecol + 2; if( spend > w->width - 1 ) { spend = end = w->width - 1; } if( sscol < 1 ) { sscol = 1; } } else { if( line < 1 || line > w->height ) { ReleaseWindow( w ); return; } spl = line - 1; sscol = scol; spend = end = ecol + 1; if( spend > w->width ) { spend = end = w->width; } if( sscol < 0 ) { sscol = 0; } } cnt1 = end - sscol; cnt2 = spend - end; line--; /* * initialize */ t = sscol + spl * w->width; scr = (char_info _FAR *) &Scrn[(w->x1 + sscol + (spl + w->y1) * WindMaxWidth) * sizeof( char_info )]; #ifdef __VIO__ oscr = (unsigned) ((char _FAR *) scr - Scrn); onscr = 0; #endif attr = MAKE_ATTR( w, s->foreground, s->background ); what.attr = attr; /* * display line */ if( w->overcnt[spl] ) { over = w->overlap + t; while( cnt1-- != 0 ) { if( *over++ == NO_CHAR ) { what.ch = (*scr).ch; WRITE_SCREEN( *scr, what ); #ifdef __VIO__ onscr++; #endif } scr++; } while( cnt2-- != 0 ) { if( *over++ == NO_CHAR ) { what.ch = (*scr).ch; WRITE_SCREEN( *scr, what ); #ifdef __VIO__ onscr++; #endif } scr++; } } else { while( cnt1-- != 0 ) { what.ch = (*scr).ch; WRITE_SCREEN( *scr, what ); #ifdef __VIO__ onscr++; #endif scr++; } while( cnt2-- != 0 ) { what.ch = (*scr).ch; WRITE_SCREEN( *scr, what ); #ifdef __VIO__ onscr++; #endif scr++; } } #ifdef __VIO__ MyVioShowBuf( oscr, onscr ); #endif ReleaseWindow( w ); } /* changeColorOfDisplayLine */
/* * SetCharInWindowWithColor - do just that, using given colors */ vi_rc SetCharInWindowWithColor( window_id wn, int line, int col, char text, type_style *style ) { wind *w; char *over; int attr, addr, start, spl; char_info tmp; char_info *txt; char_info _FAR *scr; bool has_mouse; if( EditFlags.Quiet ) { return( ERR_NO_ERR ); } w = Windows[wn]; /* * find dimensions of line */ if( w->has_border ) { if( line < 1 || line > w->height - 2 ) { return( ERR_WIND_NO_SUCH_LINE ); } start = 1; spl = line; } else { if( line < 1 || line > w->height ) { return( ERR_WIND_NO_SUCH_LINE ); } start = 0; spl = line - 1; } if( col < 1 || col > w->width ) { return( ERR_WIND_NO_SUCH_COLUMN ); } line--; col--; /* * initialize */ w = AccessWindow( wn ); addr = col + start + spl * w->width; txt = (char_info *) &(w->text[sizeof( char_info ) * addr]); scr = (char_info _FAR *) &Scrn[(w->x1 + start + col + (spl + w->y1) * WindMaxWidth) * sizeof( char_info )]; attr = MAKE_ATTR( w, style->foreground, style->background ); /* * display char */ has_mouse = DisplayMouse( FALSE ); over = &(w->overlap[addr]); tmp.attr = attr; tmp.ch = text; WRITE_SCREEN_DATA( *txt, tmp ); if( *over == NO_CHAR ) { WRITE_SCREEN( *scr, tmp ); } #ifdef __VIO__ MyVioShowBuf( (unsigned)((char *) scr - Scrn), 1 ); #endif ReleaseWindow( w ); DisplayMouse( has_mouse ); return( ERR_NO_ERR ); } /* SetCharInWindowWithColor */
/* * displayLineInWindowGeneric - takes an ss_block directly */ vi_rc displayLineInWindowGeneric( window_id wn, int c_line_no, char *text, int start_col, ss_block *ss ) { wind *w; char_info *txt; char *over, *tmp, *otmp; char_info _FAR *scr; int addr, start, end, a, spend; int cnt1, cnt2, startc, spl; char_info blank, what; #ifdef __VIO__ unsigned oscr; unsigned tbytes; #endif bool has_mouse, write_eol; unsigned ss_i; // index into text, not ss[ss_i] if( EditFlags.Quiet ) { return( ERR_NO_ERR ); } w = Windows[wn]; write_eol = FALSE; if( EditFlags.RealTabs ) { a = strlen( text ); otmp = tmp = StaticAlloc(); ExpandTabsInABuffer( text, a, tmp, MaxLinem1 + 2 ); } else { tmp = text; } tmp += start_col; a = strlen( tmp ); /* * find dimensions of line */ if( w->has_border ) { if( c_line_no < 1 || c_line_no > w->height - 2 ) { if( EditFlags.RealTabs ) { StaticFree( otmp ); } return( ERR_WIND_NO_SUCH_LINE ); } start = 1; spl = c_line_no; spend = end = w->width - 1; if( a < end - 1 ) { end = a + 1; } else if( a >= end ) { write_eol = TRUE; } } else { if( c_line_no < 1 || c_line_no > w->height ) { if( EditFlags.RealTabs ) { StaticFree( otmp ); } return( ERR_WIND_NO_SUCH_LINE ); } start = 0; spl = c_line_no - 1; spend = end = w->width; if( a < end ) { end = a; } else if( a > end ) { write_eol = TRUE; } } startc = start; cnt1 = end - start; cnt2 = spend - end; c_line_no--; w = AccessWindow( wn ); /* * initialize */ addr = startc + spl * w->width; txt = (char_info *) &(w->text[sizeof( char_info ) * addr]); scr = (char_info _FAR *) &Scrn[(w->x1 + startc + (spl + w->y1) * WindMaxWidth) * sizeof(char_info)]; #ifdef __VIO__ oscr = (unsigned) ((char *) scr - Scrn); tbytes = cnt1 + cnt2; #endif ss_i = 0; what.attr = MAKE_ATTR( w, SEType[ss->type].foreground, SEType[ss->type].background ); blank.ch = ' '; has_mouse = DisplayMouse( FALSE ); /* * display line */ if( w->overcnt[spl] ) { over = &(w->overlap[addr]); while( cnt1-- != 0 ) { what.ch = (*tmp); WRITE_SCREEN_DATA( *txt, what ); if( *over++ == NO_CHAR ) { WRITE_SCREEN( *scr, what ); } tmp++; scr++; txt++; if( ++ss_i > ss->end ) { ss++; what.attr = MAKE_ATTR( w, SEType[ss->type].foreground, SEType[ss->type].background ); } } if( write_eol && *(over - 1) == NO_CHAR ) { WriteLongLineMarker( wn, &( SEType[SE_EOFTEXT] ), txt - 1, scr - 1, *(tmp - 1) ); } else { blank.attr = MAKE_ATTR( w, SEType[ss->type].foreground, SEType[ss->type].background ); while( cnt2-- != 0 ) { WRITE_SCREEN_DATA( *txt, blank ); if( *over++ == NO_CHAR ) { WRITE_SCREEN( *scr, blank ); } scr++; txt++; } } } else { while( cnt1-- != 0 ) { what.ch = (*tmp); WRITE_SCREEN_DATA( *txt, what ); WRITE_SCREEN( *scr, what ); scr++; txt++; tmp++; if( ++ss_i > ss->end ) { ss++; what.attr = MAKE_ATTR( w, SEType[ss->type].foreground, SEType[ss->type].background ); } } if( write_eol ) { WriteLongLineMarker( wn, &( SEType[SE_EOFTEXT] ), txt - 1, scr - 1, *(tmp - 1) ); } else { blank.attr = MAKE_ATTR( w, SEType[ss->type].foreground, SEType[ss->type].background ); while( cnt2-- != 0 ) { WRITE_SCREEN_DATA( *txt, blank ); WRITE_SCREEN( *scr, blank ); txt++; scr++; } } } #ifdef __VIO__ MyVioShowBuf( oscr, tbytes ); #endif if( EditFlags.RealTabs ) { StaticFree( otmp ); } ReleaseWindow( w ); DisplayMouse( has_mouse ); return( ERR_NO_ERR ); } /* displayLineInWindowGeneric */
COSXScreen::COSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCursor) : CPlatformScreen(events), m_events(events), MouseButtonEventMap(NumButtonIDs), m_isPrimary(isPrimary), m_isOnScreen(m_isPrimary), m_cursorPosValid(false), m_cursorHidden(false), m_dragNumButtonsDown(0), m_dragTimer(NULL), m_keyState(NULL), m_sequenceNumber(0), m_screensaver(NULL), m_screensaverNotify(false), m_ownClipboard(false), m_clipboardTimer(NULL), m_hiddenWindow(NULL), m_userInputWindow(NULL), m_switchEventHandlerRef(0), m_pmMutex(new CMutex), m_pmWatchThread(NULL), m_pmThreadReady(new CCondVar<bool>(m_pmMutex, false)), m_activeModifierHotKey(0), m_activeModifierHotKeyMask(0), m_lastSingleClick(0), m_lastDoubleClick(0), m_lastSingleClickXCursor(0), m_lastSingleClickYCursor(0), m_autoShowHideCursor(autoShowHideCursor), m_eventTapRLSR(nullptr), m_eventTapPort(nullptr), m_pmRootPort(0) { try { m_displayID = CGMainDisplayID(); updateScreenShape(m_displayID, 0); m_screensaver = new COSXScreenSaver(m_events, getEventTarget()); m_keyState = new COSXKeyState(m_events); // TODO: http://stackoverflow.com/questions/2950124/enable-access-for-assistive-device-programmatically if (m_isPrimary && !AXAPIEnabled()) throw XArch("system setting not enabled: \"Enable access for assistive devices\""); // install display manager notification handler #if defined(MAC_OS_X_VERSION_10_5) CGDisplayRegisterReconfigurationCallback(displayReconfigurationCallback, this); #else m_displayManagerNotificationUPP = NewDMExtendedNotificationUPP(displayManagerCallback); OSStatus err = GetCurrentProcess(&m_PSN); err = DMRegisterExtendedNotifyProc(m_displayManagerNotificationUPP, this, 0, &m_PSN); #endif // install fast user switching event handler EventTypeSpec switchEventTypes[2]; switchEventTypes[0].eventClass = kEventClassSystem; switchEventTypes[0].eventKind = kEventSystemUserSessionDeactivated; switchEventTypes[1].eventClass = kEventClassSystem; switchEventTypes[1].eventKind = kEventSystemUserSessionActivated; EventHandlerUPP switchEventHandler = NewEventHandlerUPP(userSwitchCallback); InstallApplicationEventHandler(switchEventHandler, 2, switchEventTypes, this, &m_switchEventHandlerRef); DisposeEventHandlerUPP(switchEventHandler); constructMouseButtonEventMap(); // watch for requests to sleep m_events->adoptHandler(m_events->forCOSXScreen().confirmSleep(), getEventTarget(), new TMethodEventJob<COSXScreen>(this, &COSXScreen::handleConfirmSleep)); // create thread for monitoring system power state. *m_pmThreadReady = false; LOG((CLOG_DEBUG "starting watchSystemPowerThread")); m_pmWatchThread = new CThread(new TMethodJob<COSXScreen> (this, &COSXScreen::watchSystemPowerThread)); } catch (...) { m_events->removeHandler(m_events->forCOSXScreen().confirmSleep(), getEventTarget()); if (m_switchEventHandlerRef != 0) { RemoveEventHandler(m_switchEventHandlerRef); } #if defined(MAC_OS_X_VERSION_10_5) CGDisplayRemoveReconfigurationCallback(displayReconfigurationCallback, this); #else if (m_displayManagerNotificationUPP != NULL) { DMRemoveExtendedNotifyProc(m_displayManagerNotificationUPP, NULL, &m_PSN, 0); } if (m_hiddenWindow) { ReleaseWindow(m_hiddenWindow); m_hiddenWindow = NULL; } if (m_userInputWindow) { ReleaseWindow(m_userInputWindow); m_userInputWindow = NULL; } #endif delete m_keyState; delete m_screensaver; throw; } // install event handlers m_events->adoptHandler(CEvent::kSystem, m_events->getSystemTarget(), new TMethodEventJob<COSXScreen>(this, &COSXScreen::handleSystemEvent)); // install the platform event queue m_events->adoptBuffer(new COSXEventQueueBuffer(m_events)); }
/* * DrawBorder - display border */ void DrawBorder( window_id wn ) { wind *w; int i, j, k, stc, etc, ctc; int tl, bl, tr, br; int xtl, xbl, xtr, xbr; char *over, c; unsigned short clr; char_info what, what2; char_info _FAR *scr; char_info *txt; int topscol, topecol, topccol; char *wb; if( EditFlags.Quiet ) { return; } if( !Windows[wn]->has_border ) { return; } w = AccessWindow( wn ); txt = (char_info *) w->text; over = w->overlap; scr = (char_info _FAR *) Scrn; if( w->has_gadgets ) { wb = GadgetString; } else { wb = WindowBordersNG; } /* * set up for border addendums (title and misc top data) */ if( w->title != NULL ) { stc = (w->width - strlen( w->title )) / 2 - 1; if( stc < 1 ) { stc = 1; } etc = stc + strlen( w->title ) + 1; ctc = 0; } if( w->borderdata != NULL ) { topscol = w->bordercol; topecol = topscol + strlen( w->borderdata ) - 1; topccol = 0; } tl = (w->x1) + (w->y1) * WindMaxWidth; tr = (w->x2) + (w->y1) * WindMaxWidth; bl = (w->x1) + (w->y2) * WindMaxWidth; br = (w->x2) + (w->y2) * WindMaxWidth; xtl = 0; xtr = w->width - 1; xbl = (w->height - 1) * w->width; xbr = w->width - 1 + (w->height - 1) * w->width; clr = MAKE_ATTR( w, w->border_color1, w->border_color2 ); what.attr = clr; what2.attr = clr; /* * do the corner pieces */ what.ch = wb[WB_TOPLEFT]; WRITE_SCREEN_DATA( txt[xtl], what ); if( over[xtl] == NO_CHAR ) { WRITE_SCREEN( scr[tl], what ); } what.ch = wb[WB_TOPRIGHT]; WRITE_SCREEN_DATA( txt[xtr], what ); if( over[xtr] == NO_CHAR ) { WRITE_SCREEN( scr[tr], what ); } what.ch = wb[WB_BOTTOMLEFT]; WRITE_SCREEN_DATA( txt[xbl], what ); if( over[xbl] == NO_CHAR ) { WRITE_SCREEN( scr[bl], what ); } what.ch = wb[WB_BOTTOMRIGHT]; WRITE_SCREEN_DATA( txt[xbr], what ); if( over[xbr] == NO_CHAR ) { WRITE_SCREEN( scr[br], what ); } /* * do the left side */ what.ch = wb[WB_LEFTSIDE]; k = xtl + w->width; j = tl + WindMaxWidth; for( i = 1; i < w->height - 1; i++ ) { WRITE_SCREEN_DATA( txt[k], what ); if( over[k] == NO_CHAR ) { WRITE_SCREEN( scr[j], what ); #ifdef __VIO__ MyVioShowBuf( sizeof( char_info ) * j, 1 ); #endif } k += w->width; j += WindMaxWidth; } /* * do the right side */ what.ch = wb[WB_RIGHTSIDE]; k = xtr + w->width; j = tr + WindMaxWidth; for( i = 1; i < w->height - 1; i++ ) { WRITE_SCREEN_DATA( txt[k], what ); if( over[k] == NO_CHAR ) { WRITE_SCREEN( scr[j], what ); #ifdef __VIO__ MyVioShowBuf( sizeof( char_info ) * j, 1 ); #endif } k += w->width; j += WindMaxWidth; } /* * now do bottom and top */ what2.ch = wb[WB_TOPBOTTOM]; for( i = 1; i < w->width - 1; i++ ) { k = xtl + i; c = wb[5]; if( w->title != NULL ) { if( i >= stc && i <= etc ) { if( i == stc ) { c = wb[WB_RIGHTT]; } else if( i == etc ) { c = wb[WB_LEFTT]; } else { c = w->title[ctc++]; } } } if( w->borderdata != NULL ) { if( i >= topscol && i <= topecol ) { c = w->borderdata[topccol++]; } } what.ch = c; WRITE_SCREEN_DATA( txt[k], what ); if( over[k] == NO_CHAR ) { WRITE_SCREEN( scr[tl + i] , what ); } k = xbl + i; WRITE_SCREEN_DATA( txt[k], what2 ); if( over[k] == NO_CHAR ) { WRITE_SCREEN( scr[bl + i] , what2 ); } } /* * add side gadgets */ if( w->has_gadgets || w->has_scroll_gadgets ) { what.ch = wb[WB_UPTRIANGLE]; WRITE_SCREEN_DATA( txt[xtr + w->width], what ); if( over[xtr + w->width] == NO_CHAR ) { WRITE_SCREEN( scr[tr + WindMaxWidth], what ); #ifdef __VIO__ MyVioShowBuf( sizeof( char_info ) * (tr + WindMaxWidth), 1 ); #endif } what.ch = wb[WB_DOWNTRIANGLE]; WRITE_SCREEN_DATA( txt[xbr - w->width], what ); if( over[xbr - w->width] == NO_CHAR ) { WRITE_SCREEN( scr[br - WindMaxWidth], what ); #ifdef __VIO__ MyVioShowBuf( sizeof( char_info ) * (br - WindMaxWidth), 1 ); #endif } } #ifdef __VIO__ MyVioShowBuf( sizeof( char_info ) * tl, w->width ); MyVioShowBuf( sizeof( char_info ) * bl, w->width ); #endif if( w->has_gadgets ) { DrawVerticalThumb( w, GadgetString[WB_THUMB] ); } ReleaseWindow( w ); } /* DrawBorder */