add screen args to focus()
[awesome.git] / screen.c
blob6ce39d828d711dde4b05cc55933146c27aa1eca9
1 /*
2 * screen.c - screen management
3 *
4 * Copyright © 2007 Julien Danjou <julien@danjou.info>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "util.h"
23 #include "screen.h"
25 /** Get screens info
26 * \param disp Display ref
27 * \param statusbar statusbar
28 * \param screen_number int pointer filled with number of screens
29 * \return ScreenInfo struct array with all screens info
31 ScreenInfo *
32 get_screen_info(Display *disp, Statusbar statusbar, int *screen_number)
34 int i;
35 ScreenInfo *si;
37 if(XineramaIsActive(disp))
38 si = XineramaQueryScreens(disp, screen_number);
39 else
41 /* emulate Xinerama info */
42 *screen_number = 1;
43 si = p_new(XineramaScreenInfo, 1);
44 si->width = DisplayWidth(disp, DefaultScreen(disp));
45 si->height = DisplayHeight(disp, DefaultScreen(disp));
46 si->x_org = 0;
47 si->y_org = 0;
50 for(i = 0; i < *screen_number; i++)
52 if(statusbar.position == BarTop
53 || statusbar.position == BarBot)
54 si[i].height -= statusbar.height;
55 if(statusbar.position == BarTop)
56 si[i].y_org += statusbar.height;
59 return si;
62 /** Get display info
63 * \param disp Display ref
64 * \param statusbar statusbar
65 * \return ScreenInfo struct pointer with all display info
67 ScreenInfo *
68 get_display_info(Display *disp, Statusbar statusbar)
70 ScreenInfo *si;
72 si = p_new(ScreenInfo, 1);
74 si->x_org = 0;
75 si->y_org = statusbar.position == BarTop ? statusbar.height : 0;
76 si->width = DisplayWidth(disp, DefaultScreen(disp));
77 si->height = DisplayHeight(disp, DefaultScreen(disp)) -
78 ((statusbar.position == BarTop || statusbar.position == BarBot) ? statusbar.height : 0);
80 return si;