|
1 | | -#include "libglace-private.h" |
| 1 | +#include "glace-private.h" |
2 | 2 |
|
3 | 3 | static guint glace_client_signals[GLACE_CLIENT_N_SIGNALS] = {0}; |
4 | 4 | static GParamSpec* glace_client_properties[GLACE_CLIENT_N_PROPERTIES] = { |
@@ -324,4 +324,122 @@ GlaceClient* glace_client_new( |
324 | 324 | return self; |
325 | 325 | } |
326 | 326 |
|
| 327 | +// client getters |
| 328 | +guint glace_client_get_id(GlaceClient* self) { |
| 329 | + return (guint)self->priv->id; |
| 330 | +} |
| 331 | + |
| 332 | +const gchar* glace_client_get_app_id(GlaceClient* self) { |
| 333 | + return CLIENT_GET_CURRENT_PROP(self, app_id); |
| 334 | +} |
| 335 | + |
| 336 | +const gchar* glace_client_get_title(GlaceClient* self) { |
| 337 | + return CLIENT_GET_CURRENT_PROP(self, title); |
| 338 | +} |
| 339 | + |
| 340 | +gboolean glace_client_get_maximized(GlaceClient* self) { |
| 341 | + return CLIENT_GET_CURRENT_PROP(self, maximized); |
| 342 | +} |
| 343 | + |
| 344 | +gboolean glace_client_get_minimized(GlaceClient* self) { |
| 345 | + return CLIENT_GET_CURRENT_PROP(self, minimized); |
| 346 | +} |
| 347 | + |
| 348 | +gboolean glace_client_get_activated(GlaceClient* self) { |
| 349 | + return CLIENT_GET_CURRENT_PROP(self, activated); |
| 350 | +} |
| 351 | + |
| 352 | +gboolean glace_client_get_fullscreen(GlaceClient* self) { |
| 353 | + return CLIENT_GET_CURRENT_PROP(self, fullscreen); |
| 354 | +} |
| 355 | + |
| 356 | +gboolean glace_client_get_closed(GlaceClient* self) { |
| 357 | + return self->priv->closed; |
| 358 | +} |
| 359 | + |
| 360 | +// client methods |
| 361 | +void glace_client_maximize(GlaceClient* self) { |
| 362 | + // replacing EMPTY_TOKEN with a trailing comma |
| 363 | + // will do the trick as well |
| 364 | + RETURN_IF_INVALID_CLIENT(self, EMPTY_TOKEN); |
| 365 | + |
| 366 | + zwlr_foreign_toplevel_handle_v1_set_maximized(self->priv->wlr_handle); |
| 367 | +} |
| 368 | + |
| 369 | +void glace_client_unmaximize(GlaceClient* self) { |
| 370 | + RETURN_IF_INVALID_CLIENT(self, EMPTY_TOKEN); |
| 371 | + |
| 372 | + zwlr_foreign_toplevel_handle_v1_unset_maximized(self->priv->wlr_handle); |
| 373 | +} |
| 374 | + |
| 375 | +void glace_client_minimize(GlaceClient* self) { |
| 376 | + RETURN_IF_INVALID_CLIENT(self, EMPTY_TOKEN); |
| 377 | + |
| 378 | + zwlr_foreign_toplevel_handle_v1_set_minimized(self->priv->wlr_handle); |
| 379 | +} |
| 380 | + |
| 381 | +void glace_client_unminimize(GlaceClient* self) { |
| 382 | + RETURN_IF_INVALID_CLIENT(self, EMPTY_TOKEN); |
| 383 | + |
| 384 | + zwlr_foreign_toplevel_handle_v1_unset_minimized(self->priv->wlr_handle); |
| 385 | +} |
| 386 | + |
| 387 | +void glace_client_close(GlaceClient* self) { |
| 388 | + RETURN_IF_INVALID_CLIENT(self, EMPTY_TOKEN); |
| 389 | + |
| 390 | + zwlr_foreign_toplevel_handle_v1_close(self->priv->wlr_handle); |
| 391 | +} |
| 392 | + |
| 393 | +void glace_client_activate(GlaceClient* self) { |
| 394 | + RETURN_IF_INVALID_CLIENT(self, EMPTY_TOKEN); |
| 395 | + |
| 396 | + GdkSeat* gdk_seat = gdk_display_get_default_seat(self->priv->gdk_display); |
| 397 | + struct wl_seat* seat = gdk_wayland_seat_get_wl_seat(gdk_seat); |
| 398 | + |
| 399 | + zwlr_foreign_toplevel_handle_v1_activate( |
| 400 | + self->priv->wlr_handle, |
| 401 | + seat |
| 402 | + ); |
| 403 | +} |
| 404 | + |
| 405 | +void glace_client_move( |
| 406 | + GlaceClient* self, |
| 407 | + GdkWindow* window, |
| 408 | + const GdkRectangle* rectangle |
| 409 | +) { |
| 410 | + RETURN_IF_INVALID_CLIENT(self, EMPTY_TOKEN); |
| 411 | + |
| 412 | + if (window == NULL) { |
| 413 | + zwlr_foreign_toplevel_handle_v1_set_rectangle( |
| 414 | + self->priv->wlr_handle, |
| 415 | + NULL, |
| 416 | + rectangle->x, |
| 417 | + rectangle->y, |
| 418 | + rectangle->width, |
| 419 | + rectangle->height |
| 420 | + ); |
| 421 | + return; |
| 422 | + } |
| 423 | + |
| 424 | + zwlr_foreign_toplevel_handle_v1_set_rectangle( |
| 425 | + self->priv->wlr_handle, |
| 426 | + gdk_wayland_window_get_wl_surface(window), |
| 427 | + rectangle->x, |
| 428 | + rectangle->y, |
| 429 | + rectangle->width, |
| 430 | + rectangle->height |
| 431 | + ); |
| 432 | +} |
| 433 | + |
| 434 | +void glace_client_fullscreen(GlaceClient* self) { |
| 435 | + RETURN_IF_INVALID_CLIENT(self, EMPTY_TOKEN); |
| 436 | + |
| 437 | + zwlr_foreign_toplevel_handle_v1_set_fullscreen(self->priv->wlr_handle, self->priv->output); |
| 438 | +} |
| 439 | + |
| 440 | +void glace_client_unfullscreen(GlaceClient* self) { |
| 441 | + RETURN_IF_INVALID_CLIENT(self, EMPTY_TOKEN); |
| 442 | + |
| 443 | + zwlr_foreign_toplevel_handle_v1_unset_fullscreen(self->priv->wlr_handle); |
| 444 | +} |
327 | 445 | G_DEFINE_TYPE(GlaceClient, glace_client, G_TYPE_OBJECT); |
0 commit comments