int timer_activate( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo ) { PtArg_t args[1]; float diffsum; clock_t diff_time; isd_poll_all(isdx, &yaw, &pitch, &roll); iyaw = floor(yaw); ipitch = floor(pitch); iroll = floor(roll); PtSetArg(&args[0], Pt_ARG_GAUGE_VALUE, iyaw, 0); PtSetResources(ABW_yaw_meter, 1, args); PtSetArg(&args[0], Pt_ARG_GAUGE_VALUE, ipitch, 0); PtSetResources(ABW_pitch_meter, 1, args); PtSetArg(&args[0], Pt_ARG_GAUGE_VALUE, iroll, 0); PtSetResources(ABW_roll_meter, 1, args); sprintf(yaw_label, "%7.2f", yaw); sprintf(pitch_label, "%7.2f", pitch); sprintf(roll_label, "%7.2f", roll); PtSetArg(&args[0], Pt_ARG_TEXT_STRING, &yaw_label, 1); PtSetResources(ABW_yaw_label, 1, args); PtSetArg(&args[0], Pt_ARG_TEXT_STRING, &pitch_label, 1); PtSetResources(ABW_pitch_label, 1, args); PtSetArg(&args[0], Pt_ARG_TEXT_STRING, &roll_label, 1); PtSetResources(ABW_roll_label, 1, args); diffsum = abs(yaw - lastyaw); diffsum += abs(pitch - lastpitch); diffsum += abs(roll - lastroll); if (diffsum >= REDRAW_THRESHOLD) { lastyaw = yaw; lastpitch = pitch; lastroll = roll; PtDamageWidget(ABW_rawcube); PtFlush(); } last_time = this_time; this_time = clock(); diff_time = this_time - last_time; sprintf(timestring, "%d Hz", CLOCKS_PER_SEC/diff_time); PtSetArg(&args[0], Pt_ARG_TEXT_STRING, ×tring, 1); PtSetResources(ABW_rate_label, 1, args); /* eliminate 'unreferenced' warnings */ widget = widget, apinfo = apinfo, cbinfo = cbinfo; return( Pt_CONTINUE ); }
int processtask(task_t *ptask) { size_t i = 0, s, t ; switch(ptask->cmd) { case IMG_DRAW: s = ptask->n/(2*sizeof(double_t)); sem_wait(&sem); while(i < s){ t = roundf(((double_t*)ptask->px)[i] * 10); px[t] = ((double_t*)ptask->px)[i]; py[t] = ((double_t*)ptask->px)[i+s] -1; ++i; } sem_post(&sem); break; case IMG_CLEAR: sem_wait(&sem); while(i<POINT_MAX) { px[i] = -1; py[i] = -1; ++i; } //memset(px, -1, POINT_MAX*sizeof(double_t)); //memset(py, -1, POINT_MAX*sizeof(double_t)); sem_post(&sem); break; } PtDamageWidget( AbWidgets[ABN_PtRawDots].wgt ); return 0; }
// Assumes if Major Tick size is changes, the old array is reallocated properly. void scale_set_labels( PtWidget_t *widget, PtArg_t const *argt) { PtScaleWidget_t *sc = (PtScaleWidget_t *) widget; int i; int loop; char** str_array = (char**)argt->value; // Make sure we only set what we can if( argt->len > sc->labels_size ) { loop = sc->labels_size; } else { loop = argt->len; } // Loop here, freeing/setting string as required. for( i = 0; i < loop; i++ ) { // If label is alreay set, release storage space for it if( NULL != sc->labels[i] ) { free( sc->labels[i] ); } sc->labels[i] = strdup( str_array[i] ); } PtDamageWidget( widget ); }
// Set the major scale. If needed, allocate a new temporary array // to store static void scale_set_major_ticks( PtWidget_t *widget, PtArg_t const *argt) { PtScaleWidget_t *sc = (PtScaleWidget_t *) widget; char** str_array; int i; // If needed, allocate new array of pointers to store the labels into if( ( argt->value + 1 ) > sc->labels_size ) { str_array = calloc( ( argt->value + 1 ), sizeof( char * ) ); if( NULL != str_array ) { for( i = 0; i < sc->labels_size; i++ ) { str_array[i] = sc->labels[i]; } // No longer need the old table, release the memory. free( sc->labels ); // Set the widgets labels table to correspond to the new size. sc->labels = str_array; sc->labels_size = argt->value + 1; } } // Set the major division and mark widget damaged. sc->major_ticks_division = argt->value; PtDamageWidget( widget ); }
NS_METHOD nsWidget::Invalidate( PRBool aIsSynchronous ) { // mWidget will be null during printing if( !mWidget || !PtWidgetIsRealized( mWidget ) ) return NS_OK; PtWidget_t *aWidget = (PtWidget_t *)GetNativeData(NS_NATIVE_WIDGET); PtDamageWidget( aWidget ); if( aIsSynchronous ) PtFlush(); return NS_OK; }
/***************************************************************************** * QNXManage: handle QNX events ***************************************************************************** * This function should be called regularly by video output thread. It allows * window resizing. It returns a non null value on error. *****************************************************************************/ static int QNXManage( vout_thread_t *p_vout ) { int i_ev, i_buflen; PhEvent_t *p_event; bool b_repos = 0; if (!vlc_object_alive (p_vout)) { return ( 0 ); } /* allocate buffer for event */ i_buflen = sizeof( PhEvent_t ) * 4; if( ( p_event = malloc( i_buflen ) ) == NULL ) return( 1 ); /* event loop */ do { memset( p_event, 0, i_buflen ); i_ev = PhEventPeek( p_event, i_buflen ); if( i_ev == Ph_RESIZE_MSG ) { PhEvent_t *buf; i_buflen = PhGetMsgSize( p_event ); buf = realloc( p_event, i_buflen ); if( buf == NULL ) { free( p_event ); return( 1 ); } p_event = buf; } else if( i_ev == Ph_EVENT_MSG ) { PtEventHandler( p_event ); if( p_event->type == Ph_EV_WM ) { PhWindowEvent_t *p_ev = PhGetData( p_event ); switch( p_ev->event_f ) { case Ph_WM_CLOSE: p_vout->p_libvlc->b_die = true; break; case Ph_WM_MOVE: p_vout->p_sys->pos.x = p_ev->pos.x; p_vout->p_sys->pos.y = p_ev->pos.y; b_repos = 1; break; case Ph_WM_RESIZE: p_vout->p_sys->old_dim.w = p_vout->p_sys->dim.w; p_vout->p_sys->old_dim.h = p_vout->p_sys->dim.h; p_vout->p_sys->dim.w = p_ev->size.w; p_vout->p_sys->dim.h = p_ev->size.h; p_vout->i_changes |= VOUT_SIZE_CHANGE; break; } } else if( p_event->type == Ph_EV_KEY ) { PhKeyEvent_t *p_ev = PhGetData( p_event ); long i_key = p_ev->key_sym; if( ( p_ev->key_flags & Pk_KF_Key_Down ) && ( p_ev->key_flags & Pk_KF_Sym_Valid ) ) { switch( i_key ) { case Pk_q: case Pk_Q: p_vout->p_libvlc->b_die = true; break; case Pk_f: case Pk_F: p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE; break; default: break; } } } } } while( i_ev != -1 && i_ev != 0 ); free( p_event ); /* * fullscreen */ if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE ) { PhDim_t dim; p_vout->b_fullscreen = !p_vout->b_fullscreen; p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE; if( p_vout->b_fullscreen ) { p_vout->p_sys->old_pos.x = p_vout->p_sys->pos.x; p_vout->p_sys->old_pos.y = p_vout->p_sys->pos.y; p_vout->p_sys->pos.x = p_vout->p_sys->pos.y = 0; dim.w = p_vout->p_sys->screen_dim.w + 1; dim.h = p_vout->p_sys->screen_dim.h + 1; } else { p_vout->p_sys->pos.x = p_vout->p_sys->old_pos.x; p_vout->p_sys->pos.y = p_vout->p_sys->old_pos.y; dim.w = p_vout->p_sys->old_dim.w + 1; dim.h = p_vout->p_sys->old_dim.h + 1; } /* modify render flags, border */ PtSetResource( p_vout->p_sys->p_window, Pt_ARG_WINDOW_RENDER_FLAGS, p_vout->b_fullscreen ? Pt_FALSE : Pt_TRUE, Ph_WM_RENDER_BORDER | Ph_WM_RENDER_TITLE ); /* set position and dimension */ PtSetResource( p_vout->p_sys->p_window, Pt_ARG_POS, &p_vout->p_sys->pos, 0 ); PtSetResource( p_vout->p_sys->p_window, Pt_ARG_DIM, &dim, 0 ); /* mark as damaged to force redraw */ PtDamageWidget( p_vout->p_sys->p_window ); } /* * size change */ if( p_vout->i_changes & VOUT_SIZE_CHANGE ) { p_vout->i_changes &= ~VOUT_SIZE_CHANGE; if( p_vout->p_sys->i_mode == MODE_VIDEO_OVERLAY ) { ResizeOverlayOutput(p_vout); } #if 0 else { p_vout->output.i_width = p_vout->p_sys->dim.w; p_vout->output.i_height = p_vout->p_sys->dim.h; p_vout->i_changes |= VOUT_YUV_CHANGE; QNXEnd( p_vout ); if( QNXInit( p_vout ) ) { msg_Err( p_vout, "cannot resize display" ); return( 1 ); } } #endif msg_Dbg( p_vout, "video display resized (%dx%d)", p_vout->p_sys->dim.w, p_vout->p_sys->dim.h ); } /* * position change, move video channel */ if( b_repos && p_vout->p_sys->i_mode == MODE_VIDEO_OVERLAY ) { ResizeOverlayOutput(p_vout); } return( i_ev == -1 ); }
NS_METHOD nsWidget::Show( PRBool bState ) { if( !mWidget ) return NS_OK; // Will be null durring printing PtArg_t arg; if( bState ) { if( mWindowType != eWindowType_child ) { if (PtWidgetIsRealized(mWidget)) { mShown = PR_TRUE; return NS_OK; } //EnableDamage( mWidget, PR_FALSE ); PtRealizeWidget(mWidget); if( mWidget->rid == -1 ) { //EnableDamage( mWidget, PR_TRUE ); NS_ASSERTION(0,"nsWidget::Show mWidget's rid == -1\n"); mShown = PR_FALSE; return NS_ERROR_FAILURE; } PtSetArg(&arg, Pt_ARG_FLAGS, 0, Pt_DELAY_REALIZE); PtSetResources(mWidget, 1, &arg); //EnableDamage( mWidget, PR_TRUE ); PtDamageWidget(mWidget); #ifdef Ph_REGION_NOTIFY PhRegion_t region; PtWidget_t *mWgt; mWgt = (PtWidget_t*) GetNativeData( NS_NATIVE_WIDGET ); region.flags = Ph_REGION_NOTIFY | Ph_FORCE_BOUNDARY; region.rid = PtWidgetRid(mWgt); PhRegionChange(Ph_REGION_FLAGS, 0, ®ion, NULL, NULL); #endif } else { PtWidgetToFront( mWidget ); if( !mShown || !( mWidget->flags & Pt_REALIZED ) ) PtRealizeWidget( mWidget ); } } else { if( mWindowType != eWindowType_child ) { //EnableDamage( mWidget, PR_FALSE ); PtUnrealizeWidget(mWidget); //EnableDamage( mWidget, PR_TRUE ); PtSetArg(&arg, Pt_ARG_FLAGS, Pt_DELAY_REALIZE, Pt_DELAY_REALIZE); PtSetResources(mWidget, 1, &arg); } else { //EnableDamage( mWidget, PR_FALSE ); PtWidgetToBack( mWidget ); if( mShown ) PtUnrealizeWidget( mWidget ); //EnableDamage( mWidget, PR_TRUE ); } } mShown = bState; return NS_OK; }