aboutsummaryrefslogblamecommitdiffstats
path: root/legacy/evas/src/lib/canvas/evas_device.c
blob: 95204be77bab90256c000713b86e324f1d2afcfe (plain) (tree)




























































































































































































































































                                                                          
#include "evas_common.h"
#include "evas_private.h"

EAPI Evas_Device *
evas_device_new(Evas *e)
{
   Evas_Device *dev;
   
   MAGIC_CHECK(e, Evas, MAGIC_EVAS);
   return NULL;
   MAGIC_CHECK_END();
   dev = calloc(1, sizeof(Evas_Device));
   if (!dev) return NULL;
   dev->magic = MAGIC_DEV;
   dev->evas = e;
   dev->ref = 1;
   e->devices = eina_list_append(e->devices, dev);
   evas_event_callback_call(e, EVAS_CALLBACK_DEVICE_CHANGED, dev);
   return dev;
}

EAPI void
evas_device_free(Evas_Device *dev)
{
   MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
   return;
   MAGIC_CHECK_END();
   if (dev->ref == 1)
     {
        Evas_Device *dev2;
        
        EINA_LIST_FREE(dev->children, dev2)
          {
             dev2->parent = NULL;
             evas_device_free(dev2);
          }
        if (dev->src)
          {
             _evas_device_unref(dev->src);
             dev->src = NULL;
          }
        dev->parent = NULL;
     }
   _evas_device_unref(dev);
}

EAPI void
evas_device_push(Evas *e, Evas_Device *dev)
{
   MAGIC_CHECK(e, Evas, MAGIC_EVAS);
   return;
   MAGIC_CHECK_END();
   MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
   return;
   MAGIC_CHECK_END();
   if (!e->cur_device)
     {
        e->cur_device = eina_array_new(4);
        if (!e->cur_device) return;
     }
   dev->ref++;
   eina_array_push(e->cur_device, dev);
}

EAPI void
evas_device_pop(Evas *e)
{
   Evas_Device *dev;
   
   MAGIC_CHECK(e, Evas, MAGIC_EVAS);
   return;
   MAGIC_CHECK_END();
   dev = eina_array_pop(e->cur_device);
   if (dev) _evas_device_unref(dev);
}

EAPI const Eina_List *
evas_device_list(Evas *e, const Evas_Device *dev)
{
   MAGIC_CHECK(e, Evas, MAGIC_EVAS);
   return NULL;
   MAGIC_CHECK_END();
   if (dev)
     {
        MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
        return NULL;
        MAGIC_CHECK_END();
     }
   if (dev) return dev->children;
   return e->devices;
}

EAPI void
evas_device_name_set(Evas_Device *dev, const char *name)
{
   MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
   return;
   MAGIC_CHECK_END();
   eina_stringshare_replace(&(dev->name), name);
   evas_event_callback_call(dev->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev);
}

EAPI const char *
evas_device_name_get(const Evas_Device *dev)
{
   MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
   return NULL;
   MAGIC_CHECK_END();
   return dev->name;
}

EAPI void
evas_device_description_set(Evas_Device *dev, const char *desc)
{
   MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
   return;
   MAGIC_CHECK_END();
   eina_stringshare_replace(&(dev->desc), desc);
   evas_event_callback_call(dev->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev);
}

EAPI const char *
evas_device_description_get(const Evas_Device *dev)
{
   MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
   return NULL;
   MAGIC_CHECK_END();
   return dev->desc;
}

EAPI void
evas_device_parent_set(Evas_Device *dev, Evas_Device *parent)
{
   MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
   return;
   MAGIC_CHECK_END();
   if (parent)
     {
        MAGIC_CHECK(parent, Evas_Device, MAGIC_DEV);
        return;
        MAGIC_CHECK_END();
     }
   if (dev->parent == parent) return;
   if (dev->parent)
     dev->parent->children = eina_list_remove(dev->parent->children, dev);
   dev->parent = parent;
   if (parent)
     parent->children = eina_list_append(parent->children, dev);
   evas_event_callback_call(dev->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev);
}

EAPI const Evas_Device *
evas_device_parent_get(const Evas_Device *dev)
{
   MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
   return NULL;
   MAGIC_CHECK_END();
   return dev->parent;
}

EAPI void
evas_device_class_set(Evas_Device *dev, Evas_Device_Class clas)
{
   MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
   return;
   MAGIC_CHECK_END();
   dev->clas = clas;
   evas_event_callback_call(dev->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev);
}

EAPI Evas_Device_Class
evas_device_class_get(const Evas_Device *dev)
{
   MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
   return EVAS_DEVICE_CLASS_NONE;
   MAGIC_CHECK_END();
   return dev->clas;
}

EAPI void
evas_device_emulation_source_set(Evas_Device *dev, Evas_Device *src)
{
   MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
   return;
   MAGIC_CHECK_END();
   if (src)
     {
        MAGIC_CHECK(src, Evas_Device, MAGIC_DEV);
        return;
        MAGIC_CHECK_END();
     }
   if (dev->src == src) return;
   if (dev->src) _evas_device_unref(dev->src);
   dev->src = src;
   if (dev->src) dev->src->ref++;
   evas_event_callback_call(dev->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev);
}

EAPI const Evas_Device *
evas_device_emulation_source_get(const Evas_Device *dev)
{
   MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
   return NULL;
   MAGIC_CHECK_END();
   return dev->src;
}

void
_evas_device_cleanup(Evas *e)
{
   Evas_Device *dev;
   
   if (e->cur_device)
     {
        while ((dev = eina_array_pop(e->cur_device)))
          _evas_device_unref(dev);
        eina_array_free(e->cur_device);
        e->cur_device = NULL;
     }
   EINA_LIST_FREE(e->devices, dev)
     {
        evas_device_free(dev);
     }
}

Evas_Device *
_evas_device_top_get(const Evas *e)
{
   int num;
   
   if (!e->cur_device) return NULL;
   num = eina_array_count(e->cur_device);
   if (num < 1) return NULL;
   return eina_array_data_get(e->cur_device, num - 1);
}

void
_evas_device_ref(Evas_Device *dev)
{
   dev->ref++;
}

void
_evas_device_unref(Evas_Device *dev)
{
   dev->ref--;
   if (dev->ref > 0) return;
   if (dev->name) eina_stringshare_del(dev->name);
   if (dev->desc) eina_stringshare_del(dev->desc);
   dev->magic = 0;
   free(dev);
}