<commit_before>#include "ecore_xcb_private.h"
# ifdef ECORE_XCB_XFIXES
#  include <xcb/xfixes.h>
# endif

/* local function prototypes */
static xcb_rectangle_t *_ecore_xcb_rect_to_xcb(Ecore_X_Rectangle *rects, int num);
static Ecore_X_Rectangle *_ecore_xcb_rect_to_ecore(xcb_rectangle_t *rects, int num);

/* local variables */
static Eina_Bool _xfixes_avail = EINA_FALSE;

/* external variables */
int _ecore_xcb_event_xfixes = -1;

void 
_ecore_xcb_xfixes_init(void) 
{
   LOGFN(__FILE__, __LINE__, __FUNCTION__);

#ifdef ECORE_XCB_XFIXES
   xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_xfixes_id);
#endif
}

void 
_ecore_xcb_xfixes_finalize(void) 
{
#ifdef ECORE_XCB_XFIXES
   const xcb_query_extension_reply_t *ext_reply;
#endif

   LOGFN(__FILE__, __LINE__, __FUNCTION__);

#ifdef ECORE_XCB_XFIXES
   ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_xfixes_id);
   if ((ext_reply) && (ext_reply->present)) 
     {
        xcb_xfixes_query_version_cookie_t cookie;
        xcb_xfixes_query_version_reply_t *reply;

        cookie = 
          xcb_xfixes_query_version_unchecked(_ecore_xcb_conn, 
                                             XCB_XFIXES_MAJOR_VERSION, 
                                             XCB_XFIXES_MINOR_VERSION);
        reply = xcb_xfixes_query_version_reply(_ecore_xcb_conn, cookie, NULL);
        if (reply) 
          {
             if (reply->major_version >= 3) 
               {
                  _xfixes_avail = EINA_TRUE;
                  ECORE_X_EVENT_FIXES_SELECTION_NOTIFY = ecore_event_type_new();
               }
             free(reply);
          }

        if (_xfixes_avail) 
          _ecore_xcb_event_xfixes = ext_reply->first_event;
     }
#endif
}

EAPI Eina_Bool
ecore_x_fixes_selection_notification_request(Ecore_X_Atom selection)
{
#ifdef ECORE_XCB_XFIXES
   if (_xfixes_avail)
     {
        xcb_xfixes_select_selection_input_checked(_ecore_xcb_conn,
              /* FIXME: We need a way to know the root window. */
              NULL,
              selection,
              XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER |
              XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY |
              XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE);
        return EINA_TRUE;
     }
#endif<commit_msg>Ecore_X: Fix newly added xfixes selection code for Tom ;)<commit_after>#include "ecore_xcb_private.h"
# ifdef ECORE_XCB_XFIXES
#  include <xcb/xfixes.h>
# endif

/* local function prototypes */
static xcb_rectangle_t *_ecore_xcb_rect_to_xcb(Ecore_X_Rectangle *rects, int num);
static Ecore_X_Rectangle *_ecore_xcb_rect_to_ecore(xcb_rectangle_t *rects, int num);

/* local variables */
static Eina_Bool _xfixes_avail = EINA_FALSE;

/* external variables */
int _ecore_xcb_event_xfixes = -1;

void 
_ecore_xcb_xfixes_init(void) 
{
   LOGFN(__FILE__, __LINE__, __FUNCTION__);

#ifdef ECORE_XCB_XFIXES
   xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_xfixes_id);
#endif
}

void 
_ecore_xcb_xfixes_finalize(void) 
{
#ifdef ECORE_XCB_XFIXES
   const xcb_query_extension_reply_t *ext_reply;
#endif

   LOGFN(__FILE__, __LINE__, __FUNCTION__);

#ifdef ECORE_XCB_XFIXES
   ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_xfixes_id);
   if ((ext_reply) && (ext_reply->present)) 
     {
        xcb_xfixes_query_version_cookie_t cookie;
        xcb_xfixes_query_version_reply_t *reply;

        cookie = 
          xcb_xfixes_query_version_unchecked(_ecore_xcb_conn, 
                                             XCB_XFIXES_MAJOR_VERSION, 
                                             XCB_XFIXES_MINOR_VERSION);
        reply = xcb_xfixes_query_version_reply(_ecore_xcb_conn, cookie, NULL);
        if (reply) 
          {
             if (reply->major_version >= 3) 
               _xfixes_avail = EINA_TRUE;
             free(reply);
          }

        if (_xfixes_avail) 
          _ecore_xcb_event_xfixes = ext_reply->first_event;
     }
#endif
}

EAPI Eina_Bool
ecore_x_fixes_selection_notification_request(Ecore_X_Atom selection)
{
#ifdef ECORE_XCB_XFIXES
   Ecore_X_Window root = 0;
   xcb_void_cookie_t cookie;
   xcb_generic_error_t *err;
   int mask = 0;
#endif

   if (!_xfixes_avail) return EINA_FALSE;
#ifdef ECORE_XCB_XFIXES
   root = ((xcb_screen_t *)_ecore_xcb_screen)->root;

   mask = (XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER |
           XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY |
           XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE);

   cookie = 
     xcb_xfixes_select_selection_input_checked(_ecore_xcb_conn, root, 
                                               selection, mask);
   err = xcb_request_check(_ecore_xcb_conn, cookie);
   if (err) 
     {
        free(err);
        return EINA_FALSE;
     }

   return EINA_TRUE;
#endif
{'fraction_non_alphanumeric': 0.07142857142857142, 'fraction_numerical': 0.0012494793835901709, 'mean_word_length': 2.9892026578073088, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6704794', 'n_tokens_mistral': 1848, 'n_tokens_neox': 1804, 'n_words': 257}