fix screen_get_bycoord()

This commit is contained in:
Julien Danjou 2008-02-25 13:19:39 +01:00
parent 328e5d0d4e
commit 960d870b0b
7 changed files with 22 additions and 23 deletions

View File

@ -77,7 +77,6 @@ scan()
{
if(XQueryTree(globalconf.display, RootWindow(globalconf.display, screen), &d1, &d2, &wins, &num))
{
real_screen = screen;
for(i = 0; i < num; i++)
{
/* XGetWindowAttributes return 1 on success */
@ -87,8 +86,7 @@ scan()
continue;
if(wa.map_state == IsViewable || window_getstate(wins[i]) == IconicState)
{
if(screen == 0)
real_screen = screen_get_bycoord(wa.x, wa.y);
real_screen = screen_get_bycoord(screen, wa.x, wa.y);
client_manage(wins[i], &wa, real_screen);
}
}
@ -100,8 +98,7 @@ scan()
if(XGetTransientForHint(globalconf.display, wins[i], &d1)
&& (wa.map_state == IsViewable || window_getstate(wins[i]) == IconicState))
{
if(screen == 0)
real_screen = screen_get_bycoord(wa.x, wa.y);
real_screen = screen_get_bycoord(screen, wa.x, wa.y);
client_manage(wins[i], &wa, real_screen);
}
}

View File

@ -22,6 +22,7 @@
#include <stdio.h>
#include <X11/Xatom.h>
#include <X11/extensions/shape.h>
#include <X11/extensions/Xinerama.h>
#include "client.h"
#include "tag.h"
@ -253,7 +254,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
c = p_new(Client, 1);
c->screen = screen_get_bycoord(wa->x, wa->y);
c->screen = screen_get_bycoord(screen, wa->x, wa->y);
screen_geom = screen_get_area(c->screen,
globalconf.screens[screen].statusbar,
@ -447,7 +448,7 @@ client_resize(Client *c, Area geometry, Bool sizehints)
if(c->geometry.x != geometry.x || c->geometry.y != geometry.y
|| c->geometry.width != geometry.width || c->geometry.height != geometry.height)
{
new_screen = screen_get_bycoord(geometry.x, geometry.y);
new_screen = screen_get_bycoord(c->screen, geometry.x, geometry.y);
c->geometry.x = wc.x = geometry.x;
c->geometry.y = wc.y = geometry.y;

17
event.c
View File

@ -24,6 +24,7 @@
#include <X11/Xutil.h>
#include <X11/extensions/shape.h>
#include <X11/extensions/Xrandr.h>
#include <X11/extensions/Xinerama.h>
#include "screen.h"
#include "event.h"
@ -134,7 +135,7 @@ handle_event_buttonpress(XEvent *e)
&wdummy, &x, &y, &i,
&i, &udummy))
{
screen = screen_get_bycoord(x, y);
screen = screen_get_bycoord(screen, x, y);
handle_mouse_button_press(screen, ev->button, ev->state,
globalconf.buttons.root, NULL);
return;
@ -273,8 +274,7 @@ handle_event_keypress(XEvent * e)
* only screen in Xinerama, so we can ask for a better screen
* number with screen_get_bycoord: we'll get 0 in Zaphod mode
* so it's the same, or maybe the real Xinerama screen */
if(screen == 0)
screen = screen_get_bycoord(x, y);
screen = screen_get_bycoord(screen, x, y);
break;
}
@ -315,7 +315,7 @@ handle_event_maprequest(XEvent *e)
{
static XWindowAttributes wa;
XMapRequestEvent *ev = &e->xmaprequest;
int screen, x, y, d;
int screen = 0, x, y, d;
unsigned int m;
Window dummy;
@ -325,10 +325,13 @@ handle_event_maprequest(XEvent *e)
return;
if(!client_get_bywin(globalconf.clients, ev->window))
{
for(screen = 0; wa.screen != ScreenOfDisplay(e->xany.display, screen); screen++);
if(screen == 0 && XQueryPointer(e->xany.display, RootWindow(e->xany.display, screen),
if(XineramaIsActive(globalconf.display)
&& XQueryPointer(e->xany.display, RootWindow(e->xany.display, screen),
&dummy, &dummy, &x, &y, &d, &d, &m))
screen = screen_get_bycoord(x, y);
screen = screen_get_bycoord(screen, x, y);
else
for(screen = 0; wa.screen != ScreenOfDisplay(e->xany.display, screen); screen++);
client_manage(ev->window, &wa, screen);
}
}

4
ewmh.c
View File

@ -149,10 +149,9 @@ ewmh_update_net_client_list(int phys_screen)
int n = 0;
for(c = globalconf.clients; c; c = c->next)
if(get_phys_screen(c->screen) == phys_screen)
n++;
wins = p_new(Window, n + 1);
wins = p_new(Window, n);
for(n = 0, c = globalconf.clients; c; c = c->next, n++)
if(get_phys_screen(c->screen) == phys_screen)
@ -162,7 +161,6 @@ ewmh_update_net_client_list(int phys_screen)
net_client_list, XA_WINDOW, 32, PropModeReplace, (unsigned char *) wins, n);
p_delete(&wins);
XFlush(globalconf.display);
}
void

View File

@ -116,7 +116,7 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused)))
XQueryPointer(globalconf.display,
RootWindow(globalconf.display, phys_screen),
&dummy, &child, &x, &y, &di, &di, &dui);
if((newscreen = screen_get_bycoord(x, y)) != c->screen)
if((newscreen = screen_get_bycoord(c->screen, x, y)) != c->screen)
{
move_client_to_screen(c, newscreen, True);
globalconf.screens[c->screen].need_arrange = True;

View File

@ -110,14 +110,14 @@ get_display_area(int screen, Statusbar *statusbar, Padding *padding)
* \return screen number or DefaultScreen of disp on no match
*/
int
screen_get_bycoord(int x, int y)
screen_get_bycoord(int screen, int x, int y)
{
int i;
Area area;
/* don't waste our time */
if(!XineramaIsActive(globalconf.display))
return DefaultScreen(globalconf.display);
return screen;
for(i = 0; i < globalconf.nscreen; i++)
{

View File

@ -26,7 +26,7 @@
Area screen_get_area(int, Statusbar *, Padding *);
Area get_display_area(int, Statusbar *, Padding *);
int screen_get_bycoord(int, int);
int screen_get_bycoord(int, int, int);
void screen_build_screens(void);
int get_phys_screen(int);
void move_client_to_screen(Client *, int, Bool);