by Stefano Ceccherini

Ifdeffed R5 specific stuff so DirectWindow.cpp and WindowScreen.cpp compile on
haiku too. That doesnt' mean they work there though.
This introduced some warnings which I didn't fix, as they'll go away later.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@11982 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2005-03-25 13:18:26 +00:00
parent f3b44aede9
commit 8575beb8d6
3 changed files with 81 additions and 37 deletions
+18 -8
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2003-2004, Haiku Inc. * Copyright 2003-2005, Haiku Inc.
* Authors: * Authors:
* Stefano Ceccherini ([email protected]). * Stefano Ceccherini ([email protected]).
* Carwyn Jones ([email protected]) * Carwyn Jones ([email protected])
@@ -10,9 +10,10 @@
#include <DirectWindow.h> #include <DirectWindow.h>
#include <clipping.h> #include <clipping.h>
#ifdef COMPILE_FOR_R5
#include <R5_AppServerLink.h> #include <R5_AppServerLink.h>
#include <R5_Session.h> #include <R5_Session.h>
#endif
// TODO: We'll want to move this to a private header, // TODO: We'll want to move this to a private header,
// accessible by the app server. // accessible by the app server.
@@ -283,6 +284,8 @@ BDirectWindow::SetFullScreen(bool enable)
{ {
status_t status = B_ERROR; status_t status = B_ERROR;
if (Lock()) { if (Lock()) {
#ifdef COMPILE_FOR_R5
a_session->swrite_l(DW_SET_FULLSCREEN); a_session->swrite_l(DW_SET_FULLSCREEN);
a_session->swrite_l(server_token); a_session->swrite_l(server_token);
a_session->swrite_l((int32)enable); a_session->swrite_l((int32)enable);
@@ -291,6 +294,7 @@ BDirectWindow::SetFullScreen(bool enable)
status_t fullScreen; status_t fullScreen;
a_session->sread(sizeof(status_t), &fullScreen); a_session->sread(sizeof(status_t), &fullScreen);
a_session->sread(sizeof(status_t), &status); a_session->sread(sizeof(status_t), &status);
#endif
Unlock(); Unlock();
// TODO: Revisit this when we move to our app_server // TODO: Revisit this when we move to our app_server
@@ -312,13 +316,15 @@ BDirectWindow::IsFullScreen() const
bool bool
BDirectWindow::SupportsWindowMode(screen_id id) BDirectWindow::SupportsWindowMode(screen_id id)
{ {
int32 result = 0;
#ifdef COMPILE_FOR_R5
_BAppServerLink_ link; _BAppServerLink_ link;
link.fSession->swrite_l(DW_SUPPORTS_WINDOW_MODE); link.fSession->swrite_l(DW_SUPPORTS_WINDOW_MODE);
link.fSession->swrite_l(id.id); link.fSession->swrite_l(id.id);
link.fSession->sync(); link.fSession->sync();
int32 result;
link.fSession->sread(sizeof(result), &result); link.fSession->sread(sizeof(result), &result);
#endif
return result & true; return result & true;
} }
@@ -421,16 +427,20 @@ BDirectWindow::InitData()
direct_driver = NULL; direct_driver = NULL;
if (Lock()) { if (Lock()) {
struct dw_sync_data sync_data;
status_t status = B_ERROR;
#ifdef COMPILE_FOR_R5
a_session->swrite_l(DW_GET_SYNC_DATA); a_session->swrite_l(DW_GET_SYNC_DATA);
a_session->swrite_l(server_token); a_session->swrite_l(server_token);
Flush(); Flush();
struct dw_sync_data sync_data;
a_session->sread(sizeof(sync_data), &sync_data); a_session->sread(sizeof(sync_data), &sync_data);
status_t status;
a_session->sread(sizeof(status), &status);
a_session->sread(sizeof(status), &status);
#endif
Unlock(); Unlock();
if (status == B_OK) { if (status == B_OK) {
+10 -3
View File
@@ -3,6 +3,16 @@ SubDir OBOS_TOP src kits game ;
UsePrivateHeaders interface ; UsePrivateHeaders interface ;
UsePrivateHeaders input ; UsePrivateHeaders input ;
if ! $(HAIKU_COMPATIBLE) {
SubDirC++Flags -DCOMPILE_FOR_R5 ;
# Hack to have DirectWindow.cpp and WindowScreen.cpp
# include the R5 <Window .h> header.
PrependObjectHdrs DirectWindow.cpp : /boot/develop/headers/be/interface ;
PrependObjectHdrs WindowScreen.cpp : /boot/develop/headers/be/interface ;
}
SharedLibrary game : SharedLibrary game :
# Public Game Kit # Public Game Kit
DirectWindow.cpp DirectWindow.cpp
@@ -20,9 +30,6 @@ SharedLibrary game :
GSUtility.cpp GSUtility.cpp
; ;
# Hack to have DirectWindow.cpp and WindowScreen.cpp include the R5 <Window .h> header.
PrependObjectHdrs DirectWindow.cpp : /boot/develop/headers/be/interface ;
PrependObjectHdrs WindowScreen.cpp : /boot/develop/headers/be/interface ;
LinkSharedOSLibs libgame.so : LinkSharedOSLibs libgame.so :
be libmedia.so be libmedia.so
+53 -26
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2004, * Copyright 2002-2005,
* Marcus Overhagen, * Marcus Overhagen,
* Stefano Ceccherini ([email protected]), * Stefano Ceccherini ([email protected]),
* Carwyn Jones ([email protected]) * Carwyn Jones ([email protected])
@@ -17,10 +17,13 @@
#include <input_globals.h> #include <input_globals.h>
#include <InputServerTypes.h> // For IS_SET_MOUSE_POSITION #include <InputServerTypes.h> // For IS_SET_MOUSE_POSITION
#include <R5_AppServerLink.h>
#include <WindowPrivate.h> #include <WindowPrivate.h>
#ifdef COMPILE_FOR_R5
#include <R5_AppServerLink.h>
#endif
// WindowScreen commands // WindowScreen commands
#define WS_PROPOSE_MODE 0x00000102 #define WS_PROPOSE_MODE 0x00000102
#define WS_MOVE_DISPLAY 0x00000108 #define WS_MOVE_DISPLAY 0x00000108
@@ -328,10 +331,12 @@ BWindowScreen::~BWindowScreen()
delete_sem(debug_sem); delete_sem(debug_sem);
if (debug_state) { if (debug_state) {
#ifdef COMPILE_FOR_R5
_BAppServerLink_ link; _BAppServerLink_ link;
link.fSession->swrite_l(WS_SWITCH_WORKSPACE); link.fSession->swrite_l(WS_SWITCH_WORKSPACE);
link.fSession->swrite_l(debug_workspace); link.fSession->swrite_l(debug_workspace);
link.fSession->sync(); link.fSession->sync();
#endif
} }
free(new_space); free(new_space);
@@ -453,6 +458,7 @@ BWindowScreen::SetColorList(rgb_color *list, int32 first_index, int32 last_index
colorList[x] = list[x]; colorList[x] = list[x];
// Tell the app_server about our changes // Tell the app_server about our changes
#ifdef COMPILE_FOR_R5
_BAppServerLink_ link; _BAppServerLink_ link;
link.fSession->swrite_l(WS_SET_PALETTE); link.fSession->swrite_l(WS_SET_PALETTE);
link.fSession->swrite_l(screen_index); link.fSession->swrite_l(screen_index);
@@ -460,7 +466,7 @@ BWindowScreen::SetColorList(rgb_color *list, int32 first_index, int32 last_index
link.fSession->swrite_l(last_index); link.fSession->swrite_l(last_index);
link.fSession->swrite(colorCount * sizeof(rgb_color), colorList); link.fSession->swrite(colorCount * sizeof(rgb_color), colorList);
link.fSession->sync(); link.fSession->sync();
#endif
screen.WaitForRetrace(); screen.WaitForRetrace();
} }
@@ -500,6 +506,9 @@ BWindowScreen::SetFrameBuffer(int32 width, int32 height)
// equivalent to BScreen::ProposeMode() // equivalent to BScreen::ProposeMode()
// TODO: So why don't we just use it instead? // TODO: So why don't we just use it instead?
status_t status = B_ERROR;
#ifdef COMPILE_FOR_R5
_BAppServerLink_ link; _BAppServerLink_ link;
link.fSession->swrite_l(WS_DISPLAY_UTILS); link.fSession->swrite_l(WS_DISPLAY_UTILS);
link.fSession->swrite_l(screen_index); link.fSession->swrite_l(screen_index);
@@ -508,10 +517,9 @@ BWindowScreen::SetFrameBuffer(int32 width, int32 height)
link.fSession->swrite(sizeof(display_mode), &mode); link.fSession->swrite(sizeof(display_mode), &mode);
link.fSession->swrite(sizeof(display_mode), &lowMode); link.fSession->swrite(sizeof(display_mode), &lowMode);
link.fSession->sync(); link.fSession->sync();
status_t status;
link.fSession->sread(sizeof(status), &status); link.fSession->sread(sizeof(status), &status);
link.fSession->sread(sizeof(display_mode), &mode); link.fSession->sread(sizeof(display_mode), &mode);
#endif
// If the mode is supported, change the workspace // If the mode is supported, change the workspace
// to that mode. // to that mode.
@@ -525,16 +533,18 @@ BWindowScreen::SetFrameBuffer(int32 width, int32 height)
status_t status_t
BWindowScreen::MoveDisplayArea(int32 x, int32 y) BWindowScreen::MoveDisplayArea(int32 x, int32 y)
{ {
status_t status = B_ERROR;
#ifdef COMPILE_FOR_R5
_BAppServerLink_ link; _BAppServerLink_ link;
link.fSession->swrite_l(WS_DISPLAY_UTILS); link.fSession->swrite_l(WS_DISPLAY_UTILS);
link.fSession->swrite_l(screen_index); link.fSession->swrite_l(screen_index);
link.fSession->swrite_l(WS_MOVE_DISPLAY); link.fSession->swrite_l(WS_MOVE_DISPLAY);
link.fSession->swrite(sizeof(int16), (int16*)&x); link.fSession->swrite(sizeof(int16), (int16*)&x);
link.fSession->swrite(sizeof(int16), (int16*)&y); link.fSession->swrite(sizeof(int16), (int16*)&y);
link.fSession->sync(); link.fSession->sync();
status_t status;
link.fSession->sread(sizeof(status), &status); link.fSession->sread(sizeof(status), &status);
#endif
if (status == B_OK) { if (status == B_OK) {
format_info.display_x = x; format_info.display_x = x;
@@ -658,11 +668,12 @@ BWindowScreen::Suspend(char *label)
Unlock(); Unlock();
// Switch to debug workspace // Switch to debug workspace
#ifdef COMPILE_FOR_R5
_BAppServerLink_ link; _BAppServerLink_ link;
link.fSession->swrite_l(WS_SWITCH_WORKSPACE); link.fSession->swrite_l(WS_SWITCH_WORKSPACE);
link.fSession->swrite_l(debug_workspace); link.fSession->swrite_l(debug_workspace);
link.fSession->sync(); link.fSession->sync();
#endif
// Suspend ourself // Suspend ourself
suspend_thread(find_thread(NULL)); suspend_thread(find_thread(NULL));
@@ -707,19 +718,21 @@ BWindowScreen::CalcFrame(int32 index, int32 space, display_mode *dmode)
int32 int32
BWindowScreen::SetFullscreen(int32 enable) BWindowScreen::SetFullscreen(int32 enable)
{ {
int32 result = -1, retval = -1;
#ifdef COMPILE_FOR_R5
a_session->swrite_l(WS_SET_FULLSCREEN); a_session->swrite_l(WS_SET_FULLSCREEN);
a_session->swrite_l(server_token); a_session->swrite_l(server_token);
a_session->swrite_l(enable); a_session->swrite_l(enable);
a_session->sync(); a_session->sync();
int32 result, retval;
a_session->sread(sizeof(result), &result); a_session->sread(sizeof(result), &result);
a_session->sread(sizeof(retval), &retval); a_session->sread(sizeof(retval), &retval);
#endif
return retval; return retval;
} }
status_t status_t
BWindowScreen::InitData(uint32 space, uint32 attributes) BWindowScreen::InitData(uint32 space, uint32 attributes)
{ {
@@ -807,20 +820,23 @@ BWindowScreen::SetActiveState(int32 state)
if (status == B_OK) { if (status == B_OK) {
be_app->ShowCursor(); be_app->ShowCursor();
if (activate_state) { if (activate_state) {
const color_map *colorMap = system_colors();
#ifdef COMPILE_FOR_R5
_BAppServerLink_ link; _BAppServerLink_ link;
link.fSession->swrite_l(WS_SET_PALETTE); link.fSession->swrite_l(WS_SET_PALETTE);
link.fSession->swrite_l(screen_index); link.fSession->swrite_l(screen_index);
link.fSession->swrite_l(0); link.fSession->swrite_l(0);
link.fSession->swrite_l(255); link.fSession->swrite_l(255);
const color_map *colorMap = system_colors();
link.fSession->swrite(256 * sizeof(rgb_color), const_cast<rgb_color *>(colorMap->color_list)); link.fSession->swrite(256 * sizeof(rgb_color), const_cast<rgb_color *>(colorMap->color_list));
link.fSession->sync(); link.fSession->sync();
#endif
} }
} }
} }
return status; return status;
} }
status_t status_t
BWindowScreen::SetLockState(int32 state) BWindowScreen::SetLockState(int32 state)
{ {
@@ -835,18 +851,20 @@ BWindowScreen::SetLockState(int32 state)
acquire_engine_global = NULL; acquire_engine_global = NULL;
release_engine_global = NULL; release_engine_global = NULL;
} }
status_t status = B_ERROR;
#ifdef COMPILE_FOR_R5
_BAppServerLink_ link; _BAppServerLink_ link;
link.fSession->swrite_l(WS_SET_LOCK_STATE); link.fSession->swrite_l(WS_SET_LOCK_STATE);
link.fSession->swrite_l(screen_index); link.fSession->swrite_l(screen_index);
link.fSession->swrite_l(state); link.fSession->swrite_l(state);
link.fSession->swrite_l(server_token); link.fSession->swrite_l(server_token);
link.fSession->sync(); link.fSession->sync();
status_t status;
link.fSession->sread(sizeof(status), &status); link.fSession->sread(sizeof(status), &status);
#endif
if (status == B_NO_ERROR) { if (status == B_OK) {
lock_state = state; lock_state = state;
if (state == 1) { if (state == 1) {
if (addon_state == 0) { if (addon_state == 0) {
@@ -923,16 +941,19 @@ BWindowScreen::GetCardInfo()
card_info.flags |= B_PARALLEL_BUFFER_ACCESS; card_info.flags |= B_PARALLEL_BUFFER_ACCESS;
screen_id id = screen.ID(); screen_id id = screen.ID();
status_t result = B_ERROR;
#ifdef COMPILE_FOR_R5
_BAppServerLink_ link; _BAppServerLink_ link;
link.fSession->swrite_l(WS_GET_FRAMEBUFFER); link.fSession->swrite_l(WS_GET_FRAMEBUFFER);
link.fSession->swrite_l(id.id); link.fSession->swrite_l(id.id);
link.fSession->sync(); link.fSession->sync();
int32 result;
link.fSession->sread(sizeof(result), &result); link.fSession->sread(sizeof(result), &result);
link.fSession->sread(sizeof(frame_buffer_config), &config);
#endif
if(result == B_NO_ERROR) { if(result == B_OK) {
link.fSession->sread(sizeof(frame_buffer_config), &config);
card_info.id = id.id; card_info.id = id.id;
card_info.frame_buffer = config.frame_buffer; card_info.frame_buffer = config.frame_buffer;
card_info.bytes_per_row = config.bytes_per_row; card_info.bytes_per_row = config.bytes_per_row;
@@ -1009,6 +1030,11 @@ BWindowScreen::GetModeFromSpace(uint32 space, display_mode *dmode)
status_t status_t
BWindowScreen::InitClone() BWindowScreen::InitClone()
{ {
#ifndef COMPILE_FOR_R5
// TODO: Too much stuff to change, I'll just
return B_ERROR;
// for now
#else
// TODO: Using BScreen::GetDeviceInfo() could do the job, I think, // TODO: Using BScreen::GetDeviceInfo() could do the job, I think,
// but it always returns B_ERROR on my system (Rudolf's Nvidia driver) // but it always returns B_ERROR on my system (Rudolf's Nvidia driver)
_BAppServerLink_ link; _BAppServerLink_ link;
@@ -1072,23 +1098,24 @@ BWindowScreen::InitClone()
} }
return result; return result;
#endif
} }
status_t status_t
BWindowScreen::AssertDisplayMode(display_mode *dmode) BWindowScreen::AssertDisplayMode(display_mode *dmode)
{ {
status_t result; status_t result = B_ERROR;
_BAppServerLink_ link;
// TODO: Why not BScreen::SetMode() ? // TODO: Why not BScreen::SetMode() ?
#ifdef COMPILE_FOR_R5
_BAppServerLink_ link;
link.fSession->swrite_l(WS_GET_DISPLAY_MODE); // check display_mode valid command link.fSession->swrite_l(WS_GET_DISPLAY_MODE); // check display_mode valid command
link.fSession->swrite_l(screen_index); link.fSession->swrite_l(screen_index);
link.fSession->swrite(sizeof(display_mode), (void *)dmode); link.fSession->swrite(sizeof(display_mode), (void *)dmode);
link.fSession->sync(); link.fSession->sync();
link.fSession->sread(sizeof(result), &result); link.fSession->sread(sizeof(result), &result);
#endif
// if the result is B_OK, we copy the dmode to new_space // if the result is B_OK, we copy the dmode to new_space
if (result == B_OK) { if (result == B_OK) {
memcpy(new_space, dmode, sizeof(display_mode)); memcpy(new_space, dmode, sizeof(display_mode));