1624df6c6SStefano Ceccherini //------------------------------------------------------------------------------ 21f41d635SStefano Ceccherini // Copyright (c) 2002-2005, Haiku 3624df6c6SStefano Ceccherini // 4624df6c6SStefano Ceccherini // Permission is hereby granted, free of charge, to any person obtaining a 5624df6c6SStefano Ceccherini // copy of this software and associated documentation files (the "Software"), 6624df6c6SStefano Ceccherini // to deal in the Software without restriction, including without limitation 7624df6c6SStefano Ceccherini // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8624df6c6SStefano Ceccherini // and/or sell copies of the Software, and to permit persons to whom the 9624df6c6SStefano Ceccherini // Software is furnished to do so, subject to the following conditions: 10624df6c6SStefano Ceccherini // 11624df6c6SStefano Ceccherini // The above copyright notice and this permission notice shall be included in 12624df6c6SStefano Ceccherini // all copies or substantial portions of the Software. 13624df6c6SStefano Ceccherini // 14624df6c6SStefano Ceccherini // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15624df6c6SStefano Ceccherini // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16624df6c6SStefano Ceccherini // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17624df6c6SStefano Ceccherini // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18624df6c6SStefano Ceccherini // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19624df6c6SStefano Ceccherini // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20624df6c6SStefano Ceccherini // DEALINGS IN THE SOFTWARE. 21624df6c6SStefano Ceccherini // 22624df6c6SStefano Ceccherini // File Name: PrivateScreen.cpp 23624df6c6SStefano Ceccherini // Author: Stefano Ceccherini (burton666@libero.it) 24624df6c6SStefano Ceccherini // Description: BPrivateScreen is the class which does the real work 25624df6c6SStefano Ceccherini // for the proxy class BScreen (it interacts with the app server). 26624df6c6SStefano Ceccherini //------------------------------------------------------------------------------ 278eae8b05SStefano Ceccherini #include <Debug.h> 288eae8b05SStefano Ceccherini #include <Locker.h> 29624df6c6SStefano Ceccherini #include <Window.h> 30314a1024SStefano Ceccherini 31bbc3515bSAxel Dörfler #include <stdlib.h> 32624df6c6SStefano Ceccherini 3334c39bf0SStefano Ceccherini #include "AppServerLink.h" 34624df6c6SStefano Ceccherini #include "PrivateScreen.h" 3534c39bf0SStefano Ceccherini #include "ServerProtocol.h" 3639ffb980SStefano Ceccherini 37624df6c6SStefano Ceccherini 38624df6c6SStefano Ceccherini // TODO: We should define this somewhere else 39624df6c6SStefano Ceccherini // We could find how R5 defines this, though it's not strictly necessary 4039ffb980SStefano Ceccherini // AFAIK, R5 here keeps also the screen width, height, colorspace, and some other things 4139ffb980SStefano Ceccherini // (it's 48 bytes big) 42624df6c6SStefano Ceccherini struct screen_desc { 43624df6c6SStefano Ceccherini void *base_address; 44624df6c6SStefano Ceccherini uint32 bytes_per_row; 45624df6c6SStefano Ceccherini }; 46624df6c6SStefano Ceccherini 47624df6c6SStefano Ceccherini 488eae8b05SStefano Ceccherini static BPrivateScreen *sScreen; 498eae8b05SStefano Ceccherini static int32 sScreenRefCount; 508eae8b05SStefano Ceccherini 518eae8b05SStefano Ceccherini // used to synchronize creation/deletion of the sScreen object 528eae8b05SStefano Ceccherini static BLocker sScreenLock("screen lock"); 53624df6c6SStefano Ceccherini 54624df6c6SStefano Ceccherini 55ca8ed922SStefano Ceccherini using namespace BPrivate; 56ca8ed922SStefano Ceccherini 57624df6c6SStefano Ceccherini BPrivateScreen * 58624df6c6SStefano Ceccherini BPrivateScreen::CheckOut(BWindow *win) 59624df6c6SStefano Ceccherini { 608eae8b05SStefano Ceccherini sScreenLock.Lock(); 618eae8b05SStefano Ceccherini 628eae8b05SStefano Ceccherini if (atomic_add(&sScreenRefCount, 1) == 0) { 6339ffb980SStefano Ceccherini // TODO: If we start supporting multiple monitors, we 6439ffb980SStefano Ceccherini // should return the right screen for the passed BWindow 658eae8b05SStefano Ceccherini ASSERT(sScreen == NULL); 668eae8b05SStefano Ceccherini sScreen = new BPrivateScreen(); 678eae8b05SStefano Ceccherini } 688eae8b05SStefano Ceccherini 698eae8b05SStefano Ceccherini sScreenLock.Unlock(); 708eae8b05SStefano Ceccherini 718eae8b05SStefano Ceccherini return sScreen; 72624df6c6SStefano Ceccherini } 73624df6c6SStefano Ceccherini 74624df6c6SStefano Ceccherini 75624df6c6SStefano Ceccherini BPrivateScreen * 76624df6c6SStefano Ceccherini BPrivateScreen::CheckOut(screen_id id) 77624df6c6SStefano Ceccherini { 788eae8b05SStefano Ceccherini sScreenLock.Lock(); 798eae8b05SStefano Ceccherini 808eae8b05SStefano Ceccherini if (atomic_add(&sScreenRefCount, 1) == 0) { 8139ffb980SStefano Ceccherini // TODO: If we start supporting multiple monitors, we 8239ffb980SStefano Ceccherini // should return the right object for the given screen_id 838eae8b05SStefano Ceccherini ASSERT(sScreen == NULL); 848eae8b05SStefano Ceccherini sScreen = new BPrivateScreen(); 858eae8b05SStefano Ceccherini } 868eae8b05SStefano Ceccherini 878eae8b05SStefano Ceccherini sScreenLock.Unlock(); 888eae8b05SStefano Ceccherini 898eae8b05SStefano Ceccherini return sScreen; 90624df6c6SStefano Ceccherini } 91624df6c6SStefano Ceccherini 92624df6c6SStefano Ceccherini 93624df6c6SStefano Ceccherini void 94624df6c6SStefano Ceccherini BPrivateScreen::Return(BPrivateScreen *screen) 95624df6c6SStefano Ceccherini { 968eae8b05SStefano Ceccherini sScreenLock.Lock(); 978eae8b05SStefano Ceccherini 988eae8b05SStefano Ceccherini if (atomic_add(&sScreenRefCount, -1) == 1) { 998eae8b05SStefano Ceccherini // TODO: Check if the passed object is the same we are deleting 1008eae8b05SStefano Ceccherini // here. Not much important for now though, since we only have one. 1018eae8b05SStefano Ceccherini delete sScreen; 1028eae8b05SStefano Ceccherini sScreen = NULL; 1038eae8b05SStefano Ceccherini } 1048eae8b05SStefano Ceccherini 1058eae8b05SStefano Ceccherini sScreenLock.Unlock(); 106624df6c6SStefano Ceccherini } 107624df6c6SStefano Ceccherini 108624df6c6SStefano Ceccherini 109624df6c6SStefano Ceccherini status_t 110624df6c6SStefano Ceccherini BPrivateScreen::SetToNext() 111624df6c6SStefano Ceccherini { 112624df6c6SStefano Ceccherini // This function always returns B_ERROR 113624df6c6SStefano Ceccherini return B_ERROR; 114624df6c6SStefano Ceccherini } 115624df6c6SStefano Ceccherini 116624df6c6SStefano Ceccherini 117624df6c6SStefano Ceccherini color_space 118624df6c6SStefano Ceccherini BPrivateScreen::ColorSpace() 119624df6c6SStefano Ceccherini { 120624df6c6SStefano Ceccherini display_mode mode; 1211f41d635SStefano Ceccherini if (GetMode(B_CURRENT_WORKSPACE, &mode) == B_OK) 122624df6c6SStefano Ceccherini return (color_space)mode.space; 123624df6c6SStefano Ceccherini 124624df6c6SStefano Ceccherini return B_NO_COLOR_SPACE; 125624df6c6SStefano Ceccherini } 126624df6c6SStefano Ceccherini 127624df6c6SStefano Ceccherini 128624df6c6SStefano Ceccherini BRect 129624df6c6SStefano Ceccherini BPrivateScreen::Frame() 130624df6c6SStefano Ceccherini { 13139ffb980SStefano Ceccherini // If something goes wrong, we just return this rectangle. 13239ffb980SStefano Ceccherini BRect rect(0, 0, 0, 0); 133624df6c6SStefano Ceccherini display_mode mode; 13434c39bf0SStefano Ceccherini if (GetMode(B_CURRENT_WORKSPACE, &mode) == B_OK) 13539ffb980SStefano Ceccherini rect.Set(0, 0, (float)mode.virtual_width - 1, (float)mode.virtual_height - 1); 13639ffb980SStefano Ceccherini 13739ffb980SStefano Ceccherini return rect; 138624df6c6SStefano Ceccherini } 139624df6c6SStefano Ceccherini 140624df6c6SStefano Ceccherini 141624df6c6SStefano Ceccherini screen_id 142624df6c6SStefano Ceccherini BPrivateScreen::ID() 143624df6c6SStefano Ceccherini { 14439ffb980SStefano Ceccherini // TODO: Change this if we start supporting multiple screens 145624df6c6SStefano Ceccherini return B_MAIN_SCREEN_ID; 146624df6c6SStefano Ceccherini } 147624df6c6SStefano Ceccherini 148624df6c6SStefano Ceccherini 149624df6c6SStefano Ceccherini status_t 150624df6c6SStefano Ceccherini BPrivateScreen::WaitForRetrace(bigtime_t timeout) 151624df6c6SStefano Ceccherini { 152624df6c6SStefano Ceccherini // Get the retrace semaphore if it's the first time 153624df6c6SStefano Ceccherini // we are called. Cache the value then. 154624df6c6SStefano Ceccherini status_t status; 155624df6c6SStefano Ceccherini if (fRetraceSem == -1) 156624df6c6SStefano Ceccherini fRetraceSem = RetraceSemaphore(); 157624df6c6SStefano Ceccherini 158624df6c6SStefano Ceccherini do { 159624df6c6SStefano Ceccherini status = acquire_sem_etc(fRetraceSem, 1, B_RELATIVE_TIMEOUT, timeout); 160624df6c6SStefano Ceccherini } while (status == B_INTERRUPTED); 161624df6c6SStefano Ceccherini 162624df6c6SStefano Ceccherini return status; 163624df6c6SStefano Ceccherini } 164624df6c6SStefano Ceccherini 165624df6c6SStefano Ceccherini 166624df6c6SStefano Ceccherini sem_id 167624df6c6SStefano Ceccherini BPrivateScreen::RetraceSemaphore() 168624df6c6SStefano Ceccherini { 169624df6c6SStefano Ceccherini sem_id id = B_BAD_SEM_ID; 170624df6c6SStefano Ceccherini // TODO: Implement 17139ffb980SStefano Ceccherini /* 17239ffb980SStefano Ceccherini BAppServerLink link; 17339ffb980SStefano Ceccherini PortMessage reply; 17439ffb980SStefano Ceccherini link.SetOpCode(AS_GET_RETRACE_SEMAPHORE); 17539ffb980SStefano Ceccherini link.Attach<screen_id>(ID()); 17639ffb980SStefano Ceccherini link.FlushWithReply(&reply); 17739ffb980SStefano Ceccherini reply.Read<sem_id>(&id); 17839ffb980SStefano Ceccherini */ 179624df6c6SStefano Ceccherini return id; 180624df6c6SStefano Ceccherini } 181624df6c6SStefano Ceccherini 182624df6c6SStefano Ceccherini 183624df6c6SStefano Ceccherini 184624df6c6SStefano Ceccherini uint8 185624df6c6SStefano Ceccherini BPrivateScreen::IndexForColor(uint8 red, uint8 green, uint8 blue, uint8 alpha) 186624df6c6SStefano Ceccherini { 187624df6c6SStefano Ceccherini // Looks like this check is necessary 188624df6c6SStefano Ceccherini if (red == B_TRANSPARENT_COLOR.red && green == B_TRANSPARENT_COLOR.green && 189624df6c6SStefano Ceccherini blue == B_TRANSPARENT_COLOR.blue && alpha == B_TRANSPARENT_COLOR.alpha) 190624df6c6SStefano Ceccherini return B_TRANSPARENT_8_BIT; 191624df6c6SStefano Ceccherini 192*2ed35bc8SStefano Ceccherini uint8 index = ((red & 0xf8) << 7) | ((green & 0xf8) << 2) | (blue >> 3); 193624df6c6SStefano Ceccherini if (fColorMap) 194*2ed35bc8SStefano Ceccherini return fColorMap->index_map[index]; 195624df6c6SStefano Ceccherini 196624df6c6SStefano Ceccherini return 0; 197624df6c6SStefano Ceccherini } 198624df6c6SStefano Ceccherini 199624df6c6SStefano Ceccherini 200624df6c6SStefano Ceccherini rgb_color 201624df6c6SStefano Ceccherini BPrivateScreen::ColorForIndex(const uint8 index) 202624df6c6SStefano Ceccherini { 203624df6c6SStefano Ceccherini if (fColorMap) 204624df6c6SStefano Ceccherini return fColorMap->color_list[index]; 205624df6c6SStefano Ceccherini 206624df6c6SStefano Ceccherini return rgb_color(); 207624df6c6SStefano Ceccherini } 208624df6c6SStefano Ceccherini 209624df6c6SStefano Ceccherini 210624df6c6SStefano Ceccherini uint8 211624df6c6SStefano Ceccherini BPrivateScreen::InvertIndex(uint8 index) 212624df6c6SStefano Ceccherini { 213624df6c6SStefano Ceccherini if (fColorMap) 214624df6c6SStefano Ceccherini return fColorMap->inversion_map[index]; 215624df6c6SStefano Ceccherini 216624df6c6SStefano Ceccherini return 0; 217624df6c6SStefano Ceccherini } 218624df6c6SStefano Ceccherini 219624df6c6SStefano Ceccherini 220624df6c6SStefano Ceccherini const color_map * 221624df6c6SStefano Ceccherini BPrivateScreen::ColorMap() 222624df6c6SStefano Ceccherini { 223624df6c6SStefano Ceccherini return fColorMap; 224624df6c6SStefano Ceccherini } 225624df6c6SStefano Ceccherini 226624df6c6SStefano Ceccherini 227624df6c6SStefano Ceccherini status_t 228624df6c6SStefano Ceccherini BPrivateScreen::GetBitmap(BBitmap **bitmap, bool drawCursor, BRect *bound) 229624df6c6SStefano Ceccherini { 230624df6c6SStefano Ceccherini // TODO: Implement 231624df6c6SStefano Ceccherini return B_ERROR; 232624df6c6SStefano Ceccherini } 233624df6c6SStefano Ceccherini 234624df6c6SStefano Ceccherini 235624df6c6SStefano Ceccherini status_t 236624df6c6SStefano Ceccherini BPrivateScreen::ReadBitmap(BBitmap *bitmap, bool drawCursor, BRect *bound) 237624df6c6SStefano Ceccherini { 238624df6c6SStefano Ceccherini // TODO: Implement 239624df6c6SStefano Ceccherini return B_ERROR; 240624df6c6SStefano Ceccherini } 241624df6c6SStefano Ceccherini 242624df6c6SStefano Ceccherini 243624df6c6SStefano Ceccherini rgb_color 24439ffb980SStefano Ceccherini BPrivateScreen::DesktopColor(uint32 workspace) 245624df6c6SStefano Ceccherini { 2463ba7d6f3SAxel Dörfler rgb_color color = { 51, 102, 152, 255 }; 24739ffb980SStefano Ceccherini BAppServerLink link; 2483ba7d6f3SAxel Dörfler 2493ba7d6f3SAxel Dörfler link.StartMessage(AS_GET_DESKTOP_COLOR); 25039ffb980SStefano Ceccherini link.Attach<int32>(workspace); 2513ba7d6f3SAxel Dörfler 2523ba7d6f3SAxel Dörfler int32 code; 2533ba7d6f3SAxel Dörfler if (link.FlushWithReply(&code) == B_OK 2543ba7d6f3SAxel Dörfler && code == SERVER_TRUE) 2553ba7d6f3SAxel Dörfler link.Read<rgb_color>(&color); 2563ba7d6f3SAxel Dörfler 25739ffb980SStefano Ceccherini return color; 258624df6c6SStefano Ceccherini } 259624df6c6SStefano Ceccherini 260624df6c6SStefano Ceccherini 261624df6c6SStefano Ceccherini void 26239ffb980SStefano Ceccherini BPrivateScreen::SetDesktopColor(rgb_color color, uint32 workspace, bool makeDefault) 263624df6c6SStefano Ceccherini { 26439ffb980SStefano Ceccherini BAppServerLink link; 2653ba7d6f3SAxel Dörfler 2663ba7d6f3SAxel Dörfler link.StartMessage(AS_SET_DESKTOP_COLOR); 26739ffb980SStefano Ceccherini link.Attach<rgb_color>(color); 26839ffb980SStefano Ceccherini link.Attach<int32>(workspace); 26939ffb980SStefano Ceccherini link.Attach<bool>(makeDefault); 27039ffb980SStefano Ceccherini link.Flush(); 271624df6c6SStefano Ceccherini } 272624df6c6SStefano Ceccherini 273624df6c6SStefano Ceccherini 274624df6c6SStefano Ceccherini status_t 275624df6c6SStefano Ceccherini BPrivateScreen::ProposeMode(display_mode *target, const display_mode *low, const display_mode *high) 276624df6c6SStefano Ceccherini { 277624df6c6SStefano Ceccherini // TODO: Implement 278624df6c6SStefano Ceccherini return B_ERROR; 279624df6c6SStefano Ceccherini } 280624df6c6SStefano Ceccherini 281624df6c6SStefano Ceccherini 282624df6c6SStefano Ceccherini status_t 283624df6c6SStefano Ceccherini BPrivateScreen::GetModeList(display_mode **mode_list, uint32 *count) 284624df6c6SStefano Ceccherini { 285624df6c6SStefano Ceccherini // TODO: Implement 286624df6c6SStefano Ceccherini return B_ERROR; 287624df6c6SStefano Ceccherini } 288624df6c6SStefano Ceccherini 289624df6c6SStefano Ceccherini 290624df6c6SStefano Ceccherini status_t 291624df6c6SStefano Ceccherini BPrivateScreen::GetMode(uint32 workspace, display_mode *mode) 292624df6c6SStefano Ceccherini { 293314a1024SStefano Ceccherini if (mode == NULL) 294314a1024SStefano Ceccherini return B_BAD_VALUE; 295314a1024SStefano Ceccherini 29639ffb980SStefano Ceccherini BAppServerLink link; 29734c39bf0SStefano Ceccherini link.StartMessage(AS_SCREEN_GET_MODE); 29834c39bf0SStefano Ceccherini link.Attach<screen_id>(ID()); 29939ffb980SStefano Ceccherini link.Attach<uint32>(workspace); 300fca6492fSStefano Ceccherini 301fca6492fSStefano Ceccherini int32 code = SERVER_FALSE; 302fca6492fSStefano Ceccherini link.FlushWithReply(&code); 303fca6492fSStefano Ceccherini 304fca6492fSStefano Ceccherini if (code != SERVER_TRUE) 305fca6492fSStefano Ceccherini return B_ERROR; 30639ffb980SStefano Ceccherini 30734c39bf0SStefano Ceccherini display_mode currentMode; 30834c39bf0SStefano Ceccherini link.Read<display_mode>(¤tMode); 30934c39bf0SStefano Ceccherini 31034c39bf0SStefano Ceccherini status_t status = B_ERROR; 31134c39bf0SStefano Ceccherini link.Read<status_t>(&status); 31239ffb980SStefano Ceccherini if (status == B_OK && mode) 31339ffb980SStefano Ceccherini *mode = currentMode; 31434c39bf0SStefano Ceccherini 31539ffb980SStefano Ceccherini return status; 316624df6c6SStefano Ceccherini } 317624df6c6SStefano Ceccherini 318624df6c6SStefano Ceccherini 319624df6c6SStefano Ceccherini status_t 320624df6c6SStefano Ceccherini BPrivateScreen::SetMode(uint32 workspace, display_mode *mode, bool makeDefault) 321624df6c6SStefano Ceccherini { 322314a1024SStefano Ceccherini if (mode == NULL) 323314a1024SStefano Ceccherini return B_BAD_VALUE; 324314a1024SStefano Ceccherini 32539ffb980SStefano Ceccherini BAppServerLink link; 326314a1024SStefano Ceccherini link.StartMessage(AS_SCREEN_SET_MODE); 327314a1024SStefano Ceccherini link.Attach<screen_id>(ID()); 32839ffb980SStefano Ceccherini link.Attach<uint32>(workspace); 32939ffb980SStefano Ceccherini link.Attach<display_mode>(*mode); 33039ffb980SStefano Ceccherini link.Attach<bool>(makeDefault); 331314a1024SStefano Ceccherini 332314a1024SStefano Ceccherini int32 code = SERVER_FALSE; 333314a1024SStefano Ceccherini link.FlushWithReply(&code); 334314a1024SStefano Ceccherini 335314a1024SStefano Ceccherini status_t status = B_ERROR; 336314a1024SStefano Ceccherini if (code == SERVER_TRUE) 337314a1024SStefano Ceccherini link.Read<status_t>(&status); 338314a1024SStefano Ceccherini 33939ffb980SStefano Ceccherini return status; 340624df6c6SStefano Ceccherini } 341624df6c6SStefano Ceccherini 342624df6c6SStefano Ceccherini 343624df6c6SStefano Ceccherini status_t 344624df6c6SStefano Ceccherini BPrivateScreen::GetDeviceInfo(accelerant_device_info *info) 345624df6c6SStefano Ceccherini { 346624df6c6SStefano Ceccherini // TODO: Implement 347624df6c6SStefano Ceccherini return B_ERROR; 348624df6c6SStefano Ceccherini } 349624df6c6SStefano Ceccherini 350624df6c6SStefano Ceccherini 351624df6c6SStefano Ceccherini status_t 352624df6c6SStefano Ceccherini BPrivateScreen::GetPixelClockLimits(display_mode *mode, uint32 *low, uint32 *high) 353624df6c6SStefano Ceccherini { 354624df6c6SStefano Ceccherini // TODO: Implement 355624df6c6SStefano Ceccherini return B_ERROR; 356624df6c6SStefano Ceccherini } 357624df6c6SStefano Ceccherini 358624df6c6SStefano Ceccherini 359624df6c6SStefano Ceccherini status_t 360624df6c6SStefano Ceccherini BPrivateScreen::GetTimingConstraints(display_timing_constraints *dtc) 361624df6c6SStefano Ceccherini { 362624df6c6SStefano Ceccherini // TODO: Implement 363624df6c6SStefano Ceccherini return B_ERROR; 364624df6c6SStefano Ceccherini } 365624df6c6SStefano Ceccherini 366624df6c6SStefano Ceccherini 367624df6c6SStefano Ceccherini status_t 368624df6c6SStefano Ceccherini BPrivateScreen::SetDPMS(uint32 dpmsState) 369624df6c6SStefano Ceccherini { 37039ffb980SStefano Ceccherini status_t status = B_ERROR; 37139ffb980SStefano Ceccherini /* 37239ffb980SStefano Ceccherini BAppServerLink link; 37339ffb980SStefano Ceccherini PortMessage reply; 37439ffb980SStefano Ceccherini link.SetOpCode(AS_SET_DPMS); 37539ffb980SStefano Ceccherini link.Attach<screen_id>(ID()); 37639ffb980SStefano Ceccherini link.Attach<uint32>(dpmsState); 37739ffb980SStefano Ceccherini link.FlushWithReply(&reply); 37839ffb980SStefano Ceccherini reply.Read<status_t>(&status); 37939ffb980SStefano Ceccherini */ 38039ffb980SStefano Ceccherini return status; 381624df6c6SStefano Ceccherini } 382624df6c6SStefano Ceccherini 383624df6c6SStefano Ceccherini 384624df6c6SStefano Ceccherini uint32 385624df6c6SStefano Ceccherini BPrivateScreen::DPMSState() 386624df6c6SStefano Ceccherini { 387624df6c6SStefano Ceccherini // TODO: Implement 38839ffb980SStefano Ceccherini uint32 state = 0; 38939ffb980SStefano Ceccherini /* 39039ffb980SStefano Ceccherini BAppServerLink link; 39139ffb980SStefano Ceccherini PortMessage reply; 39239ffb980SStefano Ceccherini link.SetOpCode(AS_GET_DPMS_STATE); 39339ffb980SStefano Ceccherini link.Attach<screen_id>(ID()); 39439ffb980SStefano Ceccherini link.FlushWithReply(&reply); 39539ffb980SStefano Ceccherini reply.Read<uint32>(&state); 39639ffb980SStefano Ceccherini */ 39739ffb980SStefano Ceccherini return state; 398624df6c6SStefano Ceccherini } 399624df6c6SStefano Ceccherini 400624df6c6SStefano Ceccherini 401624df6c6SStefano Ceccherini uint32 402624df6c6SStefano Ceccherini BPrivateScreen::DPMSCapabilites() 403624df6c6SStefano Ceccherini { 404624df6c6SStefano Ceccherini // TODO: Implement 40539ffb980SStefano Ceccherini uint32 capabilities = 0; 40639ffb980SStefano Ceccherini /* 40739ffb980SStefano Ceccherini BAppServerLink link; 40839ffb980SStefano Ceccherini PortMessage reply; 40939ffb980SStefano Ceccherini link.SetOpCode(AS_GET_DPMS_CAPABILITIES); 41039ffb980SStefano Ceccherini link.Attach<screen_id>(ID()); 41139ffb980SStefano Ceccherini link.FlushWithReply(&reply); 41239ffb980SStefano Ceccherini reply.Read<uint32>(&capabilities); 41339ffb980SStefano Ceccherini */ 41439ffb980SStefano Ceccherini return capabilities; 415624df6c6SStefano Ceccherini } 416624df6c6SStefano Ceccherini 417624df6c6SStefano Ceccherini 418624df6c6SStefano Ceccherini void * 419624df6c6SStefano Ceccherini BPrivateScreen::BaseAddress() 420624df6c6SStefano Ceccherini { 421624df6c6SStefano Ceccherini screen_desc desc; 422624df6c6SStefano Ceccherini if (get_screen_desc(&desc) == B_OK) 423624df6c6SStefano Ceccherini return desc.base_address; 424624df6c6SStefano Ceccherini 425624df6c6SStefano Ceccherini return NULL; 426624df6c6SStefano Ceccherini } 427624df6c6SStefano Ceccherini 428624df6c6SStefano Ceccherini 429624df6c6SStefano Ceccherini uint32 430624df6c6SStefano Ceccherini BPrivateScreen::BytesPerRow() 431624df6c6SStefano Ceccherini { 432624df6c6SStefano Ceccherini screen_desc desc; 433624df6c6SStefano Ceccherini if (get_screen_desc(&desc) == B_OK) 434624df6c6SStefano Ceccherini return desc.bytes_per_row; 435624df6c6SStefano Ceccherini return 0; 436624df6c6SStefano Ceccherini } 437624df6c6SStefano Ceccherini 438624df6c6SStefano Ceccherini 439624df6c6SStefano Ceccherini status_t 440624df6c6SStefano Ceccherini BPrivateScreen::get_screen_desc(screen_desc *desc) 441624df6c6SStefano Ceccherini { 44239ffb980SStefano Ceccherini status_t status = B_ERROR; 44339ffb980SStefano Ceccherini /* 44439ffb980SStefano Ceccherini BAppServerLink link; 44539ffb980SStefano Ceccherini PortMessage reply; 44639ffb980SStefano Ceccherini link.SetOpCode(AS_GET_SCREEN_DESC); 44739ffb980SStefano Ceccherini link.Attach<screen_id>(ID()); 44839ffb980SStefano Ceccherini link.FlushWithReply(&reply); 44939ffb980SStefano Ceccherini reply.Read<screen_desc>(*desc); 45039ffb980SStefano Ceccherini reply.Read<status_t>(&status); 45139ffb980SStefano Ceccherini */ 45239ffb980SStefano Ceccherini return status; 453624df6c6SStefano Ceccherini } 454624df6c6SStefano Ceccherini 455624df6c6SStefano Ceccherini 456624df6c6SStefano Ceccherini // Private, called by BApplication::get_scs() 457624df6c6SStefano Ceccherini BPrivateScreen::BPrivateScreen() 458624df6c6SStefano Ceccherini : 459624df6c6SStefano Ceccherini fColorMap(NULL), 460624df6c6SStefano Ceccherini fRetraceSem(-1), 461624df6c6SStefano Ceccherini fOwnsColorMap(false) 462624df6c6SStefano Ceccherini { 4637475dcdfSStefano Ceccherini // TODO: BeOS R5 here gets the colormap pointer 4647475dcdfSStefano Ceccherini // (with BApplication::ro_offset_to_ptr() ?) 4657475dcdfSStefano Ceccherini // which is contained in a shared area created by the server. 4667475dcdfSStefano Ceccherini BAppServerLink link; 4677475dcdfSStefano Ceccherini link.StartMessage(AS_SCREEN_GET_COLORMAP); 4687475dcdfSStefano Ceccherini link.Attach<screen_id>(ID()); 4697475dcdfSStefano Ceccherini int32 reply; 4707475dcdfSStefano Ceccherini link.FlushWithReply(&reply); 4717475dcdfSStefano Ceccherini if (reply == SERVER_TRUE) { 4727475dcdfSStefano Ceccherini fColorMap = (color_map *)malloc(sizeof(color_map)); 4737475dcdfSStefano Ceccherini fOwnsColorMap = true; 474*2ed35bc8SStefano Ceccherini link.Read<color_map>(fColorMap); 4757475dcdfSStefano Ceccherini } 476624df6c6SStefano Ceccherini } 477624df6c6SStefano Ceccherini 478624df6c6SStefano Ceccherini 479624df6c6SStefano Ceccherini BPrivateScreen::~BPrivateScreen() 480624df6c6SStefano Ceccherini { 481624df6c6SStefano Ceccherini if (fOwnsColorMap) 482624df6c6SStefano Ceccherini free(fColorMap); 483624df6c6SStefano Ceccherini } 484