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-06-03 23:50:30 +04:00
|
|
|
fViewAction(B_ENTERED_VIEW),
|
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),
|
|
|
|
// fMovingWindow(false),
|
|
|
|
// fResizingWindow(false),
|
|
|
|
fHaveWinBorderList(false),
|
|
|
|
|
|
|
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-06-03 23:50:30 +04:00
|
|
|
fWinBorderListLength(64),
|
|
|
|
fWinBorderList2((WinBorder**)malloc(fWinBorderListLength * sizeof(WinBorder*))),
|
|
|
|
fWinBorderList((WinBorder**)malloc(fWinBorderListLength * sizeof(WinBorder*))),
|
2005-09-29 01:12:38 +04:00
|
|
|
fMouseTargetWinBorder(NULL),
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
fWMState(),
|
|
|
|
#endif
|
2005-06-03 23:50:30 +04:00
|
|
|
fWinBorderCount(0),
|
|
|
|
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
|
|
|
// easy way to identify this class.
|
|
|
|
fClassID = AS_ROOTLAYER_CLASS;
|
|
|
|
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-06-15 01:28:56 +04:00
|
|
|
BPrivate::PortLink msg(fListenPort, -1);
|
2005-01-17 00:35:02 +03:00
|
|
|
msg.StartMessage(B_QUIT_REQUESTED);
|
|
|
|
msg.EndMessage();
|
|
|
|
msg.Flush();
|
|
|
|
|
2005-06-03 23:50:30 +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
|
|
|
|
2005-09-23 01:43:23 +04:00
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-06-03 23:50:30 +04:00
|
|
|
free(fWinBorderList2);
|
|
|
|
free(fWinBorderList);
|
2005-09-23 01:43:23 +04:00
|
|
|
#endif
|
|
|
|
|
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
|
|
|
int32 code = 0;
|
|
|
|
status_t err = B_OK;
|
|
|
|
RootLayer *oneRootLayer = (RootLayer*)data;
|
2005-06-15 01:28:56 +04:00
|
|
|
BPrivate::PortLink messageQueue(-1, oneRootLayer->fListenPort);
|
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-01-22 23:51:12 +03:00
|
|
|
oneRootLayer->invalidate_layer(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-06-08 04:36:26 +04:00
|
|
|
for (;;) {
|
2005-06-08 08:01:59 +04:00
|
|
|
err = messageQueue.GetNextMessage(code);
|
2005-06-08 04:36:26 +04:00
|
|
|
if (err < B_OK) {
|
2005-07-21 15:42:26 +04:00
|
|
|
STRACE(("WorkingThread: messageQueue.GetNextMessage() failed: %s\n", strerror(err)));
|
2005-01-17 00:35:02 +03:00
|
|
|
continue;
|
|
|
|
}
|
2005-05-06 11:47:17 +04:00
|
|
|
|
|
|
|
oneRootLayer->Lock();
|
2005-06-08 04:36:26 +04:00
|
|
|
|
|
|
|
switch (code) {
|
2005-01-17 00:35:02 +03:00
|
|
|
// 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:
|
2005-01-23 21:22:48 +03:00
|
|
|
case B_MOUSE_WHEEL_CHANGED:
|
2005-01-17 00:35:02 +03:00
|
|
|
oneRootLayer->MouseEventHandler(code, messageQueue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case B_KEY_DOWN:
|
|
|
|
case B_KEY_UP:
|
|
|
|
case B_UNMAPPED_KEY_DOWN:
|
|
|
|
case B_UNMAPPED_KEY_UP:
|
|
|
|
case B_MODIFIERS_CHANGED:
|
|
|
|
oneRootLayer->KeyboardEventHandler(code, messageQueue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case B_QUIT_REQUESTED:
|
|
|
|
exit_thread(0);
|
|
|
|
break;
|
|
|
|
|
2005-01-22 00:13:00 +03:00
|
|
|
case AS_ROOTLAYER_SHOW_WINBORDER:
|
|
|
|
{
|
2005-06-08 04:36:26 +04:00
|
|
|
WinBorder *winBorder = NULL;
|
2005-01-22 23:51:12 +03:00
|
|
|
messageQueue.Read<WinBorder*>(&winBorder);
|
|
|
|
oneRootLayer->show_winBorder(winBorder);
|
2005-01-22 00:13:00 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_ROOTLAYER_HIDE_WINBORDER:
|
|
|
|
{
|
2005-06-08 04:36:26 +04:00
|
|
|
WinBorder *winBorder = NULL;
|
2005-01-22 23:51:12 +03:00
|
|
|
messageQueue.Read<WinBorder*>(&winBorder);
|
|
|
|
oneRootLayer->hide_winBorder(winBorder);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_ROOTLAYER_DO_INVALIDATE:
|
|
|
|
{
|
2005-06-08 04:36:26 +04:00
|
|
|
BRegion invalidRegion;
|
|
|
|
Layer *layer = NULL;
|
2005-01-22 23:51:12 +03:00
|
|
|
messageQueue.Read<Layer*>(&layer);
|
|
|
|
messageQueue.ReadRegion(&invalidRegion);
|
2005-06-22 00:11:44 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-01-22 23:51:12 +03:00
|
|
|
oneRootLayer->invalidate_layer(layer, invalidRegion);
|
2005-06-22 00:11:44 +04:00
|
|
|
#else
|
|
|
|
layer->do_Invalidate(invalidRegion);
|
|
|
|
#endif
|
2005-01-22 23:51:12 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_ROOTLAYER_DO_REDRAW:
|
|
|
|
{
|
2005-06-08 04:36:26 +04:00
|
|
|
BRegion redrawRegion;
|
|
|
|
Layer *layer = NULL;
|
2005-01-22 23:51:12 +03:00
|
|
|
messageQueue.Read<Layer*>(&layer);
|
|
|
|
messageQueue.ReadRegion(&redrawRegion);
|
2005-06-22 00:11:44 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-01-22 23:51:12 +03:00
|
|
|
oneRootLayer->redraw_layer(layer, redrawRegion);
|
2005-06-22 00:11:44 +04:00
|
|
|
#else
|
|
|
|
layer->do_Redraw(redrawRegion);
|
|
|
|
#endif
|
2005-01-22 00:13:00 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-01-23 02:25:41 +03:00
|
|
|
case AS_ROOTLAYER_LAYER_MOVE:
|
|
|
|
{
|
2005-06-08 04:36:26 +04:00
|
|
|
Layer *layer = NULL;
|
|
|
|
float x, y;
|
2005-01-23 02:25:41 +03:00
|
|
|
messageQueue.Read<Layer*>(&layer);
|
|
|
|
messageQueue.Read<float>(&x);
|
|
|
|
messageQueue.Read<float>(&y);
|
2005-06-22 00:11:44 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-01-23 02:25:41 +03:00
|
|
|
layer->move_layer(x, y);
|
2005-06-22 00:11:44 +04:00
|
|
|
#else
|
|
|
|
layer->do_MoveBy(x, y);
|
|
|
|
#endif
|
2005-01-23 02:25:41 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_ROOTLAYER_LAYER_RESIZE:
|
|
|
|
{
|
2005-06-08 04:36:26 +04:00
|
|
|
Layer *layer = NULL;
|
|
|
|
float x, y;
|
2005-01-23 02:25:41 +03:00
|
|
|
messageQueue.Read<Layer*>(&layer);
|
|
|
|
messageQueue.Read<float>(&x);
|
|
|
|
messageQueue.Read<float>(&y);
|
2005-06-22 00:11:44 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-01-23 02:25:41 +03:00
|
|
|
layer->resize_layer(x, y);
|
2005-06-22 00:11:44 +04:00
|
|
|
#else
|
|
|
|
layer->do_ResizeBy(x, y);
|
2005-06-28 16:25:32 +04:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_ROOTLAYER_LAYER_SCROLL:
|
|
|
|
{
|
|
|
|
Layer *layer = NULL;
|
|
|
|
float x, y;
|
|
|
|
messageQueue.Read<Layer*>(&layer);
|
|
|
|
messageQueue.Read<float>(&x);
|
|
|
|
messageQueue.Read<float>(&y);
|
|
|
|
#ifndef NEW_CLIPPING
|
|
|
|
// nothing
|
|
|
|
#else
|
|
|
|
layer->do_ScrollBy(x, y);
|
2005-06-22 00:11:44 +04:00
|
|
|
#endif
|
2005-01-23 02:25:41 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-06-28 19:34:54 +04:00
|
|
|
case AS_ROOTLAYER_LAYER_COPYBITS:
|
|
|
|
{
|
|
|
|
Layer *layer = NULL;
|
|
|
|
int32 xOffset, yOffset;
|
|
|
|
BRect src, dst;
|
|
|
|
messageQueue.Read<Layer*>(&layer);
|
|
|
|
messageQueue.Read<BRect>(&src);
|
|
|
|
messageQueue.Read<BRect>(&dst);
|
|
|
|
messageQueue.Read<int32>(&xOffset);
|
|
|
|
messageQueue.Read<int32>(&yOffset);
|
|
|
|
|
|
|
|
layer->do_CopyBits(src, dst, xOffset, yOffset);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-03-14 01:54:01 +03:00
|
|
|
case AS_ROOTLAYER_ADD_TO_SUBSET:
|
|
|
|
{
|
2005-06-08 04:36:26 +04:00
|
|
|
WinBorder *winBorder = NULL;
|
|
|
|
WinBorder *toWinBorder = NULL;
|
2005-03-14 01:54:01 +03:00
|
|
|
messageQueue.Read<WinBorder*>(&winBorder);
|
|
|
|
messageQueue.Read<WinBorder*>(&toWinBorder);
|
2005-05-28 17:43:13 +04:00
|
|
|
oneRootLayer->fDesktop->AddWinBorderToSubset(winBorder, toWinBorder);
|
2005-03-14 01:54:01 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-03-18 22:00:45 +03:00
|
|
|
case AS_ROOTLAYER_REMOVE_FROM_SUBSET:
|
|
|
|
{
|
2005-06-08 04:36:26 +04:00
|
|
|
WinBorder *winBorder = NULL;
|
|
|
|
WinBorder *fromWinBorder = NULL;
|
2005-03-18 22:00:45 +03:00
|
|
|
messageQueue.Read<WinBorder*>(&winBorder);
|
|
|
|
messageQueue.Read<WinBorder*>(&fromWinBorder);
|
2005-05-28 17:43:13 +04:00
|
|
|
oneRootLayer->fDesktop->RemoveWinBorderFromSubset(winBorder, fromWinBorder);
|
2005-03-18 22:00:45 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-04-10 23:04:06 +04:00
|
|
|
case AS_ROOTLAYER_WINBORDER_SET_WORKSPACES:
|
|
|
|
{
|
2005-06-08 04:36:26 +04:00
|
|
|
WinBorder *winBorder = NULL;
|
|
|
|
uint32 oldWks = 0, newWks = 0;
|
2005-04-10 23:04:06 +04:00
|
|
|
|
|
|
|
messageQueue.Read<WinBorder*>(&winBorder);
|
|
|
|
messageQueue.Read<uint32>(&oldWks);
|
|
|
|
messageQueue.Read<uint32>(&newWks);
|
|
|
|
oneRootLayer->SetWinBorderWorskpaces(winBorder, oldWks, newWks);
|
|
|
|
break;
|
|
|
|
}
|
2005-04-21 22:57:34 +04:00
|
|
|
case AS_ROOTLAYER_DO_CHANGE_WINBORDER_FEEL:
|
|
|
|
{
|
2005-06-08 04:36:26 +04:00
|
|
|
WinBorder *winBorder = NULL;
|
|
|
|
int32 newFeel = 0;
|
2005-04-21 22:57:34 +04:00
|
|
|
|
|
|
|
messageQueue.Read<WinBorder*>(&winBorder);
|
|
|
|
messageQueue.Read<int32>(&newFeel);
|
|
|
|
oneRootLayer->change_winBorder_feel(winBorder, newFeel);
|
|
|
|
break;
|
|
|
|
}
|
2005-01-17 00:35:02 +03:00
|
|
|
default:
|
2005-06-23 22:48:10 +04:00
|
|
|
printf("RootLayer(%s)::WorkingThread received unexpected code %lx\n", oneRootLayer->Name(), code);
|
2005-01-17 00:35:02 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-01-22 00:13:00 +03:00
|
|
|
oneRootLayer->Unlock();
|
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
// if we still have other messages in our queue, but we really want to quit
|
|
|
|
if (oneRootLayer->fQuiting)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-08 04:36:26 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
RootLayer::GoInvalidate(const Layer *layer, const BRegion ®ion)
|
2005-01-22 23:51:12 +03:00
|
|
|
{
|
2005-06-15 01:28:56 +04:00
|
|
|
BPrivate::PortLink msg(fListenPort, -1);
|
2005-01-22 23:51:12 +03:00
|
|
|
msg.StartMessage(AS_ROOTLAYER_DO_INVALIDATE);
|
|
|
|
msg.Attach<const Layer*>(layer);
|
|
|
|
msg.AttachRegion(region);
|
|
|
|
msg.Flush();
|
|
|
|
}
|
|
|
|
|
2005-06-22 00:11:44 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-01-22 23:51:12 +03:00
|
|
|
void RootLayer::invalidate_layer(Layer *layer, const BRegion ®ion)
|
|
|
|
{
|
|
|
|
// NOTE: our thread (WorkingThread) is locked here.
|
2005-06-23 22:48:10 +04:00
|
|
|
STRACE(("RootLayer::invalidate_layer(%s)\n", layer->Name()));
|
2005-01-22 23:51:12 +03:00
|
|
|
|
|
|
|
if (layer->fParent)
|
|
|
|
layer = layer->fParent;
|
|
|
|
|
|
|
|
layer->FullInvalidate(region);
|
|
|
|
}
|
2005-06-22 00:11:44 +04:00
|
|
|
#endif
|
2005-06-15 01:28:56 +04:00
|
|
|
|
|
|
|
status_t
|
|
|
|
RootLayer::EnqueueMessage(BPrivate::PortLink &message)
|
2005-01-23 02:25:41 +03:00
|
|
|
{
|
2005-06-15 01:28:56 +04:00
|
|
|
message.SetSenderPort(fListenPort);
|
2005-01-23 02:25:41 +03:00
|
|
|
message.Flush();
|
2005-01-23 21:22:48 +03:00
|
|
|
return B_OK;
|
2005-01-23 02:25:41 +03:00
|
|
|
}
|
|
|
|
|
2005-06-15 01:28:56 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
RootLayer::GoRedraw(const Layer *layer, const BRegion ®ion)
|
2005-01-22 23:51:12 +03:00
|
|
|
{
|
2005-06-15 01:28:56 +04:00
|
|
|
BPrivate::PortLink msg(fListenPort, -1);
|
2005-01-22 23:51:12 +03:00
|
|
|
msg.StartMessage(AS_ROOTLAYER_DO_REDRAW);
|
|
|
|
msg.Attach<const Layer*>(layer);
|
|
|
|
msg.AttachRegion(region);
|
|
|
|
msg.Flush();
|
|
|
|
}
|
|
|
|
|
2005-06-22 00:11:44 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-06-15 01:28:56 +04:00
|
|
|
void
|
|
|
|
RootLayer::redraw_layer(Layer *layer, const BRegion ®ion)
|
2005-01-22 23:51:12 +03:00
|
|
|
{
|
|
|
|
// NOTE: our thread (WorkingThread) is locked here.
|
|
|
|
|
|
|
|
layer->Invalidate(region);
|
|
|
|
}
|
2005-06-22 00:11:44 +04:00
|
|
|
#endif
|
2005-06-15 01:28:56 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
RootLayer::GoChangeWinBorderFeel(const WinBorder *winBorder, int32 newFeel)
|
2005-04-21 22:57:34 +04:00
|
|
|
{
|
2005-06-15 01:28:56 +04:00
|
|
|
BPrivate::PortLink msg(fListenPort, -1);
|
2005-04-21 22:57:34 +04:00
|
|
|
msg.StartMessage(AS_ROOTLAYER_DO_CHANGE_WINBORDER_FEEL);
|
|
|
|
msg.Attach<const WinBorder*>(winBorder);
|
|
|
|
msg.Attach<int32>(newFeel);
|
|
|
|
msg.Flush();
|
|
|
|
}
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-07-10 21:16:31 +04:00
|
|
|
fWinBorderIndex = fWinBorderCount - 1;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-07-10 21:16:31 +04:00
|
|
|
if (fWinBorderIndex >= 0)
|
|
|
|
return fWinBorderList[fWinBorderIndex];
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
return NULL;
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
fWinBorderIndex = fWMState.WindowList.CountItems()-1;
|
|
|
|
return static_cast<Layer*>(fWMState.WindowList.ItemAt(fWinBorderIndex--));
|
|
|
|
#endif
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-07-10 21:16:31 +04:00
|
|
|
fWinBorderIndex--;
|
|
|
|
|
|
|
|
if (fWinBorderIndex < fWinBorderCount && fWinBorderIndex >= 0)
|
|
|
|
return fWinBorderList[fWinBorderIndex];
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
return NULL;
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
return static_cast<Layer*>(fWMState.WindowList.ItemAt(fWinBorderIndex--));
|
|
|
|
#endif
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-07-10 21:16:31 +04:00
|
|
|
fWinBorderIndex++;
|
|
|
|
|
|
|
|
if (fWinBorderIndex < fWinBorderCount && fWinBorderIndex >= 0)
|
|
|
|
return fWinBorderList[fWinBorderIndex];
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
return NULL;
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
return static_cast<Layer*>(fWMState.WindowList.ItemAt(fWinBorderIndex++));
|
|
|
|
#endif
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-02-28 23:23:51 +03:00
|
|
|
fWinBorderIndex = 0;
|
|
|
|
|
2005-07-10 21:16:31 +04:00
|
|
|
if (fWinBorderIndex < fWinBorderCount)
|
|
|
|
return fWinBorderList[fWinBorderIndex];
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
return NULL;
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
fWinBorderIndex = 0;
|
|
|
|
return static_cast<Layer*>(fWMState.WindowList.ItemAt(fWinBorderIndex++));
|
|
|
|
#endif
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-09-24 00:34:19 +04:00
|
|
|
WinBorder* exFocus = Focus();
|
|
|
|
WinBorder* exActive = Active();
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
Workspace::State oldWMState;
|
|
|
|
ActiveWorkspace()->GetState(&oldWMState);
|
|
|
|
#endif
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-04-10 23:04:06 +04:00
|
|
|
show_final_scene(exFocus, exActive);
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
RevealNewWMState(oldWMState);
|
|
|
|
#endif
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-09-24 00:34:19 +04:00
|
|
|
WinBorder* exFocus = Focus();
|
|
|
|
WinBorder* exActive = Active();
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
Workspace::State oldWMState;
|
|
|
|
ActiveWorkspace()->GetState(&oldWMState);
|
|
|
|
#endif
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-04-10 23:04:06 +04:00
|
|
|
show_final_scene(exFocus, exActive);
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
RevealNewWMState(oldWMState);
|
|
|
|
#endif
|
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-05-28 17:43:13 +04:00
|
|
|
const BList& windowList = fDesktop->WindowList();
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
int32 ptrCount = windowList.CountItems();
|
|
|
|
WinBorder **ptrWin = (WinBorder**)windowList.Items();
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
for (int32 i = 0; i < ptrCount; i++) {
|
|
|
|
if (ptrWin[i]->Workspaces() & (0x00000001UL << index)) {
|
2005-02-28 23:23:51 +03:00
|
|
|
fWorkspace[index]->AddWinBorder(ptrWin[i]);
|
2005-07-01 10:53:07 +04:00
|
|
|
|
2005-10-01 14:03:43 +04:00
|
|
|
if (!ptrWin[i]->IsHidden()) {
|
2005-02-28 23:23:51 +03:00
|
|
|
fWorkspace[index]->ShowWinBorder(ptrWin[i]);
|
2005-10-01 14:03:43 +04:00
|
|
|
}
|
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
|
|
|
#ifdef NEW_INPUT_HANDLING
|
|
|
|
Workspace::State oldWMState;
|
|
|
|
ActiveWorkspace()->GetState(&oldWMState);
|
|
|
|
#endif
|
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-29 01:12:38 +04:00
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-06-03 23:50:30 +04:00
|
|
|
BMessage activatedMsg(B_WORKSPACE_ACTIVATED);
|
2005-04-14 01:32:23 +04:00
|
|
|
activatedMsg.AddInt64("when", real_time_clock_usecs());
|
2005-02-28 23:23:51 +03:00
|
|
|
activatedMsg.AddInt32("workspace", fActiveWksIndex);
|
|
|
|
activatedMsg.AddBool("active", false);
|
|
|
|
|
2005-04-12 02:46:48 +04:00
|
|
|
for (int32 i = 0; i < fWinBorderCount; i++)
|
|
|
|
fWinBorderList[i]->Window()->SendMessageToClient(&activatedMsg, B_NULL_TOKEN, false);
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
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
|
|
|
}
|
|
|
|
#endif
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
fActiveWksIndex = index;
|
2005-09-29 01:12:38 +04:00
|
|
|
#ifdef NEW_INPUT_HANDLING
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
#else
|
2005-06-03 23:50:30 +04:00
|
|
|
if (fMouseTargetWinBorder) {
|
2005-09-05 22:55:32 +04:00
|
|
|
// if (fMovingWindow && fNotifyLayer) {
|
|
|
|
// WinBorder *movingWinBorder = (WinBorder*)fNotifyLayer;
|
2005-04-10 15:30:51 +04:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
// movingWinBorder->MouseUp(DEC_NONE);
|
2005-04-10 15:30:51 +04:00
|
|
|
|
|
|
|
// NOTE: DO NOT reset these 2 members! We still want to move our window in the new workspace
|
2005-09-05 22:55:32 +04:00
|
|
|
//fNotifyLayer = NULL;
|
2005-04-10 15:30:51 +04:00
|
|
|
//fMovingWindow = false;
|
2005-06-03 23:50:30 +04:00
|
|
|
// fResizingWindow = false;
|
|
|
|
|
|
|
|
// Take the WinBorder we're currently dragging with us to the new workspace
|
|
|
|
// NOTE: The code looks broken for WinBorders that show on multiple workspaces
|
|
|
|
// at the same time.
|
2005-04-10 15:30:51 +04:00
|
|
|
|
|
|
|
// only normal windows can change workspaces
|
2005-06-03 23:50:30 +04:00
|
|
|
if (fMouseTargetWinBorder->Feel() == B_NORMAL_WINDOW_FEEL
|
|
|
|
&& !ActiveWorkspace()->HasWinBorder(fMouseTargetWinBorder)) {
|
2005-04-10 15:30:51 +04:00
|
|
|
// 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.
|
2005-06-03 23:50:30 +04:00
|
|
|
fMouseTargetWinBorder->fHidden = true;
|
|
|
|
fWorkspace[exIndex]->HideWinBorder(fMouseTargetWinBorder);
|
|
|
|
fWorkspace[exIndex]->RemoveWinBorder(fMouseTargetWinBorder);
|
2005-04-10 15:30:51 +04:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
fMouseTargetWinBorder->fHidden = false;
|
|
|
|
ActiveWorkspace()->AddWinBorder(fMouseTargetWinBorder);
|
|
|
|
ActiveWorkspace()->ShowWinBorder(fMouseTargetWinBorder);
|
2005-04-10 15:30:51 +04:00
|
|
|
|
2005-04-14 01:32:23 +04:00
|
|
|
// TODO: can you call SetWinBorderWorskpaces() instead of this?
|
2005-06-03 23:50:30 +04:00
|
|
|
uint32 wks = fMouseTargetWinBorder->Workspaces();
|
|
|
|
BMessage changedMsg(B_WORKSPACES_CHANGED);
|
2005-04-14 01:32:23 +04:00
|
|
|
changedMsg.AddInt64("when", real_time_clock_usecs());
|
|
|
|
changedMsg.AddInt32("old", wks);
|
2005-06-03 23:50:30 +04:00
|
|
|
wks &= ~(0x00000001 << exIndex);
|
|
|
|
wks |= (0x00000001 << fActiveWksIndex);
|
2005-04-14 01:32:23 +04:00
|
|
|
changedMsg.AddInt32("new", wks);
|
2005-06-03 23:50:30 +04:00
|
|
|
fMouseTargetWinBorder->QuietlySetWorkspaces(wks);
|
|
|
|
fMouseTargetWinBorder->Window()->SendMessageToClient(&changedMsg, B_NULL_TOKEN, false);
|
2005-04-10 15:30:51 +04:00
|
|
|
}
|
2005-09-05 22:55:32 +04:00
|
|
|
}/* else if (fNotifyLayer) {
|
2005-04-10 15:30:51 +04:00
|
|
|
// is this a WinBorder object?
|
2005-09-05 22:55:32 +04:00
|
|
|
if (!fNotifyLayer->fOwner)
|
2005-04-10 15:30:51 +04:00
|
|
|
{
|
|
|
|
// this WinBorder captured the mouse for a reason. allow it to finish its task.
|
2005-09-05 22:55:32 +04:00
|
|
|
((WinBorder*)fNotifyLayer)->MouseUp(DEC_NONE);
|
2005-04-10 15:30:51 +04:00
|
|
|
}
|
|
|
|
|
2005-09-05 22:55:32 +04:00
|
|
|
fNotifyLayer = NULL;
|
2005-04-10 15:30:51 +04:00
|
|
|
fMovingWindow = false;
|
|
|
|
fResizingWindow = false;
|
2005-06-03 23:50:30 +04:00
|
|
|
}*/
|
2005-09-29 01:12:38 +04:00
|
|
|
#endif
|
2005-09-23 01:43:23 +04:00
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-09-29 01:12:38 +04:00
|
|
|
fHaveWinBorderList = true;
|
2005-04-14 01:32:23 +04:00
|
|
|
get_workspace_windows();
|
|
|
|
|
2005-07-01 10:53:07 +04:00
|
|
|
if (WorkspacesLayer() != NULL)
|
2005-07-02 14:37:53 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-07-01 10:53:07 +04:00
|
|
|
GoRedraw(WorkspacesLayer(), WorkspacesLayer()->fVisible);
|
2005-07-02 14:37:53 +04:00
|
|
|
#else
|
|
|
|
GoRedraw(WorkspacesLayer(), WorkspacesLayer()->VisibleRegion());
|
|
|
|
#endif
|
2005-07-01 10:53:07 +04:00
|
|
|
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
RevealNewWMState(oldWMState);
|
|
|
|
#endif
|
|
|
|
|
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-29 01:12:38 +04:00
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-04-14 01:32:23 +04:00
|
|
|
BMessage activatedMsg(B_WORKSPACE_ACTIVATED);
|
|
|
|
activatedMsg.AddInt64("when", real_time_clock_usecs());
|
|
|
|
activatedMsg.AddInt32("workspace", fActiveWksIndex);
|
|
|
|
activatedMsg.AddBool("active", true);
|
|
|
|
|
|
|
|
for (int32 i = 0; i < fWinBorderCount; i++)
|
|
|
|
fWinBorderList[i]->Window()->SendMessageToClient(&activatedMsg, B_NULL_TOKEN, false);
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
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
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-09-24 00:34:19 +04:00
|
|
|
WinBorder* exFocus = Focus();
|
|
|
|
WinBorder* exActive = Active();
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
Workspace::State oldWMState;
|
|
|
|
ActiveWorkspace()->GetState(&oldWMState);
|
|
|
|
#endif
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-07-07 00:19:22 +04:00
|
|
|
BMessage changedMsg(B_WORKSPACES_CHANGED);
|
2005-04-14 01:32:23 +04:00
|
|
|
changedMsg.AddInt64("when", real_time_clock_usecs());
|
2005-10-01 14:03:43 +04:00
|
|
|
changedMsg.AddInt32("old", oldIndex);
|
|
|
|
changedMsg.AddInt32("new", newIndex);
|
|
|
|
winBorder->QuietlySetWorkspaces(newIndex);
|
2005-04-14 01:32:23 +04:00
|
|
|
winBorder->Window()->SendMessageToClient(&changedMsg, B_NULL_TOKEN, false);
|
2005-10-01 14:03:43 +04:00
|
|
|
#else
|
|
|
|
winBorder->WorkspacesChanged(oldIndex, newIndex);
|
|
|
|
#endif
|
2005-02-28 23:23:51 +03:00
|
|
|
if (invalidate)
|
2005-09-23 01:43:23 +04:00
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-04-10 23:04:06 +04:00
|
|
|
show_final_scene(exFocus, exActive);
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
RevealNewWMState(oldWMState);
|
|
|
|
#endif
|
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-06-15 01:28:56 +04:00
|
|
|
BPrivate::PortLink msg(fListenPort, -1);
|
2005-01-22 00:13:00 +03:00
|
|
|
msg.StartMessage(AS_ROOTLAYER_HIDE_WINBORDER);
|
|
|
|
msg.Attach<WinBorder*>(winBorder);
|
|
|
|
msg.Flush();
|
|
|
|
}
|
|
|
|
|
2005-06-15 01:28:56 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
RootLayer::ShowWinBorder(WinBorder* winBorder)
|
2005-01-22 00:13:00 +03:00
|
|
|
{
|
2005-06-15 01:28:56 +04:00
|
|
|
BPrivate::PortLink msg(fListenPort, -1);
|
2005-01-22 00:13:00 +03:00
|
|
|
msg.StartMessage(AS_ROOTLAYER_SHOW_WINBORDER);
|
|
|
|
msg.Attach<WinBorder*>(winBorder);
|
|
|
|
msg.Flush();
|
|
|
|
}
|
|
|
|
|
2005-06-15 01:28:56 +04:00
|
|
|
|
2005-09-23 01:43:23 +04:00
|
|
|
#ifdef NEW_INPUT_HANDLING
|
|
|
|
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) {
|
|
|
|
if (oldWMState.Active && oldWMState.Active->Window()) {
|
|
|
|
BMessage msg(B_WINDOW_ACTIVATED);
|
|
|
|
msg.AddBool("active", false);
|
|
|
|
oldWMState.Active->Window()->SendMessageToClient(&msg, B_NULL_TOKEN, false);
|
|
|
|
}
|
|
|
|
if (fWMState.Active && fWMState.Active->Window()) {
|
|
|
|
BMessage msg(B_WINDOW_ACTIVATED);
|
|
|
|
msg.AddBool("active", true);
|
|
|
|
fWMState.Active->Window()->SendMessageToClient(&msg, B_NULL_TOKEN, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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(),
|
|
|
|
fWMState.WindowList.CountItems()) != 0) {
|
|
|
|
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
|
|
|
|
invalidate_layer(this, fFull);
|
|
|
|
#else
|
|
|
|
do_Invalidate(Bounds());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else if (redraw) {
|
|
|
|
#ifndef NEW_CLIPPING
|
|
|
|
invalidate_layer(this, dirtyRegion);
|
|
|
|
#else
|
|
|
|
do_Redraw(dirtyRegion);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2005-10-03 01:55:45 +04:00
|
|
|
|
|
|
|
bool
|
|
|
|
RootLayer::SetActive(WinBorder* newActive)
|
|
|
|
{
|
|
|
|
// TODO: properly implement
|
|
|
|
return ActiveWorkspace()->AttemptToActivate(newActive);
|
|
|
|
}
|
2005-09-23 01:43:23 +04:00
|
|
|
#endif
|
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
|
|
|
#ifdef NEW_INPUT_HANDLING
|
|
|
|
void
|
|
|
|
RootLayer::_ProcessMouseMovedEvent(PointerEvent &evt)
|
|
|
|
{
|
|
|
|
Layer* target = LayerAt(evt.where);
|
|
|
|
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) {
|
|
|
|
DesktopSettings ds(gDesktop);
|
|
|
|
// TODO: Focus should be a RootLayer option/feature, NOT a Workspace one!!!
|
2005-09-24 00:34:19 +04:00
|
|
|
WinBorder* exFocus = Focus();
|
2005-09-08 20:53:42 +04:00
|
|
|
if (ds.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();
|
|
|
|
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)
|
|
|
|
fViewAction = B_INSIDE_VIEW;
|
|
|
|
else
|
|
|
|
fViewAction = B_ENTERED_VIEW;
|
|
|
|
else
|
|
|
|
if (lay == fLastLayerUnderMouse)
|
|
|
|
fViewAction = B_EXITED_VIEW;
|
|
|
|
else
|
|
|
|
fViewAction = B_OUTSIDE_VIEW;
|
|
|
|
|
|
|
|
lay->MouseMoved(evt, fViewAction);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!alreadyPresent)
|
|
|
|
fMouseNotificationList.RemoveItem(target);
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-09-08 20:53:42 +04:00
|
|
|
fLastLayerUnderMouse = target;
|
|
|
|
fLastMousePosition = evt.where;
|
|
|
|
}
|
|
|
|
#endif
|
2005-06-20 14:33:34 +04:00
|
|
|
void
|
2005-06-15 01:28:56 +04:00
|
|
|
RootLayer::MouseEventHandler(int32 code, BPrivate::PortLink& msg)
|
2005-01-17 00:35:02 +03:00
|
|
|
{
|
2005-07-07 00:19:22 +04:00
|
|
|
switch (code) {
|
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-01-17 00:35:02 +03:00
|
|
|
// Attached data:
|
|
|
|
// 1) int64 - time of mouse click
|
|
|
|
// 2) float - x coordinate of mouse click
|
|
|
|
// 3) float - y coordinate of mouse click
|
|
|
|
// 4) int32 - modifier keys down
|
|
|
|
// 5) int32 - buttons down
|
|
|
|
// 6) int32 - clicks
|
|
|
|
|
|
|
|
PointerEvent evt;
|
|
|
|
evt.code = B_MOUSE_DOWN;
|
|
|
|
msg.Read<int64>(&evt.when);
|
|
|
|
msg.Read<float>(&evt.where.x);
|
|
|
|
msg.Read<float>(&evt.where.y);
|
|
|
|
msg.Read<int32>(&evt.modifiers);
|
|
|
|
msg.Read<int32>(&evt.buttons);
|
|
|
|
msg.Read<int32>(&evt.clicks);
|
2005-03-21 23:29:24 +03:00
|
|
|
|
2005-07-10 21:16:31 +04:00
|
|
|
evt.where.ConstrainTo(fFrame);
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
if (fLastMousePosition != evt.where) {
|
2005-09-08 20:53:42 +04:00
|
|
|
#ifdef NEW_INPUT_HANDLING
|
2005-09-16 09:10:21 +04:00
|
|
|
// move cursor on screen
|
|
|
|
GetHWInterface()->MoveCursorTo(evt.where.x, evt.where.y);
|
|
|
|
|
2005-09-08 20:53:42 +04:00
|
|
|
_ProcessMouseMovedEvent(evt);
|
|
|
|
#else
|
|
|
|
|
2005-05-15 15:59:14 +04:00
|
|
|
// TODO: a B_MOUSE_MOVED message might have to be generated in order to
|
|
|
|
// correctly trigger entered/exited view transits.
|
2005-05-26 03:59:23 +04:00
|
|
|
// Commented for now, since it is not _that_ critical and happens frequently with the Haiku
|
|
|
|
// mouse driver (which is ok, but we need to catch it here).
|
2005-09-08 20:53:42 +04:00
|
|
|
//CRITICAL("mouse position changed in B_MOUSE_DOWN from last B_MOUSE_MOVED\n");
|
2005-05-15 15:59:14 +04:00
|
|
|
// update on screen mouse pos
|
2005-06-24 03:46:17 +04:00
|
|
|
GetHWInterface()->MoveCursorTo(evt.where.x, evt.where.y);
|
2005-09-08 20:53:42 +04:00
|
|
|
fLastMousePosition = evt.where;
|
|
|
|
#endif
|
2005-05-15 15:59:14 +04:00
|
|
|
}
|
2005-09-08 20:53:42 +04:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
// We'll need this so that GetMouse can query for which buttons
|
|
|
|
// are down.
|
|
|
|
fButtons = evt.buttons;
|
|
|
|
|
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-19 02:43:31 +04:00
|
|
|
#ifdef NEW_INPUT_HANDLING
|
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.
|
|
|
|
lay->MouseDown(evt);
|
|
|
|
}
|
|
|
|
|
2005-09-19 02:43:31 +04:00
|
|
|
// get the pointer for one of the first RootLayer's descendants
|
|
|
|
Layer *primaryTarget = LayerAt(evt.where, false);
|
|
|
|
primaryTarget->MouseDown(evt);
|
2005-09-08 20:53:42 +04:00
|
|
|
#else
|
2005-03-21 23:29:24 +03:00
|
|
|
// we are clicking a WinBorder
|
2005-03-11 00:34:04 +03:00
|
|
|
|
2005-09-24 00:34:19 +04:00
|
|
|
WinBorder* exActive = Active();
|
|
|
|
WinBorder* exFocus = Focus();
|
2005-09-08 20:53:42 +04:00
|
|
|
WinBorder* target = fLastLayerUnderMouse->fOwner ? fLastLayerUnderMouse->fOwner
|
|
|
|
: (WinBorder*)fLastLayerUnderMouse;
|
2005-03-21 23:29:24 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
click_type action = target->MouseDown(evt);
|
2005-03-21 23:29:24 +03:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
bool invalidate = ActiveWorkspace()->SetFocus(target);
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
// TODO: only move to front if *not* in Focus Follows Mouse mode!
|
2005-07-07 00:19:22 +04:00
|
|
|
invalidate |= action == DEC_MOVETOBACK ? ActiveWorkspace()->MoveToBack(target)
|
|
|
|
: ActiveWorkspace()->MoveToFront(target);
|
2005-03-27 14:00:37 +04:00
|
|
|
|
2005-03-27 14:51:28 +04:00
|
|
|
// Performance: MoveToFront() often returns true although it shouldn't do that.
|
|
|
|
// This is because internaly it calls Workspace::ShowWinBorder() and this imposes
|
|
|
|
// a small penalty, but we can live with that; it make Workspace code a lot more clear/clean.
|
|
|
|
|
2005-04-10 23:04:06 +04:00
|
|
|
if (invalidate)
|
|
|
|
show_final_scene(exFocus, exActive);
|
2005-03-27 17:52:26 +04:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
// some of the actions are handled by the WinBorder itself,
|
|
|
|
// others are handled by RootLayer
|
|
|
|
fMouseTargetWinBorder = NULL;
|
|
|
|
switch (action) {
|
|
|
|
case DEC_MOVETOBACK:
|
|
|
|
// TODO: handle here once we support FFM...
|
|
|
|
// now it is handled above
|
|
|
|
break;
|
|
|
|
case DEC_NONE: {
|
|
|
|
// TODO: bring to front if not in FFM...
|
|
|
|
// now it is handled above
|
|
|
|
bool sendMessage = true;
|
|
|
|
// supress mouse down events if the window has no focus or
|
|
|
|
// does not accept first clicks
|
2005-09-24 00:34:19 +04:00
|
|
|
if (target != Focus())
|
2005-06-03 23:50:30 +04:00
|
|
|
sendMessage = false;
|
2005-09-24 00:34:19 +04:00
|
|
|
else if (exFocus != Focus()
|
2005-06-03 23:50:30 +04:00
|
|
|
&& !(target->WindowFlags() & B_WILL_ACCEPT_FIRST_CLICK))
|
|
|
|
sendMessage = false;
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-09-08 20:53:42 +04:00
|
|
|
if (sendMessage && fLastLayerUnderMouse != target->fTopLayer) {
|
2005-06-03 23:50:30 +04:00
|
|
|
BMessage msg;
|
|
|
|
msg.what = B_MOUSE_DOWN;
|
|
|
|
msg.AddInt64("when", evt.when);
|
|
|
|
msg.AddPoint("where", evt.where);
|
|
|
|
msg.AddInt32("modifiers", evt.modifiers);
|
|
|
|
msg.AddInt32("buttons", evt.buttons);
|
|
|
|
msg.AddInt32("clicks", evt.clicks);
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-09-08 20:53:42 +04:00
|
|
|
target->Window()->SendMessageToClient(&msg, fLastLayerUnderMouse->fViewToken, false);
|
2005-06-03 23:50:30 +04:00
|
|
|
}
|
2005-03-21 23:29:24 +03:00
|
|
|
|
2005-09-08 20:53:42 +04:00
|
|
|
if (fLastLayerUnderMouse->EventMask() & B_POINTER_EVENTS)
|
|
|
|
fNotifyLayer = fLastLayerUnderMouse;
|
2005-06-03 23:50:30 +04:00
|
|
|
break;
|
2005-03-11 00:34:04 +03:00
|
|
|
}
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
case DEC_DRAG:
|
|
|
|
case DEC_RESIZE:
|
|
|
|
default:
|
|
|
|
// TODO: bring to front if not in FFM...
|
|
|
|
// now it is handled above
|
|
|
|
fMouseTargetWinBorder = target;
|
|
|
|
break;
|
2005-01-17 00:35:02 +03:00
|
|
|
}
|
2005-09-08 20:53:42 +04:00
|
|
|
#endif
|
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
|
|
|
// Attached data:
|
|
|
|
// 1) int64 - time of mouse click
|
|
|
|
// 2) float - x coordinate of mouse click
|
|
|
|
// 3) float - y coordinate of mouse click
|
|
|
|
// 4) int32 - modifier keys down
|
|
|
|
|
|
|
|
PointerEvent evt;
|
|
|
|
evt.code = B_MOUSE_UP;
|
|
|
|
msg.Read<int64>(&evt.when);
|
|
|
|
msg.Read<float>(&evt.where.x);
|
|
|
|
msg.Read<float>(&evt.where.y);
|
|
|
|
msg.Read<int32>(&evt.modifiers);
|
|
|
|
|
2005-07-10 21:16:31 +04:00
|
|
|
evt.where.ConstrainTo(fFrame);
|
|
|
|
|
2005-09-16 09:10:21 +04:00
|
|
|
if (fLastMousePosition != evt.where) {
|
2005-09-08 20:53:42 +04:00
|
|
|
#ifdef NEW_INPUT_HANDLING
|
2005-09-16 09:10:21 +04:00
|
|
|
// move cursor on screen
|
|
|
|
GetHWInterface()->MoveCursorTo(evt.where.x, evt.where.y);
|
2005-06-03 23:50:30 +04:00
|
|
|
|
2005-09-16 09:10:21 +04:00
|
|
|
_ProcessMouseMovedEvent(evt);
|
|
|
|
#else
|
2005-05-15 15:59:14 +04:00
|
|
|
// TODO: a B_MOUSE_MOVED message might have to be generated in order to
|
|
|
|
// correctly trigger entered/exited view transits.
|
2005-06-03 23:50:30 +04:00
|
|
|
fprintf(stderr, "mouse position changed in B_MOUSE_UP (%.1f, %.1f) from last B_MOUSE_MOVED (%.1f, %.1f)!\n",
|
|
|
|
evt.where.x, evt.where.y, fLastMousePosition.x, fLastMousePosition.y);
|
2005-05-15 15:59:14 +04:00
|
|
|
// update on screen mouse pos
|
2005-06-24 03:46:17 +04:00
|
|
|
GetHWInterface()->MoveCursorTo(evt.where.x, evt.where.y);
|
2005-06-03 23:50:30 +04:00
|
|
|
fLastMousePosition = evt.where;
|
2005-09-16 09:10:21 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NEW_INPUT_HANDLING
|
|
|
|
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)
|
|
|
|
lay->MouseUp(evt);
|
|
|
|
}
|
|
|
|
ClearNotifyLayer();
|
|
|
|
|
|
|
|
if (!foundCurrent)
|
|
|
|
fLastLayerUnderMouse->MouseUp(evt);
|
2005-09-16 09:10:21 +04:00
|
|
|
#else
|
|
|
|
if (fLastLayerUnderMouse == NULL) {
|
|
|
|
CRITICAL("RootLayer::MouseEventHandler(B_MOUSE_UP) fLastLayerUnderMouse is null!\n");
|
|
|
|
break;
|
2005-05-15 15:59:14 +04:00
|
|
|
}
|
|
|
|
|
2005-09-05 22:55:32 +04:00
|
|
|
// TODO: what if 'fNotifyLayer' is deleted in the mean time.
|
|
|
|
if (fNotifyLayer) {
|
2005-03-21 23:29:24 +03:00
|
|
|
// if this is a regular Layer, sent message to counterpart BView.
|
2005-09-05 22:55:32 +04:00
|
|
|
if (fNotifyLayer->fOwner) {
|
2005-03-21 23:29:24 +03:00
|
|
|
BMessage upmsg(B_MOUSE_UP);
|
|
|
|
upmsg.AddInt64("when",evt.when);
|
|
|
|
upmsg.AddPoint("where",evt.where);
|
|
|
|
upmsg.AddInt32("modifiers",evt.modifiers);
|
|
|
|
|
2005-09-05 22:55:32 +04:00
|
|
|
fNotifyLayer->Window()->SendMessageToClient(&upmsg, fNotifyLayer->fViewToken, false);
|
2005-06-03 23:50:30 +04:00
|
|
|
} else {
|
|
|
|
// this surely is a WinBorder
|
|
|
|
// TODO: This code is too confusing. There should be a clear separation.
|
2005-09-05 22:55:32 +04:00
|
|
|
// ((WinBorder*)fNotifyLayer)->MouseUp(((WinBorder*)fNotifyLayer)->TellWhat(evt));
|
2005-03-21 23:29:24 +03:00
|
|
|
}
|
|
|
|
|
2005-09-05 22:55:32 +04:00
|
|
|
fNotifyLayer = NULL;
|
2005-06-03 23:50:30 +04:00
|
|
|
} else {
|
2005-04-10 23:04:06 +04:00
|
|
|
// NOTE: focus may be NULL
|
2005-09-24 00:34:19 +04:00
|
|
|
if (fLastLayerUnderMouse->Window() && fLastLayerUnderMouse->fOwner == Focus()) {
|
2005-03-21 23:29:24 +03:00
|
|
|
// send B_MOUSE_UP for regular Layers/BViews
|
|
|
|
BMessage upmsg(B_MOUSE_UP);
|
|
|
|
upmsg.AddInt64("when",evt.when);
|
|
|
|
upmsg.AddPoint("where",evt.where);
|
|
|
|
upmsg.AddInt32("modifiers",evt.modifiers);
|
|
|
|
|
2005-09-08 20:53:42 +04:00
|
|
|
fLastLayerUnderMouse->Window()->SendMessageToClient(&upmsg, fLastLayerUnderMouse->fViewToken, false);
|
2005-06-03 23:50:30 +04:00
|
|
|
} else {
|
2005-03-21 23:29:24 +03:00
|
|
|
// WinBorders don't need _UP_ messages unless they received _DOWN_ messages,
|
|
|
|
// and that case is threated above - WinBorders use Layer::fEventMask to
|
|
|
|
// capture the mouse.
|
|
|
|
}
|
2005-01-17 00:35:02 +03:00
|
|
|
}
|
2005-03-11 00:34:04 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
// fMovingWindow = false;
|
|
|
|
// fResizingWindow = false;
|
|
|
|
if (fMouseTargetWinBorder) {
|
|
|
|
fMouseTargetWinBorder->MouseUp(evt);
|
|
|
|
fMouseTargetWinBorder = NULL;
|
|
|
|
}
|
2005-03-11 00:34:04 +03:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
STRACE(("MOUSE UP: at (%f, %f)\n", evt.where.x, evt.where.y));
|
2005-09-16 09:10:21 +04:00
|
|
|
#endif
|
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: {
|
|
|
|
//printf("RootLayer::MouseEventHandler(B_MOUSE_MOVED)\n");
|
2005-01-17 00:35:02 +03:00
|
|
|
// Attached data:
|
|
|
|
// 1) int64 - time of mouse click
|
|
|
|
// 2) float - x coordinate of mouse click
|
|
|
|
// 3) float - y coordinate of mouse click
|
|
|
|
// 4) int32 - buttons down
|
|
|
|
|
2005-07-10 21:16:31 +04:00
|
|
|
PointerEvent evt;
|
2005-01-17 00:35:02 +03:00
|
|
|
evt.code = B_MOUSE_MOVED;
|
|
|
|
msg.Read<int64>(&evt.when);
|
|
|
|
msg.Read<float>(&evt.where.x);
|
|
|
|
msg.Read<float>(&evt.where.y);
|
|
|
|
msg.Read<int32>(&evt.buttons);
|
|
|
|
|
2005-07-10 21:16:31 +04:00
|
|
|
evt.where.ConstrainTo(fFrame);
|
2005-09-08 20:53:42 +04:00
|
|
|
#ifdef NEW_INPUT_HANDLING
|
2005-09-16 09:10:21 +04:00
|
|
|
// move cursor on screen
|
|
|
|
GetHWInterface()->MoveCursorTo(evt.where.x, evt.where.y);
|
|
|
|
|
2005-09-08 20:53:42 +04:00
|
|
|
_ProcessMouseMovedEvent(evt);
|
|
|
|
#else
|
2005-06-24 03:46:17 +04:00
|
|
|
GetHWInterface()->MoveCursorTo(evt.where.x, evt.where.y);
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
fLastMousePosition = evt.where;
|
|
|
|
|
|
|
|
// NOTE: The mouse does NOT have to be over the fMouseTargetWinBorder for
|
|
|
|
// it to be still the valid target of the event. In fact, it is
|
|
|
|
// the only valid target until MOUSE_UP. So don't move this block farther
|
|
|
|
// down.
|
|
|
|
if (fMouseTargetWinBorder) {
|
|
|
|
fMouseTargetWinBorder->MouseMoved(evt);
|
2005-09-08 20:53:42 +04:00
|
|
|
fLastLayerUnderMouse = fMouseTargetWinBorder;
|
2005-06-03 23:50:30 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-03-27 16:19:37 +04:00
|
|
|
// TODO: lock ServerWindow here! Don't forget, you need to add/remove Layers
|
|
|
|
// from within RootLayer's thread!!!
|
2005-06-03 23:50:30 +04:00
|
|
|
Layer* target = LayerAt(evt.where);
|
|
|
|
if (target == NULL) {
|
|
|
|
CRITICAL("RootLayer::MouseEventHandler(B_MOUSE_MOVED) 'target' can't be null.\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
WinBorder* winBorderUnder = NULL;
|
2005-03-21 23:29:24 +03:00
|
|
|
|
2005-05-07 17:03:20 +04:00
|
|
|
// TODO: I think that windows created without the B_ASYNCHRONOUS_CONTROLS flag
|
|
|
|
// don't receive B_MOUSE_MOVED events after a B_MOUSE_DOWN. Test.
|
|
|
|
// This will need to be cleaned up as following the code flow
|
|
|
|
// is very hard.
|
|
|
|
|
2005-09-05 22:55:32 +04:00
|
|
|
// fNotifyLayer is always != this
|
|
|
|
if (fNotifyLayer) {
|
|
|
|
if (fNotifyLayer == target) {
|
2005-09-08 20:53:42 +04:00
|
|
|
if (target == fLastLayerUnderMouse)
|
2005-03-21 23:29:24 +03:00
|
|
|
fViewAction = B_INSIDE_VIEW;
|
|
|
|
else
|
|
|
|
fViewAction = B_ENTERED_VIEW;
|
2005-09-08 20:53:42 +04:00
|
|
|
} else if (fNotifyLayer == fLastLayerUnderMouse) {
|
2005-03-21 23:29:24 +03:00
|
|
|
fViewAction = B_EXITED_VIEW;
|
2005-06-03 23:50:30 +04:00
|
|
|
} else {
|
2005-03-21 23:29:24 +03:00
|
|
|
fViewAction = B_OUTSIDE_VIEW;
|
|
|
|
}
|
|
|
|
|
2005-09-05 22:55:32 +04:00
|
|
|
if (fNotifyLayer->fOwner) {
|
2005-03-21 23:29:24 +03:00
|
|
|
// top layer does not have B_POINTER_EVENTS in its event mask
|
|
|
|
BMessage movemsg(B_MOUSE_MOVED);
|
2005-06-03 23:50:30 +04:00
|
|
|
movemsg.AddInt64("when", evt.when);
|
|
|
|
movemsg.AddPoint("where", evt.where);
|
|
|
|
movemsg.AddInt32("buttons", evt.buttons);
|
2005-03-21 23:29:24 +03:00
|
|
|
movemsg.AddInt32("transit", fViewAction);
|
|
|
|
|
2005-09-05 22:55:32 +04:00
|
|
|
fNotifyLayer->Window()->SendMessageToClient(&movemsg, fNotifyLayer->fViewToken, false);
|
2005-06-03 23:50:30 +04:00
|
|
|
} else {
|
2005-09-05 22:55:32 +04:00
|
|
|
winBorderUnder = (WinBorder*)fNotifyLayer;
|
2005-03-21 23:29:24 +03:00
|
|
|
}
|
2005-06-03 23:50:30 +04:00
|
|
|
} else {
|
2005-09-08 20:53:42 +04:00
|
|
|
if (fLastLayerUnderMouse && fLastLayerUnderMouse != target) {
|
2005-03-21 23:29:24 +03:00
|
|
|
fViewAction = B_EXITED_VIEW;
|
2005-09-08 20:53:42 +04:00
|
|
|
if (fLastLayerUnderMouse->fOwner) {
|
|
|
|
if (fLastLayerUnderMouse != fLastLayerUnderMouse->fOwner->fTopLayer) {
|
2005-03-21 23:29:24 +03:00
|
|
|
BMessage movemsg(B_MOUSE_MOVED);
|
|
|
|
movemsg.AddInt64("when",evt.when);
|
|
|
|
movemsg.AddPoint("where",evt.where);
|
|
|
|
movemsg.AddInt32("buttons",evt.buttons);
|
|
|
|
movemsg.AddInt32("transit",fViewAction);
|
2005-09-08 20:53:42 +04:00
|
|
|
fLastLayerUnderMouse->Window()->SendMessageToClient(&movemsg, fLastLayerUnderMouse->fViewToken, false);
|
2005-03-21 23:29:24 +03:00
|
|
|
}
|
2005-09-08 20:53:42 +04:00
|
|
|
}// else if (fLastLayerUnderMouse != this)
|
|
|
|
// ((WinBorder*)fLastLayerUnderMouse)->MouseMoved(DEC_NONE);
|
2005-03-21 23:29:24 +03:00
|
|
|
|
|
|
|
fViewAction = B_ENTERED_VIEW;
|
2005-06-03 23:50:30 +04:00
|
|
|
} else {
|
2005-03-21 23:29:24 +03:00
|
|
|
fViewAction = B_INSIDE_VIEW;
|
|
|
|
}
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
if (target->fOwner) {
|
|
|
|
if (target != target->fOwner->fTopLayer) {
|
2005-03-21 23:29:24 +03:00
|
|
|
BMessage movemsg(B_MOUSE_MOVED);
|
|
|
|
movemsg.AddInt64("when",evt.when);
|
|
|
|
movemsg.AddPoint("where",evt.where);
|
|
|
|
movemsg.AddInt32("buttons",evt.buttons);
|
|
|
|
movemsg.AddInt32("transit",fViewAction);
|
|
|
|
target->Window()->SendMessageToClient(&movemsg, target->fViewToken, false);
|
|
|
|
}
|
2005-06-03 23:50:30 +04:00
|
|
|
} else if (target != this) {
|
2005-07-07 00:19:22 +04:00
|
|
|
winBorderUnder = (WinBorder*)target;
|
2005-03-21 23:29:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
/* if (winBorderUnder) {
|
2005-03-11 00:34:04 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
BPoint delta = evt.where - fLastMousePosition;
|
2005-04-29 03:56:40 +04:00
|
|
|
|
|
|
|
if (fMovingWindow) {
|
2005-03-11 00:34:04 +03:00
|
|
|
|
2005-04-29 03:56:40 +04:00
|
|
|
winBorderUnder->MoveBy(delta.x, delta.y);
|
2005-03-27 16:19:37 +04:00
|
|
|
|
|
|
|
// I know the way we get BWindow's new location it's not nice :-),
|
|
|
|
// but I don't see another way. fTopLayer.Frame().LeftTop() does not change, ever.
|
|
|
|
BPoint location(winBorderUnder->fTopLayer->fFull.Frame().LeftTop());
|
|
|
|
BMessage msg(B_WINDOW_MOVED);
|
|
|
|
msg.AddPoint("where", location);
|
|
|
|
winBorderUnder->Window()->SendMessageToClient(&msg, B_NULL_TOKEN, false);
|
2005-03-11 00:34:04 +03:00
|
|
|
|
2005-04-29 03:56:40 +04:00
|
|
|
} else if (fResizingWindow) {
|
|
|
|
|
|
|
|
winBorderUnder->ResizeBy(delta.x, delta.y);
|
2005-03-27 16:19:37 +04:00
|
|
|
|
|
|
|
BRect frame(winBorderUnder->fTopLayer->Frame());
|
|
|
|
BMessage msg(B_WINDOW_RESIZED);
|
|
|
|
msg.AddInt32("width", frame.Width());
|
|
|
|
msg.AddInt32("height", frame.Height());
|
|
|
|
winBorderUnder->Window()->SendMessageToClient(&msg, B_NULL_TOKEN, false);
|
2005-04-29 03:56:40 +04:00
|
|
|
|
|
|
|
} else {
|
2005-03-21 23:29:24 +03:00
|
|
|
winBorderUnder->MouseMoved(winBorderUnder->TellWhat(evt));
|
2005-03-11 00:34:04 +03:00
|
|
|
}
|
2005-06-03 23:50:30 +04:00
|
|
|
}*/
|
2005-01-17 00:35:02 +03:00
|
|
|
|
2005-09-08 20:53:42 +04:00
|
|
|
fLastLayerUnderMouse = target;
|
|
|
|
#endif
|
2005-01-17 00:35:02 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-06-03 23:50:30 +04:00
|
|
|
case B_MOUSE_WHEEL_CHANGED: {
|
|
|
|
//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
|
|
|
|
|
|
|
|
PointerEvent evt;
|
|
|
|
evt.code = B_MOUSE_WHEEL_CHANGED;
|
|
|
|
msg.Read<int64>(&evt.when);
|
|
|
|
msg.Read<float>(&evt.wheel_delta_x);
|
|
|
|
msg.Read<float>(&evt.wheel_delta_y);
|
2005-01-20 21:39:08 +03:00
|
|
|
|
2005-09-08 20:53:42 +04:00
|
|
|
if (fLastLayerUnderMouse && fLastLayerUnderMouse != this) {
|
|
|
|
if (fLastLayerUnderMouse->fOwner) { // is a Layer object not a WinBorder one
|
|
|
|
if (fLastLayerUnderMouse->fOwner->fTopLayer != fLastLayerUnderMouse) { // must not be the top_view's counterpart
|
2005-04-15 01:42:32 +04:00
|
|
|
BMessage wheelmsg(B_MOUSE_WHEEL_CHANGED);
|
|
|
|
wheelmsg.AddInt64("when", evt.when);
|
|
|
|
wheelmsg.AddFloat("be:wheel_delta_x",evt.wheel_delta_x);
|
|
|
|
wheelmsg.AddFloat("be:wheel_delta_y",evt.wheel_delta_y);
|
2005-09-08 20:53:42 +04:00
|
|
|
fLastLayerUnderMouse->Window()->SendMessageToClient(&wheelmsg, fLastLayerUnderMouse->fViewToken, false);
|
2005-04-15 01:42:32 +04:00
|
|
|
}
|
2005-06-03 23:50:30 +04:00
|
|
|
} else {
|
2005-04-15 01:42:32 +04:00
|
|
|
// TODO: WinBorder::MouseWheel() should dissapear or get other params!
|
2005-09-08 20:53:42 +04:00
|
|
|
// ((WinBorder*)fLastLayerUnderMouse)->MouseWheel(...)
|
2005-04-15 01:42:32 +04:00
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
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
|
|
|
|
RootLayer::KeyboardEventHandler(int32 code, BPrivate::PortLink& msg)
|
2005-01-17 00:35:02 +03:00
|
|
|
{
|
2005-07-01 15:22:58 +04:00
|
|
|
switch (code) {
|
2005-01-17 00:35:02 +03:00
|
|
|
case B_KEY_DOWN:
|
|
|
|
{
|
|
|
|
// Attached Data:
|
|
|
|
// 1) int64 bigtime_t object of when the message was sent
|
|
|
|
// 2) int32 raw key code (scancode)
|
|
|
|
// 3) int32 modifier-independent ASCII code for the character
|
|
|
|
// 4) int32 repeat count
|
|
|
|
// 5) int32 modifiers
|
|
|
|
// 6) int8[3] UTF-8 data generated
|
2005-03-26 13:40:13 +03:00
|
|
|
// 7) Character string generated by the keystroke
|
|
|
|
// 8) int8[16] state of all keys
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
bigtime_t time;
|
|
|
|
int32 scancode, modifiers;
|
2005-06-25 18:13:30 +04:00
|
|
|
int8 utf[3] = { 0, 0, 0 };
|
2005-01-17 00:35:02 +03:00
|
|
|
char *string = NULL;
|
2005-01-19 21:59:41 +03:00
|
|
|
int8 keystates[16];
|
|
|
|
int32 raw_char;
|
|
|
|
int32 repeatcount;
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
msg.Read<bigtime_t>(&time);
|
|
|
|
msg.Read<int32>(&scancode);
|
2005-01-19 21:59:41 +03:00
|
|
|
msg.Read<int32>(&raw_char);
|
|
|
|
msg.Read<int32>(&repeatcount);
|
2005-01-23 18:39:01 +03:00
|
|
|
msg.Read<int32>(&modifiers);
|
2005-01-17 00:35:02 +03:00
|
|
|
msg.Read(utf, sizeof(utf));
|
|
|
|
msg.ReadString(&string);
|
2005-07-01 15:22:58 +04:00
|
|
|
msg.Read(keystates, sizeof(keystates));
|
|
|
|
|
2005-03-26 00:51:02 +03:00
|
|
|
STRACE(("Key Down: 0x%lx\n",scancode));
|
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"));
|
|
|
|
free(string);
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-09-24 00:34:19 +04:00
|
|
|
WinBorder* exFocus = Focus();
|
|
|
|
WinBorder* exActive = Active();
|
2005-03-29 01:32:24 +04:00
|
|
|
|
2005-07-01 15:22:58 +04:00
|
|
|
if (SetActiveWorkspace(scancode - 2))
|
2005-04-10 23:04:06 +04:00
|
|
|
show_final_scene(exFocus, exActive);
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
SetActiveWorkspace(scancode - 2);
|
|
|
|
#endif
|
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
|
|
|
|
free(string);
|
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-09-23 01:43:23 +04:00
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-09-24 00:34:19 +04:00
|
|
|
WinBorder* exActive = Active();
|
|
|
|
WinBorder* exFocus = Focus();
|
2005-04-12 02:46:48 +04:00
|
|
|
if (ActiveWorkspace()->MoveToBack(exActive))
|
2005-04-12 00:11:46 +04:00
|
|
|
show_final_scene(exFocus, exActive);
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
// TODO: implement;
|
|
|
|
#endif
|
2005-03-29 19:39:08 +04:00
|
|
|
printf("Send Twitcher message key to Deskbar - unimplmemented\n");
|
2005-07-01 15:22:58 +04:00
|
|
|
free(string);
|
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
|
|
|
|
// 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
|
|
|
|
|
|
|
free(string);
|
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-09-24 00:34:19 +04:00
|
|
|
if (Focus()) {
|
|
|
|
ServerWindow *win = Focus()->Window();
|
2005-07-01 15:22:58 +04:00
|
|
|
if (win) {
|
2005-01-19 21:59:41 +03:00
|
|
|
BMessage keymsg(B_KEY_DOWN);
|
2005-03-27 05:57:28 +04:00
|
|
|
keymsg.AddInt64("when", time);
|
|
|
|
keymsg.AddInt32("key", scancode);
|
2005-07-01 15:22:58 +04:00
|
|
|
|
|
|
|
if (repeatcount > 1)
|
2005-03-27 05:57:28 +04:00
|
|
|
keymsg.AddInt32("be:key_repeat", repeatcount);
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-03-27 05:57:28 +04:00
|
|
|
keymsg.AddInt32("modifiers", modifiers);
|
|
|
|
keymsg.AddData("states", B_UINT8_TYPE, keystates, sizeof(int8) * 16);
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-03-27 05:57:28 +04:00
|
|
|
for (uint8 i = 0; i < 3; i++)
|
|
|
|
keymsg.AddInt8("byte", utf[i]);
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-03-27 05:57:28 +04:00
|
|
|
keymsg.AddString("bytes", string);
|
|
|
|
keymsg.AddInt32("raw_char", raw_char);
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-02-07 03:45:59 +03:00
|
|
|
win->SendMessageToClient(&keymsg, B_NULL_TOKEN, true);
|
2005-01-19 21:59:41 +03:00
|
|
|
}
|
|
|
|
}
|
2005-07-01 15:22:58 +04:00
|
|
|
|
|
|
|
free(string);
|
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:
|
|
|
|
{
|
|
|
|
// Attached Data:
|
|
|
|
// 1) int64 bigtime_t object of when the message was sent
|
|
|
|
// 2) int32 raw key code (scancode)
|
|
|
|
// 3) int32 modifier-independent ASCII code for the character
|
|
|
|
// 4) int32 modifiers
|
|
|
|
// 5) int8[3] UTF-8 data generated
|
2005-03-26 13:40:13 +03:00
|
|
|
// 6) Character string generated by the keystroke
|
|
|
|
// 7) int8[16] state of all keys
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
bigtime_t time;
|
2005-01-19 21:59:41 +03:00
|
|
|
int32 scancode, modifiers;
|
2005-06-25 18:13:30 +04:00
|
|
|
int8 utf[3] = { 0, 0, 0 };
|
2005-01-19 21:59:41 +03:00
|
|
|
char *string = NULL;
|
|
|
|
int8 keystates[16];
|
|
|
|
int32 raw_char;
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
msg.Read<bigtime_t>(&time);
|
|
|
|
msg.Read<int32>(&scancode);
|
2005-01-19 21:59:41 +03:00
|
|
|
msg.Read<int32>(&raw_char);
|
2005-01-17 00:35:02 +03:00
|
|
|
msg.Read<int32>(&modifiers);
|
|
|
|
msg.Read(utf, sizeof(utf));
|
|
|
|
msg.ReadString(&string);
|
2005-07-01 15:22:58 +04:00
|
|
|
msg.Read(keystates, sizeof(keystates));
|
|
|
|
|
|
|
|
STRACE(("Key Up: 0x%lx\n", scancode));
|
|
|
|
|
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-09-24 00:34:19 +04:00
|
|
|
if (Focus()) {
|
|
|
|
ServerWindow *win = Focus()->Window();
|
2005-07-01 15:22:58 +04:00
|
|
|
if (win) {
|
2005-01-19 21:59:41 +03:00
|
|
|
BMessage keymsg(B_KEY_UP);
|
2005-03-27 05:57:28 +04:00
|
|
|
keymsg.AddInt64("when", time);
|
|
|
|
keymsg.AddInt32("key", scancode);
|
|
|
|
keymsg.AddInt32("modifiers", modifiers);
|
|
|
|
keymsg.AddData("states", B_UINT8_TYPE, keystates, sizeof(int8) * 16);
|
2005-07-01 15:22:58 +04:00
|
|
|
|
|
|
|
for (uint8 i = 0; i < 3; i++) {
|
2005-03-27 05:57:28 +04:00
|
|
|
keymsg.AddInt8("byte", utf[i]);
|
2005-01-19 21:59:41 +03:00
|
|
|
}
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-03-27 05:57:28 +04:00
|
|
|
keymsg.AddString("bytes", string);
|
|
|
|
keymsg.AddInt32("raw_char", raw_char);
|
2005-07-01 15:22:58 +04:00
|
|
|
|
2005-02-07 03:45:59 +03:00
|
|
|
win->SendMessageToClient(&keymsg, B_NULL_TOKEN, true);
|
2005-01-19 21:59:41 +03:00
|
|
|
}
|
|
|
|
}
|
2005-07-01 15:22:58 +04:00
|
|
|
|
|
|
|
free(string);
|
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:
|
|
|
|
{
|
|
|
|
// Attached Data:
|
|
|
|
// 1) int64 bigtime_t object of when the message was sent
|
|
|
|
// 2) int32 raw key code (scancode)
|
|
|
|
// 3) int32 modifiers
|
2005-01-19 21:59:41 +03:00
|
|
|
// 4) int8 state of all keys
|
2005-01-17 00:35:02 +03:00
|
|
|
|
|
|
|
bigtime_t time;
|
2005-01-19 21:59:41 +03:00
|
|
|
int32 scancode, modifiers;
|
|
|
|
int8 keystates[16];
|
2005-01-17 00:35:02 +03:00
|
|
|
|
|
|
|
msg.Read<bigtime_t>(&time);
|
|
|
|
msg.Read<int32>(&scancode);
|
|
|
|
msg.Read<int32>(&modifiers);
|
2005-01-19 21:59:41 +03:00
|
|
|
msg.Read(keystates,sizeof(int8)*16);
|
|
|
|
|
|
|
|
STRACE(("Unmapped Key Down: 0x%lx\n",scancode));
|
|
|
|
|
2005-09-24 00:34:19 +04:00
|
|
|
if(Focus())
|
2005-01-19 21:59:41 +03:00
|
|
|
{
|
2005-09-24 00:34:19 +04:00
|
|
|
ServerWindow *win = Focus()->Window();
|
2005-01-19 21:59:41 +03:00
|
|
|
if(win)
|
|
|
|
{
|
|
|
|
BMessage keymsg(B_UNMAPPED_KEY_DOWN);
|
2005-03-27 05:57:28 +04:00
|
|
|
keymsg.AddInt64("when", time);
|
|
|
|
keymsg.AddInt32("key", scancode);
|
|
|
|
keymsg.AddInt32("modifiers", modifiers);
|
|
|
|
keymsg.AddData("states", B_UINT8_TYPE, keystates, sizeof(int8) * 16);
|
2005-01-19 21:59:41 +03:00
|
|
|
|
2005-04-15 01:42:32 +04:00
|
|
|
win->SendMessageToClient(&keymsg, B_NULL_TOKEN, true);
|
2005-01-19 21:59:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_UNMAPPED_KEY_UP:
|
|
|
|
{
|
|
|
|
// Attached Data:
|
|
|
|
// 1) int64 bigtime_t object of when the message was sent
|
|
|
|
// 2) int32 raw key code (scancode)
|
|
|
|
// 3) int32 modifiers
|
2005-01-19 21:59:41 +03:00
|
|
|
// 4) int8 state of all keys
|
2005-01-17 00:35:02 +03:00
|
|
|
|
|
|
|
bigtime_t time;
|
2005-01-19 21:59:41 +03:00
|
|
|
int32 scancode, modifiers;
|
|
|
|
int8 keystates[16];
|
2005-01-17 00:35:02 +03:00
|
|
|
|
|
|
|
msg.Read<bigtime_t>(&time);
|
|
|
|
msg.Read<int32>(&scancode);
|
|
|
|
msg.Read<int32>(&modifiers);
|
2005-01-19 21:59:41 +03:00
|
|
|
msg.Read(keystates,sizeof(int8)*16);
|
|
|
|
|
|
|
|
STRACE(("Unmapped Key Up: 0x%lx\n",scancode));
|
|
|
|
|
2005-09-24 00:34:19 +04:00
|
|
|
if(Focus())
|
2005-01-19 21:59:41 +03:00
|
|
|
{
|
2005-09-24 00:34:19 +04:00
|
|
|
ServerWindow *win = Focus()->Window();
|
2005-01-19 21:59:41 +03:00
|
|
|
if(win)
|
|
|
|
{
|
|
|
|
BMessage keymsg(B_UNMAPPED_KEY_UP);
|
2005-03-27 05:57:28 +04:00
|
|
|
keymsg.AddInt64("when", time);
|
|
|
|
keymsg.AddInt32("key", scancode);
|
|
|
|
keymsg.AddInt32("modifiers", modifiers);
|
|
|
|
keymsg.AddData("states", B_UINT8_TYPE, keystates, sizeof(int8) * 16);
|
2005-01-19 21:59:41 +03:00
|
|
|
|
2005-04-15 01:42:32 +04:00
|
|
|
win->SendMessageToClient(&keymsg, B_NULL_TOKEN, true);
|
2005-01-19 21:59:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-17 00:35:02 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_MODIFIERS_CHANGED:
|
|
|
|
{
|
|
|
|
// Attached Data:
|
|
|
|
// 1) int64 bigtime_t object of when the message was sent
|
|
|
|
// 2) int32 modifiers
|
|
|
|
// 3) int32 old modifiers
|
2005-01-19 21:59:41 +03:00
|
|
|
// 4) int8 state of all keys
|
2005-01-17 00:35:02 +03:00
|
|
|
|
|
|
|
bigtime_t time;
|
2005-01-19 21:59:41 +03:00
|
|
|
int32 modifiers,oldmodifiers;
|
|
|
|
int8 keystates[16];
|
2005-01-17 00:35:02 +03:00
|
|
|
|
|
|
|
msg.Read<bigtime_t>(&time);
|
|
|
|
msg.Read<int32>(&modifiers);
|
2005-01-19 21:59:41 +03:00
|
|
|
msg.Read<int32>(&oldmodifiers);
|
|
|
|
msg.Read(keystates,sizeof(int8)*16);
|
2005-01-17 00:35:02 +03:00
|
|
|
|
2005-09-24 00:34:19 +04:00
|
|
|
if(Focus())
|
2005-01-19 21:59:41 +03:00
|
|
|
{
|
2005-09-24 00:34:19 +04:00
|
|
|
ServerWindow *win = Focus()->Window();
|
2005-01-19 21:59:41 +03:00
|
|
|
if(win)
|
|
|
|
{
|
|
|
|
BMessage keymsg(B_MODIFIERS_CHANGED);
|
2005-03-27 05:57:28 +04:00
|
|
|
keymsg.AddInt64("when", time);
|
|
|
|
keymsg.AddInt32("modifiers", modifiers);
|
|
|
|
keymsg.AddInt32("be:old_modifiers", oldmodifiers);
|
|
|
|
keymsg.AddData("states", B_UINT8_TYPE, keystates, sizeof(int8) * 16);
|
2005-01-19 21:59:41 +03:00
|
|
|
|
2005-04-15 01:42:32 +04:00
|
|
|
win->SendMessageToClient(&keymsg, B_NULL_TOKEN, true);
|
2005-01-19 21:59:41 +03:00
|
|
|
}
|
|
|
|
}
|
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-29 01:12:38 +04:00
|
|
|
#ifdef NEW_INPUT_HANDLING
|
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
|
|
|
|
#else
|
2005-09-05 22:55:32 +04:00
|
|
|
if (fNotifyLayer && fNotifyLayer != lay) {
|
|
|
|
fprintf(stderr, "WARNING: fNotifyLayer already set and different than the required one!\n");
|
2005-05-23 21:23:20 +04:00
|
|
|
returnValue = false;
|
2005-07-15 16:45:23 +04:00
|
|
|
} else {
|
2005-09-05 22:55:32 +04:00
|
|
|
fNotifyLayer = lay;
|
2005-05-23 21:23:20 +04:00
|
|
|
// TODO: use this mask and options!
|
|
|
|
}
|
2005-09-03 22:08:49 +04:00
|
|
|
#endif
|
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-09-29 01:12:38 +04:00
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-07-15 16:45:23 +04:00
|
|
|
if (layer == fMouseTargetWinBorder)
|
2005-07-07 18:04:29 +04:00
|
|
|
fMouseTargetWinBorder = NULL;
|
2005-09-29 01:12:38 +04:00
|
|
|
#endif
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-09-24 00:34:19 +04:00
|
|
|
WinBorder* exFocus = Focus();
|
|
|
|
WinBorder* exActive = Active();
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
Workspace::State oldWMState;
|
|
|
|
ActiveWorkspace()->GetState(&oldWMState);
|
|
|
|
#endif
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-04-10 23:04:06 +04:00
|
|
|
show_final_scene(exFocus, exActive);
|
2005-07-01 11:58:22 +04:00
|
|
|
|
|
|
|
if (WorkspacesLayer())
|
2005-07-02 14:37:53 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-07-01 11:58:22 +04:00
|
|
|
GoRedraw(WorkspacesLayer(), fFullVisible);
|
2005-07-02 14:37:53 +04:00
|
|
|
#else
|
|
|
|
GoRedraw(WorkspacesLayer(), FullVisible());
|
|
|
|
#endif
|
2005-09-23 01:43:23 +04:00
|
|
|
|
|
|
|
#else
|
|
|
|
RevealNewWMState(oldWMState);
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-09-24 00:34:19 +04:00
|
|
|
WinBorder* exFocus = Focus();
|
|
|
|
WinBorder* exActive = Active();
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
Workspace::State oldWMState;
|
|
|
|
ActiveWorkspace()->GetState(&oldWMState);
|
|
|
|
#endif
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-04-10 23:04:06 +04:00
|
|
|
show_final_scene(exFocus, exActive);
|
2005-07-01 11:58:22 +04:00
|
|
|
|
|
|
|
if (WorkspacesLayer())
|
2005-07-02 14:37:53 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-07-01 11:58:22 +04:00
|
|
|
GoRedraw(WorkspacesLayer(), fFullVisible);
|
2005-07-02 14:37:53 +04:00
|
|
|
#else
|
|
|
|
GoRedraw(WorkspacesLayer(), FullVisible());
|
|
|
|
#endif
|
2005-09-23 01:43:23 +04:00
|
|
|
|
|
|
|
#else
|
|
|
|
RevealNewWMState(oldWMState);
|
|
|
|
#endif
|
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
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-09-24 00:34:19 +04:00
|
|
|
WinBorder* exFocus = Focus();
|
|
|
|
WinBorder* exActive = Active();
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
|
|
|
Workspace::State oldWMState;
|
|
|
|
ActiveWorkspace()->GetState(&oldWMState);
|
|
|
|
#endif
|
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-05-28 17:43:13 +04:00
|
|
|
gDesktop->SetWinBorderFeel(winBorder, newFeel);
|
2005-04-21 22:57:34 +04: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)
|
2005-09-23 01:43:23 +04:00
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-10-01 14:03:43 +04:00
|
|
|
show_final_scene(exFocus, exActive);
|
2005-09-23 01:43:23 +04:00
|
|
|
#else
|
2005-10-01 14:03:43 +04:00
|
|
|
RevealNewWMState(oldWMState);
|
2005-09-23 01:43:23 +04:00
|
|
|
#endif
|
2005-04-21 22:57:34 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-23 01:43:23 +04:00
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-03-27 14:51:28 +04:00
|
|
|
bool RootLayer::get_workspace_windows()
|
2005-03-13 02:26:05 +03:00
|
|
|
{
|
2005-07-18 21:48:32 +04:00
|
|
|
int32 bufferSize = fWinBorderListLength;
|
|
|
|
int32 exCount = fWinBorderCount;
|
|
|
|
bool present;
|
|
|
|
bool newMemory = false;
|
|
|
|
bool aChange = false;
|
2005-03-13 02:26:05 +03:00
|
|
|
|
2005-03-14 22:25:15 +03:00
|
|
|
memcpy(fWinBorderList2, fWinBorderList, fWinBorderCount * sizeof(WinBorder*));
|
2005-03-13 02:26:05 +03:00
|
|
|
|
|
|
|
if (!(ActiveWorkspace()->GetWinBorderList((void**)fWinBorderList, &bufferSize)))
|
|
|
|
{
|
2005-07-18 21:48:32 +04:00
|
|
|
newMemory = true;
|
2005-03-14 22:25:15 +03:00
|
|
|
// grow by a factor of 8.
|
|
|
|
fWinBorderListLength = (bufferSize / 8 + 1) * 8;
|
2005-07-18 21:48:32 +04:00
|
|
|
fWinBorderList = (WinBorder**)realloc(fWinBorderList, fWinBorderListLength * sizeof(WinBorder*));
|
2005-03-13 02:26:05 +03:00
|
|
|
ActiveWorkspace()->GetWinBorderList((void**)fWinBorderList, &bufferSize);
|
|
|
|
}
|
|
|
|
|
2005-07-01 10:53:07 +04:00
|
|
|
fWinBorderCount = bufferSize;
|
2005-03-13 02:26:05 +03:00
|
|
|
fWinBorderIndex = 0;
|
2005-03-14 22:25:15 +03:00
|
|
|
|
2005-07-01 10:53:07 +04:00
|
|
|
// activate any workspaces layer in the current list
|
|
|
|
|
|
|
|
SetWorkspacesLayer(NULL);
|
|
|
|
|
|
|
|
for (int32 i = 0; i < fWinBorderCount; i++) {
|
2005-07-10 21:16:31 +04:00
|
|
|
if (dynamic_cast<class WorkspacesLayer *>(fWinBorderList[i]->FirstChild()) != NULL)
|
|
|
|
SetWorkspacesLayer(fWinBorderList[i]->FirstChild());
|
2005-07-01 10:53:07 +04:00
|
|
|
}
|
|
|
|
|
2005-03-27 14:51:28 +04:00
|
|
|
// to determine if there was a change in window hierarchy
|
2005-07-18 21:48:32 +04:00
|
|
|
if (exCount != fWinBorderCount || memcmp(fWinBorderList, fWinBorderList2, fWinBorderCount * sizeof(WinBorder*)) != 0)
|
2005-03-27 14:51:28 +04:00
|
|
|
aChange = true;
|
|
|
|
|
2005-04-14 01:32:23 +04:00
|
|
|
if (aChange)
|
2005-03-14 22:25:15 +03:00
|
|
|
{
|
2005-04-14 01:32:23 +04:00
|
|
|
// clear visible and full visible regions for windows not visible anymore.
|
|
|
|
for (int32 i = 0; i < exCount; i++)
|
|
|
|
{
|
|
|
|
present = false;
|
2005-03-14 22:25:15 +03:00
|
|
|
|
2005-04-14 01:32:23 +04:00
|
|
|
for (int32 j = 0; j < fWinBorderCount; j++)
|
|
|
|
if (fWinBorderList2[i] == fWinBorderList[j])
|
|
|
|
present = true;
|
2005-03-14 22:25:15 +03:00
|
|
|
|
2005-04-14 01:32:23 +04:00
|
|
|
if (!present)
|
2005-06-22 00:11:44 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-04-14 01:32:23 +04:00
|
|
|
empty_visible_regions(fWinBorderList2[i]);
|
2005-06-22 00:11:44 +04:00
|
|
|
#else
|
|
|
|
fWinBorderList2[i]->clear_visible_regions();
|
|
|
|
#endif
|
2005-04-14 01:32:23 +04:00
|
|
|
}
|
2005-03-14 22:25:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// enlarge 2nd buffer also
|
|
|
|
if (newMemory)
|
2005-07-18 21:48:32 +04:00
|
|
|
fWinBorderList2 = (WinBorder**)realloc(fWinBorderList2, fWinBorderListLength * sizeof(WinBorder*));
|
2005-03-14 22:25:15 +03:00
|
|
|
|
2005-03-13 20:07:40 +03:00
|
|
|
//for (int32 i = 0; i < fWinBorderCount; i++)
|
|
|
|
//{
|
|
|
|
// printf("Adi: %ld get_workspace_windows(%p)\n", i, fWinBorderList[i]);
|
|
|
|
//}
|
|
|
|
//printf("Adi: get_workspace_windows DONE\n");
|
2005-03-27 14:51:28 +04:00
|
|
|
return aChange;
|
2005-03-13 20:07:40 +03:00
|
|
|
}
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
RootLayer::draw_window_tab(WinBorder *exFocus)
|
2005-03-13 22:53:44 +03:00
|
|
|
{
|
2005-09-24 00:34:19 +04:00
|
|
|
WinBorder *focus = Focus();
|
2005-06-03 23:50:30 +04:00
|
|
|
if (exFocus || focus) {
|
2005-03-13 22:53:44 +03:00
|
|
|
if (exFocus && exFocus != focus && exFocus->fDecorator)
|
|
|
|
exFocus->fDecorator->SetFocus(false);
|
|
|
|
if (focus && exFocus != focus && focus->fDecorator)
|
|
|
|
focus->fDecorator->SetFocus(true);
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
if (exFocus && focus != exFocus) {
|
2005-03-13 22:53:44 +03:00
|
|
|
// TODO: this line is a hack, decorator is drawn twice.
|
2005-06-17 00:43:53 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-07-07 00:19:22 +04:00
|
|
|
BRegion reg(exFocus->fVisible);
|
2005-03-13 22:53:44 +03:00
|
|
|
if (focus)
|
|
|
|
reg.Include(&focus->fVisible);
|
|
|
|
redraw_layer(this, reg);
|
2005-06-17 00:43:53 +04:00
|
|
|
#endif
|
2005-03-13 22:53:44 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-09-23 01:43:23 +04:00
|
|
|
#endif
|
2005-03-14 22:25:15 +03: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-09-23 01:43:23 +04:00
|
|
|
#ifndef NEW_INPUT_HANDLING
|
2005-09-19 02:43:31 +04:00
|
|
|
void
|
2005-06-03 23:50:30 +04:00
|
|
|
RootLayer::winborder_activation(WinBorder* exActive)
|
2005-03-27 17:52:26 +04:00
|
|
|
{
|
2005-07-07 00:19:22 +04:00
|
|
|
// ToDo: not sure if this is correct - do floating windows get WindowActivated() events?
|
2005-09-24 00:34:19 +04:00
|
|
|
if (exActive && Focus() != exActive) {
|
2005-06-03 23:50:30 +04:00
|
|
|
BMessage msg(B_WINDOW_ACTIVATED);
|
2005-03-27 17:52:26 +04:00
|
|
|
msg.AddBool("active", false);
|
|
|
|
exActive->Window()->SendMessageToClient(&msg, B_NULL_TOKEN, false);
|
|
|
|
}
|
2005-09-24 00:34:19 +04:00
|
|
|
if (Focus() && Focus() != exActive) {
|
2005-06-03 23:50:30 +04:00
|
|
|
BMessage msg(B_WINDOW_ACTIVATED);
|
2005-03-27 17:52:26 +04:00
|
|
|
msg.AddBool("active", true);
|
2005-09-24 00:34:19 +04:00
|
|
|
Focus()->Window()->SendMessageToClient(&msg, B_NULL_TOKEN, false);
|
2005-03-27 17:52:26 +04:00
|
|
|
}
|
|
|
|
}
|
2005-04-10 23:04:06 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-09-19 02:43:31 +04:00
|
|
|
void
|
2005-06-03 23:50:30 +04:00
|
|
|
RootLayer::show_final_scene(WinBorder *exFocus, WinBorder *exActive)
|
2005-04-10 23:04:06 +04:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
if (fHaveWinBorderList || get_workspace_windows()) {
|
2005-04-14 01:47:44 +04:00
|
|
|
// next call should call get_workspace_windows()
|
|
|
|
fHaveWinBorderList = false;
|
2005-04-10 23:04:06 +04:00
|
|
|
// TODO: should it be improved by calling with region of hidden windows
|
|
|
|
// plus the full regions of new windows???
|
2005-06-16 23:44:55 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-06-22 00:11:44 +04:00
|
|
|
invalidate_layer(this, fFull);
|
2005-06-16 23:44:55 +04:00
|
|
|
#else
|
2005-06-22 00:11:44 +04:00
|
|
|
// TODO: hmm. Bounds()? Yes, this its OK, for the moment!!! think!
|
|
|
|
do_Invalidate(Bounds());
|
2005-06-16 23:44:55 +04:00
|
|
|
#endif
|
2005-04-10 23:04:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
draw_window_tab(exFocus);
|
|
|
|
winborder_activation(exActive);
|
|
|
|
|
|
|
|
// TODO: MoveEventHandler::B_MOUSE_DOWN may not need this. Investigate.
|
|
|
|
// TODO: B_ENTERD_VIEW, B_EXITED_VIEW, B_INSIDE_VIEW, B_OUTSIDE_VIEW are sent only
|
|
|
|
// when the mouse is moved. What about when adding or removing a window that contains
|
2005-09-08 20:53:42 +04:00
|
|
|
// fLastLayerUnderMouse, shouldn't the next fLastLayerUnderMouse Layer get a B_MOUSE_MOVE at
|
2005-04-10 23:04:06 +04:00
|
|
|
// the same mouse position with B_ENTERD_VIEW??? Same when changing workspaces!!!
|
|
|
|
// INVESTIGATE, INVESTIGATE, INVESTIGATE!!!
|
|
|
|
// NOTE: the following 3 lines are here for safety reasons!
|
2005-09-08 20:53:42 +04:00
|
|
|
fLastLayerUnderMouse = LayerAt(fLastMousePosition);
|
|
|
|
if (fLastLayerUnderMouse == NULL) {
|
|
|
|
CRITICAL("RootLayer::show_final_scene: 'fLastLayerUnderMouse' can't be null.\n");
|
|
|
|
fLastLayerUnderMouse = this;
|
2005-06-03 23:50:30 +04:00
|
|
|
}
|
2005-04-18 22:48:19 +04:00
|
|
|
}
|
2005-09-23 01:43:23 +04:00
|
|
|
#endif
|
2005-07-07 00:19:22 +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
|