introduce screen "view" area and "work" area (gap applied) to simplify

various blocks that require understanding the screen geometry.
This commit is contained in:
okan 2012-07-13 14:18:04 +00:00
parent 0e20e1901a
commit 3f2059e461
2 changed files with 21 additions and 2 deletions

View File

@ -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.h,v 1.149 2012/07/06 14:18:00 okan Exp $
* $OpenBSD: calmwm.h,v 1.150 2012/07/13 14:18:04 okan Exp $
*/
#ifndef _CALMWM_H_
@ -96,6 +96,13 @@ struct color {
unsigned long pixel;
};
struct geom {
int x;
int y;
int w;
int h;
};
struct gap {
int top;
int bottom;
@ -206,6 +213,8 @@ struct screen_ctx {
int cycling;
int xmax;
int ymax;
struct geom view; /* viewable area */
struct geom work; /* workable area, gap-applied */
struct gap gap;
struct cycle_entry_q mruq;
XftColor xftcolor;

View File

@ -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.31 2012/07/06 14:18:00 okan Exp $
* $OpenBSD: screen.c,v 1.32 2012/07/13 14:18:04 okan Exp $
*/
#include <sys/param.h>
@ -120,6 +120,16 @@ screen_update_geometry(struct screen_ctx *sc)
sc->xmax = DisplayWidth(X_Dpy, sc->which);
sc->ymax = DisplayHeight(X_Dpy, sc->which);
sc->view.x = 0;
sc->view.y = 0;
sc->view.w = DisplayWidth(X_Dpy, sc->which);
sc->view.h = DisplayHeight(X_Dpy, sc->which);
sc->work.x = sc->view.x + sc->gap.left;
sc->work.y = sc->view.y + sc->gap.top;
sc->work.w = sc->view.w - (sc->gap.left + sc->gap.right);
sc->work.h = sc->view.h - (sc->gap.top + sc->gap.bottom);
screen_init_xinerama(sc);
xu_ewmh_net_desktop_geometry(sc);