static struct graphics_device * directfb_init_device (void) { struct graphics_device *gd; DFBDeviceData *data; IDirectFBWindow *window; DFBWindowDescription desc; desc.flags = (DFBWindowDescriptionFlags)(DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY); desc.width = directfb_driver.x; desc.height = directfb_driver.y; desc.posx = 0; desc.posy = 0; retry: if (layer->CreateWindow (layer, &desc, &window) != DFB_OK) { if (out_of_memory(MF_GPI, NULL, 0)) goto retry; return NULL; } gd = mem_alloc (sizeof (struct graphics_device)); gd->size.x1 = 0; gd->size.y1 = 0; window->GetSize (window, &gd->size.x2, &gd->size.y2); gd->clip = gd->size; data = mem_alloc (sizeof (DFBDeviceData)); data->window = window; data->flip_pending = 0; if (arrow) window->SetCursorShape (window, arrow, arrow_hot_x, arrow_hot_y); window->GetSurface (window, &data->surface); window->GetID (window, &data->id); gd->driver_data = data; gd->user_data = NULL; directfb_add_to_table (gd); window->AttachEventBuffer (window, events); window->SetOpacity (window, FOCUSED_OPACITY); return gd; }
static DFBResult Test_CreateSubWindow( IDirectFBDisplayLayer *layer, void *arg ) { IDirectFBWindow *window; DFBWindowID window_id; DFBDimension size = { m_desc_sub.width, m_desc_sub.height }; D_ASSERT( m_toplevel_id != 0 ); /* Write window ID of top level into description */ m_desc_sub.toplevel_id = m_toplevel_id; /* * Create a new sub window with 75% width/height and positioned at 20,20 within top level window */ SHOW_TEST( "CreateWindow( %d,%d - %dx%d %s + toplevel ID %u, options 0x%08x )...", m_desc_sub.posx, m_desc_sub.posy, m_desc_sub.width, m_desc_sub.height, dfb_pixelformat_name( m_desc_sub.pixelformat ), m_desc_sub.toplevel_id, m_desc_top.options ); _T( layer->CreateWindow( layer, &m_desc_sub, &window ) ); if (m_subcolor.valid) { DFBColor c = m_subcolor.color; SHOW_INFO( " - SetColor( 0x%02x, 0x%02x, 0x%02x, 0x%02x )...", c.r, c.g, c.b, c.a ); _T( window->SetColor( window, c.r, c.g, c.b, c.a ) ); } /* * Query its surface and clear it with light gray (if not input or color only) */ if (!(m_desc_sub.caps & (DWCAPS_INPUTONLY | DWCAPS_COLOR) )) { IDirectFBSurface *surface; SHOW_INFO( " - GetSurface()..." ); _T( window->GetSurface( window, &surface ) ); SHOW_INFO( " - Clear( 0xC0, 0xC0, 0xC0, 0xFF )..." ); _T( surface->Clear( surface, 0xC0, 0xC0, 0xC0, 0xFF ) ); _T( surface->DrawRectangle( surface, 0, 0, size.w, size.h ) ); _T( surface->FillRectangle( surface, size.w / 2, 1, 1, size.h - 2 ) ); _T( surface->FillRectangle( surface, 1, size.h / 2, size.w - 2, 1 ) ); surface->Release( surface ); } /* * Show the window */ SHOW_INFO( " - SetOpacity( 255 )..." ); _T( window->SetOpacity( window, 0xff ) ); /* * Query and print ID of new window */ SHOW_INFO( " - GetID()..." ); _T( window->GetID( window, &window_id ) ); /* * Set association of new window */ if (m_desc_sub.parent_id) { SHOW_INFO( " - SetAssociation( %u )...", m_desc_sub.parent_id ); _T( window->SetAssociation( window, m_desc_sub.parent_id ) ); } /* * Set top level window ID (user hasn't specified one) */ m_subwindow_id = window_id; m_subwindow = window; SHOW_RESULT( "...CreateWindow( %d,%d - %dx%d %s + toplevel ID %u ) done. => Sub Window ID %u", m_desc_sub.posx, m_desc_sub.posy, m_desc_sub.width, m_desc_sub.height, dfb_pixelformat_name( m_desc_sub.pixelformat ), m_desc_sub.toplevel_id, window_id ); return DFB_OK; }
static struct graphics_device * directfb_init_device (void) { struct graphics_device *gd; DFBDeviceData *data; IDirectFBWindow *window; DFBWindowDescription desc; if (!dfb || !layer) return NULL; desc.flags = DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY; /*desc.width = directfb_driver.x; desc.height = directfb_driver.y; desc.posx = 0; desc.posy = 0;*/ desc.width = (int)w; desc.height = (int)h; desc.posx = (int)x; desc.posy = (int)y; if (layer->CreateWindow (layer, &desc, &window) != DFB_OK) return NULL; gd = mem_alloc (sizeof (struct graphics_device)); gd->size.x1 = 0; gd->size.y1 = 0; window->GetSize (window, &gd->size.x2, &gd->size.y2); gd->clip = gd->size; data = mem_alloc (sizeof (DFBDeviceData)); data->window = window; data->mapped = 0; data->flip_pending = 0; data->flipWindow = 0; data->ghostWindow = 0; if (arrow) window->SetCursorShape (window, arrow, arrow_hot_x, arrow_hot_y); window->GetSurface (window, &data->surface); window->GetID (window, &data->id); gd->drv = &directfb_driver; gd->driver_data = data; gd->user_data = NULL; directfb_add_to_table (gd); if (!events) { window->CreateEventBuffer (window, &events); event_timer = install_timer (20, directfb_check_events, events); } else { window->AttachEventBuffer (window, events); } return gd; }