From c7735d4d1fbc60f799f7b2fa02be2a9f8a65c90a Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 14 Sep 2007 11:35:17 +0200 Subject: [PATCH] add screen.[ch] to handle Xinerama config, and deprecate get_wa*() --- Makefile | 2 +- awesome.h | 8 ++++---- layouts/tile.c | 28 ++++---------------------- screen.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ screen.h | 34 +++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+), 29 deletions(-) create mode 100644 screen.c create mode 100644 screen.h diff --git a/Makefile b/Makefile index f8dda22e..a2855d4f 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ include config.mk -SRC = client.c draw.c event.c layout.c awesome.c tag.c util.c config.c +SRC = client.c draw.c event.c layout.c awesome.c tag.c util.c config.c screen.c OBJ = ${SRC:.c=.o} ${LAYOUTS:.c=.o} all: options awesome diff --git a/awesome.h b/awesome.h index f721009b..95502121 100644 --- a/awesome.h +++ b/awesome.h @@ -28,9 +28,9 @@ Bool gettextprop(Display *, Window, Atom, char *, unsigned int); /* return tex void updatebarpos(Display *, Statusbar); /* updates the bar position */ void uicb_quit(Display *, DC *, awesome_config *, const char *); /* quit awesome nicely */ int xerror(Display *, XErrorEvent *); /* awesome's X error handler */ -int get_windows_area_x(Statusbar); -int get_windows_area_y(Statusbar); -int get_windows_area_height(Display *, Statusbar); -int get_windows_area_width(Display *, Statusbar); +int __attribute__ ((deprecated)) get_windows_area_x(Statusbar); +int __attribute__ ((deprecated)) get_windows_area_y(Statusbar); +int __attribute__ ((deprecated)) get_windows_area_height(Display *, Statusbar); +int __attribute__ ((deprecated)) get_windows_area_width(Display *, Statusbar); #endif diff --git a/layouts/tile.c b/layouts/tile.c index 29a21b6b..cb138785 100644 --- a/layouts/tile.c +++ b/layouts/tile.c @@ -21,8 +21,8 @@ */ #include -#include +#include "screen.h" #include "awesome.h" #include "tag.h" #include "layout.h" @@ -104,31 +104,11 @@ _tile(Display *disp, awesome_config *awesomeconf, const Bool right) unsigned int mw = 0, mh = 0; int n, i, li, last_i = 0, nmaster_screen = 0, otherwin_screen = 0; int screen_numbers = 1, use_screen = -1; - XineramaScreenInfo *screens_info = NULL; + ScreenInfo *screens_info = NULL; Client *c; - if(XineramaIsActive(disp)) - { - screens_info = XineramaQueryScreens(disp, &screen_numbers); - for(i = 0; i < screen_numbers; i++) - { - if(awesomeconf->statusbar.position == BarTop - || awesomeconf->statusbar.position == BarBot) - screens_info[i].height -= awesomeconf->statusbar.height; - if(awesomeconf->statusbar.position == BarTop) - screens_info[i].y_org += awesomeconf->statusbar.height; - } - } - else - { - /* emulate Xinerama info */ - screens_info = p_new(XineramaScreenInfo, 1); - screens_info->width = get_windows_area_width(disp, awesomeconf->statusbar); - screens_info->height = get_windows_area_height(disp, awesomeconf->statusbar); - screens_info->x_org = get_windows_area_x(awesomeconf->statusbar); - screens_info->y_org = get_windows_area_y(awesomeconf->statusbar); - } - + screens_info = get_screen_info(disp, awesomeconf->statusbar, &screen_numbers); + for(n = 0, c = clients; c; c = c->next) if(IS_TILED(c, awesomeconf->selected_tags, awesomeconf->ntags)) n++; diff --git a/screen.c b/screen.c new file mode 100644 index 00000000..6d9a6edd --- /dev/null +++ b/screen.c @@ -0,0 +1,54 @@ +/* + * screen.c - screen management + * + * Copyright © 2007 Julien Danjou + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "util.h" +#include "screen.h" + +ScreenInfo * +get_screen_info(Display *disp, Statusbar statusbar, int *screen_number) +{ + int i; + ScreenInfo *si; + + if(XineramaIsActive(disp)) + si = XineramaQueryScreens(disp, screen_number); + else + { + /* emulate Xinerama info */ + *screen_number = 1; + si = p_new(XineramaScreenInfo, 1); + si->width = DisplayWidth(disp, DefaultScreen(disp)); + si->height = DisplayHeight(disp, DefaultScreen(disp)); + si->x_org = 0; + si->y_org = 0; + } + + for(i = 0; i < *screen_number; i++) + { + if(statusbar.position == BarTop + || statusbar.position == BarBot) + si[i].height -= statusbar.height; + if(statusbar.position == BarTop) + si[i].y_org += statusbar.height; + } + + return si; +} diff --git a/screen.h b/screen.h new file mode 100644 index 00000000..1161abd7 --- /dev/null +++ b/screen.h @@ -0,0 +1,34 @@ +/* + * screen.h - screen management header + * + * Copyright © 2007 Julien Danjou + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef AWESOME_SCREEN_H +#define AWESOME_SCREEN_H + + +#include "config.h" + +#include + +typedef XineramaScreenInfo ScreenInfo; + +ScreenInfo * get_screen_info(Display *, Statusbar, int *); + +#endif