forked from enlightenment/efl
More removal of \r
This commit is contained in:
parent
d0c0a21240
commit
61b8e2aefe
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +1,11 @@
|
|||
#ifndef _ECORE_COCOA_PRIVATE_H
|
||||
#define _ECORE_COCOA_PRIVATE_H
|
||||
|
||||
struct _Ecore_Cocoa_Window
|
||||
{
|
||||
NSWindow *window;
|
||||
unsigned int borderless : 1;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef _ECORE_COCOA_PRIVATE_H
|
||||
#define _ECORE_COCOA_PRIVATE_H
|
||||
|
||||
struct _Ecore_Cocoa_Window
|
||||
{
|
||||
NSWindow *window;
|
||||
unsigned int borderless : 1;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,306 +1,306 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
# include <process.h>
|
||||
|
||||
# include "ecore_file_private.h"
|
||||
|
||||
|
||||
typedef struct _Ecore_File_Monitor_Win32 Ecore_File_Monitor_Win32;
|
||||
typedef struct _Ecore_File_Monitor_Win32_Data Ecore_File_Monitor_Win32_Data;
|
||||
|
||||
/* 4096 = 256 * sizeof(FILE_NOTIFY_INFORMATION) */
|
||||
# define ECORE_FILE_MONITOR_WIN32_BUFFER_SIZE 4096
|
||||
# define ECORE_FILE_MONITOR_WIN32(x) ((Ecore_File_Monitor_Win32 *)(x))
|
||||
|
||||
struct _Ecore_File_Monitor_Win32_Data
|
||||
{
|
||||
char buffer[ECORE_FILE_MONITOR_WIN32_BUFFER_SIZE];
|
||||
OVERLAPPED overlapped;
|
||||
HANDLE handle;
|
||||
HANDLE event;
|
||||
Ecore_File_Monitor *monitor;
|
||||
Ecore_Win32_Handler *h;
|
||||
DWORD buf_length;
|
||||
int is_dir;
|
||||
};
|
||||
|
||||
struct _Ecore_File_Monitor_Win32
|
||||
{
|
||||
Ecore_File_Monitor monitor;
|
||||
Ecore_File_Monitor_Win32_Data *file;
|
||||
Ecore_File_Monitor_Win32_Data *dir;
|
||||
};
|
||||
|
||||
static Ecore_File_Monitor *_monitors = NULL;
|
||||
|
||||
static Eina_Bool _ecore_file_monitor_win32_cb(void *data, Ecore_Win32_Handler *wh);
|
||||
|
||||
|
||||
static Ecore_File_Monitor_Win32_Data *
|
||||
_ecore_file_monitor_win32_data_new(Ecore_File_Monitor *monitor, int type)
|
||||
{
|
||||
Ecore_File_Monitor_Win32_Data *md;
|
||||
DWORD filter;
|
||||
|
||||
md = (Ecore_File_Monitor_Win32_Data *)calloc(1, sizeof(Ecore_File_Monitor_Win32_Data));
|
||||
if (!md) return NULL;
|
||||
|
||||
md->handle = CreateFile(monitor->path,
|
||||
FILE_LIST_DIRECTORY,
|
||||
FILE_SHARE_READ |
|
||||
FILE_SHARE_WRITE,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS |
|
||||
FILE_FLAG_OVERLAPPED,
|
||||
NULL);
|
||||
if (md->handle == INVALID_HANDLE_VALUE)
|
||||
goto free_md;
|
||||
|
||||
md->event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if (!md->event)
|
||||
goto close_handle;
|
||||
|
||||
ZeroMemory (&md->overlapped, sizeof(md->overlapped));
|
||||
md->overlapped.hEvent = md->event;
|
||||
|
||||
filter = (type == 0) ? FILE_NOTIFY_CHANGE_FILE_NAME : FILE_NOTIFY_CHANGE_DIR_NAME;
|
||||
filter |=
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES |
|
||||
FILE_NOTIFY_CHANGE_SIZE |
|
||||
FILE_NOTIFY_CHANGE_LAST_WRITE |
|
||||
FILE_NOTIFY_CHANGE_LAST_ACCESS |
|
||||
FILE_NOTIFY_CHANGE_CREATION |
|
||||
FILE_NOTIFY_CHANGE_SECURITY;
|
||||
|
||||
if (!ReadDirectoryChangesW(md->handle,
|
||||
md->buffer,
|
||||
ECORE_FILE_MONITOR_WIN32_BUFFER_SIZE,
|
||||
FALSE,
|
||||
filter,
|
||||
&md->buf_length,
|
||||
&md->overlapped,
|
||||
NULL))
|
||||
goto close_event;
|
||||
|
||||
md->h = ecore_main_win32_handler_add(md->event,
|
||||
_ecore_file_monitor_win32_cb,
|
||||
md);
|
||||
if (!md->h)
|
||||
goto close_event;
|
||||
|
||||
md->monitor = monitor;
|
||||
md->is_dir = type;
|
||||
|
||||
return md;
|
||||
|
||||
close_event:
|
||||
CloseHandle(md->event);
|
||||
close_handle:
|
||||
CloseHandle(md->handle);
|
||||
free_md:
|
||||
free(md);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_ecore_file_monitor_win32_data_free(Ecore_File_Monitor_Win32_Data *md)
|
||||
{
|
||||
if (!md) return;
|
||||
|
||||
CloseHandle(md->event);
|
||||
CloseHandle (md->handle);
|
||||
free (md);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_ecore_file_monitor_win32_cb(void *data, Ecore_Win32_Handler *wh)
|
||||
{
|
||||
char filename[PATH_MAX];
|
||||
PFILE_NOTIFY_INFORMATION fni;
|
||||
Ecore_File_Monitor_Win32_Data *md;
|
||||
wchar_t *wname;
|
||||
char *name;
|
||||
DWORD filter;
|
||||
DWORD offset;
|
||||
DWORD buf_length;
|
||||
Ecore_File_Event event = ECORE_FILE_EVENT_NONE;
|
||||
|
||||
md = (Ecore_File_Monitor_Win32_Data *)data;
|
||||
|
||||
if (!GetOverlappedResult (md->handle, &md->overlapped, &buf_length, TRUE))
|
||||
return 1;
|
||||
|
||||
fni = (PFILE_NOTIFY_INFORMATION)md->buffer;
|
||||
do {
|
||||
if (!fni)
|
||||
break;
|
||||
offset = fni->NextEntryOffset;
|
||||
|
||||
wname = (wchar_t *)malloc(sizeof(wchar_t) * (fni->FileNameLength + 1));
|
||||
if (!wname)
|
||||
return 0;
|
||||
|
||||
memcpy(wname, fni->FileName, fni->FileNameLength);
|
||||
wname[fni->FileNameLength]='\0';
|
||||
name = evil_wchar_to_char(wname);
|
||||
free(wname);
|
||||
if (!name)
|
||||
return 0;
|
||||
|
||||
_snprintf(filename, PATH_MAX, "%s\\%s", md->monitor->path, name);
|
||||
free(name);
|
||||
|
||||
switch (fni->Action)
|
||||
{
|
||||
case FILE_ACTION_ADDED:
|
||||
if (md->is_dir)
|
||||
event = ECORE_FILE_EVENT_CREATED_DIRECTORY;
|
||||
else
|
||||
event = ECORE_FILE_EVENT_CREATED_FILE;
|
||||
break;
|
||||
case FILE_ACTION_REMOVED:
|
||||
if (md->is_dir)
|
||||
event = ECORE_FILE_EVENT_DELETED_DIRECTORY;
|
||||
else
|
||||
event = ECORE_FILE_EVENT_DELETED_FILE;
|
||||
break;
|
||||
case FILE_ACTION_MODIFIED:
|
||||
if (!md->is_dir)
|
||||
event = ECORE_FILE_EVENT_MODIFIED;
|
||||
break;
|
||||
case FILE_ACTION_RENAMED_OLD_NAME:
|
||||
if (md->is_dir)
|
||||
event = ECORE_FILE_EVENT_DELETED_DIRECTORY;
|
||||
else
|
||||
event = ECORE_FILE_EVENT_DELETED_FILE;
|
||||
break;
|
||||
case FILE_ACTION_RENAMED_NEW_NAME:
|
||||
if (md->is_dir)
|
||||
event = ECORE_FILE_EVENT_CREATED_DIRECTORY;
|
||||
else
|
||||
event = ECORE_FILE_EVENT_CREATED_FILE;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "unknown event\n");
|
||||
event = ECORE_FILE_EVENT_NONE;
|
||||
break;
|
||||
}
|
||||
if (event != ECORE_FILE_EVENT_NONE)
|
||||
md->monitor->func(md->monitor->data, md->monitor, event, filename);
|
||||
|
||||
fni = (PFILE_NOTIFY_INFORMATION)((LPBYTE)fni + offset);
|
||||
} while (offset);
|
||||
|
||||
filter = (md->is_dir == 0) ? FILE_NOTIFY_CHANGE_FILE_NAME : FILE_NOTIFY_CHANGE_DIR_NAME;
|
||||
filter |=
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES |
|
||||
FILE_NOTIFY_CHANGE_SIZE |
|
||||
FILE_NOTIFY_CHANGE_LAST_WRITE |
|
||||
FILE_NOTIFY_CHANGE_LAST_ACCESS |
|
||||
FILE_NOTIFY_CHANGE_CREATION |
|
||||
FILE_NOTIFY_CHANGE_SECURITY;
|
||||
|
||||
ReadDirectoryChangesW(md->handle,
|
||||
md->buffer,
|
||||
ECORE_FILE_MONITOR_WIN32_BUFFER_SIZE,
|
||||
FALSE,
|
||||
filter,
|
||||
&md->buf_length,
|
||||
&md->overlapped,
|
||||
NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
ecore_file_monitor_backend_init(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
ecore_file_monitor_backend_shutdown(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Ecore_File_Monitor *
|
||||
ecore_file_monitor_backend_add(const char *path,
|
||||
void (*func) (void *data, Ecore_File_Monitor *em,
|
||||
Ecore_File_Event event,
|
||||
const char *path),
|
||||
void *data)
|
||||
{
|
||||
Ecore_File_Monitor_Win32 *m;
|
||||
Ecore_File_Monitor *em;
|
||||
size_t len;
|
||||
|
||||
if (!path || (*path == '\0')) return NULL;
|
||||
if (!ecore_file_exists(path) || !ecore_file_is_dir(path))
|
||||
return NULL;
|
||||
if (!func) return NULL;
|
||||
|
||||
em = (Ecore_File_Monitor *)calloc(1, sizeof(Ecore_File_Monitor_Win32));
|
||||
if (!em) return NULL;
|
||||
|
||||
em->func = func;
|
||||
em->data = data;
|
||||
|
||||
em->path = strdup(path);
|
||||
if (!em->path)
|
||||
{
|
||||
free(em);
|
||||
return NULL;
|
||||
}
|
||||
len = strlen(em->path);
|
||||
if (em->path[len - 1] == '/' || em->path[len - 1] == '\\')
|
||||
em->path[len - 1] = '\0';
|
||||
|
||||
m = ECORE_FILE_MONITOR_WIN32(em);
|
||||
|
||||
m->file = _ecore_file_monitor_win32_data_new(em, 0);
|
||||
if (!m->file)
|
||||
{
|
||||
free(em->path);
|
||||
free(em);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
m->dir = _ecore_file_monitor_win32_data_new(em, 1);
|
||||
if (!m->dir)
|
||||
{
|
||||
_ecore_file_monitor_win32_data_free(m->file);
|
||||
free(em->path);
|
||||
free(em);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_monitors = ECORE_FILE_MONITOR(eina_inlist_append(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));
|
||||
|
||||
return em;
|
||||
}
|
||||
|
||||
void
|
||||
ecore_file_monitor_backend_del(Ecore_File_Monitor *em)
|
||||
{
|
||||
Ecore_File_Monitor_Win32 *m;
|
||||
|
||||
if (!em)
|
||||
return;
|
||||
|
||||
m = ECORE_FILE_MONITOR_WIN32(em);
|
||||
_ecore_file_monitor_win32_data_free(m->dir);
|
||||
_ecore_file_monitor_win32_data_free(m->file);
|
||||
free(em->path);
|
||||
free(em);
|
||||
}
|
||||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
# include <process.h>
|
||||
|
||||
# include "ecore_file_private.h"
|
||||
|
||||
|
||||
typedef struct _Ecore_File_Monitor_Win32 Ecore_File_Monitor_Win32;
|
||||
typedef struct _Ecore_File_Monitor_Win32_Data Ecore_File_Monitor_Win32_Data;
|
||||
|
||||
/* 4096 = 256 * sizeof(FILE_NOTIFY_INFORMATION) */
|
||||
# define ECORE_FILE_MONITOR_WIN32_BUFFER_SIZE 4096
|
||||
# define ECORE_FILE_MONITOR_WIN32(x) ((Ecore_File_Monitor_Win32 *)(x))
|
||||
|
||||
struct _Ecore_File_Monitor_Win32_Data
|
||||
{
|
||||
char buffer[ECORE_FILE_MONITOR_WIN32_BUFFER_SIZE];
|
||||
OVERLAPPED overlapped;
|
||||
HANDLE handle;
|
||||
HANDLE event;
|
||||
Ecore_File_Monitor *monitor;
|
||||
Ecore_Win32_Handler *h;
|
||||
DWORD buf_length;
|
||||
int is_dir;
|
||||
};
|
||||
|
||||
struct _Ecore_File_Monitor_Win32
|
||||
{
|
||||
Ecore_File_Monitor monitor;
|
||||
Ecore_File_Monitor_Win32_Data *file;
|
||||
Ecore_File_Monitor_Win32_Data *dir;
|
||||
};
|
||||
|
||||
static Ecore_File_Monitor *_monitors = NULL;
|
||||
|
||||
static Eina_Bool _ecore_file_monitor_win32_cb(void *data, Ecore_Win32_Handler *wh);
|
||||
|
||||
|
||||
static Ecore_File_Monitor_Win32_Data *
|
||||
_ecore_file_monitor_win32_data_new(Ecore_File_Monitor *monitor, int type)
|
||||
{
|
||||
Ecore_File_Monitor_Win32_Data *md;
|
||||
DWORD filter;
|
||||
|
||||
md = (Ecore_File_Monitor_Win32_Data *)calloc(1, sizeof(Ecore_File_Monitor_Win32_Data));
|
||||
if (!md) return NULL;
|
||||
|
||||
md->handle = CreateFile(monitor->path,
|
||||
FILE_LIST_DIRECTORY,
|
||||
FILE_SHARE_READ |
|
||||
FILE_SHARE_WRITE,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS |
|
||||
FILE_FLAG_OVERLAPPED,
|
||||
NULL);
|
||||
if (md->handle == INVALID_HANDLE_VALUE)
|
||||
goto free_md;
|
||||
|
||||
md->event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if (!md->event)
|
||||
goto close_handle;
|
||||
|
||||
ZeroMemory (&md->overlapped, sizeof(md->overlapped));
|
||||
md->overlapped.hEvent = md->event;
|
||||
|
||||
filter = (type == 0) ? FILE_NOTIFY_CHANGE_FILE_NAME : FILE_NOTIFY_CHANGE_DIR_NAME;
|
||||
filter |=
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES |
|
||||
FILE_NOTIFY_CHANGE_SIZE |
|
||||
FILE_NOTIFY_CHANGE_LAST_WRITE |
|
||||
FILE_NOTIFY_CHANGE_LAST_ACCESS |
|
||||
FILE_NOTIFY_CHANGE_CREATION |
|
||||
FILE_NOTIFY_CHANGE_SECURITY;
|
||||
|
||||
if (!ReadDirectoryChangesW(md->handle,
|
||||
md->buffer,
|
||||
ECORE_FILE_MONITOR_WIN32_BUFFER_SIZE,
|
||||
FALSE,
|
||||
filter,
|
||||
&md->buf_length,
|
||||
&md->overlapped,
|
||||
NULL))
|
||||
goto close_event;
|
||||
|
||||
md->h = ecore_main_win32_handler_add(md->event,
|
||||
_ecore_file_monitor_win32_cb,
|
||||
md);
|
||||
if (!md->h)
|
||||
goto close_event;
|
||||
|
||||
md->monitor = monitor;
|
||||
md->is_dir = type;
|
||||
|
||||
return md;
|
||||
|
||||
close_event:
|
||||
CloseHandle(md->event);
|
||||
close_handle:
|
||||
CloseHandle(md->handle);
|
||||
free_md:
|
||||
free(md);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_ecore_file_monitor_win32_data_free(Ecore_File_Monitor_Win32_Data *md)
|
||||
{
|
||||
if (!md) return;
|
||||
|
||||
CloseHandle(md->event);
|
||||
CloseHandle (md->handle);
|
||||
free (md);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_ecore_file_monitor_win32_cb(void *data, Ecore_Win32_Handler *wh)
|
||||
{
|
||||
char filename[PATH_MAX];
|
||||
PFILE_NOTIFY_INFORMATION fni;
|
||||
Ecore_File_Monitor_Win32_Data *md;
|
||||
wchar_t *wname;
|
||||
char *name;
|
||||
DWORD filter;
|
||||
DWORD offset;
|
||||
DWORD buf_length;
|
||||
Ecore_File_Event event = ECORE_FILE_EVENT_NONE;
|
||||
|
||||
md = (Ecore_File_Monitor_Win32_Data *)data;
|
||||
|
||||
if (!GetOverlappedResult (md->handle, &md->overlapped, &buf_length, TRUE))
|
||||
return 1;
|
||||
|
||||
fni = (PFILE_NOTIFY_INFORMATION)md->buffer;
|
||||
do {
|
||||
if (!fni)
|
||||
break;
|
||||
offset = fni->NextEntryOffset;
|
||||
|
||||
wname = (wchar_t *)malloc(sizeof(wchar_t) * (fni->FileNameLength + 1));
|
||||
if (!wname)
|
||||
return 0;
|
||||
|
||||
memcpy(wname, fni->FileName, fni->FileNameLength);
|
||||
wname[fni->FileNameLength]='\0';
|
||||
name = evil_wchar_to_char(wname);
|
||||
free(wname);
|
||||
if (!name)
|
||||
return 0;
|
||||
|
||||
_snprintf(filename, PATH_MAX, "%s\\%s", md->monitor->path, name);
|
||||
free(name);
|
||||
|
||||
switch (fni->Action)
|
||||
{
|
||||
case FILE_ACTION_ADDED:
|
||||
if (md->is_dir)
|
||||
event = ECORE_FILE_EVENT_CREATED_DIRECTORY;
|
||||
else
|
||||
event = ECORE_FILE_EVENT_CREATED_FILE;
|
||||
break;
|
||||
case FILE_ACTION_REMOVED:
|
||||
if (md->is_dir)
|
||||
event = ECORE_FILE_EVENT_DELETED_DIRECTORY;
|
||||
else
|
||||
event = ECORE_FILE_EVENT_DELETED_FILE;
|
||||
break;
|
||||
case FILE_ACTION_MODIFIED:
|
||||
if (!md->is_dir)
|
||||
event = ECORE_FILE_EVENT_MODIFIED;
|
||||
break;
|
||||
case FILE_ACTION_RENAMED_OLD_NAME:
|
||||
if (md->is_dir)
|
||||
event = ECORE_FILE_EVENT_DELETED_DIRECTORY;
|
||||
else
|
||||
event = ECORE_FILE_EVENT_DELETED_FILE;
|
||||
break;
|
||||
case FILE_ACTION_RENAMED_NEW_NAME:
|
||||
if (md->is_dir)
|
||||
event = ECORE_FILE_EVENT_CREATED_DIRECTORY;
|
||||
else
|
||||
event = ECORE_FILE_EVENT_CREATED_FILE;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "unknown event\n");
|
||||
event = ECORE_FILE_EVENT_NONE;
|
||||
break;
|
||||
}
|
||||
if (event != ECORE_FILE_EVENT_NONE)
|
||||
md->monitor->func(md->monitor->data, md->monitor, event, filename);
|
||||
|
||||
fni = (PFILE_NOTIFY_INFORMATION)((LPBYTE)fni + offset);
|
||||
} while (offset);
|
||||
|
||||
filter = (md->is_dir == 0) ? FILE_NOTIFY_CHANGE_FILE_NAME : FILE_NOTIFY_CHANGE_DIR_NAME;
|
||||
filter |=
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES |
|
||||
FILE_NOTIFY_CHANGE_SIZE |
|
||||
FILE_NOTIFY_CHANGE_LAST_WRITE |
|
||||
FILE_NOTIFY_CHANGE_LAST_ACCESS |
|
||||
FILE_NOTIFY_CHANGE_CREATION |
|
||||
FILE_NOTIFY_CHANGE_SECURITY;
|
||||
|
||||
ReadDirectoryChangesW(md->handle,
|
||||
md->buffer,
|
||||
ECORE_FILE_MONITOR_WIN32_BUFFER_SIZE,
|
||||
FALSE,
|
||||
filter,
|
||||
&md->buf_length,
|
||||
&md->overlapped,
|
||||
NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
ecore_file_monitor_backend_init(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
ecore_file_monitor_backend_shutdown(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Ecore_File_Monitor *
|
||||
ecore_file_monitor_backend_add(const char *path,
|
||||
void (*func) (void *data, Ecore_File_Monitor *em,
|
||||
Ecore_File_Event event,
|
||||
const char *path),
|
||||
void *data)
|
||||
{
|
||||
Ecore_File_Monitor_Win32 *m;
|
||||
Ecore_File_Monitor *em;
|
||||
size_t len;
|
||||
|
||||
if (!path || (*path == '\0')) return NULL;
|
||||
if (!ecore_file_exists(path) || !ecore_file_is_dir(path))
|
||||
return NULL;
|
||||
if (!func) return NULL;
|
||||
|
||||
em = (Ecore_File_Monitor *)calloc(1, sizeof(Ecore_File_Monitor_Win32));
|
||||
if (!em) return NULL;
|
||||
|
||||
em->func = func;
|
||||
em->data = data;
|
||||
|
||||
em->path = strdup(path);
|
||||
if (!em->path)
|
||||
{
|
||||
free(em);
|
||||
return NULL;
|
||||
}
|
||||
len = strlen(em->path);
|
||||
if (em->path[len - 1] == '/' || em->path[len - 1] == '\\')
|
||||
em->path[len - 1] = '\0';
|
||||
|
||||
m = ECORE_FILE_MONITOR_WIN32(em);
|
||||
|
||||
m->file = _ecore_file_monitor_win32_data_new(em, 0);
|
||||
if (!m->file)
|
||||
{
|
||||
free(em->path);
|
||||
free(em);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
m->dir = _ecore_file_monitor_win32_data_new(em, 1);
|
||||
if (!m->dir)
|
||||
{
|
||||
_ecore_file_monitor_win32_data_free(m->file);
|
||||
free(em->path);
|
||||
free(em);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_monitors = ECORE_FILE_MONITOR(eina_inlist_append(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));
|
||||
|
||||
return em;
|
||||
}
|
||||
|
||||
void
|
||||
ecore_file_monitor_backend_del(Ecore_File_Monitor *em)
|
||||
{
|
||||
Ecore_File_Monitor_Win32 *m;
|
||||
|
||||
if (!em)
|
||||
return;
|
||||
|
||||
m = ECORE_FILE_MONITOR_WIN32(em);
|
||||
_ecore_file_monitor_win32_data_free(m->dir);
|
||||
_ecore_file_monitor_win32_data_free(m->file);
|
||||
free(em->path);
|
||||
free(em);
|
||||
}
|
||||
|
|
|
@ -4465,7 +4465,7 @@ evas_object_image_is_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj
|
|||
Evas_Object_Image *o = eo_data_get(eo_obj, MY_CLASS);
|
||||
int imagew, imageh, uvw, uvh;
|
||||
void *pixels;
|
||||
Evas_Func *eng = obj->layer->evas->engine.func;
|
||||
Evas_Func *eng = obj->layer->evas->engine.func;
|
||||
int is_inside = 0;
|
||||
|
||||
/* the following code is similar to evas_object_image_render(), but doesn't
|
||||
|
@ -4539,7 +4539,7 @@ evas_object_image_is_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj
|
|||
}
|
||||
else
|
||||
{
|
||||
void *im;
|
||||
void *im;
|
||||
DATA32 *data = NULL;
|
||||
int err = 0;
|
||||
|
||||
|
@ -4547,8 +4547,8 @@ evas_object_image_is_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj
|
|||
(obj->layer->evas->engine.data.output, pixels, 0, &data, &err);
|
||||
if ((!im) || (!data) || (err))
|
||||
{
|
||||
ERR("Couldn't get image pixels %p: im=%p, data=%p, err=%d",
|
||||
pixels, im, data, err);
|
||||
ERR("Couldn't get image pixels %p: im=%p, data=%p, err=%d",
|
||||
pixels, im, data, err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -4596,13 +4596,13 @@ evas_object_image_is_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj
|
|||
*/
|
||||
{
|
||||
DATA8 alpha = 0;
|
||||
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
0, 0,
|
||||
imagew, imageh,
|
||||
obj->cur.geometry.x + ix,
|
||||
obj->cur.geometry.y + iy,
|
||||
iw, ih))
|
||||
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
0, 0,
|
||||
imagew, imageh,
|
||||
obj->cur.geometry.x + ix,
|
||||
obj->cur.geometry.y + iy,
|
||||
iw, ih))
|
||||
{
|
||||
is_inside = alpha > 0;
|
||||
dobreak_h = 1;
|
||||
|
@ -4663,9 +4663,9 @@ evas_object_image_is_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj
|
|||
inw = bl; inh = bt;
|
||||
outx = ox; outy = oy;
|
||||
outw = bsl; outh = bst;
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
{
|
||||
is_inside = alpha > 0;
|
||||
dobreak_h = 1;
|
||||
|
@ -4679,9 +4679,9 @@ evas_object_image_is_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj
|
|||
inw = imw - bl - br; inh = bt;
|
||||
outx = ox + bsl; outy = oy;
|
||||
outw = iw - bsl - bsr; outh = bst;
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
{
|
||||
is_inside = alpha > 0;
|
||||
dobreak_h = 1;
|
||||
|
@ -4694,9 +4694,9 @@ evas_object_image_is_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj
|
|||
inw = br; inh = bt;
|
||||
outx = ox + iw - bsr; outy = oy;
|
||||
outw = bsr; outh = bst;
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
{
|
||||
is_inside = alpha > 0;
|
||||
dobreak_h = 1;
|
||||
|
@ -4704,14 +4704,14 @@ evas_object_image_is_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj
|
|||
break;
|
||||
}
|
||||
// .--
|
||||
// #
|
||||
// #
|
||||
inx = 0; iny = bt;
|
||||
inw = bl; inh = imh - bt - bb;
|
||||
outx = ox; outy = oy + bst;
|
||||
outw = bsl; outh = ih - bst - bsb;
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
{
|
||||
is_inside = alpha > 0;
|
||||
dobreak_h = 1;
|
||||
|
@ -4726,9 +4726,9 @@ evas_object_image_is_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj
|
|||
inw = imw - bl - br; inh = imh - bt - bb;
|
||||
outx = ox + bsl; outy = oy + bst;
|
||||
outw = iw - bsl - bsr; outh = ih - bst - bsb;
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
{
|
||||
is_inside = alpha > 0;
|
||||
dobreak_h = 1;
|
||||
|
@ -4742,9 +4742,9 @@ evas_object_image_is_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj
|
|||
inw = br; inh = imh - bt - bb;
|
||||
outx = ox + iw - bsr; outy = oy + bst;
|
||||
outw = bsr; outh = ih - bst - bsb;
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
{
|
||||
is_inside = alpha > 0;
|
||||
dobreak_h = 1;
|
||||
|
@ -4757,9 +4757,9 @@ evas_object_image_is_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj
|
|||
inw = bl; inh = bb;
|
||||
outx = ox; outy = oy + ih - bsb;
|
||||
outw = bsl; outh = bsb;
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
{
|
||||
is_inside = alpha > 0;
|
||||
dobreak_h = 1;
|
||||
|
@ -4772,9 +4772,9 @@ evas_object_image_is_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj
|
|||
inw = imw - bl - br; inh = bb;
|
||||
outx = ox + bsl; outy = oy + ih - bsb;
|
||||
outw = iw - bsl - bsr; outh = bsb;
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
{
|
||||
is_inside = alpha > 0;
|
||||
dobreak_h = 1;
|
||||
|
@ -4787,9 +4787,9 @@ evas_object_image_is_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj
|
|||
inw = br; inh = bb;
|
||||
outx = ox + iw - bsr; outy = oy + ih - bsb;
|
||||
outw = bsr; outh = bsb;
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
if (eng->pixel_alpha_get(pixels, px, py, &alpha,
|
||||
inx, iny, inw, inh,
|
||||
outx, outy, outw, outh))
|
||||
{
|
||||
is_inside = alpha > 0;
|
||||
dobreak_h = 1;
|
||||
|
|
|
@ -905,8 +905,8 @@ struct _Evas_Func
|
|||
|
||||
/* multiple font draws */
|
||||
Eina_Bool (*multi_font_draw) (void *data, void *context, void *surface, Evas_Font_Set *font, int x, int y, int w, int h, int ow, int oh, Evas_Font_Array *texts, Eina_Bool do_async);
|
||||
|
||||
Eina_Bool (*pixel_alpha_get) (void *image, int x, int y, DATA8 *alpha, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h);
|
||||
|
||||
Eina_Bool (*pixel_alpha_get) (void *image, int x, int y, DATA8 *alpha, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h);
|
||||
};
|
||||
|
||||
struct _Evas_Image_Load_Func
|
||||
|
|
|
@ -1831,93 +1831,93 @@ eng_multi_font_draw(void *data EINA_UNUSED, void *context, void *surface, Evas_F
|
|||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
eng_pixel_alpha_get(void *image, int x, int y, DATA8 *alpha, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h)
|
||||
{
|
||||
RGBA_Image *im = image;
|
||||
int px, py, dx, dy, sx, sy, src_w, src_h;
|
||||
double scale_w, scale_h;
|
||||
|
||||
if (!im) return EINA_FALSE;
|
||||
|
||||
if ((dst_region_x > x) || (x >= (dst_region_x + dst_region_w)) ||
|
||||
(dst_region_y > y) || (y >= (dst_region_y + dst_region_h)))
|
||||
{
|
||||
*alpha = 0;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
src_w = im->cache_entry.w;
|
||||
src_h = im->cache_entry.h;
|
||||
if ((src_w == 0) || (src_h == 0))
|
||||
{
|
||||
*alpha = 0;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EINA_SAFETY_ON_TRUE_GOTO(src_region_x < 0, error_oob);
|
||||
EINA_SAFETY_ON_TRUE_GOTO(src_region_y < 0, error_oob);
|
||||
EINA_SAFETY_ON_TRUE_GOTO(src_region_x + src_region_w > src_w, error_oob);
|
||||
EINA_SAFETY_ON_TRUE_GOTO(src_region_y + src_region_h > src_h, error_oob);
|
||||
|
||||
scale_w = (double)dst_region_w / (double)src_region_w;
|
||||
scale_h = (double)dst_region_h / (double)src_region_h;
|
||||
|
||||
/* point at destination */
|
||||
dx = x - dst_region_x;
|
||||
dy = y - dst_region_y;
|
||||
|
||||
/* point at source */
|
||||
sx = dx / scale_w;
|
||||
sy = dy / scale_h;
|
||||
|
||||
/* pixel point (translated) */
|
||||
px = src_region_x + sx;
|
||||
py = src_region_y + sy;
|
||||
EINA_SAFETY_ON_TRUE_GOTO(px >= src_w, error_oob);
|
||||
EINA_SAFETY_ON_TRUE_GOTO(py >= src_h, error_oob);
|
||||
|
||||
switch (im->cache_entry.space)
|
||||
{
|
||||
case EVAS_COLORSPACE_ARGB8888:
|
||||
{
|
||||
DATA32 *pixel;
|
||||
|
||||
#ifdef EVAS_CSERVE2
|
||||
if (evas_cserve2_use_get())
|
||||
evas_cache2_image_load_data(&im->cache_entry);
|
||||
else
|
||||
#endif
|
||||
evas_cache_image_load_data(&im->cache_entry);
|
||||
|
||||
if (!im->cache_entry.flags.loaded)
|
||||
{
|
||||
ERR("im %p has no pixels loaded yet", im);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
pixel = im->image.data;
|
||||
pixel += ((py * src_w) + px);
|
||||
*alpha = ((*pixel) >> 24) & 0xff;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ERR("Colorspace %d not supported.", im->cache_entry.space);
|
||||
*alpha = 0;
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
|
||||
error_oob:
|
||||
ERR("Invalid region src=(%d, %d, %d, %d), dst=(%d, %d, %d, %d), image=%dx%d",
|
||||
src_region_x, src_region_y, src_region_w, src_region_h,
|
||||
dst_region_x, dst_region_y, dst_region_w, dst_region_h,
|
||||
src_w, src_h);
|
||||
*alpha = 0;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
eng_pixel_alpha_get(void *image, int x, int y, DATA8 *alpha, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h)
|
||||
{
|
||||
RGBA_Image *im = image;
|
||||
int px, py, dx, dy, sx, sy, src_w, src_h;
|
||||
double scale_w, scale_h;
|
||||
|
||||
if (!im) return EINA_FALSE;
|
||||
|
||||
if ((dst_region_x > x) || (x >= (dst_region_x + dst_region_w)) ||
|
||||
(dst_region_y > y) || (y >= (dst_region_y + dst_region_h)))
|
||||
{
|
||||
*alpha = 0;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
src_w = im->cache_entry.w;
|
||||
src_h = im->cache_entry.h;
|
||||
if ((src_w == 0) || (src_h == 0))
|
||||
{
|
||||
*alpha = 0;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EINA_SAFETY_ON_TRUE_GOTO(src_region_x < 0, error_oob);
|
||||
EINA_SAFETY_ON_TRUE_GOTO(src_region_y < 0, error_oob);
|
||||
EINA_SAFETY_ON_TRUE_GOTO(src_region_x + src_region_w > src_w, error_oob);
|
||||
EINA_SAFETY_ON_TRUE_GOTO(src_region_y + src_region_h > src_h, error_oob);
|
||||
|
||||
scale_w = (double)dst_region_w / (double)src_region_w;
|
||||
scale_h = (double)dst_region_h / (double)src_region_h;
|
||||
|
||||
/* point at destination */
|
||||
dx = x - dst_region_x;
|
||||
dy = y - dst_region_y;
|
||||
|
||||
/* point at source */
|
||||
sx = dx / scale_w;
|
||||
sy = dy / scale_h;
|
||||
|
||||
/* pixel point (translated) */
|
||||
px = src_region_x + sx;
|
||||
py = src_region_y + sy;
|
||||
EINA_SAFETY_ON_TRUE_GOTO(px >= src_w, error_oob);
|
||||
EINA_SAFETY_ON_TRUE_GOTO(py >= src_h, error_oob);
|
||||
|
||||
switch (im->cache_entry.space)
|
||||
{
|
||||
case EVAS_COLORSPACE_ARGB8888:
|
||||
{
|
||||
DATA32 *pixel;
|
||||
|
||||
#ifdef EVAS_CSERVE2
|
||||
if (evas_cserve2_use_get())
|
||||
evas_cache2_image_load_data(&im->cache_entry);
|
||||
else
|
||||
#endif
|
||||
evas_cache_image_load_data(&im->cache_entry);
|
||||
|
||||
if (!im->cache_entry.flags.loaded)
|
||||
{
|
||||
ERR("im %p has no pixels loaded yet", im);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
pixel = im->image.data;
|
||||
pixel += ((py * src_w) + px);
|
||||
*alpha = ((*pixel) >> 24) & 0xff;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ERR("Colorspace %d not supported.", im->cache_entry.space);
|
||||
*alpha = 0;
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
|
||||
error_oob:
|
||||
ERR("Invalid region src=(%d, %d, %d, %d), dst=(%d, %d, %d, %d), image=%dx%d",
|
||||
src_region_x, src_region_y, src_region_w, src_region_h,
|
||||
dst_region_x, dst_region_y, dst_region_w, dst_region_h,
|
||||
src_w, src_h);
|
||||
*alpha = 0;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
eng_image_cache_flush(void *data EINA_UNUSED)
|
||||
{
|
||||
|
@ -2652,7 +2652,7 @@ static Evas_Func func =
|
|||
eng_image_animated_frame_set,
|
||||
NULL,
|
||||
eng_multi_font_draw,
|
||||
eng_pixel_alpha_get,
|
||||
eng_pixel_alpha_get,
|
||||
/* FUTURE software generic calls go here */
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue