mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-18 20:10:29 +01:00
Correctly draw window snapping hints on multi-head systems
Previously, the transparent frames that were drawn prior to snapping a window assumed that there was only one head, i.e., that the new position and dimensions of the window would be based on the dimensions of the entire screen. However, this is not the case on multi-head systems, and so we now base the transparent frame's position and dimensions on the current head of the window. We also refactor the code so that the new dimensions are computed in the switch statement and finish with one final call to drawTransparentFrame.
This commit is contained in:
committed by
Carlos R. Mafra
parent
9cc16182d3
commit
0718297e9a
@@ -1199,46 +1199,65 @@ updateWindowPosition(WWindow * wwin, MoveData * data, Bool doResistance,
|
|||||||
static void draw_snap_frame(WWindow *wwin, int direction)
|
static void draw_snap_frame(WWindow *wwin, int direction)
|
||||||
{
|
{
|
||||||
WScreen *scr;
|
WScreen *scr;
|
||||||
|
int head, x, y;
|
||||||
|
unsigned int width, height;
|
||||||
|
WMRect rect;
|
||||||
|
|
||||||
scr = wwin->screen_ptr;
|
scr = wwin->screen_ptr;
|
||||||
|
head = wGetHeadForWindow(wwin);
|
||||||
|
rect = wGetRectForHead(scr, head);
|
||||||
|
|
||||||
|
x = rect.pos.x;
|
||||||
|
y = rect.pos.y;
|
||||||
|
width = rect.size.width;
|
||||||
|
height = rect.size.height;
|
||||||
|
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case SNAP_LEFT:
|
case SNAP_LEFT:
|
||||||
drawTransparentFrame(wwin, 0, 0, scr->scr_width/2, scr->scr_height);
|
width /= 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNAP_RIGHT:
|
case SNAP_RIGHT:
|
||||||
drawTransparentFrame(wwin, scr->scr_width/2, 0, scr->scr_width/2, scr->scr_height);
|
width /= 2;
|
||||||
|
x += width;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNAP_TOP:
|
case SNAP_TOP:
|
||||||
if (wPreferences.snap_to_top_maximizes_fullscreen)
|
if (!wPreferences.snap_to_top_maximizes_fullscreen)
|
||||||
drawTransparentFrame(wwin, 0, 0, scr->scr_width, scr->scr_height);
|
height /= 2;
|
||||||
else
|
|
||||||
drawTransparentFrame(wwin, 0, 0, scr->scr_width, scr->scr_height/2);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNAP_BOTTOM:
|
case SNAP_BOTTOM:
|
||||||
drawTransparentFrame(wwin, 0, scr->scr_height/2, scr->scr_width, scr->scr_height/2);
|
height /= 2;
|
||||||
|
y += height;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNAP_TOPLEFT:
|
case SNAP_TOPLEFT:
|
||||||
drawTransparentFrame(wwin, 0, 0, scr->scr_width/2, scr->scr_height/2);
|
width /= 2;
|
||||||
|
height /= 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNAP_TOPRIGHT:
|
case SNAP_TOPRIGHT:
|
||||||
drawTransparentFrame(wwin, scr->scr_width/2, 0, scr->scr_width/2, scr->scr_height/2);
|
width /= 2;
|
||||||
|
height /= 2;
|
||||||
|
x += width;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNAP_BOTTOMLEFT:
|
case SNAP_BOTTOMLEFT:
|
||||||
drawTransparentFrame(wwin, 0, scr->scr_height/2, scr->scr_width/2, scr->scr_height/2);
|
width /= 2;
|
||||||
|
height /= 2;
|
||||||
|
y += height;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNAP_BOTTOMRIGHT:
|
case SNAP_BOTTOMRIGHT:
|
||||||
drawTransparentFrame(wwin, scr->scr_width/2, scr->scr_height/2,
|
width /= 2;
|
||||||
scr->scr_width/2, scr->scr_height/2);
|
height /= 2;
|
||||||
|
x += width;
|
||||||
|
y += height;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drawTransparentFrame(wwin, x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_snap_direction(WScreen *scr, int x, int y)
|
static int get_snap_direction(WScreen *scr, int x, int y)
|
||||||
|
|||||||
Reference in New Issue
Block a user