<commit_before>#include "e.h"
#include "e_comp_wl.h"
#include "e_desktop_shell_protocol.h"

#define XDG_SERVER_VERSION 3

/* FIXME: Popup Windows !! */
static void 
_e_shell_surface_parent_set(E_Client *ec, struct wl_resource *parent_resource)
{
   E_Pixmap *pp;
   E_Client *pc;
   Ecore_Window pwin = 0;

   /* get pixmap from parent */
   if (!(pp = wl_resource_get_user_data(parent_resource)))
     {
        ERR("Could not get parent resource pixmap");
        return;
     }

   pwin = e_pixmap_window_get(pp);

   /* find the parent client */
   if (!(pc = e_pixmap_client_get(pp)))
     pc = e_pixmap_find_client(E_PIXMAP_TYPE_WL, pwin);

   if (!pc) 
     {
        ERR("Could not find parent pixmap client");
        return;
     }

   e_pixmap_parent_window_set(ec->pixmap, pwin);

   ec->parent = pc;
   ec->icccm.fetch.transient_for = EINA_TRUE;
   ec->icccm.transient_for = pwin;
}

static void 
_e_shell_surface_mouse_down_helper(E_Client *ec, E_Binding_Event_Mouse_Button *ev, Eina_Bool move)
{
   if (move)
     {
        /* tell E to start moving the client */
        e_client_act_move_begin(ec, ev);

        /* we have to get a reference to the window_move action here, or else 
         * when e_client stops the move we will never get notified */
        ec->cur_mouse_action = e_action_find("window_move");
        if (ec->cur_mouse_action)
          e_object_ref(E_OBJECT(ec->cur_mouse_action));
     }
   else
     {
        /* tell E to start resizing the client */
        e_client_act_resize_begin(ec, ev);

        /* we have to get a reference to the window_resize action here, 
         * or else when e_client stops the resize we will never get notified */
        ec->cur_mouse_action = e_action_find("window_resize");
        if (ec->cur_mouse_action)
          e_object_ref(E_OBJECT(ec->cur_mouse_action));
     }

   e_focus_event_mouse_down(ec);
}

static void 
_e_shell_surface_cb_destroy(struct wl_resource *resource)
{
   E_Client *ec;

   DBG("Shell Surface Destroy: %d", wl_resource_get_id(resource));

   /* get the client for this resource */
   if ((ec = wl_resource_get_user_data(resource)))
     {
        if (ec->wl_comp_data)
          {
             if (ec->wl_comp_data->mapped)
               {
                  if ((ec->wl_comp_data->shell.surface) && 
                      (ec->wl_comp_data->shell.unmap))
                    ec->wl_comp_data->shell.unmap(ec->wl_comp_data->shell.surface);
               }

             ec->wl_comp_data->shell.surface = NULL;
          }
     }<commit_msg>check if client is getting destroyed before we try to unmap it.<commit_after>#include "e.h"
#include "e_comp_wl.h"
#include "e_desktop_shell_protocol.h"

#define XDG_SERVER_VERSION 3

/* FIXME: Popup Windows !! */
static void 
_e_shell_surface_parent_set(E_Client *ec, struct wl_resource *parent_resource)
{
   E_Pixmap *pp;
   E_Client *pc;
   Ecore_Window pwin = 0;

   /* get pixmap from parent */
   if (!(pp = wl_resource_get_user_data(parent_resource)))
     {
        ERR("Could not get parent resource pixmap");
        return;
     }

   pwin = e_pixmap_window_get(pp);

   /* find the parent client */
   if (!(pc = e_pixmap_client_get(pp)))
     pc = e_pixmap_find_client(E_PIXMAP_TYPE_WL, pwin);

   if (!pc) 
     {
        ERR("Could not find parent pixmap client");
        return;
     }

   e_pixmap_parent_window_set(ec->pixmap, pwin);

   ec->parent = pc;
   ec->icccm.fetch.transient_for = EINA_TRUE;
   ec->icccm.transient_for = pwin;
}

static void 
_e_shell_surface_mouse_down_helper(E_Client *ec, E_Binding_Event_Mouse_Button *ev, Eina_Bool move)
{
   if (move)
     {
        /* tell E to start moving the client */
        e_client_act_move_begin(ec, ev);

        /* we have to get a reference to the window_move action here, or else 
         * when e_client stops the move we will never get notified */
        ec->cur_mouse_action = e_action_find("window_move");
        if (ec->cur_mouse_action)
          e_object_ref(E_OBJECT(ec->cur_mouse_action));
     }
   else
     {
        /* tell E to start resizing the client */
        e_client_act_resize_begin(ec, ev);

        /* we have to get a reference to the window_resize action here, 
         * or else when e_client stops the resize we will never get notified */
        ec->cur_mouse_action = e_action_find("window_resize");
        if (ec->cur_mouse_action)
          e_object_ref(E_OBJECT(ec->cur_mouse_action));
     }

   e_focus_event_mouse_down(ec);
}

static void 
_e_shell_surface_cb_destroy(struct wl_resource *resource)
{
   E_Client *ec;

   DBG("Shell Surface Destroy: %d", wl_resource_get_id(resource));

   /* get the client for this resource */
   if ((ec = wl_resource_get_user_data(resource)))
     {
        if (e_object_is_del(E_OBJECT(ec))) return;

        if (ec->wl_comp_data)
          {
             if (ec->wl_comp_data->mapped)
               {
                  if ((ec->wl_comp_data->shell.surface) && 
                      (ec->wl_comp_data->shell.unmap))
                    ec->wl_comp_data->shell.unmap(ec->wl_comp_data->shell.surface);
               }

             ec->wl_comp_data->shell.surface = NULL;
          }
     }
{'fraction_non_alphanumeric': 0.10657945363601386, 'fraction_numerical': 0.0007695267410542517, 'mean_word_length': 2.5585215605749485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 49, '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': '3942004', 'n_tokens_mistral': 1814, 'n_tokens_neox': 1747, 'n_words': 386}