Esempio n. 1
0
/*!
	\brief Retrieves a cursor from the set.
	\param which System cursor specifier defined in CursorSet.h
	\param cursor ServerCursor** to receive a newly-allocated ServerCursor containing the appropriate data
	\return
	- \c B_OK: Success
	- \c B_BAD_VALUE: a NULL parameter was passed
	- \c B_NAME_NOT_FOUND: The specified cursor does not exist in this set
	- \c B_ERROR: An internal error occurred
	
	BBitmaps created by this function are the responsibility of the caller.
*/
status_t
CursorSet::FindCursor(BCursorID which, ServerCursor **_cursor) const
{
	BMessage msg;
	if (FindMessage(_CursorWhichToString(which), &msg) != B_OK)
		return B_NAME_NOT_FOUND;

	const char *className;
	BPoint hotspot;

	if (msg.FindString("class", &className) != B_OK)
		return B_ERROR;

	if (msg.FindPoint("hotspot", &hotspot) != B_OK)
		return B_ERROR;

	if (strcmp(className, "cursor") == 0) {
		ServerCursor *cursor = new ServerCursor(msg.FindRect("_frame"),
			(color_space)msg.FindInt32("_cspace"), 0, hotspot);

		const void *buffer;
		int32 bufferLength;
		msg.FindData("_data",B_RAW_TYPE, (const void **)&buffer,
			(ssize_t *)&bufferLength);
		memcpy(cursor->Bits(), buffer, bufferLength);

		*_cursor = cursor;
		return B_OK;
	}
	return B_ERROR;
}
Esempio n. 2
0
/*!
	\brief Retrieves a cursor from the set.
	\param which System cursor specifier defined in CursorSet.h
	\param cursor Bitmap** to receive a newly-allocated BBitmap containing the appropriate data
	\param hotspot The recipient of the hotspot for the cursor
	\return
	- \c B_OK: Success
	- \c B_BAD_VALUE: a NULL parameter was passed
	- \c B_NAME_NOT_FOUND: The specified cursor does not exist in this set
	- \c B_ERROR: An internal error occurred
	
	BBitmaps created by this function are the responsibility of the caller.
*/
status_t
CursorSet::FindCursor(BCursorID which, BBitmap **cursor, BPoint *hotspot)
{
	if (!cursor || !hotspot)
		return B_BAD_VALUE;

	BMessage msg;
	if (FindMessage(_CursorWhichToString(which), &msg) != B_OK)
		return B_NAME_NOT_FOUND;

	const void *buffer;
	const char *tempstr;
	int32 bufferLength;
	BBitmap *bmp;
	BPoint hotpt;

	if (msg.FindString("class", &tempstr) != B_OK)
		return B_ERROR;

	if (msg.FindPoint("hotspot", &hotpt) != B_OK)
		return B_ERROR;

	if (strcmp(tempstr, "cursor") == 0) {
		bmp = new BBitmap(msg.FindRect("_frame"),
			(color_space)msg.FindInt32("_cspace"), true);
		msg.FindData("_data", B_RAW_TYPE, (const void **)&buffer,
			(ssize_t *)&bufferLength);
		memcpy(bmp->Bits(), buffer, bufferLength);

		*cursor = bmp;
		*hotspot = hotpt;
		return B_OK;
	}
	return B_ERROR;
}
Esempio n. 3
0
void
BShelf::_InitData(BEntry *entry, BDataIO *stream, BView *view,
	bool allowDrags)
{
	fContainerView = view;
	fStream = NULL;
	fEntry = entry;
	fFilter = NULL;
	fGenCount = 1;
	fAllowDragging = allowDrags;
	fDirty = true;
	fDisplayZombies = false;
	fAllowZombies = true;
	fTypeEnforced = false;

	if (entry)
		fStream = new BFile(entry, B_READ_ONLY);
	else
		fStream = stream;

	fFilter = new ShelfContainerViewFilter(this, fContainerView);

	fContainerView->AddFilter(fFilter);
	fContainerView->_SetShelf(this);

	if (fStream) {
		BMessage archive;

		if (archive.Unflatten(fStream) == B_OK) {
			bool allowZombies;
			if (archive.FindBool("_zom_dsp", &allowZombies) != B_OK)
				allowZombies = false;

			SetDisplaysZombies(allowZombies);

			if (archive.FindBool("_zom_alw", &allowZombies) != B_OK)
				allowZombies = true;

			SetAllowsZombies(allowZombies);

			int32 genCount;
			if (!archive.FindInt32("_sg_cnt", &genCount))
				genCount = 1;

			BMessage replicant;
			BMessage *replmsg = NULL;
			for (int32 i = 0; archive.FindMessage("replicant", i, &replicant) == B_OK; i++) {
				BPoint point;
				replmsg = new BMessage();
				replicant.FindPoint("position", &point);
				replicant.FindMessage("message", replmsg);
				AddReplicant(replmsg, point);
			}
		}
	}
}
Esempio n. 4
0
void
NSBrowserFrameView::MouseDown(BPoint where)
{
	BMessage *message = Window()->DetachCurrentMessage();
	BPoint screenWhere;
	if (message->FindPoint("screen_where", &screenWhere) < B_OK) {
		screenWhere = ConvertToScreen(where);
		message->AddPoint("screen_where", screenWhere);
	}
	nsbeos_pipe_message(message, this, fGuiWindow);
}
Esempio n. 5
0
BackgroundImage *
BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop)
{
	attr_info info;
	if (node->GetAttrInfo(kBackgroundImageInfo, &info) != B_OK)
		return NULL;
	
	BMessage container;
	char *buffer = new char [info.size];

	status_t error = node->ReadAttr(kBackgroundImageInfo, info.type, 0, buffer, (size_t)info.size);
	if (error == info.size)
		error = container.Unflatten(buffer);

	delete [] buffer;

	if (error != B_OK)
		return NULL;

	BackgroundImage *result = NULL;
	for (int32 index = 0; ; index++) {
		const char *path;
		uint32 workspaces = B_ALL_WORKSPACES;
		Mode mode = kTiled;
		bool textWidgetLabelOutline = false;
		BPoint offset;
		BBitmap *bitmap = NULL;

		if (container.FindString(kBackgroundImageInfoPath, index, &path) == B_OK) {	
			bitmap = BTranslationUtils::GetBitmap(path);
			if (!bitmap) {
				PRINT(("failed to load background bitmap from path\n"));
			}
		} else
			break;

		container.FindInt32(kBackgroundImageInfoWorkspaces, index, (int32 *)&workspaces);
		container.FindInt32(kBackgroundImageInfoMode, index, (int32 *)&mode);
		container.FindBool(kBackgroundImageInfoTextOutline, index, &textWidgetLabelOutline);
		container.FindPoint(kBackgroundImageInfoOffset, index, &offset);

		BackgroundImage::BackgroundImageInfo *imageInfo = new
			BackgroundImage::BackgroundImageInfo(workspaces, bitmap, mode, offset,
				textWidgetLabelOutline);

		if (!result)
			result = new BackgroundImage(node, isDesktop);

		result->Add(imageInfo);
	}
	return result;
}
Esempio n. 6
0
BViewState::BViewState(const BMessage &message)
{
	message.FindInt32(kViewStateViewModeName, (int32 *)&fViewMode);
	message.FindInt32(kViewStateLastIconModeName, (int32 *)&fLastIconMode);
	message.FindPoint(kViewStateListOriginName, &fListOrigin);
	message.FindPoint(kViewStateIconOriginName, &fIconOrigin);
	message.FindInt32(kViewStatePrimarySortAttrName, (int32 *)&fPrimarySortAttr);
	message.FindInt32(kViewStatePrimarySortTypeName, (int32 *)&fPrimarySortType);
	message.FindInt32(kViewStateSecondarySortAttrName, (int32 *)&fSecondarySortAttr);
	message.FindInt32(kViewStateSecondarySortTypeName, (int32 *)&fSecondarySortType);
	message.FindBool(kViewStateReverseSortName, &fReverseSort);
	
	fStateNeedsSaving = false;
}
Esempio n. 7
0
void
CannaMethod::ReadSettings()
{
	BMessage pref;
	BFile preffile( CANNAIM_SETTINGS_FILE, B_READ_ONLY );
	if ( preffile.InitCheck() == B_NO_ERROR && pref.Unflatten( &preffile ) == B_OK )
	{
		pref.FindBool( "arrowkey", &gSettings.convert_arrowkey );
		pref.FindPoint( "palette", &gSettings.palette_loc );
		pref.FindPoint( "standalone", &gSettings.standalone_loc );
#ifdef DEBUG
SERIAL_PRINT(( "CannaMethod: ReadSettings() success. arrowkey=%d, palette_loc=%d,%d standalone_loc=%d, %d\n", gSettings.convert_arrowkey, gSettings.palette_loc.x, gSettings.palette_loc.y, gSettings.standalone_loc.x, gSettings.standalone_loc.y ));
#endif
		return;
	}

	//set default values
#ifdef DEBUG
SERIAL_PRINT(( "CannaMethod: ReadSettings() failed.\n" ));
#endif
	gSettings.convert_arrowkey = true;
	gSettings.palette_loc.Set( 800, 720 );
	gSettings.standalone_loc.Set( 256, 576 );
}
//------------------------------------------------------------------------------
void TMessageEasyFindTest::MessageEasyFindTest1()
{
	BRect r(0, 0, -1, -1);
	BPoint p(0, 0);
	BMessage msg;
	CPPUNIT_ASSERT(msg.FindRect("data") == r);
	CPPUNIT_ASSERT(msg.FindPoint("data") == p);
	CPPUNIT_ASSERT(msg.FindString("data") == NULL);
	CPPUNIT_ASSERT(msg.FindInt8("data") == 0);
	CPPUNIT_ASSERT(msg.FindInt16("data") == 0);
	CPPUNIT_ASSERT(msg.FindInt32("data") == 0);
	CPPUNIT_ASSERT(msg.FindInt64("data") == 0);
	CPPUNIT_ASSERT(msg.FindBool("data") == false);
	CPPUNIT_ASSERT(msg.FindFloat("data") == 0);
	CPPUNIT_ASSERT(msg.FindDouble("data") == 0);
}
Esempio n. 9
0
FontsSettings::FontsSettings()
{
	BPath path;
	BMessage msg;

	if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
		path.Append(kSettingsFile);
		BFile file(path.Path(), B_READ_ONLY);

		if (file.InitCheck() != B_OK)
			SetDefaults();
		else if (msg.Unflatten(&file) != B_OK)
			SetDefaults();
		else
			msg.FindPoint("windowlocation", &fCorner);
	}
}
Esempio n. 10
0
void
ResizeView::MouseMoved (BPoint, uint32, const BMessage *)
{
  SetViewCursor (&cursor);
  if (mousePressed)
  {
    BWindow *window (Window ());
    BMessage *windowmsg (window->CurrentMessage());
    BPoint windowCoord;
    windowmsg->FindPoint ("where", &windowCoord);
    BMessage msg (kResizeMessage);
    if (windowCoord.x <= 0.0 || windowCoord.x >= window->Bounds().right)
      return;
    msg.AddPoint ("loc", windowCoord);
    msg.AddPointer ("view", attachedView);
    BMessenger(window).SendMessage (&msg);
  }
}
Esempio n. 11
0
void
FolderShaper::ReadSettings()
{
	status_t	status;
	BMessage	settings;
	status	=	settings.Unflatten(m_settings_file);
	if (status != B_OK)
		ErrorMessage("Unflatten()", status);
	
	BPoint loc;
	if (settings.FindPoint("winloc",&loc) == B_OK)	m_winloc = loc;
	
	bool a;
	int8 b;
	if (settings.FindBool("do_move", &a) == B_OK)			m_do_move = a;
	if (settings.FindInt8("do_open", &b) == B_OK)			m_do_open = b;
	if (settings.FindBool("do_clobber", &a) == B_OK)		m_do_clobber = a;
	if (settings.FindBool("do_keep_position", &a) == B_OK)	m_do_keep_position = a;
	if (settings.FindBool("do_clean_up", &a) == B_OK)		m_do_clean_up = a;
}
Esempio n. 12
0
BViewState::BViewState(const BMessage &message)
{
	_Init();
	message.FindInt32(kViewStateViewModeName, (int32*)&fViewMode);
	message.FindInt32(kViewStateLastIconModeName, (int32*)&fLastIconMode);
	message.FindInt32(kViewStateLastIconSizeName,(int32*)&fLastIconSize);
	message.FindInt32(kViewStateIconSizeName, (int32*)&fIconSize);
	message.FindPoint(kViewStateListOriginName, &fListOrigin);
	message.FindPoint(kViewStateIconOriginName, &fIconOrigin);
	message.FindInt32(kViewStatePrimarySortAttrName,
		(int32*)&fPrimarySortAttr);
	message.FindInt32(kViewStatePrimarySortTypeName,
		(int32*)&fPrimarySortType);
	message.FindInt32(kViewStateSecondarySortAttrName,
		(int32*)&fSecondarySortAttr);
	message.FindInt32(kViewStateSecondarySortTypeName,
		(int32*)&fSecondarySortType);
	message.FindBool(kViewStateReverseSortName, &fReverseSort);

	_StorePreviousState();
	_Sanitize(this, true);
}
Esempio n. 13
0
status_t
TMailApp::LoadSettings()
{
	BMailSettings accountSettings;
	fDefaultAccount = accountSettings.DefaultOutboundAccount();

	BPath path;
	status_t status = GetSettingsPath(path);
	if (status != B_OK)
		return status;

	path.Append("BeMail Settings");

	BFile file;
	status = file.SetTo(path.Path(), B_READ_ONLY);
	if (status != B_OK)
		return LoadOldSettings();

	BMessage settings;
	status = settings.Unflatten(&file);
	if (status < B_OK || settings.what != 'BeMl') {
		// the current settings are corrupted, try old ones
		return LoadOldSettings();
	}

	BRect rect;
	if (settings.FindRect("MailWindowSize", &rect) == B_OK)
		fMailWindowFrame = rect;

	int32 int32Value;
//	if (settings.FindInt32("ExperienceLevel", &int32Value) == B_OK)
//		level = int32Value;

	const char *fontFamily;
	if (settings.FindString("FontFamily", &fontFamily) == B_OK) {
		const char *fontStyle;
		if (settings.FindString("FontStyle", &fontStyle) == B_OK) {
			float size;
			if (settings.FindFloat("FontSize", &size) == B_OK) {
				if (size >= 7)
					fContentFont.SetSize(size);

				if (fontFamily[0] && fontStyle[0]) {
					fContentFont.SetFamilyAndStyle(fontFamily[0] ? fontFamily : NULL,
						fontStyle[0] ? fontStyle : NULL);
				}
			}
		}
	}

	if (settings.FindRect("SignatureWindowSize", &rect) == B_OK)
		fSignatureWindowFrame = rect;

	bool boolValue;
	if (settings.FindBool("WordWrapMode", &boolValue) == B_OK)
		fWrapMode = boolValue;

	BPoint point;
	if (settings.FindPoint("PreferencesWindowLocation", &point) == B_OK)
		fPrefsWindowPos = point;

	if (settings.FindBool("AutoMarkRead", &boolValue) == B_OK)
		fAutoMarkRead = boolValue;

	const char *string;
	if (settings.FindString("SignatureText", &string) == B_OK) {
		free(fSignature);
		fSignature = strdup(string);
	}

	if (settings.FindInt32("CharacterSet", &int32Value) == B_OK)
		fMailCharacterSet = int32Value;
	if (fMailCharacterSet != B_MAIL_UTF8_CONVERSION
		&& fMailCharacterSet != B_MAIL_US_ASCII_CONVERSION
		&& BCharacterSetRoster::GetCharacterSetByConversionID(fMailCharacterSet) == NULL)
		fMailCharacterSet = B_MS_WINDOWS_CONVERSION;

	if (settings.FindString("FindString", &string) == B_OK)
		FindWindow::SetFindString(string);

	int8 int8Value;
	if (settings.FindInt8("ShowButtonBar", &int8Value) == B_OK)
		fShowToolBar = int8Value;

	if (settings.FindInt32("UseAccountFrom", &int32Value) == B_OK)
		fUseAccountFrom = int32Value;
	if (fUseAccountFrom < ACCOUNT_USE_DEFAULT
		|| fUseAccountFrom > ACCOUNT_FROM_MAIL)
		fUseAccountFrom = ACCOUNT_USE_DEFAULT;

	if (settings.FindBool("ColoredQuotes", &boolValue) == B_OK)
		fColoredQuotes = boolValue;

	if (settings.FindString("ReplyPreamble", &string) == B_OK) {
		free(fReplyPreamble);
		fReplyPreamble = strdup(string);
	}

	if (settings.FindBool("AttachAttributes", &boolValue) == B_OK)
		fAttachAttributes = boolValue;

	if (settings.FindBool("WarnAboutUnencodableCharacters", &boolValue) == B_OK)
		fWarnAboutUnencodableCharacters = boolValue;

	if (settings.FindBool("StartWithSpellCheck", &boolValue) == B_OK)
		fStartWithSpellCheckOn = boolValue;

	return B_OK;
}
Esempio n. 14
0
void
BShelf::_InitData(BEntry *entry, BDataIO *stream, BView *view,
	bool allowDrags)
{
	fContainerView = view;
	fStream = NULL;
	fEntry = entry;
	fFilter = NULL;
	fGenCount = 1;
	fAllowDragging = allowDrags;
	fDirty = true;
	fDisplayZombies = false;
	fAllowZombies = true;
	fTypeEnforced = false;

	if (fEntry != NULL)
		fStream = new BFile(entry, B_READ_ONLY);
	else
		fStream = stream;

	fFilter = new ShelfContainerViewFilter(this, fContainerView);

	fContainerView->AddFilter(fFilter);
	fContainerView->_SetShelf(this);

	if (fStream != NULL) {
		BMessage archive;

		if (archive.Unflatten(fStream) == B_OK) {
			bool allowZombies;
			if (archive.FindBool("_zom_dsp", &allowZombies) != B_OK)
				allowZombies = false;

			SetDisplaysZombies(allowZombies);

			if (archive.FindBool("_zom_alw", &allowZombies) != B_OK)
				allowZombies = true;

			SetAllowsZombies(allowZombies);

			int32 genCount;
			if (!archive.FindInt32("_sg_cnt", &genCount))
				genCount = 1;

			BMessage replicant;
			for (int32 i = 0; archive.FindMessage("replicant", i, &replicant)
				== B_OK; i++) {
				BPoint point;
				BMessage *replMsg = new BMessage();
				ObjectDeleter<BMessage> deleter(replMsg);
				replicant.FindPoint("position", &point);
				if (replicant.FindMessage("message", replMsg) == B_OK)
					if (AddReplicant(replMsg, point) == B_OK) {
						// Detach the deleter since AddReplicant is taking
						// ownership on success. In R2 API this should be
						// changed to take always ownership on the message.
						deleter.Detach();
					}
			}
		}
	}
}
void
EventDispatcher::_EventLoop()
{
	BMessage* event;
	while (fStream->GetNextEvent(&event)) {
		BAutolock _(this);
		fLastUpdate = system_time();

		EventTarget* current = NULL;
		EventTarget* previous = NULL;
		bool pointerEvent = false;
		bool keyboardEvent = false;
		bool addedTokens = false;

		switch (event->what) {
			case kFakeMouseMoved:
				_SendFakeMouseMoved(event);
				break;
			case B_MOUSE_MOVED:
			{
				BPoint where;
				if (event->FindPoint("where", &where) == B_OK)
					fLastCursorPosition = where;

				if (fDraggingMessage)
					event->AddMessage("be:drag_message", &fDragMessage);

				if (!HasCursorThread()) {
					// There is no cursor thread, we need to move the cursor
					// ourselves
					BAutolock _(fCursorLock);

					if (fHWInterface != NULL) {
						fHWInterface->MoveCursorTo(fLastCursorPosition.x,
							fLastCursorPosition.y);
					}
				}

				// This is for B_NO_POINTER_HISTORY - we always want the
				// latest mouse moved event in the queue only
				if (fNextLatestMouseMoved == NULL)
					fNextLatestMouseMoved = fStream->PeekLatestMouseMoved();
				else if (fNextLatestMouseMoved != event) {
					// Drop older mouse moved messages if the server is lagging
					// too much (if the message is older than 100 msecs)
					bigtime_t eventTime;
					if (event->FindInt64("when", &eventTime) == B_OK) {
						if (system_time() - eventTime > 100000)
							break;
					}
				}

				// supposed to fall through
			}
			case B_MOUSE_DOWN:
			case B_MOUSE_UP:
			{
#ifdef TRACE_EVENTS
				if (event->what != B_MOUSE_MOVED)
					printf("mouse up/down event, previous target = %p\n", fPreviousMouseTarget);
#endif
				pointerEvent = true;

				if (fMouseFilter == NULL)
					break;

				EventTarget* mouseTarget = fPreviousMouseTarget;
				int32 viewToken = B_NULL_TOKEN;
				if (fMouseFilter->Filter(event, &mouseTarget, &viewToken,
						fNextLatestMouseMoved) == B_SKIP_MESSAGE) {
					// this is a work-around if the wrong B_MOUSE_UP
					// event is filtered out
					if (event->what == B_MOUSE_UP
						&& event->FindInt32("buttons") == 0) {
						fSuspendFocus = false;
						_RemoveTemporaryListeners();
					}
					break;
				}

				int32 buttons;
				if (event->FindInt32("buttons", &buttons) == B_OK)
					fLastButtons = buttons;
				else
					fLastButtons = 0;

				// The "where" field will be filled in by the receiver
				// (it's supposed to be expressed in local window coordinates)
				event->RemoveName("where");
				event->AddPoint("screen_where", fLastCursorPosition);

				if (event->what == B_MOUSE_MOVED
					&& fPreviousMouseTarget != NULL
					&& mouseTarget != fPreviousMouseTarget) {
					// Target has changed, we need to notify the previous target
					// that the mouse has exited its views
					addedTokens = _AddTokens(event, fPreviousMouseTarget,
						B_POINTER_EVENTS);
					if (addedTokens)
						_SetFeedFocus(event);

					_SendMessage(fPreviousMouseTarget->Messenger(), event,
						kMouseTransitImportance);
					previous = fPreviousMouseTarget;
				}

				current = fPreviousMouseTarget = mouseTarget;

				if (current != NULL) {
					int32 focusView = viewToken;
					addedTokens |= _AddTokens(event, current, B_POINTER_EVENTS,
						fNextLatestMouseMoved, &focusView);

					bool noPointerHistoryFocus = focusView != viewToken;

					if (viewToken != B_NULL_TOKEN)
						event->AddInt32("_view_token", viewToken);

					if (addedTokens && !noPointerHistoryFocus)
						_SetFeedFocus(event);
					else if (noPointerHistoryFocus) {
						// No tokens were added or the focus shouldn't get a
						// mouse moved
						break;
					}

					_SendMessage(current->Messenger(), event,
						event->what == B_MOUSE_MOVED
							? kMouseMovedImportance : kStandardImportance);
				}
				break;
			}

			case B_KEY_DOWN:
			case B_KEY_UP:
			case B_UNMAPPED_KEY_DOWN:
			case B_UNMAPPED_KEY_UP:
			case B_MODIFIERS_CHANGED:
			case B_INPUT_METHOD_EVENT:
				ETRACE(("key event, focus = %p\n", fFocus));

				if (fKeyboardFilter != NULL
					&& fKeyboardFilter->Filter(event, &fFocus) == B_SKIP_MESSAGE)
					break;

				keyboardEvent = true;

				if (fFocus != NULL && _AddTokens(event, fFocus,
						B_KEYBOARD_EVENTS)) {
					// if tokens were added, we need to explicetly suspend
					// focus in the event - if not, the event is simply not
					// forwarded to the target
					addedTokens = true;

					if (!fSuspendFocus)
						_SetFeedFocus(event);
				}

				// supposed to fall through

			default:
				// TODO: the keyboard filter sets the focus - ie. no other
				//	focus messages that go through the event dispatcher can
				//	go through.
				if (event->what == B_MOUSE_WHEEL_CHANGED)
					current = fPreviousMouseTarget;
				else
					current = fFocus;

				if (current != NULL && (!fSuspendFocus || addedTokens)) {
					_SendMessage(current->Messenger(), event,
						kStandardImportance);
				}
				break;
		}

		if (keyboardEvent || pointerEvent) {
			// send the event to the additional listeners

			if (addedTokens) {
				_RemoveTokens(event);
				_UnsetFeedFocus(event);
			}
			if (pointerEvent) {
				// this is added in the Desktop mouse processing
				// but it's only intended for the focus view
				event->RemoveName("_view_token");
			}

			for (int32 i = fTargets.CountItems(); i-- > 0;) {
				EventTarget* target = fTargets.ItemAt(i);

				// We already sent the event to the all focus and last focus
				// tokens
				if (current == target || previous == target)
					continue;

				// Don't send the message if there are no tokens for this event
				if (!_AddTokens(event, target,
						keyboardEvent ? B_KEYBOARD_EVENTS : B_POINTER_EVENTS,
						event->what == B_MOUSE_MOVED
							? fNextLatestMouseMoved : NULL))
					continue;

				if (!_SendMessage(target->Messenger(), event,
						event->what == B_MOUSE_MOVED
							? kMouseMovedImportance : kListenerImportance)) {
					// the target doesn't seem to exist anymore, let's remove it
					fTargets.RemoveItemAt(i);
				}
			}

			if (event->what == B_MOUSE_UP && fLastButtons == 0) {
				// no buttons are pressed anymore
				fSuspendFocus = false;
				_RemoveTemporaryListeners();
				if (fDraggingMessage)
					_DeliverDragMessage();
			}
		}

		if (fNextLatestMouseMoved == event)
			fNextLatestMouseMoved = NULL;
		delete event;
	}

	// The loop quit, therefore no more events are coming from the input
	// server, it must have died. Unset ourselves and notify the desktop.
	fThread = -1;
		// Needed to avoid problems with wait_for_thread in _Unset()
	_Unset();

	if (fDesktop)
		fDesktop->PostMessage(AS_EVENT_STREAM_CLOSED);
}
Esempio n. 16
0
void
TBarApp::InitSettings()
{
	desk_settings settings;
	settings.vertical = true;
	settings.left = false;
	settings.top = true;
	settings.ampmMode = true;
	settings.showTime = true;
	settings.state = kExpandoState;
	settings.width = 0;
	settings.switcherLoc = BPoint(5000, 5000);
	settings.recentAppsCount = 10;
	settings.recentDocsCount = 10;
	settings.timeShowSeconds = false;
	settings.recentFoldersCount = 10;
	settings.alwaysOnTop = false;
	settings.timeFullDate = false;
	settings.trackerAlwaysFirst = false;
	settings.sortRunningApps = false;
	settings.superExpando = false;
	settings.expandNewTeams = false;
	settings.autoRaise = false;
	settings.autoHide = false;
	settings.recentAppsEnabled = true;
	settings.recentDocsEnabled = true;
	settings.recentFoldersEnabled = true;

	BPath dirPath;
	const char* settingsFileName = "Deskbar_settings";

	find_directory(B_USER_DESKBAR_DIRECTORY, &dirPath, true);
	// just make it

	if (find_directory (B_USER_SETTINGS_DIRECTORY, &dirPath, true) == B_OK) {
		BPath filePath = dirPath;
		filePath.Append(settingsFileName);
		fSettingsFile = new BFile(filePath.Path(), O_RDWR);
		if (fSettingsFile->InitCheck() != B_OK) {
			BDirectory theDir(dirPath.Path());
			if (theDir.InitCheck() == B_OK)
				theDir.CreateFile(settingsFileName, fSettingsFile);
		}

		BMessage storedSettings;
		if (fSettingsFile->InitCheck() == B_OK
			&& storedSettings.Unflatten(fSettingsFile) == B_OK) {
			storedSettings.FindBool("vertical", &settings.vertical);
			storedSettings.FindBool("left", &settings.left);
			storedSettings.FindBool("top", &settings.top);
			storedSettings.FindBool("ampmMode", &settings.ampmMode);

			storedSettings.FindInt32("state", (int32*)&settings.state);
			storedSettings.FindFloat("width", &settings.width);
			storedSettings.FindBool("showTime", &settings.showTime);
			storedSettings.FindPoint("switcherLoc", &settings.switcherLoc);
			storedSettings.FindInt32("recentAppsCount",
				&settings.recentAppsCount);
			storedSettings.FindInt32("recentDocsCount",
				&settings.recentDocsCount);
			storedSettings.FindBool("timeShowSeconds",
				&settings.timeShowSeconds);
			storedSettings.FindInt32("recentFoldersCount",
				&settings.recentFoldersCount);
			storedSettings.FindBool("alwaysOnTop", &settings.alwaysOnTop);
			storedSettings.FindBool("timeFullDate", &settings.timeFullDate);
			storedSettings.FindBool("trackerAlwaysFirst",
				&settings.trackerAlwaysFirst);
			storedSettings.FindBool("sortRunningApps",
				&settings.sortRunningApps);
			storedSettings.FindBool("superExpando", &settings.superExpando);
			storedSettings.FindBool("expandNewTeams", &settings.expandNewTeams);
			storedSettings.FindBool("autoRaise", &settings.autoRaise);
			storedSettings.FindBool("autoHide", &settings.autoHide);
			storedSettings.FindBool("recentAppsEnabled",
				&settings.recentAppsEnabled);
			storedSettings.FindBool("recentDocsEnabled",
				&settings.recentDocsEnabled);
			storedSettings.FindBool("recentFoldersEnabled",
				&settings.recentFoldersEnabled);
		}
	}

	fSettings = settings;
}