blank_cursor.c (2364B)
1/* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20#include "config.h" 21 22#include <cairo/cairo.h> 23#include <guacamole/client.h> 24#include <guacamole/layer.h> 25#include <guacamole/protocol.h> 26#include <guacamole/socket.h> 27#include <guacamole/user.h> 28 29/* Dimensions */ 30const int guac_common_blank_cursor_width = 1; 31const int guac_common_blank_cursor_height = 1; 32 33/* Format */ 34const cairo_format_t guac_common_blank_cursor_format = CAIRO_FORMAT_ARGB32; 35const int guac_common_blank_cursor_stride = 4; 36 37/* Embedded blank cursor graphic */ 38unsigned char guac_common_blank_cursor[] = { 39 40 0x00,0x00,0x00,0x00 41 42}; 43 44void guac_common_set_blank_cursor(guac_user* user) { 45 46 guac_client* client = user->client; 47 guac_socket* socket = user->socket; 48 49 /* Draw to buffer */ 50 guac_layer* cursor = guac_client_alloc_buffer(client); 51 52 cairo_surface_t* graphic = cairo_image_surface_create_for_data( 53 guac_common_blank_cursor, 54 guac_common_blank_cursor_format, 55 guac_common_blank_cursor_width, 56 guac_common_blank_cursor_height, 57 guac_common_blank_cursor_stride); 58 59 guac_user_stream_png(user, socket, GUAC_COMP_SRC, cursor, 60 0, 0, graphic); 61 cairo_surface_destroy(graphic); 62 63 /* Set cursor */ 64 guac_protocol_send_cursor(socket, 0, 0, cursor, 0, 0, 65 guac_common_blank_cursor_width, 66 guac_common_blank_cursor_height); 67 68 /* Free buffer */ 69 guac_client_free_buffer(client, cursor); 70 71 guac_client_log(client, GUAC_LOG_DEBUG, 72 "Client cursor image set to generic transparent (blank) cursor."); 73 74} 75