Partially cleaned out code
authorNathan Heisey <nathanheisey@gmail.com>
Mon, 22 Aug 2011 11:02:05 +0000
changeset 5939d9e9c343d264
parent 5938 b85b6326c498
child 5940 377e870b3f49
Partially cleaned out code
src/main/beos/SDL_BApp.h
src/video/bwindow/SDL_BWin.h
src/video/bwindow/SDL_bclipboard.cc
src/video/bwindow/SDL_bevents.cc
src/video/bwindow/SDL_bframebuffer.cc
src/video/bwindow/SDL_bmodes.cc
src/video/bwindow/SDL_bopengl.cc
src/video/bwindow/SDL_bvideo.cc
src/video/bwindow/SDL_bwindow.cc
     1.1 --- a/src/main/beos/SDL_BApp.h	Sat Aug 20 15:16:13 2011 +0000
     1.2 +++ b/src/main/beos/SDL_BApp.h	Mon Aug 22 11:02:05 2011 +0000
     1.3 @@ -177,11 +177,6 @@
     1.4      	}
     1.5      }
     1.6      
     1.7 -    /* Modes methods */
     1.8 -    void SetPrevMode(display_mode *prevMode) { _saved_mode = prevMode; }
     1.9 -    
    1.10 -    display_mode* GetPrevMode() { return _saved_mode; }
    1.11 -    
    1.12      /* FIXME: Bad coding practice, but I can't include SDL_BWin.h here.  Is
    1.13         there another way to do this? */
    1.14      void ClearID(SDL_BWin *bwin); /* Defined in SDL_BeApp.cc */
    1.15 @@ -225,7 +220,7 @@
    1.16  		win = GetSDLWindow(winID);
    1.17  		SDL_SendMouseMotion(win, 0, x, y);
    1.18  		
    1.19 -		/* FIXME: Attempt at fixing rendering problems */
    1.20 +		/* Tell the application that the mouse passed over, redraw needed */
    1.21  		BE_UpdateWindowFramebuffer(NULL,win,NULL,-1);
    1.22  	}
    1.23  	
    1.24 @@ -328,9 +323,6 @@
    1.25  		}
    1.26  		win = GetSDLWindow(winID);
    1.27  		SDL_SendWindowEvent(win, SDL_WINDOWEVENT_MOVED, xPos, yPos);
    1.28 -		
    1.29 -		/* FIXME: Attempt at fixing rendering problems */
    1.30 -//		BE_UpdateWindowFramebuffer(NULL,win,NULL,-1); Handled by DirectConnected
    1.31  	}
    1.32  	
    1.33  	void _HandleWindowResized(BMessage *msg) {
    1.34 @@ -347,9 +339,6 @@
    1.35  		}
    1.36  		win = GetSDLWindow(winID);
    1.37  		SDL_SendWindowEvent(win, SDL_WINDOWEVENT_RESIZED, w, h);
    1.38 -
    1.39 -		/* FIXME: Attempt at fixing rendering problems */
    1.40 -//		BE_UpdateWindowFramebuffer(NULL,win,NULL,-1); Handled by DirectConnected
    1.41  	}
    1.42  
    1.43  	bool _GetWinID(BMessage *msg, int32 *winID) {
    1.44 @@ -379,7 +368,7 @@
    1.45  
    1.46  
    1.47  	/* Members */
    1.48 -	vector<SDL_Window*> _window_map; /* Keeps track of SDL_Windows by index-id */
    1.49 +	vector<SDL_Window*> _window_map; /* Keeps track of SDL_Windows by index-id*/
    1.50  
    1.51  	display_mode *_saved_mode;
    1.52  	BGLView      *_current_context;
     2.1 --- a/src/video/bwindow/SDL_BWin.h	Sat Aug 20 15:16:13 2011 +0000
     2.2 +++ b/src/video/bwindow/SDL_BWin.h	Mon Aug 22 11:02:05 2011 +0000
     2.3 @@ -53,7 +53,7 @@
     2.4  	BWIN_HIDE_WINDOW,
     2.5  	BWIN_MAXIMIZE_WINDOW,
     2.6  	BWIN_MINIMIZE_WINDOW,
     2.7 -	BWIN_RESTORE_WINDOW,	/* TODO: IMPLEMENT THIS! */
     2.8 +	BWIN_RESTORE_WINDOW,
     2.9  	BWIN_SET_TITLE,
    2.10  	BWIN_FULLSCREEN
    2.11  };
    2.12 @@ -185,9 +185,6 @@
    2.13      			_bits = (uint8*) info->bits;
    2.14      			_row_bytes = info->bytes_per_row;
    2.15      			_bounds = info->window_bounds;
    2.16 -printf("Bounds = (%i,%i,%i,%i), Frame = (%0.f,%0.f,%0.f,%0.f)\n", _bounds.left,
    2.17 -	_bounds.top, _bounds.right, _bounds.bottom, Frame().left, Frame().top,
    2.18 -	Frame().right, Frame().bottom);
    2.19      			_bytes_per_px = info->bits_per_pixel / 8;
    2.20      			_buffer_dirty = true;
    2.21      		}
    2.22 @@ -230,7 +227,8 @@
    2.23      virtual void FrameResized(float width, float height) {
    2.24      	/* Post a message to the BApp so that it can handle the window event */
    2.25      	BMessage msg(BAPP_WINDOW_RESIZED);
    2.26 -		msg.AddInt32("window-w", (int)width + 1);	/* TODO: Check that +1 is needed */
    2.27 +
    2.28 +		msg.AddInt32("window-w", (int)width + 1);
    2.29  		msg.AddInt32("window-h", (int)height + 1);
    2.30      	_PostWindowEvent(msg);
    2.31  		
    2.32 @@ -409,15 +407,12 @@
    2.33  	uint32 GetRowBytes() { return _row_bytes; }
    2.34  	int32 GetFbX() { return _bounds.left; }
    2.35  	int32 GetFbY() { return _bounds.top; }
    2.36 -//	int32 GetFbHeight() { return _bounds.bottom - _bounds.top + 1; }
    2.37 -//	int32 GetFbWidth() { return _bounds.right - _bounds.left + 1; }
    2.38  	bool ConnectionEnabled() { return !_connection_disabled; }
    2.39  	bool Connected() { return _connected; }
    2.40  	clipping_rect *GetClips() { return _clips; }
    2.41  	int32 GetNumClips() { return _num_clips; }
    2.42  	uint8* GetBufferPx() { return _bits; }
    2.43  	int32 GetBytesPerPx() { return _bytes_per_px; }
    2.44 -//	uint8* GetWindowFramebuffer() { return _window_buffer; }
    2.45  	bool CanTrashWindowBuffer() { return _trash_window_buffer; }
    2.46  	bool BufferExists() { return _buffer_created; }
    2.47  	bool BufferIsDirty() { return _buffer_dirty; }
    2.48 @@ -429,7 +424,6 @@
    2.49  	/* Setter methods */
    2.50  	void SetID(int32 id) { _id = id; }
    2.51  	void SetBufferExists(bool bufferExists) { _buffer_created = bufferExists; }
    2.52 -//	void SetWindowFramebuffer(uint8* fb) { _window_buffer = fb; }
    2.53  	void LockBuffer() {	_buffer_locker->Lock(); }
    2.54  	void UnlockBuffer() { _buffer_locker->Unlock(); }
    2.55  	void SetBufferDirty(bool bufferDirty) { _buffer_dirty = bufferDirty; }
    2.56 @@ -575,27 +569,12 @@
    2.57  
    2.58      void _SetFullScreen(BMessage *msg) {
    2.59      	bool fullscreen;
    2.60 -
    2.61 -    	BRect rc1 = Bounds(),
    2.62 -    		  rc2 = Frame();
    2.63 -printf(__FILE__": %d - bounds = (%.0f,%.0f,%.0f,%.0f), frame = (%.0f,%.0f,%.0f,%.0f\n", __LINE__, rc1.left, rc1.top, rc1.right, rc1.bottom,
    2.64 -rc2.left, rc2.top, rc2.right, rc2.bottom);
    2.65      	if(
    2.66  			msg->FindBool("fullscreen", &fullscreen) != B_OK
    2.67  		) {
    2.68  			return;
    2.69      	}
    2.70 -
    2.71 -if(fullscreen) {
    2.72 -	printf("Setting fullscreen...\n");
    2.73 -} else {
    2.74 -	printf("Unsetting fullscreen...\n");
    2.75 -}
    2.76 -#if 1
    2.77      	SetFullScreen(fullscreen);
    2.78 -#endif
    2.79 -printf(__FILE__": %d - bounds = (%.0f,%.0f,%.0f,%.0f), frame = (%.0f,%.0f,%.0f,%.0f\n", __LINE__, rc1.left, rc1.top, rc1.right, rc1.bottom,
    2.80 -rc2.left, rc2.top, rc2.right, rc2.bottom);
    2.81      }
    2.82      
    2.83      /* Members */
    2.84 @@ -615,7 +594,8 @@
    2.85      bool			_connected,
    2.86      				_connection_disabled,
    2.87      				_buffer_created,
    2.88 -    				_buffer_dirty;
    2.89 +    				_buffer_dirty,
    2.90 +    				_trash_window_buffer;
    2.91      uint8		   *_bits;
    2.92      uint32			_row_bytes;
    2.93      clipping_rect	_bounds;
    2.94 @@ -623,11 +603,24 @@
    2.95      clipping_rect  *_clips;
    2.96      int32			_num_clips;
    2.97      int32			_bytes_per_px;
    2.98 -//    uint8		   *_window_buffer;	/* A copy of the window buffer */
    2.99 -    bool			_trash_window_buffer;
   2.100      thread_id		_draw_thread_id;
   2.101      
   2.102      BBitmap		   *_bitmap;
   2.103  };
   2.104  
   2.105 +
   2.106 +/* FIXME:
   2.107 + * An explanation of framebuffer flags.
   2.108 + *
   2.109 + * _connected -           Original variable used to let the drawing thread know
   2.110 + *                         when changes are being made to the other framebuffer
   2.111 + *                         members.
   2.112 + * _connection_disabled - Used to signal to the drawing thread that the window
   2.113 + *                         is closing, and the thread should exit.
   2.114 + * _buffer_created -      True if the current buffer is valid
   2.115 + * _buffer_dirty -        True if the window should be redrawn.
   2.116 + * _trash_window_buffer - True if the window buffer needs to be trashed partway
   2.117 + *                         through a draw cycle.  Occurs when the previous
   2.118 + *                         buffer provided by DirectConnected() is invalidated.
   2.119 + */
   2.120  #endif
     3.1 --- a/src/video/bwindow/SDL_bclipboard.cc	Sat Aug 20 15:16:13 2011 +0000
     3.2 +++ b/src/video/bwindow/SDL_bclipboard.cc	Mon Aug 22 11:02:05 2011 +0000
     3.3 @@ -35,7 +35,6 @@
     3.4  #endif
     3.5  
     3.6  int BE_SetClipboardText(_THIS, const char *text) {
     3.7 -#if 0
     3.8  	BMessage *clip = NULL;
     3.9  	if(be_clipboard->Lock()) {
    3.10  		be_clipboard->Clear();
    3.11 @@ -48,20 +47,17 @@
    3.12  		}
    3.13  		be_clipboard->Unlock();
    3.14  	}
    3.15 -#else
    3.16 -return -1;
    3.17 -#endif
    3.18  }
    3.19  
    3.20  char *BE_GetClipboardText(_THIS) {
    3.21 -#if 0
    3.22  	BMessage *clip = NULL;
    3.23  	const char *text;
    3.24  	ssize_t length;
    3.25  	if(be_clipboard->Lock()) {
    3.26  		if((clip = be_clipboard->Data())) {
    3.27  			/* Presumably the string of characters is ascii-format */
    3.28 -			clip->FindData("text/plain", B_MIME_TYPE, (void**)&text, &length);
    3.29 +			clip->FindData("text/plain", B_MIME_TYPE, (const void**)&text,
    3.30 +				&length);
    3.31  		} else {
    3.32  			be_clipboard->Unlock();
    3.33  			return NULL;
    3.34 @@ -76,13 +72,9 @@
    3.35  	SDL_strlcpy(result, text, length);
    3.36  	
    3.37  	return result;
    3.38 -#else
    3.39 -return NULL;
    3.40 -#endif;
    3.41  }
    3.42  
    3.43  SDL_bool BE_HasClipboardText(_THIS) {
    3.44 -#if 0
    3.45  	BMessage *clip = NULL;
    3.46  	const char *text;
    3.47  	ssize_t length;
    3.48 @@ -91,15 +83,13 @@
    3.49  	if(be_clipboard->Lock()) {
    3.50  		if((clip = be_clipboard->Data())) {
    3.51  			/* Presumably the string of characters is ascii-format */
    3.52 -			clip->FindData("text/plain", B_MIME_TYPE, (void**)&text, &length);
    3.53 +			clip->FindData("text/plain", B_MIME_TYPE, (const void**)&text,
    3.54 +				&length);
    3.55  			if( text ) retval = SDL_TRUE;
    3.56  		}
    3.57  		be_clipboard->Unlock();
    3.58  	}
    3.59  	return retval;
    3.60 -#else
    3.61 -return SDL_FALSE;
    3.62 -#endif
    3.63  
    3.64  }
    3.65  
     4.1 --- a/src/video/bwindow/SDL_bevents.cc	Sat Aug 20 15:16:13 2011 +0000
     4.2 +++ b/src/video/bwindow/SDL_bevents.cc	Mon Aug 22 11:02:05 2011 +0000
     4.3 @@ -26,6 +26,7 @@
     4.4  #endif
     4.5  
     4.6  void BE_PumpEvents(_THIS) {
     4.7 +	/* Since the event thread is its own thread, this isn't really necessary */
     4.8  }
     4.9  
    4.10  #ifdef __cplusplus
     5.1 --- a/src/video/bwindow/SDL_bframebuffer.cc	Sat Aug 20 15:16:13 2011 +0000
     5.2 +++ b/src/video/bwindow/SDL_bframebuffer.cc	Mon Aug 22 11:02:05 2011 +0000
     5.3 @@ -126,9 +126,7 @@
     5.4  		if( bwin->Connected() && bwin->BufferExists() && bwin->BufferIsDirty() ) {
     5.5  			bwin->LockBuffer();
     5.6  			BBitmap *bitmap = NULL;
     5.7 -//			while(!bitmap) {
     5.8 -				bitmap = bwin->GetBitmap();
     5.9 -//			}
    5.10 +			bitmap = bwin->GetBitmap();
    5.11  			int32 windowPitch = bitmap->BytesPerRow();
    5.12  			int32 bufferPitch = bwin->GetRowBytes();
    5.13  			uint8 *windowpx;
    5.14 @@ -163,14 +161,12 @@
    5.15  						goto escape;	/* Break out before the buffer is killed */
    5.16  					}
    5.17  
    5.18 -//					printf("memcpy(0x%x, 0x%x, %i) ", bufferpx, windowpx, width * BPP);
    5.19  					memcpy(bufferpx, windowpx, width * BPP);
    5.20  					bufferpx += bufferPitch;
    5.21  					windowpx += windowPitch;
    5.22  				}
    5.23 -//				printf("\t-\t");
    5.24  			}
    5.25 -//			printf("\n");
    5.26 +
    5.27  			bwin->SetBufferDirty(false);
    5.28  escape:
    5.29  			bwin->UnlockBuffer();
     6.1 --- a/src/video/bwindow/SDL_bmodes.cc	Sat Aug 20 15:16:13 2011 +0000
     6.2 +++ b/src/video/bwindow/SDL_bmodes.cc	Mon Aug 22 11:02:05 2011 +0000
     6.3 @@ -37,10 +37,11 @@
     6.4  #endif
     6.5  
     6.6  
     6.7 -#define WRAP_BMODE 1
     6.8 +#define WRAP_BMODE 1 /* FIXME: Some debate as to whether this is necessary */
     6.9  
    6.10  #if WRAP_BMODE
    6.11 -/* This wrapper is here so that the driverdata can be freed */
    6.12 +/* This wrapper is here so that the driverdata can be freed without freeing
    6.13 +   the display_mode structure */
    6.14  typedef struct SDL_DisplayModeData {
    6.15  	display_mode *bmode;
    6.16  };
    6.17 @@ -55,10 +56,10 @@
    6.18  }
    6.19  
    6.20  static inline display_mode * _ExtractBMode(SDL_DisplayMode *mode) {
    6.21 -#if 0
    6.22 +#if WRAP_BMODE
    6.23 +	return ((SDL_DisplayModeData*)mode->driverdata)->bmode;
    6.24 +#else
    6.25  	return (display_mode*)(mode->driverdata);
    6.26 -#else
    6.27 -	return ((SDL_DisplayModeData*)mode->driverdata)->bmode;
    6.28  #endif
    6.29  }
    6.30  
    6.31 @@ -68,6 +69,68 @@
    6.32  		/ float(mode.timing.h_total * mode.timing.v_total);
    6.33  }
    6.34  
    6.35 +
    6.36 +#if 0
    6.37 +/* TODO:
    6.38 + * This is a useful debugging tool.  Uncomment and insert into code as needed.
    6.39 + */
    6.40 +void _SpoutModeData(display_mode *bmode) {
    6.41 +	printf("BMode:\n");
    6.42 +	printf("\tw,h = (%i,%i)\n", bmode->virtual_width, bmode->virtual_height);
    6.43 +	printf("\th,v = (%i,%i)\n", bmode->h_display_start, 
    6.44 +			bmode->v_display_start);
    6.45 +	if(bmode->flags) {
    6.46 +		printf("\tFlags:\n");
    6.47 +		if(bmode->flags & B_SCROLL) {
    6.48 +			printf("\t\tB_SCROLL\n");
    6.49 +		}
    6.50 +		if(bmode->flags & B_8_BIT_DAC) {
    6.51 +			printf("\t\tB_8_BIT_DAC\n");
    6.52 +		}
    6.53 +		if(bmode->flags & B_HARDWARE_CURSOR) {
    6.54 +			printf("\t\tB_HARDWARE_CURSOR\n");
    6.55 +		}
    6.56 +		if(bmode->flags & B_PARALLEL_ACCESS) {
    6.57 +			printf("\t\tB_PARALLEL_ACCESS\n");
    6.58 +		}
    6.59 +		if(bmode->flags & B_DPMS) {
    6.60 +			printf("\t\tB_DPMS\n");
    6.61 +		}
    6.62 +		if(bmode->flags & B_IO_FB_NA) {
    6.63 +			printf("\t\tB_IO_FB_NA\n");
    6.64 +		}
    6.65 +	}
    6.66 +	printf("\tTiming:\n");
    6.67 +	printf("\t\tpx clock: %i\n", bmode->timing.pixel_clock);
    6.68 +	printf("\t\th - display: %i sync start: %i sync end: %i total: %i\n",
    6.69 +		bmode->timing.h_display, bmode->timing.h_sync_start,
    6.70 +		bmode->timing.h_sync_end, bmode->timing.h_total);
    6.71 +	printf("\t\tv - display: %i sync start: %i sync end: %i total: %i\n",
    6.72 +		bmode->timing.v_display, bmode->timing.v_sync_start,
    6.73 +		bmode->timing.v_sync_end, bmode->timing.v_total);
    6.74 +	if(bmode->timing.flags) {
    6.75 +		printf("\t\tFlags:\n");
    6.76 +		if(bmode->timing.flags & B_BLANK_PEDESTAL) {
    6.77 +			printf("\t\t\tB_BLANK_PEDESTAL\n");
    6.78 +		}
    6.79 +		if(bmode->timing.flags & B_TIMING_INTERLACED) {
    6.80 +			printf("\t\t\tB_TIMING_INTERLACED\n");
    6.81 +		}
    6.82 +		if(bmode->timing.flags & B_POSITIVE_HSYNC) {
    6.83 +			printf("\t\t\tB_POSITIVE_HSYNC\n");
    6.84 +		}
    6.85 +		if(bmode->timing.flags & B_POSITIVE_VSYNC) {
    6.86 +			printf("\t\t\tB_POSITIVE_VSYNC\n");
    6.87 +		}
    6.88 +		if(bmode->timing.flags & B_SYNC_ON_GREEN) {
    6.89 +			printf("\t\t\tB_SYNC_ON_GREEN\n");
    6.90 +		}
    6.91 +	}
    6.92 +}
    6.93 +#endif
    6.94 +
    6.95 +
    6.96 +
    6.97  static inline int32 ColorSpaceToBitsPerPixel(uint32 colorspace)
    6.98  {
    6.99  	int bitsperpixel;
   6.100 @@ -123,17 +186,21 @@
   6.101  	}
   6.102  }
   6.103  
   6.104 -static inline void BE_BDisplayModeToSdlDisplayMode(display_mode *bmode,
   6.105 +static inline void _BDisplayModeToSdlDisplayMode(display_mode *bmode,
   6.106  		SDL_DisplayMode *mode) {
   6.107  	mode->w = bmode->virtual_width;
   6.108  	mode->h = bmode->virtual_height;
   6.109  	mode->refresh_rate = (int)get_refresh_rate(*bmode);
   6.110 +
   6.111  #if WRAP_BMODE
   6.112 -	SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1, sizeof(SDL_DisplayModeData));
   6.113 +	SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1,
   6.114 +		sizeof(SDL_DisplayModeData));
   6.115  	data->bmode = bmode;
   6.116  	
   6.117  	mode->driverdata = data;
   6.118 +
   6.119  #else
   6.120 +
   6.121  	mode->driverdata = bmode;
   6.122  #endif
   6.123  
   6.124 @@ -143,13 +210,14 @@
   6.125  }
   6.126  
   6.127  /* Later, there may be more than one monitor available */
   6.128 -void BE_AddDisplay(BScreen *screen) {
   6.129 +void _AddDisplay(BScreen *screen) {
   6.130  	SDL_VideoDisplay display;
   6.131 -	SDL_DisplayMode *mode = (SDL_DisplayMode*)SDL_calloc(1, sizeof(SDL_DisplayMode));
   6.132 +	SDL_DisplayMode *mode = (SDL_DisplayMode*)SDL_calloc(1,
   6.133 +		sizeof(SDL_DisplayMode));
   6.134  	display_mode *bmode = (display_mode*)SDL_calloc(1, sizeof(display_mode));
   6.135  	screen->GetMode(bmode);
   6.136  
   6.137 -	BE_BDisplayModeToSdlDisplayMode(bmode, mode);
   6.138 +	_BDisplayModeToSdlDisplayMode(bmode, mode);
   6.139  	
   6.140  	SDL_zero(display);
   6.141  	display.desktop_mode = *mode;
   6.142 @@ -158,23 +226,20 @@
   6.143  	SDL_AddVideoDisplay(&display);
   6.144  }
   6.145  
   6.146 +/*
   6.147 + * Functions called by SDL
   6.148 + */
   6.149 +
   6.150  int BE_InitModes(_THIS) {
   6.151  	BScreen screen;
   6.152 -	
   6.153 -	/* Save the current display mode */
   6.154 -//	display_mode *prevMode;
   6.155 -//	screen.GetMode(prevMode);
   6.156 -//	_GetBeApp()->SetPrevMode(prevMode);
   6.157  
   6.158 -	/* Only one possible video display right now */
   6.159 -	BE_AddDisplay(&screen);
   6.160 +	/* TODO: When Haiku supports multiple display screens, call
   6.161 +	   _AddDisplayScreen() for each of them. */
   6.162 +	_AddDisplay(&screen);
   6.163  }
   6.164  
   6.165  int BE_QuitModes(_THIS) {
   6.166 -	/* Restore the previous video mode */
   6.167 -	BScreen screen;
   6.168 -//	display_mode *savedMode = _GetBeApp()->GetPrevMode();
   6.169 -//	screen.SetMode(savedMode);
   6.170 +	/* FIXME: Nothing really needs to be done here at the moment? */
   6.171  	return 0;
   6.172  }
   6.173  
   6.174 @@ -206,7 +271,7 @@
   6.175  	for(i = 0; i < count; ++i) {
   6.176  		//FIXME: Apparently there are errors with colorspace changes
   6.177  		if (bmodes[i].space == this_bmode.space) {
   6.178 -			BE_BDisplayModeToSdlDisplayMode(&bmodes[i], &mode);
   6.179 +			_BDisplayModeToSdlDisplayMode(&bmodes[i], &mode);
   6.180  			SDL_AddDisplayMode(display, &mode);
   6.181  		}
   6.182  	}
   6.183 @@ -214,158 +279,8 @@
   6.184  }
   6.185  
   6.186  
   6.187 -
   6.188 -
   6.189 -
   6.190 -
   6.191 -
   6.192 -
   6.193 -
   6.194 -
   6.195 -
   6.196 -
   6.197 -
   6.198 -
   6.199 -static int get_combine_mode(display_mode &mode) {
   6.200 -	if ((mode.flags & B_SCROLL) == 0)
   6.201 -		return 0;
   6.202 -
   6.203 -	if (mode.virtual_width == mode.timing.h_display * 2)
   6.204 -		return 1;
   6.205 -
   6.206 -	if (mode.virtual_height == mode.timing.v_display * 2)
   6.207 -		return 2;
   6.208 -     
   6.209 -		return 0;
   6.210 -}
   6.211 -#if 0
   6.212 -bool _GetDisplayMode(const screen_mode& mode, display_mode& displayMode)
   6.213 -{
   6.214 - 	uint16 virtualWidth, virtualHeight;
   6.215 - 	int32 bestIndex = -1;
   6.216 - 	float bestDiff = 999;
   6.217 - 
   6.218 - 	virtualWidth = mode.combine == kCombineHorizontally
   6.219 - 		? mode.width * 2 : mode.width;
   6.220 - 	virtualHeight = mode.combine == kCombineVertically
   6.221 - 		? mode.height * 2 : mode.height;
   6.222 - 
   6.223 - 	// try to find mode in list provided by driver
   6.224 - 	for (uint32 i = 0; i < fModeCount; i++) {
   6.225 - 		if (fModeList[i].virtual_width != virtualWidth
   6.226 - 			|| fModeList[i].virtual_height != virtualHeight
   6.227 - 			|| (color_space)fModeList[i].space != mode.space)
   6.228 - 			continue;
   6.229 - 
   6.230 - 		// Accept the mode if the computed refresh rate of the mode is within
   6.231 - 		// 0.6 percent of the refresh rate specified by the caller.  Note that
   6.232 - 		// refresh rates computed from mode parameters is not exact; especially
   6.233 - 		// some of the older modes such as 640x480, 800x600, and 1024x768.
   6.234 - 		// The tolerance of 0.6% was obtained by examining the various possible
   6.235 - 		// modes.
   6.236 -
   6.237 - 		float refreshDiff = fabs(get_refresh_rate(fModeList[i]) - mode.refresh);
   6.238 - 		if (refreshDiff < 0.006 * mode.refresh) {
   6.239 - 			// Accept this mode.
   6.240 - 			displayMode = fModeList[i];
   6.241 - 			displayMode.h_display_start = 0;
   6.242 - 			displayMode.v_display_start = 0;
   6.243 - 
   6.244 -			// Since the computed refresh rate of the selected mode might differ
   6.245 - 			// from selected refresh rate by a few tenths (e.g. 60.2 instead of
   6.246 - 			// 60.0), tweak the pixel clock so the the refresh rate of the mode
   6.247 - 			// matches the selected refresh rate.
   6.248 - 
   6.249 - 			displayMode.timing.pixel_clock = uint32(((displayMode.timing.h_total
   6.250 - 				* displayMode.timing.v_total * mode.refresh) / 1000.0) + 0.5);
   6.251 - 			return true;
   6.252 - 		}
   6.253 - 
   6.254 -		// Mode not acceptable.
   6.255 - 
   6.256 - 		if (refreshDiff < bestDiff) {
   6.257 - 			bestDiff = refreshDiff;
   6.258 - 			bestIndex = i;
   6.259 -		}
   6.260 -	}
   6.261 - 
   6.262 - 	// we didn't find the exact mode, but something very similar?
   6.263 - 	if (bestIndex == -1)
   6.264 - 		return false;
   6.265 - 
   6.266 - 	displayMode = fModeList[bestIndex];
   6.267 - 	displayMode.h_display_start = 0;
   6.268 - 	displayMode.v_display_start = 0;
   6.269 - 
   6.270 - 	// For the mode selected by the width, height, and refresh rate, compute
   6.271 - 	// the video timing parameters for the mode by using the VESA Generalized
   6.272 - 	// Timing Formula (GTF).
   6.273 - 
   6.274 -	ComputeGTFVideoTiming(displayMode.timing.h_display,
   6.275 - 		displayMode.timing.v_display, mode.refresh, displayMode.timing);
   6.276 -
   6.277 -	return true;
   6.278 -}
   6.279 -#endif
   6.280 -
   6.281 -void _SpoutModeData(display_mode *bmode) {
   6.282 -	printf("BMode:\n");
   6.283 -	printf("\tw,h = (%i,%i)\n", bmode->virtual_width, bmode->virtual_height);
   6.284 -	printf("\th,v = (%i,%i)\n", bmode->h_display_start, 
   6.285 -			bmode->v_display_start);
   6.286 -	printf("\tcombine mode = %i\n", get_combine_mode(*bmode));
   6.287 -	if(bmode->flags) {
   6.288 -		printf("\tFlags:\n");
   6.289 -		if(bmode->flags & B_SCROLL) {
   6.290 -			printf("\t\tB_SCROLL\n");
   6.291 -		}
   6.292 -		if(bmode->flags & B_8_BIT_DAC) {
   6.293 -			printf("\t\tB_8_BIT_DAC\n");
   6.294 -		}
   6.295 -		if(bmode->flags & B_HARDWARE_CURSOR) {
   6.296 -			printf("\t\tB_HARDWARE_CURSOR\n");
   6.297 -		}
   6.298 -		if(bmode->flags & B_PARALLEL_ACCESS) {
   6.299 -			printf("\t\tB_PARALLEL_ACCESS\n");
   6.300 -		}
   6.301 -		if(bmode->flags & B_DPMS) {
   6.302 -			printf("\t\tB_DPMS\n");
   6.303 -		}
   6.304 -		if(bmode->flags & B_IO_FB_NA) {
   6.305 -			printf("\t\tB_IO_FB_NA\n");
   6.306 -		}
   6.307 -	}
   6.308 -	printf("\tTiming:\n");
   6.309 -	printf("\t\tpx clock: %i\n", bmode->timing.pixel_clock);
   6.310 -	printf("\t\th - display: %i sync start: %i sync end: %i total: %i\n",
   6.311 -		bmode->timing.h_display, bmode->timing.h_sync_start,
   6.312 -		bmode->timing.h_sync_end, bmode->timing.h_total);
   6.313 -	printf("\t\tv - display: %i sync start: %i sync end: %i total: %i\n",
   6.314 -		bmode->timing.v_display, bmode->timing.v_sync_start,
   6.315 -		bmode->timing.v_sync_end, bmode->timing.v_total);
   6.316 -	if(bmode->timing.flags) {
   6.317 -		printf("\t\tFlags:\n");
   6.318 -		if(bmode->timing.flags & B_BLANK_PEDESTAL) {
   6.319 -			printf("\t\t\tB_BLANK_PEDESTAL\n");
   6.320 -		}
   6.321 -		if(bmode->timing.flags & B_TIMING_INTERLACED) {
   6.322 -			printf("\t\t\tB_TIMING_INTERLACED\n");
   6.323 -		}
   6.324 -		if(bmode->timing.flags & B_POSITIVE_HSYNC) {
   6.325 -			printf("\t\t\tB_POSITIVE_HSYNC\n");
   6.326 -		}
   6.327 -		if(bmode->timing.flags & B_POSITIVE_VSYNC) {
   6.328 -			printf("\t\t\tB_POSITIVE_VSYNC\n");
   6.329 -		}
   6.330 -		if(bmode->timing.flags & B_SYNC_ON_GREEN) {
   6.331 -			printf("\t\t\tB_SYNC_ON_GREEN\n");
   6.332 -		}
   6.333 -	}
   6.334 -}
   6.335 -
   6.336  int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
   6.337  	/* Get the current screen */
   6.338 -printf(__FILE__": %d\n", __LINE__);
   6.339  	BScreen bscreen;
   6.340  	if(!bscreen.IsValid()) {
   6.341  		printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__);
   6.342 @@ -375,24 +290,18 @@
   6.343  	display_mode *bmode = _ExtractBMode(mode);
   6.344  
   6.345  
   6.346 -_SpoutModeData(bmode);
   6.347 -printf("\n");
   6.348 -uint32 c = 0, i, x = 0;
   6.349 -#define RES 0
   6.350 -display_mode *bmode_list;
   6.351 -bscreen.GetModeList(&bmode_list, &c);
   6.352 -for(i = 0; i < c; ++i) {
   6.353 -	if(	bmode_list[i].space == bmode->space &&
   6.354 -		bmode_list[i].virtual_width == bmode->virtual_width &&
   6.355 -		bmode_list[i].virtual_height == bmode->virtual_height ) {
   6.356 -			if(x == RES)
   6.357 +	/* FIXME: Is the first option always going to be the right one? */
   6.358 +	uint32 c = 0, i;
   6.359 +	display_mode *bmode_list;
   6.360 +	bscreen.GetModeList(&bmode_list, &c);
   6.361 +	for(i = 0; i < c; ++i) {
   6.362 +		if(	bmode_list[i].space == bmode->space &&
   6.363 +			bmode_list[i].virtual_width == bmode->virtual_width &&
   6.364 +			bmode_list[i].virtual_height == bmode->virtual_height ) {
   6.365  				bmode = &bmode_list[i];
   6.366 -			
   6.367 -			++x;
   6.368 -			_SpoutModeData(&bmode_list[i]);
   6.369 -//			break;
   6.370 +				break;
   6.371 +		}
   6.372  	}
   6.373 -}
   6.374  
   6.375  	if(bscreen.SetMode(bmode) != B_OK) {
   6.376  		SDL_SetError("Bad video mode\n");
   6.377 @@ -401,11 +310,11 @@
   6.378  free(bmode_list);
   6.379  	
   6.380  #if SDL_VIDEO_OPENGL
   6.381 -	/* The OpenGL context may need to be rebooted */
   6.382 +	/* FIXME: Is there some way to reboot the OpenGL context?  This doesn't
   6.383 +	   help */
   6.384  //	BE_GL_RebootContexts(_this);
   6.385  #endif
   6.386  
   6.387 -printf(__FILE__": %d\n", __LINE__);
   6.388  	return 0;
   6.389  }
   6.390  
     7.1 --- a/src/video/bwindow/SDL_bopengl.cc	Sat Aug 20 15:16:13 2011 +0000
     7.2 +++ b/src/video/bwindow/SDL_bopengl.cc	Mon Aug 22 11:02:05 2011 +0000
     7.3 @@ -45,6 +45,7 @@
     7.4  /* Passing a NULL path means load pointers from the application */
     7.5  int BE_GL_LoadLibrary(_THIS, const char *path)
     7.6  {
     7.7 +/* FIXME: Is this working correctly? */
     7.8  	image_info info;
     7.9  			int32 cookie = 0;
    7.10  	while (get_next_image_info(0, &cookie, &info) == B_OK) {
    7.11 @@ -58,64 +59,6 @@
    7.12  					SDL_arraysize(_this->gl_config.driver_path));
    7.13  		}
    7.14  	}
    7.15 -#if 0
    7.16 -printf("\n\nLibrary loading: %s\n\n", path);
    7.17 -	if (path == NULL) {
    7.18 -		if (_this->gl_config.dll_handle == NULL) {
    7.19 -			image_info info;
    7.20 -			int32 cookie = 0;
    7.21 -			while (get_next_image_info(0, &cookie, &info) == B_OK) {
    7.22 -				printf(__FILE__": %d - Inside while\n",__LINE__);
    7.23 -				void *location = NULL;
    7.24 -				if (get_image_symbol
    7.25 -				((image_id) cookie, "glBegin",
    7.26 -				B_SYMBOL_TYPE_ANY, &location) == B_OK) {
    7.27 -					_this->gl_config.dll_handle = (void *) cookie;
    7.28 -					_this->gl_config.driver_loaded = 1;
    7.29 -					SDL_strlcpy(_this->gl_config.driver_path,
    7.30 -					"libGL.so",
    7.31 -					SDL_arraysize(_this->
    7.32 -					gl_config.driver_path));
    7.33 -				}
    7.34 -			}
    7.35 -		}
    7.36 -	} else {
    7.37 -        /*
    7.38 -           FIXME None of BeOS libGL.so implementations have exported functions 
    7.39 -           to load BGLView, which should be reloaded from new lib.
    7.40 -           So for now just "load" linked libGL.so :(
    7.41 -        */
    7.42 -        if (_this->gl_config.dll_handle == NULL) {
    7.43 -        	return BE_GL_LoadLibrary(_this, NULL);
    7.44 -        }
    7.45 -            /* Unload old first */
    7.46 -            /*if (_this->gl_config.dll_handle != NULL) { */
    7.47 -            /* Do not try to unload application itself (if LoadLibrary was called before with NULL ;) */
    7.48 -            /*      image_info info;
    7.49 -               if (get_image_info((image_id)_this->gl_config.dll_handle, &info) == B_OK) {
    7.50 -               if (info.type != B_APP_IMAGE) {
    7.51 -               unload_add_on((image_id)_this->gl_config.dll_handle);
    7.52 -               }
    7.53 -               }
    7.54 -
    7.55 -               }
    7.56 -
    7.57 -               if ((_this->gl_config.dll_handle = (void*)load_add_on(path)) != (void*)B_ERROR) {
    7.58 -               _this->gl_config.driver_loaded = 1;
    7.59 -               SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path));
    7.60 -               } */
    7.61 -	}
    7.62 -	
    7.63 -	if (_this->gl_config.dll_handle != NULL) {
    7.64 -		return 0;
    7.65 -	} else {
    7.66 -printf(__FILE__": %d- gl_config.driver_loaded = 0\n", __LINE__);
    7.67 -		_this->gl_config.dll_handle = NULL;
    7.68 -		_this->gl_config.driver_loaded = 0;
    7.69 -		*_this->gl_config.driver_path = '\0';
    7.70 -		return -1;
    7.71 -	}
    7.72 -#endif
    7.73  }
    7.74  
    7.75  void *BE_GL_GetProcAddress(_THIS, const char *proc)
    7.76 @@ -161,28 +104,29 @@
    7.77  
    7.78  void BE_GL_DeleteContext(_THIS, SDL_GLContext context) {
    7.79  	/* Currently, automatically unlocks the view */
    7.80 -printf(__FILE__": %d\n", __LINE__);
    7.81  	((SDL_BWin*)context)->RemoveGLView();
    7.82  }
    7.83  
    7.84  
    7.85  int BE_GL_SetSwapInterval(_THIS, int interval) {
    7.86 -	printf(__FILE__": %d- swap interval set\n", __LINE__);
    7.87 +	/* TODO: Implement this, if necessary? */
    7.88  	return 0;
    7.89  }
    7.90  
    7.91  int BE_GL_GetSwapInterval(_THIS) {
    7.92 -	printf(__FILE__": %d- swap interval requested\n", __LINE__);
    7.93 +	/* TODO: Implement this, if necessary? */
    7.94  	return 0;
    7.95  }
    7.96  
    7.97  
    7.98  void BE_GL_UnloadLibrary(_THIS) {
    7.99 -	printf(__FILE__": %d- Library unloaded\n", __LINE__);
   7.100 +	/* TODO: Implement this, if necessary? */
   7.101  }
   7.102  
   7.103  
   7.104 -
   7.105 +/* FIXME: This function is meant to clear the OpenGL context when the video
   7.106 +   mode changes (see SDL_bmodes.cc), but it doesn't seem to help, and is not
   7.107 +   currently in use. */
   7.108  void BE_GL_RebootContexts(_THIS) {
   7.109  	SDL_Window *window = _this->windows;
   7.110  	while(window) {
     8.1 --- a/src/video/bwindow/SDL_bvideo.cc	Sat Aug 20 15:16:13 2011 +0000
     8.2 +++ b/src/video/bwindow/SDL_bvideo.cc	Mon Aug 22 11:02:05 2011 +0000
     8.3 @@ -53,23 +53,11 @@
     8.4  
     8.5      /* Initialize all variables that we clean on shutdown */
     8.6      device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
     8.7 -#if 0
     8.8 -    if (device) {
     8.9 -        data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
    8.10 -    } else {
    8.11 -        data = NULL;
    8.12 -    }
    8.13 -    if (!data) {
    8.14 -        SDL_OutOfMemory();
    8.15 -        if (device) {
    8.16 -            SDL_free(device);
    8.17 -        }
    8.18 -        return NULL;
    8.19 -    }
    8.20 -#endif
    8.21 -    device->driverdata = NULL; /*data;*/
    8.22  
    8.23 -/* TODO: Figure out what sort of initialization needs to go here */
    8.24 +    device->driverdata = NULL; /* FIXME: Is this the cause of some of the
    8.25 +    							  SDL_Quit() errors? */
    8.26 +
    8.27 +/* TODO: Figure out if any initialization needs to go here */
    8.28  
    8.29      /* Set the function pointers */
    8.30      device->VideoInit = BE_VideoInit;
    8.31 @@ -105,7 +93,7 @@
    8.32      device->shape_driver.SetWindowShape = NULL;
    8.33      device->shape_driver.ResizeWindowShape = NULL;
    8.34  
    8.35 -//#if SDL_VIDEO_OPENGL_WGL	/* FIXME: Replace with BeOs's SDL OPENGL stuff */
    8.36 +
    8.37      device->GL_LoadLibrary = BE_GL_LoadLibrary;
    8.38      device->GL_GetProcAddress = BE_GL_GetProcAddress;
    8.39      device->GL_UnloadLibrary = BE_GL_UnloadLibrary;
    8.40 @@ -115,7 +103,7 @@
    8.41      device->GL_GetSwapInterval = BE_GL_GetSwapInterval;
    8.42      device->GL_SwapWindow = BE_GL_SwapWindow;
    8.43      device->GL_DeleteContext = BE_GL_DeleteContext;
    8.44 -//#endif
    8.45 +
    8.46      device->StartTextInput = BE_StartTextInput;
    8.47      device->StopTextInput = BE_StopTextInput;
    8.48      device->SetTextInputRect = BE_SetTextInputRect;
    8.49 @@ -140,8 +128,6 @@
    8.50  	SDL_free(device);
    8.51  }
    8.52  
    8.53 -/* FIXME: This is the 1.2 function at the moment.  Read through it and
    8.54 -  o understand what it does. */
    8.55  int BE_VideoInit(_THIS)
    8.56  {
    8.57  	/* Initialize the Be Application for appserver interaction */
    8.58 @@ -162,9 +148,6 @@
    8.59      BE_GL_LoadLibrary(_this, NULL);
    8.60  #endif
    8.61  
    8.62 -        /* Fill in some window manager capabilities */
    8.63 -//    _this->info.wm_available = 1;
    8.64 -
    8.65          /* We're done! */
    8.66      return (0);
    8.67  }
    8.68 @@ -177,24 +160,8 @@
    8.69  void BE_VideoQuit(_THIS)
    8.70  {
    8.71  
    8.72 -#if 0
    8.73 -        SDL_Win->Quit();
    8.74 -        SDL_Win = NULL;
    8.75 -#endif
    8.76 -#if 0
    8.77 -        if (SDL_BlankCursor != NULL) {
    8.78 -            BE_FreeWMCursor(_this, SDL_BlankCursor);
    8.79 -            SDL_BlankCursor = NULL;
    8.80 -        }
    8.81 -#endif
    8.82 -
    8.83      BE_QuitModes(_this);
    8.84  
    8.85 -#if SDL_VIDEO_OPENGL
    8.86 -//    if (_this->gl_config.dll_handle != NULL)
    8.87 -//        unload_add_on((image_id) _this->gl_config.dll_handle);
    8.88 -#endif
    8.89 -
    8.90      SDL_QuitBeApp();
    8.91  }
    8.92  
     9.1 --- a/src/video/bwindow/SDL_bwindow.cc	Sat Aug 20 15:16:13 2011 +0000
     9.2 +++ b/src/video/bwindow/SDL_bwindow.cc	Mon Aug 22 11:02:05 2011 +0000
     9.3 @@ -47,13 +47,17 @@
     9.4      );
     9.5      
     9.6      if(window->flags & SDL_WINDOW_FULLSCREEN) {
     9.7 +    	/* TODO: Add support for this flag */
     9.8 +    	printf(__FILE__": %d!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",__LINE__);
     9.9      }
    9.10      if(window->flags & SDL_WINDOW_OPENGL) {
    9.11 +    	/* TODO: Add support for this flag */
    9.12      }
    9.13      if(!(window->flags & SDL_WINDOW_RESIZABLE)) {
    9.14      	flags |= B_NOT_RESIZABLE | B_NOT_ZOOMABLE;
    9.15      }
    9.16      if(window->flags & SDL_WINDOW_BORDERLESS) {
    9.17 +    	/* TODO: Add support for this flag */
    9.18      }
    9.19  
    9.20      SDL_BWin *bwin = new(std::nothrow) SDL_BWin(bounds, flags);
    9.21 @@ -172,10 +176,12 @@
    9.22  
    9.23  int BE_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) {
    9.24  	/* FIXME: Not BeOs/Haiku supported */
    9.25 +	return -1;
    9.26  }
    9.27  
    9.28  int BE_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) {
    9.29  	/* FIXME: Not BeOs/Haiku supported */
    9.30 +	return -1;
    9.31  }
    9.32  
    9.33  
    9.34 @@ -193,6 +199,7 @@
    9.35  SDL_bool BE_GetWindowWMInfo(_THIS, SDL_Window * window,
    9.36                                      struct SDL_SysWMinfo *info) {
    9.37  	/* FIXME: What is the point of this? What information should be included? */
    9.38 +	return SDL_FALSE;
    9.39  }
    9.40  
    9.41