1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
/* libkrandr.h - class KRandr that makes it easy to use XRandr in KDE
This file is part of KRandr 0.9.5
Copyright (C) 2010 Timothy Pearson
LibKRandr's homepage : http://www.trinitydesktop.org
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
Send comments and bug fixes to Timothy Pearson <[email protected]>
***************************************************************************/
#ifndef _LIBKRANDR_H
#define _LIBKRANDR_H
#include "randr.h"
#include "lowlevel_randr.h"
#ifdef __cplusplus
#include <tqfile.h>
#include <kconfig.h>
#include <ksimpleconfig.h>
#include <tdelibs_export.h>
#define ROTATION_0_DEGREES_STRING "0 degrees"
#define ROTATION_90_DEGREES_STRING "90 degrees"
#define ROTATION_180_DEGREES_STRING "180 degrees"
#define ROTATION_270_DEGREES_STRING "270 degrees"
/**
* Simple API covering most of the uses of libkrandr.
*
* You can use the members of this class in pure C applications, just by using
* the same name as the corresponding function member.
*
* @short A simple API around the rest of libkrandr.
* @version 0.9.5 27/04/2010
* @author Timothy Pearson <[email protected]>
*/
class KRANDR_EXPORT KRandrSimpleAPI : public RandRDisplay
{
private:
public:
/**
* Retrieves the specificed ICC profile filename from the configuration database
*/
TQString getIccFileName(TQString profileName, TQString screenName, TQString kde_confdir);
/**
* Applies the specificed ICC profile filename to the specified RandR output
* If RandR is not available, the specified file is applied to the current display
*/
TQString applyIccFile(TQString screenName, TQString fileName);
/**
* Applies all saved ICC profile settings to all RandR outputs
* If RandR is not available, the settings are applied to the current display
*/
TQString applyIccConfiguration(TQString profileName, TQString kde_confdir);
/**
* Applies saved system wide settings to the current display
*/
TQString applySystemWideIccConfiguration(TQString kde_confdir);
/**
* Resets the current display
*/
TQString clearIccConfiguration(void);
/**
* Retrieves current profile name
*/
TQString getCurrentProfile(void);
/**
* Reads current screen information.
* NOTE: The caller is responsible for calling freeScreenInfoStructure() when done
*/
ScreenInfo* read_screen_info(Display *display);
/**
* Frees the ScreenInfo structure
*/
void freeScreenInfoStructure(ScreenInfo* screen_info);
/**
* Sets the screen size.
*/
int set_screen_size (ScreenInfo *screen_info);
/**
* Automatically selects an output port.
*/
void output_auto (ScreenInfo *screen_info, OutputInfo *output_info);
/**
* Turns off a specified output on a specified screen.
*/
void output_off(ScreenInfo *screen_info, OutputInfo *output);
/**
* Automatically finds the CRTC structure.
*/
CrtcInfo* auto_find_crtc (ScreenInfo *screen_info, OutputInfo *output_info);
/**
* Finds a mode by XID.
*/
XRRModeInfo *find_mode_by_xid (ScreenInfo *screen_info, RRMode mode_id);
/**
* Returns specified mode height in pixels.
*/
int mode_height (XRRModeInfo *mode_info, Rotation rotation);
/**
* Returns specified mode width in pixels.
*/
int mode_width (XRRModeInfo *mode_info, Rotation rotation);
/**
* Returns specified output width in pixels.
*/
int get_width_by_output_id (ScreenInfo *screen_info, RROutput output_id);
/**
* Returns specified output height in pixels.
*/
int get_height_by_output_id (ScreenInfo *screen_info, RROutput output_id);
/**
* Returns output name.
*/
char *get_output_name (ScreenInfo *screen_info, RROutput id);
/**
* Applies specified CRTC.
*/
Status crtc_apply (CrtcInfo *crtc_info);
/**
* Disables specificed CRTC
*/
Status crtc_disable (CrtcInfo *crtc);
/**
* Applies all previously configured settings to the specified screen.
*/
int main_low_apply (ScreenInfo *screen_info);
/**
* Sets the primary output device to the specified output_id
*/
void set_primary_output (ScreenInfo *screen_info, RROutput output_id);
/**
* Gets the binary monitor EDID for the specified card and display
*/
TQByteArray getEDID(int card, TQString displayname);
/**
* Gets the monitor EDID name for the specified card and display
*/
TQString getEDIDMonitorName(int card, TQString displayname);
/**
* Returns true if the specified configuration directory has enabled display configuration
*/
bool getDisplayConfigurationEnabled(TQString kde_confdir);
/**
* Returns true if the specified configuration directory has enabled automatic profile application on startup
*/
bool getDisplayConfigurationStartupAutoApplyEnabled(TQString kde_confdir);
/**
* Returns the name of the automatically applied startup profile in the specified configuration directory
*/
TQString getDisplayConfigurationStartupAutoApplyName(TQString kde_confdir);
/**
* Returns a HotPlugRulesList containing all hotplug rules from the specified configuration directory
*/
HotPlugRulesList getHotplugRules(TQString kde_confdir);
/**
* Saves a HotPlugRulesList containing all hotplug rules to the specified configuration directory
*/
void saveHotplugRules(HotPlugRulesList rules, TQString kde_confdir);
/**
* Applies all hotplug rules in the specified configuration directory to the current display configuration
*/
void applyHotplugRules(TQString kde_confdir);
/**
* Returns a list of all profiles available in the specified configuration directory
* This list does not include the default ("") profile
*/
TQStringList getDisplayConfigurationProfiles(TQString kde_confdir);
/**
* Deletes the specified profile from the specified configuration directory
* Returns true on success, false on failure
*/
bool deleteDisplayConfiguration(TQString profilename, TQString kde_confdir);
/**
* Renames the specified profile in the specified configuration directory
* Returns true on success, false on failure
*/
bool renameDisplayConfiguration(TQString profilename, TQString newprofilename, TQString kde_confdir);
/**
* Saves the systemwide display configuration screenInfoArray to the specified profile
* If profilename is empty, the default profile is utilized
* If enable is set to true, the default profile will be applied at system startup
*/
void saveDisplayConfiguration(bool enable, bool applyonstart, TQString profilename, TQString defaultprofilename, TQString kde_confdir, TQPtrList<SingleScreenData> screenInfoArray);
/**
* Reads the systemwide display configuration screenInfoArray from the specified profile
* If profilename is empty, the default profile is utilized
* WARNING: The calling application must free the returned objects when it is done using them
*/
TQPtrList<SingleScreenData> loadDisplayConfiguration(TQString profilename, TQString kde_confdir);
/**
* Applies the startup display configuration profile if enabled
* Returns the offset of the primary screen's top left corner
*/
TQPoint applyStartupDisplayConfiguration(TQString kde_confdir);
/**
* Applies the systemwide display configuration screenInfoArray from the specified profile
* If profilename is empty, the default profile is utilized
* Returns the offset of the primary screen's top left corner
*/
TQPoint applyDisplayConfiguration(TQString profilename, TQString kde_confdir);
/**
* Applies the systemwide display configuration screenInfoArray to the hardware
* If test is true, the new configuration will be loaded for a short period of time, then reverted automatically
* Returns true if configuration was accepted; false if not
*/
bool applyDisplayConfiguration(TQPtrList<SingleScreenData> screenInfoArray, bool test=TRUE, TQString kde_confdir="");
/**
* Applies the gamma contained within the systemwide display configuration screenInfoArray to the hardware
*/
void applyDisplayGamma(TQPtrList<SingleScreenData> screenInfoArray);
/**
* Applies the DPMS settings contained within the systemwide display configuration screenInfoArray to the hardware
*/
void applyDisplayDPMS(TQPtrList<SingleScreenData> screenInfoArray);
/**
* Copies a screen information object
*/
TQPtrList<SingleScreenData> copyScreenInformationObject(TQPtrList<SingleScreenData> screenInfoArray);
/**
* Destroys a screen information object
*/
void destroyScreenInformationObject(TQPtrList<SingleScreenData> screenInfoArray);
/**
* Returns the offset of the primary screen's Top Left Corner
*/
TQPoint primaryScreenOffsetFromTLC(TQPtrList<SingleScreenData> screenInfoArray);
/**
* Ensures that the data contained within screenInfoArray is self consistent
*/
void ensureMonitorDataConsistency(TQPtrList<SingleScreenData> screenInfoArray);
/**
* Reads the current display configuration screenInfoArray from the hardware
*/
TQPtrList<SingleScreenData> readCurrentDisplayConfiguration();
/**
* Returns the hardware rotation flags given a valid SingleScreenData structure
*/
int getHardwareRotationFlags(SingleScreenData*);
/**
* Returns whether or not the system supports XRandR
*/
bool kRandrHasRandr();
/**
* Returns the version number of libkrandr, i.e. "0.9.5" or "1.0 Beta"
*/
static const char *kRandrVersion(void);
/**
* Returns the copyright notice that applications using libkrandr should print
* to the user in an about box or somewhere visible.
* I.e.
*
* "LibKRandr 0.9.5 (C) 2010 Timothy Pearson <[email protected]>. U.S.A."
*/
static const char *kRandrCopyright(void);
};
extern "C" {
#else
#define KRANDR_EXPORT
#endif
// KRANDR_EXPORT ScreenInfo* read_screen_info(Display *);
// KRANDR_EXPORT int set_screen_size (ScreenInfo *screen_info);
// KRANDR_EXPORT void output_auto (ScreenInfo *screen_info, OutputInfo *output_info);
// KRANDR_EXPORT void output_off(ScreenInfo *screen_info, OutputInfo *output);
// KRANDR_EXPORT CrtcInfo* auto_find_crtc (ScreenInfo *screen_info, OutputInfo *output_info);
// KRANDR_EXPORT XRRModeInfo *find_mode_by_xid (ScreenInfo *screen_info, RRMode mode_id);
// KRANDR_EXPORT int mode_height (XRRModeInfo *mode_info, Rotation rotation);
// KRANDR_EXPORT int mode_width (XRRModeInfo *mode_info, Rotation rotation);
// KRANDR_EXPORT int get_width_by_output_id (ScreenInfo *screen_info, RROutput output_id);
// KRANDR_EXPORT int get_height_by_output_id (ScreenInfo *screen_info, RROutput output_id);
// KRANDR_EXPORT char *get_output_name (ScreenInfo *screen_info, RROutput id);
// KRANDR_EXPORT Status crtc_apply (CrtcInfo *crtc_info);
// KRANDR_EXPORT Status crtc_disable (CrtcInfo *crtc);
// KRANDR_EXPORT int main_low_apply (ScreenInfo *screen_info);
// KRANDR_EXPORT bool kRandrHasRandr();
KRANDR_EXPORT const char *kRandrVersion(void);
KRANDR_EXPORT const char *kRandrCopyright(void);
#ifdef __cplusplus
}
#endif
#endif
|