Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating window gets pushed left when moving to the right side of the screen #1

Open
eeeXun opened this issue Jan 22, 2021 · 10 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@eeeXun
Copy link

eeeXun commented Jan 22, 2021

When the window in floating mode, and drag it to a specific area, it would overflow or something.

ezgif com-gif-maker

@saloniamatteo
Copy link
Owner

saloniamatteo commented Jan 22, 2021 via email

@saloniamatteo
Copy link
Owner

I have spent a few hours trying to fix the bug, but so far I haven't made any progress.

I will continue another time; Any help is appreciated.

@saloniamatteo saloniamatteo added bug Something isn't working help wanted Extra attention is needed labels Jan 22, 2021
@saloniamatteo saloniamatteo pinned this issue Jan 22, 2021
@saloniamatteo saloniamatteo changed the title Flaoting window broken Floating window gets pushed left when moving to the right side of the screen Jan 22, 2021
@eeeXun eeeXun closed this as completed Jan 23, 2021
@eeeXun eeeXun reopened this Jan 23, 2021
@eeeXun
Copy link
Author

eeeXun commented Jan 23, 2021

That's fine.By the way,your dwm is very awesome.

@saloniamatteo
Copy link
Owner

Thanks 😁

@nicksaprigkin
Copy link

nicksaprigkin commented Feb 19, 2024

The problem is with the custom systray patch ([dwm-systray.diff], in the dwm.c 'drawbar' function exactly . Here is the fixed function just replace it:

void drawbar(Monitor *m) {
  int x, w, tw = 0, stw = 0;
  int boxs = drw->fonts->h / 9;
  int boxw = drw->fonts->h / 6 + 2;
  unsigned int i, occ = 0, urg = 0;
  Client *c;

  if (showsystray && m == systraytomon(m))
    stw = getsystraywidth();

  /* draw status first so it can be overdrawn by tags later */
  if (m == selmon) { /* status is only drawn on selected monitor */
    drw_setscheme(drw, scheme[SchemeNorm]);
    tw = TEXTW(stext) - lrpad / 2 + 2; /* 2px right padding */
    drw_text(drw, m->ww - tw - stw, 0, tw, bh, lrpad / 2 - 2, stext, 0);
  }

  resizebarwin(m);
  for (c = m->clients; c; c = c->next) {
    occ |= c->tags == 255 ? 0 : c->tags;
    if (c->isurgent)
      urg |= c->tags;
  }
  x = 0;
  for (i = 0; i < LENGTH(tags); i++) {
    /* do not draw vacant tags */
    if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
      continue;

    w = TEXTW(tags[i]);
    drw_setscheme(
        drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
    drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);

    if (occ & 1 << i)
      drw_rect(drw, x + boxs, boxs, boxw, boxw,
               m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
               urg & 1 << i);

    x += w;
  }
  w = blw = TEXTW(m->ltsymbol);
  drw_setscheme(drw, scheme[SchemeNorm]);
  x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);

  if ((w = m->ww - tw - stw - x) > bh) {
    if (m->sel) {
      drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
      drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
      if (m->sel->isfloating)
        drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
    } else {
      drw_setscheme(drw, scheme[SchemeNorm]);
      drw_rect(drw, x, 0, w, bh, 1, 1);
    }
  }

  drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
}

The exact lines that were changed in this function are:

int x, w, stw = 0; --> to: int x, w, tw = 0, stw = 0;

sw = TEXTW(stext) - lrpad / 2 + 2; /* 2px right padding */ --> to    tw = TEXTW(stext) - lrpad / 2 + 2; /* 2px right padding */

drw_text(drw, m->ww - sw - stw, 0, sw, bh, lrpad / 2 - 2, stext, 0); --> to: drw_text(drw, m->ww - tw - stw, 0, tw, bh, lrpad / 2 - 2, stext, 0);

if ((w = m->ww - sw - stw - x) > bh) { --> to: if ((w = m->ww - tw - stw - x) > bh) {

@saloniamatteo
Copy link
Owner

Thank you very much for commenting! I will try out this patch later on in the day, and will update the code if everything goes well.

@saloniamatteo
Copy link
Owner

Hi @nicksaprigkin, I am afraid I have tried your patch, only to find out not only does it not work, but the systray (as well as the whole bar for dwmblocks) gets removed as well (as in, there is no space for it).

Anyway, one of these days I ought to start this from scratch: get dwm sources, get patches, and fix everything...

@nicksaprigkin
Copy link

@saloniamatteo was this commented or you edited it? c/* draw status first so it can be overdrawn by tags later / if (m == selmon) { / status is only drawn on selected monitor / drw_setscheme(drw, scheme[SchemeNorm]); tw = TEXTW(stext) - lrpad / 2 + 2; / 2px right padding */
if it was then my bad i also forgot to list it in the "lines that were changed:" c sw = TEXTW(stext) - lrpad / 2 + 2; /* 2px right padding */ --> to tw = TEXTW(stext) - lrpad / 2 + 2; /* 2px right padding */
if you commented then it i guess it works for my monitor or something...!

@nicksaprigkin
Copy link

I updated the original comment btw

@nicksaprigkin
Copy link

Also I found this! so maybe the problem is with the version of dwm. I have version 6.2 and in that version its tw instead of sw. I found this in reddit:
image
link: https://git.suckless.org/dwm/commit/ed3ab6b4fceded0e9f2d22372df49a2bbd58de66.html
so I guess my solution works for dwm 6.2 and maybe @eeeXun has it too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants