Ticket #8365: workspaceszoom1.patch

File workspaceszoom1.patch, 4.2 KB (added by devine, 13 years ago)

Updates the size (by calling Zoom()) when the workspace layout is updated. Depends on patch in #8188

  • src/apps/workspaces/Workspaces.cpp

    diff --git a/src/apps/workspaces/Workspaces.cpp b/src/apps/workspaces/Workspaces.cpp
    index f92b580..ca58b3e 100644
    a b static const uint32 kMsgToggleBorder = 'tgBd';  
    5555static const uint32 kMsgToggleAutoRaise = 'tgAR';
    5656static const uint32 kMsgToggleAlwaysOnTop = 'tgAT';
    5757static const uint32 kMsgToggleLiveInDeskbar = 'tgDb';
    58 
     58static const uint32 kMsgWorkspaceLayoutChanged = 'wslc'; //From Screen preflet
    5959
    6060extern "C" _EXPORT BView* instantiate_deskbar_item();
    6161
    class WorkspacesApp : public BApplication {  
    156156
    157157        virtual void AboutRequested();
    158158        virtual void ArgvReceived(int32 argc, char **argv);
     159        virtual void MessageReceived(BMessage *message);
    159160        virtual void ReadyToRun();
    160161
    161162        void Usage(const char *programName);
    WorkspacesWindow::Zoom(BPoint origin, float width, float height)  
    757758    height = floor(workspaceHeight * rows);
    758759
    759760    while (width + 2 * GetScreenBorderOffset() > screenWidth
    760         || height + 2 * GetScreenBorderOffset() + GetTabHeight() > screenHeight) {
     761        || height + 2 * GetScreenBorderOffset() + GetTabHeight() > screenHeight)    {
    761762        width = floor(0.95 * width);
    762763        height = floor(0.95 * height);
    763764    }
    764765
    765766    ResizeTo(width, height);
    766 
    767     origin = screen.Frame().RightBottom();
    768     origin.x -= GetScreenBorderOffset() + width;
    769     origin.y -= GetScreenBorderOffset() + height;
    770 
    771     MoveTo(origin);
    772767}
    773768
    774769
    WorkspacesWindow::MessageReceived(BMessage *message)  
    859854            break;
    860855        }
    861856
     857        case kMsgWorkspaceLayoutChanged:
     858        {
     859            float width = Frame().right - Frame().left;
     860            float height = Frame().bottom - Frame().top;
     861            Zoom(BPoint(0,0), width, height);
     862            break;
     863        }
     864
    862865        default:
    863866            BWindow::MessageReceived(message);
    864867            break;
    WorkspacesApp::ReadyToRun()  
    10291032    fWindow->Show();
    10301033}
    10311034
     1035void
     1036WorkspacesApp::MessageReceived(BMessage *message)
     1037{
     1038    switch (message->what) {
     1039        case kMsgWorkspaceLayoutChanged:
     1040        {
     1041            fWindow->MessageReceived(message);
     1042            break;
     1043        }
     1044        default:
     1045            BApplication::MessageReceived(message);
     1046            break;
     1047    };
     1048}
    10321049
    10331050//  #pragma mark -
    10341051
    1035 
    10361052int
    10371053main(int argc, char **argv)
    10381054{
  • src/preferences/screen/Constants.h

    diff --git a/src/preferences/screen/Constants.h b/src/preferences/screen/Constants.h
    index 3191d9d..6183d0b 100644
    a b static const uint32 kMsgWorkspaceRowsChanged = 'wsrc';  
    4343
    4444// Constants
    4545extern const char* kBackgroundsSignature;
     46extern const char* kWorkspacesSignature;
    4647
    4748static const int32 gMinRefresh = 45;    // This is the minimum selectable refresh
    4849static const int32 gMaxRefresh = 140;   // This is the maximum selectable refresh
  • src/preferences/screen/ScreenWindow.cpp

    diff --git a/src/preferences/screen/ScreenWindow.cpp b/src/preferences/screen/ScreenWindow.cpp
    index 335f70d..61f4c9c 100644
    a b  
    6767
    6868
    6969const char* kBackgroundsSignature = "application/x-vnd.Haiku-Backgrounds";
     70const char* kWorkspacesSignature = "application/x-vnd.Be-WORK";
    7071
    7172// list of officially supported colour spaces
    7273static const struct {
    ScreenWindow::_UpdateWorkspaceButtons()  
    827828    _GetColumnRowButton(false, true)->SetEnabled(columns * (rows + 1) < 32);
    828829}
    829830
     831void
     832ScreenWindow::_UpdateWorkspaceWindow()
     833{
     834    BMessage msg(kMsgWorkspaceLayoutChanged); //Workspace Layout Changed
     835    BMessenger messenger(kWorkspacesSignature,-1);
     836    messenger.SendMessage(&msg);
     837}
     838
    830839
    831840void
    832841ScreenWindow::ScreenChanged(BRect frame, color_space mode)
    ScreenWindow::MessageReceived(BMessage* message)  
    878887            BPrivate::set_workspaces_layout(newColumns, newRows);
    879888
    880889            _UpdateWorkspaceButtons();
     890            _UpdateWorkspaceWindow();
    881891            _CheckApplyEnabled();
    882892            break;
    883893        }
  • src/preferences/screen/ScreenWindow.h

    diff --git a/src/preferences/screen/ScreenWindow.h b/src/preferences/screen/ScreenWindow.h
    index b5bedd8..2638eb7 100644
    a b private:  
    5151
    5252            void            _UpdateActiveMode();
    5353            void            _UpdateWorkspaceButtons();
     54            void            _UpdateWorkspaceWindow();
    5455            void            _UpdateRefreshControl();
    5556            void            _UpdateMonitorView();
    5657            void            _UpdateControls();