1 /* 2 * Copyright 2003-2009, Haiku Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stefano Ceccherini (burton666@libero.it) 7 * Axel Dörfler, axeld@pinc-software.de 8 */ 9 10 11 #include <Screen.h> 12 13 #include <Window.h> 14 15 #include <PrivateScreen.h> 16 17 18 using namespace BPrivate; 19 20 21 BScreen::BScreen(screen_id id) 22 { 23 fScreen = BPrivateScreen::Get(id.id); 24 } 25 26 27 BScreen::BScreen(BWindow* window) 28 { 29 fScreen = BPrivateScreen::Get(window); 30 } 31 32 33 BScreen::~BScreen() 34 { 35 BPrivateScreen::Put(fScreen); 36 } 37 38 39 bool 40 BScreen::IsValid() 41 { 42 return fScreen != NULL && fScreen->IsValid(); 43 } 44 45 46 status_t 47 BScreen::SetToNext() 48 { 49 if (fScreen != NULL) { 50 BPrivateScreen* screen = BPrivateScreen::GetNext(fScreen); 51 if (screen != NULL) { 52 fScreen = screen; 53 return B_OK; 54 } 55 } 56 return B_ERROR; 57 } 58 59 60 color_space 61 BScreen::ColorSpace() 62 { 63 if (fScreen != NULL) 64 return fScreen->ColorSpace(); 65 66 return B_NO_COLOR_SPACE; 67 } 68 69 70 BRect 71 BScreen::Frame() 72 { 73 if (fScreen != NULL) 74 return fScreen->Frame(); 75 76 return BRect(0, 0, 0, 0); 77 } 78 79 80 screen_id 81 BScreen::ID() 82 { 83 if (fScreen != NULL) { 84 screen_id id = { fScreen->ID() }; 85 return id; 86 } 87 88 return B_MAIN_SCREEN_ID; 89 } 90 91 92 status_t 93 BScreen::WaitForRetrace() 94 { 95 return WaitForRetrace(B_INFINITE_TIMEOUT); 96 } 97 98 99 status_t 100 BScreen::WaitForRetrace(bigtime_t timeout) 101 { 102 if (fScreen != NULL) 103 return fScreen->WaitForRetrace(timeout); 104 105 return B_ERROR; 106 } 107 108 109 uint8 110 BScreen::IndexForColor(uint8 red, uint8 green, uint8 blue, uint8 alpha) 111 { 112 if (fScreen != NULL) 113 return fScreen->IndexForColor(red, green, blue, alpha); 114 115 return 0; 116 } 117 118 119 rgb_color 120 BScreen::ColorForIndex(const uint8 index) 121 { 122 if (fScreen != NULL) 123 return fScreen->ColorForIndex(index); 124 125 return rgb_color(); 126 } 127 128 129 uint8 130 BScreen::InvertIndex(uint8 index) 131 { 132 if (fScreen != NULL) 133 return fScreen->InvertIndex(index); 134 135 return 0; 136 } 137 138 139 const color_map* 140 BScreen::ColorMap() 141 { 142 if (fScreen != NULL) 143 return fScreen->ColorMap(); 144 145 return NULL; 146 } 147 148 149 status_t 150 BScreen::GetBitmap(BBitmap** _bitmap, bool drawCursor, BRect* bounds) 151 { 152 if (fScreen != NULL) 153 return fScreen->GetBitmap(_bitmap, drawCursor, bounds); 154 155 return B_ERROR; 156 } 157 158 159 status_t 160 BScreen::ReadBitmap(BBitmap* bitmap, bool drawCursor, BRect* bounds) 161 { 162 if (fScreen != NULL) 163 return fScreen->ReadBitmap(bitmap, drawCursor, bounds); 164 165 return B_ERROR; 166 } 167 168 169 rgb_color 170 BScreen::DesktopColor() 171 { 172 if (fScreen != NULL) 173 return fScreen->DesktopColor(B_CURRENT_WORKSPACE_INDEX); 174 175 return rgb_color(); 176 } 177 178 179 rgb_color 180 BScreen::DesktopColor(uint32 workspace) 181 { 182 if (fScreen != NULL) 183 return fScreen->DesktopColor(workspace); 184 185 return rgb_color(); 186 } 187 188 189 void 190 BScreen::SetDesktopColor(rgb_color color, bool stick) 191 { 192 if (fScreen != NULL) 193 fScreen->SetDesktopColor(color, B_CURRENT_WORKSPACE_INDEX, stick); 194 } 195 196 197 void 198 BScreen::SetDesktopColor(rgb_color color, uint32 workspace, bool stick) 199 { 200 if (fScreen != NULL) 201 fScreen->SetDesktopColor(color, workspace, stick); 202 } 203 204 205 status_t 206 BScreen::ProposeMode(display_mode* target, const display_mode* low, 207 const display_mode* high) 208 { 209 if (fScreen != NULL) 210 return fScreen->ProposeMode(target, low, high); 211 212 return B_ERROR; 213 } 214 215 216 status_t 217 BScreen::GetModeList(display_mode** _modeList, uint32* _count) 218 { 219 if (fScreen != NULL) 220 return fScreen->GetModeList(_modeList, _count); 221 222 return B_ERROR; 223 } 224 225 226 status_t 227 BScreen::GetMode(display_mode* mode) 228 { 229 if (fScreen != NULL) 230 return fScreen->GetMode(B_CURRENT_WORKSPACE_INDEX, mode); 231 232 return B_ERROR; 233 } 234 235 236 status_t 237 BScreen::GetMode(uint32 workspace, display_mode* mode) 238 { 239 if (fScreen != NULL) 240 return fScreen->GetMode(workspace, mode); 241 242 return B_ERROR; 243 } 244 245 246 status_t 247 BScreen::SetMode(display_mode* mode, bool makeDefault) 248 { 249 if (fScreen != NULL) 250 return fScreen->SetMode(B_CURRENT_WORKSPACE_INDEX, mode, makeDefault); 251 252 return B_ERROR; 253 } 254 255 256 status_t 257 BScreen::SetMode(uint32 workspace, display_mode* mode, bool makeDefault) 258 { 259 if (fScreen != NULL) 260 return fScreen->SetMode(workspace, mode, makeDefault); 261 262 return B_ERROR; 263 } 264 265 266 status_t 267 BScreen::GetDeviceInfo(accelerant_device_info* info) 268 { 269 if (fScreen != NULL) 270 return fScreen->GetDeviceInfo(info); 271 272 return B_ERROR; 273 } 274 275 276 status_t 277 BScreen::GetMonitorInfo(monitor_info* info) 278 { 279 if (fScreen != NULL) 280 return fScreen->GetMonitorInfo(info); 281 282 return B_ERROR; 283 } 284 285 286 status_t 287 BScreen::GetPixelClockLimits(display_mode* mode, uint32* _low, uint32* _high) 288 { 289 if (fScreen != NULL) 290 return fScreen->GetPixelClockLimits(mode, _low, _high); 291 292 return B_ERROR; 293 } 294 295 296 status_t 297 BScreen::GetTimingConstraints(display_timing_constraints* constraints) 298 { 299 if (fScreen != NULL) 300 return fScreen->GetTimingConstraints(constraints); 301 302 return B_ERROR; 303 } 304 305 306 status_t 307 BScreen::SetDPMS(uint32 dpmsState) 308 { 309 if (fScreen != NULL) 310 return fScreen->SetDPMS(dpmsState); 311 312 return B_ERROR; 313 } 314 315 316 uint32 317 BScreen::DPMSState() 318 { 319 if (fScreen != NULL) 320 return fScreen->DPMSState(); 321 322 return 0; 323 } 324 325 326 uint32 327 BScreen::DPMSCapabilites() 328 { 329 if (fScreen != NULL) 330 return fScreen->DPMSCapabilites(); 331 332 return 0; 333 } 334 335 336 // #pragma mark - Deprecated methods 337 338 339 BPrivate::BPrivateScreen* 340 BScreen::private_screen() 341 { 342 return fScreen; 343 } 344 345 346 status_t 347 BScreen::ProposeDisplayMode(display_mode* target, const display_mode* low, 348 const display_mode* high) 349 { 350 return ProposeMode(target, low, high); 351 } 352 353 354 void* 355 BScreen::BaseAddress() 356 { 357 if (fScreen != NULL) 358 return fScreen->BaseAddress(); 359 360 return NULL; 361 } 362 363 364 uint32 365 BScreen::BytesPerRow() 366 { 367 if (fScreen != NULL) 368 return fScreen->BytesPerRow(); 369 370 return 0; 371 } 372