Hello,

I have following code, which blocks the system if it startet.
What is wrong with this code?
Thanks for reply
Jens


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#include <time.h>

#include <directfb.h>
#include <directfb_util.h>
#include <directfb_version.h>

#include <direct/util.h>

static IDirectFBInputDevice *keyboard = NULL;

int main( int argc, char *argv[] )
{
     IDirectFB              *dfb;
     IDirectFBDisplayLayer  *layer;

     IDirectFBImageProvider *provider;
     IDirectFBVideoProvider *video_provider;

     IDirectFBWindow        *window1;
     IDirectFBSurface       *window_surface1;

     IDirectFBEventBuffer   *buffer;

     DFBDisplayLayerConfig         layer_config;
     DFBGraphicsDeviceDescription  gdesc;
     IDirectFBWindow*              upper;
     DFBWindowID                   id1;

int quit = 0;

     IDirectFBWindow* active = NULL;
     int grabbed = 0;

     DirectFBInit( &argc, &argv );
     DirectFBCreate( &dfb );


     dfb->GetDeviceDescription( dfb, &gdesc );

     dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer );

     layer->SetCooperativeLevel( layer, DLSCL_ADMINISTRATIVE );
     layer->GetConfiguration( layer, &layer_config );
     layer->EnableCursor ( layer, 1 );


          DFBWindowDescription desc;

          desc.flags  = ( DWDESC_POSX | DWDESC_POSY |
                          DWDESC_WIDTH | DWDESC_HEIGHT | 
                          DWDESC_CAPS | 
                          DWDESC_STACKING | DWDESC_SURFACE_CAPS );
          desc.posx   = 200;
          desc.posy   = 200;
          desc.width  = 512;
          desc.height = 145;
          desc.caps   = DWCAPS_ALPHACHANNEL;
          desc.surface_caps = DSCAPS_PREMULTIPLIED;

          layer->CreateWindow( layer, &desc, &window1 );
          window1->GetSurface( window1, &window_surface1 );

        dfb->GetInputDevice (dfb, DIDID_KEYBOARD, &keyboard);

     keyboard->CreateEventBuffer (keyboard, &buffer);

//     window1->CreateEventBuffer( window1, &buffer );

     window_surface1->Clear( window_surface1,
0xff,0xff,0xff,0xff); ////0xc0, 0xb0, 0x90, 0xFF );
     window_surface1->SetDrawingFlags( window_surface1,
DSDRAW_SRC_PREMULTIPLY );
     window_surface1->SetColor( window_surface1, 0xFF, 0x20, 0x20,
0x90 );
     window_surface1->DrawRectangle( window_surface1,
                                          0, 0, desc.width,
desc.height );

     window1->SetOpacity( window1, 0xFF );
     window1->GetID( window1, &id1 );

     upper = window1;


  while (!quit)
    {
      DFBInputEvent event;

        buffer->WaitForEvent (buffer);
      while (buffer->GetEvent (buffer, DFB_EVENT(&event)) == DFB_OK)
        {
          if (event.type == DIET_KEYPRESS)
            {
              if (event.key_id == DIKI_ESCAPE)
                quit = 1;
            }
        }
     }

ende:
//return 42;

     buffer->Release( buffer );
     window_surface1->Release( window_surface1 );
     window1->Release( window1 );
//     layer->Release( layer );
     dfb->Release( dfb );

     return 42;
}

_______________________________________________
directfb-dev mailing list
directfb-dev@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to