ibar_cursor.c (2937B)
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/* Macros for prettying up the embedded image. */ 30#define X 0x00,0x00,0x00,0xFF 31#define U 0x80,0x80,0x80,0xFF 32#define O 0xFF,0xFF,0xFF,0xFF 33#define _ 0x00,0x00,0x00,0x00 34 35/* Dimensions */ 36const int guac_common_ibar_cursor_width = 7; 37const int guac_common_ibar_cursor_height = 16; 38 39/* Format */ 40const cairo_format_t guac_common_ibar_cursor_format = CAIRO_FORMAT_ARGB32; 41const int guac_common_ibar_cursor_stride = 28; 42 43/* Embedded I-bar graphic */ 44unsigned char guac_common_ibar_cursor[] = { 45 46 X,X,X,X,X,X,X, 47 X,O,O,U,O,O,X, 48 X,X,X,O,X,X,X, 49 _,_,X,O,X,_,_, 50 _,_,X,O,X,_,_, 51 _,_,X,O,X,_,_, 52 _,_,X,O,X,_,_, 53 _,_,X,O,X,_,_, 54 _,_,X,O,X,_,_, 55 _,_,X,O,X,_,_, 56 _,_,X,O,X,_,_, 57 _,_,X,O,X,_,_, 58 _,_,X,O,X,_,_, 59 X,X,X,O,X,X,X, 60 X,O,O,U,O,O,X, 61 X,X,X,X,X,X,X 62 63}; 64 65void guac_common_set_ibar_cursor(guac_user* user) { 66 67 guac_client* client = user->client; 68 guac_socket* socket = user->socket; 69 70 /* Draw to buffer */ 71 guac_layer* cursor = guac_client_alloc_buffer(client); 72 73 cairo_surface_t* graphic = cairo_image_surface_create_for_data( 74 guac_common_ibar_cursor, 75 guac_common_ibar_cursor_format, 76 guac_common_ibar_cursor_width, 77 guac_common_ibar_cursor_height, 78 guac_common_ibar_cursor_stride); 79 80 guac_user_stream_png(user, socket, GUAC_COMP_SRC, cursor, 81 0, 0, graphic); 82 cairo_surface_destroy(graphic); 83 84 /* Set cursor */ 85 guac_protocol_send_cursor(socket, 0, 0, cursor, 86 guac_common_ibar_cursor_width / 2, 87 guac_common_ibar_cursor_height / 2, 88 guac_common_ibar_cursor_width, 89 guac_common_ibar_cursor_height); 90 91 /* Free buffer */ 92 guac_client_free_buffer(client, cursor); 93 94 guac_client_log(client, GUAC_LOG_DEBUG, 95 "Client cursor image set to generic built-in I-bar."); 96 97} 98