Skip to content

Commit

Permalink
shell-client: Add client list functions
Browse files Browse the repository at this point in the history
  • Loading branch information
adlocode committed Jul 3, 2019
1 parent 3fe572a commit 6a8df57
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ $(top_srcdir)/protocol/xfway-shell-client-protocol.c \
$(top_srcdir)/protocol/xfway-shell-client-protocol.h \
$(top_srcdir)/protocol/wlr-foreign-toplevel-management-unstable-v1-protocol.c \
$(top_srcdir)/protocol/wlr-foreign-toplevel-management-unstable-v1-client-protocol.h \
display.h \
screen.c \
screen.h \
client.c \
client.h \
stacking.c \
stacking.h \
$(top_srcdir)/util/libgwater-wayland.c \
$(top_srcdir)/util/libgwater-wayland.h \
$(top_srcdir)/util/helpers.h \
Expand Down
6 changes: 5 additions & 1 deletion src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <gtk/gtk.h>

#include <protocol/wlr-foreign-toplevel-management-unstable-v1-client-protocol.h>
#include "display.h"
#include "screen.h"


Expand Down Expand Up @@ -267,10 +268,13 @@ struct _Client

struct zwlr_foreign_toplevel_handle_v1 *toplevel_handle;

Client *next;
Client *prev;

gchar *name;
};

typedef struct _Client Client;


extern Client *clients;
extern unsigned int client_count;
Expand Down
3 changes: 3 additions & 0 deletions src/display.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
typedef struct _ScreenInfo ScreenInfo;
typedef struct _Client Client;

10 changes: 9 additions & 1 deletion src/screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,24 @@
#define INC_SCREEN_H

#include <gtk/gtk.h>
#include "display.h"
#include "client.h"
#include <protocol/wlr-foreign-toplevel-management-unstable-v1-client-protocol.h>

struct _ScreenInfo
{
GList *windows_stack;
GList *windows;

GdkScreen *gscr;

struct zwlr_foreign_toplevel_manager_v1 *toplevel_manager;

Client *clients;
guint client_count;
};

typedef struct _ScreenInfo ScreenInfo;


ScreenInfo *myScreenInit (GdkScreen *);
gint myScreenGetNumMonitors (ScreenInfo *);
Expand Down
108 changes: 108 additions & 0 deletions src/stacking.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/* $Id$
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, 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., Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
xfwm4 - (c) 2002-2011 Olivier Fourdan
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <glib.h>

#include "display.h"
#include "screen.h"
#include "client.h"
#include "stacking.h"

void
clientAddToList (Client * c)
{
ScreenInfo *screen_info;
//DisplayInfo *display_info;

g_return_if_fail (c != NULL);
//TRACE ("client \"%s\" (0x%lx)", c->name, c->window);

screen_info = c->screen_info;
//display_info = screen_info->display_info;
//myDisplayAddClient (display_info, c);

screen_info->client_count++;
if (screen_info->clients)
{
c->prev = screen_info->clients->prev;
c->next = screen_info->clients;
screen_info->clients->prev->next = c;
screen_info->clients->prev = c;
}
else
{
screen_info->clients = c;
c->next = c;
c->prev = c;
}

screen_info->windows = g_list_append (screen_info->windows, c);
screen_info->windows_stack = g_list_append (screen_info->windows_stack, c);

//clientSetNetClientList (screen_info, display_info->atoms[NET_CLIENT_LIST], screen_info->windows);

//FLAG_SET (c->xfwm_flags, XFWM_FLAG_MANAGED);
}

void
clientRemoveFromList (Client * c)
{
ScreenInfo *screen_info;
//DisplayInfo *display_info;

g_return_if_fail (c != NULL);
//TRACE ("client \"%s\" (0x%lx)", c->name, c->window);

//FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_MANAGED);

screen_info = c->screen_info;
//display_info = screen_info->display_info;
// myDisplayRemoveClient (display_info, c);

g_assert (screen_info->client_count > 0);
screen_info->client_count--;
if (screen_info->client_count == 0)
{
screen_info->clients = NULL;
}
else
{
c->next->prev = c->prev;
c->prev->next = c->next;
if (c == screen_info->clients)
{
screen_info->clients = screen_info->clients->next;
}
}

screen_info->windows = g_list_remove (screen_info->windows, c);
screen_info->windows_stack = g_list_remove (screen_info->windows_stack, c);

//clientSetNetClientList (screen_info, display_info->atoms[NET_CLIENT_LIST], screen_info->windows);
//clientSetNetClientList (screen_info, display_info->atoms[NET_CLIENT_LIST_STACKING], screen_info->windows_stack);

//FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_MANAGED);
}
37 changes: 37 additions & 0 deletions src/stacking.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* $Id$
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, 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., Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
xfwm4 - (c) 2002-2011 Olivier Fourdan
*/

#ifndef INC_STACKING_H
#define INC_STACKING_H

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <glib.h>
#include "screen.h"
#include "client.h"

void clientAddToList (Client *);
void clientRemoveFromList (Client *);

#endif /* INC_STACKING_H */

0 comments on commit 6a8df57

Please sign in to comment.