Compare commits

...

7 Commits

Author SHA1 Message Date
Vincent Torri a6915ecfc5 mimic access() behavior on Windows 2024-03-25 10:18:44 -07:00
Vincent Torri 9e5bb18af1 Eina: add eina_file_access() API
this addition is motivated by the fact that the access() API on
Windows just check if a file is read only or read/write. See

https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess?view=msvc-170#remarks

This API now also manage if a file/dir is executable or not.

On Unix, access() is just called.
2024-03-25 10:18:44 -07:00
Carsten Haitzler 11cd98e119 ecore drm2 - use last plane found not first. makes it work on rk3588
this is a temporary hack until things change a bit...
2024-02-13 14:30:04 +00:00
Carsten Haitzler ae0c1783d4 elm - remove commented printfs 2024-02-09 20:27:42 +00:00
Carsten Haitzler 35bc3f933f elm - win - fix xsd icon hint set with junk stack data and crash
fixes a crash accessing junk on stack data that was unset for netwm
icon hints.

@fix
2024-02-09 18:36:52 +00:00
Carsten Haitzler 178b786f39 elm theme - make blur effects for theme ifdefed to allow turning on
you can compile the them with edje_cc -DBLUR_WINLIST and either
-DBLUR_TITLE or -DBLUR_BEHIND options passed to edje_cc ... if you
compile it by hand. either way it makes it easier to see how to do
this for theme makers.
2024-02-04 11:54:51 +00:00
Carsten Haitzler 5aefadeef3 elm theme - fix some typos in colorclass names
this snuck through. fix the typos. thanks avlinux.

@fix
2024-01-23 20:23:20 +00:00
11 changed files with 208 additions and 26 deletions

View File

@ -337,7 +337,7 @@ color_tree {
"/fg/normal/text-preedit";
"/fg/normal/text-info";
"/fg/normal/text-type";
"/fg/nmormal/fileselector/pathsep";
"/fg/normal/fileselector/pathsep";
"/fg/selected/button/bar";
"/fg/normal/button-anchor";
"/fg/selected/thumb/bar";
@ -1294,7 +1294,7 @@ color_classes {
// color_class { name: "/fg/disabled/flipselector/up";
// color: 96 96 96 255; }
///////////////////////////////////////////////////////////////////////////////
// color_class { name: "/fg/nmormal/fileselector/pathsep";
// color_class { name: "/fg/normal/fileselector/pathsep";
// color: 51 153 255 255; }
///////////////////////////////////////////////////////////////////////////////
// color_class { name: "/bg/normal/button";

View File

@ -1,3 +1,13 @@
// Define this to enable a demo title blur
//#define BLUR_TITLE 1
// Define this to enable a demo blue behind everythnig - conflicts with title
//#define BLUR_BEHIND 1
// Some values used if blur is enabled
#define BLUR_FORCE_ALPHA 160
#define BLUR_TITLE_AMOUNT "32"
#define BLUR_BEHIND_AMOUNT "32"
group { name: "e/widgets/border/volume";
images.image: "shadow_circle_vert.png" COMP;
parts {
@ -164,6 +174,15 @@ group { name: "e/widgets/border/default/border";
}
}
WIN_SHAD("shadow_base", "shadow_clip", "win_shad_flat.png", 21, 21, 14, 28, 0.5)
#ifdef BLUR_BEHIND
snapshot { name: "title-blur"; mouse_events: 0;
description { state: "default" 0.0;
rel1.to: "top";
rel2.to: "bottom";
filter.code: "padding_set { 0 } blur { "BLUR_BEHIND_AMOUNT", color = '#ffff' }";
}
}
#endif
part { name: "client_clip"; type: RECT; mouse_events: 0;
description { state: "default" 0.0;
rel1.to_y: "e.swallow.client";
@ -193,12 +212,23 @@ group { name: "e/widgets/border/default/border";
rel2.offset: -1 -1;
}
}
#ifdef BLUR_TITLE
snapshot { name: "title-blur"; mouse_events: 0;
description { state: "default" 0.0;
rel.to: "top";
filter.code: "padding_set { 0 } blur { "BLUR_TITLE_AMOUNT", color = '#ffff' }";
}
}
#endif
part { name: "top"; type: RECT; mouse_events: 0;
scale: 1;
description { state: "default" 0.0;
rel2.to_y: "e.text.title";
rel2.offset: -1 2;
color_class: "/bg/normal/titlebar";
#if defined(BLUR_TITLE) || defined(BLUR_BEHIND)
color: 255 255 255 BLUR_FORCE_ALPHA;
#endif
offscale;
}
description { state: "focused" 0.0;
@ -494,6 +524,9 @@ group { name: "e/widgets/border/default/border";
description { state: "default" 0.0;
color_class: "/bg/normal/border";
rel.to: "bottom";
#if defined(BLUR_BEHIND)
color: 255 255 255 BLUR_FORCE_ALPHA;
#endif
}
description { state: "focused" 0.0;
inherit: "default" 0.0;

View File

@ -263,7 +263,7 @@ group { "efl/border"; data.item: "version" "123";
rel2.to_x: "event.minimize";
rel2.to_y: "shadow_base";
align: 0.5 0.0;
color_class: "/fg/noemal/titlebar";
color_class: "/fg/normal/titlebar";
min: 0 16;
text { font: FNBD; size: 10;
text_class: "title_bar";
@ -330,7 +330,7 @@ group { "efl/border"; data.item: "version" "123";
rel.to: "event.close";
min: 15 15; max: 15 15;
fixed: 1 1;
color_class: "/fg/noemal/titlebar/close";
color_class: "/fg/normal/titlebar/close";
}
desc { "selected";
inherit: "default";
@ -345,7 +345,7 @@ group { "efl/border"; data.item: "version" "123";
rel.to: "event.maximize";
min: 15 15; max: 15 15;
fixed: 1 1;
color_class: "/fg/noemal/titlebar/maximize";
color_class: "/fg/normal/titlebar/maximize";
}
desc { "selected";
inherit: "default";

View File

@ -6,7 +6,7 @@ group { name: "elm/entry/path/separator/default";
image.normal: "i-arrow-r";
FIXED_SIZE(15, 15)
aspect: 1.0 1.0;
color_class: "/fg/nmormal/fileselector/pathsep";
color_class: "/fg/normal/fileselector/pathsep";
}
}
}

View File

@ -1,3 +1,9 @@
// Define this to enable blur background to winlist
//#define BLUR_WINLIST 1
// Some values used if blur is enabled
#define BLUR_WINLIST_AMOUNT "48"
group { name: "e/widgets/winlist/main";
parts {
part { name: "base"; type: RECT; mouse_events: 0;
@ -270,27 +276,27 @@ group { name: "e/widgets/winlist/large/bg";
color: 255 255 255 255; // no cc
}
}
/*
#ifdef BLUR_WINLIST
snapshot { "bg_blur";
clip_to: "bg_clip";
description { state: "default" 0.0;
filter.code: "padding_set { 0 } blur { state.pos * 50, color = '#ffff' }";
filter.code: "padding_set { 0 } blur { state.pos * "BLUR_WINLIST_AMOUNT", color = '#ffff' }";
visible: 0;
}
desc { state: "visible" 0.0;
inherit: "default" 0.0;
filter.code: "padding_set { 0 } blur { (1.0 - state.pos) * 50, color = '#ffff' }";
filter.code: "padding_set { 0 } blur { (1.0 - state.pos) * "BLUR_WINLIST_AMOUNT", color = '#ffff' }";
visible: 1;
}
}
*/
#endif
part { name: "bg_darken"; type: RECT;
clip_to: "bg_clip";
description { state: "default" 0.0;
color_class: "/dim/normal/winlist/base";
}
}
/*
#ifdef BLUR_WINLIST
part { name: "shadow"; mouse_events: 0;
clip_to: "bg_clip";
description { state: "default" 0.0;
@ -298,26 +304,26 @@ group { name: "e/widgets/winlist/large/bg";
rel2.relative: 2.0 2.0;
image.normal: "screen_circular_shadow.png";
fill.smooth: 0;
color: 255 255 255 0; // no cc
visible: 0;
}
description { state: "visible" 0.0;
inherit;
rel1.relative: 0.0 0.0;
rel2.relative: 1.0 1.0;
color: 255 255 255 255; // no cc
visible: 1;
}
}
*/
#endif
}
programs {
program { signal: "e,state,visible,on"; source: "e";
action: STATE_SET "visible" 0.0;
transition: DECELERATE 0.2 USE_DURATION_FACTOR 1 CURRENT;
target: "bg_clip";
// target: "bg_blur";
// target: "shadow";
#ifdef BLUR_WINLIST
target: "bg_blur";
target: "shadow";
#endif
after: "show2";
}
program { name: "show2";
@ -327,8 +333,10 @@ group { name: "e/widgets/winlist/large/bg";
action: STATE_SET "default" 0.0;
transition: ACCELERATE 0.2 USE_DURATION_FACTOR 1 CURRENT;
target: "bg_clip";
// target: "bg_blur";
// target: "shadow";
#ifdef BLUR_WINLIST
target: "bg_blur";
target: "shadow";
#endif
after: "hide2";
}
program { name: "hide2";

View File

@ -43,7 +43,7 @@ ecore_drm2_plane_assign(Ecore_Drm2_Output *output, Ecore_Drm2_Fb *fb, int x, int
{
Eina_List *l;
Ecore_Drm2_Plane *plane;
Ecore_Drm2_Plane_State *pstate;
Ecore_Drm2_Plane_State *pstate, *pstate_chosen = NULL;
if (!_ecore_drm2_use_atomic) return NULL;
@ -68,12 +68,12 @@ ecore_drm2_plane_assign(Ecore_Drm2_Output *output, Ecore_Drm2_Fb *fb, int x, int
continue;
/* if we reach here, this FB can go on the cursor plane */
goto out;
pstate_chosen = pstate;
}
else if (pstate->type.value == DRM_PLANE_TYPE_OVERLAY)
{
/* there are no size checks for an overlay plane */
goto out;
pstate_chosen = pstate;
}
else if (pstate->type.value == DRM_PLANE_TYPE_PRIMARY)
{
@ -82,10 +82,15 @@ ecore_drm2_plane_assign(Ecore_Drm2_Output *output, Ecore_Drm2_Fb *fb, int x, int
continue;
/* if we reach here, this FB can go on the primary plane */
goto out;
pstate_chosen = pstate;
}
}
if (pstate_chosen)
{
pstate = pstate_chosen;
goto out;
}
return NULL;
out:

View File

@ -148,6 +148,21 @@ typedef enum {
EINA_FILE_REMOVE /**< This memory is to be released and any content will be lost. Subsequent accesses will succeed but return fresh memory as if accessed for the first time. This may not succeed if the filesystem does not support it. @since 1.8 */
} Eina_File_Populate;
/**
* @typedef Eina_File_Access_Mode
* @brief Type for enumeration of a file access mode.
* @details This type is used with eina_file_access(). Enumerations can be
* combined bitwise with the OR operator.
* @since 1.28
*/
typedef enum
{
EINA_FILE_ACCESS_MODE_EXIST = 0, /**< existence test: F_OK */
EINA_FILE_ACCESS_MODE_EXEC = 1 << 0, /**< exec permission: X_OK */
EINA_FILE_ACCESS_MODE_WRITE = 1 << 1, /**< write permission: W_OK */
EINA_FILE_ACCESS_MODE_READ = 1 << 2, /**< read permission: R_OK */
} Eina_File_Access_Mode;
/* Why do this? Well PATH_MAX may vary from when eina itself is compiled
* to when the app using eina is compiled. Exposing the path buffer below
* can't safely and portably vary based on how/when you compile. It should
@ -830,6 +845,30 @@ EINA_API void eina_file_statgen_enable(void);
*/
EINA_API void eina_file_statgen_disable(void);
/**
* @brief Determine the accessibility of a file or path.
*
* @param[in] path The path to check.
* @param[in] mode Access permissions to be checked, or existence test.
* @return #EINA_TRUE it @p path satisfies the tests, #EINA_FALSE otherwise.
*
* On Linux, this function just calls the access() function. On Windows, it
* mimics as best as possible the behavior of access():
* - Existence is always checked.
* - As on Windows, a file is either read only or read/write, read permission
* is equivalent to existence. so Write permission is equivalent to not
* being read only.
* - A directory is always executable, except if greater privilege is needed.
*
* The @p mode has the same values than F_OK, X_OK, W_OK and R_OK, and the
* usage is the same than the access() function.
*
* If @p path is NULL or the epty string, this function returns #EINA_FALSE.
*
* @since 1.28
*/
EINA_API Eina_Bool eina_file_access(const char *path, Eina_File_Access_Mode mode);
/**
* @}
*/

View File

@ -1573,3 +1573,13 @@ eina_file_mkdtemp(const char *templatename, Eina_Tmpstr **path)
if (path) *path = eina_tmpstr_add(tmpdirname);
return EINA_TRUE;
}
EINA_API Eina_Bool
eina_file_access(const char *path, Eina_File_Access_Mode mode)
{
if (!path || !*path)
return EINA_FALSE;
return access(path, mode) == 0;
}

View File

@ -1286,3 +1286,48 @@ eina_file_mkdtemp(const char *templatename, Eina_Tmpstr **path)
if (path) *path = eina_tmpstr_add(tmpdirname);
return EINA_TRUE;
}
EINA_API Eina_Bool
eina_file_access(const char *path, Eina_File_Access_Mode mode)
{
DWORD attr;
if (!path || !*path)
return EINA_FALSE;
if ((mode != EINA_FILE_ACCESS_MODE_EXIST) &&
((mode >> 3) != 0))
return EINA_FALSE;
/*
* Always check for existence for both files and directories
*/
attr = GetFileAttributes(path);
if (attr == INVALID_FILE_ATTRIBUTES)
return EINA_FALSE;
/*
* On Windows a file or path is either read/write or read only.
* So if it exists, it has at least read access.
* So do something only if mode is EXEC or WRITE
*/
if (mode & EINA_FILE_ACCESS_MODE_EXEC)
{
if (!(attr & FILE_ATTRIBUTE_DIRECTORY) &&
!eina_str_has_extension(path, ".exe") &&
!eina_str_has_extension(path, ".bat"))
return EINA_FALSE;
}
if (mode & EINA_FILE_ACCESS_MODE_WRITE)
{
if (attr == INVALID_FILE_ATTRIBUTES)
return EINA_FALSE;
if (attr & FILE_ATTRIBUTE_READONLY)
return EINA_FALSE;
}
return EINA_TRUE;
}

View File

@ -3563,13 +3563,13 @@ _elm_win_xwin_update(Efl_Ui_Win_Data *sd)
if (image)
{
int w = 0, h = 0, stride, x, y;
int w = 0, h = 0, stride = 0, x, y;
Eina_Bool unmap = EINA_FALSE;
Eina_Rw_Slice sl = {};
Eina_Rw_Slice sl = { 0 };
if (efl_isa(image, EFL_CANVAS_IMAGE_CLASS))
{
Eina_Rect rect = {};
Eina_Rect rect = { 0 };
unmap = EINA_TRUE;
rect.size = efl_gfx_buffer_size_get(image);

View File

@ -897,6 +897,48 @@ EFL_START_TEST(eina_test_file_unlink)
}
EFL_END_TEST
EFL_START_TEST(eina_test_file_access)
{
typedef struct
{
const char *path;
Eina_File_Access_Mode mode;
Eina_Bool expected;
} Paths;
Paths paths[] = {
#ifdef _WIN32
{ "c:\\Windows", EINA_FILE_ACCESS_MODE_EXIST, EINA_TRUE },
{ "c:\\Windows", EINA_FILE_ACCESS_MODE_EXEC, EINA_TRUE },
{ "c:\\Windows\\notepad.exe", EINA_FILE_ACCESS_MODE_EXIST, EINA_TRUE },
{ "c:\\Windows\\notepad.exe", EINA_FILE_ACCESS_MODE_EXEC, EINA_TRUE },
{ "c:\\Windows\\notepad.exe", EINA_FILE_ACCESS_MODE_WRITE, EINA_TRUE },
{ "c:\\Windows\\notepad.exe", EINA_FILE_ACCESS_MODE_READ, EINA_TRUE },
#else
{ "/usr", EINA_FILE_ACCESS_MODE_EXIST, EINA_TRUE },
{ "/usr", EINA_FILE_ACCESS_MODE_EXEC, EINA_TRUE },
{ "/usr", EINA_FILE_ACCESS_MODE_READ, EINA_TRUE },
{ "/root", EINA_FILE_ACCESS_MODE_WRITE, EINA_FALSE },
#endif
{ NULL, EINA_FILE_ACCESS_MODE_EXIST, EINA_FALSE },
};
size_t i;
Eina_Bool result;
result = eina_file_access(NULL, EINA_FILE_ACCESS_MODE_EXIST);
fail_if(result == EINA_TRUE);
result = eina_file_access("", EINA_FILE_ACCESS_MODE_EXIST);
fail_if(result == EINA_TRUE);
for (i = 0; paths[i].path; i++)
{
result = eina_file_access(paths[i].path, paths[i].mode);
fail_if(result != paths[i].expected);
}
}
EFL_END_TEST
void
eina_test_file(TCase *tc)
{
@ -914,5 +956,5 @@ eina_test_file(TCase *tc)
tcase_add_test(tc, eina_test_file_statat);
tcase_add_test(tc, eina_test_file_mktemp);
tcase_add_test(tc, eina_test_file_unlink);
tcase_add_test(tc, eina_test_file_access);
}