1 /* 2 * Copyright 2001-2008, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stefano Ceccherini <stefano.ceccherini@gmail.com> 7 */ 8 #ifndef _DIRECT_WINDOW_H 9 #define _DIRECT_WINDOW_H 10 11 #include <Region.h> 12 #include <Window.h> 13 14 15 enum direct_buffer_state { 16 B_DIRECT_MODE_MASK = 15, 17 18 B_DIRECT_START = 0, 19 B_DIRECT_STOP = 1, 20 B_DIRECT_MODIFY = 2, 21 22 B_CLIPPING_MODIFIED = 16, 23 B_BUFFER_RESIZED = 32, 24 B_BUFFER_MOVED = 64, 25 B_BUFFER_RESET = 128 26 }; 27 28 29 enum direct_driver_state { 30 B_DRIVER_CHANGED = 0x0001, 31 B_MODE_CHANGED = 0x0002 32 }; 33 34 35 typedef struct { 36 direct_buffer_state buffer_state; 37 direct_driver_state driver_state; 38 void *bits; 39 void *pci_bits; 40 int32 bytes_per_row; 41 uint32 bits_per_pixel; 42 color_space pixel_format; 43 buffer_layout layout; 44 buffer_orientation orientation; 45 uint32 _reserved[9]; 46 uint32 _dd_type_; 47 uint32 _dd_token_; 48 uint32 clip_list_count; 49 clipping_rect window_bounds; 50 clipping_rect clip_bounds; 51 clipping_rect clip_list[1]; 52 } direct_buffer_info; 53 54 55 class BDirectWindow : public BWindow { 56 public: 57 BDirectWindow(BRect frame, const char *title, window_type type, 58 uint32 flags, uint32 workspace = B_CURRENT_WORKSPACE); 59 BDirectWindow(BRect frame, const char *title, window_look look, 60 window_feel feel, uint32 flags, 61 uint32 workspace = B_CURRENT_WORKSPACE); 62 virtual ~BDirectWindow(); 63 64 static BArchivable* Instantiate(BMessage *data); 65 virtual status_t Archive(BMessage *data, bool deep = true) const; 66 67 virtual void Quit(); 68 virtual void DispatchMessage(BMessage *message, BHandler *handler); 69 virtual void MessageReceived(BMessage *message); 70 virtual void FrameMoved(BPoint newPosition); 71 virtual void WorkspacesChanged(uint32 oldWorkspaces, 72 uint32 newWorkspaces); 73 virtual void WorkspaceActivated(int32 workspaceIndex, bool state); 74 virtual void FrameResized(float newWidth, float newHeight); 75 virtual void Minimize(bool minimize); 76 virtual void Zoom(BPoint recPosition, float recWidth, 77 float recHeight); 78 virtual void ScreenChanged(BRect screenFrame, color_space depth); 79 virtual void MenusBeginning(); 80 virtual void MenusEnded(); 81 virtual void WindowActivated(bool state); 82 virtual void Show(); 83 virtual void Hide(); 84 virtual BHandler* ResolveSpecifier(BMessage *message, int32 index, 85 BMessage *specifier, int32 form, 86 const char *property); 87 virtual status_t GetSupportedSuites(BMessage *data); 88 virtual status_t Perform(perform_code code, void *arg); 89 90 private: 91 virtual void task_looper(); 92 virtual BMessage* ConvertToMessage(void *raw, int32 code); 93 94 public: 95 virtual void DirectConnected(direct_buffer_info *info); 96 status_t GetClippingRegion(BRegion *region, 97 BPoint *origin = NULL) const; 98 status_t SetFullScreen(bool enable); 99 bool IsFullScreen() const; 100 101 static bool SupportsWindowMode(screen_id id = B_MAIN_SCREEN_ID); 102 103 private: 104 typedef BWindow inherited; 105 106 virtual void _ReservedDirectWindow1(); 107 virtual void _ReservedDirectWindow2(); 108 virtual void _ReservedDirectWindow3(); 109 virtual void _ReservedDirectWindow4(); 110 111 BDirectWindow(); 112 BDirectWindow(BDirectWindow& other); 113 BDirectWindow& operator=(BDirectWindow& other); 114 115 static int32 _daemon_thread(void* arg); 116 int32 _DirectDaemon(); 117 bool _LockDirect() const; 118 void _UnlockDirect() const; 119 120 void _InitData(); 121 void _DisposeData(); 122 123 bool fDaemonKiller; 124 bool fConnectionEnable; 125 bool fIsFullScreen; 126 bool _unused; 127 bool fInDirectConnect; 128 129 int32 fDirectLock; 130 sem_id fDirectSem; 131 uint32 fDirectLockCount; 132 thread_id fDirectLockOwner; 133 char* fDirectLockStack; 134 135 sem_id fDisableSem; 136 sem_id fDisableSemAck; 137 138 uint32 fInitStatus; 139 uint32 fInfoAreaSize; 140 141 uint32 _reserved[2]; 142 143 area_id fClonedClippingArea; 144 area_id fSourceClippingArea; 145 thread_id fDirectDaemonId; 146 direct_buffer_info* fBufferDesc; 147 148 uint32 _more_reserved_[17]; 149 }; 150 151 #endif // _DIRECT_WINDOW_H 152