2004-01-17 21:37:57 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2005-05-26 03:59:23 +04:00
|
|
|
// Copyright (c) 2001-2005, Haiku, Inc.
|
2004-01-17 21:37:57 +03:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
//
|
|
|
|
// File Name: RootLayer.cpp
|
|
|
|
// Author: Gabe Yoder <gyoder@stny.rr.com>
|
|
|
|
// DarkWyrm <bpmagic@columbus.rr.com>
|
2005-02-28 23:23:51 +03:00
|
|
|
// Adi Oanca <adioanca@cotty.iren.ro>
|
2005-05-26 03:59:23 +04:00
|
|
|
// Stephan Aßmus <superstippi@gmx.de>
|
2004-01-17 21:37:57 +03:00
|
|
|
// Description: Class used for the top layer of each workspace's Layer tree
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
2004-01-12 01:12:55 +03:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <Window.h>
|
|
|
|
#include <List.h>
|
2004-06-26 06:15:48 +04:00
|
|
|
#include <Message.h>
|
2005-01-17 00:35:02 +03:00
|
|
|
#include <Entry.h>
|
2004-06-26 06:15:48 +04:00
|
|
|
#include <File.h>
|
2005-01-17 00:35:02 +03:00
|
|
|
#include <PortLink.h>
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2005-06-11 17:00:17 +04:00
|
|
|
#include "Decorator.h"
|
|
|
|
#include "DisplayDriver.h"
|
2004-01-12 01:12:55 +03:00
|
|
|
#include "Globals.h"
|
2005-06-24 03:46:17 +04:00
|
|
|
#include "HWInterface.h"
|
2004-01-12 01:12:55 +03:00
|
|
|
#include "Layer.h"
|
2004-01-13 03:56:36 +03:00
|
|
|
#include "ServerApp.h"
|
2004-06-26 06:15:48 +04:00
|
|
|
#include "ServerConfig.h"
|
2005-01-17 00:35:02 +03:00
|
|
|
#include "ServerProtocol.h"
|
2005-06-11 17:00:17 +04:00
|
|
|
#include "ServerScreen.h"
|
|
|
|
#include "ServerWindow.h"
|
|
|
|
#include "WinBorder.h"
|
|
|
|
#include "Workspace.h"
|
2005-07-01 10:53:07 +04:00
|
|
|
#include "WorkspacesLayer.h"
|
2005-06-11 17:00:17 +04:00
|
|
|
|
|
|
|
#include "RootLayer.h"
|
|
|
|
|
|
|
|
#if DISPLAY_HAIKU_LOGO
|
|
|
|
#include "ServerBitmap.h"
|
|
|
|
#include "HaikuLogo.h"
|
|
|
|
static const float kGoldenProportion = (sqrtf(5.0) - 1.0) / 2.0;
|
|
|
|
#endif
|
2004-01-13 03:56:36 +03:00
|
|
|
|
2005-01-24 20:18:19 +03:00
|
|
|
//#define DEBUG_ROOTLAYER
|
2005-04-28 22:28:23 +04:00
|
|
|
#define APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER
|
2004-01-17 21:37:57 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG_ROOTLAYER
|
2005-01-23 21:22:48 +03:00
|
|
|
#define STRACE(a) printf a
|
2004-01-17 21:37:57 +03:00
|
|
|
#else
|
|
|
|
#define STRACE(a) /* nothing */
|
|
|
|
#endif
|
|
|
|
|
2005-05-26 03:59:23 +04:00
|
|
|
static RGBColor kDefaultWorkspaceColor = RGBColor(51, 102, 152);
|
2005-06-03 23:50:30 +04:00
|
|
|
static int32 kMaxWorkspaceCount = 32;
|
2005-05-26 03:59:23 +04:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
RootLayer::RootLayer(const char *name, int32 workspaceCount,
|
|
|
|
Desktop *desktop, DisplayDriver *driver)
|
|
|
|
: Layer(BRect(0, 0, 0, 0), name, 0, B_FOLLOW_ALL, B_WILL_DRAW, driver),
|
2005-01-17 00:35:02 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
fDesktop(desktop),
|
|
|
|
fDragMessage(NULL),
|
2005-09-08 20:53:42 +04:00
|
|
|
fLastLayerUnderMouse(this),
|
2005-09-05 22:55:32 +04:00
|
|
|
fNotifyLayer(NULL),
|
|
|
|
fSavedEventMask(0),
|
|
|
|
fSavedEventOptions(0),
|
2005-06-03 23:50:30 +04:00
|
|
|
fAllRegionsLock("root layer region lock"),
|
|
|
|
|
|
|
|
fThreadID(B_ERROR),
|
|
|
|
fListenPort(-1),
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
fButtons(0),
|
|
|
|
fLastMousePosition(0.0, 0.0),
|
|
|
|
|
|
|
|
fActiveWksIndex(0),
|
|
|
|
fWsCount(0),
|
|
|
|
fWorkspace(new Workspace*[kMaxWorkspaceCount]),
|
2005-07-01 10:53:07 +04:00
|
|
|
fWorkspacesLayer(NULL),
|
2005-09-23 01:43:23 +04:00
|
|
|
fWMState(),
|
2005-06-03 23:50:30 +04:00
|
|
|
fWinBorderIndex(0),
|
|
|
|
|
|
|
|
fScreenShotIndex(1),
|
|
|
|
fQuiting(false)
|
|
|
|
{
|
2004-06-11 18:47:36 +04:00
|
|
|
//NOTE: be careful about this one.
|
|
|
|
fRootLayer = this;
|
2005-01-19 01:23:34 +03:00
|
|
|
|
2005-06-11 17:00:17 +04:00
|
|
|
// Some stuff that will go away in the future but fills some gaps right now
|
|
|
|
#if ON_SCREEN_DEBUGGING_INFO
|
|
|
|
fDebugInfo.SetTo("");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if DISPLAY_HAIKU_LOGO
|
|
|
|
fLogoBitmap = new UtilityBitmap(BRect(0.0, 0.0, kLogoWidth - 1.0,
|
|
|
|
kLogoHeight - 1.0),
|
|
|
|
kLogoFormat, 0);
|
|
|
|
if (fLogoBitmap->IsValid()) {
|
|
|
|
int32 size = min_c(sizeof(kLogoBits), fLogoBitmap->BitsLength());
|
|
|
|
memcpy(fLogoBitmap->Bits(), kLogoBits, size);
|
|
|
|
} else {
|
|
|
|
delete fLogoBitmap;
|
|
|
|
fLogoBitmap = NULL;
|
|
|
|
}
|
|
|
|
#endif // DISPLAY_HAIKU_LOGO
|
|
|
|
|
2005-04-10 15:30:51 +04:00
|
|
|
fHidden = false;
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
memset(fWorkspace, 0, sizeof(Workspace*) * kMaxWorkspaceCount);
|
2005-04-10 15:30:51 +04:00
|
|
|
SetWorkspaceCount(workspaceCount);
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// TODO: this should eventually be replaced by a method to convert the monitor
|
|
|
|
// number to an index in the name, i.e. workspace_settings_1 for screen #1
|
2005-04-12 02:46:48 +04:00
|
|
|
// ReadWorkspaceData(WORKSPACE_DATA_LIST);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-05-26 13:21:51 +04:00
|
|
|
// TODO: read these 4 from a configuration file.
|
2005-06-03 23:50:30 +04:00
|
|
|
// fScreenWidth = 0;
|
|
|
|
// fScreenHeight = 0;
|
|
|
|
// fColorSpace = B_RGB32;
|
|
|
|
// fFrequency = 60.f;
|
2004-07-05 19:23:29 +04:00
|
|
|
|
2005-04-12 02:46:48 +04:00
|
|
|
// init the first, default workspace
|
2005-05-26 03:59:23 +04:00
|
|
|
fWorkspace[fActiveWksIndex] = new Workspace(fActiveWksIndex, 0xFF00FF00,
|
|
|
|
kDefaultWorkspaceColor);
|
|
|
|
fLayerData->SetHighColor(RGBColor(255, 255, 255));
|
|
|
|
fLayerData->SetLowColor(fWorkspace[fActiveWksIndex]->BGColor());
|
2005-01-17 00:35:02 +03:00
|
|
|
|
|
|
|
// Spawn our working thread
|
2005-03-28 15:13:19 +04:00
|
|
|
fThreadID = spawn_thread(WorkingThread, name, B_DISPLAY_PRIORITY, this);
|
2005-05-26 13:21:51 +04:00
|
|
|
|
2005-03-30 02:44:13 +04:00
|
|
|
fListenPort = find_port(SERVER_INPUT_PORT);
|
|
|
|
if (fListenPort == B_NAME_NOT_FOUND) {
|
|
|
|
fListenPort = -1;
|
|
|
|
}
|
2005-05-26 03:59:23 +04:00
|
|
|
#if ON_SCREEN_DEBUGGING_INFO
|
|
|
|
DebugInfoManager::Default()->SetRootLayer(this);
|
|
|
|
#endif
|
2005-07-15 16:45:23 +04:00
|
|
|
|
|
|
|
fFrame = desktop->VirtualScreen().Frame();
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-05-26 13:21:51 +04:00
|
|
|
|
2004-01-17 21:37:57 +03:00
|
|
|
RootLayer::~RootLayer()
|
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
fQuiting = true;
|
|
|
|
|
2005-10-29 14:35:09 +04:00
|
|
|
BMessage quitMsg(B_QUIT_REQUESTED);
|
|
|
|
ssize_t length = quitMsg.FlattenedSize();
|
|
|
|
char buffer[length];
|
|
|
|
if (quitMsg.Flatten(buffer,length) < B_OK) {
|
|
|
|
// failed to flatten?
|
|
|
|
kill_thread(fThreadID);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
write_port(fListenPort, 0, buffer, length);
|
2005-10-25 22:42:10 +04:00
|
|
|
|
2005-10-29 14:35:09 +04:00
|
|
|
status_t dummy;
|
|
|
|
wait_for_thread(fThreadID, &dummy);
|
|
|
|
}
|
2005-01-17 00:35:02 +03:00
|
|
|
|
|
|
|
|
2005-05-26 03:59:23 +04:00
|
|
|
delete fDragMessage;
|
2005-01-17 00:35:02 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
for (int32 i = 0; i < fWsCount; i++)
|
2005-05-26 03:59:23 +04:00
|
|
|
delete fWorkspace[i];
|
2005-06-03 23:50:30 +04:00
|
|
|
delete[] fWorkspace;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
// RootLayer object just uses Screen objects, it is not allowed to delete them.
|
2005-06-11 17:00:17 +04:00
|
|
|
|
|
|
|
#if DISPLAY_HAIKU_LOGO
|
|
|
|
delete fLogoBitmap;
|
|
|
|
#endif
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-05-26 13:21:51 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
RootLayer::RunThread()
|
2005-01-22 00:13:00 +03:00
|
|
|
{
|
|
|
|
if (fThreadID > 0)
|
|
|
|
resume_thread(fThreadID);
|
|
|
|
else
|
2005-05-26 03:59:23 +04:00
|
|
|
CRITICAL("Can not create any more threads.\n");
|
2005-01-22 00:13:00 +03:00
|
|
|
}
|
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
/*!
|
|
|
|
\brief Thread function for handling input messages and calculating visible regions.
|
|
|
|
\param data Pointer to the app_server to which the thread belongs
|
|
|
|
\return Throwaway value - always 0
|
|
|
|
*/
|
2005-06-08 04:36:26 +04:00
|
|
|
int32
|
|
|
|
RootLayer::WorkingThread(void *data)
|
2005-01-17 00:35:02 +03:00
|
|
|
{
|
2005-06-08 04:36:26 +04:00
|
|
|
RootLayer *oneRootLayer = (RootLayer*)data;
|
2005-01-22 00:13:00 +03:00
|
|
|
|
|
|
|
// first make sure we are actualy visible
|
|
|
|
oneRootLayer->Lock();
|
2005-06-16 22:58:14 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-01-22 00:13:00 +03:00
|
|
|
oneRootLayer->RebuildFullRegion();
|
2005-10-24 20:02:23 +04:00
|
|
|
oneRootLayer->GoInvalidate(oneRootLayer, oneRootLayer->Bounds());
|
2005-06-22 00:11:44 +04:00
|
|
|
#else
|
|
|
|
oneRootLayer->rebuild_visible_regions(
|
|
|
|
BRegion(oneRootLayer->Bounds()),
|
|
|
|
BRegion(oneRootLayer->Bounds()),
|
2005-07-10 21:16:31 +04:00
|
|
|
oneRootLayer->LastChild());
|
2005-06-22 00:11:44 +04:00
|
|
|
|
|
|
|
oneRootLayer->fRedrawReg.Include(oneRootLayer->Bounds());
|
2005-07-10 21:16:31 +04:00
|
|
|
oneRootLayer->RequestDraw(oneRootLayer->fRedrawReg, oneRootLayer->LastChild());
|
2005-06-22 00:11:44 +04:00
|
|
|
#endif
|
2005-01-22 00:13:00 +03:00
|
|
|
oneRootLayer->Unlock();
|
2005-01-17 00:35:02 +03:00
|
|
|
|
2005-06-23 22:48:10 +04:00
|
|
|
STRACE(("info: RootLayer(%s)::WorkingThread listening on port %ld.\n", oneRootLayer->Name(), oneRootLayer->fListenPort));
|
2005-10-25 22:42:10 +04:00
|
|
|
while(!oneRootLayer->fQuiting) {
|
|
|
|
|
|
|
|
BMessage *msg = oneRootLayer->ReadMessageFromPort(B_INFINITE_TIMEOUT);
|
|
|
|
|
|
|
|
if (msg)
|
|
|
|
oneRootLayer->fQueue.AddMessage(msg);
|
|
|
|
|
|
|
|
int32 msgCount = port_count(oneRootLayer->fListenPort);
|
|
|
|
for (int32 i = 0; i < msgCount; ++i) {
|
|
|
|
msg = oneRootLayer->ReadMessageFromPort(0);
|
|
|
|
if (msg)
|
|
|
|
oneRootLayer->fQueue.AddMessage(msg);
|
2005-01-17 00:35:02 +03:00
|
|
|
}
|
2005-05-06 11:47:17 +04:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
// loop as long as there are messages in the queue and the port is empty.
|
|
|
|
bool dispatchNextMessage = true;
|
|
|
|
while(dispatchNextMessage && !oneRootLayer->fQuiting) {
|
|
|
|
BMessage *currentMessage = oneRootLayer->fQueue.NextMessage();
|
|
|
|
|
|
|
|
if (!currentMessage)
|
|
|
|
// no more messages
|
|
|
|
dispatchNextMessage = false;
|
|
|
|
else {
|
2005-01-17 00:35:02 +03:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
oneRootLayer->Lock();
|
|
|
|
|
|
|
|
switch (currentMessage->what) {
|
|
|
|
// We don't need to do anything with these two, so just pass them
|
|
|
|
// onto the active application. Eventually, we will end up passing
|
|
|
|
// them onto the window which is currently under the cursor.
|
|
|
|
case B_MOUSE_DOWN:
|
|
|
|
case B_MOUSE_UP:
|
|
|
|
case B_MOUSE_MOVED:
|
|
|
|
case B_MOUSE_WHEEL_CHANGED:
|
|
|
|
oneRootLayer->MouseEventHandler(currentMessage);
|
|
|
|
break;
|
2005-01-17 00:35:02 +03:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
case B_KEY_DOWN:
|
|
|
|
case B_KEY_UP:
|
|
|
|
case B_UNMAPPED_KEY_DOWN:
|
|
|
|
case B_UNMAPPED_KEY_UP:
|
|
|
|
case B_MODIFIERS_CHANGED:
|
|
|
|
oneRootLayer->KeyboardEventHandler(currentMessage);
|
|
|
|
break;
|
2005-01-17 00:35:02 +03:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
case B_QUIT_REQUESTED:
|
|
|
|
exit_thread(0);
|
|
|
|
break;
|
2005-01-17 00:35:02 +03:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
default:
|
|
|
|
printf("RootLayer(%s)::WorkingThread received unexpected code %lx\n", oneRootLayer->Name(), msg->what);
|
|
|
|
break;
|
|
|
|
}
|
2005-01-22 00:13:00 +03:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
oneRootLayer->Unlock();
|
|
|
|
|
|
|
|
delete currentMessage;
|
|
|
|
|
|
|
|
// Are any messages on the port?
|
|
|
|
if (port_count(oneRootLayer->fListenPort) > 0)
|
|
|
|
dispatchNextMessage = false;
|
|
|
|
}
|
|
|
|
}
|
2005-01-17 00:35:02 +03:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-08 04:36:26 +04:00
|
|
|
|
|
|
|
void
|
2005-10-24 20:02:23 +04:00
|
|
|
RootLayer::GoInvalidate(Layer *layer, const BRegion ®ion)
|
2005-01-22 23:51:12 +03:00
|
|
|
{
|
2005-10-24 20:02:23 +04:00
|
|
|
BRegion invalidRegion(region);
|
2005-01-22 23:51:12 +03:00
|
|
|
|
2005-10-24 20:02:23 +04:00
|
|
|
Lock();
|
2005-06-22 00:11:44 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-01-22 23:51:12 +03:00
|
|
|
if (layer->fParent)
|
|
|
|
layer = layer->fParent;
|
|
|
|
|
2005-10-24 20:02:23 +04:00
|
|
|
layer->FullInvalidate(invalidRegion);
|
|
|
|
#else
|
|
|
|
layer->do_Invalidate(invalidRegion);
|
2005-06-22 00:11:44 +04:00
|
|
|
#endif
|
2005-10-24 20:02:23 +04:00
|
|
|
Unlock();
|
|
|
|
}
|
2005-06-15 01:28:56 +04:00
|
|
|
|
|
|
|
void
|
2005-10-24 20:02:23 +04:00
|
|
|
RootLayer::GoRedraw(Layer *layer, const BRegion ®ion)
|
2005-01-22 23:51:12 +03:00
|
|
|
{
|
2005-10-24 20:02:23 +04:00
|
|
|
BRegion redrawRegion(region);
|
|
|
|
|
|
|
|
Lock();
|
2005-06-22 00:11:44 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-10-24 20:02:23 +04:00
|
|
|
layer->Invalidate(redrawRegion);
|
|
|
|
#else
|
|
|
|
layer->do_Redraw(redrawRegion);
|
2005-06-22 00:11:44 +04:00
|
|
|
#endif
|
2005-10-24 20:02:23 +04:00
|
|
|
Unlock();
|
|
|
|
}
|
2005-06-15 01:28:56 +04:00
|
|
|
|
|
|
|
void
|
2005-10-24 20:02:23 +04:00
|
|
|
RootLayer::GoChangeWinBorderFeel(WinBorder *winBorder, int32 newFeel)
|
2005-04-21 22:57:34 +04:00
|
|
|
{
|
2005-10-24 20:02:23 +04:00
|
|
|
Lock();
|
|
|
|
change_winBorder_feel(winBorder, newFeel);
|
|
|
|
Unlock();
|
2005-04-21 22:57:34 +04:00
|
|
|
}
|
2005-01-22 23:51:12 +03:00
|
|
|
|
2005-06-15 01:28:56 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
RootLayer::MoveBy(float x, float y)
|
2004-01-17 21:37:57 +03:00
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-06-15 01:28:56 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
RootLayer::ResizeBy(float x, float y)
|
2004-01-17 21:37:57 +03:00
|
|
|
{
|
2004-03-28 19:01:08 +04:00
|
|
|
// TODO: implement
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-06-15 01:28:56 +04:00
|
|
|
|
2005-07-10 21:16:31 +04:00
|
|
|
Layer*
|
|
|
|
RootLayer::FirstChild() const
|
2004-01-17 21:37:57 +03:00
|
|
|
{
|
2005-09-23 01:43:23 +04:00
|
|
|
fWinBorderIndex = fWMState.WindowList.CountItems()-1;
|
|
|
|
return static_cast<Layer*>(fWMState.WindowList.ItemAt(fWinBorderIndex--));
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-07-10 21:16:31 +04:00
|
|
|
Layer*
|
|
|
|
RootLayer::NextChild() const
|
2004-01-17 21:37:57 +03:00
|
|
|
{
|
2005-09-23 01:43:23 +04:00
|
|
|
return static_cast<Layer*>(fWMState.WindowList.ItemAt(fWinBorderIndex--));
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-07-10 21:16:31 +04:00
|
|
|
Layer*
|
|
|
|
RootLayer::PreviousChild() const
|
2004-01-17 21:37:57 +03:00
|
|
|
{
|
2005-09-23 01:43:23 +04:00
|
|
|
return static_cast<Layer*>(fWMState.WindowList.ItemAt(fWinBorderIndex++));
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-07-10 21:16:31 +04:00
|
|
|
Layer*
|
|
|
|
RootLayer::LastChild() const
|
2004-01-17 21:37:57 +03:00
|
|
|
{
|
2005-09-23 01:43:23 +04:00
|
|
|
fWinBorderIndex = 0;
|
|
|
|
return static_cast<Layer*>(fWMState.WindowList.ItemAt(fWinBorderIndex++));
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-10 21:16:31 +04:00
|
|
|
void
|
|
|
|
RootLayer::AddWinBorder(WinBorder* winBorder)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
if (!winBorder->IsHidden())
|
|
|
|
{
|
2005-07-18 21:48:32 +04:00
|
|
|
CRITICAL("RootLayer::AddWinBorder - winBorder must be hidden\n");
|
2005-02-28 23:23:51 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-03-14 01:54:01 +03:00
|
|
|
// Subset modals also need to have a main window before appearing in workspace list.
|
2005-04-16 17:30:49 +04:00
|
|
|
int32 feel = winBorder->Feel();
|
2005-03-14 01:54:01 +03:00
|
|
|
if (feel != B_FLOATING_SUBSET_WINDOW_FEEL && feel != B_MODAL_SUBSET_WINDOW_FEEL)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
uint32 wks = winBorder->Workspaces();
|
2005-03-14 01:54:01 +03:00
|
|
|
// add to current workspace
|
|
|
|
if (wks == 0)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-03-14 01:54:01 +03:00
|
|
|
fWorkspace[fActiveWksIndex]->AddWinBorder(winBorder);
|
|
|
|
}
|
|
|
|
// add to desired workspaces
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (int32 i = 0; i < fWsCount; i++)
|
|
|
|
{
|
|
|
|
if (fWorkspace[i] && (wks & (0x00000001UL << i)))
|
|
|
|
fWorkspace[i]->AddWinBorder(winBorder);
|
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// we _DO_NOT_ need to invalidate here. At this point our WinBorder is hidden!
|
|
|
|
|
|
|
|
// set some internals
|
|
|
|
winBorder->SetRootLayer(this);
|
|
|
|
winBorder->fParent = this;
|
|
|
|
}
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
RootLayer::RemoveWinBorder(WinBorder* winBorder)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
// Note: removing a subset window is also permited/performed.
|
|
|
|
|
|
|
|
if (!winBorder->IsHidden())
|
|
|
|
{
|
2005-05-26 03:59:23 +04:00
|
|
|
CRITICAL("RootLayer::RemoveWinBorder - winBorder must be hidden\n");
|
2005-02-28 23:23:51 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// security measure: in case of windows whose workspace count is 0(current workspace),
|
|
|
|
// we don't know the exact workspaces to remove it from. And how all modal and floating
|
|
|
|
// windows have 0 as a workspace index, this action is fully justified.
|
2005-07-18 13:24:08 +04:00
|
|
|
for (int32 i = 0; i < fWsCount; i++) {
|
2005-02-28 23:23:51 +03:00
|
|
|
if (fWorkspace[i])
|
|
|
|
fWorkspace[i]->RemoveWinBorder(winBorder);
|
2005-07-18 13:24:08 +04:00
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
// we _DO_NOT_ need to invalidate here. At this point our WinBorder is hidden!
|
|
|
|
|
2005-07-18 13:24:08 +04:00
|
|
|
LayerRemoved(winBorder);
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// set some internals
|
|
|
|
winBorder->SetRootLayer(NULL);
|
|
|
|
winBorder->fParent = NULL;
|
|
|
|
}
|
|
|
|
|
2005-07-18 13:24:08 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
void
|
|
|
|
RootLayer::AddSubsetWinBorder(WinBorder *winBorder, WinBorder *toWinBorder)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
// SUBSET windows _must_ have their workspaceIndex set to 0x0
|
2005-04-16 17:30:49 +04:00
|
|
|
if (winBorder->Workspaces() != 0UL)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-05-26 03:59:23 +04:00
|
|
|
CRITICAL("SUBSET windows _must_ have their workspaceIndex set to 0x0\n");
|
2005-02-28 23:23:51 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// there is no point in continuing - this subset window won't be shown,
|
|
|
|
// from 'toWinBorder's point of view
|
|
|
|
if (winBorder->IsHidden() || toWinBorder->IsHidden())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
bool invalidate = false;
|
|
|
|
bool invalid;
|
2005-09-23 01:43:23 +04:00
|
|
|
Workspace::State oldWMState;
|
|
|
|
ActiveWorkspace()->GetState(&oldWMState);
|
2005-10-11 22:11:25 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// we try to add WinBorders to all workspaces. If they are not needed, nothing will be done.
|
|
|
|
// If they are needed, Workspace automaticaly allocates space and inserts them.
|
2005-07-07 00:19:22 +04:00
|
|
|
for (int32 i = 0; i < fWsCount; i++) {
|
|
|
|
invalid = false;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
if (fWorkspace[i] && fWorkspace[i]->HasWinBorder(toWinBorder))
|
|
|
|
invalid = fWorkspace[i]->ShowWinBorder(winBorder, false);
|
|
|
|
|
|
|
|
if (fActiveWksIndex == i)
|
|
|
|
invalidate = invalid;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (invalidate)
|
2005-09-23 01:43:23 +04:00
|
|
|
RevealNewWMState(oldWMState);
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
RootLayer::RemoveSubsetWinBorder(WinBorder *winBorder, WinBorder *fromWinBorder)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
// there is no point in continuing - this subset window is not visible
|
|
|
|
// at least not visible from 'fromWinBorder's point of view.
|
|
|
|
if (winBorder->IsHidden() || fromWinBorder->IsHidden())
|
|
|
|
return;
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
bool invalidate = false;
|
|
|
|
bool invalid;
|
2005-09-23 01:43:23 +04:00
|
|
|
Workspace::State oldWMState;
|
|
|
|
ActiveWorkspace()->GetState(&oldWMState);
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
// we try to remove from all workspaces. If winBorder is not in there, nothing will be done.
|
2005-07-07 00:19:22 +04:00
|
|
|
for (int32 i = 0; i < fWsCount; i++) {
|
|
|
|
invalid = false;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
if (fWorkspace[i] && fWorkspace[i]->HasWinBorder(fromWinBorder))
|
|
|
|
invalid = fWorkspace[i]->HideWinBorder(winBorder);
|
|
|
|
|
|
|
|
if (fActiveWksIndex == i)
|
|
|
|
invalidate = invalid;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (invalidate)
|
2005-09-23 01:43:23 +04:00
|
|
|
RevealNewWMState(oldWMState);
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: This must be called by RootLayer's thread!!!!
|
2005-04-12 02:46:48 +04:00
|
|
|
bool RootLayer::SetActiveWorkspace(int32 index)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-06-23 22:48:10 +04:00
|
|
|
STRACE(("RootLayer(%s)::SetActiveWorkspace(%ld)\n", Name(), index));
|
2005-04-12 02:46:48 +04:00
|
|
|
|
|
|
|
// nice try!
|
|
|
|
if (index >= fWsCount || index == fActiveWksIndex || index < 0)
|
|
|
|
return false;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-09-29 01:12:38 +04:00
|
|
|
// you cannot switch workspaces on R5 if there is an event mask BView
|
|
|
|
if (fNotifyLayer && fNotifyLayer->Owner())
|
2005-06-03 23:50:30 +04:00
|
|
|
return false;
|
|
|
|
|
2005-09-29 01:12:38 +04:00
|
|
|
// if you're dragging something you are allowed to change workspaces only if
|
|
|
|
// the Layer being dragged is a B_NORMAL_WINDOW_FEEL WinBorder.
|
|
|
|
WinBorder *draggedWinBorder = dynamic_cast<WinBorder*>(fNotifyLayer);
|
|
|
|
if (fNotifyLayer) {
|
|
|
|
if (draggedWinBorder) {
|
|
|
|
if (draggedWinBorder->Feel() != B_NORMAL_WINDOW_FEEL)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// if fWorkspace[index] object does not exist, create and add allowed WinBorders
|
2005-06-03 23:50:30 +04:00
|
|
|
if (!fWorkspace[index]) {
|
2005-02-28 23:23:51 +03:00
|
|
|
// TODO: we NEED datas from a file!!!
|
2005-05-26 03:59:23 +04:00
|
|
|
fWorkspace[index] = new Workspace(index, 0xFF00FF00, kDefaultWorkspaceColor);
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-04-12 02:46:48 +04:00
|
|
|
// we need to lock the window list here so no other window can be created
|
2005-05-28 17:43:13 +04:00
|
|
|
fDesktop->Lock();
|
2005-04-12 02:46:48 +04:00
|
|
|
|
2005-10-31 22:35:46 +03:00
|
|
|
const BObjectList<WinBorder>& windowList = fDesktop->WindowList();
|
|
|
|
int32 windowCount = windowList.CountItems();
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-10-31 22:35:46 +03:00
|
|
|
for (int32 i = 0; i < windowCount; i++) {
|
|
|
|
WinBorder* winBorder = windowList.ItemAt(i);
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-10-31 22:35:46 +03:00
|
|
|
// is WinBorder on this workspace?
|
|
|
|
if (winBorder->Workspaces() & (0x00000001UL << index)) {
|
|
|
|
fWorkspace[index]->AddWinBorder(winBorder);
|
2005-07-01 10:53:07 +04:00
|
|
|
|
2005-10-31 22:35:46 +03:00
|
|
|
if (!winBorder->IsHidden())
|
|
|
|
fWorkspace[index]->ShowWinBorder(winBorder);
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
fDesktop->Unlock();
|
2005-04-12 02:46:48 +04:00
|
|
|
}
|
2005-06-03 23:50:30 +04:00
|
|
|
// adjust our DrawData to workspace colors
|
2005-05-26 03:59:23 +04:00
|
|
|
rgb_color bg = fWorkspace[index]->BGColor().GetColor32();
|
|
|
|
if ((bg.red + bg.green + bg.blue) / 3 > 128)
|
|
|
|
fLayerData->SetHighColor(RGBColor(0, 0, 0));
|
|
|
|
else
|
|
|
|
fLayerData->SetHighColor(RGBColor(255, 255, 255));
|
|
|
|
fLayerData->SetLowColor(fWorkspace[index]->BGColor());
|
2005-03-29 01:32:24 +04:00
|
|
|
|
2005-09-29 01:12:38 +04:00
|
|
|
// save some datas
|
2005-06-03 23:50:30 +04:00
|
|
|
int32 exIndex = ActiveWorkspaceIndex();
|
2005-09-23 01:43:23 +04:00
|
|
|
Workspace::State oldWMState;
|
|
|
|
ActiveWorkspace()->GetState(&oldWMState);
|
2005-10-11 22:11:25 +04:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
// send the workspace changed message for the old workspace
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-09-23 01:43:23 +04:00
|
|
|
Layer *layer;
|
|
|
|
for (int32 i = 0; (layer = static_cast<Layer*>(fWMState.WindowList.ItemAt(i++))); ) {
|
2005-09-29 01:12:38 +04:00
|
|
|
layer->WorkspaceActivated(fActiveWksIndex, false);
|
2005-09-23 01:43:23 +04:00
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
fActiveWksIndex = index;
|
2005-10-11 22:11:25 +04:00
|
|
|
|
2005-09-29 01:12:38 +04:00
|
|
|
if (draggedWinBorder && !ActiveWorkspace()->HasWinBorder(draggedWinBorder)) {
|
|
|
|
// Workspace class expects a window to be hidden when it's about to be removed.
|
|
|
|
// As we surely know this windows is visible, we simply set fHidden to true and then
|
|
|
|
// change it back when adding winBorder to the current workspace.
|
|
|
|
draggedWinBorder->fHidden = true;
|
|
|
|
fWorkspace[exIndex]->HideWinBorder(draggedWinBorder);
|
|
|
|
fWorkspace[exIndex]->RemoveWinBorder(draggedWinBorder);
|
|
|
|
|
|
|
|
draggedWinBorder->fHidden = false;
|
|
|
|
ActiveWorkspace()->AddWinBorder(draggedWinBorder);
|
|
|
|
ActiveWorkspace()->ShowWinBorder(draggedWinBorder);
|
|
|
|
|
|
|
|
// TODO: can you call SetWinBorderWorskpaces() instead of this?
|
|
|
|
uint32 wks = draggedWinBorder->Workspaces();
|
|
|
|
BMessage changedMsg(B_WORKSPACES_CHANGED);
|
|
|
|
changedMsg.AddInt64("when", real_time_clock_usecs());
|
|
|
|
changedMsg.AddInt32("old", wks);
|
|
|
|
wks &= ~(0x00000001 << exIndex);
|
|
|
|
wks |= (0x00000001 << fActiveWksIndex);
|
|
|
|
changedMsg.AddInt32("new", wks);
|
|
|
|
draggedWinBorder->QuietlySetWorkspaces(wks);
|
|
|
|
draggedWinBorder->Window()->SendMessageToClient(&changedMsg, B_NULL_TOKEN, false);
|
|
|
|
}
|
2005-07-01 10:53:07 +04:00
|
|
|
|
2005-09-23 01:43:23 +04:00
|
|
|
RevealNewWMState(oldWMState);
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
// send the workspace changed message for the new workspace
|
2005-04-14 01:32:23 +04:00
|
|
|
{
|
2005-09-23 01:43:23 +04:00
|
|
|
Layer *layer;
|
|
|
|
for (int32 i = 0; (layer = static_cast<Layer*>(fWMState.WindowList.ItemAt(i++))); ) {
|
2005-09-29 01:12:38 +04:00
|
|
|
layer->WorkspaceActivated(fActiveWksIndex, true);
|
2005-09-23 01:43:23 +04:00
|
|
|
}
|
2005-04-14 01:32:23 +04:00
|
|
|
}
|
|
|
|
|
2005-04-12 02:46:48 +04:00
|
|
|
// workspace changed
|
|
|
|
return true;
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
|
|
|
void
|
2005-10-01 14:03:43 +04:00
|
|
|
RootLayer::SetWinBorderWorskpaces(WinBorder *winBorder, uint32 oldIndex, uint32 newIndex)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-10-01 14:03:43 +04:00
|
|
|
// if the active notify Layer is somehow related to winBorder, then
|
|
|
|
// this window/WinBorder is not allowed to leave this workspace.
|
|
|
|
if (fNotifyLayer && (fNotifyLayer == winBorder || fNotifyLayer->Owner() == winBorder)) {
|
|
|
|
newIndex |= (0x00000001UL << fActiveWksIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 localOldIndex = oldIndex;
|
|
|
|
uint32 localNewIndex = newIndex;
|
|
|
|
bool invalidate = false;
|
|
|
|
bool invalid;
|
|
|
|
|
|
|
|
// if we're in the current workspace only, reflect that in the workspace index
|
|
|
|
if (localOldIndex == 0UL)
|
|
|
|
localOldIndex |= (0x00000001UL << fActiveWksIndex);
|
|
|
|
if (localNewIndex == 0UL)
|
|
|
|
localNewIndex |= (0x00000001UL << fActiveWksIndex);
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// you *cannot* set workspaces index for a window other than a normal one!
|
|
|
|
// Note: See ServerWindow class.
|
2005-10-01 14:03:43 +04:00
|
|
|
if (winBorder->Feel() != B_NORMAL_WINDOW_FEEL || localOldIndex == localNewIndex)
|
2005-02-28 23:23:51 +03:00
|
|
|
return;
|
|
|
|
|
2005-09-23 01:43:23 +04:00
|
|
|
Workspace::State oldWMState;
|
|
|
|
ActiveWorkspace()->GetState(&oldWMState);
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
for (int32 i = 0; i < 32; i++) {
|
|
|
|
if (fWorkspace[i]) {
|
2005-02-28 23:23:51 +03:00
|
|
|
invalid = false;
|
|
|
|
|
2005-10-01 14:03:43 +04:00
|
|
|
if (!(localNewIndex & (0x00000001UL << i)) && fWorkspace[i]->HasWinBorder(winBorder)) {
|
2005-07-07 00:19:22 +04:00
|
|
|
if (!winBorder->IsHidden()) {
|
2005-02-28 23:23:51 +03:00
|
|
|
// a little trick to force Workspace to properly pick the next front.
|
2005-04-10 23:04:06 +04:00
|
|
|
winBorder->fHidden = true;
|
2005-02-28 23:23:51 +03:00
|
|
|
invalid = fWorkspace[i]->HideWinBorder(winBorder);
|
2005-04-10 23:04:06 +04:00
|
|
|
winBorder->fHidden = false;
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
fWorkspace[i]->RemoveWinBorder(winBorder);
|
2005-10-01 14:03:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((localNewIndex & (0x00000001UL << i)) && !fWorkspace[i]->HasWinBorder(winBorder)) {
|
2005-02-28 23:23:51 +03:00
|
|
|
fWorkspace[i]->AddWinBorder(winBorder);
|
|
|
|
if (!winBorder->IsHidden())
|
|
|
|
invalid = fWorkspace[i]->ShowWinBorder(winBorder);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fActiveWksIndex == i)
|
|
|
|
invalidate = invalid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-01 14:03:43 +04:00
|
|
|
winBorder->WorkspacesChanged(oldIndex, newIndex);
|
2005-10-11 22:11:25 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
if (invalidate)
|
2005-09-23 01:43:23 +04:00
|
|
|
RevealNewWMState(oldWMState);
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
RootLayer::SetWorkspaceCount(int32 wksCount)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
if (wksCount < 1)
|
|
|
|
wksCount = 1;
|
2005-06-03 23:50:30 +04:00
|
|
|
if (wksCount > kMaxWorkspaceCount)
|
|
|
|
wksCount = kMaxWorkspaceCount;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
for (int32 i = wksCount; i < fWsCount; i++) {
|
|
|
|
delete fWorkspace[i];
|
|
|
|
fWorkspace[i] = NULL;
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
fWsCount = wksCount;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
RootLayer::ReadWorkspaceData(const char *path)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
|
|
|
BMessage msg, settings;
|
|
|
|
BFile file(path,B_READ_ONLY);
|
|
|
|
char string[20];
|
2005-07-07 00:19:22 +04:00
|
|
|
|
|
|
|
if (file.InitCheck() == B_OK && msg.Unflatten(&file) == B_OK) {
|
2004-06-26 06:15:48 +04:00
|
|
|
int32 count;
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (msg.FindInt32("workspace_count", &count)!=B_OK)
|
|
|
|
count = 9;
|
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
SetWorkspaceCount(count);
|
2005-07-07 00:19:22 +04:00
|
|
|
|
|
|
|
for (int32 i = 0; i < count; i++) {
|
2005-02-28 23:23:51 +03:00
|
|
|
Workspace *ws=(Workspace*)fWorkspace[i];
|
2005-07-07 00:19:22 +04:00
|
|
|
if (!ws)
|
2004-06-26 06:15:48 +04:00
|
|
|
continue;
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
sprintf(string,"workspace %ld",i);
|
2005-07-07 00:19:22 +04:00
|
|
|
|
|
|
|
if (msg.FindMessage(string,&settings) == B_OK) {
|
2004-06-26 06:15:48 +04:00
|
|
|
ws->GetSettings(settings);
|
|
|
|
settings.MakeEmpty();
|
2005-07-07 00:19:22 +04:00
|
|
|
} else
|
2004-06-26 06:15:48 +04:00
|
|
|
ws->GetDefaultSettings();
|
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
} else {
|
2004-06-26 06:15:48 +04:00
|
|
|
SetWorkspaceCount(9);
|
2005-07-07 00:19:22 +04:00
|
|
|
|
|
|
|
for (int32 i = 0; i < 9; i++) {
|
2005-02-28 23:23:51 +03:00
|
|
|
Workspace *ws=(Workspace*)fWorkspace[i];
|
2005-07-07 00:19:22 +04:00
|
|
|
if (!ws)
|
2004-06-26 06:15:48 +04:00
|
|
|
continue;
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
ws->GetDefaultSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
RootLayer::SaveWorkspaceData(const char *path)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
|
|
|
BMessage msg,dummy;
|
|
|
|
BFile file(path,B_READ_WRITE | B_CREATE_FILE);
|
|
|
|
|
|
|
|
if(file.InitCheck()!=B_OK)
|
|
|
|
{
|
|
|
|
printf("ERROR: Couldn't save workspace data in RootLayer\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
char string[20];
|
2005-02-28 23:23:51 +03:00
|
|
|
int32 count=fWsCount;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
if(msg.Unflatten(&file)==B_OK)
|
|
|
|
{
|
|
|
|
// if we were successful in unflattening the file, it means we're
|
|
|
|
// going to need to save over the existing data
|
|
|
|
for(int32 i=0; i<count; i++)
|
|
|
|
{
|
|
|
|
sprintf(string,"workspace %ld",i);
|
|
|
|
if(msg.FindMessage(string,&dummy)==B_OK)
|
|
|
|
msg.RemoveName(string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int32 i=0; i<count; i++)
|
|
|
|
{
|
|
|
|
sprintf(string,"workspace %ld",i);
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
Workspace *ws=(Workspace*)fWorkspace[i];
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
if(!ws)
|
|
|
|
{
|
|
|
|
dummy.MakeEmpty();
|
|
|
|
ws->PutSettings(&dummy,i);
|
|
|
|
msg.AddMessage(string,&dummy);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We're not supposed to have this happen, but we'll suck it up, anyway. :P
|
|
|
|
Workspace::PutDefaultSettings(&msg,i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-06-15 01:28:56 +04:00
|
|
|
void
|
|
|
|
RootLayer::HideWinBorder(WinBorder* winBorder)
|
2005-01-22 00:13:00 +03:00
|
|
|
{
|
2005-10-24 20:02:23 +04:00
|
|
|
Lock();
|
|
|
|
hide_winBorder(winBorder);
|
|
|
|
Unlock();
|
2005-01-22 00:13:00 +03:00
|
|
|
}
|
|
|
|
|
2005-06-15 01:28:56 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
RootLayer::ShowWinBorder(WinBorder* winBorder)
|
2005-01-22 00:13:00 +03:00
|
|
|
{
|
2005-10-24 20:02:23 +04:00
|
|
|
Lock();
|
|
|
|
show_winBorder(winBorder);
|
|
|
|
Unlock();
|
2005-01-22 00:13:00 +03:00
|
|
|
}
|
|
|
|
|
2005-06-15 01:28:56 +04:00
|
|
|
|
2005-09-23 01:43:23 +04:00
|
|
|
void
|
|
|
|
RootLayer::RevealNewWMState(Workspace::State &oldWMState)
|
|
|
|
{
|
|
|
|
// clean fWMState
|
|
|
|
fWMState.Focus = NULL;
|
|
|
|
fWMState.Front = NULL;
|
|
|
|
fWMState.Active = NULL;
|
|
|
|
fWMState.WindowList.MakeEmpty();
|
|
|
|
|
|
|
|
ActiveWorkspace()->GetState(&fWMState);
|
|
|
|
|
|
|
|
// BOOKMARK!
|
|
|
|
// TODO: there can be more than one window active at a time! ex: a normal + floating_app, with
|
|
|
|
// floating window having focus.
|
|
|
|
// send window activation messages
|
|
|
|
if (oldWMState.Active != fWMState.Active) {
|
2005-10-29 15:15:47 +04:00
|
|
|
if (oldWMState.Active)
|
|
|
|
oldWMState.Active->Activated(false);
|
|
|
|
if (fWMState.Active)
|
|
|
|
fWMState.Active->Activated(true);
|
2005-09-23 01:43:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// calculate the region that must be invalidated/redrawn
|
2005-05-26 13:21:51 +04:00
|
|
|
|
2005-09-23 01:43:23 +04:00
|
|
|
bool redraw = false;
|
|
|
|
// first, if the focus window changed, make sure the decorators reflect this state.
|
|
|
|
BRegion dirtyRegion;
|
|
|
|
if (oldWMState.Focus != fWMState.Focus) {
|
|
|
|
if (oldWMState.Focus) {
|
|
|
|
dirtyRegion.Include(&oldWMState.Focus->VisibleRegion());
|
|
|
|
redraw = true;
|
|
|
|
}
|
|
|
|
if (fWMState.Focus) {
|
|
|
|
dirtyRegion.Include(&fWMState.Focus->VisibleRegion());
|
|
|
|
redraw = true;
|
|
|
|
}
|
|
|
|
if (redraw) {
|
|
|
|
#ifndef NEW_CLIPPING
|
|
|
|
fRedrawReg.Include(&dirtyRegion);
|
|
|
|
#else
|
|
|
|
// TODO: code for new clipping engine!
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool invalidate = false;
|
|
|
|
// check to see if window count changed over states
|
|
|
|
if (oldWMState.WindowList.CountItems() != fWMState.WindowList.CountItems()) {
|
|
|
|
invalidate = true;
|
|
|
|
}
|
|
|
|
else if (memcmp(oldWMState.WindowList.Items(), fWMState.WindowList.Items(),
|
2005-10-29 14:19:23 +04:00
|
|
|
fWMState.WindowList.CountItems()*sizeof(void*)) != 0) {
|
2005-09-23 01:43:23 +04:00
|
|
|
invalidate = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (invalidate) {
|
2005-09-24 00:34:19 +04:00
|
|
|
// clear visible areas for windows not visible anymore.
|
|
|
|
int32 oldWindowCount = oldWMState.WindowList.CountItems();
|
|
|
|
int32 newWindowCount = fWMState.WindowList.CountItems();
|
|
|
|
bool stillPresent;
|
|
|
|
Layer *layer;
|
|
|
|
for (int32 i = 0; i < oldWindowCount; i++)
|
|
|
|
{
|
|
|
|
layer = static_cast<Layer*>(oldWMState.WindowList.ItemAtFast(i));
|
|
|
|
stillPresent = false;
|
|
|
|
for (int32 j = 0; j < newWindowCount; j++)
|
|
|
|
if (layer == fWMState.WindowList.ItemAtFast(j))
|
|
|
|
stillPresent = true;
|
|
|
|
|
|
|
|
if (!stillPresent && layer)
|
|
|
|
#ifndef NEW_CLIPPING
|
|
|
|
empty_visible_regions(layer);
|
|
|
|
#else
|
|
|
|
layer->clear_visible_regions();
|
|
|
|
#endif
|
|
|
|
}
|
2005-09-23 01:43:23 +04:00
|
|
|
// redraw of focus change is automaticaly done
|
|
|
|
redraw = false;
|
|
|
|
// trigger region rebuilding and redraw
|
|
|
|
#ifndef NEW_CLIPPING
|
2005-10-24 20:02:23 +04:00
|
|
|
GoInvalidate(this, fFull);
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
do_Invalidate(Bounds());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else if (redraw) {
|
|
|
|
#ifndef NEW_CLIPPING
|
2005-10-24 20:02:23 +04:00
|
|
|
GoInvalidate(this, dirtyRegion);
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
do_Redraw(dirtyRegion);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2005-10-03 01:55:45 +04:00
|
|
|
|
|
|
|
bool
|
2005-10-29 14:19:23 +04:00
|
|
|
RootLayer::SetActive(WinBorder* newActive, bool activate)
|
2005-10-03 01:55:45 +04:00
|
|
|
{
|
2005-10-06 14:45:46 +04:00
|
|
|
bool returnValue = false;
|
|
|
|
uint32 workspaceIndex = newActive->Workspaces();
|
|
|
|
if (workspaceIndex == 0)
|
|
|
|
workspaceIndex = 0x00000001UL << fActiveWksIndex;
|
|
|
|
|
|
|
|
for (int32 i = 0; i < kMaxWorkspaceCount; i++) {
|
|
|
|
if (fWorkspace[i] && (workspaceIndex & (0x00000001UL << i))) {
|
|
|
|
if (i == fActiveWksIndex) {
|
|
|
|
Workspace::State oldWMState;
|
|
|
|
ActiveWorkspace()->GetState(&oldWMState);
|
|
|
|
|
2005-10-29 14:19:23 +04:00
|
|
|
if (activate)
|
|
|
|
returnValue = ActiveWorkspace()->AttemptToActivate(newActive);
|
|
|
|
else
|
|
|
|
returnValue = ActiveWorkspace()->AttemptToMoveToBack(newActive);
|
2005-10-06 14:45:46 +04:00
|
|
|
|
|
|
|
RevealNewWMState(oldWMState);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fWorkspace[i]->AttemptToActivate(newActive);
|
|
|
|
// NOTE: for multiple monitor support, if a workspaces is mapped to
|
|
|
|
// a Screen, we must invalidate/redraw to see the change.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If this WinBorder does not appear in current workspace,
|
|
|
|
// change to the first one who does.
|
2005-10-29 14:19:23 +04:00
|
|
|
if (activate && !(workspaceIndex & (0x00000001UL << fActiveWksIndex))) {
|
2005-10-06 14:45:46 +04:00
|
|
|
// find an workspace index in which this Layer appears
|
|
|
|
for (int32 i = 0; i < kMaxWorkspaceCount; i++) {
|
|
|
|
if (workspaceIndex & (0x00000001UL << i)) {
|
|
|
|
SetActiveWorkspace(i);
|
|
|
|
returnValue = Active() == newActive;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return returnValue;
|
2005-10-03 01:55:45 +04:00
|
|
|
}
|
2005-10-11 22:11:25 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Workspace related methods
|
|
|
|
//---------------------------------------------------------------------------
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Input related methods
|
|
|
|
//---------------------------------------------------------------------------
|
2005-09-08 20:53:42 +04:00
|
|
|
void
|
2005-10-25 22:42:10 +04:00
|
|
|
RootLayer::_ProcessMouseMovedEvent(BMessage *msg)
|
2005-09-08 20:53:42 +04:00
|
|
|
{
|
2005-10-25 22:42:10 +04:00
|
|
|
BPoint where(0,0);
|
|
|
|
msg->FindPoint("where", &where);
|
|
|
|
|
|
|
|
Layer* target = LayerAt(where);
|
2005-09-08 20:53:42 +04:00
|
|
|
if (target == NULL) {
|
|
|
|
CRITICAL("RootLayer::_ProcessMouseMovedEvent() 'target' can't be null.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// change focus in FFM mode
|
|
|
|
WinBorder* winBorderTarget = dynamic_cast<WinBorder*>(target);
|
|
|
|
if (winBorderTarget) {
|
2005-10-31 14:05:52 +03:00
|
|
|
DesktopSettings desktopSettings(fDesktop);
|
2005-09-08 20:53:42 +04:00
|
|
|
// TODO: Focus should be a RootLayer option/feature, NOT a Workspace one!!!
|
2005-09-24 00:34:19 +04:00
|
|
|
WinBorder* exFocus = Focus();
|
2005-10-31 14:05:52 +03:00
|
|
|
if (desktopSettings.MouseMode() != B_NORMAL_MOUSE && exFocus != winBorderTarget) {
|
2005-10-03 01:55:45 +04:00
|
|
|
ActiveWorkspace()->AttemptToSetFocus(winBorderTarget);
|
2005-09-08 20:53:42 +04:00
|
|
|
// Workspace::SetFocus() *attempts* to set a new focus WinBorder, it may not succeed
|
2005-09-24 00:34:19 +04:00
|
|
|
if (exFocus != Focus()) {
|
2005-09-08 20:53:42 +04:00
|
|
|
// TODO: invalidate border area and send message to client for the widgets to light up
|
2005-09-24 00:34:19 +04:00
|
|
|
// What message? Is there a message on Focus change?
|
2005-09-08 20:53:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// add the layer under mouse to the list of layers to be notified on mouse moved
|
|
|
|
bool alreadyPresent = fMouseNotificationList.HasItem(target);
|
|
|
|
if (!alreadyPresent)
|
|
|
|
fMouseNotificationList.AddItem(target);
|
|
|
|
|
|
|
|
int32 count = fMouseNotificationList.CountItems();
|
2005-10-11 22:11:25 +04:00
|
|
|
int32 viewAction;
|
2005-09-08 20:53:42 +04:00
|
|
|
Layer *lay;
|
|
|
|
for (int32 i = 0; i <= count; i++) {
|
|
|
|
lay = static_cast<Layer*>(fMouseNotificationList.ItemAt(i));
|
|
|
|
if (lay) {
|
|
|
|
// set transit state
|
|
|
|
if (lay == target)
|
|
|
|
if (lay == fLastLayerUnderMouse)
|
2005-10-11 22:11:25 +04:00
|
|
|
viewAction = B_INSIDE_VIEW;
|
2005-09-08 20:53:42 +04:00
|
|
|
else
|
2005-10-11 22:11:25 +04:00
|
|
|
viewAction = B_ENTERED_VIEW;
|
2005-09-08 20:53:42 +04:00
|
|
|
else
|
|
|
|
if (lay == fLastLayerUnderMouse)
|
2005-10-11 22:11:25 +04:00
|
|
|
viewAction = B_EXITED_VIEW;
|
2005-09-08 20:53:42 +04:00
|
|
|
else
|
2005-10-11 22:11:25 +04:00
|
|
|
viewAction = B_OUTSIDE_VIEW;
|
2005-09-08 20:53:42 +04:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
msg->AddInt32("transit", viewAction);
|
|
|
|
lay->MouseMoved(msg);
|
2005-09-08 20:53:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!alreadyPresent)
|
|
|
|
fMouseNotificationList.RemoveItem(target);
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-09-08 20:53:42 +04:00
|
|
|
fLastLayerUnderMouse = target;
|
2005-10-25 22:42:10 +04:00
|
|
|
fLastMousePosition = where;
|
2005-09-08 20:53:42 +04:00
|
|
|
}
|
2005-10-11 22:11:25 +04:00
|
|
|
|
2005-06-20 14:33:34 +04:00
|
|
|
void
|
2005-10-25 22:42:10 +04:00
|
|
|
RootLayer::MouseEventHandler(BMessage *msg)
|
2005-01-17 00:35:02 +03:00
|
|
|
{
|
2005-10-25 22:42:10 +04:00
|
|
|
switch (msg->what) {
|
2005-06-03 23:50:30 +04:00
|
|
|
case B_MOUSE_DOWN: {
|
2005-07-07 00:19:22 +04:00
|
|
|
//printf("RootLayer::MouseEventHandler(B_MOUSE_DOWN)\n");
|
2005-10-25 22:42:10 +04:00
|
|
|
|
|
|
|
BPoint where(0,0);
|
|
|
|
|
|
|
|
msg->FindPoint("where", &where);
|
|
|
|
// We'll need this so that GetMouse can query for which buttons are down.
|
|
|
|
msg->FindInt32("buttons", &fButtons);
|
|
|
|
|
|
|
|
where.ConstrainTo(Frame());
|
|
|
|
|
|
|
|
if (fLastMousePosition != where) {
|
2005-09-16 09:10:21 +04:00
|
|
|
// move cursor on screen
|
2005-10-25 22:42:10 +04:00
|
|
|
GetHWInterface()->MoveCursorTo(where.x, where.y);
|
2005-09-16 09:10:21 +04:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
// If this happens, it's input server's fault.
|
|
|
|
// There might be additional fields an application expects in B_MOUSE_MOVED
|
|
|
|
// message, and in this way it won't get them.
|
|
|
|
int64 when = 0;
|
|
|
|
int32 buttons = 0;
|
2005-09-08 20:53:42 +04:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
msg->FindInt64("when", &when);
|
|
|
|
msg->FindInt32("buttons", &buttons);
|
|
|
|
|
|
|
|
BMessage mouseMovedMsg(B_MOUSE_MOVED);
|
|
|
|
mouseMovedMsg.AddInt64("when", when);
|
|
|
|
mouseMovedMsg.AddInt32("buttons", buttons);
|
|
|
|
mouseMovedMsg.AddPoint("where", where);
|
|
|
|
|
|
|
|
_ProcessMouseMovedEvent(msg);
|
|
|
|
}
|
2005-06-03 23:50:30 +04:00
|
|
|
|
2005-09-08 20:53:42 +04:00
|
|
|
if (fLastLayerUnderMouse == NULL) {
|
|
|
|
CRITICAL("RootLayer::MouseEventHandler(B_MOUSE_DOWN) fLastLayerUnderMouse is null!\n");
|
2005-05-26 03:59:23 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-03-21 23:29:24 +03:00
|
|
|
|
2005-09-08 20:53:42 +04:00
|
|
|
if (fLastLayerUnderMouse == this)
|
2005-03-21 23:29:24 +03:00
|
|
|
break;
|
2005-09-16 09:10:21 +04:00
|
|
|
|
2005-09-20 02:41:48 +04:00
|
|
|
int32 count = fMouseNotificationList.CountItems();
|
|
|
|
Layer *lay;
|
|
|
|
for (int32 i = 0; i <= count; i++) {
|
|
|
|
lay = static_cast<Layer*>(fMouseNotificationList.ItemAt(i));
|
|
|
|
if (lay)
|
|
|
|
// NOTE: testing under R5 shows that it doesn't matter if a window is created
|
|
|
|
// with B_ASYNCHRONOUS_CONTROLS flag or not. B_MOUSE_DOWN is always transmited.
|
2005-10-25 22:42:10 +04:00
|
|
|
lay->MouseDown(msg);
|
2005-09-20 02:41:48 +04:00
|
|
|
}
|
|
|
|
|
2005-09-19 02:43:31 +04:00
|
|
|
// get the pointer for one of the first RootLayer's descendants
|
2005-10-25 22:42:10 +04:00
|
|
|
Layer *primaryTarget = LayerAt(where, false);
|
|
|
|
primaryTarget->MouseDown(msg);
|
2005-03-27 14:51:28 +04:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-06-03 23:50:30 +04:00
|
|
|
case B_MOUSE_UP: {
|
2005-07-07 00:19:22 +04:00
|
|
|
//printf("RootLayer::MouseEventHandler(B_MOUSE_UP)\n");
|
2005-01-17 00:35:02 +03:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
BPoint where(0,0);
|
2005-01-17 00:35:02 +03:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
msg->FindPoint("where", &where);
|
2005-07-10 21:16:31 +04:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
where.ConstrainTo(fFrame);
|
|
|
|
|
|
|
|
if (fLastMousePosition != where) {
|
2005-09-16 09:10:21 +04:00
|
|
|
// move cursor on screen
|
2005-10-25 22:42:10 +04:00
|
|
|
GetHWInterface()->MoveCursorTo(where.x, where.y);
|
|
|
|
|
|
|
|
// If this happens, it's input server's fault.
|
|
|
|
// There might be additional fields an application expects in B_MOUSE_MOVED
|
|
|
|
// message, and in this way it won't get them.
|
|
|
|
int64 when = 0;
|
|
|
|
int32 buttons = 0;
|
2005-06-03 23:50:30 +04:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
msg->FindInt64("when", &when);
|
|
|
|
msg->FindInt32("buttons", &buttons);
|
|
|
|
|
|
|
|
BMessage mouseMovedMsg(B_MOUSE_MOVED);
|
|
|
|
mouseMovedMsg.AddInt64("when", when);
|
|
|
|
mouseMovedMsg.AddInt32("buttons", buttons);
|
|
|
|
mouseMovedMsg.AddPoint("where", where);
|
|
|
|
|
|
|
|
_ProcessMouseMovedEvent(msg);
|
2005-09-16 09:10:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fLastLayerUnderMouse == NULL) {
|
|
|
|
CRITICAL("RootLayer::MouseEventHandler(B_MOUSE_UP) fLastLayerUnderMouse is null!\n");
|
|
|
|
break;
|
|
|
|
}
|
2005-09-20 02:41:48 +04:00
|
|
|
|
|
|
|
bool foundCurrent = fMouseNotificationList.HasItem(fLastLayerUnderMouse);
|
|
|
|
int32 count = fMouseNotificationList.CountItems();
|
|
|
|
Layer *lay;
|
|
|
|
for (int32 i = 0; i <= count; i++) {
|
|
|
|
lay = static_cast<Layer*>(fMouseNotificationList.ItemAt(i));
|
|
|
|
if (lay)
|
2005-10-25 22:42:10 +04:00
|
|
|
lay->MouseUp(msg);
|
2005-09-20 02:41:48 +04:00
|
|
|
}
|
|
|
|
ClearNotifyLayer();
|
|
|
|
|
|
|
|
if (!foundCurrent)
|
2005-10-25 22:42:10 +04:00
|
|
|
fLastLayerUnderMouse->MouseUp(msg);
|
2005-03-11 00:34:04 +03:00
|
|
|
|
2005-05-07 17:03:20 +04:00
|
|
|
// TODO: This is a quick fix to avoid the endless loop with windows created
|
|
|
|
// with the B_ASYNCHRONOUS_CONTROLS flag, but please someone have a look into this.
|
|
|
|
fButtons = 0;
|
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-06-03 23:50:30 +04:00
|
|
|
case B_MOUSE_MOVED: {
|
2005-10-24 20:02:23 +04:00
|
|
|
//printf("RootLayer::MouseEventHandler(B_MOUSE_MOVED)\n");
|
2005-10-25 22:42:10 +04:00
|
|
|
|
|
|
|
BPoint where(0,0);
|
|
|
|
|
|
|
|
msg->FindPoint("where", &where);
|
|
|
|
|
|
|
|
where.ConstrainTo(fFrame);
|
2005-09-16 09:10:21 +04:00
|
|
|
// move cursor on screen
|
2005-10-25 22:42:10 +04:00
|
|
|
GetHWInterface()->MoveCursorTo(where.x, where.y);
|
2005-09-16 09:10:21 +04:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
_ProcessMouseMovedEvent(msg);
|
2005-06-03 23:50:30 +04:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-06-03 23:50:30 +04:00
|
|
|
case B_MOUSE_WHEEL_CHANGED: {
|
2005-10-24 20:02:23 +04:00
|
|
|
//printf("RootLayer::MouseEventHandler(B_MOUSE_WHEEL_CHANGED)\n");
|
2005-01-17 00:35:02 +03:00
|
|
|
// FEATURE: This is a tentative change: mouse wheel messages are always sent to the window
|
|
|
|
// under the cursor. It's pretty stupid to send it to the active window unless a particular
|
|
|
|
// view has locked focus via SetMouseEventMask
|
|
|
|
|
2005-10-24 20:11:50 +04:00
|
|
|
if (fLastLayerUnderMouse == NULL) {
|
|
|
|
CRITICAL("RootLayer::MouseEventHandler(B_MOUSE_DOWN) fLastLayerUnderMouse is null!\n");
|
|
|
|
break;
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
2005-10-24 20:11:50 +04:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
fLastLayerUnderMouse->MouseWheelChanged(msg);
|
2005-01-17 00:35:02 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
printf("RootLayer::MouseEventHandler(): WARNING: unknown message\n");
|
2005-01-17 00:35:02 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-20 14:33:34 +04:00
|
|
|
|
|
|
|
void
|
2005-10-25 22:42:10 +04:00
|
|
|
RootLayer::KeyboardEventHandler(BMessage *msg)
|
2005-01-17 00:35:02 +03:00
|
|
|
{
|
2005-10-25 22:42:10 +04:00
|
|
|
switch (msg->what) {
|
2005-01-17 00:35:02 +03:00
|
|
|
case B_KEY_DOWN:
|
|
|
|
{
|
2005-10-25 22:42:10 +04:00
|
|
|
int32 scancode = 0;
|
|
|
|
int32 modifiers = 0;
|
|
|
|
|
|
|
|
msg->FindInt32("key", &scancode);
|
|
|
|
msg->FindInt32("modifiers", &modifiers);
|
2005-01-17 00:35:02 +03:00
|
|
|
|
2005-07-01 15:22:58 +04:00
|
|
|
// F1-F12
|
|
|
|
if (scancode > 0x01 && scancode < 0x0e) {
|
|
|
|
// Check for workspace change or safe video mode
|
|
|
|
#if !TEST_MODE
|
|
|
|
if (scancode == 0x0d && (modifiers & (B_LEFT_COMMAND_KEY
|
|
|
|
| B_LEFT_CONTROL_KEY | B_LEFT_SHIFT_KEY)) != 0)
|
|
|
|
#else
|
|
|
|
if (scancode == 0x0d && (modifiers & (B_LEFT_CONTROL_KEY
|
|
|
|
| B_LEFT_SHIFT_KEY | B_LEFT_OPTION_KEY)) != 0)
|
|
|
|
#endif
|
2005-01-17 00:35:02 +03:00
|
|
|
{
|
2005-07-01 15:22:58 +04:00
|
|
|
// TODO: Set to Safe Mode in KeyboardEventHandler:B_KEY_DOWN. (DisplayDriver API change)
|
|
|
|
STRACE(("Safe Video Mode invoked - code unimplemented\n"));
|
2005-03-29 19:39:08 +04:00
|
|
|
break;
|
2005-01-17 00:35:02 +03:00
|
|
|
}
|
2005-07-01 15:22:58 +04:00
|
|
|
|
|
|
|
#if !TEST_MODE
|
|
|
|
if (modifiers & B_CONTROL_KEY)
|
|
|
|
#else
|
|
|
|
if (modifiers & (B_LEFT_SHIFT_KEY | B_LEFT_CONTROL_KEY))
|
|
|
|
#endif
|
2005-03-29 19:39:08 +04:00
|
|
|
{
|
|
|
|
STRACE(("Set Workspace %ld\n",scancode-1));
|
2005-09-23 01:43:23 +04:00
|
|
|
SetActiveWorkspace(scancode - 2);
|
2005-07-01 15:22:58 +04:00
|
|
|
#ifdef APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER
|
|
|
|
// to draw the current Workspace index on screen.
|
2005-06-17 00:43:53 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-04-28 22:28:23 +04:00
|
|
|
BRegion reg(fVisible);
|
|
|
|
fDriver->ConstrainClippingRegion(®);
|
|
|
|
Draw(reg.Frame());
|
|
|
|
fDriver->ConstrainClippingRegion(NULL);
|
2005-06-17 00:43:53 +04:00
|
|
|
#endif
|
2005-07-01 15:22:58 +04:00
|
|
|
#endif
|
2005-03-29 19:39:08 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-07-01 15:22:58 +04:00
|
|
|
|
|
|
|
// Tab key
|
|
|
|
#if !TEST_MODE
|
|
|
|
if (scancode == 0x26 && (modifiers & B_CONTROL_KEY))
|
|
|
|
#else
|
|
|
|
if (scancode == 0x26 && (modifiers & B_SHIFT_KEY))
|
|
|
|
#endif
|
2005-03-29 19:39:08 +04:00
|
|
|
{
|
|
|
|
STRACE(("Twitcher\n"));
|
2005-07-01 15:22:58 +04:00
|
|
|
//ServerApp *deskbar = app_server->FindApp("application/x-vnd.Be-TSKB");
|
2005-03-29 19:39:08 +04:00
|
|
|
//if(deskbar)
|
|
|
|
//{
|
2005-10-11 22:11:25 +04:00
|
|
|
// TODO: implement;
|
2005-03-29 19:39:08 +04:00
|
|
|
printf("Send Twitcher message key to Deskbar - unimplmemented\n");
|
|
|
|
break;
|
|
|
|
//}
|
|
|
|
}
|
2005-01-17 00:35:02 +03:00
|
|
|
|
2005-07-01 15:22:58 +04:00
|
|
|
#if !TEST_MODE
|
|
|
|
// PrintScreen
|
|
|
|
if (scancode == 0xe)
|
|
|
|
#else
|
2005-03-29 19:39:08 +04:00
|
|
|
// Pause/Break
|
2005-07-01 15:22:58 +04:00
|
|
|
if (scancode == 0x7f)
|
|
|
|
#endif
|
2005-03-29 19:39:08 +04:00
|
|
|
{
|
2005-07-01 15:22:58 +04:00
|
|
|
if (GetDisplayDriver()) {
|
2005-03-29 19:39:08 +04:00
|
|
|
char filename[128];
|
|
|
|
BEntry entry;
|
2005-07-01 15:22:58 +04:00
|
|
|
|
|
|
|
int32 index = 1;
|
|
|
|
do {
|
2005-07-06 14:21:23 +04:00
|
|
|
sprintf(filename, "/boot/home/screen%ld.png", index++);
|
2005-06-03 23:50:30 +04:00
|
|
|
entry.SetTo(filename);
|
2005-07-01 15:22:58 +04:00
|
|
|
} while(entry.Exists());
|
2005-03-29 19:39:08 +04:00
|
|
|
|
|
|
|
GetDisplayDriver()->DumpToFile(filename);
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-03-29 19:39:08 +04:00
|
|
|
break;
|
2005-01-17 00:35:02 +03:00
|
|
|
}
|
|
|
|
}
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
// We got this far, so apparently it's safe to pass to the active
|
|
|
|
// window.
|
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
if (Focus())
|
|
|
|
Focus()->KeyDown(msg);
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
case B_KEY_UP:
|
|
|
|
{
|
2005-10-25 22:42:10 +04:00
|
|
|
int32 scancode = 0;
|
|
|
|
int32 modifiers = 0;
|
|
|
|
|
|
|
|
msg->FindInt32("key", &scancode);
|
|
|
|
msg->FindInt32("modifiers", &modifiers);
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-04-18 22:48:19 +04:00
|
|
|
#if !TEST_MODE
|
2005-03-29 19:39:08 +04:00
|
|
|
// Tab key
|
|
|
|
if(scancode==0x26 && (modifiers & B_CONTROL_KEY))
|
2005-01-17 00:35:02 +03:00
|
|
|
{
|
2005-03-29 19:39:08 +04:00
|
|
|
//ServerApp *deskbar=app_server->FindApp("application/x-vnd.Be-TSKB");
|
|
|
|
//if(deskbar)
|
|
|
|
//{
|
|
|
|
printf("Send Twitcher message key to Deskbar - unimplmemented\n");
|
|
|
|
break;
|
|
|
|
//}
|
2005-01-17 00:35:02 +03:00
|
|
|
}
|
2005-04-18 22:48:19 +04:00
|
|
|
#else // TEST_MODE
|
2005-03-29 19:39:08 +04:00
|
|
|
if(scancode==0x26 && (modifiers & B_LEFT_SHIFT_KEY))
|
2005-01-17 00:35:02 +03:00
|
|
|
{
|
2005-03-29 19:39:08 +04:00
|
|
|
//ServerApp *deskbar=app_server->FindApp("application/x-vnd.Be-TSKB");
|
|
|
|
//if(deskbar)
|
|
|
|
//{
|
|
|
|
printf("Send Twitcher message key to Deskbar - unimplmemented\n");
|
|
|
|
break;
|
|
|
|
//}
|
2005-01-17 00:35:02 +03:00
|
|
|
}
|
2005-03-29 19:39:08 +04:00
|
|
|
#endif
|
2005-01-17 00:35:02 +03:00
|
|
|
|
|
|
|
// We got this far, so apparently it's safe to pass to the active
|
|
|
|
// window.
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-10-25 22:42:10 +04:00
|
|
|
if (Focus())
|
|
|
|
Focus()->KeyUp(msg);
|
2005-10-24 21:03:46 +04:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
case B_UNMAPPED_KEY_DOWN:
|
|
|
|
{
|
2005-10-25 22:42:10 +04:00
|
|
|
if(Focus())
|
|
|
|
Focus()->UnmappedKeyDown(msg);
|
2005-01-19 21:59:41 +03:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_UNMAPPED_KEY_UP:
|
|
|
|
{
|
2005-10-25 22:42:10 +04:00
|
|
|
if(Focus())
|
|
|
|
Focus()->UnmappedKeyUp(msg);
|
2005-01-19 21:59:41 +03:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_MODIFIERS_CHANGED:
|
|
|
|
{
|
2005-10-25 22:42:10 +04:00
|
|
|
if(Focus())
|
|
|
|
Focus()->ModifiersChanged(msg);
|
2005-03-17 20:41:00 +03:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-23 21:23:20 +04:00
|
|
|
bool
|
2005-09-05 22:55:32 +04:00
|
|
|
RootLayer::AddToInputNotificationLists(Layer *lay, uint32 mask, uint32 options)
|
2005-05-23 21:23:20 +04:00
|
|
|
{
|
|
|
|
if (!lay)
|
|
|
|
return false;
|
|
|
|
|
2005-07-15 16:45:23 +04:00
|
|
|
bool returnValue = true;
|
2005-05-23 21:23:20 +04:00
|
|
|
|
|
|
|
Lock();
|
|
|
|
|
2005-09-03 21:55:16 +04:00
|
|
|
if (mask & B_POINTER_EVENTS) {
|
2005-09-05 22:55:32 +04:00
|
|
|
if (!fMouseNotificationList.HasItem(lay))
|
|
|
|
fMouseNotificationList.AddItem(lay);
|
2005-09-03 21:55:16 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (options == 0)
|
2005-09-05 22:55:32 +04:00
|
|
|
fMouseNotificationList.RemoveItem(lay);
|
2005-09-03 21:55:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mask & B_KEYBOARD_EVENTS) {
|
2005-09-05 22:55:32 +04:00
|
|
|
if (!fKeyboardNotificationList.HasItem(lay))
|
|
|
|
fKeyboardNotificationList.AddItem(lay);
|
2005-09-03 21:55:16 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (options == 0)
|
2005-09-05 22:55:32 +04:00
|
|
|
fKeyboardNotificationList.RemoveItem(lay);
|
2005-09-03 21:55:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: set options!!!
|
|
|
|
// B_NO_POINTER_HISTORY only! How? By telling to the input_server?
|
|
|
|
|
|
|
|
Unlock();
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2005-09-05 22:55:32 +04:00
|
|
|
RootLayer::SetNotifyLayer(Layer *lay, uint32 mask, uint32 options)
|
2005-09-03 21:55:16 +04:00
|
|
|
{
|
|
|
|
if (!lay)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
bool returnValue = true;
|
|
|
|
|
|
|
|
Lock();
|
|
|
|
|
2005-09-05 22:55:32 +04:00
|
|
|
fNotifyLayer = lay;
|
|
|
|
fSavedEventMask = lay->EventMask();
|
2005-09-16 09:10:21 +04:00
|
|
|
fSavedEventOptions = lay->EventOptions();
|
2005-09-03 22:08:49 +04:00
|
|
|
|
2005-09-05 22:55:32 +04:00
|
|
|
AddToInputNotificationLists(lay, mask, options);
|
2005-09-03 22:08:49 +04:00
|
|
|
|
2005-09-05 22:55:32 +04:00
|
|
|
// TODO: set other options!!!
|
2005-09-03 22:08:49 +04:00
|
|
|
// B_SUSPEND_VIEW_FOCUS
|
|
|
|
// B_LOCK_WINDOW_FOCUS
|
2005-05-23 21:23:20 +04:00
|
|
|
Unlock();
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
|
2005-09-05 22:55:32 +04:00
|
|
|
void
|
|
|
|
RootLayer::ClearNotifyLayer()
|
|
|
|
{
|
|
|
|
if (fNotifyLayer) {
|
|
|
|
Lock();
|
2005-09-20 02:41:48 +04:00
|
|
|
// remove from notification list.
|
2005-09-05 22:55:32 +04:00
|
|
|
AddToInputNotificationLists(fNotifyLayer, 0UL, 0UL);
|
2005-09-20 02:41:48 +04:00
|
|
|
// set event masks
|
2005-09-05 22:55:32 +04:00
|
|
|
fNotifyLayer->QuietlySetEventMask(fSavedEventMask);
|
|
|
|
fNotifyLayer->QuietlySetEventOptions(fSavedEventOptions);
|
2005-09-20 02:41:48 +04:00
|
|
|
// add to notification list with event masks set my BView::SetEventMask()
|
2005-09-05 22:55:32 +04:00
|
|
|
AddToInputNotificationLists(fNotifyLayer, fSavedEventMask, fSavedEventOptions);
|
|
|
|
|
|
|
|
fNotifyLayer = NULL;
|
|
|
|
fSavedEventMask = 0UL;
|
|
|
|
fSavedEventOptions = 0UL;
|
|
|
|
|
|
|
|
Unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-07 18:04:29 +04:00
|
|
|
// LayerRemoved
|
|
|
|
void
|
|
|
|
RootLayer::LayerRemoved(Layer* layer)
|
|
|
|
{
|
2005-09-05 22:55:32 +04:00
|
|
|
if (layer == fNotifyLayer)
|
|
|
|
fNotifyLayer = NULL;
|
2005-07-15 16:45:23 +04:00
|
|
|
|
2005-09-08 20:53:42 +04:00
|
|
|
if (layer == fLastLayerUnderMouse)
|
|
|
|
fLastLayerUnderMouse = NULL;
|
2005-07-07 18:04:29 +04:00
|
|
|
}
|
|
|
|
|
2005-07-15 16:45:23 +04:00
|
|
|
|
2005-05-23 21:23:20 +04:00
|
|
|
void
|
|
|
|
RootLayer::SetDragMessage(BMessage* msg)
|
2005-01-17 00:35:02 +03:00
|
|
|
{
|
2005-07-15 16:45:23 +04:00
|
|
|
if (fDragMessage) {
|
2005-01-17 00:35:02 +03:00
|
|
|
delete fDragMessage;
|
|
|
|
fDragMessage = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msg)
|
|
|
|
fDragMessage = new BMessage(*msg);
|
|
|
|
}
|
|
|
|
|
2005-05-26 13:21:51 +04:00
|
|
|
|
|
|
|
BMessage *
|
|
|
|
RootLayer::DragMessage(void) const
|
2005-01-17 00:35:02 +03:00
|
|
|
{
|
|
|
|
return fDragMessage;
|
|
|
|
}
|
|
|
|
|
2005-01-22 00:13:00 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// PRIVATE methods
|
2005-01-22 00:13:00 +03:00
|
|
|
|
2005-05-26 13:21:51 +04:00
|
|
|
void
|
|
|
|
RootLayer::show_winBorder(WinBorder *winBorder)
|
2005-01-22 00:13:00 +03:00
|
|
|
{
|
2005-07-07 00:19:22 +04:00
|
|
|
bool invalidate = false;
|
|
|
|
bool invalid;
|
2005-09-23 01:43:23 +04:00
|
|
|
Workspace::State oldWMState;
|
|
|
|
ActiveWorkspace()->GetState(&oldWMState);
|
2005-01-22 00:13:00 +03:00
|
|
|
|
|
|
|
winBorder->Show(false);
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
for (int32 i = 0; i < fWsCount; i++) {
|
|
|
|
invalid = false;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-03-13 20:07:40 +03:00
|
|
|
if (fWorkspace[i] &&
|
|
|
|
(fWorkspace[i]->HasWinBorder(winBorder) ||
|
2005-03-19 21:58:47 +03:00
|
|
|
// subset modals are a bit like floating windows, they are being added
|
|
|
|
// and removed from workspace when there's at least a normal window
|
|
|
|
// that uses them.
|
2005-04-23 14:05:33 +04:00
|
|
|
winBorder->Feel() == B_MODAL_SUBSET_WINDOW_FEEL ||
|
2005-03-13 20:07:40 +03:00
|
|
|
// floating windows are inserted/removed on-the-fly so this window,
|
|
|
|
// although needed may not be in workspace's list.
|
|
|
|
winBorder->Level() == B_FLOATING_APP))
|
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
invalid = fWorkspace[i]->ShowWinBorder(winBorder);
|
2005-07-08 04:11:39 +04:00
|
|
|
|
|
|
|
// ToDo: this won't work with FFM
|
2005-10-03 01:55:45 +04:00
|
|
|
fWorkspace[i]->AttemptToSetFocus(winBorder);
|
2005-03-13 20:07:40 +03:00
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-07-01 10:53:07 +04:00
|
|
|
if (fActiveWksIndex == i) {
|
2005-02-28 23:23:51 +03:00
|
|
|
invalidate = invalid;
|
2005-07-01 10:53:07 +04:00
|
|
|
|
2005-07-10 21:16:31 +04:00
|
|
|
if (dynamic_cast<class WorkspacesLayer *>(winBorder->FirstChild()) != NULL)
|
|
|
|
SetWorkspacesLayer(winBorder->FirstChild());
|
2005-07-01 10:53:07 +04:00
|
|
|
}
|
2005-01-22 00:13:00 +03:00
|
|
|
}
|
2005-06-23 23:30:29 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
if (invalidate)
|
2005-09-23 01:43:23 +04:00
|
|
|
RevealNewWMState(oldWMState);
|
2005-01-22 00:13:00 +03:00
|
|
|
}
|
|
|
|
|
2005-07-01 11:58:22 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
RootLayer::hide_winBorder(WinBorder *winBorder)
|
2005-01-22 00:13:00 +03:00
|
|
|
{
|
2005-07-07 00:19:22 +04:00
|
|
|
bool invalidate = false;
|
|
|
|
bool invalid;
|
2005-09-23 01:43:23 +04:00
|
|
|
Workspace::State oldWMState;
|
|
|
|
ActiveWorkspace()->GetState(&oldWMState);
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-03-04 02:21:36 +03:00
|
|
|
winBorder->Hide(false);
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
for (int32 i = 0; i < fWsCount; i++) {
|
|
|
|
invalid = false;
|
2005-01-22 00:13:00 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
if (fWorkspace[i] && fWorkspace[i]->HasWinBorder(winBorder))
|
|
|
|
invalid = fWorkspace[i]->HideWinBorder(winBorder);
|
|
|
|
|
2005-07-01 10:53:07 +04:00
|
|
|
if (fActiveWksIndex == i) {
|
2005-02-28 23:23:51 +03:00
|
|
|
invalidate = invalid;
|
2005-07-01 10:53:07 +04:00
|
|
|
|
2005-07-10 21:16:31 +04:00
|
|
|
if (dynamic_cast<class WorkspacesLayer *>(winBorder->FirstChild()) != NULL)
|
2005-07-01 10:53:07 +04:00
|
|
|
SetWorkspacesLayer(NULL);
|
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (invalidate)
|
2005-09-23 01:43:23 +04:00
|
|
|
RevealNewWMState(oldWMState);
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
2005-07-01 11:58:22 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
RootLayer::change_winBorder_feel(WinBorder *winBorder, int32 newFeel)
|
2005-04-21 22:57:34 +04:00
|
|
|
{
|
2005-10-01 14:03:43 +04:00
|
|
|
// if the notify Layer is somehow related to winBorder, then
|
|
|
|
// this window/WinBorder is not allowed to change feel.
|
|
|
|
if (fNotifyLayer && (fNotifyLayer == winBorder || fNotifyLayer->Owner() == winBorder)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isVisible = false;
|
|
|
|
bool isVisibleInActiveWorkspace = false;
|
2005-04-21 22:57:34 +04:00
|
|
|
|
2005-09-23 01:43:23 +04:00
|
|
|
Workspace::State oldWMState;
|
|
|
|
ActiveWorkspace()->GetState(&oldWMState);
|
2005-04-21 22:57:34 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (!winBorder->IsHidden()) {
|
2005-04-21 22:57:34 +04:00
|
|
|
isVisible = true;
|
2005-10-01 14:03:43 +04:00
|
|
|
isVisibleInActiveWorkspace = ActiveWorkspace()->HasWinBorder(winBorder);
|
|
|
|
// just hide, don't invalidate
|
2005-04-21 22:57:34 +04:00
|
|
|
winBorder->Hide(false);
|
2005-10-01 14:03:43 +04:00
|
|
|
// all workspaces must be up-to-date with this change of feel.
|
|
|
|
for (int32 i = 0; i < kMaxWorkspaceCount; i++) {
|
|
|
|
if (fWorkspace[i]) {
|
|
|
|
fWorkspace[i]->HideWinBorder(winBorder);
|
|
|
|
fWorkspace[i]->RemoveWinBorder(winBorder);
|
|
|
|
}
|
|
|
|
}
|
2005-04-21 22:57:34 +04:00
|
|
|
}
|
|
|
|
|
2005-10-31 14:05:52 +03:00
|
|
|
fDesktop->SetWinBorderFeel(winBorder, newFeel);
|
2005-04-21 22:57:34 +04:00
|
|
|
|
2005-10-31 14:05:52 +03:00
|
|
|
if (isVisible) {
|
2005-10-01 14:03:43 +04:00
|
|
|
// just show, don't invalidate
|
|
|
|
winBorder->Show(false);
|
|
|
|
// all workspaces must be up-to-date with this change of feel.
|
|
|
|
for (int32 i = 0; i < kMaxWorkspaceCount; i++) {
|
|
|
|
if (fWorkspace[i]) {
|
|
|
|
fWorkspace[i]->AddWinBorder(winBorder);
|
|
|
|
fWorkspace[i]->ShowWinBorder(winBorder);
|
|
|
|
}
|
2005-04-21 22:57:34 +04:00
|
|
|
}
|
|
|
|
|
2005-10-01 14:03:43 +04:00
|
|
|
if (isVisibleInActiveWorkspace)
|
|
|
|
RevealNewWMState(oldWMState);
|
2005-04-21 22:57:34 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-22 00:11:44 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-09-19 02:43:31 +04:00
|
|
|
void
|
2005-06-03 23:50:30 +04:00
|
|
|
RootLayer::empty_visible_regions(Layer *layer)
|
2005-03-14 22:25:15 +03:00
|
|
|
{
|
|
|
|
// TODO: optimize by avoiding recursion?
|
|
|
|
// NOTE: first 'layer' must be a WinBorder
|
|
|
|
layer->fFullVisible.MakeEmpty();
|
|
|
|
layer->fVisible.MakeEmpty();
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-07-10 21:16:31 +04:00
|
|
|
Layer* child = layer->LastChild();
|
2005-07-07 00:19:22 +04:00
|
|
|
while (child) {
|
2005-03-14 22:25:15 +03:00
|
|
|
empty_visible_regions(child);
|
2005-07-10 21:16:31 +04:00
|
|
|
child = layer->PreviousChild();
|
2005-03-14 22:25:15 +03:00
|
|
|
}
|
2005-03-27 01:05:40 +03:00
|
|
|
}
|
2005-06-22 00:11:44 +04:00
|
|
|
#endif
|
2005-03-27 17:52:26 +04:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
RootLayer::Draw(const BRect &r)
|
2005-04-28 22:28:23 +04:00
|
|
|
{
|
2005-05-26 03:59:23 +04:00
|
|
|
fDriver->FillRect(r, fWorkspace[fActiveWksIndex]->BGColor());
|
2005-04-28 22:28:23 +04:00
|
|
|
#ifdef APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER
|
|
|
|
char string[30];
|
2005-05-26 03:59:23 +04:00
|
|
|
sprintf(string, "Workspace %ld", fActiveWksIndex + 1);
|
|
|
|
fDriver->DrawString(string, strlen(string), BPoint(5, 15),
|
2005-04-28 22:28:23 +04:00
|
|
|
fLayerData);
|
2005-05-26 03:59:23 +04:00
|
|
|
#endif // APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER
|
|
|
|
#if ON_SCREEN_DEBUGGING_INFO
|
|
|
|
BPoint location(5, 40);
|
|
|
|
float textHeight = 15.0; // be lazy
|
|
|
|
const char* p = fDebugInfo.String();
|
|
|
|
const char* start = p;
|
|
|
|
while (*p) {
|
|
|
|
p++;
|
|
|
|
if (*p == 0 || *p == '\n') {
|
|
|
|
fDriver->DrawString(start, p - start, location,
|
|
|
|
fLayerData);
|
|
|
|
// NOTE: Eventually, this will be below the screen!
|
|
|
|
location.y += textHeight;
|
|
|
|
start = p + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // ON_SCREEN_DEBUGGING_INFO
|
2005-06-11 17:00:17 +04:00
|
|
|
|
|
|
|
#if DISPLAY_HAIKU_LOGO
|
|
|
|
if (fLogoBitmap) {
|
|
|
|
BPoint logoPos;
|
|
|
|
logoPos.x = floorf(min_c(fFrame.left + fFrame.Width() * kGoldenProportion,
|
|
|
|
fFrame.right - (kLogoWidth + kLogoHeight / 2.0)));
|
|
|
|
logoPos.y = floorf(fFrame.bottom - kLogoHeight * 1.5);
|
|
|
|
BRect bitmapBounds = fLogoBitmap->Bounds();
|
|
|
|
fDriver->DrawBitmap(fLogoBitmap, bitmapBounds,
|
|
|
|
bitmapBounds.OffsetToCopy(logoPos), fLayerData);
|
|
|
|
}
|
|
|
|
#endif // DISPLAY_HAIKU_LOGO
|
2005-05-26 03:59:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#if ON_SCREEN_DEBUGGING_INFO
|
|
|
|
void
|
|
|
|
RootLayer::AddDebugInfo(const char* string)
|
|
|
|
{
|
|
|
|
if (Lock()) {
|
|
|
|
fDebugInfo << string;
|
|
|
|
GoRedraw(this, BRegion(fFrame));
|
|
|
|
Unlock();
|
|
|
|
}
|
2005-04-28 22:28:23 +04:00
|
|
|
}
|
2005-05-26 03:59:23 +04:00
|
|
|
#endif // ON_SCREEN_DEBUGGING_INFO
|
2005-10-24 21:46:37 +04:00
|
|
|
|
|
|
|
|
|
|
|
// taken from BLooper
|
|
|
|
void *
|
|
|
|
RootLayer::ReadRawFromPort(int32 *msgCode, bigtime_t timeout)
|
|
|
|
{
|
|
|
|
int8 *msgBuffer = NULL;
|
|
|
|
ssize_t bufferSize;
|
|
|
|
|
|
|
|
do {
|
|
|
|
bufferSize = port_buffer_size_etc(fListenPort, B_RELATIVE_TIMEOUT, timeout);
|
|
|
|
} while (bufferSize == B_INTERRUPTED);
|
|
|
|
|
|
|
|
if (bufferSize < B_OK)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (bufferSize > 0)
|
|
|
|
msgBuffer = new int8[bufferSize];
|
|
|
|
|
|
|
|
// we don't want to wait again here, since that can only mean
|
|
|
|
// that someone else has read our message and our bufferSize
|
|
|
|
// is now probably wrong
|
|
|
|
bufferSize = read_port_etc(fListenPort, msgCode, msgBuffer, bufferSize,
|
|
|
|
B_RELATIVE_TIMEOUT, 0);
|
|
|
|
if (bufferSize < B_OK) {
|
|
|
|
delete[] msgBuffer;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return msgBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BMessage *
|
|
|
|
RootLayer::ReadMessageFromPort(bigtime_t tout)
|
|
|
|
{
|
|
|
|
int32 msgcode;
|
|
|
|
BMessage* bmsg;
|
|
|
|
|
|
|
|
void* msgbuffer = ReadRawFromPort(&msgcode, tout);
|
|
|
|
if (!msgbuffer)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
bmsg = ConvertToMessage(msgbuffer, msgcode);
|
|
|
|
|
|
|
|
delete[] (int8*)msgbuffer;
|
|
|
|
|
|
|
|
return bmsg;
|
|
|
|
}
|
2005-10-31 22:35:46 +03:00
|
|
|
|
|
|
|
|
2005-10-24 21:46:37 +04:00
|
|
|
BMessage*
|
|
|
|
RootLayer::ConvertToMessage(void* raw, int32 code)
|
|
|
|
{
|
|
|
|
BMessage* bmsg = new BMessage(code);
|
|
|
|
|
|
|
|
if (raw != NULL) {
|
|
|
|
if (bmsg->Unflatten((const char*)raw) != B_OK) {
|
2005-10-25 22:42:10 +04:00
|
|
|
printf("Convert To BMessage FAILED. port message code was: %ld - %c%c%c%c",
|
|
|
|
code, (int8)(code >> 24), (int8)(code >> 16), (int8)(code >> 8), (int8)code );
|
2005-10-24 21:46:37 +04:00
|
|
|
delete bmsg;
|
|
|
|
bmsg = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bmsg;
|
2005-10-31 14:05:52 +03:00
|
|
|
}
|