Merge branch 'client_resize_do-prefer-current' of https://github.com/blueyed/awesome
This commit is contained in:
commit
22305f3abf
|
@ -799,7 +799,10 @@ client_resize_do(client_t *c, area_t geometry, bool force_notice)
|
||||||
lua_State *L = globalconf_get_lua_State();
|
lua_State *L = globalconf_get_lua_State();
|
||||||
bool send_notice = force_notice;
|
bool send_notice = force_notice;
|
||||||
bool hide_titlebars = c->fullscreen;
|
bool hide_titlebars = c->fullscreen;
|
||||||
screen_t *new_screen = screen_getbycoord(geometry.x, geometry.y);
|
|
||||||
|
screen_t *new_screen = c->screen;
|
||||||
|
if(!screen_coord_in_screen(new_screen, geometry.x, geometry.y))
|
||||||
|
new_screen = screen_getbycoord(geometry.x, geometry.y);
|
||||||
|
|
||||||
if(c->geometry.width == geometry.width
|
if(c->geometry.width == geometry.width
|
||||||
&& c->geometry.height == geometry.height)
|
&& c->geometry.height == geometry.height)
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "objects/client.h"
|
#include "objects/client.h"
|
||||||
#include "objects/drawin.h"
|
#include "objects/drawin.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
|
@ -284,8 +285,7 @@ screen_scan(void)
|
||||||
screen_scan_x11();
|
screen_scan_x11();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the Xinerama screen number where the coordinates belongs to.
|
/** Return the first screen number where the coordinates belong to.
|
||||||
* \param screen The logical screen number.
|
|
||||||
* \param x X coordinate
|
* \param x X coordinate
|
||||||
* \param y Y coordinate
|
* \param y Y coordinate
|
||||||
* \return Screen pointer or screen param if no match or no multi-head.
|
* \return Screen pointer or screen param if no match or no multi-head.
|
||||||
|
@ -294,12 +294,35 @@ screen_t *
|
||||||
screen_getbycoord(int x, int y)
|
screen_getbycoord(int x, int y)
|
||||||
{
|
{
|
||||||
foreach(s, globalconf.screens)
|
foreach(s, globalconf.screens)
|
||||||
if((x < 0 || (x >= (*s)->geometry.x && x < (*s)->geometry.x + (*s)->geometry.width))
|
if(screen_coord_in_screen(*s, x, y))
|
||||||
&& (y < 0 || (y >= (*s)->geometry.y && y < (*s)->geometry.y + (*s)->geometry.height)))
|
|
||||||
return *s;
|
return *s;
|
||||||
|
|
||||||
/* No screen found, let's be creative. */
|
/* No screen found, find nearest screen. */
|
||||||
return globalconf.screens.tab[0];
|
screen_t * nearest_screen = globalconf.screens.tab[0];
|
||||||
|
int nearest_dist = INT_MAX;
|
||||||
|
foreach(s, globalconf.screens)
|
||||||
|
{
|
||||||
|
int dist = sqrt(pow((*s)->geometry.x - x, 2) + pow((*s)->geometry.y - y, 2));
|
||||||
|
if( dist < nearest_dist )
|
||||||
|
{
|
||||||
|
nearest_dist = dist;
|
||||||
|
nearest_screen = (*s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nearest_screen;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Are the given coordinates in a given screen?
|
||||||
|
* \param screen The logical screen number.
|
||||||
|
* \param x X coordinate
|
||||||
|
* \param y Y coordinate
|
||||||
|
* \return True if the X/Y coordinates are in the given screen.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
screen_coord_in_screen(screen_t *s, int x, int y)
|
||||||
|
{
|
||||||
|
return (x >= s->geometry.x && x < s->geometry.x + s->geometry.width)
|
||||||
|
&& (y >= s->geometry.y && y < s->geometry.y + s->geometry.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get screens info.
|
/** Get screens info.
|
||||||
|
|
|
@ -43,6 +43,7 @@ ARRAY_FUNCS(screen_t *, screen, DO_NOTHING)
|
||||||
void screen_class_setup(lua_State *L);
|
void screen_class_setup(lua_State *L);
|
||||||
void screen_scan(void);
|
void screen_scan(void);
|
||||||
screen_t *screen_getbycoord(int, int);
|
screen_t *screen_getbycoord(int, int);
|
||||||
|
bool screen_coord_in_screen(screen_t *, int, int);
|
||||||
int screen_get_index(screen_t *);
|
int screen_get_index(screen_t *);
|
||||||
area_t display_area_get(void);
|
area_t display_area_get(void);
|
||||||
void screen_client_moveto(client_t *, screen_t *, bool);
|
void screen_client_moveto(client_t *, screen_t *, bool);
|
||||||
|
|
Loading…
Reference in New Issue