2 * Copyright (C) 2016 Mentor Graphics Development (Deutschland) GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "windowmanager.hpp"
19 //////////////////////////////////////////
20 // THIS IS STILL UNDER HEAVY DEVELOPMENT!
21 // DO NOT JUDGE THE SOURCE CODE :)
22 //////////////////////////////////////////
25 WindowManager::WindowManager(QObject *parent) :
28 qDebug("WindowManager");
31 if (true)//!ilm_isInitialized()) ...crashes...
34 qDebug("ilm_init = %d", err);
38 t_ilm_uint screenID = 0;
42 err = ilm_getScreenResolution(screenID, &width, &height);
43 qDebug("ilm_getScreenResolution = %d", err);
44 qDebug("pWidth %d, pHeight %d", width, height);
47 t_ilm_layer layerId = 42; // does not matter
48 err = ilm_layerCreateWithDimension(&layerId, width, height);
49 qDebug("ilm_layerCreateWithDimension = %d", err);
50 qDebug("layerId = %d", layerId);
52 err = ilm_layerSetVisibility(layerId, true);
53 qDebug("ilm_layerSetVisibility = %d", err);
57 err = ilm_displaySetRenderOrder(screenID, &layerId, 1);
58 qDebug("ilm_displaySetRenderOrder = %d", err);
62 err = ilm_layerSetSourceRectangle(layerId, 0, 0, width, height);
63 qDebug("ilm_layerSetSourceRectangle = %d", err);
64 err = ilm_layerSetDestinationRectangle(layerId, 0, 0, width, height);
65 qDebug("layerSetDestinationRectangle = %d", err);
69 t_ilm_float opacity = 1.0;
71 err = ilm_layerSetOpacity(layerId, opacity);
72 qDebug("ilm_layerSetOpacity = %d", err);
76 t_ilm_surface* pArray;
78 err = ilm_getSurfaceIDs(&length, &pArray);
79 qDebug("ilm_getSurfaceIDs = %d", err);
80 qDebug("length %d pArray[0] %d", length, pArray[0]);
84 t_ilm_surface surfaceId = pArray[0];
86 err = ilm_layerAddSurface(layerId, surfaceId);
87 qDebug("ilm_layerAddSurface = %d", err);
89 t_ilm_bool visibility;
90 err = ilm_surfaceGetVisibility(surfaceId, &visibility);
91 qDebug("ilm_surfaceGetVisibility = %d", err);
92 qDebug("visibility %d", visibility);
94 err = ilm_surfaceSetVisibility(surfaceId, true);
95 qDebug("ilm_surfaceSetVisibility = %d", err);
97 err = ilm_surfaceSetOpacity(surfaceId, opacity);
98 qDebug("ilm_surfaceSetOpacity = %d", err);
100 err = ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, 200, 200);
101 qDebug("ilm_surfaceSetSourceRectangle = %d", err);
102 err = ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, 200, 200);
103 qDebug("surfaceSetDestinationRectangle = %d", err);
110 struct ilmScreenProperties screenProperties;
111 struct ilmLayerProperties layerProperties;
112 struct ilmSurfaceProperties surfaceProperties;
114 err = ilm_getPropertiesOfScreen(0, &screenProperties);
115 qDebug("ilm_getPropertiesOfScreen = %d", err);
116 err = ilm_getPropertiesOfLayer(layerId, &layerProperties);
117 qDebug("ilm_getPropertiesOfLayer = %d", err);
118 err = ilm_getPropertiesOfSurface(pArray[0], &surfaceProperties);
119 qDebug("ilm_getPropertiesOfSurface = %d", err);
123 qDebug("t_ilm_uint %d", screenProperties.layerCount); /*!< number of layers displayed on the screen */
124 //qDebug("t_ilm_layer* %d", screenProperties.layerIds[0]); /*!< array of layer ids */
125 qDebug("t_ilm_uint %d", screenProperties.harwareLayerCount); /*!< number of hardware layers */
126 qDebug("t_ilm_uint %d", screenProperties.screenWidth); /*!< width value of screen in pixels */
127 qDebug("t_ilm_uint %d", screenProperties.screenHeight); /*!< height value of screen in pixels */
130 qDebug("t_ilm_float %f", layerProperties.opacity); /*!< opacity value of the layer */
131 qDebug("t_ilm_uint %d", layerProperties.sourceX); /*!< x source position value of the layer */
132 qDebug("t_ilm_uint %d", layerProperties.sourceY); /*!< y source position value of the layer */
133 qDebug("t_ilm_uint %d", layerProperties.sourceWidth); /*!< source width value of the layer */
134 qDebug("t_ilm_uint %d", layerProperties.sourceHeight); /*!< source height value of the layer */
135 qDebug("t_ilm_uint %d", layerProperties.origSourceWidth); /*!< original source width value of the layer */
136 qDebug("t_ilm_uint %d", layerProperties.origSourceHeight); /*!< original source height value of the layer */
137 qDebug("t_ilm_uint %d", layerProperties.destX); /*!< x destination position value of the layer */
138 qDebug("t_ilm_uint %d", layerProperties.destY); /*!< y desitination position value of the layer */
139 qDebug("t_ilm_uint %d", layerProperties.destWidth); /*!< destination width value of the layer */
140 qDebug("t_ilm_uint %d", layerProperties.destHeight); /*!< destination height value of the layer */
141 qDebug("ilmOrientation%d", layerProperties.orientation); /*!< orientation value of the layer */
142 qDebug("t_ilm_bool %d", layerProperties.visibility); /*!< visibility value of the layer */
143 qDebug("t_ilm_uint %d", layerProperties.type); /*!< type of layer */
144 qDebug("t_ilm_int %d", layerProperties.creatorPid); /*!< process id of application that created this layer */
147 qDebug("t_ilm_float %f", surfaceProperties.opacity); /*!< opacity value of the surface */
148 qDebug("t_ilm_uint %d", surfaceProperties.sourceX); /*!< x source position value of the surface */
149 qDebug("t_ilm_uint %d", surfaceProperties.sourceY); /*!< y source position value of the surface */
150 qDebug("t_ilm_uint %d", surfaceProperties.sourceWidth); /*!< source width value of the surface */
151 qDebug("t_ilm_uint %d", surfaceProperties.sourceHeight); /*!< source height value of the surface */
152 qDebug("t_ilm_uint %d", surfaceProperties.origSourceWidth); /*!< original source width value of the surface */
153 qDebug("t_ilm_uint %d", surfaceProperties.origSourceHeight); /*!< original source height value of the surface */
154 qDebug("t_ilm_uint %d", surfaceProperties.destX); /*!< x destination position value of the surface */
155 qDebug("t_ilm_uint %d", surfaceProperties.destY); /*!< y desitination position value of the surface */
156 qDebug("t_ilm_uint %d", surfaceProperties.destWidth); /*!< destination width value of the surface */
157 qDebug("t_ilm_uint %d", surfaceProperties.destHeight); /*!< destination height value of the surface */
158 qDebug("ilmOrientation %d", surfaceProperties.orientation); /*!< orientation value of the surface */
159 qDebug("t_ilm_bool %d", surfaceProperties.visibility); /*!< visibility value of the surface */
160 qDebug("t_ilm_uint %d", surfaceProperties.frameCounter); /*!< already rendered frames of surface */
161 qDebug("t_ilm_uint %d", surfaceProperties.drawCounter); /*!< content updates of surface */
162 qDebug("t_ilm_uint %d", surfaceProperties.updateCounter); /*!< content updates of surface */
163 qDebug("t_ilm_uint %d", surfaceProperties.pixelformat); /*!< pixel format of surface */
164 qDebug("t_ilm_uint %d", surfaceProperties.nativeSurface); /*!< native surface handle of surface */
165 qDebug("t_ilm_int %d", surfaceProperties.creatorPid); /*!< process id of application that created this surface */
166 qDebug("ilmInputDevice %d", surfaceProperties.focus); /*!< bitmask of every type of device that this surface has focus in */
168 err = ilm_registerNotification(WindowManager::notificationFunc_static, this);
172 WindowManager::~WindowManager()
176 if (ilm_isInitialized())
179 qDebug("ilm_destroy = %d", err);
185 void WindowManager::notificationFunc_non_static(ilmObjectType object,
189 qDebug("notificationFunc_non_static");
190 if (ILM_SURFACE == object)
192 struct ilmSurfaceProperties surfaceProperties;
196 qDebug("Surface created, ID: %d", id);
198 ilm_layerAddSurface(42 /*always use layer 42 for now*/, id);
199 ilm_surfaceSetOpacity(id, 1.0);
200 ilm_surfaceSetVisibility(id, true);
201 ilm_getPropertiesOfSurface(id, &surfaceProperties);
202 ilm_surfaceSetSourceRectangle(id, 0, 0, surfaceProperties.origSourceWidth, surfaceProperties.origSourceHeight);
208 qDebug("Surface destroyed, ID: %d", id);
211 t_ilm_uint screenID = 0;
214 ilm_getScreenResolution(screenID, &width, &height);
217 t_ilm_surface* pArray;
219 ilm_getSurfaceIDs(&length, &pArray);
220 qDebug("length %d", length);
223 for (int i = 0; i < length; ++i)
225 //ilm_getPropertiesOfSurface(pArray[i], &surfaceProperties);
226 qDebug("place surface %d at x: %f, y: %f, width: %f, height: %f",
228 i * (width / (1.0 * length)),
230 width / (1.0 * length),
232 ilm_surfaceSetDestinationRectangle(pArray[(int)i],
233 i * (width / (1.0 * length)),
235 width / (1.0 * length),
241 if (ILM_LAYER == object)
243 qDebug("Layer.. we don't care...");
247 void WindowManager::notificationFunc_static(ilmObjectType object,
252 qDebug("notificationFunc_static");
253 static_cast<WindowManager*>(user_data)->notificationFunc_non_static(object, id, created);