forked from enlightenment/efl
ecore_fb_init(): use 'name' parameter similar to ecore_evas_fb_new().
Instead of assuming /dev/fb/0 or /dev/fb0, use the given 'name' parameter in a similar way to ecore_evas_fb_new(): a number to be parsed with 'strtoul()'. Without this calling ecore_evas_fb_new() or ecore_evas_new() with 'display=1' will produce incorrect results. @fix
This commit is contained in:
parent
3f84aac424
commit
806be7adc0
|
@ -4,8 +4,9 @@
|
|||
|
||||
#include "Ecore_Fb.h"
|
||||
#include "ecore_fb_private.h"
|
||||
#include <limits.h>
|
||||
|
||||
static void _ecore_fb_size_get(int *w, int *h);
|
||||
static void _ecore_fb_size_get(const char *name, int *w, int *h);
|
||||
|
||||
static int _ecore_fb_init_count = 0;
|
||||
static int _ecore_fb_console_w = 0;
|
||||
|
@ -38,7 +39,7 @@ nosigint(int val EINA_UNUSED)
|
|||
* the Ecore_Fb library.
|
||||
*/
|
||||
EAPI int
|
||||
ecore_fb_init(const char *name EINA_UNUSED)
|
||||
ecore_fb_init(const char *name)
|
||||
{
|
||||
if (++_ecore_fb_init_count != 1)
|
||||
return _ecore_fb_init_count;
|
||||
|
@ -51,7 +52,7 @@ ecore_fb_init(const char *name EINA_UNUSED)
|
|||
oldhand = signal(SIGINT, nosigint);
|
||||
}
|
||||
|
||||
_ecore_fb_size_get(&_ecore_fb_console_w, &_ecore_fb_console_h);
|
||||
_ecore_fb_size_get(name, &_ecore_fb_console_w, &_ecore_fb_console_h);
|
||||
|
||||
return _ecore_fb_init_count;
|
||||
}
|
||||
|
@ -103,7 +104,7 @@ ecore_fb_size_get(int *w, int *h)
|
|||
}
|
||||
|
||||
static void
|
||||
_ecore_fb_size_get(int *w, int *h)
|
||||
_ecore_fb_size_get(const char *name, int *w, int *h)
|
||||
{
|
||||
struct fb_var_screeninfo fb_var;
|
||||
int fb;
|
||||
|
@ -113,18 +114,40 @@ _ecore_fb_size_get(int *w, int *h)
|
|||
(getuid() == geteuid()) &&
|
||||
#endif
|
||||
(getenv("EVAS_FB_DEV")))
|
||||
{
|
||||
fb = open(getenv("EVAS_FB_DEV"), O_RDWR);
|
||||
if (fb < 0)
|
||||
fprintf(stderr, "[ecore_fb] error opening $EVAS_FB_DEV=%s: %s\n", getenv("EVAS_FB_DEV"), strerror(errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
fb = open("/dev/fb/0", O_RDWR);
|
||||
char dev[PATH_MAX];
|
||||
int device;
|
||||
|
||||
/* consistent with ecore_evas_default_display in ecore_evas_fb.c */
|
||||
if (!name) name = "0";
|
||||
|
||||
/* consistent with ecore_evas_fb.c -> evas_fb_main.c */
|
||||
device = strtol(name, NULL, 10);
|
||||
|
||||
snprintf(dev, sizeof(dev), "/dev/fb/%i", device);
|
||||
fb = open(dev, O_RDWR);
|
||||
if (fb == -1)
|
||||
fb = open("/dev/fb0", O_RDWR);
|
||||
{
|
||||
snprintf(dev, sizeof(dev), "/dev/fb%i", device);
|
||||
fb = open(dev, O_RDWR);
|
||||
if (fb < 0)
|
||||
fprintf(stderr, "[ecore_fb] error opening /dev/fb/%i and /dev/fb%i: %s\n", device, device, strerror(errno));
|
||||
}
|
||||
}
|
||||
if (fb < 0)
|
||||
goto exit;
|
||||
|
||||
if (ioctl(fb, FBIOGET_VSCREENINFO, &fb_var) == -1)
|
||||
{
|
||||
perror("[ecore_fb] ioctl FBIOGET_VSCREENINFO");
|
||||
goto err_ioctl;
|
||||
}
|
||||
|
||||
*w = fb_var.xres;
|
||||
*h = fb_var.yres;
|
||||
|
|
Loading…
Reference in New Issue