21
21
#import < spice/protocol.h>
22
22
#import " UTMShaderTypes.h"
23
23
24
+ @interface CSInput ()
25
+
26
+ @property (nonatomic , readwrite , nullable ) SpiceSession *session;
27
+ @property (nonatomic , readwrite , assign ) NSInteger channelID;
28
+ @property (nonatomic , readwrite , assign ) NSInteger monitorID;
29
+ @property (nonatomic , readwrite , assign ) BOOL serverModeCursor;
30
+ @property (nonatomic , readwrite , assign ) BOOL hasCursor;
31
+ @property (nonatomic , readwrite ) CGSize cursorSize;
32
+
33
+ @end
34
+
24
35
@implementation CSInput {
25
36
SpiceMainChannel *_main;
26
37
SpiceCursorChannel *_cursor;
@@ -37,7 +48,6 @@ @implementation CSInput {
37
48
id <MTLBuffer > _vertices;
38
49
NSUInteger _numVertices;
39
50
dispatch_semaphore_t _drawLock;
40
- CGSize _cursorSize;
41
51
BOOL _cursorHidden;
42
52
}
43
53
@@ -51,7 +61,7 @@ static void cs_update_mouse_mode(SpiceChannel *channel, gpointer data)
51
61
g_object_get (channel, " mouse-mode" , &mouse_mode, NULL );
52
62
DISPLAY_DEBUG (self, " mouse mode %u " , mouse_mode);
53
63
54
- self-> _serverModeCursor = (mouse_mode == SPICE_MOUSE_MODE_SERVER);
64
+ self. serverModeCursor = (mouse_mode == SPICE_MOUSE_MODE_SERVER);
55
65
56
66
if (self.serverModeCursor ) {
57
67
self->_mouse_guest .x = -1 ;
@@ -83,7 +93,7 @@ static void cs_cursor_set(SpiceCursorChannel *channel,
83
93
84
94
CGPoint hotspot = CGPointMake (cursor_shape->hot_spot_x , cursor_shape->hot_spot_y );
85
95
CGSize newSize = CGSizeMake (cursor_shape->width , cursor_shape->height );
86
- if (!CGSizeEqualToSize (newSize, self-> _cursorSize )) {
96
+ if (!CGSizeEqualToSize (newSize, self. cursorSize )) {
87
97
[self rebuildTexture: newSize center: hotspot];
88
98
}
89
99
[self drawCursor: cursor_shape->data];
@@ -141,7 +151,7 @@ static void cs_channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data
141
151
142
152
if (SPICE_IS_CURSOR_CHANNEL (channel)) {
143
153
gpointer cursor_shape;
144
- if (chid != self-> _channelID )
154
+ if (chid != self. channelID )
145
155
return ;
146
156
self->_cursor = SPICE_CURSOR_CHANNEL (channel);
147
157
g_signal_connect (channel, " notify::cursor" ,
@@ -186,7 +196,7 @@ static void cs_channel_destroy(SpiceSession *s, SpiceChannel *channel, gpointer
186
196
}
187
197
188
198
if (SPICE_IS_CURSOR_CHANNEL (channel)) {
189
- if (chid != self-> _channelID )
199
+ if (chid != self. channelID )
190
200
return ;
191
201
self->_cursor = NULL ;
192
202
g_signal_handlers_disconnect_by_func (channel, G_CALLBACK (cs_cursor_set), GLIB_OBJC_RELEASE (self));
@@ -393,6 +403,10 @@ - (void)requestMouseMode:(BOOL)server {
393
403
}
394
404
}
395
405
406
+ - (void )forceCursorPosition : (CGPoint)pos {
407
+ _mouse_guest = pos;
408
+ }
409
+
396
410
#pragma mark - Initializers
397
411
398
412
- (id )init {
@@ -411,9 +425,9 @@ - (id)initWithSession:(nonnull SpiceSession *)session channelID:(NSInteger)chann
411
425
GList *list;
412
426
GList *it;
413
427
414
- _channelID = channelID;
415
- _monitorID = monitorID;
416
- _session = session;
428
+ self. channelID = channelID;
429
+ self. monitorID = monitorID;
430
+ self. session = session;
417
431
g_object_ref (session);
418
432
419
433
NSLog (@" %s :%d " , __FUNCTION__, __LINE__);
@@ -440,15 +454,14 @@ - (void)dealloc {
440
454
cs_channel_destroy (self.session , SPICE_CHANNEL (_main), (__bridge void *)self);
441
455
}
442
456
NSLog (@" %s :%d " , __FUNCTION__, __LINE__);
443
- g_signal_handlers_disconnect_by_func (_session , G_CALLBACK (cs_channel_new), GLIB_OBJC_RELEASE (self));
444
- g_signal_handlers_disconnect_by_func (_session , G_CALLBACK (cs_channel_destroy), GLIB_OBJC_RELEASE (self));
445
- g_object_unref (_session );
446
- _session = NULL ;
457
+ g_signal_handlers_disconnect_by_func (self. session , G_CALLBACK (cs_channel_new), GLIB_OBJC_RELEASE (self));
458
+ g_signal_handlers_disconnect_by_func (self. session , G_CALLBACK (cs_channel_destroy), GLIB_OBJC_RELEASE (self));
459
+ g_object_unref (self. session );
460
+ self. session = NULL ;
447
461
}
448
462
449
463
#pragma mark - Drawing Cursor
450
464
451
- @synthesize cursorSize = _cursorSize;
452
465
@synthesize device = _device;
453
466
@synthesize drawLock = _drawLock;
454
467
@synthesize texture = _texture;
@@ -491,8 +504,8 @@ - (void)rebuildTexture:(CGSize)size center:(CGPoint)hotspot {
491
504
492
505
// Calculate the number of vertices by dividing the byte length by the size of each vertex
493
506
_numVertices = sizeof (quadVertices) / sizeof (UTMVertex);
494
- _cursorSize = size;
495
- _hasCursor = YES ;
507
+ self. cursorSize = size;
508
+ self. hasCursor = YES ;
496
509
dispatch_semaphore_signal (_drawLock);
497
510
}
498
511
@@ -501,27 +514,27 @@ - (void)destroyTexture {
501
514
_numVertices = 0 ;
502
515
_vertices = nil ;
503
516
_texture = nil ;
504
- _cursorSize = CGSizeZero;
505
- _hasCursor = NO ;
517
+ self. cursorSize = CGSizeZero;
518
+ self. hasCursor = NO ;
506
519
dispatch_semaphore_signal (_drawLock);
507
520
}
508
521
509
522
- (void )drawCursor : (const void *)buffer {
510
523
const NSInteger pixelSize = 4 ;
511
524
MTLRegion region = {
512
525
{ 0 , 0 }, // MTLOrigin
513
- { _cursorSize. width , _cursorSize .height , 1 } // MTLSize
526
+ { self. cursorSize . width , self. cursorSize .height , 1 } // MTLSize
514
527
};
515
528
dispatch_semaphore_wait (_drawLock, DISPATCH_TIME_FOREVER);
516
529
[_texture replaceRegion: region
517
530
mipmapLevel: 0
518
531
withBytes: buffer
519
- bytesPerRow: _cursorSize .width*pixelSize];
532
+ bytesPerRow: self .cursorSize .width*pixelSize];
520
533
dispatch_semaphore_signal (_drawLock);
521
534
}
522
535
523
536
- (BOOL )visible {
524
- return self.hasCursor && !_cursorHidden;
537
+ return !self. inhibitCursor && self.hasCursor && !_cursorHidden;
525
538
}
526
539
527
540
- (CGPoint)viewportOrigin {
0 commit comments