Example #1
0
def resource_destroy_func(res_ptr):
    # the user data to the resource is the handle to the resource
    resource_handle = lib.wl_resource_get_user_data(res_ptr)
    resource = ffi.from_handle(resource_handle)

    # if the destructor has been set, run it
    func = resource.dispatcher.destructor
    if func is not None:
        func(resource)
Example #2
0
    def get_object(self, id):
        """Look up an object in the client name space

        This looks up an object in the client object name space by its object
        ID.

        :param id: The object id
        :type id: `int`
        :returns: The object, or ``None`` if there is not object for the given
                  ID
        """

        res_ptr = lib.wl_client_get_object(self._ptr, id)
        # If the object doesn't exist, this returns NULL, and asking for
        # forgiveness doesn't work, becuase it will seg fault
        if res_ptr == ffi.NULL:
            return
        res_py_ptr = lib.wl_resource_get_user_data(res_ptr)
        return ffi.from_handle(res_py_ptr)
Example #3
0
    def get_object(self, object_id):
        """Look up an object in the client name space

        This looks up an object in the client object name space by its object
        ID.

        :param object_id: The object id
        :type object_id: `int`
        :returns:
            The object, or ``None`` if there is not object for the given ID
        """

        res_ptr = lib.wl_client_get_object(self._ptr, object_id)
        # If the object doesn't exist, this returns NULL, and asking for
        # forgiveness doesn't work, becuase it will seg fault
        if res_ptr == ffi.NULL:
            return None

        resource_handle = lib.wl_resource_get_user_data(res_ptr)
        return ffi.from_handle(resource_handle)