static pascal OSStatus wxMacAppCommandEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; HICommand command ; wxMacCarbonEvent cEvent( event ) ; cEvent.GetParameter<HICommand>(kEventParamDirectObject,typeHICommand,&command) ; wxMenuItem* item = NULL ; wxMenu* itemMenu = wxFindMenuFromMacCommand( command , item ) ; int id = wxMacCommandToId( command.commandID ) ; if ( item ) { wxASSERT( itemMenu != NULL ) ; switch ( cEvent.GetKind() ) { case kEventProcessCommand : result = itemMenu->MacHandleCommandProcess( item, id ); break ; case kEventCommandUpdateStatus: result = itemMenu->MacHandleCommandUpdateStatus( item, id ); break ; default : break ; } } return result ; }
wxInt32 wxScrollBar::MacControlHit( WXEVENTHANDLERREF handler , WXEVENTREF mevent ) { int position = m_peer->GetValue() ; int minPos = m_peer->GetMinimum() ; int maxPos = m_peer->GetMaximum() ; wxEventType scrollEvent = wxEVT_NULL; int nScrollInc = 0; wxMacCarbonEvent cEvent( (EventRef) mevent ) ; ControlPartCode controlpart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPart,typeControlPartCode) ; // all events have already been reported during mouse down, except for THUMBRELEASE if ( controlpart !=kControlIndicatorPart ) return eventNotHandledErr ; switch( controlpart ) { case kControlIndicatorPart : nScrollInc = 0 ; scrollEvent = wxEVT_SCROLL_THUMBRELEASE; break ; default : wxFAIL_MSG(wxT("illegal scrollbar selector")); break ; } int new_pos = position + nScrollInc; if (new_pos < minPos) new_pos = minPos; if (new_pos > maxPos) new_pos = maxPos; if ( nScrollInc ) SetThumbPosition(new_pos); wxScrollEvent event(scrollEvent, m_windowId); if ( m_windowStyle & wxHORIZONTAL ) { event.SetOrientation( wxHORIZONTAL ) ; } else { event.SetOrientation( wxVERTICAL ) ; } event.SetPosition(new_pos); event.SetEventObject( this ); wxWindow* window = GetParent() ; if (window && window->MacIsWindowScrollbar(this) ) { // this is hardcoded window->MacOnScroll(event); } else GetEventHandler()->ProcessEvent(event); return noErr ; }
static enum MqErrorE sEvent ( struct MqS * const context, MQ_PTR const data ) { cEvent(context, (GoInterface*)data); return MqErrorStack(context); }
static pascal OSStatus wxMacAppMenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { wxMacCarbonEvent cEvent( event ) ; MenuRef menuRef = cEvent.GetParameter<MenuRef>(kEventParamDirectObject) ; #ifndef __WXUNIVERSAL__ wxMenu* menu = wxFindMenuFromMacMenu( menuRef ) ; if ( menu ) { wxEventType type=0; MenuCommand cmd=0; switch (GetEventKind(event)) { case kEventMenuOpening: type = wxEVT_MENU_OPEN; break; case kEventMenuClosed: type = wxEVT_MENU_CLOSE; break; case kEventMenuTargetItem: cmd = cEvent.GetParameter<MenuCommand>(kEventParamMenuCommand,typeMenuCommand) ; if (cmd != 0) type = wxEVT_MENU_HIGHLIGHT; break; default: wxFAIL_MSG(wxT("Unexpected menu event kind")); break; } if ( type ) { wxMenuEvent wxevent(type, cmd, menu); wxevent.SetEventObject(menu); wxEvtHandler* handler = menu->GetEventHandler(); if (handler && handler->ProcessEvent(wxevent)) { // handled } else { wxWindow *win = menu->GetInvokingWindow(); if (win) win->GetEventHandler()->ProcessEvent(wxevent); } } } #endif return eventNotHandledErr; }
static pascal OSStatus wxMacAppCommandEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; HICommand command ; wxMacCarbonEvent cEvent( event ) ; cEvent.GetParameter<HICommand>(kEventParamDirectObject,typeHICommand,&command) ; wxMenuItem* item = NULL ; MenuCommand id = command.commandID ; // for items we don't really control if ( id == kHICommandPreferences ) { id = wxApp::s_macPreferencesMenuItemId ; wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ; if ( mbar ) { wxMenu* menu = NULL ; item = mbar->FindItem( id , &menu ) ; } } else if ( id != 0 && command.menu.menuRef != 0 && command.menu.menuItemIndex != 0 ) { GetMenuItemRefCon( command.menu.menuRef , command.menu.menuItemIndex , (UInt32*) &item ) ; } if ( item ) { switch( cEvent.GetKind() ) { case kEventProcessCommand : { if (item->IsCheckable()) { item->Check( !item->IsChecked() ) ; } item->GetMenu()->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ; result = noErr ; } break ; case kEventCommandUpdateStatus: // eventually trigger an updateui round result = noErr ; break ; default : break ; } } return result ; }
pascal OSStatus wxMacAppEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { EventRef formerEvent = (EventRef) wxTheApp->MacGetCurrentEvent() ; EventHandlerCallRef formerEventHandlerCallRef = (EventHandlerCallRef) wxTheApp->MacGetCurrentEventHandlerCallRef() ; wxTheApp->MacSetCurrentEvent( event , handler ) ; OSStatus result = eventNotHandledErr ; switch ( GetEventClass( event ) ) { case kEventClassCommand : result = wxMacAppCommandEventHandler( handler , event , data ) ; break ; case kEventClassApplication : result = wxMacAppApplicationEventHandler( handler , event , data ) ; break ; case kEventClassMenu : result = wxMacAppMenuEventHandler( handler , event , data ) ; break ; case kEventClassMouse : { wxMacCarbonEvent cEvent( event ) ; WindowRef window ; Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ; ::FindWindow(screenMouseLocation, &window); // only send this event in case it had not already been sent to a tlw, as we get // double events otherwise (in case event.skip) was called if ( window == NULL ) result = wxMacTopLevelMouseEventHandler( handler , event , NULL ) ; } break ; case kEventClassAppleEvent : { EventRecord rec ; wxMacConvertEventToRecord( event , &rec ) ; result = AEProcessAppleEvent( &rec ) ; } break ; default : break ; } wxTheApp->MacSetCurrentEvent( formerEvent, formerEventHandlerCallRef ) ; return result ; }
static pascal OSStatus wxMacAppMenuEventHandler( EventHandlerCallRef WXUNUSED(handler), EventRef event, void *WXUNUSED(data) ) { wxMacCarbonEvent cEvent( event ) ; MenuRef menuRef = cEvent.GetParameter<MenuRef>(kEventParamDirectObject) ; #ifndef __WXUNIVERSAL__ wxMenu* menu = wxFindMenuFromMacMenu( menuRef ) ; if ( menu ) { switch (GetEventKind(event)) { case kEventMenuOpening: menu->HandleMenuOpened(); break; case kEventMenuClosed: menu->HandleMenuClosed(); break; case kEventMenuTargetItem: { HICommand command ; command.menu.menuRef = menuRef; command.menu.menuItemIndex = cEvent.GetParameter<MenuItemIndex>(kEventParamMenuItemIndex,typeMenuItemIndex) ; command.commandID = cEvent.GetParameter<MenuCommand>(kEventParamMenuCommand,typeMenuCommand) ; if (command.commandID != 0) { wxMenuItem* item = NULL ; wxMenu* itemMenu = wxFindMenuFromMacCommand( command , item ) ; if ( itemMenu && item ) itemMenu->HandleMenuItemHighlighted( item ); } } break; default: wxFAIL_MSG(wxT("Unexpected menu event kind")); break; } } #endif return eventNotHandledErr; }
static pascal OSStatus wxMacToolBarToolControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; wxMacCarbonEvent cEvent( event ) ; ControlRef controlRef ; cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ; switch( GetEventKind( event ) ) { case kEventControlHit : { wxToolBarTool* tbartool = (wxToolBarTool*)data ; if ( tbartool->CanBeToggled() ) { #ifdef __WXMAC_OSX__ ((wxToolBar*)tbartool->GetToolBar())->ToggleTool(tbartool->GetId(), !tbartool->IsToggled() ); #else ((wxToolBar*)tbartool->GetToolBar())->ToggleTool(tbartool->GetId(), GetControl32BitValue((ControlRef)tbartool->GetControlHandle())); #endif } ((wxToolBar*)tbartool->GetToolBar())->OnLeftClick( tbartool->GetId() , tbartool -> IsToggled() ) ; result = noErr; } break ; #ifdef __WXMAC_OSX__ case kEventControlHitTest : { HIPoint pt = cEvent.GetParameter<HIPoint>(kEventParamMouseLocation) ; HIRect rect ; HIViewGetBounds( controlRef , &rect ) ; ControlPartCode pc = kControlNoPart ; if ( CGRectContainsPoint( rect , pt ) ) pc = kControlIconPart ; cEvent.SetParameter( kEventParamControlPart , typeControlPartCode, pc ) ; result = noErr ; } break ; #endif default : break ; } return result ; }
int main(int argc, char *argv[]) { GitlModual cModual; /// subscribe to an event cModual.subscribeToEvtByName("I am a test event", [](GitlEvent& rcEvt)->bool { qDebug() << "Hello GitlEvtBus!"; return true; } ); GitlEvent cEvent("I am a test event"); ///< create an event cEvent.dispatch(); ///< dispatch /// output: "Hello GitlEvtBus!"*/ return 0; }
static pascal OSStatus wxMacSearchControlEventHandler( EventHandlerCallRef WXUNUSED(handler) , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; wxMacCarbonEvent cEvent( event ) ; ControlRef controlRef ; wxSearchCtrl* thisWindow = (wxSearchCtrl*) data ; cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ; switch( GetEventKind( event ) ) { case kEventSearchFieldCancelClicked : thisWindow->HandleSearchFieldCancelHit() ; break ; case kEventSearchFieldSearchClicked : thisWindow->HandleSearchFieldSearchHit() ; break ; } return result ; }
pascal OSStatus wxMacCarbonFontPanelHandler(EventHandlerCallRef WXUNUSED(nextHandler), EventRef event, void *userData) { OSStatus result = eventNotHandledErr ; wxFontDialog *fontdialog = (wxFontDialog*) userData ; wxFontData& fontdata= fontdialog->GetFontData() ; wxMacCarbonEvent cEvent( event ); switch(cEvent.GetKind()) { case kEventFontSelection : { bool setup = false ; #if wxOSX_USE_CORE_TEXT if ( UMAGetSystemVersion() >= 0x1050 ) { CTFontDescriptorRef descr; if ( cEvent.GetParameter<CTFontDescriptorRef>( kEventParamCTFontDescriptor, typeCTFontDescriptorRef, &descr ) == noErr ) { wxFont font; wxNativeFontInfo fontinfo; fontinfo.Init(descr); font.Create(fontinfo); fontdata.SetChosenFont( font ) ; setup = true; } } #endif #if wxOSX_USE_ATSU_TEXT ATSUFontID fontId = 0 ; if ( !setup && (cEvent.GetParameter<ATSUFontID>(kEventParamATSUFontID, &fontId) == noErr) ) { FMFontStyle fontStyle = cEvent.GetParameter<FMFontStyle>(kEventParamFMFontStyle); FMFontSize fontSize = cEvent.GetParameter<FMFontSize>(kEventParamFMFontSize); CFStringRef cfName = NULL; #if 1 FMFontFamily fontFamily = cEvent.GetParameter<FMFontFamily>(kEventParamFMFontFamily); ATSFontFamilyRef atsfontfamilyref = FMGetATSFontFamilyRefFromFontFamily( fontFamily ) ; OSStatus err = ATSFontFamilyGetName( atsfontfamilyref , kATSOptionFlagsDefault , &cfName ) ; if ( err != noErr ) { wxFAIL_MSG("ATSFontFamilyGetName failed"); } #else // we don't use the ATSU naming anymore ByteCount actualLength = 0; char *c = NULL; OSStatus err = ATSUFindFontName(fontId , kFontFamilyName, kFontUnicodePlatform, kFontNoScriptCode, kFontNoLanguageCode , 0 , NULL , &actualLength , NULL ); if ( err == noErr) { actualLength += 1 ; char *c = (char*)malloc( actualLength ); err = ATSUFindFontName(fontId, kFontFamilyName, kFontUnicodePlatform, kFontNoScriptCode, kFontNoLanguageCode, actualLength, c , NULL, NULL); cfName = CFStringCreateWithCharacters(NULL, (UniChar*) c, (actualLength-1) >> 1); } else { err = ATSUFindFontName(fontId , kFontFamilyName, kFontNoPlatformCode, kFontNoScriptCode, kFontNoLanguageCode , 0 , NULL , &actualLength , NULL ); if ( err == noErr ) { actualLength += 1 ; c = (char*)malloc(actualLength); err = ATSUFindFontName(fontId, kFontFamilyName, kFontNoPlatformCode, kFontNoScriptCode, kFontNoLanguageCode, actualLength, c , NULL, NULL); c[actualLength-1] = 0; cfName = CFStringCreateWithCString(NULL, c, kCFStringEncodingMacRoman ); } } if ( c!=NULL ) free(c); #endif if ( cfName!=NULL ) { fontdata.m_chosenFont.SetFaceName(wxCFStringRef(cfName).AsString(wxLocale::GetSystemEncoding())); fontdata.m_chosenFont.SetPointSize(fontSize); fontdata.m_chosenFont.SetStyle(fontStyle & italic ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL); fontdata.m_chosenFont.SetUnderlined((fontStyle & underline)!=0); fontdata.m_chosenFont.SetWeight(fontStyle & bold ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL); } }
void Task_MigrateCtTarget::finalizeTask() { IOSendJob::Handle hJob; SmartPtr<IOPackage> pPackage; // delete temporary registration if (m_nSteps & MIGRATE_VM_EXCL_PARAMS_LOCKED) CDspService::instance()->getVmDirManager().unlockExclusiveVmParameters(m_pVmInfo.getImpl()); int nRetCode = getLastErrorCode(); if (PRL_SUCCEEDED(nRetCode)) { if (m_pVm.getImpl()) { PRL_EVENT_TYPE evtType; /* restore Vm previous state */ switch (m_nPrevVmState) { case VMS_RUNNING: evtType = PET_DSP_EVT_VM_STARTED; break; case VMS_STOPPED: default: evtType = PET_DSP_EVT_VM_STOPPED; break; } CVmEvent cStateEvent(evtType, m_sVmUuid, PIE_DISPATCHER); SmartPtr<IOPackage> pUpdateVmStatePkg = DispatcherPackage::createInstance( PVE::DspVmEvent, cStateEvent.toString()); m_pVm->changeVmState(pUpdateVmStatePkg); CDspService::instance()->getClientManager(). sendPackageToVmClients(pUpdateVmStatePkg, m_sVzDirUuid, m_sVmUuid); if (m_nPrevVmState == VMS_STOPPED) { CDspService::instance()->getVmDirHelper().unregisterExclusiveVmOperation( m_sVmUuid, m_sVzDirUuid, PVE::DspCmdDirVmMigrate, getClient()); CDspVm::UnregisterVmObject(m_pVm); } else { /* lock running Vm (https://jira.sw.ru/browse/PSBM-7682) */ /* will do it via initial Vm creation command (https://jira.sw.ru/browse/PSBM-8222) */ m_pVm->replaceInitDspCmd(PVE::DspCmdVmStart, getClient()); } } /* notify source task about target task finish, will send reply to check precondition request. https://jira.sw.ru/browse/PSBM-9596 */ m_pCheckDispConnection->sendSimpleResponse(m_pCheckPackage, PRL_ERR_SUCCESS); /* migration initiator wait event from original Vm uuid */ CVmEvent cEvent(PET_DSP_EVT_VM_MIGRATE_FINISHED, m_sOriginVmUuid, PIE_DISPATCHER); pPackage = DispatcherPackage::createInstance(PVE::DspVmEvent, cEvent.toString()); CDspService::instance()->getClientManager().sendPackageToVmClients(pPackage, m_sVzDirUuid, m_sOriginVmUuid); } else { /* It is not possible to get Vm client list after deleteVmDirectoryItem(), and sendPackageToVmClients() does not work. Get list right now and will use sendPackageToClientList() call (https://jira.sw.ru/browse/PSBM-9159) */ QList< SmartPtr<CDspClient> > clientList = CDspService::instance()->getClientManager(). getSessionListByVm(m_sVzDirUuid, m_sVmUuid).values(); if (operationIsCancelled()) setLastErrorCode(PRL_ERR_OPERATION_WAS_CANCELED); /* if migration was not started, do not cleanup anything - we can remove 'already existed Vm' */ if (m_nSteps & MIGRATE_STARTED) { if (m_nSteps & MIGRATE_VM_APP_STARTED && m_pVm.getImpl()) { /* stop Vm */ CProtoCommandPtr pCmd = CProtoSerializer::CreateProtoVmCommandStop(m_sVmUuid, PSM_KILL, 0); pPackage = DispatcherPackage::createInstance( PVE::DspCmdVmStop, pCmd ); m_pVm->stop(getClient(), pPackage, PSM_KILL, true); // Wait until VM stopped while (m_pVm->isConnected()) { if (operationIsCancelled() && CDspService::instance()->isServerStopping()) break; QThread::msleep(1000); } } if (m_pVm.getImpl()) { CDspVm::UnregisterVmObject(m_pVm); m_pVm = SmartPtr<CDspVm>(0); } if (!CDspService::instance()->isServerStopping()) CDspService::instance()->getVmConfigWatcher().unregisterVmToWatch(m_sTargetVmHomePath); if ( !(m_nReservedFlags & PVM_DONT_COPY_VM) ) { CFileHelper::ClearAndDeleteDir(m_sTargetVmHomePath); } // Unregister VM dir item CDspService::instance()->getVmDirHelper().deleteVmDirectoryItem(m_sVzDirUuid, m_sVmUuid); CVmEvent cDelEvent(PET_DSP_EVT_VM_DELETED, m_sVmUuid, PIE_DISPATCHER); SmartPtr<IOPackage> pDelPackage = DispatcherPackage::createInstance(PVE::DspVmEvent, cDelEvent.toString()); CDspService::instance()->getClientManager().sendPackageToClientList( pDelPackage, clientList); } /* migration initiator wait event from original Vm uuid */ CVmEvent cEvent(PET_DSP_EVT_VM_MIGRATE_CANCELLED, m_sOriginVmUuid, PIE_DISPATCHER); pPackage = DispatcherPackage::createInstance(PVE::DspVmEvent, cEvent.toString()); CDspService::instance()->getClientManager().sendPackageToClientList(pPackage, clientList); if (m_pStartDispConnection.isValid()) hJob = m_pStartDispConnection->sendResponseError(getLastError(), getRequestPackage()); else hJob = m_pCheckDispConnection->sendResponseError(getLastError(), getRequestPackage()); CDspService::instance()->getIOServer().waitForSend(hJob, m_nTimeout); } }