diff --git a/headers/private/interface/InterfacePrivate.h b/headers/private/interface/InterfacePrivate.h index 6df8bf4372..56e0ec5873 100644 --- a/headers/private/interface/InterfacePrivate.h +++ b/headers/private/interface/InterfacePrivate.h @@ -19,6 +19,9 @@ bool get_mode_parameter(uint32 mode, int32& width, int32& height, uint32& colorSpace); int32 get_bytes_per_row(color_space colorSpace, int32 width); +void get_workspaces_layout(uint32* _columns, uint32* _rows); +void set_workspaces_layout(uint32 columns, uint32 rows); + } // namespace BPrivate diff --git a/src/kits/interface/InterfaceDefs.cpp b/src/kits/interface/InterfaceDefs.cpp index 6b1383dc49..b9a0f27eaf 100644 --- a/src/kits/interface/InterfaceDefs.cpp +++ b/src/kits/interface/InterfaceDefs.cpp @@ -10,7 +10,7 @@ /*! Global functions and variables for the Interface Kit */ -#include +#include #include #include @@ -18,7 +18,6 @@ #include #include -#include #include #include #include @@ -32,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -194,6 +194,43 @@ get_mode_parameter(uint32 mode, int32& width, int32& height, uint32& colorSpace) return true; } + +void +get_workspaces_layout(uint32* _columns, uint32* _rows) +{ + int32 columns = 1; + int32 rows = 1; + + BPrivate::AppServerLink link; + link.StartMessage(AS_GET_WORKSPACE_LAYOUT); + + status_t status; + if (link.FlushWithReply(status) == B_OK && status == B_OK) { + link.Read(&columns); + link.Read(&rows); + } + + if (_columns != NULL) + *_columns = columns; + if (_rows != NULL) + *_rows = rows; +} + + +void +set_workspaces_layout(uint32 columns, uint32 rows) +{ + if (columns < 1 || rows < 1) + return; + + BPrivate::AppServerLink link; + link.StartMessage(AS_SET_WORKSPACE_LAYOUT); + link.Attach(columns); + link.Attach(rows); + link.Flush(); +} + + } // namespace BPrivate @@ -718,17 +755,9 @@ keyboard_navigation_color() int32 count_workspaces() { - int32 columns = 1; - int32 rows = 1; - - BPrivate::AppServerLink link; - link.StartMessage(AS_GET_WORKSPACE_LAYOUT); - - status_t status; - if (link.FlushWithReply(status) == B_OK && status == B_OK) { - link.Read(&columns); - link.Read(&rows); - } + uint32 columns; + uint32 rows; + BPrivate::get_workspaces_layout(&columns, &rows); return columns * rows; } @@ -747,11 +776,7 @@ set_workspace_count(int32 count) int32 columns = count / rows; - BPrivate::AppServerLink link; - link.StartMessage(AS_SET_WORKSPACE_LAYOUT); - link.Attach(columns); - link.Attach(rows); - link.Flush(); + BPrivate::set_workspaces_layout(columns, rows); } @@ -952,7 +977,7 @@ _init_interface_kit_() be_control_look = new BControlLook(); _init_global_fonts_(); - + BPrivate::gWidthBuffer = new BPrivate::WidthBuffer; status = BPrivate::MenuPrivate::CreateBitmaps(); if (status != B_OK) @@ -980,7 +1005,7 @@ extern "C" status_t _fini_interface_kit_() { BPrivate::MenuPrivate::DeleteBitmaps(); - + delete BPrivate::gWidthBuffer; BPrivate::gWidthBuffer = NULL;