add support for Xinerama in max layout
[awesome.git] / screen.c
blob9a3221e9a0557448a98871b0be67253bd21e7251
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 screen Screen number
28 * \param statusbar statusbar
29 * \param screen_number int pointer filled with number of screens
30 * \return ScreenInfo struct array with all screens info
32 ScreenInfo *
33 get_screen_info(Display *disp, int screen, Statusbar statusbar, int *screen_number)
35 int i, fake_screen_number = 0;
36 ScreenInfo *si;
38 if(XineramaIsActive(disp))
40 si = XineramaQueryScreens(disp, screen_number);
41 fake_screen_number = *screen_number;
43 else
45 /* emulate Xinerama info but only fill the screen we want */
46 *screen_number = 1;
47 si = p_new(ScreenInfo, screen + 1);
48 si[screen].width = DisplayWidth(disp, screen);
49 si[screen].height = DisplayHeight(disp, screen);
50 si[screen].x_org = 0;
51 si[screen].y_org = 0;
52 fake_screen_number = screen + 1;
55 for(i = 0; i < fake_screen_number; i++)
57 if(statusbar.position == BarTop
58 || statusbar.position == BarBot)
59 si[i].height -= statusbar.height;
60 if(statusbar.position == BarTop)
61 si[i].y_org += statusbar.height;
64 return si;
67 /** Get display info
68 * \param disp Display ref
69 * \param screen Screen number
70 * \param statusbar the statusbar
71 * \return ScreenInfo struct pointer with all display info
73 ScreenInfo *
74 get_display_info(Display *disp, int screen, Statusbar statusbar)
76 ScreenInfo *si;
78 si = p_new(ScreenInfo, 1);
80 si->x_org = 0;
81 si->y_org = statusbar.position == BarTop ? statusbar.height : 0;
82 si->width = DisplayWidth(disp, screen);
83 si->height = DisplayHeight(disp, screen) -
84 ((statusbar.position == BarTop || statusbar.position == BarBot) ? statusbar.height : 0);
86 return si;