-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathminimize.cpp
105 lines (79 loc) · 2.34 KB
/
minimize.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* Copyrights (c):
* 2001 - 2008 , Werner Freytag.
* 2009, Haiku
* Distributed under the terms of the MIT License.
*
* Original Author:
* Werner Freytag <[email protected]>
*/
#include "minimize.h"
#include <Beep.h>
#include <InterfaceDefs.h>
#ifdef __INTEL__
#include <iostream>
#endif
#include <Looper.h>
#include <Roster.h>
#include <string.h>
#include <vector>
using std::vector;
// wird irgendwo vom BeOS definiert (stammt aus Tracker source)
void do_minimize_team(BRect zoomRect, team_id team, bool zoom);
void do_bring_to_front_team(BRect zoomRect, team_id app, bool zoom);
vector<thread_id> last_threads;
// decide if this application may be maximized / minimized
bool is_valid_app( app_info &a_info ) {
char excluded_teams[][B_MIME_TYPE_LENGTH] = {
"", /* system teams */
"application/x-vnd.Be-TSKB", /* Deskbar */
"application/x-vnd.Be-APPS", /* application_server */
"application/x-vnd.Be-input_server", /* input_server */
};
for (uint i=0; i<sizeof(excluded_teams)/B_MIME_TYPE_LENGTH; ++i) {
if (strcmp(a_info.signature, excluded_teams[i])==0) {
return false;
}
}
return true;
}
void minimize( min_mode min ) {
BRect zoomRect(0, 0, 0, 0);
app_info a_info;
switch (min) {
case min_maximize_last: { // maximieren
if (!last_threads.empty()) {
vector<thread_id>::iterator i = last_threads.end();
i--;
thread_id last_team = *i;
be_roster->GetRunningAppInfo(last_team, &a_info);
do_bring_to_front_team(zoomRect, a_info.team, true);
last_threads.pop_back();
}
} break;
case min_minimize_all: { // alle Anwendungen
int32 cookie = 0;
team_info t_info;
while (get_next_team_info(&cookie, &t_info) == B_OK) {
be_roster->GetRunningAppInfo(t_info.team, &a_info);
// only if the app can be activated, it has a window!
team_id team = a_info.team;
be_roster->ActivateApp(team);
if ( is_valid_app(a_info)
&& be_roster->GetActiveAppInfo(&a_info)==B_OK
&& a_info.team==team )
{
do_minimize_team(zoomRect, team, true);
last_threads.push_back( team );
}
}
} break;
default: { // aktuelle Anwenung verkleinern
be_roster->GetActiveAppInfo(&a_info);
if (is_valid_app(a_info)) {
do_minimize_team(zoomRect, a_info.team, true);
last_threads.push_back( a_info.team );
}
}
}
}