1
- package data ;
1
+ package de . dortmunddev . snowdesktop . logic ;
2
2
3
3
import java .awt .GraphicsDevice ;
4
4
import java .awt .GraphicsEnvironment ;
7
7
import java .util .Queue ;
8
8
import java .util .concurrent .ConcurrentLinkedQueue ;
9
9
10
- import visual .SnowDesktop ;
11
- import visual .SnowflakePanel ;
12
-
13
10
import com .sun .jna .Native ;
14
11
import com .sun .jna .Pointer ;
15
12
import com .sun .jna .platform .win32 .WinDef ;
18
15
import com .sun .jna .platform .win32 .WinUser .WINDOWINFO ;
19
16
import com .sun .jna .platform .win32 .WinUser .WNDENUMPROC ;
20
17
18
+ import de .dortmunddev .snowdesktop .data .WindowHandle ;
19
+ import de .dortmunddev .snowdesktop .ui .SnowWindow ;
20
+ import de .dortmunddev .snowdesktop .ui .SnowflakePanel ;
21
+
21
22
public class SnowSimulator {
22
23
23
- private static final ArrayList <SnowDesktop > desktops = new ArrayList <SnowDesktop >();
24
+ private static final ArrayList <SnowWindow > desktops = new ArrayList <SnowWindow >();
24
25
25
26
// Rect of the whole monitor setup
26
27
private final static WinDef .RECT totalScreenRect = new WinDef .RECT ();
@@ -29,7 +30,7 @@ public class SnowSimulator {
29
30
private final WinDef .RECT cursorRect = new WinDef .RECT ();
30
31
31
32
// Already known windows
32
- private final ArrayList <Window > windowList = new ArrayList <Window >();
33
+ private final ArrayList <WindowHandle > windowList = new ArrayList <WindowHandle >();
33
34
34
35
// All occupied pixels by ALL visible windows
35
36
private static int [][] windows ;
@@ -78,18 +79,18 @@ public SnowSimulator() {
78
79
currentMonitorRect .top = 0 ;
79
80
currentMonitorRect .bottom = 1050 ;
80
81
81
- SnowSimulator .getDesktops ().add (new SnowDesktop (currentMonitorRect ));
82
+ SnowSimulator .getDesktops ().add (new SnowWindow (currentMonitorRect ));
82
83
}
83
84
84
- for (final SnowDesktop snowDesktop : SnowSimulator .getDesktops ()) {
85
+ for (final SnowWindow snowDesktop : SnowSimulator .getDesktops ()) {
85
86
System .out .println (snowDesktop .getScreenRect ());
86
87
}
87
88
88
- final SnowDesktop [][] desktopsArray = new SnowDesktop [9 ][9 ];
89
+ final SnowWindow [][] desktopsArray = new SnowWindow [9 ][9 ];
89
90
90
91
desktopsArray [4 ][4 ] = SnowSimulator .desktops .get (0 );
91
92
92
- for (final SnowDesktop snowDesktop : SnowSimulator .getDesktops ()) {
93
+ for (final SnowWindow snowDesktop : SnowSimulator .getDesktops ()) {
93
94
94
95
}
95
96
@@ -129,7 +130,7 @@ public void run() {
129
130
// gets all the visible windows and adds them to the windowList
130
131
public void getAllWindows () throws InterruptedException {
131
132
132
- for (final Window curWindow : SnowSimulator .this .windowList ) {
133
+ for (final WindowHandle curWindow : SnowSimulator .this .windowList ) {
133
134
curWindow .setStillExists (false );
134
135
}
135
136
@@ -145,15 +146,15 @@ public boolean callback(final HWND arg0, final Pointer arg1) {
145
146
if (User32 .IsWindowVisible (arg0 ) && !title .equals ("" ) && !title .equals ("Program Manager" )) {
146
147
boolean alreadyFound = false ;
147
148
148
- for (final Window curWindow : SnowSimulator .this .windowList ) {
149
+ for (final WindowHandle curWindow : SnowSimulator .this .windowList ) {
149
150
if (arg0 .getPointer ().equals (curWindow .getWindowHandle ().getPointer ())) {
150
151
alreadyFound = true ;
151
152
curWindow .setStillExists (true );
152
153
break ;
153
154
}
154
155
}
155
156
if (!alreadyFound ) {
156
- SnowSimulator .this .windowList .add (new Window (arg0 , title , rect ));
157
+ SnowSimulator .this .windowList .add (new WindowHandle (arg0 , title , rect ));
157
158
for (int x = rect .left ; x < rect .right ; x ++) {
158
159
for (int y = rect .top ; y < rect .bottom ; y ++) {
159
160
if (x - SnowSimulator .totalScreenRect .left > 0 && x - SnowSimulator .totalScreenRect .left < SnowSimulator .getWindows ().length && y > 0 && y < SnowSimulator .getWindows ()[0 ].length - 2 ) {
@@ -169,16 +170,16 @@ public boolean callback(final HWND arg0, final Pointer arg1) {
169
170
}
170
171
}, 0 );
171
172
172
- final Queue <Window > removeWindowQueue = new ConcurrentLinkedQueue <Window >();
173
+ final Queue <WindowHandle > removeWindowQueue = new ConcurrentLinkedQueue <WindowHandle >();
173
174
174
- for (final Window curWindow : SnowSimulator .this .windowList ) {
175
+ for (final WindowHandle curWindow : SnowSimulator .this .windowList ) {
175
176
if (curWindow .stillExists () == false ) {
176
177
removeWindowQueue .add (curWindow );
177
178
}
178
179
}
179
180
180
181
while (!removeWindowQueue .isEmpty ()) {
181
- final Window curWindow = removeWindowQueue .poll ();
182
+ final WindowHandle curWindow = removeWindowQueue .poll ();
182
183
183
184
SnowSimulator .this .windowList .remove (curWindow );
184
185
@@ -198,10 +199,10 @@ public boolean callback(final HWND arg0, final Pointer arg1) {
198
199
// updates the position and size of all visible windows
199
200
public void updateWindows () throws InterruptedException {
200
201
final long start = System .currentTimeMillis ();
201
- final Queue <Window > toUpdate = new ConcurrentLinkedQueue <Window >();
202
+ final Queue <WindowHandle > toUpdate = new ConcurrentLinkedQueue <WindowHandle >();
202
203
203
204
// Check for a changed Window position/size
204
- for (final Window curWindow : SnowSimulator .this .windowList ) {
205
+ for (final WindowHandle curWindow : SnowSimulator .this .windowList ) {
205
206
final WinDef .RECT curRect = curWindow .getRect ();
206
207
207
208
final WinDef .RECT rect = new WinDef .RECT ();
@@ -212,7 +213,7 @@ public void updateWindows() throws InterruptedException {
212
213
}
213
214
}
214
215
215
- for (final Window curWindow : toUpdate ) {
216
+ for (final WindowHandle curWindow : toUpdate ) {
216
217
final WinDef .RECT newRect = new WinDef .RECT ();
217
218
218
219
User32 .GetWindowRect (curWindow .getWindowHandle (), newRect );
@@ -304,7 +305,7 @@ public static RECT getTotalScreenRect() {
304
305
return SnowSimulator .totalScreenRect ;
305
306
}
306
307
307
- public static ArrayList <SnowDesktop > getDesktops () {
308
+ public static ArrayList <SnowWindow > getDesktops () {
308
309
return SnowSimulator .desktops ;
309
310
}
310
311
0 commit comments