LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 881|回复: 0

[zz]dwm的 'View last view' 补丁

[复制链接]
发表于 2007-3-20 18:14:07 | 显示全部楼层 |阅读模式
http://flash.metawaredesign.co.uk/4/
站点本身就是dwm化的,呵呵

打了补丁后,Alt-Tab即可切回原先的tag,很实用的
http://flash.metawaredesign.co.uk/files/dwm/dwm-3.8-viewlast.diff

  1. diff -up dwm-3.8/config.default.h dwm-3.8-viewlast/config.default.h
  2. --- dwm-3.8/config.default.h        2007-03-05 10:54:57.000000000 +0000
  3. +++ dwm-3.8-viewlast/config.default.h        2007-03-05 19:10:20.000000000 +0000
  4. @@ -53,6 +53,7 @@ static Key key[] = { \
  5.         { MODKEY,                        XK_k,                focusclient,        "-1" }, \
  6.         { MODKEY,                        XK_m,                togglemax,        NULL }, \
  7.         { MODKEY,                        XK_Return,        zoom,                NULL }, \
  8. +        { MODKEY,                        XK_Tab,        viewlast,                NULL }, \
  9.         { MODKEY|ShiftMask,                XK_space,        togglefloating,        NULL }, \
  10.         { MODKEY|ShiftMask,                XK_c,                killclient,        NULL }, \
  11.         { MODKEY,                        XK_0,                view,                NULL }, \
  12. diff -up dwm-3.8/dwm.h dwm-3.8-viewlast/dwm.h
  13. --- dwm-3.8/dwm.h        2007-03-05 10:54:57.000000000 +0000
  14. +++ dwm-3.8-viewlast/dwm.h        2007-03-05 19:10:20.000000000 +0000
  15. @@ -87,6 +87,7 @@ unsigned int ntags, numlockmask;        /* numb
  16. void (*handler[LASTEvent])(XEvent *);        /* event handler */
  17. Atom wmatom[WMLast], netatom[NetLast];
  18. Bool selscreen, *seltag;                /* seltag is array of Bool */
  19. +unsigned int currenttag, lasttag;  /* The last tag viewed */
  20. Client *clients, *sel, *stack;                /* global client list and stack */
  21. Cursor cursor[CurLast];
  22. DC dc;                                        /* global draw context */
  23. @@ -139,6 +140,7 @@ void settags(Client *c, Client *trans);       
  24. void tag(const char *arg);                /* tags c with arg's index */
  25. void toggletag(const char *arg);                /* toggles c tags with arg's index */
  26. void toggleview(const char *arg);        /* toggles the tag with arg's index (in)visible */
  27. +void viewlast(void);     /* views the last viewed tag */
  28. void view(const char *arg);                /* views the tag with arg's index */

  29. /* util.c */
  30. diff -up dwm-3.8/main.c dwm-3.8-viewlast/main.c
  31. --- dwm-3.8/main.c        2007-03-05 10:54:57.000000000 +0000
  32. +++ dwm-3.8-viewlast/main.c        2007-03-05 19:10:20.000000000 +0000
  33. @@ -20,6 +20,7 @@
  34. char stext[256];
  35. int screen, sx, sy, sw, sh, wax, way, waw, wah;
  36. unsigned int bh, ntags, numlockmask;
  37. +unsigned int currenttag, lasttag;
  38. Atom wmatom[WMLast], netatom[NetLast];
  39. Bool *seltag;
  40. Bool selscreen = True;
  41. @@ -185,6 +186,8 @@ setup(void) {
  42.         sw = DisplayWidth(dpy, screen);
  43.         sh = DisplayHeight(dpy, screen);
  44.         initlayouts();
  45. +  currenttag = 0;
  46. +  lasttag = 0;
  47.         /* bar */
  48.         dc.h = bh = dc.font.height + 2;
  49.         wa.override_redirect = 1;
  50. diff -up dwm-3.8/tag.c dwm-3.8-viewlast/tag.c
  51. --- dwm-3.8/tag.c        2007-03-05 10:54:57.000000000 +0000
  52. +++ dwm-3.8-viewlast/tag.c        2007-03-05 19:11:32.000000000 +0000
  53. @@ -142,13 +142,27 @@ toggleview(const char *arg) {
  54. }

  55. void
  56. +viewlast(void) {
  57. +  char buf[32];
  58. +  snprintf(buf, sizeof buf, "%d", lasttag);
  59. +  view(buf);
  60. +  lt->arrange();
  61. +}
  62. +
  63. +void
  64. view(const char *arg) {
  65.         int i;

  66.         for(i = 0; i < ntags; i++)
  67.                 seltag[i] = arg == NULL;
  68.         i = arg ? atoi(arg) : 0;
  69. -        if(i >= 0 && i < ntags)
  70. +        if(i >= 0 && i < ntags) {
  71.                 seltag[i] = True;
  72. +
  73. +    if (currenttag != i) {
  74. +      lasttag = currenttag;
  75. +      currenttag = i;
  76. +    }
  77. +  }
  78.         lt->arrange();
  79. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表