@@ -5,6 +5,14 @@ static GParamSpec* glace_client_properties[GLACE_CLIENT_N_PROPERTIES] = {
55 NULL ,
66};
77
8+ static void on_mapping_handle_window_address (void * user_data , struct hyprland_toplevel_window_mapping_handle_v1 * handle , uint32_t address_hi , uint32_t address );
9+ static void on_mapping_handle_failed (void * user_data , struct hyprland_toplevel_window_mapping_handle_v1 * handle );
10+
11+ static const struct hyprland_toplevel_window_mapping_handle_v1_listener mapping_handle_listener = {
12+ .window_address = & on_mapping_handle_window_address ,
13+ .failed = & on_mapping_handle_failed ,
14+ };
15+
816static void glace_client_signal_changed_emit (GlaceClient * self ) {
917 g_signal_emit (
1018 self ,
@@ -54,6 +62,9 @@ static void glace_client_get_property(
5462 case GLACE_CLIENT_PROPERTY_CLOSED :
5563 g_value_set_boolean (value , self -> priv -> closed );
5664 break ;
65+ case GLACE_CLIENT_PROPERTY_HYPRLAND_ADDRESS :
66+ g_value_set_uint64 (value , self -> priv -> hyprland_address );
67+ break ;
5768 default :
5869 G_OBJECT_WARN_INVALID_PROPERTY_ID (object , prop_id , pspec );
5970 break ;
@@ -285,6 +296,16 @@ static void glace_client_class_init(GlaceClientClass* klass) {
285296 G_PARAM_READABLE
286297 );
287298
299+ glace_client_properties [GLACE_CLIENT_PROPERTY_HYPRLAND_ADDRESS ] = g_param_spec_uint64 (
300+ "hyprland-address" ,
301+ "hyprland-address" ,
302+ "the internal window address for hyprland in 64bits" ,
303+ 0 ,
304+ G_MAXUINT64 ,
305+ 0 ,
306+ G_PARAM_READABLE
307+ );
308+
288309 g_object_class_install_properties (
289310 parent_class ,
290311 GLACE_CLIENT_N_PROPERTIES ,
@@ -300,6 +321,7 @@ static void glace_client_init(GlaceClient* self) {
300321 );
301322
302323 self -> priv -> closed = false;
324+ self -> priv -> hyprland_address = 0 ;
303325 CLIENT_SET_CURRENT_PROP (self , app_id , false);
304326 CLIENT_SET_CURRENT_PROP (self , title , false);
305327 CLIENT_SET_CURRENT_PROP (self , maximized , false);
@@ -308,8 +330,41 @@ static void glace_client_init(GlaceClient* self) {
308330 CLIENT_SET_CURRENT_PROP (self , fullscreen , false);
309331}
310332
333+ static void on_mapping_handle_window_address (
334+ void * user_data ,
335+ struct hyprland_toplevel_window_mapping_handle_v1 * handle ,
336+ // that's how you know a protocol is good
337+ uint32_t address_hi ,
338+ uint32_t address_lo
339+ ) {
340+ GlaceClient * self = GLACE_CLIENT (user_data );
341+ RETURN_IF_INVALID_CLIENT (self , hyprland_toplevel_window_mapping_handle_v1_destroy (handle ));
342+
343+ self -> priv -> hyprland_address = ((guint64 )address_hi << 32 ) | address_lo ;
344+
345+ // we have a proper address now, notify the user...
346+ g_object_notify_by_pspec (
347+ G_OBJECT (self ),
348+ glace_client_properties [GLACE_CLIENT_PROPERTY_HYPRLAND_ADDRESS ]
349+ );
350+
351+ glace_client_signal_changed_emit (self );
352+
353+ hyprland_toplevel_window_mapping_handle_v1_destroy (handle );
354+ }
355+
356+ static void on_mapping_handle_failed (
357+ void * user_data ,
358+ struct hyprland_toplevel_window_mapping_handle_v1 * handle
359+ ) {
360+ // something's fucked up, cleanup meanwhile
361+ hyprland_toplevel_window_mapping_handle_v1_destroy (handle );
362+ return ;
363+ }
364+
311365GlaceClient * glace_client_new (
312366 struct zwlr_foreign_toplevel_handle_v1 * wlr_handle ,
367+ struct hyprland_toplevel_mapping_manager_v1 * hl_mapping_manager ,
313368 GdkWaylandDisplay * gdk_display
314369) {
315370 GlaceClient * self = g_object_new (GLACE_TYPE_CLIENT , NULL );
@@ -321,6 +376,22 @@ GlaceClient* glace_client_new(
321376 & toplevel_handle_listener ,
322377 self
323378 );
379+
380+ if (!hl_mapping_manager )
381+ return self ;
382+
383+ struct hyprland_toplevel_window_mapping_handle_v1 *
384+ handle = hyprland_toplevel_mapping_manager_v1_get_window_for_toplevel_wlr (
385+ hl_mapping_manager ,
386+ self -> priv -> wlr_handle
387+ );
388+
389+ hyprland_toplevel_window_mapping_handle_v1_add_listener (
390+ handle ,
391+ & mapping_handle_listener ,
392+ self // Pass the client instance as user data
393+ );
394+
324395 return self ;
325396}
326397
@@ -329,6 +400,10 @@ guint glace_client_get_id(GlaceClient* self) {
329400 return (guint )self -> priv -> id ;
330401}
331402
403+ guint64 glace_client_get_hyprland_address (GlaceClient * self ) {
404+ return (guint64 )self -> priv -> hyprland_address ;
405+ }
406+
332407const gchar * glace_client_get_app_id (GlaceClient * self ) {
333408 return CLIENT_GET_CURRENT_PROP (self , app_id );
334409}
0 commit comments