/ CoreGraphics / CGSConnection.m
CGSConnection.m
  1  /*
  2   This file is part of Darling.
  3  
  4   Copyright (C) 2020 Lubos Dolezel
  5  
  6   Darling is free software: you can redistribute it and/or modify
  7   it under the terms of the GNU General Public License as published by
  8   the Free Software Foundation, either version 3 of the License, or
  9   (at your option) any later version.
 10  
 11   Darling is distributed in the hope that it will be useful,
 12   but WITHOUT ANY WARRANTY; without even the implied warranty of
 13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14   GNU General Public License for more details.
 15  
 16   You should have received a copy of the GNU General Public License
 17   along with Darling.  If not, see <http://www.gnu.org/licenses/>.
 18  */
 19  #import <CoreGraphics/CGSConnection.h>
 20  #import <CoreGraphics/CGSWindow.h>
 21  #import <CoreGraphics/CGSSurface.h>
 22  #import <Foundation/NSDictionary.h>
 23  #import <Foundation/NSNumber.h>
 24  #import <Foundation/NSRaise.h>
 25  
 26  @implementation CGSConnection
 27  -(instancetype) initWithConnectionID:(CGSConnectionID)connId
 28  {
 29  	_nextWindowId = 1;
 30  	_connectionId = connId;
 31  	_windows = [[NSMutableDictionary alloc] initWithCapacity: 1];
 32  	return self;
 33  }
 34  
 35  -(CGSWindow*) windowForId:(CGSWindowID)winId
 36  {
 37  	@synchronized(_windows)
 38  	{
 39  		return [_windows objectForKey: [NSNumber numberWithInt: winId]];
 40  	}
 41  }
 42  
 43  -(void) _windowInvalidated: (CGSWindowID) winId
 44  {
 45  	@synchronized(_windows)
 46  	{
 47  		[_windows removeObjectForKey: [NSNumber numberWithInt: winId]];
 48  	}
 49  }
 50  
 51  -(void) dealloc
 52  {
 53  	[_windows release];
 54  	[super dealloc];
 55  }
 56  
 57  +(BOOL) isAvailable
 58  {
 59  	NSInvalidAbstractInvocation();
 60  }
 61  
 62  -(CGSKeyboardLayout*) createKeyboardLayout
 63  {
 64  	NSInvalidAbstractInvocation();
 65  }
 66  
 67  -(CGPoint) mouseLocation
 68  {
 69  	NSInvalidAbstractInvocation();
 70  }
 71  
 72  -(NSArray *) modesForScreen:(int)screenIndex
 73  {
 74  	NSInvalidAbstractInvocation();
 75  }
 76  
 77  -(BOOL) setMode:(NSDictionary *)mode forScreen:(int)screenIndex
 78  {
 79  	NSInvalidAbstractInvocation();
 80  }
 81  
 82  -(NSDictionary*) currentModeForScreen:(int)screenIndex
 83  {
 84  	NSInvalidAbstractInvocation();
 85  }
 86  
 87  -(CGSWindow*) newWindow:(CGSRegionRef)region
 88  {
 89  	NSInvalidAbstractInvocation();
 90  }
 91  
 92  -(void*) nativeDisplay
 93  {
 94  	NSInvalidAbstractInvocation();
 95  }
 96  
 97  -(CGError) destroyWindow:(CGSWindowID)winId
 98  {
 99  	CGSWindow* win = [self windowForId: winId];
100  	if (win == nil)
101  		return kCGErrorIllegalArgument;
102  	[win invalidate];
103  
104  	@synchronized (_windows)
105  	{
106  		[_windows removeObjectForKey: [NSNumber numberWithInt: winId]];
107  	}
108  	return kCGSErrorSuccess;
109  }
110  
111  @end