mirror of
				https://github.com/DreamMaoMao/maomaowm.git
				synced 2025-11-03 09:01:47 -05:00 
			
		
		
		
	feat:add sprial and dwindle layout
This commit is contained in:
		
							parent
							
								
									8b4932fd79
								
							
						
					
					
						commit
						4be4c211df
					
				
					 3 changed files with 123 additions and 49 deletions
				
			
		| 
						 | 
					@ -51,7 +51,7 @@ scratchpadcolor=0x516c93ff
 | 
				
			||||||
globalcolor=0xb153a7ff
 | 
					globalcolor=0xb153a7ff
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# tags rule
 | 
					# tags rule
 | 
				
			||||||
# layout support: tile,scroller,grid,monocle
 | 
					# layout support: tile,scroller,grid,monocle,spiral,dwindle
 | 
				
			||||||
tags=id:1,layout_name:tile
 | 
					tags=id:1,layout_name:tile
 | 
				
			||||||
tags=id:2,layout_name:tile
 | 
					tags=id:2,layout_name:tile
 | 
				
			||||||
tags=id:3,layout_name:tile
 | 
					tags=id:3,layout_name:tile
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										162
									
								
								maomao.c
									
										
									
									
									
								
							
							
						
						
									
										162
									
								
								maomao.c
									
										
									
									
									
								
							| 
						 | 
					@ -485,7 +485,8 @@ static void tile(Monitor *m, unsigned int gappo, unsigned int uappi);
 | 
				
			||||||
static void overview(Monitor *m, unsigned int gappo, unsigned int gappi);
 | 
					static void overview(Monitor *m, unsigned int gappo, unsigned int gappi);
 | 
				
			||||||
static void grid(Monitor *m, unsigned int gappo, unsigned int uappi);
 | 
					static void grid(Monitor *m, unsigned int gappo, unsigned int uappi);
 | 
				
			||||||
static void scroller(Monitor *m, unsigned int gappo, unsigned int uappi);
 | 
					static void scroller(Monitor *m, unsigned int gappo, unsigned int uappi);
 | 
				
			||||||
 | 
					static void dwindle(Monitor *mon, unsigned int gappo, unsigned int gappi);
 | 
				
			||||||
 | 
					static void spiral(Monitor *mon, unsigned int gappo, unsigned int gappi);
 | 
				
			||||||
static void unlocksession(struct wl_listener *listener, void *data);
 | 
					static void unlocksession(struct wl_listener *listener, void *data);
 | 
				
			||||||
static void unmaplayersurfacenotify(struct wl_listener *listener, void *data);
 | 
					static void unmaplayersurfacenotify(struct wl_listener *listener, void *data);
 | 
				
			||||||
static void unmapnotify(struct wl_listener *listener, void *data);
 | 
					static void unmapnotify(struct wl_listener *listener, void *data);
 | 
				
			||||||
| 
						 | 
					@ -2493,56 +2494,56 @@ void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
 | 
				
			||||||
  focused = focustop(monitor);
 | 
					  focused = focustop(monitor);
 | 
				
			||||||
  zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon);
 | 
					  zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if ((monitor->tagset[monitor->seltags] & TAGMASK) == TAGMASK) {
 | 
					  // if ((monitor->tagset[monitor->seltags] & TAGMASK) == TAGMASK) {
 | 
				
			||||||
    state = 0;
 | 
					  //   state = 0;
 | 
				
			||||||
    state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_ACTIVE;
 | 
					  //   state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_ACTIVE;
 | 
				
			||||||
    zdwl_ipc_output_v2_send_tag(ipc_output->resource, 888, state, 1, 1);
 | 
					  //   zdwl_ipc_output_v2_send_tag(ipc_output->resource, 888, state, 1, 1);
 | 
				
			||||||
  } else {
 | 
					  // } else {
 | 
				
			||||||
    for (tag = 0; tag < LENGTH(tags); tag++) {
 | 
					  //   for (tag = 0; tag < LENGTH(tags); tag++) {
 | 
				
			||||||
      numclients = state = focused_client = 0;
 | 
					 | 
				
			||||||
      tagmask = 1 << tag;
 | 
					 | 
				
			||||||
      if ((tagmask & monitor->tagset[monitor->seltags]) != 0)
 | 
					 | 
				
			||||||
        state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_ACTIVE;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      wl_list_for_each(c, &clients, link) {
 | 
					 | 
				
			||||||
        if (c->iskilling)
 | 
					 | 
				
			||||||
          continue;
 | 
					 | 
				
			||||||
        if (c->mon != monitor)
 | 
					 | 
				
			||||||
          continue;
 | 
					 | 
				
			||||||
        if (!(c->tags & tagmask))
 | 
					 | 
				
			||||||
          continue;
 | 
					 | 
				
			||||||
        if (c == focused)
 | 
					 | 
				
			||||||
          focused_client = 1;
 | 
					 | 
				
			||||||
        if (c->isurgent)
 | 
					 | 
				
			||||||
          state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_URGENT;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        numclients++;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      zdwl_ipc_output_v2_send_tag(ipc_output->resource, tag, state, numclients,
 | 
					 | 
				
			||||||
                                  focused_client);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // for ( tag = 0 ; tag < LENGTH(tags); tag++) {
 | 
					 | 
				
			||||||
  //     numclients = state = focused_client = 0;
 | 
					  //     numclients = state = focused_client = 0;
 | 
				
			||||||
  //     tagmask = 1 << tag;
 | 
					  //     tagmask = 1 << tag;
 | 
				
			||||||
  //     if ((tagmask & monitor->tagset[monitor->seltags]) != 0)
 | 
					  //     if ((tagmask & monitor->tagset[monitor->seltags]) != 0)
 | 
				
			||||||
  //         state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_ACTIVE;
 | 
					  //       state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_ACTIVE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //     wl_list_for_each(c, &clients, link) {
 | 
					  //     wl_list_for_each(c, &clients, link) {
 | 
				
			||||||
  //         if (c->mon != monitor)
 | 
					  //       if (c->iskilling)
 | 
				
			||||||
  //             continue;
 | 
					  //         continue;
 | 
				
			||||||
  //         if (!(c->tags & tagmask))
 | 
					  //       if (c->mon != monitor)
 | 
				
			||||||
  //             continue;
 | 
					  //         continue;
 | 
				
			||||||
  //         if (c == focused)
 | 
					  //       if (!(c->tags & tagmask))
 | 
				
			||||||
  //             focused_client = 1;
 | 
					  //         continue;
 | 
				
			||||||
  //         if (c->isurgent)
 | 
					  //       if (c == focused)
 | 
				
			||||||
  //             state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_URGENT;
 | 
					  //         focused_client = 1;
 | 
				
			||||||
  //         numclients++;
 | 
					  //       if (c->isurgent)
 | 
				
			||||||
 | 
					  //         state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_URGENT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //       numclients++;
 | 
				
			||||||
  //     }
 | 
					  //     }
 | 
				
			||||||
  //     zdwl_ipc_output_v2_send_tag(ipc_output->resource, tag, state,
 | 
					  //     zdwl_ipc_output_v2_send_tag(ipc_output->resource, tag, state, numclients,
 | 
				
			||||||
  //     numclients, focused_client);
 | 
					  //                                 focused_client);
 | 
				
			||||||
 | 
					  //   }
 | 
				
			||||||
  // }
 | 
					  // }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for ( tag = 0 ; tag < LENGTH(tags); tag++) {
 | 
				
			||||||
 | 
					      numclients = state = focused_client = 0;
 | 
				
			||||||
 | 
					      tagmask = 1 << tag;
 | 
				
			||||||
 | 
					      if ((tagmask & monitor->tagset[monitor->seltags]) != 0)
 | 
				
			||||||
 | 
					          state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_ACTIVE;
 | 
				
			||||||
 | 
					      wl_list_for_each(c, &clients, link) {
 | 
				
			||||||
 | 
					          if (c->mon != monitor)
 | 
				
			||||||
 | 
					              continue;
 | 
				
			||||||
 | 
					          if (!(c->tags & tagmask))
 | 
				
			||||||
 | 
					              continue;
 | 
				
			||||||
 | 
					          if (c == focused)
 | 
				
			||||||
 | 
					              focused_client = 1;
 | 
				
			||||||
 | 
					          if (c->isurgent)
 | 
				
			||||||
 | 
					              state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_URGENT;
 | 
				
			||||||
 | 
					          numclients++;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      zdwl_ipc_output_v2_send_tag(ipc_output->resource, tag, state,
 | 
				
			||||||
 | 
					      numclients, focused_client);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  title = focused ? client_get_title(focused) : "";
 | 
					  title = focused ? client_get_title(focused) : "";
 | 
				
			||||||
  appid = focused ? client_get_appid(focused) : "";
 | 
					  appid = focused ? client_get_appid(focused) : "";
 | 
				
			||||||
  symbol =
 | 
					  symbol =
 | 
				
			||||||
| 
						 | 
					@ -3245,7 +3246,7 @@ monocle(Monitor *m,unsigned int gappo, unsigned int gappi) {
 | 
				
			||||||
  int n = 0;
 | 
					  int n = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  wl_list_for_each(c, &clients, link) {
 | 
					  wl_list_for_each(c, &clients, link) {
 | 
				
			||||||
    if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
 | 
					    if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen || c->ismaxmizescreen || c->iskilling || c->animation.tagouting)
 | 
				
			||||||
      continue;
 | 
					      continue;
 | 
				
			||||||
    resize(c, m->w, 0);
 | 
					    resize(c, m->w, 0);
 | 
				
			||||||
    n++;
 | 
					    n++;
 | 
				
			||||||
| 
						 | 
					@ -4833,6 +4834,77 @@ void overview(Monitor *m, unsigned int gappo, unsigned int gappi) {
 | 
				
			||||||
  grid(m, overviewgappo, overviewgappi);
 | 
					  grid(m, overviewgappo, overviewgappi);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void fibonacci(Monitor *mon, int s) {
 | 
				
			||||||
 | 
						unsigned int i=0, n=0, nx, ny, nw, nh;
 | 
				
			||||||
 | 
						Client *c;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						wl_list_for_each(c, &clients, link)
 | 
				
			||||||
 | 
							if (VISIBLEON(c, mon) && !c->isfloating)
 | 
				
			||||||
 | 
								n++;
 | 
				
			||||||
 | 
						if(n == 0)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						nx = mon->w.x;
 | 
				
			||||||
 | 
						ny = 0;
 | 
				
			||||||
 | 
						nw = mon->w.width;
 | 
				
			||||||
 | 
						nh = mon->w.height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						wl_list_for_each(c, &clients, link)
 | 
				
			||||||
 | 
							if (VISIBLEON(c, mon) && !c->isfloating){
 | 
				
			||||||
 | 
							if((i % 2 && nh / 2 > 2 * c->bw)
 | 
				
			||||||
 | 
							   || (!(i % 2) && nw / 2 > 2 * c->bw)) {
 | 
				
			||||||
 | 
								if(i < n - 1) {
 | 
				
			||||||
 | 
									if(i % 2)
 | 
				
			||||||
 | 
										nh /= 2;
 | 
				
			||||||
 | 
									else
 | 
				
			||||||
 | 
										nw /= 2;
 | 
				
			||||||
 | 
									if((i % 4) == 2 && !s)
 | 
				
			||||||
 | 
										nx += nw;
 | 
				
			||||||
 | 
									else if((i % 4) == 3 && !s)
 | 
				
			||||||
 | 
										ny += nh;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if((i % 4) == 0) {
 | 
				
			||||||
 | 
									if(s)
 | 
				
			||||||
 | 
										ny += nh;
 | 
				
			||||||
 | 
									else
 | 
				
			||||||
 | 
										ny -= nh;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else if((i % 4) == 1)
 | 
				
			||||||
 | 
									nx += nw;
 | 
				
			||||||
 | 
								else if((i % 4) == 2)
 | 
				
			||||||
 | 
									ny += nh;
 | 
				
			||||||
 | 
								else if((i % 4) == 3) {
 | 
				
			||||||
 | 
									if(s)
 | 
				
			||||||
 | 
										nx += nw;
 | 
				
			||||||
 | 
									else
 | 
				
			||||||
 | 
										nx -= nw;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if(i == 0)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									if(n != 1)
 | 
				
			||||||
 | 
										nw = mon->w.width * mon->mfact;
 | 
				
			||||||
 | 
									ny = mon->w.y;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else if(i == 1)
 | 
				
			||||||
 | 
									nw = mon->w.width - nw;
 | 
				
			||||||
 | 
								i++;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							resize(c, (struct wlr_box){.x = nx, .y = ny,
 | 
				
			||||||
 | 
								.width = nw - 2 * c->bw, .height = nh - 2 * c->bw}, 0);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					dwindle(Monitor *mon,unsigned int gappo, unsigned int gappi) {
 | 
				
			||||||
 | 
						fibonacci(mon, 1);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					spiral(Monitor *mon, unsigned int gappo, unsigned int gappi) {
 | 
				
			||||||
 | 
						fibonacci(mon, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 网格布局窗口大小和位置计算
 | 
					// 网格布局窗口大小和位置计算
 | 
				
			||||||
void grid(Monitor *m, unsigned int gappo, unsigned int gappi) {
 | 
					void grid(Monitor *m, unsigned int gappo, unsigned int gappi) {
 | 
				
			||||||
  unsigned int i, n;
 | 
					  unsigned int i, n;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -67,10 +67,12 @@ Layout overviewlayout = { "",  overview, "overview" };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Layout layouts[] = { //最少两个,不能删除少于两个
 | 
					Layout layouts[] = { //最少两个,不能删除少于两个
 | 
				
			||||||
	/* symbol     arrange function   name */
 | 
						/* symbol     arrange function   name */
 | 
				
			||||||
	{ "⬌",      scroller, "scroller" },	//滚动布局
 | 
						{ "S",      scroller, "scroller" },	//滚动布局
 | 
				
			||||||
	{ "",      tile, "tile" },	//堆栈布局
 | 
						{ "T",      tile, "tile" },	//堆栈布局
 | 
				
			||||||
	{"", grid, "grid"},
 | 
						{"G", grid, "grid"},
 | 
				
			||||||
	{"M",monocle,"monocle"},
 | 
						{"M",monocle,"monocle"},
 | 
				
			||||||
 | 
						{"D",dwindle,"dwindle"},
 | 
				
			||||||
 | 
						{"P",spiral,"spiral"},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue