static DFBResult Test_HideWindow( IDirectFBDisplayLayer *layer, void *arg ) { IDirectFBWindow *window; D_ASSERT( m_toplevel_id != 0 ); /* * Get the top level window */ _T( layer->GetWindow( layer, arg ? (unsigned long) arg : m_toplevel_id, &window ) ); /* * Hide it */ SHOW_TEST( "SetOpacity( 0 )..." ); _T( window->SetOpacity( window, 0 ) ); SHOW_RESULT( "...SetOpacity( 0 ) done." ); /* * Show it again */ SHOW_TEST( "SetOpacity( 0xff )..." ); _T( window->SetOpacity( window, 0xff ) ); SHOW_RESULT( "...SetOpacity( 0xff ) done." ); window->Release( window ); return DFB_OK; }
static DFBResult Test_DestroyWindow( IDirectFBDisplayLayer *layer, void *arg ) { IDirectFBWindow *window; D_ASSERT( m_toplevel_id != 0 ); /* * Get the top level window */ _T( layer->GetWindow( layer, arg ? (unsigned long) arg : m_toplevel_id, &window ) ); /* * Destroy it */ SHOW_TEST( "Destroy()..." ); _T( window->Destroy( window ) ); SHOW_RESULT( "...Destroy() done." ); window->Release( window ); return DFB_OK; }
void DFBDeviceScreen::releaseWindow(void* win) { set<IDirectFBWindow*>::iterator i; IDirectFBWindow* w; w = (IDirectFBWindow*)win; pthread_mutex_lock(&winMutex); if (windowPool != NULL) { i = windowPool->find(w); if (i != windowPool->end()) { windowPool->erase(i); pthread_mutex_unlock(&winMutex); } else { pthread_mutex_unlock(&winMutex); } } else { pthread_mutex_unlock(&winMutex); } w->Destroy(w); w->Release(w); win = NULL; w = NULL; }
static DFBResult Test_RestackWindow( IDirectFBDisplayLayer *layer, void *arg ) { int i; IDirectFBWindow *window; D_ASSERT( m_toplevel_id != 0 ); /* * Get the top level window */ _T( layer->GetWindow( layer, arg ? (unsigned long) arg : m_toplevel_id, &window ) ); /* * Lower it a few times */ for (i=0; i<2; i++) { SHOW_TEST( "Lower() #%d...", i+1 ); _T( window->Lower( window ) ); SHOW_RESULT( "...Lower() #%d done.", i+1 ); } /* * Raise it a few times */ for (i=0; i<2; i++) { SHOW_TEST( "Raise() #%d...", i+1 ); _T( window->Raise( window ) ); SHOW_RESULT( "...Raise() #%d done.", i+1 ); } /* * Lower it to the bottom */ SHOW_TEST( "LowerToBottom()..." ); _T( window->LowerToBottom( window ) ); SHOW_RESULT( "...LowerToBottom() done." ); /* * Raise it to the top */ SHOW_TEST( "RaiseToTop()..." ); _T( window->RaiseToTop( window ) ); SHOW_RESULT( "...RaiseToTop() done." ); window->Release( window ); return DFB_OK; }
static DFBResult Test_DstGeometry( IDirectFBDisplayLayer *layer, void *arg ) { int i; IDirectFBWindow *window; DFBWindowGeometry geometry; DFBDimension size; D_ASSERT( m_toplevel_id != 0 ); /* * Get the top level window */ _T( layer->GetWindow( layer, arg ? (unsigned long) arg : m_toplevel_id, &window ) ); window->GetSize( window, &size.w, &size.h ); /* * Change destination geometry */ { DFBRectangle rects[] = { { 0, 0, size.w / 2, size.h / 2 }, { size.w / 2, 0, size.w / 2, size.h / 2 }, { size.w / 2, size.h / 2, size.w / 2, size.h / 2 }, { 0, size.h / 2, size.w / 2, size.h / 2 } }; for (i=0; i<D_ARRAY_SIZE(rects); i++) { SHOW_TEST( "SetDstGeometry( %4d,%4d-%4dx%4d - [%02d] )...", DFB_RECTANGLE_VALS(&rects[i]), i ); geometry.mode = DWGM_RECTANGLE; geometry.rectangle = rects[i]; _T( window->SetDstGeometry( window, &geometry ) ); SHOW_RESULT( "...SetDstGeometry( %4d,%4d-%4dx%4d - [%02d] ) done.", DFB_RECTANGLE_VALS(&rects[i]), i ); } } SHOW_TEST( "SetDstGeometry( DEFAULT )..." ); geometry.mode = DWGM_DEFAULT; _T( window->SetDstGeometry( window, &geometry ) ); SHOW_RESULT( "...SetDstGeometry( DEFAULT ) done." ); window->Release( window ); return DFB_OK; }
static DFBResult Test_ScaleWindow( IDirectFBDisplayLayer *layer, void *arg ) { int i; IDirectFBWindow *window; DFBWindowOptions opts; DFBDimension size; D_ASSERT( m_toplevel_id != 0 ); /* * Get the top level window */ _T( layer->GetWindow( layer, arg ? (unsigned long) arg : m_toplevel_id, &window ) ); window->GetSize( window, &size.w, &size.h ); /* * Enable scaling */ _T( window->GetOptions( window, &opts ) ); _T( window->SetOptions( window, opts | DWOP_SCALE ) ); /* * Scale the window */ { DFBDimension sizes[] = { { size.w + 40, size.h }, { size.w + 40, size.h + 40 }, { size.w, size.h + 40 }, { size.w + 40, size.h - 40 }, { size.w - 40, size.h + 40 }, { size.w, size.h } }; for (i=0; i<D_ARRAY_SIZE(sizes); i++) { SHOW_TEST( "Resize( %4d,%4d - [%02d] )...", sizes[i].w, sizes[i].h, i ); _T( window->Resize( window, sizes[i].w, sizes[i].h ) ); SHOW_RESULT( "...Resize( %4d,%4d - [%02d] ) done.", sizes[i].w, sizes[i].h, i ); } } /* * Restore options */ _T( window->SetOptions( window, opts ) ); window->Release( window ); return DFB_OK; }
static DFBResult Test_MoveWindow( IDirectFBDisplayLayer *layer, void *arg ) { int i; DFBPoint pos; IDirectFBWindow *window; D_ASSERT( m_toplevel_id != 0 ); /* * Get the top level window */ _T( layer->GetWindow( layer, arg ? (unsigned long) arg : m_toplevel_id, &window ) ); window->GetPosition( window, &pos.x, &pos.y ); /* * Move the window */ { DFBPoint poss[] = { { pos.x - 40, pos.y - 40 }, { pos.x + 40, pos.y - 40 }, { pos.x + 40, pos.y + 40 }, { pos.x - 40, pos.y + 40 }, { pos.x , pos.y } }; for (i=0; i<D_ARRAY_SIZE(poss); i++) { SHOW_TEST( "MoveTo( %4d,%4d - [%02d] )...", poss[i].x, poss[i].y, i ); _T( window->MoveTo( window, poss[i].x, poss[i].y ) ); SHOW_RESULT( "...MoveTo( %4d,%4d - [%02d] ) done.", poss[i].x, poss[i].y, i ); } } window->Release( window ); return DFB_OK; }
void QDirectFBWindowSurface::setPermanentState(const QByteArray &state) { const char *ptr = state.constData(); IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer(); SurfaceFlags flags; memcpy(&flags, ptr, sizeof(SurfaceFlags)); setSurfaceFlags(flags); ptr += sizeof(SurfaceFlags); DFBWindowID id; memcpy(&id, ptr, sizeof(DFBWindowID)); if (dfbSurface) dfbSurface->Release(dfbSurface); if (id != (DFBWindowID)-1) { IDirectFBWindow *dw; layer->GetWindow(layer, id, &dw); if (dw->GetSurface(dw, &dfbSurface) != DFB_OK) dfbSurface = 0; dw->Release(dw); } else { dfbSurface = 0; } }
int main( int argc, char *argv[] ) { DFBResult ret; IDirectFB *dfb; IDirectFBDisplayLayer *layer; /* Initialize DirectFB. */ ret = DirectFBInit( &argc, &argv ); if (ret) { D_DERROR( ret, "DFBTest/Window_Surface: DirectFBInit() failed!\n" ); return ret; } /* Create super interface. */ ret = DirectFBCreate( &dfb ); if (ret) { D_DERROR( ret, "DFBTest/Window_Surface: DirectFBCreate() failed!\n" ); return ret; } dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer ); while (true) { DFBWindowDescription desc; IDirectFBWindow *window; IDirectFBSurface *surface; desc.flags = DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS; desc.posx = 150; desc.posy = 150; desc.width = 300; desc.height = 300; desc.caps = DWCAPS_ALPHACHANNEL; ret = layer->CreateWindow( layer, &desc, &window ); if (ret) { D_DERROR( ret, "DFBTest/Window_Surface: CreateWindow() failed!\n" ); return ret; } window->GetSurface( window, &surface ); D_INFO( "Created window and surface, going to release window... (in 2 seconds)\n" ); usleep( 2000000 ); D_INFO("Releasing window...\n"); window->Release( window ); D_INFO("Window released, going to release surface... (in 2 seconds)\n"); usleep( 2000000 ); D_INFO("Releasing surface...\n"); surface->Release( surface ); D_INFO("Surface released, done.\n"); usleep( 5000000 ); } /* Shutdown DirectFB. */ dfb->Release( dfb ); return ret; }
static void TestResize( IDirectFB *dfb ) { DFBResult ret; DirectThread *thread; DFBWindowDescription desc; IDirectFBDisplayLayer *layer; IDirectFBWindow *window; IDirectFBSurface *surface; DFBInputEvent evt; IDirectFBEventBuffer *keybuffer; quit = 0; /* Create an input buffer for key events */ ret = dfb->CreateInputEventBuffer( dfb, DICAPS_KEYS, DFB_FALSE, &keybuffer); if (ret) { D_DERROR( ret, "DFBTest/Resize: CreateInputBuffer() failed!\n" ); return; } ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer ); if (ret) { D_DERROR( ret, "DFBTest/Resize: Failed to get display layer!\n" ); keybuffer->Release( keybuffer ); return; } desc.flags = DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_PIXELFORMAT; desc.width = 500; desc.height = 500; desc.pixelformat = DSPF_ARGB; ret = layer->CreateWindow( layer, &desc, &window ); if (ret) { D_DERROR( ret, "DFBTest/Resize: CreateWindow() failed!\n" ); keybuffer->Release( keybuffer ); layer->Release( layer ); return; } ret = window->GetSurface( window, &surface ); if (ret) { D_DERROR( ret, "DFBTest/Resize: GetSurface() failed!\n" ); keybuffer->Release( keybuffer ); window->Release( window ); layer->Release( layer ); return; } thread = direct_thread_create( DTT_DEFAULT, TestThread, surface, "Test" ); while (!quit) { ret = window->Resize( window, 500, 400 ); if (ret) D_DERROR( ret, "DFBTest/Resize: Resize() failed!\n" ); ret = window->Resize( window, 500, 500 ); if (ret) D_DERROR( ret, "DFBTest/Resize: Resize() failed!\n" ); /* Process keybuffer */ while (keybuffer->GetEvent( keybuffer, DFB_EVENT(&evt)) == DFB_OK) { if (evt.type == DIET_KEYPRESS) { switch (DFB_LOWER_CASE(evt.key_symbol)) { case DIKS_ESCAPE: case DIKS_SMALL_Q: case DIKS_BACK: case DIKS_STOP: case DIKS_EXIT: /* Quit main loop & test thread */ quit = 1; direct_thread_join(thread); break; default: break; } } } } keybuffer->Release( keybuffer ); surface->Release( surface ); window->Release( window ); layer->Release( layer ); }