Exemplo n.º 1
0
static void
_ecore_evas_fullscreen_set(Ecore_Evas *ee, Eina_Bool on)
{
   Eina_List *l;
   Ecore_Fb_Input_Device *dev;
   Ecore_Evas_Engine_FB_Data *idata = ee->engine.data;
   int resized = 0;

   if (((ee->prop.fullscreen) && (on)) ||
       ((!ee->prop.fullscreen) && (!on))) return;
   if (on)
     {
        int w, h;

        idata->real_w = ee->w;
        idata->real_h = ee->h;
        w = ee->w;
        h = ee->h;
        ecore_fb_size_get(&w, &h);
        if ((w == 0) && (h == 0))
          {
             w = ee->w;
             h = ee->h;
          }
        if ((w != ee->w) || (h != ee->h)) resized = 1;
        ee->w = w;
        ee->h = h;
        ee->req.w = ee->w;
        ee->req.h = ee->h;
        evas_output_size_set(ee->evas, ee->w, ee->h);
        evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
        evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
     }
   else
     {
        if ((idata->real_w != ee->w) || (idata->real_h != ee->h)) resized = 1;
        ee->w = idata->real_w;
        ee->h = idata->real_h;
        ee->req.w = ee->w;
        ee->req.h = ee->h;
        evas_output_size_set(ee->evas, ee->w, ee->h);
        evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
        evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
     }
   ee->prop.fullscreen = on;
   EINA_LIST_FOREACH(ecore_evas_input_devices, l, dev)
     ecore_fb_input_device_axis_size_set(dev, ee->w, ee->h);
   /* rescale the input device area */
   if (resized)
     {
        if (ee->func.fn_resize) ee->func.fn_resize(ee);
     }
}
Exemplo n.º 2
0
void EvasTargetWidget::resizeEvent(QResizeEvent *e)
{
   QSize sz;

   sz = e->size();
   evas_output_size_set(evas, sz.width(), sz.height());
}
Exemplo n.º 3
0
int
main(int argc, char **argv)
{
   int                 rot = 0;

   if ((argc >= 3) && (!strcmp(argv[1], "-rot")))
      rot = atoi(argv[2]);
   evas_init();
   evas = evas_new();
   evas_output_method_set(evas, evas_render_method_lookup("fb"));
   evas_output_size_set(evas, win_w, win_h);
   evas_output_viewport_set(evas, 0, 0, win_w, win_h);
   {
      Evas_Engine_Info_FB *einfo;

      einfo = (Evas_Engine_Info_FB *) evas_engine_info_get(evas);

      /* the following is specific to the engine */
      einfo->info.virtual_terminal = 0;
      einfo->info.device_number = 0;
      einfo->info.refresh = 0;
      einfo->info.rotation = rot;

      evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
   }
   setup();
   orig_start_time = start_time = get_time();
   for (;;)
     {
	loop();
	evas_render(evas);
     }
   evas_shutdown();
   return 0;
}
static Evas* create_canvas(int width, int height)
{
	Evas *canvas;
	Evas_Engine_Info_Buffer *einfo;
	int method;
	void *pixels;

	method = evas_render_method_lookup("buffer");
	if (unlikely(method <= 0))
	{
		//fputs("ERROR: evas was not compiled with 'buffer' engine!\n", stderr);
		return NULL;
	}

	canvas = evas_new();
	if (unlikely(canvas == NULL))
	{
		//fputs("ERROR: could not instantiate new evas canvas.\n", stderr);
		return NULL;
	}

	evas_output_method_set(canvas, method);
	evas_output_size_set(canvas, width, height);
	evas_output_viewport_set(canvas, 0, 0, width, height);

	einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(canvas);
	if (unlikely(einfo == NULL))
	{
		//fputs("ERROR: could not get evas engine info!\n", stderr);
		evas_free(canvas);
		return NULL;
	}

	// ARGB32 is sizeof(int), that is 4 bytes, per pixel
	pixels = real_malloc(width * height * sizeof(int));
	if (unlikely(pixels == NULL)) {
		//fputs("ERROR: could not allocate canvas pixels!\n", stderr);
		evas_free(canvas);
		return NULL;
	}

	einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
	einfo->info.dest_buffer = pixels;
	einfo->info.dest_buffer_row_bytes = width * sizeof(int);
	einfo->info.use_color_key = 0;
	einfo->info.alpha_threshold = 0;
	einfo->info.func.new_update_region = NULL;
	einfo->info.func.free_update_region = NULL;

	if (unlikely(evas_engine_info_set(canvas,(Evas_Engine_Info*)einfo) == EINA_FALSE)) {
		PRINTMSG("ERROR: could not set evas engine info!\n");
		evas_free(canvas);
		return NULL;
	}

	return canvas;
}
Exemplo n.º 5
0
static void
_ecore_evas_resize(Ecore_Evas *ee, int w, int h)
{
   Evas_Engine_Info_Buffer *einfo;
   Ecore_Evas_Engine_Buffer_Data *bdata = ee->engine.data;
   int stride = 0;

   if (w < 1) w = 1;
   if (h < 1) h = 1;
   ee->req.w = w;
   ee->req.h = h;
   if ((w == ee->w) && (h == ee->h)) return;
   ee->w = w;
   ee->h = h;
   evas_output_size_set(ee->evas, ee->w, ee->h);
   evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
   evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);

   if (bdata->image)
     {
        bdata->pixels = evas_object_image_data_get(bdata->image, 1);
        stride = evas_object_image_stride_get(bdata->image);
     }
   else
     {
        if (bdata->pixels)
          bdata->free_func(bdata->data, bdata->pixels);
        bdata->pixels =
          bdata->alloc_func(bdata->data, ee->w * ee->h * sizeof(int));
        stride = ee->w * sizeof(int);
     }

   einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas);
   if (einfo)
     {
        if (ee->alpha)
          einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
        else
          einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
        einfo->info.dest_buffer = bdata->pixels;
        einfo->info.dest_buffer_row_bytes = stride;
        einfo->info.use_color_key = 0;
        einfo->info.alpha_threshold = 0;
        einfo->info.func.new_update_region = NULL;
        einfo->info.func.free_update_region = NULL;
        if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
          {
             ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
          }
     }
   if (bdata->image)
     evas_object_image_data_set(bdata->image, bdata->pixels);
   else
     bdata->resized = 1;
}
Exemplo n.º 6
0
static void
_ecore_evas_move_resize(Ecore_Evas *ee, int x EINA_UNUSED, int y EINA_UNUSED, int w, int h)
{
   ee->req.w = w;
   ee->req.h = h;
   if ((w == ee->w) && (h == ee->h)) return;
   ee->w = w;
   ee->h = h;
   if (ECORE_EVAS_PORTRAIT(ee))
     {
       evas_output_size_set(ee->evas, ee->w, ee->h);
       evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
       evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
     }
   else
     {
       evas_output_size_set(ee->evas, ee->h, ee->w);
       evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
       evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w);
     }
   if (ee->func.fn_resize) ee->func.fn_resize(ee);
}
Exemplo n.º 7
0
EvasTestApp::EvasTestApp(QWidget *parent, const char *name, int wFlags)
  : QMainWindow(parent, name, wFlags)
{
   setCaption(tr("Evas Qtopia Demo"));

   evas_target_widget = new EvasTargetWidget(this, "EvasTargetWidget");

   evas_init();
   evas = evas_new();
   evas_output_method_set(evas, evas_render_method_lookup("software_qtopia"));
   evas_output_size_set(evas, win_w, win_h);
   evas_output_viewport_set(evas, 0, 0, win_w, win_h);
     {
	Evas_Engine_Info_Software_Qtopia *einfo;

	einfo = (Evas_Engine_Info_Software_Qtopia *)evas_engine_info_get(evas);

	/* the following is specific to the engine */
	einfo->info.target = evas_target_widget;
	evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
     }
   setup();
   orig_start_time = start_time = get_time();
}
Exemplo n.º 8
0
int main( int argc, char *argv[] )
{
     IDirectFB              *dfb;
     IDirectFBDisplayLayer  *layer;

     IDirectFBSurface       *bgsurface;
     IDirectFBImageProvider *provider;

     IDirectFBWindow        *window1;
     IDirectFBWindow        *window2;
     IDirectFBSurface       *window_surface1;
     IDirectFBSurface       *window_surface2;

     IDirectFBEventBuffer   *buffer;

     DFBDisplayLayerConfig  layer_config;

#if ((DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23))
     DFBCardCapabilities    caps;
#else
     DFBGraphicsDeviceDescription caps;
#endif
     IDirectFBWindow*       upper;
     DFBWindowID            id1;

     IDirectFBFont          *font;
     int fontheight;
     int err;
     int quit = 0;


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

#if ((DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23))
     dfb->GetCardCapabilities( dfb, &caps );
#else
     dfb->GetDeviceDescription( dfb, &caps );
#endif

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

     if (!((caps.blitting_flags & DSBLIT_BLEND_ALPHACHANNEL) &&
           (caps.blitting_flags & DSBLIT_BLEND_COLORALPHA  )))
     {
          layer_config.flags = DLCONF_BUFFERMODE;
          layer_config.buffermode = DLBM_BACKSYSTEM;

          layer->SetConfiguration( layer, &layer_config );
     }

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

     {
          DFBFontDescription desc;

          desc.flags = DFDESC_HEIGHT;
          desc.height = layer_config.width/50;

          DFBCHECK(dfb->CreateFont( dfb, PACKAGE_DATA_DIR"/grunge.ttf", &desc, &font ));
          font->GetHeight( font, &fontheight );
     }

     {
          DFBSurfaceDescription desc;

          DFBCHECK(dfb->CreateImageProvider( dfb,
                                             PACKAGE_DATA_DIR"/bg.png",
                                             &provider ));

          desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT;
          desc.width = layer_config.width;
          desc.height = layer_config.height;

          DFBCHECK(dfb->CreateSurface( dfb, &desc, &bgsurface ) );


          provider->RenderTo( provider, bgsurface, NULL );
          provider->Release( provider );

	  DFBCHECK(bgsurface->SetFont( bgsurface, font ));

          bgsurface->SetColor( bgsurface, 0xCF, 0xCF, 0xFF, 0xFF );
          bgsurface->DrawString( bgsurface,
                                 "Move the mouse over a window to activate it.",
                                 -1, 10, 0, DSTF_LEFT | DSTF_TOP );

          bgsurface->SetColor( bgsurface, 0xFF, 0xCF, 0xFF, 0xFF );
          bgsurface->DrawString( bgsurface,
                    "You can drag them around, too, if you want.",
                                 -1, 10 , 40, DSTF_LEFT | DSTF_TOP );

          bgsurface->SetColor( bgsurface, 0xCF, 0xCF, 0xFF, 0xFF );
	  bgsurface->DrawString( bgsurface,
                    "The one with funky stuff happening and things flying around is an evas.",
                                 -1, 10, 80, DSTF_LEFT | DSTF_TOP );




          layer->SetBackgroundImage( layer, bgsurface );
          layer->SetBackgroundMode( layer, DLBM_IMAGE );
     }
     {
	  DFBWindowDescription desc;
	  desc.flags = ( DWDESC_POSX | DWDESC_POSY |
                         DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS );

	  desc.posx = 20;
          desc.posy = 120;
          desc.width = 200;
          desc.height = 200;
	  desc.caps = DWCAPS_ALPHACHANNEL;

          DFBCHECK( layer->CreateWindow( layer, &desc, &window2 ) );
          window2->GetSurface( window2, &window_surface2 );

          window2->SetOpacity( window2, 0xFF );

          window2->CreateEventBuffer( window2, &buffer );

	  {
	     window_surface2->SetColor( window_surface2,
		   0x00, 0x30, 0x10, 0xc0 );
	     window_surface2->DrawRectangle( window_surface2, 0, 0,
		   desc.width, desc.height );
	     window_surface2->SetColor( window_surface2,
		   0x80, 0xa0, 0x00, 0x90 );
	     window_surface2->FillRectangle( window_surface2, 1, 1,
		   desc.width-2, desc.height-2 );


	     DFBCHECK(window_surface2->SetFont(window_surface2, font ));
	     window_surface2->SetColor( window_surface2, 0xCF, 0xFF, 0xCF, 0xFF );

	     window_surface2->DrawString( window_surface2,
		   "Pants!",
		   -1,10, fontheight + 5, DSTF_LEFT | DSTF_TOP );

	  }

          window_surface2->Flip( window_surface2, NULL, 0 );
     }

     {
          DFBWindowDescription desc;

          desc.flags = ( DWDESC_POSX | DWDESC_POSY |
                         DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS );
          desc.posx = 200;
          desc.posy = 200;
          desc.width = 240;
          desc.height = 320;
          desc.caps = DWCAPS_ALPHACHANNEL;

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

          window_surface1->SetColor( window_surface1, 0xFF, 0x20, 0x20, 0x90 );
          window_surface1->DrawRectangle( window_surface1, 0, 0,
                                          desc.width, desc.height );

          window_surface1->Flip( window_surface1, NULL, 0 );

          window1->SetOpacity( window1, 0xFF );

          window1->GetID( window1, &id1 );

          window1->AttachEventBuffer( window1, buffer );
     }

     window1->RequestFocus( window1 );
     window1->RaiseToTop( window1 );
     upper = window1;
     {
	evas_init();
	evas = evas_new();
	evas_output_method_set(evas, evas_render_method_lookup("directfb"));
	evas_output_size_set(evas, 240, 320);
	evas_output_viewport_set(evas, 0, 0, 240, 320);
	{
	   Evas_Engine_Info_DirectFB *einfo;

	   einfo = (Evas_Engine_Info_DirectFB *) evas_engine_info_get(evas);

	   einfo->info.dfb = dfb;
	   einfo->info.surface = window_surface1;
	   einfo->info.flags = DSDRAW_BLEND;
	   evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
	}
	setup();
	evas_render(evas);
	start_time = get_time();
     }

     while (!quit) {
          static IDirectFBWindow* active = NULL;
          static int grabbed = 0;
          static int startx = 0;
          static int starty = 0;
          static int endx = 0;
          static int endy = 0;
          DFBWindowEvent evt;

          buffer->WaitForEventWithTimeout( buffer, 0, 10 );

          while (buffer->GetEvent( buffer, DFB_EVENT(&evt) ) == DFB_OK) {
               IDirectFBWindow* window;

               if (evt.window_id == id1)
                    window = window1;
               else
                    window = window2;

               if (active) {
                    switch (evt.type) {

                    case DWET_BUTTONDOWN:
                         if (!grabbed && evt.button == DIBI_LEFT) {
                              grabbed = 1;
                              layer->GetCursorPosition( layer,
                                                        &startx, &starty );
                              window->GrabPointer( window );
                         }
                         break;

                    case DWET_BUTTONUP:
                         switch (evt.button) {
                              case DIBI_LEFT:
                                   if (grabbed) {
                                        window->UngrabPointer( window );
                                        grabbed = 0;
                                   }
                                   break;
                              case DIBI_MIDDLE:
                                   upper->LowerToBottom( upper );
                                   upper = (upper == window1) ? window2 : window1;
                                   break;
                              case DIBI_RIGHT:
                                   quit = DIKS_DOWN;
                                   break;
                              default:
                                   break;
                         }
                         break;

                    case DWET_KEYDOWN:
                         if (grabbed)
                              break;
                         switch (evt.key_id) {
                              case DIKI_RIGHT:
                                   active->Move (active, 1, 0);
                                   break;
                              case DIKI_LEFT:
                                   active->Move (active, -1, 0);
                                   break;
                              case DIKI_UP:
                                   active->Move (active, 0, -1);
                                   break;
                              case DIKI_DOWN:
                                   active->Move (active, 0, 1);
                                   break;
                              default:
                                   break;
                         }
                         break;

                    case DWET_LOSTFOCUS:
                         if (!grabbed)
                              active = NULL;
                         break;

                    default:
                         break;

                    }
               }
               else if (evt.type == DWET_GOTFOCUS)
                    active = window;

               switch (evt.type) {

               case DWET_MOTION:
                    endx = evt.cx;
                    endy = evt.cy;
                    break;

               case DWET_KEYDOWN:
                    switch (evt.key_symbol) {
                    case DIKS_ESCAPE:
                    case DIKS_SMALL_Q:
                    case DIKS_CAPITAL_Q:
                    case DIKS_BACK:
                    case DIKS_STOP:
                         quit = 1;
                         break;
                    default:
                         break;
                    }
                    break;

               default:
                    break;
               }
          }

          if (active) {
               if (grabbed) {
                    active->Move( active, endx - startx, endy - starty);
                    startx = endx;
                    starty = endy;
               }
               active->SetOpacity( active,
                                   (sin( myclock()/300.0 ) * 85) + 170 );
          }
	  loop();
	  {
	     Eina_List *updates;

	     updates = evas_render_updates(evas);
	     /* efficient update.. only flip the rectangle regions that changed! */
	     if (updates)
	       {
		  DFBRegion region;
		  Eina_List *l;

		  for (l = updates; l; l = l->next)
		    {
		       Evas_Rectangle *rect;

		       rect = l->data;
		       region.x1 = rect->x;
		       region.y1 = rect->y;
		       region.x2 = rect->x + rect->w - 1;
		       region.y2 = rect->y + rect->h - 1;
		       window_surface1->Flip(window_surface1, &region,
					     DSFLIP_BLIT);
		    }
		  evas_render_updates_free(updates);
	       }
	  }
     }

     buffer->Release( buffer );
     window_surface2->Release( window_surface2 );
     window_surface1->Release( window_surface1 );
     window2->Release( window2 );
     window1->Release( window1 );
     layer->Release( layer );
     bgsurface->Release( bgsurface );
     dfb->Release( dfb );

   evas_shutdown();
   return 0;
}
Exemplo n.º 9
0
/* external functions */
EAPI Ecore_Evas *
ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
                                    int x, int y, int w, int h, Eina_Bool frame)
{
    Ecore_Wl_Window *p = NULL;
    Evas_Engine_Info_Wayland_Egl *einfo;
    Ecore_Evas_Interface_Wayland *iface;
    Ecore_Evas_Engine_Wl_Data *wdata;
    Ecore_Evas *ee;
    int method = 0, count = 0;

    LOGFN(__FILE__, __LINE__, __FUNCTION__);

    if (!(method = evas_render_method_lookup("wayland_egl")))
    {
        ERR("Render method lookup failed for Wayland_Egl");
        return NULL;
    }

    count = ecore_wl_init(disp_name);
    if (!count)
    {
        ERR("Failed to initialize Ecore_Wayland");
        return NULL;
    }
    else if (count == 1)
        ecore_wl_display_iterate();

    if (!(ee = calloc(1, sizeof(Ecore_Evas))))
    {
        ERR("Failed to allocate Ecore_Evas");
        goto ee_err;
    }

    if (!(wdata = calloc(1, sizeof(Ecore_Evas_Engine_Wl_Data))))
    {
        ERR("Failed to allocate Ecore_Evas_Engine_Wl_Data");
        free(ee);
        goto ee_err;
    }

    ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);

    _ecore_evas_wl_common_init();

    ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_wl_engine_func;
    ee->engine.data = wdata;

    iface = _ecore_evas_wl_interface_new();
    ee->engine.ifaces = eina_list_append(ee->engine.ifaces, iface);

    ee->driver = "wayland_egl";
    if (disp_name) ee->name = strdup(disp_name);

    if (w < 1) w = 1;
    if (h < 1) h = 1;

    ee->x = x;
    ee->y = y;
    ee->w = w;
    ee->h = h;
    ee->req.x = ee->x;
    ee->req.y = ee->y;
    ee->req.w = ee->w;
    ee->req.h = ee->h;
    ee->rotation = 0;
    ee->prop.max.w = 32767;
    ee->prop.max.h = 32767;
    ee->prop.layer = 4;
    ee->prop.request_pos = 0;
    ee->prop.sticky = 0;
    ee->prop.draw_frame = frame;
    ee->alpha = EINA_FALSE;

    ee->evas = evas_new();
    evas_data_attach_set(ee->evas, ee);
    evas_output_method_set(ee->evas, method);
    evas_output_size_set(ee->evas, ee->w, ee->h);
    evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);

    /* FIXME: This needs to be set based on theme & scale */
    if (ee->prop.draw_frame)
        evas_output_framespace_set(ee->evas, 4, 18, 8, 22);

    if (parent)
        p = ecore_wl_window_find(parent);

    /* FIXME: Get if parent is alpha, and set */

    wdata->parent = p;
    wdata->win =
        ecore_wl_window_new(p, x, y, w, h, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW);
    ee->prop.window = wdata->win->id;

    if ((einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas)))
    {
        einfo->info.display = ecore_wl_display_get();
        einfo->info.destination_alpha = ee->alpha;
        einfo->info.rotation = ee->rotation;
        einfo->info.depth = 32;
        if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
        {
            ERR("Failed to set Evas Engine Info for '%s'", ee->driver);
            goto err;
        }
    }
    else
    {
        ERR("Failed to get Evas Engine Info for '%s'", ee->driver);
        goto err;
    }

    ecore_evas_callback_pre_free_set(ee, _ecore_evas_wl_common_pre_free);

    if (ee->prop.draw_frame)
    {
        wdata->frame = _ecore_evas_wl_common_frame_add(ee->evas);
        evas_object_is_frame_object_set(wdata->frame, EINA_TRUE);
        evas_object_move(wdata->frame, 0, 0);
    }

    _ecore_evas_register(ee);
    ecore_evas_input_event_register(ee);

    ecore_event_window_register(ee->prop.window, ee, ee->evas,
                                (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
                                (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
                                (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
                                (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);

    return ee;

err:
    ecore_evas_free(ee);
    _ecore_evas_wl_common_shutdown();

ee_err:
    ecore_wl_shutdown();
    return NULL;
}
Exemplo n.º 10
0
static void
_ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h)
{
    Ecore_Evas_Engine_Wl_Data *wdata;
    LOGFN(__FILE__, __LINE__, __FUNCTION__);

    if (!ee) return;
    if (w < 1) w = 1;
    if (h < 1) h = 1;

    ee->req.w = w;
    ee->req.h = h;

    wdata = ee->engine.data;
    if (!ee->prop.fullscreen)
    {
        int fw = 0, fh = 0;

        if (ee->prop.min.w > w) w = ee->prop.min.w;
        else if (w > ee->prop.max.w) w = ee->prop.max.w;
        if (ee->prop.min.h > h) h = ee->prop.min.h;
        else if (h > ee->prop.max.h) h = ee->prop.max.h;

        evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh);
        w += fw;
        h += fh;
    }

    if ((ee->w != w) || (ee->h != h))
    {
        ee->w = w;
        ee->h = h;

        if ((ee->rotation == 90) || (ee->rotation == 270))
        {
            evas_output_size_set(ee->evas, h, w);
            evas_output_viewport_set(ee->evas, 0, 0, h, w);
        }
        else
        {
            evas_output_size_set(ee->evas, w, h);
            evas_output_viewport_set(ee->evas, 0, 0, w, h);
        }

        if (ee->prop.avoid_damage)
        {
            int pdam = 0;

            pdam = ecore_evas_avoid_damage_get(ee);
            ecore_evas_avoid_damage_set(ee, 0);
            ecore_evas_avoid_damage_set(ee, pdam);
        }

        if (wdata->frame)
            evas_object_resize(wdata->frame, w, h);


        if (wdata->win)
        {
            ecore_wl_window_update_size(wdata->win, w, h);
            ecore_wl_window_buffer_attach(wdata->win, NULL, 0, 0);
        }

        if (ee->func.fn_resize) ee->func.fn_resize(ee);
    }
}
Exemplo n.º 11
0
static LRESULT CALLBACK
MainWndProc(HWND   hwnd,
            UINT   uMsg,
            WPARAM wParam,
            LPARAM lParam)
{
   switch (uMsg)
     {
     case WM_CREATE:
       return 0;
     case WM_DESTROY:
       PostQuitMessage(0);
       return 0;
     case WM_CLOSE:
       PostQuitMessage(0);
       return 0;
     case WM_WINDOWPOSCHANGED: {
       PAINTSTRUCT ps;
       HDC hdc;

       hdc = BeginPaint (window, &ps);
       evas_damage_rectangle_add(evas,
                                 ps.rcPaint.left, ps.rcPaint.top,
                                 ps.rcPaint.right - ps.rcPaint.left,
                                 ps.rcPaint.bottom - ps.rcPaint.top);
       EndPaint(window, &ps);
       return 0;
     }
     case WM_SIZING:
       {
          PRECT rect = (PRECT)lParam;

          evas_output_viewport_set(evas, 0, 0,
                                   rect->right - rect->left,
                                   rect->bottom - rect->top);
          evas_output_size_set(evas,
                               rect->right - rect->left,
                               rect->bottom - rect->top);
          win_w = rect->right - rect->left;
          win_h = rect->bottom - rect->top;
          return 0;
       }
     case WM_RBUTTONDOWN:
       evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
       evas_event_feed_mouse_down(evas, 3, EVAS_BUTTON_NONE, 0, NULL);
       return 0;
     case WM_LBUTTONDOWN:
       evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
       evas_event_feed_mouse_down(evas, 1, EVAS_BUTTON_NONE, 0, NULL);
       return 0;
     case WM_LBUTTONUP:
       evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
       evas_event_feed_mouse_up(evas, 1, EVAS_BUTTON_NONE, 0, NULL);
       return 0;
     case WM_RBUTTONUP:
       evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
       evas_event_feed_mouse_up(evas, 3, EVAS_BUTTON_NONE, 0, NULL);
       return 0;
     case WM_MOUSEMOVE:
       if (!evas_pointer_inside_get(evas)) evas_event_feed_mouse_in(evas, 0, NULL);
       evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
       return 0;
     case WM_MOUSELEAVE:
       evas_event_feed_mouse_out(evas, 0, NULL);
       return 0;
       /* FIXME : can't find an event when the mouse is entering */
     case WM_KEYDOWN:
     case WM_SYSKEYDOWN: {
        int key;

        key = LOWORD(wParam);

        if ((key == VK_SHIFT) ||
            (key == VK_LSHIFT) ||
            (key == VK_RSHIFT))
          evas_key_modifier_on(evas, "Shift");
        if ((key == VK_CONTROL) ||
            (key == VK_LCONTROL) ||
            (key == VK_RCONTROL))
          evas_key_modifier_on(evas, "Control");
        if ((key == VK_MENU) ||
            (key == VK_LMENU) ||
            (key == VK_RMENU))
          evas_key_modifier_on(evas, "Alt");
        if ((key == VK_LWIN) ||
            (key == VK_RWIN))
          evas_key_modifier_on(evas, "Super");

        if (key == VK_CAPITAL)
          {
             if (evas_key_lock_is_set(evas_key_lock_get(evas), "Caps_Lock"))
               evas_key_lock_off(evas, "Caps_Lock");
             else
               evas_key_lock_on(evas, "Caps_Lock");
          }
        if (key == VK_NUMLOCK)
          {
             if (evas_key_lock_is_set(evas_key_lock_get(evas), "Num_Lock"))
               evas_key_lock_off(evas, "Num_Lock");
             else
               evas_key_lock_on(evas, "Num_Lock");
          }
        if (key == VK_SCROLL)
          {
             if (evas_key_lock_is_set(evas_key_lock_get(evas), "Scroll_Lock"))
               evas_key_lock_off(evas, "Scroll_Lock");
             else
               evas_key_lock_on(evas, "Scroll_Lock");
          }
        if (key == VK_ESCAPE)
          evas_event_feed_key_down(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
        if (key == VK_RETURN)
          evas_event_feed_key_down(evas, "Return", "Return", NULL, NULL, 0, NULL);
        if (key == VK_LEFT)
          evas_event_feed_key_down(evas, "Left", "Left", NULL, NULL, 0, NULL);
        if (key == VK_RIGHT)
          evas_event_feed_key_down(evas, "Right", "Right", NULL, NULL, 0, NULL);
        if (key == 81)
          evas_event_feed_key_down(evas, "Q", "Q", NULL, NULL, 0, NULL);
        if (key == 113)
          evas_event_feed_key_down(evas, "q", "q", NULL, NULL, 0, NULL);
        return 0;
     }
     case WM_KEYUP:
     case WM_SYSKEYUP: {
        int key;

        key = LOWORD(wParam);

        if ((key == VK_SHIFT) ||
            (key == VK_LSHIFT) ||
            (key == VK_RSHIFT))
          evas_key_modifier_off(evas, "Shift");
        if ((key == VK_CONTROL) ||
            (key == VK_LCONTROL) ||
            (key == VK_RCONTROL))
          evas_key_modifier_off(evas, "Control");
        if ((key == VK_MENU) ||
            (key == VK_LMENU) ||
            (key == VK_RMENU))
          evas_key_modifier_off(evas, "Alt");
        if ((key == VK_LWIN) ||
            (key == VK_RWIN))
          evas_key_modifier_off(evas, "Super");
        if (key == VK_ESCAPE)
          evas_event_feed_key_up(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
        if (key == VK_RETURN)
          evas_event_feed_key_up(evas, "Return", "Return", NULL, NULL, 0, NULL);
        if (key == VK_LEFT)
          evas_event_feed_key_up(evas, "Left", "Left", NULL, NULL, 0, NULL);
        if (key == VK_RIGHT)
          evas_event_feed_key_up(evas, "Right", "Right", NULL, NULL, 0, NULL);
        if (key == 81)
          evas_event_feed_key_up(evas, "Q", "Q", NULL, NULL, 0, NULL);
        if (key == 113)
          evas_event_feed_key_up(evas, "q", "q", NULL, NULL, 0, NULL);
        return 0;
     }
     default:
       return DefWindowProc(hwnd, uMsg, wParam, lParam);
     }
}
Exemplo n.º 12
0
static void
engine_directfb_event_window(const DFBWindowEvent *ev)
{
   DBG("===> Window Event (type=%#10x, window=%d) <===\n",
       ev->type, ev->window_id);

   if (ev->type & DWET_POSITION)
     {
	DBG("\tDWET_POSITION %d, %d\n", ev->x, ev->y);
     }

   if (ev->type & DWET_SIZE)
     {
	DBG("\tDWET_SIZE %dx%d\n", ev->w, ev->h);
        evas_output_viewport_set(evas, 0, 0,
                                 ev->w, ev->h);
        evas_output_size_set(evas, ev->w, ev->h);
        win_w = ev->w;
        win_h = ev->h;
     }

   if (ev->type & DWET_CLOSE)
     {
	DBG("\tDWET_CLOSE\n");
	engine_directfb_quit();
     }

   if (ev->type & DWET_DESTROYED)
     {
	DBG("\tDWET_DESTROYED\n");
	engine_directfb_quit();
     }

   if (ev->type & DWET_GOTFOCUS)
     {
	DBG("\tDWET_GOTFOCUS\n");
     }

   if (ev->type & DWET_LOSTFOCUS)
     {
	DBG("\tDWET_LOSTFOCUS\n");
     }

   if (ev->type & DWET_KEYDOWN)
     {
	const char *k;

	k = key_string(ev->key_symbol);
	DBG("\tDWET_KEYDOWN key_symbol=%s\n", k);

	if (k)
	  evas_event_feed_key_down(evas, k, k, NULL, NULL, 0, NULL);
     }

   if (ev->type & DWET_KEYUP)
     {
	const char *k;

	k = key_string(ev->key_symbol);
	DBG("\tDWET_KEYUP key_symbol=%s\n", k);

	if (k)
	  evas_event_feed_key_up(evas, k, k, NULL, NULL, 0, NULL);
     }

   if (ev->type & DWET_BUTTONDOWN)
     {
	DBG("\tDWET_BUTTONDOWN pos=(%d, %d) cur_pos=(%d, %d) "
	    "button=%#x buttons=%#x\n",
	    ev->x, ev->y, ev->cx, ev->cy, ev->button, ev->buttons);
	evas_event_feed_mouse_move(evas, ev->cx, ev->cy, 0, NULL);
	evas_event_feed_mouse_down(evas, ev->button, EVAS_BUTTON_NONE, 0, NULL);
     }

   if (ev->type & DWET_BUTTONUP)
     {
	DBG("\tDWET_BUTTONUP pos=(%d, %d) cur_pos=(%d, %d) "
	    "button=%#x buttons=%#x\n",
	    ev->x, ev->y, ev->cx, ev->cy, ev->button, ev->buttons);
	evas_event_feed_mouse_move(evas, ev->cx, ev->cy, 0, NULL);
	evas_event_feed_mouse_up(evas, ev->button, EVAS_BUTTON_NONE, 0, NULL);
     }

   if (ev->type & DWET_MOTION)
     {
	DBG("\tDWET_MOTION pos=(%d, %d) cur_pos=(%d, %d) buttons=%#x\n",
	    ev->x, ev->y, ev->cx, ev->cy, ev->buttons);
	/* Mouse Motion Compression [tm] */
	_layer->GetCursorPosition( _layer, (int*)&ev->x, (int*)&ev->y );

	evas_event_feed_mouse_move(evas, ev->x, ev->y, 0, NULL);
     }

   if (ev->type & DWET_LEAVE)
     {
	DBG("\tDWET_LEAVE pos=(%d, %d) cur_pos=(%d, %d)\n",
	    ev->x, ev->y, ev->cx, ev->cy);
	evas_event_feed_mouse_out(evas, 0, NULL);
     }

   if (ev->type & DWET_ENTER)
     {
	DBG("\tDWET_ENTER pos=(%d, %d) cur_pos=(%d, %d)\n",
	    ev->x, ev->y, ev->cx, ev->cy);
	evas_event_feed_mouse_in(evas, 0, NULL);
     }

   if (ev->type & DWET_WHEEL)
     {
	DBG("\tDWET_WHEEL step=%d\n", ev->step);
     }


   DBG("\n");
}
Exemplo n.º 13
0
void EvasCanvas::resize( int width, int height )
{
    evas_output_size_set( o, width, height );
}
Exemplo n.º 14
0
static void
_ecore_evas_rotation_set(Ecore_Evas *ee, int rotation, int resize EINA_UNUSED)
{
   const Evas_Device *pointer;
   Ecore_Evas_Cursor *cursor;
   Evas_Engine_Info_FB *einfo;
   int rot_dif;

   pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_TYPE_MOUSE);
   pointer = evas_device_parent_get(pointer);
   cursor = eina_hash_find(ee->prop.cursors, &pointer);
   EINA_SAFETY_ON_NULL_RETURN(cursor);

   if (ee->rotation == rotation) return;
   einfo = (Evas_Engine_Info_FB *)evas_engine_info_get(ee->evas);
   if (!einfo) return;
   rot_dif = ee->rotation - rotation;
   if (rot_dif < 0) rot_dif = -rot_dif;
   if (rot_dif != 180)
     {

        einfo->info.rotation = rotation;
        if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
          {
             ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
          }
        if (!ee->prop.fullscreen)
          {
             int tmp;

             tmp = ee->w;
             ee->w = ee->h;
             ee->h = tmp;
             ee->req.w = ee->w;
             ee->req.h = ee->h;
          }
        else
          {
             if (ECORE_EVAS_PORTRAIT(ee))
               {
                  evas_output_size_set(ee->evas, ee->w, ee->h);
                  evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
               }
             else
               {
                  evas_output_size_set(ee->evas, ee->h, ee->w);
                  evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
               }
          }
        ee->rotation = rotation;
     }
   else
     {
        einfo->info.rotation = rotation;
        if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
          {
             ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
          }
        ee->rotation = rotation;
     }
   if (ECORE_EVAS_PORTRAIT(ee))
     evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
   else
     evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w);

   _ecore_evas_mouse_move_process_fb(ee, cursor->pos_x, cursor->pos_y);
   if (ee->func.fn_resize) ee->func.fn_resize(ee);
}
Exemplo n.º 15
0
void
engine_software_16_x11_loop(void)
{
   XEvent ev;
   KeySym ks;
   char *kstr;

   again:
   if (!XCheckMaskEvent(disp,
			ExposureMask |
			StructureNotifyMask |
			KeyPressMask |
			KeyReleaseMask |
			ButtonPressMask |
			ButtonReleaseMask |
			PointerMotionMask |
			EnterWindowMask |
			LeaveWindowMask, &ev))
     return;
   switch (ev.type)
     {
      case ButtonPress:
	evas_event_feed_mouse_move(evas, ev.xbutton.x, ev.xbutton.y, 0, NULL);
	evas_event_feed_mouse_down(evas, ev.xbutton.button, EVAS_BUTTON_NONE, 0, NULL);
	break;
      case ButtonRelease:
	evas_event_feed_mouse_move(evas, ev.xbutton.x, ev.xbutton.y, 0, NULL);
	evas_event_feed_mouse_up(evas, ev.xbutton.button, EVAS_BUTTON_NONE, 0, NULL);
	break;
      case MotionNotify:
	evas_event_feed_mouse_move(evas, ev.xmotion.x, ev.xmotion.y, 0, NULL);
	break;
      case Expose:
        first_expose = 1;
	evas_damage_rectangle_add(evas,
				  ev.xexpose.x,
				  ev.xexpose.y,
				  ev.xexpose.width,
				  ev.xexpose.height);
	break;
      case ConfigureNotify:
        evas_output_viewport_set(evas, 0, 0,
                                 ev.xconfigure.width,
                                 ev.xconfigure.height);
	evas_output_size_set(evas,
			     ev.xconfigure.width,
			     ev.xconfigure.height);
        win_w = ev.xconfigure.width;
        win_h = ev.xconfigure.height;
	break;
      case EnterNotify:
	evas_event_feed_mouse_in(evas, 0, NULL);
	break;
      case LeaveNotify:
	evas_event_feed_mouse_out(evas, 0, NULL);
	break;
      case KeyPress:
	ks = XKeycodeToKeysym(ev.xkey.display, ev.xkey.keycode, 0);
	kstr = XKeysymToString(ks);
	if (kstr)
	  {
	     if ((!strcmp(kstr, "Shift_L")) ||
		 (!strcmp(kstr, "Shift_R")))
	       evas_key_modifier_on(evas, "Shift");
	     if ((!strcmp(kstr, "Control_L")) ||
		 (!strcmp(kstr, "Control_R")))
	       evas_key_modifier_on(evas, "Control");
	     if ((!strcmp(kstr, "Alt_L")) ||
		 (!strcmp(kstr, "Alt_R")))
	       evas_key_modifier_on(evas, "Alt");
	     if ((!strcmp(kstr, "Super_L")) ||
		 (!strcmp(kstr, "Super_R")))
	       evas_key_modifier_on(evas, "Super");
	     if (!strcmp(kstr, "Caps_Lock"))
	       {
		  if (evas_key_lock_is_set(evas_key_lock_get(evas), "Caps_Lock"))
		    evas_key_lock_off(evas, "Caps_Lock");
		  else
		    evas_key_lock_on(evas, "Caps_Lock");
	       }
	     if (!strcmp(kstr, "Num_Lock"))
	       {
		  if (evas_key_lock_is_set(evas_key_lock_get(evas), "Num_Lock"))
		    evas_key_lock_off(evas, "Num_Lock");
		  else
		    evas_key_lock_on(evas, "Num_Lock");
	       }
	     if (!strcmp(kstr, "Scroll_Lock"))
	       {
		  if (evas_key_lock_is_set(evas_key_lock_get(evas), "Scroll_Lock"))
		    evas_key_lock_off(evas, "Scroll_Lock");
		  else
		    evas_key_lock_on(evas, "Scroll_Lock");
	       }
	     if (kstr) evas_event_feed_key_down(evas, kstr, kstr, NULL, NULL, 0, NULL);
	  }
	break;
      case KeyRelease:
	ks = XKeycodeToKeysym(ev.xkey.display, ev.xkey.keycode, 0);
	kstr = XKeysymToString(ks);
	if (kstr)
	  {
	     if ((!strcmp(kstr, "Shift_L")) ||
		 (!strcmp(kstr, "Shift_R")))
	       evas_key_modifier_off(evas, "Shift");
	     if ((!strcmp(kstr, "Control_L")) ||
		 (!strcmp(kstr, "Control_R")))
	       evas_key_modifier_off(evas, "Control");
	     if ((!strcmp(kstr, "Alt_L")) ||
		 (!strcmp(kstr, "Alt_R")))
	       evas_key_modifier_off(evas, "Alt");
	     if ((!strcmp(kstr, "Super_L")) ||
		 (!strcmp(kstr, "Super_R")))
	       evas_key_modifier_off(evas, "Super");
	     evas_event_feed_key_up(evas, kstr, kstr, NULL, NULL, 0, NULL);
	  }
	break;
      default:
	break;
     }
   goto again;
}
Exemplo n.º 16
0
void
engine_gl_sdl_loop(void)
{
   SDL_Event event;

   while(SDL_PollEvent(&event))
     {
        switch(event.type)
          {
          case SDL_MOUSEMOTION:
             evas_event_feed_mouse_move(evas, event.motion.x, event.motion.y, 0, NULL);
             break;
          case SDL_MOUSEBUTTONDOWN:
             evas_event_feed_mouse_move(evas, event.button.x, event.button.y, 0, NULL);
             evas_event_feed_mouse_down(evas, event.button.state, EVAS_BUTTON_NONE, 0, NULL);
             break;
          case SDL_MOUSEBUTTONUP:
             evas_event_feed_mouse_move(evas, event.button.x, event.button.y, 0, NULL);
             evas_event_feed_mouse_up(evas, event.button.state, EVAS_BUTTON_NONE, 0, NULL);
             break;
          case SDL_VIDEORESIZE:
             evas_output_viewport_set(evas, 0, 0,
                                      event.resize.w, event.resize.w);
             evas_output_size_set(evas, event.resize.w, event.resize.w);
             evas_output_size_get(evas, &win_w, &win_h);
             break;
          case SDL_VIDEOEXPOSE:
             evas_output_size_get(evas, &win_w, &win_h);
             evas_damage_rectangle_add(evas, 0, 0, win_w, win_h);
             break;
          case SDL_KEYDOWN:
             switch (event.key.keysym.sym)
               {
               case SDLK_LSHIFT:
               case SDLK_RSHIFT:
                  evas_key_modifier_on(evas, "Shift");
                  break;
               case SDLK_RCTRL:
               case SDLK_LCTRL:
                  evas_key_modifier_on(evas, "Control");
                  break;
               case SDLK_MENU:
               case SDLK_RALT:
               case SDLK_LALT:
                  evas_key_modifier_on(evas, "Alt");
                  break;
               case SDLK_LSUPER:
               case SDLK_RSUPER:
                  evas_key_modifier_on(evas, "Super");
                  break;
               case SDLK_CAPSLOCK:
                  if (evas_key_lock_is_set(evas_key_lock_get(evas), "Caps_Lock"))
                    evas_key_lock_off(evas, "Caps_Lock");
                  else
                    evas_key_lock_on(evas, "Caps_Lock");
                  break;
               case SDLK_NUMLOCK:
                  if (evas_key_lock_is_set(evas_key_lock_get(evas), "Num_Lock"))
                    evas_key_lock_off(evas, "Num_Lock");
                  else
                    evas_key_lock_on(evas, "Num_Lock");
                  break;
               case SDLK_SCROLLOCK:
                  if (evas_key_lock_is_set(evas_key_lock_get(evas), "Scroll_Lock"))
                    evas_key_lock_off(evas, "Scroll_Lock");
                  else
                    evas_key_lock_on(evas, "Scroll_Lock");
                  break;
               case SDLK_s:
               case SDLK_ESCAPE:
                  evas_event_feed_key_down(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
                  break;
               case SDLK_KP_ENTER:
               case SDLK_RETURN:
                  evas_event_feed_key_down(evas, "Return", "Return", NULL, NULL, 0, NULL);
                  break;
               case SDLK_LEFT: evas_event_feed_key_down(evas, "Left", "Left", NULL, NULL, 0, NULL); break;
               case SDLK_RIGHT: evas_event_feed_key_down(evas, "Right", "Right", NULL, NULL, 0, NULL); break;
               case SDLK_q:
                  if (evas_key_lock_is_set(evas_key_lock_get(evas), "Caps_Lock"))
                    evas_event_feed_key_down(evas, "Q", "Q", NULL, NULL, 0, NULL);
                  else
                    evas_event_feed_key_down(evas, "q", "q", NULL, NULL, 0, NULL);
                  break;
	       default:
		  break;
               }
             break;
          case SDL_KEYUP:
             switch (event.key.keysym.sym)
               {
               case SDLK_LSHIFT:
               case SDLK_RSHIFT:
                  evas_key_modifier_off(evas, "Shift");
                  break;
               case SDLK_RCTRL:
               case SDLK_LCTRL:
                  evas_key_modifier_off(evas, "Control");
                  break;
               case SDLK_MENU:
               case SDLK_RALT:
               case SDLK_LALT:
                  evas_key_modifier_off(evas, "Alt");
                  break;
               case SDLK_LSUPER:
               case SDLK_RSUPER:
                  evas_key_modifier_off(evas, "Super");
                  break;
               case SDLK_ESCAPE: evas_event_feed_key_up(evas, "Escape", "Escape", NULL, NULL, 0, NULL); break;
               case SDLK_RETURN: evas_event_feed_key_up(evas, "Return", "Return", NULL, NULL, 0, NULL); break;
               case SDLK_LEFT: evas_event_feed_key_up(evas, "Left", "Left", NULL, NULL, 0, NULL); break;
               case SDLK_RIGHT: evas_event_feed_key_up(evas, "Right", "Right", NULL, NULL, 0, NULL); break;
               case SDLK_q:
                  if (evas_key_lock_is_set(evas_key_lock_get(evas), "Caps_Lock"))
                    evas_event_feed_key_up(evas, "Q", "Q", NULL, NULL, 0, NULL);
                  else
                    evas_event_feed_key_up(evas, "q", "q", NULL, NULL, 0, NULL);
                  break;
	       default:
		  break;
               }
             break;
          case SDL_QUIT:
          case SDL_SYSWMEVENT:
          case SDL_USEREVENT:
          case SDL_ACTIVEEVENT:
          case SDL_JOYAXISMOTION:
          case SDL_JOYBALLMOTION:
          case SDL_JOYHATMOTION:
          case SDL_JOYBUTTONDOWN:
          case SDL_JOYBUTTONUP:
          default:
             break;
          }
     }
}
Exemplo n.º 17
0
int
main(int argc, char **argv)
{
   WNDCLASS            wc;
   RECT                rect;
   HINSTANCE           hinstance;
   MSG                 msg;
   HWND                window;
   LPDIRECTDRAW        object;
   LPDIRECTDRAWSURFACE surface_primary;
   LPDIRECTDRAWSURFACE surface_back;
   int                 depth;
   int                 running;
   int                 pause_me = 0;

   hinstance = GetModuleHandle(0);

   wc.style = 0;
   wc.lpfnWndProc = MainWndProc;
   wc.cbClsExtra = 0;
   wc.cbWndExtra = 0;
   wc.hInstance = hinstance;
   wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
   wc.hCursor = LoadCursor (NULL, IDC_ARROW);
   wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
   wc.lpszMenuName =  NULL;
   wc.lpszClassName = "Evas_Software_DDraw_Test";

   if(!RegisterClass(&wc)) return EXIT_FAILURE;

   rect.left = 0;
   rect.top = 0;
   rect.right = win_w;
   rect.bottom = win_h;
   AdjustWindowRect (&rect, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, FALSE);

   window = CreateWindowEx(0,
			   "Evas_Software_DDraw_Test",
			   "Evas_Software_DDraw_Test",
			   WS_OVERLAPPEDWINDOW | WS_SIZEBOX,
			   CW_USEDEFAULT, CW_USEDEFAULT,
                           rect.right - rect.left, rect.bottom - rect.top,
			   NULL, NULL, hinstance, NULL);
   if (!window) return EXIT_FAILURE;

   if (!_directdraw_init(window,
			 &object,
			 &surface_primary,
			 &surface_back,
			 &depth, win_w, win_h))
     return EXIT_FAILURE;

   ShowWindow(window, SW_SHOWDEFAULT);
   UpdateWindow(window);

   /* test evas_free....  :) */
   evas_init();
   evas = evas_new();
   evas_output_method_set(evas, evas_render_method_lookup("software_ddraw"));
   evas_output_size_set(evas, win_w, win_h);
   evas_output_viewport_set(evas, 0, 0, win_w, win_h);
   {
      Evas_Engine_Info_Software_DDraw *einfo;

      einfo = (Evas_Engine_Info_Software_DDraw *)evas_engine_info_get(evas);

      /* the following is specific to the engine */
      einfo->info.window = window;
      einfo->info.object = object;
      einfo->info.surface_primary = surface_primary;
      einfo->info.surface_back = surface_back;
      einfo->info.depth = depth;
      einfo->info.rotation = 0;
      evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
   }
   setup();
   printf("################ evas free\n");
   setdown();
   evas_free(evas);
   printf("evas freed. DONE\n");

   evas = evas_new();
   evas_output_method_set(evas, evas_render_method_lookup("software_ddraw"));
   evas_output_size_set(evas, win_w, win_h);
   evas_output_viewport_set(evas, 0, 0, win_w, win_h);
   {
      Evas_Engine_Info_Software_DDraw *einfo;

      einfo = (Evas_Engine_Info_Software_DDraw *) evas_engine_info_get(evas);

      /* the following is specific to the engine */
      einfo->info.window = window;
      einfo->info.object = object;
      einfo->info.surface_primary = surface_primary;
      einfo->info.surface_back = surface_back;
      einfo->info.depth = depth;
      einfo->info.rotation = 0;
      evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
   }
   setup();
   printf("################ evas free\n");
   setdown();
   evas_free(evas);
   printf("evas freed. DONE\n");

   evas = evas_new();
   evas_output_method_set(evas, evas_render_method_lookup("software_ddraw"));
   evas_output_size_set(evas, win_w, win_h);
   evas_output_viewport_set(evas, 0, 0, win_w, win_h);
   {
      Evas_Engine_Info_Software_DDraw *einfo;

      einfo = (Evas_Engine_Info_Software_DDraw *) evas_engine_info_get(evas);

      /* the following is specific to the engine */
      einfo->info.window = window;
      einfo->info.object = object;
      einfo->info.surface_primary = surface_primary;
      einfo->info.surface_back = surface_back;
      einfo->info.depth = depth;
      einfo->info.rotation = 0;
      evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
   }
   setup();
   printf("################ evas free\n");
   setdown();
   evas_free(evas);
   printf("evas freed. DONE\n");

   evas = evas_new();
   evas_output_method_set(evas, evas_render_method_lookup("software_ddraw"));
   evas_output_size_set(evas, win_w, win_h);
   evas_output_viewport_set(evas, 0, 0, win_w, win_h);
   {
      Evas_Engine_Info_Software_DDraw *einfo;

      einfo = (Evas_Engine_Info_Software_DDraw *) evas_engine_info_get(evas);

      /* the following is specific to the engine */
      einfo->info.window = window;
      einfo->info.object = object;
      einfo->info.surface_primary = surface_primary;
      einfo->info.surface_back = surface_back;
      einfo->info.depth = depth;
      einfo->info.rotation = 0;
      evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
   }
   setup();
   printf("################ evas free\n");
   setdown();
   evas_free(evas);
   printf("evas freed. DONE\n");

   evas = evas_new();
   evas_output_method_set(evas, evas_render_method_lookup("software_ddraw"));
   evas_output_size_set(evas, win_w, win_h);
   evas_output_viewport_set(evas, 0, 0, win_w, win_h);
   {
      Evas_Engine_Info_Software_DDraw *einfo;

      einfo = (Evas_Engine_Info_Software_DDraw *) evas_engine_info_get(evas);

      /* the following is specific to the engine */
      einfo->info.window = window;
      einfo->info.object = object;
      einfo->info.surface_primary = surface_primary;
      einfo->info.surface_back = surface_back;
      einfo->info.depth = depth;
      einfo->info.rotation = 0;
      evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
   }
   setup();
   orig_start_time = start_time = get_time();

   running = 1;
   while (running)
     {
        while (PeekMessage (&msg, window, 0, 0, PM_NOREMOVE))
	  {
	     int res;

	     res = GetMessage (&msg, NULL, 0, 0);
	     TranslateMessage (&msg);
	     DispatchMessage (&msg);
	     if (res == 0)
	       running = 0;
	  }
	if (!(pause_me == 1))
	  {
	     loop();
	     evas_render(evas);
	  }
     }

 exit:
   setdown();
   evas_free(evas);
   if (surface_primary)
     IDirectDrawSurface7_Release (surface_primary);
   if (object)
      IDirectDraw7_Release (object);
   evas_shutdown();

   return EXIT_SUCCESS;
}