/* PanelWindow.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from PanelWindow.vala, do not modify */

/*
 * Copyright (c) 2011-2015 Wingpanel Developers (http://launchpad.net/wingpanel)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA.
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include "pantheon-desktop-shell-client-protocol.h"
#include <wayland-client.h>
#include <gdk/gdk.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdkwayland.h>
#include <cairo-gobject.h>
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <X11/Xregion.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define WINGPANEL_TYPE_PANEL_WINDOW (wingpanel_panel_window_get_type ())
#define WINGPANEL_PANEL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WINGPANEL_TYPE_PANEL_WINDOW, WingpanelPanelWindow))
#define WINGPANEL_PANEL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WINGPANEL_TYPE_PANEL_WINDOW, WingpanelPanelWindowClass))
#define WINGPANEL_IS_PANEL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WINGPANEL_TYPE_PANEL_WINDOW))
#define WINGPANEL_IS_PANEL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WINGPANEL_TYPE_PANEL_WINDOW))
#define WINGPANEL_PANEL_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WINGPANEL_TYPE_PANEL_WINDOW, WingpanelPanelWindowClass))

typedef struct _WingpanelPanelWindow WingpanelPanelWindow;
typedef struct _WingpanelPanelWindowClass WingpanelPanelWindowClass;
typedef struct _WingpanelPanelWindowPrivate WingpanelPanelWindowPrivate;

#define WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER (wingpanel_services_popover_manager_get_type ())
#define WINGPANEL_SERVICES_POPOVER_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER, WingpanelServicesPopoverManager))
#define WINGPANEL_SERVICES_POPOVER_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER, WingpanelServicesPopoverManagerClass))
#define WINGPANEL_SERVICES_IS_POPOVER_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER))
#define WINGPANEL_SERVICES_IS_POPOVER_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER))
#define WINGPANEL_SERVICES_POPOVER_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER, WingpanelServicesPopoverManagerClass))

typedef struct _WingpanelServicesPopoverManager WingpanelServicesPopoverManager;
typedef struct _WingpanelServicesPopoverManagerClass WingpanelServicesPopoverManagerClass;

#define WINGPANEL_WIDGETS_TYPE_PANEL (wingpanel_widgets_panel_get_type ())
#define WINGPANEL_WIDGETS_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WINGPANEL_WIDGETS_TYPE_PANEL, WingpanelWidgetsPanel))
#define WINGPANEL_WIDGETS_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WINGPANEL_WIDGETS_TYPE_PANEL, WingpanelWidgetsPanelClass))
#define WINGPANEL_WIDGETS_IS_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WINGPANEL_WIDGETS_TYPE_PANEL))
#define WINGPANEL_WIDGETS_IS_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WINGPANEL_WIDGETS_TYPE_PANEL))
#define WINGPANEL_WIDGETS_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WINGPANEL_WIDGETS_TYPE_PANEL, WingpanelWidgetsPanelClass))

typedef struct _WingpanelWidgetsPanel WingpanelWidgetsPanel;
typedef struct _WingpanelWidgetsPanelClass WingpanelWidgetsPanelClass;
enum  {
	WINGPANEL_PANEL_WINDOW_0_PROPERTY,
	WINGPANEL_PANEL_WINDOW_NUM_PROPERTIES
};
static GParamSpec* wingpanel_panel_window_properties[WINGPANEL_PANEL_WINDOW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _wl_proxy_destroy0(var) ((var == NULL) ? NULL : (var = (wl_proxy_destroy (var), NULL)))

#define WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY (wingpanel_widgets_indicator_entry_get_type ())
#define WINGPANEL_WIDGETS_INDICATOR_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY, WingpanelWidgetsIndicatorEntry))
#define WINGPANEL_WIDGETS_INDICATOR_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY, WingpanelWidgetsIndicatorEntryClass))
#define WINGPANEL_WIDGETS_IS_INDICATOR_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY))
#define WINGPANEL_WIDGETS_IS_INDICATOR_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY))
#define WINGPANEL_WIDGETS_INDICATOR_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY, WingpanelWidgetsIndicatorEntryClass))

typedef struct _WingpanelWidgetsIndicatorEntry WingpanelWidgetsIndicatorEntry;
typedef struct _WingpanelWidgetsIndicatorEntryClass WingpanelWidgetsIndicatorEntryClass;

#define WINGPANEL_SERVICES_TYPE_BACKGROUND_MANAGER (wingpanel_services_background_manager_get_type ())
#define WINGPANEL_SERVICES_BACKGROUND_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WINGPANEL_SERVICES_TYPE_BACKGROUND_MANAGER, WingpanelServicesBackgroundManager))
#define WINGPANEL_SERVICES_BACKGROUND_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WINGPANEL_SERVICES_TYPE_BACKGROUND_MANAGER, WingpanelServicesBackgroundManagerClass))
#define WINGPANEL_SERVICES_IS_BACKGROUND_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WINGPANEL_SERVICES_TYPE_BACKGROUND_MANAGER))
#define WINGPANEL_SERVICES_IS_BACKGROUND_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WINGPANEL_SERVICES_TYPE_BACKGROUND_MANAGER))
#define WINGPANEL_SERVICES_BACKGROUND_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WINGPANEL_SERVICES_TYPE_BACKGROUND_MANAGER, WingpanelServicesBackgroundManagerClass))

typedef struct _WingpanelServicesBackgroundManager WingpanelServicesBackgroundManager;
typedef struct _WingpanelServicesBackgroundManagerClass WingpanelServicesBackgroundManagerClass;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef void (*wl_RegistryListenerGlobal) (void* data, struct wl_registry* wl_registry, guint32 name, const gchar* interface, guint32 version);
#define _wl_registry_destroy0(var) ((var == NULL) ? NULL : (var = (wl_registry_destroy (var), NULL)))

struct _WingpanelPanelWindow {
	GtkWindow parent_instance;
	WingpanelPanelWindowPrivate * priv;
	WingpanelServicesPopoverManager* popover_manager;
};

struct _WingpanelPanelWindowClass {
	GtkWindowClass parent_class;
};

struct _WingpanelPanelWindowPrivate {
	WingpanelWidgetsPanel* panel;
	GtkEventControllerKey* key_controller;
	GtkRevealer* revealer;
	gint monitor_width;
	gint monitor_height;
	gint panel_height;
	gboolean expanded;
	struct io_elementary_pantheon_shell_v1* desktop_shell;
	struct io_elementary_pantheon_panel_v1* desktop_panel;
};

static gint WingpanelPanelWindow_private_offset;
static gpointer wingpanel_panel_window_parent_class = NULL;
static struct wl_registry_listener wingpanel_panel_window_registry_listener;
static struct wl_registry_listener wingpanel_panel_window_registry_listener = {0};

VALA_EXTERN GType wingpanel_panel_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WingpanelPanelWindow, g_object_unref)
VALA_EXTERN GType wingpanel_services_popover_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WingpanelServicesPopoverManager, g_object_unref)
VALA_EXTERN GType wingpanel_widgets_panel_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WingpanelWidgetsPanel, g_object_unref)
VALA_EXTERN WingpanelPanelWindow* wingpanel_panel_window_new (GtkApplication* application);
VALA_EXTERN WingpanelPanelWindow* wingpanel_panel_window_construct (GType object_type,
                                                        GtkApplication* application);
static void wingpanel_panel_window_update_panel_dimensions (WingpanelPanelWindow* self);
static void _wingpanel_panel_window_update_panel_dimensions_gdk_screen_size_changed (GdkScreen* _sender,
                                                                              gpointer self);
static void _wingpanel_panel_window_update_panel_dimensions_gdk_screen_monitors_changed (GdkScreen* _sender,
                                                                                  gpointer self);
static void wingpanel_panel_window_update_visual (WingpanelPanelWindow* self);
static void _wingpanel_panel_window_update_visual_gtk_widget_screen_changed (GtkWidget* _sender,
                                                                      GdkScreen* previous_screen,
                                                                      gpointer self);
VALA_EXTERN WingpanelServicesPopoverManager* wingpanel_services_popover_manager_new (WingpanelPanelWindow* owner);
VALA_EXTERN WingpanelServicesPopoverManager* wingpanel_services_popover_manager_construct (GType object_type,
                                                                               WingpanelPanelWindow* owner);
VALA_EXTERN WingpanelWidgetsPanel* wingpanel_widgets_panel_new (WingpanelServicesPopoverManager* popover_manager);
VALA_EXTERN WingpanelWidgetsPanel* wingpanel_widgets_panel_construct (GType object_type,
                                                          WingpanelServicesPopoverManager* popover_manager);
static void wingpanel_panel_window_on_realize (WingpanelPanelWindow* self);
static void _wingpanel_panel_window_on_realize_gtk_widget_realize (GtkWidget* _sender,
                                                            gpointer self);
static void __lambda22_ (WingpanelPanelWindow* self);
VALA_EXTERN void wingpanel_widgets_panel_cycle (WingpanelWidgetsPanel* self,
                                    gboolean forward);
static void ___lambda22__g_simple_action_activate (GSimpleAction* _sender,
                                            GVariant* parameter,
                                            gpointer self);
static void __lambda23_ (WingpanelPanelWindow* self);
static void ___lambda23__g_simple_action_activate (GSimpleAction* _sender,
                                            GVariant* parameter,
                                            gpointer self);
static gboolean wingpanel_panel_window_on_key_pressed (WingpanelPanelWindow* self,
                                                guint keyval,
                                                guint keycode,
                                                GdkModifierType state);
static gboolean _wingpanel_panel_window_on_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                                      guint keyval,
                                                                                      guint keycode,
                                                                                      GdkModifierType state,
                                                                                      gpointer self);
static void _wingpanel_panel_window_update_panel_dimensions_gtk_widget_size_allocate (GtkWidget* _sender,
                                                                               GtkAllocation* allocation,
                                                                               gpointer self);
static void wingpanel_panel_window_on_scale_changed (WingpanelPanelWindow* self);
static void _wingpanel_panel_window_on_scale_changed_g_object_notify (GObject* _sender,
                                                               GParamSpec* pspec,
                                                               gpointer self);
VALA_EXTERN void wingpanel_services_background_manager_initialize (gint panel_height);
static void wingpanel_panel_window_init_wl (WingpanelPanelWindow* self);
static void _wingpanel_panel_window_init_wl_gsource_once_func (gpointer self);
static void wingpanel_panel_window_init_x (WingpanelPanelWindow* self);
VALA_EXTERN gboolean wingpanel_services_display_config_is_logical_layout (void);
VALA_EXTERN GType wingpanel_widgets_indicator_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WingpanelWidgetsIndicatorEntry, g_object_unref)
VALA_EXTERN WingpanelWidgetsIndicatorEntry* wingpanel_services_popover_manager_get_current_indicator (WingpanelServicesPopoverManager* self);
VALA_EXTERN void wingpanel_services_popover_manager_close (WingpanelServicesPopoverManager* self);
VALA_EXTERN void wingpanel_panel_window_set_expanded (WingpanelPanelWindow* self,
                                          gboolean expand);
VALA_EXTERN GType wingpanel_services_background_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WingpanelServicesBackgroundManager, g_object_unref)
VALA_EXTERN WingpanelServicesBackgroundManager* wingpanel_services_background_manager_get_default (void);
VALA_EXTERN void wingpanel_services_background_manager_remember_window (WingpanelServicesBackgroundManager* self);
VALA_EXTERN void wingpanel_services_background_manager_restore_window (WingpanelServicesBackgroundManager* self);
VALA_EXTERN void wingpanel_panel_window_toggle_indicator (WingpanelPanelWindow* self,
                                              const gchar* name);
VALA_EXTERN void wingpanel_services_popover_manager_toggle_popover_visible (WingpanelServicesPopoverManager* self,
                                                                const gchar* code_name);
static gint wingpanel_panel_window_get_actual_height (WingpanelPanelWindow* self);
VALA_EXTERN void wingpanel_panel_window_registry_handle_global (WingpanelPanelWindow* self,
                                                    struct wl_registry* wl_registry,
                                                    guint32 name,
                                                    const gchar* interface,
                                                    guint32 version);
static void _wingpanel_panel_window_update_panel_dimensions_gsource_once_func (gpointer self);
static void _wingpanel_panel_window_registry_handle_global_wl_registrylistenerglobal (void* data,
                                                                               struct wl_registry* wl_registry,
                                                                               guint32 name,
                                                                               const gchar* interface,
                                                                               guint32 version);
static void wingpanel_panel_window_finalize (GObject * obj);
static GType wingpanel_panel_window_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
wingpanel_panel_window_get_instance_private (WingpanelPanelWindow* self)
{
	return G_STRUCT_MEMBER_P (self, WingpanelPanelWindow_private_offset);
}

static void
_wingpanel_panel_window_update_panel_dimensions_gdk_screen_size_changed (GdkScreen* _sender,
                                                                         gpointer self)
{
	wingpanel_panel_window_update_panel_dimensions ((WingpanelPanelWindow*) self);
}

static void
_wingpanel_panel_window_update_panel_dimensions_gdk_screen_monitors_changed (GdkScreen* _sender,
                                                                             gpointer self)
{
	wingpanel_panel_window_update_panel_dimensions ((WingpanelPanelWindow*) self);
}

static void
_wingpanel_panel_window_update_visual_gtk_widget_screen_changed (GtkWidget* _sender,
                                                                 GdkScreen* previous_screen,
                                                                 gpointer self)
{
	wingpanel_panel_window_update_visual ((WingpanelPanelWindow*) self);
}

static void
_wingpanel_panel_window_on_realize_gtk_widget_realize (GtkWidget* _sender,
                                                       gpointer self)
{
	wingpanel_panel_window_on_realize ((WingpanelPanelWindow*) self);
}

static void
__lambda22_ (WingpanelPanelWindow* self)
{
	WingpanelWidgetsPanel* _tmp0_;
	_tmp0_ = self->priv->panel;
	wingpanel_widgets_panel_cycle (_tmp0_, TRUE);
}

static void
___lambda22__g_simple_action_activate (GSimpleAction* _sender,
                                       GVariant* parameter,
                                       gpointer self)
{
	__lambda22_ ((WingpanelPanelWindow*) self);
}

static void
__lambda23_ (WingpanelPanelWindow* self)
{
	WingpanelWidgetsPanel* _tmp0_;
	_tmp0_ = self->priv->panel;
	wingpanel_widgets_panel_cycle (_tmp0_, FALSE);
}

static void
___lambda23__g_simple_action_activate (GSimpleAction* _sender,
                                       GVariant* parameter,
                                       gpointer self)
{
	__lambda23_ ((WingpanelPanelWindow*) self);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static gboolean
_wingpanel_panel_window_on_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                             guint keyval,
                                                                             guint keycode,
                                                                             GdkModifierType state,
                                                                             gpointer self)
{
	gboolean result;
	result = wingpanel_panel_window_on_key_pressed ((WingpanelPanelWindow*) self, keyval, keycode, state);
	return result;
}

static void
_wingpanel_panel_window_update_panel_dimensions_gtk_widget_size_allocate (GtkWidget* _sender,
                                                                          GtkAllocation* allocation,
                                                                          gpointer self)
{
	wingpanel_panel_window_update_panel_dimensions ((WingpanelPanelWindow*) self);
}

static void
_wingpanel_panel_window_on_scale_changed_g_object_notify (GObject* _sender,
                                                          GParamSpec* pspec,
                                                          gpointer self)
{
	wingpanel_panel_window_on_scale_changed ((WingpanelPanelWindow*) self);
}

WingpanelPanelWindow*
wingpanel_panel_window_construct (GType object_type,
                                  GtkApplication* application)
{
	WingpanelPanelWindow * self = NULL;
	GtkCssProvider* app_provider = NULL;
	GtkCssProvider* _tmp0_;
	GdkScreen* _tmp1_;
	GdkScreen* _tmp2_;
	GdkScreen* _tmp3_;
	GdkScreen* _tmp4_;
	GdkScreen* _tmp5_;
	WingpanelServicesPopoverManager* _tmp6_;
	WingpanelServicesPopoverManager* _tmp7_;
	WingpanelWidgetsPanel* _tmp8_;
	WingpanelWidgetsPanel* _tmp9_;
	GSimpleAction* cycle_action = NULL;
	GSimpleAction* _tmp10_;
	GSimpleAction* cycle_back_action = NULL;
	GSimpleAction* _tmp11_;
	gchar* _tmp12_;
	gchar** _tmp13_;
	gchar** _tmp14_;
	gint _tmp14__length1;
	gchar* _tmp15_;
	gchar** _tmp16_;
	gchar** _tmp17_;
	gint _tmp17__length1;
	WingpanelWidgetsPanel* _tmp18_;
	GtkWidget* _tmp19_;
	GtkRevealer* _tmp20_ = NULL;
	GtkRevealer* _tmp21_;
	GtkEventControllerKey* _tmp22_;
	GtkEventControllerKey* _tmp23_;
	WingpanelWidgetsPanel* _tmp24_;
	g_return_val_if_fail (application != NULL, NULL);
	self = (WingpanelPanelWindow*) g_object_new (object_type, "application", application, "app-paintable", TRUE, "decorated", FALSE, "resizable", FALSE, "skip-pager-hint", TRUE, "skip-taskbar-hint", TRUE, "vexpand", FALSE, NULL);
	_tmp0_ = gtk_css_provider_new ();
	app_provider = _tmp0_;
	gtk_css_provider_load_from_resource (app_provider, "io/elementary/wingpanel/Application.css");
	_tmp1_ = gdk_screen_get_default ();
	gtk_style_context_add_provider_for_screen (_tmp1_, (GtkStyleProvider*) app_provider, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	_tmp2_ = gtk_window_get_screen ((GtkWindow*) self);
	_tmp3_ = _tmp2_;
	g_signal_connect_object (_tmp3_, "size-changed", (GCallback) _wingpanel_panel_window_update_panel_dimensions_gdk_screen_size_changed, self, 0);
	_tmp4_ = gtk_window_get_screen ((GtkWindow*) self);
	_tmp5_ = _tmp4_;
	g_signal_connect_object (_tmp5_, "monitors-changed", (GCallback) _wingpanel_panel_window_update_panel_dimensions_gdk_screen_monitors_changed, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "screen-changed", (GCallback) _wingpanel_panel_window_update_visual_gtk_widget_screen_changed, self, 0);
	wingpanel_panel_window_update_visual (self);
	_tmp6_ = wingpanel_services_popover_manager_new (self);
	_g_object_unref0 (self->popover_manager);
	self->popover_manager = _tmp6_;
	_tmp7_ = self->popover_manager;
	_tmp8_ = wingpanel_widgets_panel_new (_tmp7_);
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->panel);
	self->priv->panel = _tmp8_;
	_tmp9_ = self->priv->panel;
	g_signal_connect_object ((GtkWidget*) _tmp9_, "realize", (GCallback) _wingpanel_panel_window_on_realize_gtk_widget_realize, self, 0);
	_tmp10_ = g_simple_action_new ("cycle", NULL);
	cycle_action = _tmp10_;
	g_signal_connect_object (cycle_action, "activate", (GCallback) ___lambda22__g_simple_action_activate, self, 0);
	_tmp11_ = g_simple_action_new ("cycle-back", NULL);
	cycle_back_action = _tmp11_;
	g_signal_connect_object (cycle_back_action, "activate", (GCallback) ___lambda23__g_simple_action_activate, self, 0);
	g_action_map_add_action ((GActionMap*) application, (GAction*) cycle_action);
	g_action_map_add_action ((GActionMap*) application, (GAction*) cycle_back_action);
	_tmp12_ = g_strdup ("<Control>Tab");
	_tmp13_ = g_new0 (gchar*, 1 + 1);
	_tmp13_[0] = _tmp12_;
	_tmp14_ = _tmp13_;
	_tmp14__length1 = 1;
	gtk_application_set_accels_for_action (application, "app.cycle", _tmp14_);
	_tmp14_ = (_vala_array_free (_tmp14_, _tmp14__length1, (GDestroyNotify) g_free), NULL);
	_tmp15_ = g_strdup ("<Control><Shift>Tab");
	_tmp16_ = g_new0 (gchar*, 1 + 1);
	_tmp16_[0] = _tmp15_;
	_tmp17_ = _tmp16_;
	_tmp17__length1 = 1;
	gtk_application_set_accels_for_action (application, "app.cycle-back", _tmp17_);
	_tmp17_ = (_vala_array_free (_tmp17_, _tmp17__length1, (GDestroyNotify) g_free), NULL);
	_tmp18_ = self->priv->panel;
	_tmp19_ = _g_object_ref0 ((GtkWidget*) _tmp18_);
	_tmp20_ = (GtkRevealer*) gtk_revealer_new ();
	g_object_set ((GtkContainer*) _tmp20_, "child", _tmp19_, NULL);
	_g_object_unref0 (_tmp19_);
	gtk_revealer_set_reveal_child (_tmp20_, TRUE);
	gtk_revealer_set_transition_type (_tmp20_, GTK_REVEALER_TRANSITION_TYPE_NONE);
	g_object_ref_sink (_tmp20_);
	_g_object_unref0 (self->priv->revealer);
	self->priv->revealer = _tmp20_;
	_tmp21_ = self->priv->revealer;
	g_object_set ((GtkContainer*) self, "child", (GtkWidget*) _tmp21_, NULL);
	_tmp22_ = (GtkEventControllerKey*) gtk_event_controller_key_new ((GtkWidget*) self);
	_g_object_unref0 (self->priv->key_controller);
	self->priv->key_controller = _tmp22_;
	_tmp23_ = self->priv->key_controller;
	g_signal_connect_object (_tmp23_, "key-pressed", (GCallback) _wingpanel_panel_window_on_key_pressed_gtk_event_controller_key_key_pressed, self, 0);
	_tmp24_ = self->priv->panel;
	g_signal_connect_object ((GtkWidget*) _tmp24_, "size-allocate", (GCallback) _wingpanel_panel_window_update_panel_dimensions_gtk_widget_size_allocate, self, 0);
	g_signal_connect_object ((GObject*) self, "notify::scale-factor", (GCallback) _wingpanel_panel_window_on_scale_changed_g_object_notify, self, 0);
	_g_object_unref0 (cycle_back_action);
	_g_object_unref0 (cycle_action);
	_g_object_unref0 (app_provider);
	return self;
}

WingpanelPanelWindow*
wingpanel_panel_window_new (GtkApplication* application)
{
	return wingpanel_panel_window_construct (WINGPANEL_TYPE_PANEL_WINDOW, application);
}

static void
_wingpanel_panel_window_init_wl_gsource_once_func (gpointer self)
{
	wingpanel_panel_window_init_wl ((WingpanelPanelWindow*) self);
}

static void
wingpanel_panel_window_on_realize (WingpanelPanelWindow* self)
{
	GdkDisplay* _tmp0_;
	g_return_if_fail (self != NULL);
	wingpanel_panel_window_update_panel_dimensions (self);
	wingpanel_services_background_manager_initialize (self->priv->panel_height);
	_tmp0_ = gdk_display_get_default ();
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GDK_TYPE_WAYLAND_DISPLAY)) {
		g_idle_add_once (_wingpanel_panel_window_init_wl_gsource_once_func, self);
	} else {
		wingpanel_panel_window_init_x (self);
	}
}

static void
wingpanel_panel_window_update_panel_dimensions (WingpanelPanelWindow* self)
{
	WingpanelWidgetsPanel* _tmp0_;
	GdkRectangle monitor_dimensions = {0};
	GdkDisplay* _tmp1_;
	GdkWindow* _tmp2_;
	GdkMonitor* _tmp3_;
	GdkRectangle _tmp4_ = {0};
	gboolean _tmp5_ = FALSE;
	GdkRectangle _tmp7_;
	GdkRectangle _tmp8_;
	gint _tmp9_ = 0;
	WingpanelServicesPopoverManager* _tmp10_;
	WingpanelWidgetsIndicatorEntry* _tmp11_;
	WingpanelWidgetsIndicatorEntry* _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->panel;
	self->priv->panel_height = gtk_widget_get_allocated_height ((GtkWidget*) _tmp0_);
	_tmp1_ = gtk_widget_get_display ((GtkWidget*) self);
	_tmp2_ = gtk_widget_get_window ((GtkWidget*) self);
	_tmp3_ = gdk_display_get_monitor_at_window (_tmp1_, _tmp2_);
	gdk_monitor_get_geometry (_tmp3_, &_tmp4_);
	monitor_dimensions = _tmp4_;
	if (!wingpanel_services_display_config_is_logical_layout ()) {
		GdkDisplay* _tmp6_;
		_tmp6_ = gdk_display_get_default ();
		_tmp5_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp6_, GDK_TYPE_WAYLAND_DISPLAY);
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		monitor_dimensions.width = monitor_dimensions.width / gtk_widget_get_scale_factor ((GtkWidget*) self);
		monitor_dimensions.height = monitor_dimensions.height / gtk_widget_get_scale_factor ((GtkWidget*) self);
		monitor_dimensions.x = monitor_dimensions.x / gtk_widget_get_scale_factor ((GtkWidget*) self);
		monitor_dimensions.y = monitor_dimensions.y / gtk_widget_get_scale_factor ((GtkWidget*) self);
	}
	_tmp7_ = monitor_dimensions;
	self->priv->monitor_width = _tmp7_.width;
	_tmp8_ = monitor_dimensions;
	self->priv->monitor_height = _tmp8_.height;
	_tmp10_ = self->popover_manager;
	_tmp11_ = wingpanel_services_popover_manager_get_current_indicator (_tmp10_);
	_tmp12_ = _tmp11_;
	if (_tmp12_ != NULL) {
		_tmp9_ = self->priv->monitor_height;
	} else {
		_tmp9_ = -1;
	}
	gtk_widget_set_size_request ((GtkWidget*) self, self->priv->monitor_width, _tmp9_);
}

static void
wingpanel_panel_window_update_visual (WingpanelPanelWindow* self)
{
	GdkVisual* visual = NULL;
	GdkScreen* _tmp0_;
	GdkScreen* _tmp1_;
	GdkVisual* _tmp2_;
	GdkVisual* _tmp3_;
	GdkVisual* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_window_get_screen ((GtkWindow*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = gdk_screen_get_rgba_visual (_tmp1_);
	_tmp3_ = _g_object_ref0 (_tmp2_);
	visual = _tmp3_;
	_tmp4_ = visual;
	if (_tmp4_ == NULL) {
		g_warning ("PanelWindow.vala:122: Compositing not available, things will Look Bad " \
"(TM)");
	} else {
		GdkVisual* _tmp5_;
		_tmp5_ = visual;
		gtk_widget_set_visual ((GtkWidget*) self, _tmp5_);
	}
	_g_object_unref0 (visual);
}

static gboolean
wingpanel_panel_window_on_key_pressed (WingpanelPanelWindow* self,
                                       guint keyval,
                                       guint keycode,
                                       GdkModifierType state)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (keyval == GDK_KEY_Escape) {
		WingpanelServicesPopoverManager* _tmp0_;
		_tmp0_ = self->popover_manager;
		wingpanel_services_popover_manager_close (_tmp0_);
	}
	result = GDK_EVENT_PROPAGATE;
	return result;
}

void
wingpanel_panel_window_set_expanded (WingpanelPanelWindow* self,
                                     gboolean expand)
{
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	if (expand) {
		_tmp0_ = !self->priv->expanded;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		WingpanelServicesBackgroundManager* _tmp1_;
		WingpanelServicesBackgroundManager* _tmp2_;
		struct io_elementary_pantheon_panel_v1* _tmp3_;
		_tmp1_ = wingpanel_services_background_manager_get_default ();
		_tmp2_ = _tmp1_;
		wingpanel_services_background_manager_remember_window (_tmp2_);
		_g_object_unref0 (_tmp2_);
		self->priv->expanded = TRUE;
		gtk_widget_set_size_request ((GtkWidget*) self, self->priv->monitor_width, self->priv->monitor_height);
		_tmp3_ = self->priv->desktop_panel;
		if (_tmp3_ != NULL) {
			struct io_elementary_pantheon_panel_v1* _tmp4_;
			_tmp4_ = self->priv->desktop_panel;
			io_elementary_pantheon_panel_v1_focus (_tmp4_);
		}
	} else {
		if (!expand) {
			WingpanelServicesBackgroundManager* _tmp5_;
			WingpanelServicesBackgroundManager* _tmp6_;
			_tmp5_ = wingpanel_services_background_manager_get_default ();
			_tmp6_ = _tmp5_;
			wingpanel_services_background_manager_restore_window (_tmp6_);
			_g_object_unref0 (_tmp6_);
			self->priv->expanded = FALSE;
			gtk_widget_set_size_request ((GtkWidget*) self, self->priv->monitor_width, -1);
			gtk_window_resize ((GtkWindow*) self, self->priv->monitor_width, 1);
		}
	}
}

void
wingpanel_panel_window_toggle_indicator (WingpanelPanelWindow* self,
                                         const gchar* name)
{
	WingpanelServicesPopoverManager* _tmp0_;
	struct io_elementary_pantheon_panel_v1* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_tmp0_ = self->popover_manager;
	wingpanel_services_popover_manager_toggle_popover_visible (_tmp0_, name);
	_tmp1_ = self->priv->desktop_panel;
	if (_tmp1_ != NULL) {
		struct io_elementary_pantheon_panel_v1* _tmp2_;
		_tmp2_ = self->priv->desktop_panel;
		io_elementary_pantheon_panel_v1_focus (_tmp2_);
	}
}

static void
wingpanel_panel_window_on_scale_changed (WingpanelPanelWindow* self)
{
	struct io_elementary_pantheon_panel_v1* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->desktop_panel;
	if (_tmp0_ != NULL) {
		struct io_elementary_pantheon_panel_v1* _tmp1_;
		_tmp1_ = self->priv->desktop_panel;
		io_elementary_pantheon_panel_v1_set_size (_tmp1_, -1, wingpanel_panel_window_get_actual_height (self));
	} else {
		wingpanel_panel_window_init_x (self);
	}
	wingpanel_panel_window_update_panel_dimensions (self);
}

static gint
wingpanel_panel_window_get_actual_height (WingpanelPanelWindow* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	if (!wingpanel_services_display_config_is_logical_layout ()) {
		result = gtk_widget_get_allocated_height ((GtkWidget*) self) * gtk_widget_get_scale_factor ((GtkWidget*) self);
		return result;
	}
	result = gtk_widget_get_allocated_height ((GtkWidget*) self);
	return result;
}

static void
wingpanel_panel_window_init_x (WingpanelPanelWindow* self)
{
	GdkDisplay* display = NULL;
	GdkDisplay* _tmp0_;
	GdkDisplay* _tmp1_;
	GdkDisplay* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gdk_display_get_default ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	display = _tmp1_;
	_tmp2_ = display;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, gdk_x11_display_get_type ())) {
		Display* xdisplay = NULL;
		GdkDisplay* _tmp3_;
		Display* _tmp4_;
		Window window = 0;
		GdkWindow* _tmp5_;
		Atom prop = {0};
		Display* _tmp6_;
		gchar* value = NULL;
		gchar* _tmp7_;
		Display* _tmp8_;
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		_tmp3_ = display;
		_tmp4_ = gdk_x11_display_get_xdisplay (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gdk_x11_display_get_type (), GdkX11Display));
		xdisplay = _tmp4_;
		_tmp5_ = gtk_widget_get_window ((GtkWidget*) self);
		window = gdk_x11_window_get_xid (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gdk_x11_window_get_type (), GdkX11Window));
		_tmp6_ = xdisplay;
		prop = XInternAtom (_tmp6_, "_MUTTER_HINTS", FALSE);
		_tmp7_ = g_strdup_printf ("anchor=4:hide-mode=0:size=-1,%d", wingpanel_panel_window_get_actual_height (self));
		value = _tmp7_;
		_tmp8_ = xdisplay;
		_tmp9_ = value;
		_tmp10_ = value;
		_tmp11_ = strlen (_tmp10_);
		_tmp12_ = _tmp11_;
		XChangeProperty (_tmp8_, window, prop, XA_STRING, 8, 0, (guchar*) _tmp9_, _tmp12_);
		_g_free0 (value);
	}
	_g_object_unref0 (display);
}

static void
_wingpanel_panel_window_update_panel_dimensions_gsource_once_func (gpointer self)
{
	wingpanel_panel_window_update_panel_dimensions ((WingpanelPanelWindow*) self);
}

void
wingpanel_panel_window_registry_handle_global (WingpanelPanelWindow* self,
                                               struct wl_registry* wl_registry,
                                               guint32 name,
                                               const gchar* interface,
                                               guint32 version)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (wl_registry != NULL);
	g_return_if_fail (interface != NULL);
	if (g_strcmp0 (interface, "io_elementary_pantheon_shell_v1") == 0) {
		gpointer _tmp0_;
		GdkWindow* window = NULL;
		GdkWindow* _tmp1_;
		GdkWindow* _tmp2_;
		_tmp0_ = wl_registry_bind (wl_registry, name, &io_elementary_pantheon_shell_v1_interface, MIN (version, (guint32) 1));
		_wl_proxy_destroy0 (self->priv->desktop_shell);
		self->priv->desktop_shell = (struct io_elementary_pantheon_shell_v1*) _tmp0_;
		_tmp1_ = gtk_widget_get_window ((GtkWidget*) self);
		window = _tmp1_;
		_tmp2_ = window;
		if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, GDK_TYPE_WAYLAND_WINDOW)) {
			struct wl_surface* wl_surface = NULL;
			GdkWindow* _tmp3_;
			struct wl_surface* _tmp4_;
			struct io_elementary_pantheon_shell_v1* _tmp5_;
			struct wl_surface* _tmp6_;
			struct io_elementary_pantheon_panel_v1* _tmp7_;
			struct io_elementary_pantheon_panel_v1* _tmp8_;
			struct io_elementary_pantheon_panel_v1* _tmp9_;
			struct io_elementary_pantheon_panel_v1* _tmp10_;
			_tmp3_ = window;
			_tmp4_ = gdk_wayland_window_get_wl_surface (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GDK_TYPE_WAYLAND_WINDOW, GdkWaylandWindow));
			wl_surface = _tmp4_;
			_tmp5_ = self->priv->desktop_shell;
			_tmp6_ = wl_surface;
			_tmp7_ = io_elementary_pantheon_shell_v1_get_panel (_tmp5_, _tmp6_);
			_wl_proxy_destroy0 (self->priv->desktop_panel);
			self->priv->desktop_panel = _tmp7_;
			_tmp8_ = self->priv->desktop_panel;
			io_elementary_pantheon_panel_v1_set_anchor (_tmp8_, IO_ELEMENTARY_PANTHEON_PANEL_V1_ANCHOR_TOP);
			_tmp9_ = self->priv->desktop_panel;
			io_elementary_pantheon_panel_v1_set_hide_mode (_tmp9_, IO_ELEMENTARY_PANTHEON_PANEL_V1_HIDE_MODE_NEVER);
			_tmp10_ = self->priv->desktop_panel;
			io_elementary_pantheon_panel_v1_set_size (_tmp10_, -1, wingpanel_panel_window_get_actual_height (self));
			g_idle_add_once (_wingpanel_panel_window_update_panel_dimensions_gsource_once_func, self);
		}
	}
}

static void
_wingpanel_panel_window_registry_handle_global_wl_registrylistenerglobal (void* data,
                                                                          struct wl_registry* wl_registry,
                                                                          guint32 name,
                                                                          const gchar* interface,
                                                                          guint32 version)
{
	wingpanel_panel_window_registry_handle_global (data, wl_registry, name, interface, version);
}

static void
wingpanel_panel_window_init_wl (WingpanelPanelWindow* self)
{
	GdkDisplay* display = NULL;
	GdkDisplay* _tmp0_;
	GdkDisplay* _tmp1_;
	g_return_if_fail (self != NULL);
	wingpanel_panel_window_registry_listener.global = _wingpanel_panel_window_registry_handle_global_wl_registrylistenerglobal;
	_tmp0_ = gdk_display_get_default ();
	display = _tmp0_;
	_tmp1_ = display;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, GDK_TYPE_WAYLAND_DISPLAY)) {
		struct wl_display* wl_display = NULL;
		GdkDisplay* _tmp2_;
		struct wl_display* _tmp3_;
		struct wl_registry* wl_registry = NULL;
		struct wl_display* _tmp4_;
		struct wl_registry* _tmp5_;
		struct wl_registry* _tmp6_;
		struct wl_registry_listener _tmp7_;
		struct wl_display* _tmp8_;
		_tmp2_ = display;
		_tmp3_ = gdk_wayland_display_get_wl_display (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GDK_TYPE_WAYLAND_DISPLAY, GdkWaylandDisplay));
		wl_display = _tmp3_;
		_tmp4_ = wl_display;
		_tmp5_ = wl_display_get_registry (_tmp4_);
		wl_registry = _tmp5_;
		_tmp6_ = wl_registry;
		_tmp7_ = wingpanel_panel_window_registry_listener;
		wl_registry_add_listener (_tmp6_, &_tmp7_, self);
		_tmp8_ = wl_display;
		if (wl_display_roundtrip (_tmp8_) < 0) {
			_wl_registry_destroy0 (wl_registry);
			return;
		}
		_wl_registry_destroy0 (wl_registry);
	}
}

static void
wingpanel_panel_window_class_init (WingpanelPanelWindowClass * klass,
                                   gpointer klass_data)
{
	wingpanel_panel_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &WingpanelPanelWindow_private_offset);
	G_OBJECT_CLASS (klass)->finalize = wingpanel_panel_window_finalize;
}

static void
wingpanel_panel_window_instance_init (WingpanelPanelWindow * self,
                                      gpointer klass)
{
	self->priv = wingpanel_panel_window_get_instance_private (self);
	self->priv->expanded = FALSE;
}

static void
wingpanel_panel_window_finalize (GObject * obj)
{
	WingpanelPanelWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WINGPANEL_TYPE_PANEL_WINDOW, WingpanelPanelWindow);
	_g_object_unref0 (self->popover_manager);
	_g_object_unref0 (self->priv->panel);
	_g_object_unref0 (self->priv->key_controller);
	_g_object_unref0 (self->priv->revealer);
	_wl_proxy_destroy0 (self->priv->desktop_shell);
	_wl_proxy_destroy0 (self->priv->desktop_panel);
	G_OBJECT_CLASS (wingpanel_panel_window_parent_class)->finalize (obj);
}

static GType
wingpanel_panel_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WingpanelPanelWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) wingpanel_panel_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WingpanelPanelWindow), 0, (GInstanceInitFunc) wingpanel_panel_window_instance_init, NULL };
	GType wingpanel_panel_window_type_id;
	wingpanel_panel_window_type_id = g_type_register_static (gtk_window_get_type (), "WingpanelPanelWindow", &g_define_type_info, 0);
	WingpanelPanelWindow_private_offset = g_type_add_instance_private (wingpanel_panel_window_type_id, sizeof (WingpanelPanelWindowPrivate));
	return wingpanel_panel_window_type_id;
}

GType
wingpanel_panel_window_get_type (void)
{
	static volatile gsize wingpanel_panel_window_type_id__once = 0;
	if (g_once_init_enter (&wingpanel_panel_window_type_id__once)) {
		GType wingpanel_panel_window_type_id;
		wingpanel_panel_window_type_id = wingpanel_panel_window_get_type_once ();
		g_once_init_leave (&wingpanel_panel_window_type_id__once, wingpanel_panel_window_type_id);
	}
	return wingpanel_panel_window_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

