File indexing completed on 2024-04-21 04:20:22
0001 /******************************************************************** 0002 KolorServer - color server based on the X Color Management Specification 0003 This file is part of the KDE project. 0004 0005 Copyright (C) 2012 Casian Andrei <skeletk13@gmail.com> 0006 0007 Redistribution and use in source and binary forms, with or without 0008 modification, are permitted provided that the following conditions 0009 are met: 0010 0011 1. Redistributions of source code must retain the above copyright 0012 notice, this list of conditions and the following disclaimer. 0013 2. Redistributions in binary form must reproduce the above copyright 0014 notice, this list of conditions and the following disclaimer in the 0015 documentation and/or other materials provided with the distribution. 0016 0017 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0018 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0019 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0020 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0021 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0022 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0023 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0024 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0025 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0026 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0027 *********************************************************************/ 0028 0029 #ifndef KOLOR_SERVER_DISPLAY_H_ 0030 #define KOLOR_SERVER_DISPLAY_H_ 0031 0032 #include <QObject> 0033 0034 #include "x11-helpers.h" 0035 0036 struct oyStructList_s; 0037 0038 namespace KolorServer 0039 { 0040 0041 class Screen; 0042 0043 /** 0044 * Implements a color server conforming to the X Color Management 0045 * specification. 0046 * 0047 * \link http://oyranos.org/scm?p=xcolor.git;a=blob;f=docs/X_Color_Management.txt 0048 * 0049 * \note PrivDisplay 0050 */ 0051 class Display : public QObject 0052 { 0053 Q_OBJECT 0054 0055 friend class KolorServer::Screen; 0056 0057 public: 0058 static Display *getInstance(); 0059 static void cleanup(); 0060 0061 /** 0062 * \return The default screen for this display 0063 */ 0064 KolorServer::Screen *screen() const; 0065 0066 /** 0067 * \return Oyranos cache for profiles and other structures 0068 */ 0069 oyStructList_s *cache(); 0070 0071 /** 0072 * \return Whether color desktop functionality is enabled 0073 */ 0074 bool colorDesktopActivated() const; 0075 0076 /** 0077 * Activates or deactivates color desktop functionality. 0078 * If it is deactivated, then the whole color server stands idle. 0079 */ 0080 void activateColorDesktop(bool activate); 0081 0082 /** 0083 * \note cleanDisplay 0084 * - perform some kind of get display name weirdness 0085 * - indicate that we want to clear up monitors from Oyranos 0086 * - and release everything (clean up old displays) 0087 * - get number of connected devices? 0088 * - refresh EDIDs (grab them from Oyranos) 0089 * 0090 * Used by: setupOutputs 0091 */ 0092 void clean(); 0093 0094 /** 0095 * \note updateNetColorDesktopAtom 0096 * Check and update the _ICC_COLOR_DESKTOP status atom. It is used to 0097 * communicate with the applications. 0098 * 0099 * The atom is attached on the root window to inform about the color server. 0100 * The content is of type XA_STRING and has four sections separated by a 0101 * empty space char ' '. 0102 * The _ICC_COLOR_DESKTOP atom is a string with following usages: 0103 * - uniquely identify the colour server 0104 * - tell the name of the colour server 0105 * - tell the colour server is alive 0106 * - list the colour server capabilities and spec compliance 0107 * All sections are separated by one space char ' ' for easy parsing. 0108 * 0109 * The first section contains the process id (pid_t) of the color server process, 0110 * which has set the atom. 0111 * The second section contains time since epoch GMT as returned by time(NULL). 0112 * The thired section contains the bar '|' separated and surrounded 0113 * capabilities: 0114 * - ICP _ICC_COLOR_PROFILES XcolorRegion::md5 is handled 0115 * - ICT _ICC_COLOR_TARGET - deprecated 0116 * - ICM _ICC_COLOR_MANAGEMENT 0117 * - ICR _ICC_COLOR_REGIONS XcolorRegion is handled 0118 * - ICO _ICC_COLOR_OUTPUTS XcolorOutput is handled 0119 * - ICA _ICC_COLOR_DISPLAY_ADVANCED 0120 * - V0.4 indicates version compliance to the _ICC_Profile in X spec 0121 * The fourth section contains the servers name identifier. 0122 * 0123 * @return - 0 all fine 0124 * - 1 inactivate 0125 * - 2 activate 0126 * - 3 error 0127 * 0128 * Used by: moveICCprofileAtoms, pluginHandleEvent on iccColorDesktop 0129 */ 0130 int updateNetColorDesktopAtom(bool init); 0131 0132 /** 0133 * \note getDisplayAdvanced 0134 * - determine if some iccDisplayAdvanced atom is present 0135 * - return the result 0136 * 0137 * Used by: setupOutputTable 0138 * 0139 * _ICC_COLOR_DISPLAY_ADVANCED: 0140 * The atom is optionaly attached to the root window. A value of "1" signals the 0141 * colour server to use advanced CMS options like proofing. The type is XA_STRING. 0142 */ 0143 bool isAdvancedIccDisplay(); 0144 0145 private: 0146 /** 0147 * \note pluginInitDisplay 0148 * - abort on no randrExtension 0149 * - grab the atoms 0150 * - use default screen for the display 0151 */ 0152 Display(); 0153 0154 /** 0155 * \note pluginFiniDisplay 0156 * - destroy iccColorDesktop atom contents 0157 */ 0158 virtual ~Display(); 0159 0160 /** 0161 * Initializes the color server, mainly X11 related, like grab atoms, setup 0162 * event monitoring, etc. 0163 */ 0164 void initialize(); 0165 0166 /** 0167 * \note pluginHandleEvent 0168 * - handle PropertyNotify 0169 * - iccColorProfiles 0170 * - iccColorOutputs (not yet? for windows?) 0171 * - iccColorDesktop 0172 * - the weird icc target profile in x base 0173 * - netDesktopGeometry 0174 * - iccDisplayAdvanced 0175 * - handle ClientMessage, iccColorManagement (not yet? for windows?) 0176 * - handle RandR event, outputChange 0177 * - initialize stuff if necessary 0178 */ 0179 void handleEvent(X11::XEvent *event); 0180 0181 private slots: 0182 void checkX11Events(); 0183 0184 private: 0185 X11::Display *m_display; 0186 KolorServer::Screen *m_screen; 0187 0188 X11::XcmeContext_s *m_xcmeContext; 0189 0190 /* ClientMessage sent by the application */ 0191 X11::Atom iccColorManagement; 0192 0193 /* Window properties */ 0194 X11::Atom iccColorProfiles; 0195 X11::Atom iccColorRegions; 0196 X11::Atom iccColorOutputs; 0197 X11::Atom iccColorDesktop; 0198 X11::Atom netDesktopGeometry; 0199 X11::Atom iccDisplayAdvanced; 0200 0201 /** 0202 * Initially, the color desktop functionality is enabled, but 0203 * it can be later be disabled if there is another color server 0204 * running or there are other problems. 0205 */ 0206 bool m_colorDesktopActivated; 0207 0208 /** 0209 * Cache for color profiles and other structures 0210 */ 0211 oyStructList_s *m_oyCache; 0212 }; 0213 0214 } // KolorServer namespace 0215 0216 #endif // KOLOR_SERVER_DISPLAY_H_