First Revision (from Archive)
[~jspiros/WindowBlur.git] / CGSInternal / CGSWindow.h
1 /*
2  * Copyright (C) 2007-2008 Alacatia Labs
3  * 
4  * This software is provided 'as-is', without any express or implied
5  * warranty.  In no event will the authors be held liable for any damages
6  * arising from the use of this software.
7  * 
8  * Permission is granted to anyone to use this software for any purpose,
9  * including commercial applications, and to alter it and redistribute it
10  * freely, subject to the following restrictions:
11  * 
12  * 1. The origin of this software must not be misrepresented; you must not
13  *    claim that you wrote the original software. If you use this software
14  *    in a product, an acknowledgment in the product documentation would be
15  *    appreciated but is not required.
16  * 2. Altered source versions must be plainly marked as such, and must not be
17  *    misrepresented as being the original software.
18  * 3. This notice may not be removed or altered from any source distribution.
19  * 
20  * Joe Ranieri joe@alacatia.com
21  *
22  */
23
24 #pragma once
25 #include "CGSConnection.h"
26 #include "CGSRegion.h"
27
28 typedef int CGSWindowID;
29 typedef int CGSAnimationObj;
30 typedef struct { CGPoint localPoint; CGPoint globalPoint; } CGSWarpPoint;
31
32 typedef enum {
33         kCGSSharingNone,
34         kCGSSharingReadOnly,
35         kCGSSharingReadWrite
36 } CGSSharingState;
37
38 typedef enum {
39         kCGSOrderBelow = -1,
40         kCGSOrderOut, /* hides the window */
41         kCGSOrderAbove,
42         kCGSOrderIn /* shows the window */
43 } CGSWindowOrderingMode;
44
45 typedef enum {
46    kCGSBackingNonRetianed,
47    kCGSBackingRetained,
48    kCGSBackingBuffered,
49 } CGSBackingType;
50
51
52 CG_EXTERN_C_BEGIN
53
54 /*! Switches to the next (or previous) window in the global list. */
55 CG_EXTERN CGError CGSCycleWindows(CGSConnectionID cid, CGSWindowOrderingMode order);
56
57 /*! Gets and sets the desktop window. Not sure what happens if more than one process sets the desktop window. */
58 CG_EXTERN CGError CGSDesktopWindow(CGSConnectionID cid, CGSWindowID *outWID);
59 CG_EXTERN CGError CGSSetDesktopWindow(CGSConnectionID cid, CGSWindowID wid);
60
61 /*! Sets the window's title. Internally this simply calls `CGSSetWindowProperty(cid, wid, kCGSWindowTitle, title)`. */
62 CG_EXTERN CGError CGSSetWindowTitle(CGSConnectionID cid, CGSWindowID wid, CFStringRef title);
63
64 /*! Gets and sets a property for a window. */
65 CG_EXTERN CGError CGSGetWindowProperty(CGSConnectionID cid, CGSWindowID wid, CFStringRef key, CFTypeRef *outValue);
66 CG_EXTERN CGError CGSSetWindowProperty(CGSConnectionID cid, CGSWindowID wid, CFStringRef key, CFTypeRef value);
67
68 /*! Gets and sets the window's transparency. */
69 CG_EXTERN CGError CGSGetWindowAlpha(CGSConnectionID cid, CGSWindowID wid, float *outAlpha);
70 CG_EXTERN CGError CGSSetWindowAlpha(CGSConnectionID cid, CGSWindowID wid, float alpha);
71
72 /*! Sets the alpha of a group of windows over a period of time. Note that `duration` is in seconds. */
73 CG_EXTERN CGError CGSSetWindowListAlpha(CGSConnectionID cid, const CGSWindowID *widList, int widCount, float alpha, float duration);
74
75 /*! Gets and sets the `CGConnectionID` that owns this window. Only the owner can change most properties of the window. */
76 CG_EXTERN CGError CGSGetWindowOwner(CGSConnectionID cid, CGSWindowID wid, CGSConnectionID *outOwner);
77 CG_EXTERN CGError CGSSetWindowOwner(CGSConnectionID cid, CGSWindowID wid, CGSConnectionID owner);
78
79 /*! Sets the background color of the window. */
80 CG_EXTERN CGError CGSSetWindowAutofillColor(CGSConnectionID cid, CGSWindowID wid, float red, float green, float blue);
81
82 /*! Locks a window to the cursor, so that whenever the cursor moves, the window moves with it. There doesn't seem to be a way to unlock the window from the cursor. */
83 CG_EXTERN CGError CGSLockWindowToCursor(CGSConnectionID cid, CGSWindowID wid, float offsetLeft, float offsetTop);
84
85 /*! Sets the warp for the window. The mesh maps a local (window) point to a point on screen. */
86 CG_EXTERN CGError CGSSetWindowWarp(CGSConnectionID cid, CGSWindowID wid, int warpWidth, int warpHeight, const CGSWarpPoint *warp);
87
88 /*! Gets or sets whether the window server should auto-fill the window's background. */
89 CG_EXTERN CGError CGSGetWindowAutofill(CGSConnectionID cid, CGSWindowID wid, bool *outShouldAutoFill);
90 CG_EXTERN CGError CGSSetWindowAutofill(CGSConnectionID cid, CGSWindowID wid, bool shouldAutoFill);
91
92 /*! Gets the screen rect for a window. */
93 CG_EXTERN CGError CGSGetScreenRectForWindow(CGSConnectionID cid, CGSWindowID wid, CGRect *outRect);
94
95 /*! Gets and sets the window level for a window. */
96 CG_EXTERN CGError CGSGetWindowLevel(CGSConnectionID cid, CGSWindowID wid, CGWindowLevel *outLevel);
97 CG_EXTERN CGError CGSSetWindowLevel(CGSConnectionID cid, CGSWindowID wid, CGWindowLevel level);
98
99 /*! Gets and sets the sharing state. This determines the level of access other applications have over this window. */
100 CG_EXTERN CGError CGSGetWindowSharingState(CGSConnectionID cid, CGSWindowID wid, CGSSharingState *outState);
101 CG_EXTERN CGError CGSSetWindowSharingState(CGSConnectionID cid, CGSWindowID wid, CGSSharingState state);
102
103 /*! Sets whether this window is ignored in the global window cycle (Control-F4 by default). There is no Get version? */
104 CG_EXTERN CGError CGSSetIgnoresCycle(CGSConnectionID cid, CGSWindowID wid, bool ignoresCycle);
105
106 /*! Creates a graphics context for the window. */
107 CG_EXTERN CGContextRef CGWindowContextCreate(CGSConnectionID cid, CGSWindowID wid, int unknown);
108
109 /*! Sets the order of a window */
110 CG_EXTERN CGError CGSOrderWindow(CGSConnectionID cid, CGSWindowID wid, CGSWindowOrderingMode mode, CGSWindowID relativeToWID);
111
112 /*! Sets the origin (top-left) of a window */
113 CG_EXTERN CGError CGSMoveWindow(CGSConnectionID cid, CGSWindowID wid, const CGPoint *origin);
114
115 /*! Sets the origin (top-left) of a window relative to another window's origin. */
116 CG_EXTERN CGError CGSSetWindowOriginRelativeToWindow(CGSConnectionID cid, CGSWindowID wid, CGSWindowID relativeToWID, float offsetX, float offsetY);
117
118 /* Flushes a window's buffer to the screen. */
119 CG_EXTERN CGError CGSFlushWindow(CGSConnectionID cid, CGSWindowID wid, CGSRegionObj flushRegion);
120
121
122 #pragma mark shadows
123 /*! Gets and sets the shadow information for a window. Values for `flags` are unknown. */
124 CG_EXTERN CGError CGSSetWindowShadowAndRimParameters(CGSConnectionID cid, CGSWindowID wid, float standardDeviation, float density, int offsetX, int offsetY, int flags);
125 CG_EXTERN CGError CGSGetWindowShadowAndRimParameters(CGSConnectionID cid, CGSWindowID wid, float *outStandardDeviation, float *outDensity, int *outOffsetX, int *outOffsetY, int *outFlags);
126
127 /*! Sets the shadow information for a window. Simply calls through to `CGSSetWindowShadowAndRimParameters` passing 1 for `flags`. */
128 CG_EXTERN CGError CGSSetWindowShadowParameters(CGSConnectionID cid, CGSWindowID wid, float standardDeviation, float density, int offsetX, int offsetY);
129
130 /*! Invalidates a window's shadow. */
131 CG_EXTERN CGError CGSInvalidateWindowShadow(CGSConnectionID cid, CGSWindowID wid);
132
133
134 #pragma mark window lists
135 /*! Gets the number of windows the `targetCID` owns. */
136 CG_EXTERN CGError CGSGetWindowCount(CGSConnectionID cid, CGSConnectionID targetCID, int *outCount);
137
138 /*! Gets a list of windows owned by `targetCID`. */
139 CG_EXTERN CGError CGSGetWindowList(CGSConnectionID cid, CGSConnectionID targetCID, int count, CGSWindowID *list, int *outCount);
140
141 /*! Gets the number of windows owned by `targetCID` that are on screen. */
142 CG_EXTERN CGError CGSGetOnScreenWindowCount(CGSConnectionID cid, CGSConnectionID targetCID, int *outCount);
143
144 /*! Gets a list of windows oned by `targetCID` that are on screen. */
145 CG_EXTERN CGError CGSGetOnScreenWindowList(CGSConnectionID cid, CGSConnectionID targetCID, int count, CGSWindowID *list, int *outCount);
146
147
148 #pragma mark window management
149 /*! Creates a new CGSWindow. The real window top/left is the sum of the region's top/left and the top/left parameters. */
150 CG_EXTERN CGError CGSNewWindow(CGSConnectionID cid, CGSBackingType backingType, float left, float top, CGSRegionObj region, CGSWindowID *outWID);
151
152 /*! Creates a new CGSWindow. The real window top/left is the sum of the region's top/left and the top/left parameters. */
153 CG_EXTERN CGError CGSNewWindowWithOpaqueShape(CGSConnectionID cid, CGSBackingType backingType, float left, float top, CGSRegionObj region, CGSRegionObj opaqueShape, int unknown, const int *tags, int tagSize, CGSWindowID *outWID);
154
155 /*! Releases a CGSWindow. */
156 CG_EXTERN CGError CGSReleaseWindow(CGSConnectionID cid, CGSWindowID wid);
157
158
159 #pragma mark animations
160 /*! Creates a Dock-style genie animation that goes from `wid` to `destinationWID`. */
161 CG_EXTERN CGError CGSCreateGenieWindowAnimation(CGSConnectionID cid, CGSWindowID wid, CGSWindowID destinationWID, CGSAnimationObj *outAnimation);
162
163 /*! Creates a sheet animation that's used when the parent window is brushed metal. Oddly enough, seems to be the only one used, even if the parent window isn't metal. */
164 CG_EXTERN CGError CGSCreateMetalSheetWindowAnimationWithParent(CGSConnectionID cid, CGSWindowID wid, CGSWindowID parentWID, CGSAnimationObj *outAnimation);
165
166 /*! Sets the progress of an animation. */
167 CG_EXTERN CGError CGSSetWindowAnimationProgress(CGSAnimationObj animation, float progress);
168
169 /*! DOCUMENTATION PENDING */
170 CG_EXTERN CGError CGSWindowAnimationChangeLevel(CGSAnimationObj animation, CGWindowLevel level);
171
172 /*! DOCUMENTATION PENDING */
173 CG_EXTERN CGError CGSWindowAnimationSetParent(CGSAnimationObj animation, CGSWindowID parent) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
174
175 /*! Releases a window animation. */
176 CG_EXTERN CGError CGSReleaseWindowAnimation(CGSAnimationObj animation);
177
178
179 #pragma mark window accelleration
180 /*! Gets the state of accelleration for the window. */
181 CG_EXTERN CGError CGSWindowIsAccelerated(CGSConnectionID cid, CGSWindowID wid, bool *outIsAccelerated);
182
183 /*! Gets and sets if this window can be accellerated. I don't know if playing with this is safe. */
184 CG_EXTERN CGError CGSWindowCanAccelerate(CGSConnectionID cid, CGSWindowID wid, bool *outCanAccelerate);
185 CG_EXTERN CGError CGSWindowSetCanAccelerate(CGSConnectionID cid, CGSWindowID wid, bool canAccelerate);
186
187
188 #pragma mark system status items
189 /*! Registers or unregisters a window as a global status item (see `NSStatusItem`, `NSMenuExtra`). Once a window is registered, the window server takes care of placing it in the apropriate location. */
190 CG_EXTERN CGError CGSRegisterWindowWithSystemStatusBar(CGSConnectionID cid, CGSWindowID wid, int priority);
191 CG_EXTERN CGError CGSUnregisterWindowWithSystemStatusBar(CGSConnectionID cid, CGSWindowID wid);
192
193 /*! Rearranges items in the system status bar. You should call this after registering or unregistering a status item or changing the window's width. */
194 CG_EXTERN CGError CGSAdjustSystemStatusBarWindows(CGSConnectionID cid);
195
196 CG_EXTERN_C_END