* Implemented BDragger::{Show|Hide}AllDraggers() and its backend in the app_server.

This fixes bug #242. The value is currently stored in a separate file.
* Removed some unused codes from ServerProtocol.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20188 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2007-02-21 07:57:21 +00:00
parent 72d71bc8dc
commit cf2aeb201f
9 changed files with 243 additions and 77 deletions

View File

@ -67,18 +67,23 @@ class BDragger : public BView {
virtual BBitmap* DragBitmap(BPoint* offset, drawing_mode *mode);
class Private;
protected:
bool IsVisibilityChanging() const;
private:
friend class BPrivate::ShelfContainerViewFilter;
friend class BPrivate::replicant_data;
friend class Private;
friend class BShelf;
virtual void _ReservedDragger2();
virtual void _ReservedDragger3();
virtual void _ReservedDragger4();
static void _UpdateShowAllDraggers(bool visible);
BDragger& operator=(const BDragger& other);
void _AddToList();

View File

@ -17,9 +17,9 @@
// Server port names. The input port is the port which is used to receive
// input messages from the Input Server. The other is the "main" port for
// the server and is utilized mostly by BApplication objects.
#define SERVER_PORT_NAME "OBappserver"
#define SERVER_PORT_NAME "haiku app_server"
#if TEST_MODE
# define SERVER_INPUT_PORT "OBinputport"
# define SERVER_INPUT_PORT "haiku input port"
#endif
#define AS_REQUEST_COLOR_KEY 0x00010000
@ -29,8 +29,10 @@ enum {
// NOTE: all defines have to start with "AS_" to let the "code_to_name"
// utility work correctly
AS_REGISTER_INPUT_SERVER = 1,
AS_GET_DESKTOP,
AS_REGISTER_INPUT_SERVER = 1,
AS_EVENT_STREAM_CLOSED,
// Notification of event stream closing to restart input_server
// Desktop definitions (through the ServerApp, though)
AS_GET_WINDOW_LIST,
@ -93,7 +95,6 @@ enum {
AS_SET_SIZE_LIMITS,
AS_ACTIVATE_WINDOW,
AS_IS_FRONT_WINDOW,
AS_UPDATE_IF_NEEDED,
// BPicture definitions
AS_CREATE_PICTURE,
@ -176,14 +177,13 @@ enum {
AS_GET_MENU_INFO,
AS_SET_MENU_INFO,
AS_IDLE_TIME,
AS_SELECT_PRINTER_PANEL,
AS_ADD_PRINTER_PANEL,
AS_RUN_BE_ABOUT,
AS_SET_MOUSE_MODE,
AS_GET_MOUSE_MODE,
AS_GET_MOUSE,
AS_SET_DECORATOR_SETTINGS,
AS_GET_DECORATOR_SETTINGS,
AS_GET_SHOW_ALL_DRAGGERS,
AS_SET_SHOW_ALL_DRAGGERS,
// Graphics calls
AS_SET_HIGH_COLOR,
@ -289,9 +289,6 @@ enum {
AS_DIRECT_WINDOW_GET_SYNC_DATA,
AS_DIRECT_WINDOW_SET_FULLSCREEN,
// Notification of event stream closing to restart input_server
AS_EVENT_STREAM_CLOSED,
AS_LAST_CODE
};

View File

@ -0,0 +1,23 @@
/*
* Copyright 2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _DRAGGER_PRIVATE_H
#define _DRAGGER_PRIVATE_H
#include <Dragger.h>
class BDragger::Private {
public:
Private(BDragger* dragger) : fDragger(dragger) {}
static void UpdateShowAllDraggers(bool visible)
{ BDragger::_UpdateShowAllDraggers(visible); }
private:
BDragger* fDragger;
};
#endif // _DRAGGER_PRIVATE_H

View File

@ -9,16 +9,20 @@
*/
#include <new>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <AppMisc.h>
#include <AppServerLink.h>
#include <DraggerPrivate.h>
#include <LooperList.h>
#include <MenuWindow.h>
#include <ObjectLocker.h>
#include <PortLink.h>
#include <RosterPrivate.h>
#include <ServerMemoryAllocator.h>
#include <ServerProtocol.h>
#include <Alert.h>
#include <AppFileInfo.h>
#include <Application.h>
#include <AppMisc.h>
#include <MessageRunner.h>
#include <Cursor.h>
#include <Debug.h>
@ -30,20 +34,16 @@
#include <RegistrarDefs.h>
#include <Resources.h>
#include <Roster.h>
#include <RosterPrivate.h>
#include <Window.h>
#include <AppServerLink.h>
#include <LooperList.h>
#include <MenuWindow.h>
#include <ObjectLocker.h>
#include <PortLink.h>
#include <ServerMemoryAllocator.h>
#include <ServerProtocol.h>
#include <new>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
using namespace BPrivate;
// Globals ---------------------------------------------------------------------
BApplication *be_app = NULL;
BMessenger be_app_messenger;
@ -953,12 +953,14 @@ BApplication::DispatchMessage(BMessage *message, BHandler *handler)
case _SHOW_DRAG_HANDLES_:
{
bool visible = false;
message->FindBool("visible", &visible);
// TODO: Call the registrar or whoever is responsible for this
bool show;
if (message->FindBool("show", &show) != B_OK)
break;
BDragger::Private::UpdateShowAllDraggers(show);
break;
}
// TODO: Handle these as well
case _DISPOSE_DRAG_:
case _PING_:

View File

@ -1,5 +1,5 @@
/*
* Copyright 2001-2006, Haiku.
* Copyright 2001-2007, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -8,6 +8,9 @@
//! BDragger represents a replicant "handle".
#include <AppServerLink.h>
#include <ServerProtocol.h>
#include <ViewPrivate.h>
#include <Alert.h>
@ -46,14 +49,14 @@ kHandBitmap[] = {
BDragger::BDragger(BRect bounds, BView *target, uint32 rmask, uint32 flags)
: BView(bounds, "_dragger_", rmask, flags),
fTarget(target),
fRelation(TARGET_UNKNOWN),
fShelf(NULL),
fTransition(false),
fIsZombie(false),
fErrCount(0),
fPopUp(NULL)
: BView(bounds, "_dragger_", rmask, flags),
fTarget(target),
fRelation(TARGET_UNKNOWN),
fShelf(NULL),
fTransition(false),
fIsZombie(false),
fErrCount(0),
fPopUp(NULL)
{
fBitmap = new BBitmap(BRect(0.0f, 0.0f, 7.0f, 7.0f), B_CMAP8, false, false);
fBitmap->SetBits(kHandBitmap, fBitmap->BitsLength(), 0, B_CMAP8);
@ -61,14 +64,14 @@ BDragger::BDragger(BRect bounds, BView *target, uint32 rmask, uint32 flags)
BDragger::BDragger(BMessage *data)
: BView(data),
fTarget(NULL),
fRelation(TARGET_UNKNOWN),
fShelf(NULL),
fTransition(false),
fIsZombie(false),
fErrCount(0),
fPopUp(NULL)
: BView(data),
fTarget(NULL),
fRelation(TARGET_UNKNOWN),
fShelf(NULL),
fTransition(false),
fIsZombie(false),
fErrCount(0),
fPopUp(NULL)
{
data->FindInt32("_rel", (int32 *)&fRelation);
@ -270,8 +273,8 @@ BDragger::MessageReceived(BMessage *msg)
"Can't delete this replicant from its original application. Life goes on.",
"OK", NULL, NULL, B_WIDTH_FROM_WIDEST, B_WARNING_ALERT))->Go(NULL);
}
} else if (msg->what == B_SCREEN_CHANGED) {
// TODO: this code is to be called whenever the "are draggers drawn" option is changed
} else if (msg->what == _SHOW_DRAG_HANDLES_) {
// this code is used whenever the "are draggers drawn" option is changed
if (fRelation == TARGET_IS_CHILD) {
fTransition = true;
Invalidate();
@ -306,16 +309,34 @@ BDragger::FrameResized(float newWidth, float newHeight)
status_t
BDragger::ShowAllDraggers()
{
// TODO: Implement. Should ask the registrar or the app server
return B_OK;
BPrivate::AppServerLink link;
link.StartMessage(AS_SET_SHOW_ALL_DRAGGERS);
link.Attach<bool>(true);
status_t status = link.Flush();
if (status == B_OK) {
sVisible = true;
sVisibleInitialized = true;
}
return status;
}
status_t
BDragger::HideAllDraggers()
{
// TODO: Implement. Should ask the registrar or the app server
return B_OK;
BPrivate::AppServerLink link;
link.StartMessage(AS_SET_SHOW_ALL_DRAGGERS);
link.Attach<bool>(false);
status_t status = link.Flush();
if (status == B_OK) {
sVisible = false;
sVisibleInitialized = true;
}
return status;
}
@ -325,10 +346,17 @@ BDragger::AreDraggersDrawn()
BAutolock _(sLock);
if (!sVisibleInitialized) {
// TODO: Implement. Should ask the registrar or the app server
sVisible = true;
sVisibleInitialized = true;
BPrivate::AppServerLink link;
link.StartMessage(AS_GET_SHOW_ALL_DRAGGERS);
status_t status;
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
link.Read<bool>(&sVisible);
sVisibleInitialized = true;
} else
return false;
}
return sVisible;
}
@ -451,6 +479,22 @@ BDragger::operator=(const BDragger &)
}
/*static*/ void
BDragger::_UpdateShowAllDraggers(bool visible)
{
BAutolock _(sLock);
sVisibleInitialized = true;
sVisible = visible;
for (int32 i = sList.CountItems(); i-- > 0;) {
BDragger* dragger = (BDragger*)sList.ItemAt(i);
BMessenger target(dragger);
target.SendMessage(_SHOW_DRAG_HANDLES_);
}
}
void
BDragger::_AddToList()
{
@ -482,8 +526,6 @@ BDragger::_RemoveFromList()
status_t
BDragger::_DetermineRelationship()
{
status_t err = B_OK;
if (fTarget) {
if (fTarget == Parent())
fRelation = TARGET_IS_PARENT;
@ -497,10 +539,10 @@ BDragger::_DetermineRelationship()
else if (fRelation == TARGET_IS_CHILD)
fTarget = ChildAt(0);
else
err = B_ERROR;
return B_ERROR;
}
return err;
return B_OK;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2005-2006, Haiku.
* Copyright 2005-2007, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -46,12 +46,13 @@ DesktopSettingsPrivate::_SetDefaults()
fFixedFont = *gFontManager->DefaultFixedFont();
fMouseMode = B_NORMAL_MOUSE;
fShowAllDraggers = true;
// init scrollbar info
fScrollBarInfo.proportional = true;
fScrollBarInfo.double_arrows = false;
// look of the knob (R5: (0, 1, 2), 1 = default)
fScrollBarInfo.knob = 1;
// look of the knob (R5: (0, 1, 2), 1 = default)
fScrollBarInfo.min_knob_size = 15;
// init menu info
@ -60,9 +61,8 @@ DesktopSettingsPrivate::_SetDefaults()
fMenuInfo.font_size = fPlainFont.Size();
fMenuInfo.background_color.set_to(216, 216, 216);
// look of the separator (R5: (0, 1, 2), default 0)
// TODO: we could just choose a nice one and remove the others
fMenuInfo.separator = 0;
// look of the separator (R5: (0, 1, 2), default 0)
fMenuInfo.click_to_open = true; // always true
fMenuInfo.triggers_always_shown = false;
@ -288,6 +288,20 @@ DesktopSettingsPrivate::Save(uint32 mask)
}
}
if (mask & kDraggerSettings) {
BPath path(basePath);
if (path.Append("dragger") == B_OK) {
BMessage settings('asdg');
settings.AddBool("show", fShowAllDraggers);
BFile file;
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_READ_WRITE);
if (status == B_OK) {
status = settings.Flatten(&file, NULL);
}
}
}
if (mask & kAppearanceSettings) {
BPath path(basePath);
if (path.Append("appearance") == B_OK) {
@ -410,6 +424,21 @@ DesktopSettingsPrivate::FocusFollowsMouse() const
}
void
DesktopSettingsPrivate::SetShowAllDraggers(bool show)
{
fShowAllDraggers = show;
Save(kDraggerSettings);
}
bool
DesktopSettingsPrivate::ShowAllDraggers() const
{
return fShowAllDraggers;
}
void
DesktopSettingsPrivate::SetWorkspacesCount(int32 number)
{
@ -513,6 +542,13 @@ DesktopSettings::FocusFollowsMouse() const
}
bool
DesktopSettings::ShowAllDraggers() const
{
return fSettings->ShowAllDraggers();
}
int32
DesktopSettings::WorkspacesCount() const
{
@ -531,12 +567,10 @@ DesktopSettings::WorkspacesMessage(int32 index) const
LockedDesktopSettings::LockedDesktopSettings(Desktop* desktop)
:
fSettings(desktop->fSettings),
: DesktopSettings(desktop),
fDesktop(desktop)
{
// TODO: this only works in MultiLocker's DEBUG mode
#if 0
#if DEBUG
if (desktop->fWindowLock.IsReadLocked())
debugger("desktop read locked when trying to change settings");
#endif
@ -593,3 +627,9 @@ LockedDesktopSettings::SetMouseMode(const mode_mouse mode)
}
void
LockedDesktopSettings::SetShowAllDraggers(bool show)
{
fSettings->SetShowAllDraggers(show);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2001-2005, Haiku.
* Copyright 2001-2007, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -26,6 +26,7 @@ enum {
kFontSettings = 0x02,
kAppearanceSettings = 0x04,
kMouseSettings = 0x08,
kDraggerSettings = 0x10,
};
class DesktopSettings {
@ -44,16 +45,16 @@ class DesktopSettings {
mode_mouse MouseMode() const;
bool FocusFollowsMouse() const;
bool ShowAllDraggers() const;
int32 WorkspacesCount() const;
const BMessage* WorkspacesMessage(int32 index) const;
private:
// friend class Desktop;
protected:
DesktopSettingsPrivate* fSettings;
};
class LockedDesktopSettings {
class LockedDesktopSettings : public DesktopSettings {
public:
LockedDesktopSettings(Desktop* desktop);
~LockedDesktopSettings();
@ -67,10 +68,9 @@ class LockedDesktopSettings {
void SetMouseMode(mode_mouse mode);
private:
// friend class Desktop;
void SetShowAllDraggers(bool show);
DesktopSettingsPrivate* fSettings;
private:
Desktop* fDesktop;
};

View File

@ -1,5 +1,5 @@
/*
* Copyright 2005-2006, Haiku.
* Copyright 2005-2007, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -43,6 +43,9 @@ class DesktopSettingsPrivate {
mode_mouse MouseMode() const;
bool FocusFollowsMouse() const;
void SetShowAllDraggers(bool show);
bool ShowAllDraggers() const;
void SetWorkspacesCount(int32 number);
int32 WorkspacesCount() const;
@ -61,6 +64,7 @@ class DesktopSettingsPrivate {
scroll_bar_info fScrollBarInfo;
menu_info fMenuInfo;
mode_mouse fMouseMode;
bool fShowAllDraggers;
int32 fWorkspacesCount;
BMessage fWorkspaceMessages[kMaxWorkspaces];

View File

@ -77,6 +77,7 @@
using std::nothrow;
static const uint32 kMsgUpdateShowAllDraggers = '_adg';
static const uint32 kMsgAppQuit = 'appQ';
@ -1022,7 +1023,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
case AS_GET_MOUSE_MODE:
{
STRACE(("ServerApp %s: Get Focus Follows Mouse mode\n", Signature()));
if (fDesktop->LockSingleWindow()) {
DesktopSettings settings(fDesktop);
@ -1037,6 +1038,58 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
break;
}
case AS_GET_SHOW_ALL_DRAGGERS:
{
STRACE(("ServerApp %s: Get Show All Draggers\n", Signature()));
if (fDesktop->LockSingleWindow()) {
DesktopSettings settings(fDesktop);
fLink.StartMessage(B_OK);
fLink.Attach<bool>(settings.ShowAllDraggers());
fDesktop->UnlockSingleWindow();
} else
fLink.StartMessage(B_ERROR);
fLink.Flush();
break;
}
case AS_SET_SHOW_ALL_DRAGGERS:
{
STRACE(("ServerApp %s: Set Show All Draggers\n", Signature()));
bool changed = false;
bool show;
if (link.Read<bool>(&show) == B_OK) {
LockedDesktopSettings settings(fDesktop);
if (show != settings.ShowAllDraggers()) {
settings.SetShowAllDraggers(show);
changed = true;
}
}
if (changed)
fDesktop->BroadcastToAllApps(kMsgUpdateShowAllDraggers);
break;
}
case kMsgUpdateShowAllDraggers:
{
bool show = false;
if (fDesktop->LockSingleWindow()) {
DesktopSettings settings(fDesktop);
show = settings.ShowAllDraggers();
fDesktop->UnlockSingleWindow();
}
BMessage update(_SHOW_DRAG_HANDLES_);
update.AddBool("show", show);
SendMessageToClient(&update);
break;
}
/* font messages */
case AS_SET_SYSTEM_FONT: