src/video/bwindow/SDL_BWin.h
changeset 5925 262ce29aabf6
parent 5923 460ce3fb104c
child 5927 463b84c19645
     1.1 --- a/src/video/bwindow/SDL_BWin.h	Mon Jul 25 13:47:19 2011 +0000
     1.2 +++ b/src/video/bwindow/SDL_BWin.h	Mon Jul 25 16:46:55 2011 +0000
     1.3 @@ -64,47 +64,46 @@
     1.4      SDL_BWin(BRect bounds):BDirectWindow(bounds, "Untitled",
     1.5                                           B_TITLED_WINDOW, 0)
     1.6      {
     1.7 -        last_buttons = 0;
     1.8 -printf("SDL_BWin.h: 69\n");
     1.9 +        _last_buttons = 0;
    1.10  
    1.11  #if SDL_VIDEO_OPENGL
    1.12 -        SDL_GLView = NULL;
    1.13 +        _SDL_GLView = NULL;
    1.14  #endif
    1.15          _shown = false;
    1.16 -        inhibit_resize = false;
    1.17 -        mouse_focused = false;
    1.18 -        prev_frame = NULL; printf("SDL_BWin.h: 79\n");
    1.19 -        
    1.20 +        _inhibit_resize = false;
    1.21 +        _mouse_focused = false;
    1.22 +        _prev_frame = NULL;
    1.23 +
    1.24          /* Handle framebuffer stuff */
    1.25 -        _connected = connection_disabled = false;
    1.26 -        trash_window_buffer = false;
    1.27 -        buffer_locker = new BLocker();
    1.28 -        window_buffer = NULL;
    1.29 +        _connected = _connection_disabled = false;
    1.30 +        _trash__window_buffer = false;
    1.31 +        _buffer_locker = new BLocker();
    1.32 +        _window_buffer = NULL;
    1.33  //        LockBuffer();	/* Unlocked by buffer initialization */
    1.34      }
    1.35  
    1.36      virtual ~ SDL_BWin()
    1.37      {
    1.38          Lock();
    1.39 -        connection_disabled = true;
    1.40 +        _connection_disabled = true;
    1.41          
    1.42  #if SDL_VIDEO_OPENGL
    1.43 -        if (SDL_GLView) {
    1.44 -            SDL_GLView->UnlockGL();
    1.45 +        if (_SDL_GLView) {
    1.46 +            _SDL_GLView->UnlockGL();
    1.47          }
    1.48 -        RemoveChild(SDL_GLView);
    1.49 +        RemoveChild(_SDL_GLView);
    1.50  #endif    
    1.51          Unlock();
    1.52  #if SDL_VIDEO_OPENGL
    1.53 -        if (SDL_GLView) {
    1.54 -            delete SDL_GLView;
    1.55 +        if (_SDL_GLView) {
    1.56 +            delete _SDL_GLView;
    1.57          }
    1.58  #endif
    1.59          
    1.60          /* Clean up framebuffer stuff */
    1.61 -        buffer_locker->Lock();
    1.62 +        _buffer_locker->Lock();
    1.63          free(_clips);
    1.64 -        delete buffer_locker;
    1.65 +        delete _buffer_locker;
    1.66      }
    1.67      
    1.68  
    1.69 @@ -117,24 +116,24 @@
    1.70          retval = 0;
    1.71          Lock();
    1.72          if (flags & SDL_OPENGL/*SDL_INTERNALOPENGL*/) {
    1.73 -            if (SDL_GLView == NULL) {
    1.74 -                SDL_GLView = new BGLView(Bounds(), "SDL GLView",
    1.75 +            if (_SDL_GLView == NULL) {
    1.76 +                _SDL_GLView = new BGLView(Bounds(), "SDL GLView",
    1.77                                           B_FOLLOW_ALL_SIDES,
    1.78                                           (B_WILL_DRAW | B_FRAME_EVENTS),
    1.79                                           gl_flags);
    1.80              }
    1.81 -            if (the_view != SDL_GLView) {
    1.82 -                if (the_view) {
    1.83 -                    RemoveChild(the_view);
    1.84 +            if (_the_view != _SDL_GLView) {
    1.85 +                if (_the_view) {
    1.86 +                    RemoveChild(_the_view);
    1.87                  }
    1.88 -                AddChild(SDL_GLView);
    1.89 -                SDL_GLView->LockGL();
    1.90 -                the_view = SDL_GLView;
    1.91 +                AddChild(_SDL_GLView);
    1.92 +                _SDL_GLView->LockGL();
    1.93 +                _the_view = _SDL_GLView;
    1.94              }
    1.95          } else {
    1.96 -            if (the_view) {
    1.97 -                    SDL_GLView->UnlockGL();
    1.98 -                RemoveChild(the_view);
    1.99 +            if (_the_view) {
   1.100 +                    _SDL_GLView->UnlockGL();
   1.101 +                RemoveChild(_the_view);
   1.102              }
   1.103          }
   1.104          Unlock();
   1.105 @@ -144,41 +143,41 @@
   1.106      
   1.107      /* * * * * Framebuffering* * * * */
   1.108      virtual void DirectConnected(direct_buffer_info *info) {
   1.109 -    	if(!_connected && connection_disabled) {
   1.110 +    	if(!_connected && _connection_disabled) {
   1.111      		return;
   1.112      	}
   1.113      	LockBuffer();
   1.114      	
   1.115      	switch(info->buffer_state & B_DIRECT_MODE_MASK) {
   1.116      	case B_DIRECT_START:
   1.117 -printf(__FILE__": %d; Direct start.\n", __LINE__);
   1.118      		_connected = true;
   1.119  
   1.120      	case B_DIRECT_MODIFY:
   1.121 -
   1.122      		if(_clips) {
   1.123      			free(_clips);
   1.124      			_clips = NULL;
   1.125      		}
   1.126      		
   1.127      		/* Can we reuse the window's pixel buffer after this? */
   1.128 -    		trash_window_buffer = ((info->buffer_state & B_BUFFER_RESIZED)
   1.129 +    		_trash__window_buffer = ((info->buffer_state & B_BUFFER_RESIZED)
   1.130      							|| (info->buffer_state & B_BUFFER_RESET)
   1.131      							|| ((info->buffer_state & B_DIRECT_MODE_MASK)
   1.132      								== B_DIRECT_START));
   1.133 -    		
   1.134 -    		num_clips = info->clip_list_count;
   1.135 -    		_clips = (clipping_rect *)malloc(num_clips*sizeof(clipping_rect));
   1.136 +
   1.137 +    		_num_clips = info->clip_list_count;
   1.138 +    		_clips = (clipping_rect *)malloc(_num_clips*sizeof(clipping_rect));
   1.139      		if(_clips) {
   1.140      			memcpy(_clips, info->clip_list,
   1.141 -    				num_clips*sizeof(clipping_rect));
   1.142 +    				_num_clips*sizeof(clipping_rect));
   1.143      			
   1.144      			_bits = (uint8*) info->bits;
   1.145 -    			row_bytes = info->bytes_per_row;
   1.146 +    			_row_bytes = info->bytes_per_row;
   1.147      			_bounds = info->window_bounds;
   1.148 -    			bytes_per_px = info->bits_per_pixel / 8;
   1.149 +    			_bytes_per_px = info->bits_per_pixel / 8;
   1.150      		}
   1.151 -    		
   1.152 +
   1.153 +    		/* Whatever the case, I think this merits a repaint event */
   1.154 +//    		_RepaintEvent();
   1.155      		break;
   1.156  
   1.157      	case B_DIRECT_STOP:
   1.158 @@ -218,7 +217,7 @@
   1.159  	virtual bool QuitRequested() {
   1.160      	BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED);
   1.161      	_PostWindowEvent(msg);
   1.162 -    	
   1.163 +
   1.164      	/* We won't allow a quit unless asked by DestroyWindow() */
   1.165      	return false;	
   1.166      }
   1.167 @@ -235,8 +234,8 @@
   1.168      	_PostWindowEvent(msg);
   1.169      	
   1.170      	/* Before the window zooms, record its size */
   1.171 -    	if( !prev_frame )
   1.172 -    		prev_frame = new BRect(Frame());
   1.173 +    	if( !_prev_frame )
   1.174 +    		_prev_frame = new BRect(Frame());
   1.175  
   1.176      	/* Perform normal hook operations */
   1.177      	BDirectWindow::Zoom(origin, width, height);
   1.178 @@ -244,19 +243,19 @@
   1.179      
   1.180      /* Member functions */
   1.181      virtual void Show() {
   1.182 -    	BDirectWindow::Show();
   1.183 +    	while(IsHidden()) {
   1.184 +    		BDirectWindow::Show();
   1.185 +    	}
   1.186      	_shown = true;
   1.187 -    	
   1.188 +
   1.189      	BMessage msg(BAPP_SHOW);
   1.190      	_PostWindowEvent(msg);
   1.191      }
   1.192      
   1.193      virtual void Hide() {
   1.194 -    	/* FIXME: Multiple hides require multiple shows to undo. Should
   1.195 -    	   this be altered to prevent this from happening? */
   1.196      	BDirectWindow::Hide();
   1.197      	_shown = false;
   1.198 -    	
   1.199 +
   1.200      	BMessage msg(BAPP_HIDE);
   1.201      	_PostWindowEvent(msg);
   1.202      }
   1.203 @@ -273,7 +272,6 @@
   1.204      /* BView message interruption */
   1.205      virtual void DispatchMessage(BMessage * msg, BHandler * target)
   1.206      {
   1.207 -    	
   1.208          BPoint where;	/* Used by mouse moved */
   1.209          int32 buttons;	/* Used for mouse button events */
   1.210          int32 key;		/* Used for key events */
   1.211 @@ -326,11 +324,6 @@
   1.212              	_KeyEvent(key, SDL_RELEASED);
   1.213              }
   1.214              break;
   1.215 -                
   1.216 -        case _UPDATE_:
   1.217 -        case _UPDATE_IF_NEEDED_:	/* Hopefully one doesn't call the other */
   1.218 -        	_RepaintEvent();
   1.219 -        	break;
   1.220          	
   1.221          default:
   1.222              /* move it after switch{} so it's always handled
   1.223 @@ -341,6 +334,7 @@
   1.224              //BDirectWindow::DispatchMessage(msg, target);
   1.225              break;
   1.226          }
   1.227 +
   1.228          BDirectWindow::DispatchMessage(msg, target);
   1.229      }
   1.230      
   1.231 @@ -388,22 +382,22 @@
   1.232  	/* Accessor methods */
   1.233  	bool IsShown() { return _shown; }
   1.234  	int32 GetID() { return _id; }
   1.235 -	void LockBuffer() {	buffer_locker->Lock(); }
   1.236 -	void UnlockBuffer() { buffer_locker->Unlock(); }
   1.237 -	uint32 GetRowBytes() { return row_bytes; }
   1.238 +	void LockBuffer() {	_buffer_locker->Lock(); }
   1.239 +	void UnlockBuffer() { _buffer_locker->Unlock(); }
   1.240 +	uint32 GetRowBytes() { return _row_bytes; }
   1.241  	int32 GetFbX() { return _bounds.left; }
   1.242  	int32 GetFbY() { return _bounds.top; }
   1.243  	int32 GetFbHeight() { return _bounds.bottom - _bounds.top + 1; }
   1.244  	int32 GetFbWidth() { return _bounds.right - _bounds.left + 1; }
   1.245 -	bool ConnectionEnabled() { return !connection_disabled; }
   1.246 +	bool ConnectionEnabled() { return !_connection_disabled; }
   1.247  	bool Connected() { return _connected; }
   1.248  	clipping_rect *GetClips() { return _clips; }
   1.249 -	int32 GetNumClips() { return num_clips; }
   1.250 +	int32 GetNumClips() { return _num_clips; }
   1.251  	uint8* GetBufferPx() { return _bits; }
   1.252 -	int32 GetBytesPerPx() { return bytes_per_px; }
   1.253 -	void SetWindowFramebuffer(uint8* fb) { window_buffer = fb; }
   1.254 -	uint8* GetWindowFramebuffer() { return window_buffer; }
   1.255 -	bool CanTrashWindowBuffer() { return trash_window_buffer; }
   1.256 +	int32 GetBytesPerPx() { return _bytes_per_px; }
   1.257 +	void SetWindowFramebuffer(uint8* fb) { _window_buffer = fb; }
   1.258 +	uint8* GetWindowFramebuffer() { return _window_buffer; }
   1.259 +	bool CanTrashWindowBuffer() { return _trash__window_buffer; }
   1.260  	
   1.261  	/* Setter methods */
   1.262  	void SetID(int32 id) { _id = id; }
   1.263 @@ -413,14 +407,14 @@
   1.264  #if SDL_VIDEO_OPENGL
   1.265      virtual void SwapBuffers(void)
   1.266      {
   1.267 -        SDL_GLView->UnlockGL();
   1.268 -        SDL_GLView->LockGL();
   1.269 -        SDL_GLView->SwapBuffers();
   1.270 +        _SDL_GLView->UnlockGL();
   1.271 +        _SDL_GLView->LockGL();
   1.272 +        _SDL_GLView->SwapBuffers();
   1.273      }
   1.274  #endif
   1.275      virtual BView *View(void)
   1.276      {
   1.277 -        return (the_view);
   1.278 +        return (_the_view);
   1.279      }
   1.280  
   1.281  	
   1.282 @@ -434,27 +428,26 @@
   1.283      void _MouseMotionEvent(BPoint &where, int32 transit) {
   1.284      	if(transit == B_EXITED_VIEW) {
   1.285      		/* Change mouse focus */
   1.286 -    		if(mouse_focused) {
   1.287 +    		if(_mouse_focused) {
   1.288      			_MouseFocusEvent(false);
   1.289      		}
   1.290      	} else {
   1.291      		static int x = 0, y = 0;
   1.292      		/* Change mouse focus */
   1.293 -    		if (!mouse_focused) {
   1.294 +    		if (!_mouse_focused) {
   1.295      			_MouseFocusEvent(true);
   1.296      		}
   1.297 -//    		GetXYOffset(x, y);	//FIXME: What is this doing? (from SDL 1.2)
   1.298      		BMessage msg(BAPP_MOUSE_MOVED);
   1.299      		msg.AddInt32("dx", where.x - x);
   1.300      		msg.AddInt32("dy", where.y - y);
   1.301      		x = (int) where.x;
   1.302 -    		y = (int) where.y;
   1.303 +    		y = (int) where.y;    		
   1.304      		_PostWindowEvent(msg);
   1.305      	}
   1.306      }
   1.307      
   1.308      void _MouseFocusEvent(bool focusGained) {
   1.309 -    	mouse_focused = focusGained;
   1.310 +    	_mouse_focused = focusGained;
   1.311      	BMessage msg(BAPP_MOUSE_FOCUS);
   1.312      	msg.AddBool("focusGained", focusGained);
   1.313      	_PostWindowEvent(msg);
   1.314 @@ -465,7 +458,7 @@
   1.315      }
   1.316      
   1.317      void _MouseButtonEvent(int32 buttons) {
   1.318 -    	int32 buttonStateChange = buttons ^ last_buttons;
   1.319 +    	int32 buttonStateChange = buttons ^ _last_buttons;
   1.320      	
   1.321      	/* Make sure at least one button has changed state */ 
   1.322      	if( !(buttonStateChange) ) {
   1.323 @@ -486,7 +479,7 @@
   1.324      			B_PRIMARY_MOUSE_BUTTON);
   1.325      	}
   1.326      	
   1.327 -    	last_buttons = buttons;
   1.328 +    	_last_buttons = buttons;
   1.329      }
   1.330      
   1.331      void _SendMouseButton(int32 button, int32 state) {
   1.332 @@ -561,9 +554,9 @@
   1.333      		Minimize(false);
   1.334      	} else if(IsHidden()) {
   1.335      		Show();
   1.336 -    	} else if(prev_frame != NULL) {	/* Zoomed */
   1.337 -    		MoveTo(prev_frame->left, prev_frame->top);
   1.338 -    		ResizeTo(prev_frame->Width(), prev_frame->Height());
   1.339 +    	} else if(_prev_frame != NULL) {	/* Zoomed */
   1.340 +    		MoveTo(_prev_frame->left, _prev_frame->top);
   1.341 +    		ResizeTo(_prev_frame->Width(), _prev_frame->Height());
   1.342      	}
   1.343      }
   1.344  
   1.345 @@ -579,29 +572,29 @@
   1.346      
   1.347      /* Members */
   1.348  #if SDL_VIDEO_OPENGL
   1.349 -    BGLView * SDL_GLView;
   1.350 +    BGLView * _SDL_GLView;
   1.351  #endif
   1.352 -    BView *the_view;
   1.353 +    BView *_the_view;
   1.354      
   1.355 -    int32 last_buttons;
   1.356 +    int32 _last_buttons;
   1.357      int32 _id;	/* Window id used by SDL_BApp */
   1.358 -    bool mouse_focused;		/* Does this window have mouse focus? */
   1.359 -    bool _shown;
   1.360 -    bool inhibit_resize;
   1.361 +    bool  _mouse_focused;		/* Does this window have mouse focus? */
   1.362 +    bool  _shown;
   1.363 +    bool  _inhibit_resize;
   1.364      
   1.365 -    BRect *prev_frame;	/* Previous position and size of the window */
   1.366 +    BRect *_prev_frame;	/* Previous position and size of the window */
   1.367      
   1.368      /* Framebuffer members */
   1.369 -    bool			_connected, connection_disabled;
   1.370 -    uint8			*_bits;
   1.371 -    uint32			row_bytes;
   1.372 +    bool			_connected, _connection_disabled;
   1.373 +    uint8		   *_bits;
   1.374 +    uint32			_row_bytes;
   1.375      clipping_rect	_bounds;
   1.376 -    BLocker 		*buffer_locker;
   1.377 -    clipping_rect	*_clips;
   1.378 -    int32			num_clips;
   1.379 -    int32			bytes_per_px;
   1.380 -    uint8			*window_buffer;	/* A copy of the window buffer */
   1.381 -    bool			trash_window_buffer;
   1.382 +    BLocker 	   *_buffer_locker;
   1.383 +    clipping_rect  *_clips;
   1.384 +    int32			_num_clips;
   1.385 +    int32			_bytes_per_px;
   1.386 +    uint8		   *_window_buffer;	/* A copy of the window buffer */
   1.387 +    bool			_trash__window_buffer;
   1.388  };
   1.389  
   1.390  #endif