apps/autoraise Restore functionality
* Restore functionality / compilation (C++11)Spacing issues with string macros fixed. Fix type declarartion for removeFromDeskbar so compiles on x86_64. * Code format cleanup * Remove DANO related code Change-Id: I738d14914e320b7606210d8263065187b2c06b1a Reviewed-on: https://review.haiku-os.org/c/898 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
@@ -6,15 +6,16 @@ AutoRaiseApp::AutoRaiseApp()
|
|||||||
{
|
{
|
||||||
removeFromDeskbar(NULL);
|
removeFromDeskbar(NULL);
|
||||||
_directToDeskbar = false;
|
_directToDeskbar = false;
|
||||||
|
|
||||||
//since the tray item shows an icon, and the class TrayView needs to be able to know the location
|
//since the tray item shows an icon, and the class TrayView needs to be
|
||||||
//of the executing binary, we write into the settings file this critical information when the app is fired up
|
//able to know the location of the executing binary, we write into the
|
||||||
|
//settings file this critical information when the app is fired up
|
||||||
app_info info;
|
app_info info;
|
||||||
be_app->GetAppInfo(&info);
|
be_app->GetAppInfo(&info);
|
||||||
|
|
||||||
//now, put the path into the settings file
|
//now, put the path into the settings file
|
||||||
AutoRaiseSettings settings;
|
AutoRaiseSettings settings;
|
||||||
settings.SetAppPath(info.ref);
|
settings.SetAppPath(info.ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoRaiseApp::~AutoRaiseApp()
|
AutoRaiseApp::~AutoRaiseApp()
|
||||||
@@ -26,39 +27,43 @@ void AutoRaiseApp::ArgvReceived(int32 argc, char ** argv)
|
|||||||
{
|
{
|
||||||
BString option;
|
BString option;
|
||||||
bool inDeskbar = false, persist = false;
|
bool inDeskbar = false, persist = false;
|
||||||
|
BString usageNote;
|
||||||
|
usageNote = "\nUsage: " APP_NAME " [options]\n\t--deskbar\twill not open "
|
||||||
|
"window, will just put " APP_NAME " into tray\n\t--persist will put "
|
||||||
|
APP_NAME " into tray such that it remains between bootings\n";
|
||||||
|
|
||||||
for (int32 i = 1; i < argc; i++)
|
for (int32 i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
option = argv[i];
|
option = argv[i];
|
||||||
if (option.IFindFirst("deskbar") != B_ERROR)
|
if (option.IFindFirst("deskbar") != B_ERROR)
|
||||||
inDeskbar = true;
|
inDeskbar = true;
|
||||||
|
|
||||||
if (option.IFindFirst("persist") != B_ERROR)
|
if (option.IFindFirst("persist") != B_ERROR)
|
||||||
persist = true;
|
persist = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inDeskbar && !persist)
|
if (inDeskbar && !persist)
|
||||||
{
|
{
|
||||||
printf(APP_NAME" being put into Tray (one shot)...\n");
|
printf(APP_NAME " being put into Tray (one shot)...\n");
|
||||||
|
|
||||||
PutInTray(false);
|
PutInTray(false);
|
||||||
|
|
||||||
_directToDeskbar = true;
|
_directToDeskbar = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (inDeskbar && persist)
|
else if (inDeskbar && persist)
|
||||||
{
|
{
|
||||||
printf(APP_NAME" being put into Tray (persistant)...\n");
|
printf(APP_NAME " being put into Tray (persistant)...\n");
|
||||||
|
|
||||||
PutInTray(true);
|
PutInTray(true);
|
||||||
|
|
||||||
_directToDeskbar = true;
|
_directToDeskbar = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("\nUsage: "APP_NAME" [options]\n\t--deskbar\twill not open window, will just put "APP_NAME" into tray\n\t--persist will put "APP_NAME" into tray such that it remains between bootings\n");
|
printf(usageNote);
|
||||||
}
|
}
|
||||||
|
|
||||||
be_app_messenger.SendMessage(B_QUIT_REQUESTED);
|
be_app_messenger.SendMessage(B_QUIT_REQUESTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,12 +71,16 @@ void AutoRaiseApp::ReadyToRun()
|
|||||||
{
|
{
|
||||||
if (!_directToDeskbar)
|
if (!_directToDeskbar)
|
||||||
{
|
{
|
||||||
printf("\nUsage: " APP_NAME " [options]\n\t--deskbar\twill not open window, will just put " APP_NAME " into tray\n\t--persist will put " APP_NAME " into tray such that it remains between bootings\n");
|
printf(usageNote);
|
||||||
BAlert *alert = new BAlert("usage box", APP_NAME ", (c) 2002, mmu_man\nUsage: " APP_NAME " [options]\n\t--deskbar\twill not open window, will just put " APP_NAME " into tray\n\t--persist will put "APP_NAME" into tray such that it remains between bootings\n", "OK", NULL, NULL,
|
BAlert *alert = new BAlert("usage box", APP_NAME ", (c) 2002, "
|
||||||
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_INFO_ALERT);
|
"mmu_man\nUsage: " APP_NAME " [options]\n\t--deskbar\twill not "
|
||||||
alert->SetShortcut(0, B_ENTER);
|
"open window, will just put " APP_NAME " into tray\n\t--persist "
|
||||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
"will put " APP_NAME " into tray such that it remains between "
|
||||||
alert->Go();
|
"bootings\n", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
|
||||||
|
B_INFO_ALERT);
|
||||||
|
alert->SetShortcut(0, B_ENTER);
|
||||||
|
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
||||||
|
alert->Go();
|
||||||
be_app_messenger.SendMessage(B_QUIT_REQUESTED);
|
be_app_messenger.SendMessage(B_QUIT_REQUESTED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,7 +88,7 @@ void AutoRaiseApp::ReadyToRun()
|
|||||||
void AutoRaiseApp::PutInTray(bool persist)
|
void AutoRaiseApp::PutInTray(bool persist)
|
||||||
{
|
{
|
||||||
BDeskbar db;
|
BDeskbar db;
|
||||||
|
|
||||||
if (!persist)
|
if (!persist)
|
||||||
db.AddItem(new TrayView);
|
db.AddItem(new TrayView);
|
||||||
else {
|
else {
|
||||||
@@ -95,5 +104,4 @@ int main()
|
|||||||
{
|
{
|
||||||
AutoRaiseApp *app = new AutoRaiseApp();
|
AutoRaiseApp *app = new AutoRaiseApp();
|
||||||
app->Run();
|
app->Run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ class AutoRaiseApp: public BApplication{
|
|||||||
virtual void ReadyToRun();
|
virtual void ReadyToRun();
|
||||||
|
|
||||||
void PutInTray(bool);
|
void PutInTray(bool);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BString usageNote;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
/* this is for the DANO hack (new, simpler version than the BStringIO hack) */
|
|
||||||
#include <BeBuild.h>
|
#include <BeBuild.h>
|
||||||
#ifdef B_BEOS_VERSION_DANO
|
|
||||||
#define private public
|
|
||||||
#include <Messenger.h>
|
|
||||||
#undef private
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "AutoRaiseIcon.h"
|
#include "AutoRaiseIcon.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -21,13 +15,14 @@ extern "C" _EXPORT BView *instantiate_deskbar_item(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long removeFromDeskbar(void *)
|
status_t removeFromDeskbar(void *)
|
||||||
{
|
{
|
||||||
BDeskbar db;
|
BDeskbar db;
|
||||||
if (db.RemoveItem(APP_NAME) != B_OK)
|
if (db.RemoveItem(APP_NAME) != B_OK) {
|
||||||
printf("Unable to remove AutoRaise from BDeskbar\n");
|
printf("Unable to remove AutoRaise from BDeskbar\n");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
//**************************************************
|
//**************************************************
|
||||||
@@ -61,9 +56,6 @@ ConfigMenu::ConfigMenu(TrayView *tv, bool useMag)
|
|||||||
msg->AddInt32(AR_MODE, Mode_DeskbarOver);
|
msg->AddInt32(AR_MODE, Mode_DeskbarOver);
|
||||||
tmpi = new BMenuItem("Deskbar only (over its area)", msg);
|
tmpi = new BMenuItem("Deskbar only (over its area)", msg);
|
||||||
tmpi->SetMarked(s->Mode() == Mode_DeskbarOver);
|
tmpi->SetMarked(s->Mode() == Mode_DeskbarOver);
|
||||||
#ifdef USE_DANO_HACK
|
|
||||||
tmpi->SetEnabled(false);
|
|
||||||
#endif
|
|
||||||
tmpm->AddItem(tmpi);
|
tmpm->AddItem(tmpi);
|
||||||
|
|
||||||
msg = new BMessage(MSG_SET_MODE);
|
msg = new BMessage(MSG_SET_MODE);
|
||||||
@@ -170,7 +162,7 @@ ConfigMenu::ConfigMenu(TrayView *tv, bool useMag)
|
|||||||
AddSeparatorItem();
|
AddSeparatorItem();
|
||||||
// AddItem(new BMenuItem("Settings...", new BMessage(OPEN_SETTINGS)));
|
// AddItem(new BMenuItem("Settings...", new BMessage(OPEN_SETTINGS)));
|
||||||
|
|
||||||
AddItem(new BMenuItem("About "APP_NAME B_UTF8_ELLIPSIS,
|
AddItem(new BMenuItem("About " APP_NAME B_UTF8_ELLIPSIS,
|
||||||
new BMessage(B_ABOUT_REQUESTED)));
|
new BMessage(B_ABOUT_REQUESTED)));
|
||||||
AddItem(new BMenuItem("Remove from tray", new BMessage(REMOVE_FROM_TRAY)));
|
AddItem(new BMenuItem("Remove from tray", new BMessage(REMOVE_FROM_TRAY)));
|
||||||
|
|
||||||
@@ -221,10 +213,8 @@ void TrayView::_init()
|
|||||||
get_thread_info(find_thread(NULL), &ti);
|
get_thread_info(find_thread(NULL), &ti);
|
||||||
fDeskbarTeam = ti.team;
|
fDeskbarTeam = ti.team;
|
||||||
|
|
||||||
#ifndef USE_DANO_HACK
|
|
||||||
resume_thread(poller_thread = spawn_thread(poller, "AutoRaise desktop "
|
resume_thread(poller_thread = spawn_thread(poller, "AutoRaise desktop "
|
||||||
"poller", B_NORMAL_PRIORITY, (void *)this));
|
"poller", B_NORMAL_PRIORITY, (void *)this));
|
||||||
#endif
|
|
||||||
|
|
||||||
//determine paths to icon files based on app path in settings file
|
//determine paths to icon files based on app path in settings file
|
||||||
|
|
||||||
@@ -269,18 +259,11 @@ TrayView::~TrayView(){
|
|||||||
status_t ret;
|
status_t ret;
|
||||||
|
|
||||||
if (watching) {
|
if (watching) {
|
||||||
#ifdef USE_DANO_HACK
|
|
||||||
be_roster->StopWatching(this);
|
|
||||||
#else
|
|
||||||
// acquire_sem(fPollerSem);
|
|
||||||
#endif
|
|
||||||
set_mouse_mode(fNormalMM);
|
set_mouse_mode(fNormalMM);
|
||||||
watching = false;
|
watching = false;
|
||||||
}
|
}
|
||||||
delete_sem(fPollerSem);
|
delete_sem(fPollerSem);
|
||||||
#ifndef USE_DANO_HACK
|
|
||||||
wait_for_thread(poller_thread, &ret);
|
wait_for_thread(poller_thread, &ret);
|
||||||
#endif
|
|
||||||
if (_activeIcon) delete _activeIcon;
|
if (_activeIcon) delete _activeIcon;
|
||||||
if (_inactiveIcon) delete _inactiveIcon;
|
if (_inactiveIcon) delete _inactiveIcon;
|
||||||
if (_settings) delete _settings;
|
if (_settings) delete _settings;
|
||||||
@@ -303,8 +286,7 @@ status_t TrayView::Archive(BMessage *data, bool deep) const {
|
|||||||
//Rehydrate the View from a given message (called by the DeskBar)
|
//Rehydrate the View from a given message (called by the DeskBar)
|
||||||
TrayView *TrayView::Instantiate(BMessage *data) {
|
TrayView *TrayView::Instantiate(BMessage *data) {
|
||||||
|
|
||||||
if (!validate_instantiation(data, "TrayView"))
|
if (!validate_instantiation(data, "TrayView")) {
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,16 +296,12 @@ TrayView *TrayView::Instantiate(BMessage *data) {
|
|||||||
void TrayView::AttachedToWindow() {
|
void TrayView::AttachedToWindow() {
|
||||||
if(Parent())
|
if(Parent())
|
||||||
SetViewColor(Parent()->ViewColor());
|
SetViewColor(Parent()->ViewColor());
|
||||||
if (_settings->Active()) {
|
if (_settings->Active()) {
|
||||||
fNormalMM = mouse_mode();
|
fNormalMM = mouse_mode();
|
||||||
set_mouse_mode(B_FOCUS_FOLLOWS_MOUSE);
|
set_mouse_mode(B_FOCUS_FOLLOWS_MOUSE);
|
||||||
#ifdef USE_DANO_HACK
|
release_sem(fPollerSem);
|
||||||
be_roster->StartWatching(this, B_REQUEST_WINDOW_ACTIVATED);
|
watching = true;
|
||||||
#else
|
}
|
||||||
release_sem(fPollerSem);
|
|
||||||
#endif
|
|
||||||
watching = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrayView::Draw(BRect updaterect) {
|
void TrayView::Draw(BRect updaterect) {
|
||||||
@@ -389,16 +367,14 @@ void TrayView::MouseDown(BPoint where) {
|
|||||||
int32 fronter(void *arg)
|
int32 fronter(void *arg)
|
||||||
{
|
{
|
||||||
TrayView *tv = (TrayView *)arg;
|
TrayView *tv = (TrayView *)arg;
|
||||||
int32 tok = tv->current_window;
|
|
||||||
int32 ws = current_workspace();
|
int32 ws = current_workspace();
|
||||||
|
volatile int32 tok = tv->current_window;
|
||||||
sem_id sem = tv->fPollerSem;
|
sem_id sem = tv->fPollerSem;
|
||||||
|
|
||||||
snooze(tv->raise_delay);
|
snooze(tv->raise_delay);
|
||||||
|
|
||||||
#ifndef USE_DANO_HACK
|
|
||||||
if (acquire_sem(sem) != B_OK)
|
if (acquire_sem(sem) != B_OK)
|
||||||
return B_OK; // this really needs a better locking model...
|
return B_OK; // this really needs a better locking model...
|
||||||
#endif
|
|
||||||
if (ws != current_workspace())
|
if (ws != current_workspace())
|
||||||
goto end; // don't touch windows if we changed workspace
|
goto end; // don't touch windows if we changed workspace
|
||||||
if (tv->last_raiser_thread != find_thread(NULL))
|
if (tv->last_raiser_thread != find_thread(NULL))
|
||||||
@@ -415,7 +391,6 @@ PRINT(("tok = %ld cw = %ld\n", tok, tv->current_window));
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_DANO_HACK
|
|
||||||
|
|
||||||
int32 poller(void *arg)
|
int32 poller(void *arg)
|
||||||
{
|
{
|
||||||
@@ -451,7 +426,8 @@ int32 poller(void *arg)
|
|||||||
goto zzz; // invalid window ?
|
goto zzz; // invalid window ?
|
||||||
/*
|
/*
|
||||||
printf("if (!%s && (%li, %li)isin(%li)(%li, %li, %li, %li) && (%li != %li) ", wi->is_mini?"true":"false",
|
printf("if (!%s && (%li, %li)isin(%li)(%li, %li, %li, %li) && (%li != %li) ", wi->is_mini?"true":"false",
|
||||||
(long)mouse.x, (long)mouse.y, i, wi->window_left, wi->window_right, wi->window_top, wi->window_bottom, wi->id, tok);
|
(long)mouse.x, (long)mouse.y, i, wi->window_left, wi->window_right,
|
||||||
|
wi->window_top, wi->window_bottom, wi-server_token, tok);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -460,12 +436,13 @@ printf("if (!%s && (%li, %li)isin(%li)(%li, %li, %li, %li) && (%li != %li) ", wi
|
|||||||
&& (((long)mouse.y) > wi->window_top) && (((long)mouse.y) < wi->window_bottom)) {
|
&& (((long)mouse.y) > wi->window_top) && (((long)mouse.y) < wi->window_bottom)) {
|
||||||
//((tv->_settings->Mode() != Mode_DeskbarOver) || (wi->team == tv->fDeskbarTeam))
|
//((tv->_settings->Mode() != Mode_DeskbarOver) || (wi->team == tv->fDeskbarTeam))
|
||||||
|
|
||||||
if ((tv->_settings->Mode() == Mode_All) && (wi->id == tv->current_window))
|
if ((tv->_settings->Mode() == Mode_All) &&
|
||||||
|
(wi->server_token == tv->current_window))
|
||||||
goto zzz; // already raised
|
goto zzz; // already raised
|
||||||
|
|
||||||
if ((tv->_settings->Mode() == Mode_All) || (wi->team == tv->fDeskbarTeam)) {
|
if ((tv->_settings->Mode() == Mode_All) || (wi->team == tv->fDeskbarTeam)) {
|
||||||
tv->current_window = wi->id;
|
tv->current_window = wi->server_token;
|
||||||
tok = wi->id;
|
tok = wi->server_token;
|
||||||
resume_thread(tv->last_raiser_thread = spawn_thread(fronter, "fronter", B_NORMAL_PRIORITY, (void *)tv));
|
resume_thread(tv->last_raiser_thread = spawn_thread(fronter, "fronter", B_NORMAL_PRIORITY, (void *)tv));
|
||||||
goto zzz;
|
goto zzz;
|
||||||
} else if (tv->_settings->Mode() == Mode_DeskbarTouch) // give up, before we find Deskbar under it
|
} else if (tv->_settings->Mode() == Mode_DeskbarTouch) // give up, before we find Deskbar under it
|
||||||
@@ -487,7 +464,6 @@ printf("if (!%s && (%li, %li)isin(%li)(%li, %li, %li, %li) && (%li != %li) ", wi
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void TrayView::MessageReceived(BMessage* message)
|
void TrayView::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
@@ -533,72 +509,22 @@ void TrayView::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
case REMOVE_FROM_TRAY:
|
case REMOVE_FROM_TRAY:
|
||||||
{
|
{
|
||||||
thread_id tid = spawn_thread(removeFromDeskbar, "RemoveFromDeskbar", B_NORMAL_PRIORITY, NULL);
|
thread_id tid = spawn_thread(removeFromDeskbar, "RemoveFromDeskbar", B_NORMAL_PRIORITY, (void*)this);
|
||||||
if (tid) resume_thread(tid);
|
if (tid != 0) resume_thread(tid);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_ABOUT_REQUESTED:
|
case B_ABOUT_REQUESTED:
|
||||||
alert = new BAlert("about box", "AutoRaise, (c) 2002, mmu_man\nEnjoy :-)", "OK", NULL, NULL,
|
alert = new BAlert("about box", "AutoRaise, (c) 2002, mmu_man\nEnjoy :-)", "OK", NULL, NULL,
|
||||||
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_INFO_ALERT);
|
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_INFO_ALERT);
|
||||||
alert->SetShortcut(0, B_ENTER);
|
alert->SetShortcut(0, B_ENTER);
|
||||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
||||||
alert->Go(NULL); // use asynchronous version
|
alert->Go(NULL); // use asynchronous version
|
||||||
break;
|
break;
|
||||||
case OPEN_SETTINGS:
|
case OPEN_SETTINGS:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#ifdef USE_DANO_HACK
|
|
||||||
case B_SOME_WINDOW_ACTIVATED:
|
|
||||||
// printf("Window Activated\n");
|
|
||||||
// message->PrintToStream();
|
|
||||||
BPoint mouse;
|
|
||||||
uint32 buttons;
|
|
||||||
GetMouse(&mouse, &buttons);
|
|
||||||
if (buttons)
|
|
||||||
break;
|
|
||||||
if (message->FindMessenger("be:window", &msgr) < B_OK)
|
|
||||||
puts("BMsgr ERROR");
|
|
||||||
else {
|
|
||||||
bool doZoom = false;
|
|
||||||
BRect zoomRect(0.0f, 0.0f, 0.0f, 0.0f);
|
|
||||||
port_id pi = msgr.fPort;
|
|
||||||
// printf("port:%li (%lx)\n", pi, pi);
|
|
||||||
|
|
||||||
int32 *tl, tlc;
|
|
||||||
tl = get_token_list(msgr.Team(), &tlc);
|
|
||||||
// printf("tokens (team %li): (%li) ", msgr.Team(), tlc);
|
|
||||||
for (tlc; tlc; tlc--) {
|
|
||||||
// printf("%li ", tl[tlc-1]);
|
|
||||||
window_info *wi = get_window_info(tl[tlc-1]);
|
|
||||||
if (wi) {
|
|
||||||
if (wi->client_port == pi) {
|
|
||||||
if ((wi->layer < 3) // we hit the desktop or a window not on this WS
|
|
||||||
|| (wi->window_left > wi->window_right) || (wi->window_top > wi->window_bottom)
|
|
||||||
|| (wi->is_mini)
|
|
||||||
|| (/*(_settings->Mode() == Mode_All) && */(wi->id == current_window))) {
|
|
||||||
// already raised
|
|
||||||
free(wi);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((_settings->Mode() == Mode_All) || (wi->team == fDeskbarTeam)) {
|
|
||||||
PRINT(("raising wi=%li, cp=%ld, pi=%ld team=%ld DBteam=%ld\n", wi->id, wi->client_port, pi, wi->team, fDeskbarTeam));
|
|
||||||
current_window = wi->id;
|
|
||||||
int32 tok = wi->id;
|
|
||||||
resume_thread(last_raiser_thread = spawn_thread(fronter, "fronter", B_NORMAL_PRIORITY, (void *)this));
|
|
||||||
} else {
|
|
||||||
current_window = wi->id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(wi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// puts("");
|
|
||||||
free(tl);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
}
|
}
|
||||||
@@ -617,22 +543,14 @@ void TrayView::SetActive(bool st)
|
|||||||
if (!watching) {
|
if (!watching) {
|
||||||
fNormalMM = mouse_mode();
|
fNormalMM = mouse_mode();
|
||||||
set_mouse_mode(B_FOCUS_FOLLOWS_MOUSE);
|
set_mouse_mode(B_FOCUS_FOLLOWS_MOUSE);
|
||||||
#ifdef USE_DANO_HACK
|
|
||||||
be_roster->StartWatching(this, B_REQUEST_WINDOW_ACTIVATED);
|
|
||||||
#else
|
|
||||||
release_sem(fPollerSem);
|
release_sem(fPollerSem);
|
||||||
#endif
|
|
||||||
watching = true;
|
watching = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (watching) {
|
if (watching) {
|
||||||
#ifdef USE_DANO_HACK
|
|
||||||
be_roster->StopWatching(this);
|
|
||||||
#else
|
|
||||||
acquire_sem(fPollerSem);
|
acquire_sem(fPollerSem);
|
||||||
#endif
|
|
||||||
set_mouse_mode(fNormalMM);
|
set_mouse_mode(fNormalMM);
|
||||||
watching = false;
|
watching = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ extern "C" _EXPORT BView* instantiate_deskbar_item();
|
|||||||
|
|
||||||
|
|
||||||
//since we can't remove the view from the deskbar from within the same thread
|
//since we can't remove the view from the deskbar from within the same thread
|
||||||
//as tray view, a thread will be spawned and this function called. It removed TrayView
|
//as tray view, a thread will be spawned and this function called. It removed
|
||||||
//from the Deskbar
|
//TrayView from the Deskbar
|
||||||
long removeFromDeskbar(void *);
|
status_t removeFromDeskbar(void *);
|
||||||
|
|
||||||
class _EXPORT TrayView;
|
class _EXPORT TrayView;
|
||||||
|
|
||||||
@@ -27,20 +27,20 @@ class _EXPORT TrayView;
|
|||||||
class TrayView derived from BView
|
class TrayView derived from BView
|
||||||
|
|
||||||
The icon in the Deskbar tray, provides the fundamental
|
The icon in the Deskbar tray, provides the fundamental
|
||||||
user interface. Archivable, so it can be flattened and fired
|
user interface. Archivable, so it can be flattened and
|
||||||
at the deskbar.
|
fired at the deskbar.
|
||||||
|
|
||||||
*********************************************/
|
*********************************************/
|
||||||
|
|
||||||
class TrayView:public BView{
|
class TrayView:public BView{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
BBitmap *_activeIcon, *_inactiveIcon;
|
BBitmap *_activeIcon, *_inactiveIcon;
|
||||||
entry_ref _appPath;
|
entry_ref _appPath;
|
||||||
bool watching;
|
bool watching;
|
||||||
|
|
||||||
void _init(void); //initialization common to all constructors
|
void _init(void); //initialization common to all constructors
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AutoRaiseSettings *_settings;
|
AutoRaiseSettings *_settings;
|
||||||
mode_mouse fNormalMM;
|
mode_mouse fNormalMM;
|
||||||
@@ -48,24 +48,24 @@ class TrayView:public BView{
|
|||||||
bigtime_t raise_delay;
|
bigtime_t raise_delay;
|
||||||
volatile thread_id last_raiser_thread;
|
volatile thread_id last_raiser_thread;
|
||||||
team_id fDeskbarTeam;
|
team_id fDeskbarTeam;
|
||||||
|
|
||||||
bigtime_t polling_delay; // for !DANO
|
bigtime_t polling_delay;
|
||||||
sem_id fPollerSem;
|
sem_id fPollerSem;
|
||||||
thread_id poller_thread;
|
thread_id poller_thread;
|
||||||
|
|
||||||
TrayView();
|
TrayView();
|
||||||
TrayView(BMessage *mdArchive);
|
TrayView(BMessage *mdArchive);
|
||||||
virtual ~TrayView();
|
virtual ~TrayView();
|
||||||
|
|
||||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
||||||
static TrayView *Instantiate(BMessage *data);
|
static TrayView *Instantiate(BMessage *data);
|
||||||
|
|
||||||
virtual void Draw(BRect updateRect );
|
virtual void Draw(BRect updateRect );
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void GetPreferredSize(float *w, float *h);
|
virtual void GetPreferredSize(float *w, float *h);
|
||||||
|
|
||||||
AutoRaiseSettings *Settings() const;
|
AutoRaiseSettings *Settings() const;
|
||||||
void SetActive(bool);
|
void SetActive(bool);
|
||||||
};
|
};
|
||||||
@@ -84,7 +84,7 @@ int32 poller(void *);
|
|||||||
|
|
||||||
class ConfigMenu: public BPopUpMenu{
|
class ConfigMenu: public BPopUpMenu{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConfigMenu(TrayView *tv, bool useMag);
|
ConfigMenu(TrayView *tv, bool useMag);
|
||||||
virtual ~ConfigMenu();
|
virtual ~ConfigMenu();
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
SubDir HAIKU_TOP src apps autoraise ;
|
SubDir HAIKU_TOP src apps autoraise ;
|
||||||
|
|
||||||
|
UsePrivateHeaders interface shared ;
|
||||||
|
UsePrivateHeaders private shared ;
|
||||||
|
|
||||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
|
||||||
Application AutoRaise :
|
Application AutoRaise :
|
||||||
|
|||||||
@@ -7,12 +7,7 @@
|
|||||||
#include <InterfaceKit.h>
|
#include <InterfaceKit.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <StorageKit.h>
|
#include <StorageKit.h>
|
||||||
|
#include <WindowInfo.h>
|
||||||
|
|
||||||
// R5.1 has a very helpful API...
|
|
||||||
#if (B_BEOS_VERSION == 0x0510)
|
|
||||||
#define USE_DANO_HACK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/***************************************************
|
/***************************************************
|
||||||
common.h
|
common.h
|
||||||
@@ -21,7 +16,7 @@
|
|||||||
|
|
||||||
// used to check the image to use to get the resources
|
// used to check the image to use to get the resources
|
||||||
#define APP_NAME "AutoRaise"
|
#define APP_NAME "AutoRaise"
|
||||||
#define APP_SIG "application/x-vnd.mmu.AutoRaise"
|
#define APP_SIG "application/x-vnd.mmu.AutoRaise"
|
||||||
#define SETTINGS_FILE "x-vnd.mmu.AutoRaise_settings"
|
#define SETTINGS_FILE "x-vnd.mmu.AutoRaise_settings"
|
||||||
|
|
||||||
//names of data segments in settings file
|
//names of data segments in settings file
|
||||||
@@ -51,12 +46,8 @@ enum {
|
|||||||
|
|
||||||
#define ADD_TO_TRAY 'zATT'
|
#define ADD_TO_TRAY 'zATT'
|
||||||
#define REMOVE_FROM_TRAY 'zRFT'
|
#define REMOVE_FROM_TRAY 'zRFT'
|
||||||
|
|
||||||
#define OPEN_SETTINGS 'zOPS'
|
#define OPEN_SETTINGS 'zOPS'
|
||||||
|
|
||||||
|
|
||||||
#define MSG_DELAY_POPUP 'arDP'
|
#define MSG_DELAY_POPUP 'arDP'
|
||||||
|
|
||||||
#define MSG_TOGGLE_ACTIVE 'arTA'
|
#define MSG_TOGGLE_ACTIVE 'arTA'
|
||||||
#define MSG_SET_ACTIVE 'arSA'
|
#define MSG_SET_ACTIVE 'arSA'
|
||||||
#define MSG_SET_INACTIVE 'arSI'
|
#define MSG_SET_INACTIVE 'arSI'
|
||||||
@@ -64,43 +55,4 @@ enum {
|
|||||||
#define MSG_SET_MODE 'arSM'
|
#define MSG_SET_MODE 'arSM'
|
||||||
#define MSG_SET_BEHAVIOUR 'arSB'
|
#define MSG_SET_BEHAVIOUR 'arSB'
|
||||||
|
|
||||||
/* from OpenTracker deskbar/WindowMenuItem.h */
|
|
||||||
|
|
||||||
// from interface_defs.h
|
|
||||||
struct window_info {
|
|
||||||
team_id team;
|
|
||||||
int32 id; /* window's token */
|
|
||||||
|
|
||||||
int32 thread;
|
|
||||||
int32 client_token;
|
|
||||||
int32 client_port;
|
|
||||||
uint32 workspaces;
|
|
||||||
|
|
||||||
int32 layer;
|
|
||||||
uint32 w_type; /* B_TITLED_WINDOW, etc. */
|
|
||||||
uint32 flags; /* B_WILL_FLOAT, etc. */
|
|
||||||
int32 window_left;
|
|
||||||
int32 window_top;
|
|
||||||
int32 window_right;
|
|
||||||
int32 window_bottom;
|
|
||||||
int32 show_hide_level;
|
|
||||||
bool is_mini;
|
|
||||||
char name[1];
|
|
||||||
};
|
|
||||||
|
|
||||||
// from interface_misc.h
|
|
||||||
enum window_action {
|
|
||||||
B_MINIMIZE_WINDOW,
|
|
||||||
B_BRING_TO_FRONT
|
|
||||||
};
|
|
||||||
|
|
||||||
// from interface_misc.h
|
|
||||||
void do_window_action(int32 window_id, int32 action,
|
|
||||||
BRect zoomRect, bool zoom);
|
|
||||||
window_info *get_window_info(int32 a_token);
|
|
||||||
int32 *get_token_list(team_id app, int32 *count);
|
|
||||||
void do_minimize_team(BRect zoomRect, team_id team, bool zoom);
|
|
||||||
void do_bring_to_front_team(BRect zoomRect, team_id app, bool zoom);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user