File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 7
7
/**
8
8
* @method static object cursorPosition()
9
9
* @method static array displays()
10
+ * @method static array getCenterOfActiveScreen()
11
+ * @method static array active()
12
+ * @method static array primary()
10
13
*/
11
14
class Screen extends Facade
12
15
{
Original file line number Diff line number Diff line change 6
6
7
7
class Screen
8
8
{
9
- public function __construct (protected Client $ client ) {}
9
+ public function __construct (protected Client $ client )
10
+ {
11
+ }
10
12
11
13
public function cursorPosition (): object
12
14
{
@@ -17,4 +19,32 @@ public function displays(): array
17
19
{
18
20
return $ this ->client ->get ('screen/displays ' )->json ('displays ' );
19
21
}
22
+
23
+ public function primary (): object
24
+ {
25
+ return $ this ->client ->get ('screen/primary-display ' )->json ('primaryDisplay ' );
26
+ }
27
+
28
+ public function active (): object
29
+ {
30
+ return $ this ->client ->get ('screen/active ' )->json ();
31
+ }
32
+
33
+ /**
34
+ * Returns the center of the screen where the mouse pointer is placed.
35
+ *
36
+ * @return array<string,int>
37
+ */
38
+ public function getCenterOfActiveScreen (): array
39
+ {
40
+ /* Navigate every screen and check for cursor position against the bounds of the screen. */
41
+ $ activeScreen = $ this ->active ();
42
+
43
+ $ bounds = $ activeScreen ['bounds ' ];
44
+
45
+ return [
46
+ 'x ' => $ bounds ['x ' ] + $ bounds ['width ' ] / 2 ,
47
+ 'y ' => $ bounds ['y ' ] + $ bounds ['height ' ] / 2 ,
48
+ ];
49
+ }
20
50
}
You can’t perform that action at this time.
0 commit comments