aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorokan2012-07-18 21:53:22 +0000
committerokan2012-07-18 21:53:22 +0000
commit1b981a5d166590176f6bff12fe483602e7b86d2a (patch)
treeea9ba87ab77345d1ac533232af6a5f14b63ee7f7
parent30be2c97b08b260cdeae51e51450d045e1319fdf (diff)
downloadcwm-1b981a5d166590176f6bff12fe483602e7b86d2a.tar.gz
Further simplify Xinerama init and re-init on XRR events.
While testing for Xinerama during setup was done display-wide, each time XineramaQueryScreens() is called either in start-up or due to an XRR event, the library re-tests for the Xinerama extension anyway before moving on; so the initial test is redundant and allows another global to go away with one other change: always fill in sc->xinerama (and _no), regardless of the success of malloc in XineramaQueryScreens(), and use it to see if Xinerama dimensions exist when asked by client and/or menu code.
-rw-r--r--calmwm.c9
-rw-r--r--screen.c22
2 files changed, 9 insertions, 22 deletions
diff --git a/calmwm.c b/calmwm.c
index 53f1896..73526ba 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: calmwm.c,v 1.63 2012/07/06 14:18:00 okan Exp $
+ * $OpenBSD: calmwm.c,v 1.64 2012/07/18 21:53:22 okan Exp $
*/
#include <sys/param.h>
@@ -44,7 +44,7 @@ Cursor Cursor_resize;
struct screen_ctx_q Screenq = TAILQ_HEAD_INITIALIZER(Screenq);
struct client_ctx_q Clientq = TAILQ_HEAD_INITIALIZER(Clientq);
-int HasXinerama, HasRandr, Randr_ev;
+int HasRandr, Randr_ev;
struct conf Conf;
static void sigchld_cb(int);
@@ -97,7 +97,7 @@ main(int argc, char **argv)
static void
dpy_init(const char *dpyname)
{
- int i, fake;
+ int i;
XSetErrorHandler(x_errorhandler);
@@ -110,9 +110,6 @@ dpy_init(const char *dpyname)
XSync(X_Dpy, False);
XSetErrorHandler(x_errorhandler);
- if (XineramaQueryExtension(X_Dpy, &fake, &fake) == 1 &&
- ((HasXinerama = XineramaIsActive(X_Dpy)) == 1))
- HasXinerama = 1;
HasRandr = XRRQueryExtension(X_Dpy, &Randr_ev, &i);
}
diff --git a/screen.c b/screen.c
index d211871..24d085a 100644
--- a/screen.c
+++ b/screen.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: screen.c,v 1.35 2012/07/16 01:42:00 okan Exp $
+ * $OpenBSD: screen.c,v 1.36 2012/07/18 21:53:22 okan Exp $
*/
#include <sys/param.h>
@@ -74,21 +74,11 @@ screen_updatestackingorder(struct screen_ctx *sc)
void
screen_init_xinerama(struct screen_ctx *sc)
{
- XineramaScreenInfo *info;
- int no;
-
- if (HasXinerama == 0 || XineramaIsActive(X_Dpy) == 0) {
- HasXinerama = 0;
- sc->xinerama_no = 0;
- }
+ XineramaScreenInfo *info = NULL;
+ int no = 0;
- info = XineramaQueryScreens(X_Dpy, &no);
- if (info == NULL) {
- /* Is xinerama actually off, instead of a malloc failure? */
- if (sc->xinerama == NULL)
- HasXinerama = 0;
- return;
- }
+ if (XineramaIsActive(X_Dpy))
+ info = XineramaQueryScreens(X_Dpy, &no);
if (sc->xinerama != NULL)
XFree(sc->xinerama);
@@ -105,7 +95,7 @@ screen_find_xinerama(struct screen_ctx *sc, int x, int y)
XineramaScreenInfo *info;
int i;
- if (HasXinerama == 0)
+ if (sc->xinerama == NULL)
return (NULL);
for (i = 0; i < sc->xinerama_no; i++) {