mirror of
https://github.com/rozniak/xfce-winxp-tc.git
synced 2026-05-01 11:41:30 +00:00
Enhancement: Fixes #184, Replace xfdesktop with our own desktop implementation
This commit is contained in:
@@ -13,8 +13,6 @@ set(PROJECT_MAINTAINER "Rory Fewell <roryf@oddmatics.uk>")
|
||||
|
||||
set(PROJECT_ROOT ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
set(WINTC_NO_PEDANTIC_COMPILE true) # Necessary because we use dlsym()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
include(../../packaging/cmake-inc/common/CMakeLists.txt)
|
||||
@@ -30,6 +28,7 @@ wintc_resolve_library(glib-2.0 GLIB)
|
||||
wintc_resolve_library(gtk+-3.0 GTK3)
|
||||
wintc_resolve_library(wintc-comgtk WINTC_COMGTK)
|
||||
wintc_resolve_library(wintc-exec WINTC_EXEC)
|
||||
wintc_resolve_library(wintc-shelldpa WINTC_SHELLDPA)
|
||||
wintc_resolve_library(wintc-shllang WINTC_SHLLANG)
|
||||
|
||||
wintc_compile_resources()
|
||||
@@ -39,16 +38,6 @@ add_executable(
|
||||
wintc-taskband
|
||||
src/application.c
|
||||
src/application.h
|
||||
src/dispproto.c
|
||||
src/dispproto.h
|
||||
src/dispproto-wayland.c
|
||||
src/dispproto-wayland.h
|
||||
src/dispproto-x11.c
|
||||
src/dispproto-x11.h
|
||||
src/dispproto-wndmgmt-wnck.c
|
||||
src/dispproto-wndmgmt-wnck.h
|
||||
src/dispproto-wndmgmt-xfw.c
|
||||
src/dispproto-wndmgmt-xfw.h
|
||||
src/main.c
|
||||
src/meta.h
|
||||
src/resources.c
|
||||
@@ -83,21 +72,6 @@ target_compile_options(
|
||||
PRIVATE ${WINTC_COMPILE_OPTIONS}
|
||||
)
|
||||
|
||||
message(
|
||||
STATUS
|
||||
"Include dirs: ${GARCON_INCLUDE_DIRS}"
|
||||
)
|
||||
|
||||
message(
|
||||
STATUS
|
||||
"Link dirs: ${GARCON_LIBRARY_DIRS}"
|
||||
)
|
||||
|
||||
message(
|
||||
STATUS
|
||||
"Link libs: ${GARCON_LIBRARIES}"
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
wintc-taskband
|
||||
SYSTEM
|
||||
@@ -108,6 +82,7 @@ target_include_directories(
|
||||
PRIVATE ${GTK3_INCLUDE_DIRS}
|
||||
PRIVATE ${WINTC_COMGTK_INCLUDE_DIRS}
|
||||
PRIVATE ${WINTC_EXEC_INCLUDE_DIRS}
|
||||
PRIVATE ${WINTC_SHELLDPA_INCLUDE_DIRS}
|
||||
PRIVATE ${WINTC_SHLLANG_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
@@ -120,12 +95,12 @@ target_link_directories(
|
||||
PRIVATE ${GTK3_LIBRARY_DIRS}
|
||||
PRIVATE ${WINTC_COMGTK_LIBRARY_DIRS}
|
||||
PRIVATE ${WINTC_EXEC_LIBRARY_DIRS}
|
||||
PRIVATE ${WINTC_SHELLDPA_LIBRARY_DIRS}
|
||||
PRIVATE ${WINTC_SHLLANG_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
wintc-taskband
|
||||
PRIVATE ${CMAKE_DL_LIBS}
|
||||
PRIVATE ${GARCON_LIBRARIES}
|
||||
PRIVATE ${GARCON_GTK3_LIBRARIES}
|
||||
PRIVATE ${GDK_PIXBUF_LIBRARIES}
|
||||
@@ -133,6 +108,7 @@ target_link_libraries(
|
||||
PRIVATE ${GTK3_LIBRARIES}
|
||||
PRIVATE ${WINTC_COMGTK_LIBRARIES}
|
||||
PRIVATE ${WINTC_EXEC_LIBRARIES}
|
||||
PRIVATE ${WINTC_SHELLDPA_LIBRARIES}
|
||||
PRIVATE ${WINTC_SHLLANG_LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
@@ -5,4 +5,5 @@ bt,rt:glib2
|
||||
bt,rt:gtk3
|
||||
bt,rt:wintc-comgtk
|
||||
bt,rt:wintc-exec
|
||||
bt,rt:wintc-shelldpa
|
||||
bt,rt:wintc-shllang
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <wintc-comgtk.h>
|
||||
#include <wintc-shelldpa.h>
|
||||
|
||||
#include "application.h"
|
||||
#include "dispproto.h"
|
||||
#include "window.h"
|
||||
|
||||
//
|
||||
@@ -104,7 +104,7 @@ static void wintc_taskband_application_startup(
|
||||
|
||||
// Init APIs at runtime
|
||||
//
|
||||
if (!init_display_protocol_apis())
|
||||
if (!wintc_init_display_protocol_apis())
|
||||
{
|
||||
g_critical("%s", "Failed to resolve display protocol APIs.");
|
||||
g_application_quit(application);
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
#include <dlfcn.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "dispproto.h"
|
||||
#include "dispproto-wayland.h"
|
||||
|
||||
//
|
||||
// PRIVATE ENUMS
|
||||
//
|
||||
typedef enum
|
||||
{
|
||||
GTK_LAYER_SHELL_EDGE_LEFT = 0,
|
||||
GTK_LAYER_SHELL_EDGE_RIGHT,
|
||||
GTK_LAYER_SHELL_EDGE_TOP,
|
||||
GTK_LAYER_SHELL_EDGE_BOTTOM,
|
||||
GTK_LAYER_SHELL_EDGE_ENTRY_NUMBER
|
||||
} GtkLayerShellEdge;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_LAYER_SHELL_LAYER_BACKGROUND = 0,
|
||||
GTK_LAYER_SHELL_LAYER_BOTTOM,
|
||||
GTK_LAYER_SHELL_LAYER_TOP,
|
||||
GTK_LAYER_SHELL_LAYER_OVERLAY,
|
||||
GTK_LAYER_SHELL_LAYER_ENTRY_NUMBER
|
||||
} GtkLayerShellLayer;
|
||||
|
||||
//
|
||||
// RESOLVED FUNCS
|
||||
//
|
||||
void (*p_gtk_layer_auto_exclusive_zone_enable) (
|
||||
GtkWindow* window
|
||||
);
|
||||
void (*p_gtk_layer_init_for_window) (
|
||||
GtkWindow* window
|
||||
);
|
||||
void (*p_gtk_layer_set_anchor) (
|
||||
GtkWindow* window,
|
||||
GtkLayerShellEdge edge,
|
||||
gboolean anchor_to_edge
|
||||
);
|
||||
void (*p_gtk_layer_set_layer) (
|
||||
GtkWindow* window,
|
||||
GtkLayerShellLayer layer
|
||||
);
|
||||
|
||||
//
|
||||
// FORWARD DECLARATIONS
|
||||
//
|
||||
static void wayland_anchor_taskband_to_bottom(
|
||||
GtkWindow* taskband
|
||||
);
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
//
|
||||
gboolean init_wayland_protocol_impl(void)
|
||||
{
|
||||
void* dl_gtk_layer_shell =
|
||||
dlopen("libgtk-layer-shell.so", RTLD_LAZY | RTLD_LOCAL);
|
||||
|
||||
if (dl_gtk_layer_shell == NULL)
|
||||
{
|
||||
g_critical("%s", "Failed to open libgtk-layer-shell for symbols.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Resolve funcs we're using
|
||||
//
|
||||
p_gtk_layer_auto_exclusive_zone_enable =
|
||||
dlsym(dl_gtk_layer_shell, "gtk_layer_auto_exclusive_zone_enable");
|
||||
p_gtk_layer_init_for_window =
|
||||
dlsym(dl_gtk_layer_shell, "gtk_layer_init_for_window");
|
||||
p_gtk_layer_set_anchor =
|
||||
dlsym(dl_gtk_layer_shell, "gtk_layer_set_anchor");
|
||||
p_gtk_layer_set_layer =
|
||||
dlsym(dl_gtk_layer_shell, "gtk_layer_set_layer");
|
||||
|
||||
if (
|
||||
p_gtk_layer_auto_exclusive_zone_enable == NULL ||
|
||||
p_gtk_layer_init_for_window == NULL ||
|
||||
p_gtk_layer_set_anchor == NULL ||
|
||||
p_gtk_layer_set_layer == NULL
|
||||
)
|
||||
{
|
||||
g_critical("%s", "Failed to resolve symbols for GTK layer shell.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// All good, assign the API now
|
||||
//
|
||||
anchor_taskband_to_bottom = &wayland_anchor_taskband_to_bottom;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// PRIVATE FUNCTIONS
|
||||
//
|
||||
static void wayland_anchor_taskband_to_bottom(
|
||||
GtkWindow* taskband
|
||||
)
|
||||
{
|
||||
static gboolean anchors[] = { TRUE, TRUE, FALSE, TRUE };
|
||||
|
||||
p_gtk_layer_init_for_window(taskband);
|
||||
p_gtk_layer_set_layer(taskband, GTK_LAYER_SHELL_LAYER_BOTTOM);
|
||||
p_gtk_layer_auto_exclusive_zone_enable(taskband);
|
||||
|
||||
for (int i = 0; i < GTK_LAYER_SHELL_EDGE_ENTRY_NUMBER; i++)
|
||||
{
|
||||
p_gtk_layer_set_anchor(taskband, i, anchors[i]);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef __DISPPROTO_WAYLAND_H__
|
||||
#define __DISPPROTO_WAYLAND_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
//
|
||||
gboolean init_wayland_protocol_impl(void);
|
||||
|
||||
#endif
|
||||
@@ -1,117 +0,0 @@
|
||||
#include <dlfcn.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "dispproto.h"
|
||||
#include "dispproto-wndmgmt-wnck.h"
|
||||
|
||||
//
|
||||
// RESOLVED FUNCS
|
||||
//
|
||||
static WndMgmtWindow* (*p_wnck_screen_get_active_window) (
|
||||
WndMgmtScreen* screen
|
||||
) = NULL;
|
||||
static WndMgmtScreen* (*p_wnck_screen_get_default) (void) = NULL;
|
||||
|
||||
static GdkPixbuf* (*p_wnck_window_get_mini_icon) (
|
||||
WndMgmtWindow* window
|
||||
) = NULL;
|
||||
static gchar* (*p_wnck_window_get_name) (
|
||||
WndMgmtWindow* window
|
||||
) = NULL;
|
||||
static gboolean (*p_wnck_window_is_skip_tasklist) (
|
||||
WndMgmtWindow* window
|
||||
) = NULL;
|
||||
static void (*p_wnck_window_minimize) (
|
||||
WndMgmtWindow* window
|
||||
) = NULL;
|
||||
static void (*p_wnck_window_unminimize) (
|
||||
WndMgmtWindow* window,
|
||||
guint32 timestamp
|
||||
) = NULL;
|
||||
|
||||
//
|
||||
// FORWARD DECLARATIONS
|
||||
//
|
||||
static void wnck_window_unminimize_now(
|
||||
WndMgmtWindow* window
|
||||
);
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
//
|
||||
gboolean init_wndmgmt_wnck_impl(void)
|
||||
{
|
||||
void* dl_wnck = dlopen("libwnck-3.so", RTLD_LAZY | RTLD_LOCAL);
|
||||
|
||||
if (dl_wnck == NULL)
|
||||
{
|
||||
g_message("%s", "libwnck not available.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Attempt to load the necessary functions
|
||||
//
|
||||
p_wnck_screen_get_active_window =
|
||||
dlsym(dl_wnck, "wnck_screen_get_active_window");
|
||||
|
||||
p_wnck_screen_get_default =
|
||||
dlsym(dl_wnck, "wnck_screen_get_default");
|
||||
|
||||
p_wnck_window_get_mini_icon =
|
||||
dlsym(dl_wnck, "wnck_window_get_mini_icon");
|
||||
|
||||
p_wnck_window_get_name =
|
||||
dlsym(dl_wnck, "wnck_window_get_name");
|
||||
|
||||
p_wnck_window_is_skip_tasklist =
|
||||
dlsym(dl_wnck, "wnck_window_is_skip_tasklist");
|
||||
|
||||
p_wnck_window_minimize =
|
||||
dlsym(dl_wnck, "wnck_window_minimize");
|
||||
|
||||
p_wnck_window_unminimize =
|
||||
dlsym(dl_wnck, "wnck_window_unminimize");
|
||||
|
||||
// Check all symbols loaded
|
||||
//
|
||||
if (
|
||||
p_wnck_screen_get_active_window == NULL ||
|
||||
p_wnck_screen_get_default == NULL ||
|
||||
p_wnck_window_get_mini_icon == NULL ||
|
||||
p_wnck_window_get_name == NULL ||
|
||||
p_wnck_window_is_skip_tasklist == NULL ||
|
||||
p_wnck_window_minimize == NULL ||
|
||||
p_wnck_window_unminimize == NULL
|
||||
)
|
||||
{
|
||||
g_warning("%s", "libwnck loaded, but not all symbols.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// We're good, implement the API
|
||||
//
|
||||
wndmgmt_screen_get_active_window = p_wnck_screen_get_active_window;
|
||||
wndmgmt_screen_get_default = p_wnck_screen_get_default;
|
||||
wndmgmt_window_get_mini_icon = p_wnck_window_get_mini_icon;
|
||||
wndmgmt_window_get_name = p_wnck_window_get_name;
|
||||
wndmgmt_window_is_skip_tasklist = p_wnck_window_is_skip_tasklist;
|
||||
wndmgmt_window_minimize = p_wnck_window_minimize;
|
||||
wndmgmt_window_unminimize = &wnck_window_unminimize_now;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// PRIVATE FUNCTIONS
|
||||
//
|
||||
static void wnck_window_unminimize_now(
|
||||
WndMgmtWindow* window
|
||||
)
|
||||
{
|
||||
// FIXME: This throws a warning because we use 0 or GDK_CURRENT_TIME where
|
||||
// it expects an X11 timestamp - it works and I can't be bothered to
|
||||
// resolve this right now
|
||||
//
|
||||
p_wnck_window_unminimize(window, 0);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef __DISPPROTO_WNDMGMT_WNCK_H__
|
||||
#define __DISPPROTO_WNDMGMT_WNCK_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
//
|
||||
gboolean init_wndmgmt_wnck_impl(void);
|
||||
|
||||
#endif
|
||||
@@ -1,128 +0,0 @@
|
||||
#include <dlfcn.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "dispproto.h"
|
||||
#include "dispproto-wndmgmt-xfw.h"
|
||||
|
||||
//
|
||||
// RESOLVED FUNCS
|
||||
//
|
||||
static WndMgmtWindow* (*p_xfw_screen_get_active_window) (
|
||||
WndMgmtScreen* screen
|
||||
) = NULL;
|
||||
static WndMgmtScreen* (*p_xfw_screen_get_default) (void) = NULL;
|
||||
|
||||
static GdkPixbuf* (*p_xfw_window_get_icon) (
|
||||
WndMgmtWindow* window,
|
||||
gint size,
|
||||
gint scale
|
||||
) = NULL;
|
||||
static gchar* (*p_xfw_window_get_name) (
|
||||
WndMgmtWindow* window
|
||||
) = NULL;
|
||||
static gboolean (*p_xfw_window_is_skip_tasklist) (
|
||||
WndMgmtWindow* window
|
||||
) = NULL;
|
||||
static gboolean (*p_xfw_window_set_minimized) (
|
||||
WndMgmtWindow* window,
|
||||
gboolean is_maximized,
|
||||
GError** error
|
||||
) = NULL;
|
||||
|
||||
//
|
||||
// FORWARD DECLARATIONS
|
||||
//
|
||||
static GdkPixbuf* xfw_window_get_mini_icon(
|
||||
WndMgmtWindow* window
|
||||
);
|
||||
static void xfw_window_minimize(
|
||||
WndMgmtWindow* window
|
||||
);
|
||||
static void xfw_window_unminimize(
|
||||
WndMgmtWindow* window
|
||||
);
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
//
|
||||
gboolean init_wndmgmt_xfw_impl(void)
|
||||
{
|
||||
void* dl_xfw = dlopen("libxfce4windowing-0.so", RTLD_LAZY | RTLD_LOCAL);
|
||||
|
||||
if (dl_xfw == NULL)
|
||||
{
|
||||
g_message("%s", "libxfce4windowing not available.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Attempt to load the necessary functions
|
||||
//
|
||||
p_xfw_screen_get_active_window =
|
||||
dlsym(dl_xfw, "xfw_screen_get_active_window");
|
||||
|
||||
p_xfw_screen_get_default =
|
||||
dlsym(dl_xfw, "xfw_screen_get_default");
|
||||
|
||||
p_xfw_window_get_icon =
|
||||
dlsym(dl_xfw, "xfw_window_get_icon");
|
||||
|
||||
p_xfw_window_get_name =
|
||||
dlsym(dl_xfw, "xfw_window_get_name");
|
||||
|
||||
p_xfw_window_is_skip_tasklist =
|
||||
dlsym(dl_xfw, "xfw_window_is_skip_tasklist");
|
||||
|
||||
p_xfw_window_set_minimized =
|
||||
dlsym(dl_xfw, "xfw_window_set_minimized");
|
||||
|
||||
// Check all symbols loaded
|
||||
//
|
||||
if (
|
||||
p_xfw_screen_get_active_window == NULL ||
|
||||
p_xfw_screen_get_default == NULL ||
|
||||
p_xfw_window_get_icon == NULL ||
|
||||
p_xfw_window_get_name == NULL ||
|
||||
p_xfw_window_is_skip_tasklist == NULL ||
|
||||
p_xfw_window_set_minimized == NULL
|
||||
)
|
||||
{
|
||||
g_warning("%s", "libxfce4windowing loaded, but not all symbols.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// We're good, implement the API
|
||||
//
|
||||
wndmgmt_screen_get_active_window = p_xfw_screen_get_active_window;
|
||||
wndmgmt_screen_get_default = p_xfw_screen_get_default;
|
||||
wndmgmt_window_get_mini_icon = &xfw_window_get_mini_icon;
|
||||
wndmgmt_window_get_name = p_xfw_window_get_name;
|
||||
wndmgmt_window_is_skip_tasklist = p_xfw_window_is_skip_tasklist;
|
||||
wndmgmt_window_minimize = &xfw_window_minimize;
|
||||
wndmgmt_window_unminimize = &xfw_window_unminimize;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// PRIVATE FUNCTIONS
|
||||
//
|
||||
static GdkPixbuf* xfw_window_get_mini_icon(
|
||||
WndMgmtWindow* window
|
||||
)
|
||||
{
|
||||
return p_xfw_window_get_icon(window, 16, 1);
|
||||
}
|
||||
|
||||
static void xfw_window_minimize(
|
||||
WndMgmtWindow* window
|
||||
)
|
||||
{
|
||||
p_xfw_window_set_minimized(window, TRUE, NULL);
|
||||
}
|
||||
|
||||
static void xfw_window_unminimize(
|
||||
WndMgmtWindow* window
|
||||
)
|
||||
{
|
||||
p_xfw_window_set_minimized(window, FALSE, NULL);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef __DISPPROTO_WNDMGMT_XFW_H__
|
||||
#define __DISPPROTO_WNDMGMT_XFW_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
//
|
||||
gboolean init_wndmgmt_xfw_impl(void);
|
||||
|
||||
#endif
|
||||
@@ -1,142 +0,0 @@
|
||||
#include <gdk/gdk.h>
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <wintc-comgtk.h>
|
||||
|
||||
#include "dispproto.h"
|
||||
#include "dispproto-x11.h"
|
||||
#include "taskband.h"
|
||||
|
||||
//
|
||||
// STRUCTURE DEFINITIONS
|
||||
//
|
||||
struct X11Struts
|
||||
{
|
||||
gulong left;
|
||||
gulong right;
|
||||
gulong top;
|
||||
gulong bottom;
|
||||
|
||||
gulong left_start_y;
|
||||
gulong left_end_y;
|
||||
|
||||
gulong right_start_y;
|
||||
gulong right_end_y;
|
||||
|
||||
gulong top_start_x;
|
||||
gulong top_end_x;
|
||||
|
||||
gulong bottom_start_x;
|
||||
gulong bottom_end_x;
|
||||
};
|
||||
|
||||
//
|
||||
// FORWARD DECLARATIONS
|
||||
//
|
||||
static void x11_anchor_taskband_to_bottom(
|
||||
GtkWindow* taskband
|
||||
);
|
||||
|
||||
static void on_taskband_realized(
|
||||
GtkWidget* self,
|
||||
gpointer user_data
|
||||
);
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
//
|
||||
gboolean init_x11_protocol_impl(void)
|
||||
{
|
||||
anchor_taskband_to_bottom = &x11_anchor_taskband_to_bottom;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// PRIVATE FUNCTIONS
|
||||
//
|
||||
static void x11_anchor_taskband_to_bottom(
|
||||
GtkWindow* taskband
|
||||
)
|
||||
{
|
||||
g_signal_connect(
|
||||
taskband,
|
||||
"realize",
|
||||
G_CALLBACK(on_taskband_realized),
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// CALLBACKS
|
||||
//
|
||||
static void on_taskband_realized(
|
||||
GtkWidget* self,
|
||||
WINTC_UNUSED(gpointer user_data)
|
||||
)
|
||||
{
|
||||
GdkAtom cardinal_atom;
|
||||
GdkDisplay* display = gdk_display_get_default();
|
||||
GdkRectangle geometry;
|
||||
GdkMonitor* monitor = NULL;
|
||||
int monitor_count = gdk_display_get_n_monitors(display);
|
||||
GdkAtom net_wm_strut_partial_atom;
|
||||
int screen_bottom = 0;
|
||||
|
||||
cardinal_atom =
|
||||
gdk_atom_intern_static_string("CARDINAL");
|
||||
net_wm_strut_partial_atom =
|
||||
gdk_atom_intern_static_string("_NET_WM_STRUT_PARTIAL");
|
||||
|
||||
struct X11Struts struts = { 0 };
|
||||
|
||||
for (int i = 0; i < monitor_count; i++)
|
||||
{
|
||||
int monitor_bottom = 0;
|
||||
GdkMonitor* monitor_i = gdk_display_get_monitor(display, i);
|
||||
|
||||
if (monitor == NULL || gdk_monitor_is_primary(monitor_i))
|
||||
{
|
||||
monitor = monitor_i;
|
||||
}
|
||||
|
||||
// Update screen bottom
|
||||
//
|
||||
gdk_monitor_get_geometry(monitor_i, &geometry);
|
||||
|
||||
monitor_bottom = geometry.y + geometry.height;
|
||||
|
||||
if (monitor_bottom > screen_bottom)
|
||||
{
|
||||
screen_bottom = monitor_bottom;
|
||||
}
|
||||
}
|
||||
|
||||
gdk_monitor_get_geometry(monitor, &geometry);
|
||||
|
||||
gtk_window_set_default_size(
|
||||
GTK_WINDOW(self),
|
||||
geometry.width,
|
||||
TASKBAND_ROW_HEIGHT
|
||||
);
|
||||
gtk_window_move(
|
||||
GTK_WINDOW(self),
|
||||
geometry.x,
|
||||
geometry.y + geometry.height - TASKBAND_ROW_HEIGHT
|
||||
);
|
||||
|
||||
struts.bottom =
|
||||
screen_bottom - (geometry.y + geometry.height) + TASKBAND_ROW_HEIGHT;
|
||||
struts.bottom_start_x = geometry.x;
|
||||
struts.bottom_end_x = geometry.x + geometry.width;
|
||||
|
||||
gdk_property_change(
|
||||
gtk_widget_get_window(self),
|
||||
net_wm_strut_partial_atom,
|
||||
cardinal_atom,
|
||||
32,
|
||||
GDK_PROP_MODE_REPLACE,
|
||||
(guchar*) &struts,
|
||||
sizeof (struct X11Struts) / sizeof (gulong)
|
||||
);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef __DISPPROTO_X11_H__
|
||||
#define __DISPPROTO_X11_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
//
|
||||
gboolean init_x11_protocol_impl(void);
|
||||
|
||||
#endif
|
||||
@@ -1,146 +0,0 @@
|
||||
#include <dlfcn.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "dispproto.h"
|
||||
#include "dispproto-wayland.h"
|
||||
#include "dispproto-x11.h"
|
||||
#include "dispproto-wndmgmt-wnck.h"
|
||||
#include "dispproto-wndmgmt-xfw.h"
|
||||
|
||||
//
|
||||
// STATIC DATA
|
||||
//
|
||||
static TaskbandDisplayProtocol s_dispproto;
|
||||
|
||||
//
|
||||
// RESOLVED FUNCS
|
||||
//
|
||||
static GType (*p_gdk_x11_display_get_type) (void) = NULL;
|
||||
static GType (*p_gdk_wayland_display_get_type) (void) = NULL;
|
||||
|
||||
void (*anchor_taskband_to_bottom)(
|
||||
GtkWindow* taskband
|
||||
) = NULL;
|
||||
|
||||
WndMgmtWindow* (*wndmgmt_screen_get_active_window) (
|
||||
WndMgmtScreen* screen
|
||||
) = NULL;
|
||||
WndMgmtScreen* (*wndmgmt_screen_get_default) (void) = NULL;
|
||||
|
||||
GdkPixbuf* (*wndmgmt_window_get_mini_icon) (
|
||||
WndMgmtWindow* window
|
||||
) = NULL;
|
||||
gchar* (*wndmgmt_window_get_name) (
|
||||
WndMgmtWindow* window
|
||||
) = NULL;
|
||||
gboolean (*wndmgmt_window_is_skip_tasklist) (
|
||||
WndMgmtWindow* window
|
||||
) = NULL;
|
||||
void (*wndmgmt_window_minimize) (
|
||||
WndMgmtWindow* window
|
||||
) = NULL;
|
||||
void (*wndmgmt_window_unminimize) (
|
||||
WndMgmtWindow* window
|
||||
) = NULL;
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
//
|
||||
TaskbandDisplayProtocol get_display_protocol_in_use(void)
|
||||
{
|
||||
return s_dispproto;
|
||||
}
|
||||
|
||||
gboolean init_display_protocol_apis(void)
|
||||
{
|
||||
void* dl_gdk = dlopen("libgdk-3.so", RTLD_LAZY | RTLD_LOCAL);
|
||||
|
||||
if (dl_gdk == NULL)
|
||||
{
|
||||
g_critical("%s", "Failed to open libgdk for symbols.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Resolve GObject type codes for the displays
|
||||
//
|
||||
p_gdk_x11_display_get_type = dlsym(dl_gdk, "gdk_x11_display_get_type");
|
||||
p_gdk_wayland_display_get_type = dlsym(dl_gdk, "gdk_wayland_display_get_type");
|
||||
|
||||
if (
|
||||
p_gdk_x11_display_get_type == NULL &&
|
||||
p_gdk_wayland_display_get_type == NULL
|
||||
)
|
||||
{
|
||||
g_critical("%s", "Unable to resolve X11 nor Wayland symbols in GDK.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// What is our display?
|
||||
//
|
||||
GdkDisplay* display = gdk_display_get_default();
|
||||
|
||||
if (
|
||||
p_gdk_x11_display_get_type != NULL &&
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((display), p_gdk_x11_display_get_type()))
|
||||
)
|
||||
{
|
||||
s_dispproto = DISPPROTO_X11;
|
||||
|
||||
if (!init_x11_protocol_impl())
|
||||
{
|
||||
g_critical("%s", "Failed to initialize X11 implementation.");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else if (
|
||||
p_gdk_wayland_display_get_type != NULL &&
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((display), p_gdk_wayland_display_get_type()))
|
||||
)
|
||||
{
|
||||
s_dispproto = DISPPROTO_WAYLAND;
|
||||
|
||||
if (!init_wayland_protocol_impl())
|
||||
{
|
||||
g_critical("%s", "Failed to initialize Wayland implementation.");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_critical("%s", "Can't determine display type, not X11 or Wayland?");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Window management stuff, we prioritise loading xfce4windowing because it
|
||||
// is the future - failing that we try WNCK, but only for X cos It Don't
|
||||
// Work On Wayland! (TM)
|
||||
//
|
||||
if (!init_wndmgmt_xfw_impl())
|
||||
{
|
||||
if (get_display_protocol_in_use() == DISPPROTO_WAYLAND)
|
||||
{
|
||||
// It's over for Wayland!
|
||||
//
|
||||
g_critical(
|
||||
"%s",
|
||||
"libxfce4windowing not available, cannot continue on Wayland."
|
||||
);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!init_wndmgmt_wnck_impl())
|
||||
{
|
||||
// No WNCK! Computer over! Disaster = very yes!
|
||||
//
|
||||
g_critical(
|
||||
"%s",
|
||||
"libwnck not available, cannot continue."
|
||||
);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
#ifndef __DISPPROTO_H__
|
||||
#define __DISPPROTO_H__
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
//
|
||||
// PUBLIC DEFINES
|
||||
//
|
||||
#define WndMgmtScreen void
|
||||
#define WndMgmtWindow void
|
||||
|
||||
//
|
||||
// PUBLIC ENUMS
|
||||
//
|
||||
typedef enum
|
||||
{
|
||||
DISPPROTO_X11,
|
||||
DISPPROTO_WAYLAND
|
||||
} TaskbandDisplayProtocol;
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
//
|
||||
TaskbandDisplayProtocol get_display_protocol_in_use(void);
|
||||
gboolean init_display_protocol_apis(void);
|
||||
|
||||
extern void (*anchor_taskband_to_bottom) (
|
||||
GtkWindow* taskband
|
||||
);
|
||||
|
||||
extern WndMgmtWindow* (*wndmgmt_screen_get_active_window) (
|
||||
WndMgmtScreen* screen
|
||||
);
|
||||
extern WndMgmtScreen* (*wndmgmt_screen_get_default) (void);
|
||||
|
||||
extern GdkPixbuf* (*wndmgmt_window_get_mini_icon) (
|
||||
WndMgmtWindow* window
|
||||
);
|
||||
extern gchar* (*wndmgmt_window_get_name) (
|
||||
WndMgmtWindow* window
|
||||
);
|
||||
extern gboolean (*wndmgmt_window_is_skip_tasklist) (
|
||||
WndMgmtWindow* window
|
||||
);
|
||||
extern void (*wndmgmt_window_minimize) (
|
||||
WndMgmtWindow* window
|
||||
);
|
||||
extern void (*wndmgmt_window_unminimize) (
|
||||
WndMgmtWindow* window
|
||||
);
|
||||
|
||||
#endif
|
||||
@@ -6,8 +6,8 @@
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
#include <wintc-comgtk.h>
|
||||
#include <wintc-shelldpa.h>
|
||||
|
||||
#include "../dispproto.h"
|
||||
#include "../meta.h"
|
||||
#include "action.h"
|
||||
#include "placeslist.h"
|
||||
@@ -114,7 +114,7 @@ StartMenu* start_menu_new(
|
||||
//
|
||||
// So... GtkWindow on X11, GtkPopover on Wayland :)
|
||||
//
|
||||
if (get_display_protocol_in_use() == DISPPROTO_X11)
|
||||
if (wintc_get_display_protocol_in_use() == WINTC_DISPPROTO_X11)
|
||||
{
|
||||
start_menu->menu = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
@@ -170,7 +170,7 @@ StartMenu* start_menu_new(
|
||||
fake_titlebar
|
||||
);
|
||||
}
|
||||
else if (get_display_protocol_in_use() == DISPPROTO_WAYLAND)
|
||||
else if (wintc_get_display_protocol_in_use() == WINTC_DISPPROTO_WAYLAND)
|
||||
{
|
||||
start_menu->menu = gtk_popover_new(start_button);
|
||||
}
|
||||
@@ -206,7 +206,7 @@ void start_menu_present(
|
||||
gint x;
|
||||
gint y;
|
||||
|
||||
if (get_display_protocol_in_use() == DISPPROTO_X11)
|
||||
if (wintc_get_display_protocol_in_use() == WINTC_DISPPROTO_X11)
|
||||
{
|
||||
gtk_window_present_with_time(
|
||||
GTK_WINDOW(start_menu->menu),
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <pango/pango.h>
|
||||
#include <wintc-comgtk.h>
|
||||
#include <wintc-shelldpa.h>
|
||||
|
||||
#include "../dispproto.h"
|
||||
#include "windowmonitor.h"
|
||||
|
||||
//
|
||||
@@ -11,53 +11,53 @@
|
||||
//
|
||||
typedef struct _WindowManagerSingle
|
||||
{
|
||||
GtkToggleButton* button;
|
||||
GtkImage* button_icon;
|
||||
gboolean button_synchronizing;
|
||||
GtkLabel* button_text;
|
||||
WndMgmtWindow* managed_window;
|
||||
WindowMonitor* parent_monitor;
|
||||
GtkToggleButton* button;
|
||||
GtkImage* button_icon;
|
||||
gboolean button_synchronizing;
|
||||
GtkLabel* button_text;
|
||||
WinTCWndMgmtWindow* managed_window;
|
||||
WindowMonitor* parent_monitor;
|
||||
} WindowManagerSingle;
|
||||
|
||||
struct _WindowMonitor
|
||||
{
|
||||
GtkContainer* container;
|
||||
WndMgmtScreen* screen;
|
||||
GHashTable* window_manager_map;
|
||||
GtkContainer* container;
|
||||
WinTCWndMgmtScreen* screen;
|
||||
GHashTable* window_manager_map;
|
||||
};
|
||||
|
||||
//
|
||||
// FORWARD DECLARATIONS
|
||||
//
|
||||
static void on_active_window_changed(
|
||||
WndMgmtScreen* screen,
|
||||
WndMgmtWindow* previously_active_window,
|
||||
gpointer user_data
|
||||
WinTCWndMgmtScreen* screen,
|
||||
WinTCWndMgmtWindow* previously_active_window,
|
||||
gpointer user_data
|
||||
);
|
||||
static void on_window_closed(
|
||||
WndMgmtScreen* screen,
|
||||
WndMgmtWindow* window,
|
||||
gpointer user_data
|
||||
WinTCWndMgmtScreen* screen,
|
||||
WinTCWndMgmtWindow* window,
|
||||
gpointer user_data
|
||||
);
|
||||
static void on_window_opened(
|
||||
WndMgmtScreen* screen,
|
||||
WndMgmtWindow* window,
|
||||
gpointer user_data
|
||||
WinTCWndMgmtScreen* screen,
|
||||
WinTCWndMgmtWindow* window,
|
||||
gpointer user_data
|
||||
);
|
||||
|
||||
static void on_window_icon_changed(
|
||||
WndMgmtWindow* window,
|
||||
gpointer user_data
|
||||
WinTCWndMgmtWindow* window,
|
||||
gpointer user_data
|
||||
);
|
||||
static void on_window_name_changed(
|
||||
WndMgmtWindow* window,
|
||||
gpointer user_data
|
||||
WinTCWndMgmtWindow* window,
|
||||
gpointer user_data
|
||||
);
|
||||
static void on_window_state_changed(
|
||||
WndMgmtWindow* window,
|
||||
gint changed_mask,
|
||||
gint new_state,
|
||||
gpointer user_data
|
||||
WinTCWndMgmtWindow* window,
|
||||
gint changed_mask,
|
||||
gint new_state,
|
||||
gpointer user_data
|
||||
);
|
||||
|
||||
static void on_window_button_toggled(
|
||||
@@ -85,7 +85,7 @@ WindowMonitor* window_monitor_init_management(
|
||||
WindowMonitor* window_monitor = g_new(WindowMonitor, 1);
|
||||
|
||||
window_monitor->container = container;
|
||||
window_monitor->screen = wndmgmt_screen_get_default();
|
||||
window_monitor->screen = wintc_wndmgmt_screen_get_default();
|
||||
window_monitor->window_manager_map = g_hash_table_new(
|
||||
g_direct_hash,
|
||||
g_direct_equal
|
||||
@@ -127,7 +127,7 @@ static void window_manager_update_icon(
|
||||
|
||||
gtk_image_set_from_pixbuf(
|
||||
window_manager->button_icon,
|
||||
wndmgmt_window_get_mini_icon(
|
||||
wintc_wndmgmt_window_get_mini_icon(
|
||||
window_manager->managed_window
|
||||
)
|
||||
);
|
||||
@@ -141,7 +141,7 @@ static void window_manager_update_state(
|
||||
gboolean skip_tasklist;
|
||||
|
||||
skip_tasklist =
|
||||
wndmgmt_window_is_skip_tasklist(window_manager->managed_window);
|
||||
wintc_wndmgmt_window_is_skip_tasklist(window_manager->managed_window);
|
||||
|
||||
if (skip_tasklist && window_manager->button != NULL)
|
||||
{
|
||||
@@ -218,7 +218,7 @@ static void window_manager_update_text(
|
||||
)
|
||||
{
|
||||
const gchar* new_text =
|
||||
wndmgmt_window_get_name(window_manager->managed_window);
|
||||
wintc_wndmgmt_window_get_name(window_manager->managed_window);
|
||||
|
||||
gtk_label_set_text(
|
||||
window_manager->button_text,
|
||||
@@ -234,17 +234,18 @@ static void window_manager_update_text(
|
||||
// CALLBACKS
|
||||
//
|
||||
static void on_active_window_changed(
|
||||
WINTC_UNUSED(WndMgmtScreen* screen),
|
||||
WndMgmtWindow* previously_active_window,
|
||||
gpointer user_data
|
||||
WINTC_UNUSED(WinTCWndMgmtScreen* screen),
|
||||
WinTCWndMgmtWindow* previously_active_window,
|
||||
gpointer user_data
|
||||
)
|
||||
{
|
||||
WndMgmtWindow* active_window;
|
||||
WinTCWndMgmtWindow* active_window;
|
||||
WindowManagerSingle* window_manager_old;
|
||||
WindowManagerSingle* window_manager_new;
|
||||
WindowMonitor* window_monitor = (WindowMonitor*) user_data;
|
||||
|
||||
active_window = wndmgmt_screen_get_active_window(window_monitor->screen);
|
||||
active_window =
|
||||
wintc_wndmgmt_screen_get_active_window(window_monitor->screen);
|
||||
|
||||
if (previously_active_window != NULL)
|
||||
{
|
||||
@@ -296,9 +297,9 @@ static void on_active_window_changed(
|
||||
}
|
||||
|
||||
static void on_window_closed(
|
||||
WINTC_UNUSED(WndMgmtScreen* screen),
|
||||
WndMgmtWindow* window,
|
||||
gpointer user_data
|
||||
WINTC_UNUSED(WinTCWndMgmtScreen* screen),
|
||||
WinTCWndMgmtWindow* window,
|
||||
gpointer user_data
|
||||
)
|
||||
{
|
||||
WindowManagerSingle* window_manager;
|
||||
@@ -327,9 +328,9 @@ static void on_window_closed(
|
||||
}
|
||||
|
||||
static void on_window_opened(
|
||||
WINTC_UNUSED(WndMgmtScreen* screen),
|
||||
WndMgmtWindow* window,
|
||||
gpointer user_data
|
||||
WINTC_UNUSED(WinTCWndMgmtScreen* screen),
|
||||
WinTCWndMgmtWindow* window,
|
||||
gpointer user_data
|
||||
)
|
||||
{
|
||||
WindowManagerSingle* window_manager = g_new(WindowManagerSingle, 1);
|
||||
@@ -371,7 +372,7 @@ static void on_window_opened(
|
||||
}
|
||||
|
||||
static void on_window_icon_changed(
|
||||
WINTC_UNUSED(WndMgmtWindow* window),
|
||||
WINTC_UNUSED(WinTCWndMgmtWindow* window),
|
||||
gpointer user_data
|
||||
)
|
||||
{
|
||||
@@ -381,7 +382,7 @@ static void on_window_icon_changed(
|
||||
}
|
||||
|
||||
static void on_window_name_changed(
|
||||
WINTC_UNUSED(WndMgmtWindow* window),
|
||||
WINTC_UNUSED(WinTCWndMgmtWindow* window),
|
||||
gpointer user_data
|
||||
)
|
||||
{
|
||||
@@ -391,7 +392,7 @@ static void on_window_name_changed(
|
||||
}
|
||||
|
||||
static void on_window_state_changed(
|
||||
WINTC_UNUSED(WndMgmtWindow* window),
|
||||
WINTC_UNUSED(WinTCWndMgmtWindow* window),
|
||||
WINTC_UNUSED(gint changed_mask),
|
||||
WINTC_UNUSED(gint new_state),
|
||||
gpointer user_data
|
||||
@@ -416,10 +417,10 @@ static void on_window_button_toggled(
|
||||
|
||||
if (gtk_toggle_button_get_active(button))
|
||||
{
|
||||
wndmgmt_window_unminimize(window_manager->managed_window);
|
||||
wintc_wndmgmt_window_unminimize(window_manager->managed_window);
|
||||
}
|
||||
else
|
||||
{
|
||||
wndmgmt_window_minimize(window_manager->managed_window);
|
||||
wintc_wndmgmt_window_minimize(window_manager->managed_window);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <wintc-comgtk.h>
|
||||
#include <wintc-shelldpa.h>
|
||||
|
||||
#include "application.h"
|
||||
#include "dispproto.h"
|
||||
#include "window.h"
|
||||
#include "start/startbutton.h"
|
||||
#include "systray/notifarea.h"
|
||||
@@ -63,7 +63,7 @@ static void wintc_taskband_window_init(
|
||||
"wintc-taskband"
|
||||
);
|
||||
|
||||
anchor_taskband_to_bottom(GTK_WINDOW(self));
|
||||
wintc_anchor_taskband_to_bottom(GTK_WINDOW(self));
|
||||
|
||||
//
|
||||
// SET UP CHILDREN IN HERE
|
||||
|
||||
Reference in New Issue
Block a user