JWM Source Documentation
screen.c
Go to the documentation of this file.
1 
14 #include "jwm.h"
15 #include "screen.h"
16 #include "main.h"
17 #include "cursor.h"
18 #include "misc.h"
19 
20 static ScreenType *screens = NULL;
21 static int screenCount;
22 
24 void StartupScreens(void)
25 {
26 #ifdef USE_XINERAMA
27 
28  XineramaScreenInfo *info;
29  int x;
30 
31  if(XineramaIsActive(display)) {
32 
33  info = XineramaQueryScreens(display, &screenCount);
34 
35  screens = Allocate(sizeof(ScreenType) * screenCount);
36  for(x = 0; x < screenCount; x++) {
37  screens[x].index = x;
38  screens[x].x = info[x].x_org;
39  screens[x].y = info[x].y_org;
40  screens[x].width = info[x].width;
41  screens[x].height = info[x].height;
42  }
43 
44  JXFree(info);
45 
46  } else {
47 
48  screenCount = 1;
49  screens = Allocate(sizeof(ScreenType));
50  screens->index = 0;
51  screens->x = 0;
52  screens->y = 0;
53  screens->width = rootWidth;
54  screens->height = rootHeight;
55 
56  }
57 
58 #else
59 
60  screenCount = 1;
61  screens = Allocate(sizeof(ScreenType));
62  screens->index = 0;
63  screens->x = 0;
64  screens->y = 0;
65  screens->width = rootWidth;
66  screens->height = rootHeight;
67 
68 #endif /* USE_XINERAMA */
69 }
70 
72 void ShutdownScreens(void)
73 {
74  if(screens) {
75  Release(screens);
76  screens = NULL;
77  }
78 }
79 
81 const ScreenType *GetCurrentScreen(int x, int y)
82 {
83 
84  ScreenType *sp;
85  int index;
86 
87  x = Max(0, x);
88  x = Min(x, rootWidth - 1);
89  y = Max(0, y);
90  y = Min(y, rootHeight - 1);
91  for(index = 1; index < screenCount; index++) {
92  sp = &screens[index];
93  if(x >= sp->x && x < sp->x + sp->width) {
94  if(y >= sp->y && y < sp->y + sp->height) {
95  return sp;
96  }
97  }
98  }
99 
100  return &screens[0];
101 
102 }
103 
106 {
107 #ifdef USE_XINERAMA
108 
109  Window w;
110  int x, y;
111 
112  GetMousePosition(&x, &y, &w);
113  return GetCurrentScreen(x, y);
114 
115 #else
116 
117  return &screens[0];
118 
119 #endif
120 }
121 
123 const ScreenType *GetScreen(int index)
124 {
125 
126  Assert(index >= 0);
127  Assert(index < screenCount);
128 
129  return &screens[index];
130 
131 }
132 
134 int GetScreenCount(void)
135 {
136  return screenCount;
137 }
138 
139 

joewing.net / Projects / JWM