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

IPC feature documentation improvement for dwl patching #3

Open
yveszoundi opened this issue Feb 22, 2023 · 6 comments
Open

IPC feature documentation improvement for dwl patching #3

yveszoundi opened this issue Feb 22, 2023 · 6 comments

Comments

@yveszoundi
Copy link

Summary

Patching dwl for the IPC feature is not clear, per current documentation.

Current problem and ambiguity

If dwl is patched appropriately, dwlb is capable of communicating directly with dwl doesn't really tell what is required, especially for people who have never used/tried somebar:

  • Users could attempt to apply the wayland IPC patch from somebar. However, most people wont likely notice proposed updates.
  • Users might also try applying the swaycompat patch which I believe is related to the wayland-ipc patch, but incomplete as far as I can tell (no XML file in the diff or whatsoever)

Request

Indicate clearly which dwl patch to apply to enjoy the dwlb IPC feature, in the README.

I think that even a link to the pending diff is fine, until it's updated in the somebar repository.

@kolunmi
Copy link
Owner

kolunmi commented Feb 22, 2023

I've added the link to the pending diff in the README. This is probably not an optimal long-term solution, however, so I'll keep this issue open. Thank you.

@yveszoundi
Copy link
Author

While working on displaying the number of clients for the monocle layout is positive (djpohly/dwl#388), I realized that it didn't work once the IPC feature got added (if IPC is enabled).

  • I added a new ltsymbol field in the IPC protocol XML descriptor (similar to title field)
  • On the dwl side, the ltsymbol value is sent similarly to the title field
diff --git a/dwlb.c b/dwlb.c
index a053d38..31081fb 100644
--- a/dwlb.c
+++ b/dwlb.c
@@ -140,6 +140,7 @@ struct Bar {
 	uint32_t layout_idx;
 	uint32_t last_layout_idx;
 	char title[1024];
+	char ltsymbol[16];
 	char status[1024];
 	
 	StatusColor *status_colors;
@@ -418,7 +419,7 @@ draw_frame(Bar *bar)
 			      bar->width, bar->height, bar->textpadding, NULL, 0);
 	}
 	
-	x = draw_text(bar->layout, x, y, foreground, background,
+	x = draw_text(bar->ltsymbol, x, y, foreground, background,
 		      &inactive_fg_color, &inactive_bg_color, bar->width,
 		      bar->height, bar->textpadding, NULL, 0);
 	
@@ -808,6 +809,18 @@ dwl_wm_monitor_layout(void *data, struct znet_tapesoftware_dwl_wm_monitor_v1 *dw
 	}
 }
 
+static void
+dwl_wm_monitor_ltsymbol(void *data, struct znet_tapesoftware_dwl_wm_monitor_v1 *dwl_wm_monitor,
+		     const char *ltsymbol)
+{
+	Bar *bar = (Bar *)data;
+	
+	if (strcmp(bar->ltsymbol, ltsymbol) != 0) {
+		snprintf(bar->ltsymbol, sizeof bar->ltsymbol, "%s", ltsymbol);
+		bar->redraw = true;
+	}
+}
+
 static void
 dwl_wm_monitor_title(void *data, struct znet_tapesoftware_dwl_wm_monitor_v1 *dwl_wm_monitor,
 		     const char *title)
@@ -829,6 +842,7 @@ static const struct znet_tapesoftware_dwl_wm_monitor_v1_listener dwl_wm_monitor_
 	.selected = dwl_wm_monitor_selected,
 	.tag = dwl_wm_monitor_tag,
 	.layout = dwl_wm_monitor_layout,
+	.ltsymbol = dwl_wm_monitor_ltsymbol,
 	.title = dwl_wm_monitor_title,
 	.frame = dwl_wm_monitor_frame
 };
@@ -875,8 +889,10 @@ setup_bar(Bar *bar)
 	bar->bottom = bottom;
 	bar->hidden = hidden;
 
-	if (!ipc)
+	if (!ipc) {
 		snprintf(bar->layout, sizeof bar->layout, "[]=");
+		snprintf(bar->ltsymbol, sizeof bar->ltsymbol, "[]=");
+	}
 		
 	bar->xdg_output = zxdg_output_manager_v1_get_xdg_output(output_manager, bar->wl_output);
 	if (!bar->xdg_output)
diff --git a/protocols/net-tapesoftware-dwl-wm-unstable-v1.xml b/protocols/net-tapesoftware-dwl-wm-unstable-v1.xml
index 4fe5b73..1b333d0 100644
--- a/protocols/net-tapesoftware-dwl-wm-unstable-v1.xml
+++ b/protocols/net-tapesoftware-dwl-wm-unstable-v1.xml
@@ -121,6 +121,13 @@
             <arg name="layout" type="uint" summary="index of a layout received by the dwl_wm_v1.layout event."/>
         </event>
 
+        <event name="ltsymbol">
+            <description summary="The layout symbol">
+                Announces the update of the layout symbol.
+            </description>
+            <arg name="ltsymbol" type="string"/>
+        </event>
+        
         <event name="title">
             <description summary="updates the focused client">
                 Announces the update of the selected client.

@kolunmi
Copy link
Owner

kolunmi commented Feb 24, 2023

Once your pull request is merged with dwl, open one here so we can discuss these changes.

@podit
Copy link
Contributor

podit commented May 25, 2023

hey @yveszoundi, this has been merged with dwl. i was just about to update my dwl when i noticed this commit, would this mean that it would break the IPC behaviour in dwlb, or has that been fixed in the dwl implemtation?

@yveszoundi
Copy link
Author

yveszoundi commented May 25, 2023

@podit My dwl changes have indeed been merged upstream (client count information for monocle layout).

  • There shouldn't be any breakage for dwlb, because the feature implemented in dwl is additive,
  • @kolunmi, wanted to discuss the design first
    • The guts of changes consist into leveraging a new message payload to display the layout symbol
    • Most of what needs to be concretely updated can be found in my previous message in this thread

If my approach makes sense and the changes are desirable, I can create a pull request relatively soon.

@podit
Copy link
Contributor

podit commented May 26, 2023

great, thanks i'll give it a go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants