<commit_before>#include "e.h"

/* intercept elm_win operations so we talk directly to e_client */
#undef elm_win_add

typedef struct _Elm_Win_Trap_Ctx
{
   E_Client      *client;
   E_Pointer     *pointer;
   Eina_Bool      centered : 1;
   Eina_Bool      placed : 1;
   Eina_Bool      internal_no_remember : 1;
   Eina_Bool      internal_no_reopen : 1;
   Eina_Bool      visible : 1;
} Elm_Win_Trap_Ctx;


static void *
_e_elm_win_trap_add(Evas_Object *o)
{
   Elm_Win_Trap_Ctx *ctx = calloc(1, sizeof(Elm_Win_Trap_Ctx));
   EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, NULL);
   evas_object_name_set(o, "E_Win");
   return ctx;
}

static void
_e_elm_win_trap_del(void *data, Evas_Object *o)
{
   Elm_Win_Trap_Ctx *ctx = data;
   EINA_SAFETY_ON_NULL_RETURN(ctx);
   if (ctx->client)
     {
        evas_object_hide(ctx->client->frame);
        e_object_del(E_OBJECT(ctx->client));
        evas_object_data_set(o, "E_Client", NULL);
        ctx->client->internal_elm_win = NULL;
     }
   free(ctx);
}

static Eina_Bool
_e_elm_win_trap_hide(void *data, Evas_Object *o)
{
   Elm_Win_Trap_Ctx *ctx = data;
   EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, EINA_TRUE);
   if (!ctx->visible) return EINA_FALSE;
   if (strncmp(ecore_evas_engine_name_get(e_win_ee_get(o)), "wayland", 7))
     E_FREE_FUNC(ctx->pointer, e_object_del);

   if (!ctx->client) return EINA_TRUE;
   ctx->visible = 0;
   evas_object_hide(ctx->client->frame);
   return EINA_FALSE;
}

static Eina_Bool
_e_elm_win_trap_show(void *data, Evas_Object *o)
{
   Elm_Win_Trap_Ctx *ctx = data;
   Evas *e = evas_object_evas_get(o);
   Ecore_Evas *ee = ecore_evas_ecore_evas_get(e);

   EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, EINA_TRUE);
   if (!ctx->client)
     {
        E_Client *ec;
        Ecore_Window win;
        E_Pixmap_Type type;

        win = elm_win_window_id_get(o);
        if (!strncmp(ecore_evas_engine_name_get(ee), "wayland", 7))
          {
             type = E_PIXMAP_TYPE_WL;
             ctx->pointer = e_comp_get(NULL)->pointer;
          }
        else
          {
             type = E_PIXMAP_TYPE_X;
             ctx->pointer = e_pointer_window_new(win, EINA_TRUE);
          }

        ec = e_pixmap_find_client(type, win);
        if (ec)
          ctx->client = ec;
        else
          {
             E_Pixmap *cp;
             E_Comp *c = NULL;

             ecore_evas_name_class_set(ee, "E", "_e_internal_window");
             ecore_evas_title_set(ee, elm_win_title_get(o));
             cp = e_pixmap_new(type, win);
             EINA_SAFETY_ON_NULL_RETURN_VAL(cp, EINA_TRUE);

             /* if (eina_list_count(e_comp_list()) > 1) */
             /*   { */
/* #ifndef HAVE_WAYLAND_ONLY */
             /*      c = e_comp_find_by_window(ecore_x_window_root_get(win)); */
/* #else */
             /*      c = ; */
/* #endif */
             /*   } */

             if (!c)
               c = e_comp_get(NULL);
             ctx->client = e_client_new(c, cp, 0, 1);
             EINA_SAFETY_ON_NULL_RETURN_VAL(ctx->client, EINA_TRUE);
          }
        ctx->client->placed = ctx->placed | ctx->centered;
        ctx->client->internal_no_remember = ctx->internal_no_remember;
        ctx->client->internal_no_reopen = ctx->internal_no_reopen;
        ctx->client->internal_elm_win = o;
        elm_win_autodel_set(o, 1);
        evas_object_data_set(o, "E_Client", ctx->client);
<commit_msg>only use elm win title for internal windows if it has been set<commit_after>#include "e.h"

/* intercept elm_win operations so we talk directly to e_client */
#undef elm_win_add

typedef struct _Elm_Win_Trap_Ctx
{
   E_Client      *client;
   E_Pointer     *pointer;
   Eina_Bool      centered : 1;
   Eina_Bool      placed : 1;
   Eina_Bool      internal_no_remember : 1;
   Eina_Bool      internal_no_reopen : 1;
   Eina_Bool      visible : 1;
} Elm_Win_Trap_Ctx;


static void *
_e_elm_win_trap_add(Evas_Object *o)
{
   Elm_Win_Trap_Ctx *ctx = calloc(1, sizeof(Elm_Win_Trap_Ctx));
   EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, NULL);
   evas_object_name_set(o, "E_Win");
   return ctx;
}

static void
_e_elm_win_trap_del(void *data, Evas_Object *o)
{
   Elm_Win_Trap_Ctx *ctx = data;
   EINA_SAFETY_ON_NULL_RETURN(ctx);
   if (ctx->client)
     {
        evas_object_hide(ctx->client->frame);
        e_object_del(E_OBJECT(ctx->client));
        evas_object_data_set(o, "E_Client", NULL);
        ctx->client->internal_elm_win = NULL;
     }
   free(ctx);
}

static Eina_Bool
_e_elm_win_trap_hide(void *data, Evas_Object *o)
{
   Elm_Win_Trap_Ctx *ctx = data;
   EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, EINA_TRUE);
   if (!ctx->visible) return EINA_FALSE;
   if (strncmp(ecore_evas_engine_name_get(e_win_ee_get(o)), "wayland", 7))
     E_FREE_FUNC(ctx->pointer, e_object_del);

   if (!ctx->client) return EINA_TRUE;
   ctx->visible = 0;
   evas_object_hide(ctx->client->frame);
   return EINA_FALSE;
}

static Eina_Bool
_e_elm_win_trap_show(void *data, Evas_Object *o)
{
   Elm_Win_Trap_Ctx *ctx = data;
   Evas *e = evas_object_evas_get(o);
   Ecore_Evas *ee = ecore_evas_ecore_evas_get(e);

   EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, EINA_TRUE);
   if (!ctx->client)
     {
        E_Client *ec;
        Ecore_Window win;
        E_Pixmap_Type type;

        win = elm_win_window_id_get(o);
        if (!strncmp(ecore_evas_engine_name_get(ee), "wayland", 7))
          {
             type = E_PIXMAP_TYPE_WL;
             ctx->pointer = e_comp_get(NULL)->pointer;
          }
        else
          {
             type = E_PIXMAP_TYPE_X;
             ctx->pointer = e_pointer_window_new(win, EINA_TRUE);
          }

        ec = e_pixmap_find_client(type, win);
        if (ec)
          ctx->client = ec;
        else
          {
             E_Pixmap *cp;
             E_Comp *c = NULL;
             const char *title;

             ecore_evas_name_class_set(ee, "E", "_e_internal_window");
             title = elm_win_title_get(o);
             if ((!title) || (!title[0]))
               title = "E";
             ecore_evas_title_set(ee, title);
             cp = e_pixmap_new(type, win);
             EINA_SAFETY_ON_NULL_RETURN_VAL(cp, EINA_TRUE);

             /* if (eina_list_count(e_comp_list()) > 1) */
             /*   { */
/* #ifndef HAVE_WAYLAND_ONLY */
             /*      c = e_comp_find_by_window(ecore_x_window_root_get(win)); */
/* #else */
             /*      c = ; */
/* #endif */
             /*   } */

             if (!c)
               c = e_comp_get(NULL);
             ctx->client = e_client_new(c, cp, 0, 1);
             EINA_SAFETY_ON_NULL_RETURN_VAL(ctx->client, EINA_TRUE);
          }
        ctx->client->placed = ctx->placed | ctx->centered;
        ctx->client->internal_no_remember = ctx->internal_no_remember;
        ctx->client->internal_no_reopen = ctx->internal_no_reopen;
        ctx->client->internal_elm_win = o;
        elm_win_autodel_set(o, 1);
        evas_object_data_set(o, "E_Client", ctx->client);

{'fraction_non_alphanumeric': 0.11623536215122163, 'fraction_numerical': 0.003903426340899234, 'mean_word_length': 2.4624624624624625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1405534', 'n_tokens_mistral': 2735, 'n_tokens_neox': 2642, 'n_words': 420}