<commit_before>#include "debug.h"
#include "desktops.h"
#include "config.h"
#include "actions.h"
#include "border.h"
#include "background.h"
#include "view.h"
#include "icccm.h"
#include "util.h"
#include "object.h"

static Evas_List desktops = NULL;
static Window    e_base_win = 0;
static int       screen_w, screen_h;

static void ecore_idle(void *data);

static void
ecore_idle(void *data)
{
   D_ENTER;
   /* FIXME -- Raster, how is this related to the desktop code? */

   e_db_flush();
   D_RETURN;
   UN(data);
}

void
e_desktops_init(void)
{
   E_Desktop *desk;
  
   D_ENTER;

   ecore_window_get_geometry(0, NULL, NULL, &screen_w, &screen_h);
   e_base_win = ecore_window_override_new(0, 0, 0, screen_w, screen_h);
   ecore_window_show(e_base_win);
   desk = e_desktops_new();
   e_desktops_show(desk);
   ecore_event_filter_idle_handler_add(ecore_idle, NULL);
 
   e_icccm_advertise_e_compat();
   e_icccm_advertise_mwm_compat();
   e_icccm_advertise_gnome_compat();
   e_icccm_advertise_kde_compat();
   e_icccm_advertise_net_compat();
   
   e_icccm_set_desk_area_size(0, 1, 1);
   e_icccm_set_desk_area(0, 0, 0);
   e_icccm_set_desk(0, 0);

   D_RETURN;
}

void
e_desktops_scroll(E_Desktop *desk, int dx, int dy)
{
   Evas_List l;
   int xd, yd, wd, hd;
   int grav, grav_stick;   
   
   D_ENTER;

   /* set grav */
   if ((dx ==0) && (dy == 0)) D_RETURN;
   desk->x -= dx;
   desk->y -= dy;
   xd = yd = wd = hd = 0;
   grav = NorthWestGravity;
   grav_stick = SouthEastGravity;
   if ((dx <= 0) && (dy <= 0))
     {
	grav = NorthWestGravity;
	grav_stick = SouthEastGravity;
	xd = dx;
	yd = dy;
	wd = -dx;
	hd = -dy;
     }
   else if ((dx >= 0) && (dy <= 0))
     {
	grav = NorthEastGravity;
	grav_stick = SouthWestGravity;
	xd = 0;
	yd = dy;
	wd = dx;
	hd = -dy;
     }
   else if ((dx >= 0) && (dy >= 0))
     {
	grav = SouthEastGravity;
	grav_stick = NorthWestGravity;
	xd = 0;
	yd = 0;
	wd = dx;
	hd = dy;
     }
   else if ((dx <= 0) && (dy >= 0))
     {
	grav = SouthWestGravity;
	grav_stick = NorthEastGravity;
	xd = dx;
	yd = 0;
	wd = -dx;
	hd = dy;
     }
   for (l = desk->windows; l; l = l->next)
     {
	E_Border *b;
	
	b = l->data;
	/* if sticky */
	if ((b->client.sticky) && (!b->mode.move))	  
	  ecore_window_gravity_set(b->win.main, StaticGravity);
	else
	  ecore_window_gravity_set(b->win.main, grav);	
     }
   grav_stick = StaticGravity;
   /* scroll */
   ecore_window_move_resize(desk->win.container, 
			xd, yd, 
			screen_w + wd, screen_h + hd);
   /* reset */
   for (l = desk->windows; l; l = l->next)
     {
	E_Border *b;
	
	b = l->data;
	/* if sticky */
	if (b->client.sticky)
	  ecore_window_gravity_set(b->win.main, StaticGravity);
	else
	  ecore_window_gravity_set(b->win.main, grav_stick);	
/*	ecore_window_gravity_set(b->win.main, grav_stick);*/
     }   
   ecore_window_move_resize(desk->win.container, 0, 0, screen_w, screen_h);
   for (l = desk->windows; l; l = l->next)
     {
	E_Border *b;
	
	b = l->data;
	ecore_window_gravity_reset(b->win.main);
	if ((!b->client.sticky) && (!b->mode.move))	  
	  {
	     b->current.requested.x += dx;
	     b->current.requested.y += dy;
	     b->current.x = b->current.requested.x;
	     b->current.y = b->current.requested.y;
	     b->previous.requested.x = b->current.requested.x;
	     b->previous.requested.y = b->current.requested.y;
	     b->previous.x = b->current.x;
	     b->previous.y = b->current.y;
	     b->changed = 1;
	  }
     }

   D_RETURN;
}

void
e_desktops_cleanup(E_Desktop *desk)
{
   D_ENTER;

   while (desk->windows)
     {<commit_msg>this works somewhat better =)<commit_after>#include "debug.h"
#include "desktops.h"
#include "config.h"
#include "actions.h"
#include "border.h"
#include "background.h"
#include "view.h"
#include "icccm.h"
#include "util.h"
#include "object.h"

static Evas_List desktops = NULL;
static Window    e_base_win = 0;
static int       screen_w, screen_h;

static void ecore_idle(void *data);

static void
ecore_idle(void *data)
{
   D_ENTER;
   /* FIXME -- Raster, how is this related to the desktop code? */

   e_db_flush();
   D_RETURN;
   UN(data);
}

void
e_desktops_init(void)
{
   E_Desktop *desk;
  
   D_ENTER;

   ecore_window_get_geometry(0, NULL, NULL, &screen_w, &screen_h);
   e_base_win = ecore_window_override_new(0, 0, 0, screen_w, screen_h);
   ecore_window_show(e_base_win);
   desk = e_desktops_new();
   e_desktops_show(desk);
   ecore_event_filter_idle_handler_add(ecore_idle, NULL);
 
   e_icccm_advertise_e_compat();
   e_icccm_advertise_mwm_compat();
   e_icccm_advertise_gnome_compat();
   e_icccm_advertise_kde_compat();
   e_icccm_advertise_net_compat();
   
   e_icccm_set_desk_area_size(0, 1, 1);
   e_icccm_set_desk_area(0, 0, 0);
   e_icccm_set_desk(0, 0);

   D_RETURN;
}

void
e_desktops_scroll(E_Desktop *desk, int dx, int dy)
{
   Evas_List l;
   int xd, yd, wd, hd;
   int grav, grav_stick;   
   
   D_ENTER;

   /* set grav */
   if ((dx ==0) && (dy == 0)) D_RETURN;
   desk->x -= dx;
   desk->y -= dy;
   xd = yd = wd = hd = 0;
   grav = NorthWestGravity;
   grav_stick = SouthEastGravity;
   if ((dx <= 0) && (dy <= 0))
     {
	grav = NorthWestGravity;
	grav_stick = SouthEastGravity;
	xd = dx;
	yd = dy;
	wd = -dx;
	hd = -dy;
     }
   else if ((dx >= 0) && (dy <= 0))
     {
	grav = NorthEastGravity;
	grav_stick = SouthWestGravity;
	xd = 0;
	yd = dy;
	wd = dx;
	hd = -dy;
     }
   else if ((dx >= 0) && (dy >= 0))
     {
	grav = SouthEastGravity;
	grav_stick = NorthWestGravity;
	xd = 0;
	yd = 0;
	wd = dx;
	hd = dy;
     }
   else if ((dx <= 0) && (dy >= 0))
     {
	grav = SouthWestGravity;
	grav_stick = NorthEastGravity;
	xd = dx;
	yd = 0;
	wd = -dx;
	hd = dy;
     }
   for (l = desk->windows; l; l = l->next)
     {
	E_Border *b;
	
	b = l->data;
	/* if sticky */
	if ((b->client.sticky) && (!b->mode.move))	  
	  ecore_window_gravity_set(b->win.main, StaticGravity);
	else
	  ecore_window_gravity_set(b->win.main, grav);	
     }
   grav_stick = StaticGravity;
   /* scroll */
   ecore_window_move_resize(desk->win.container, 
			xd, yd, 
			screen_w + wd, screen_h + hd);
   /* reset */
   for (l = desk->windows; l; l = l->next)
     {
	E_Border *b;
	
	b = l->data;
	/* if sticky */
	if (b->client.sticky)
	  ecore_window_gravity_set(b->win.main, StaticGravity);
	else
	  ecore_window_gravity_set(b->win.main, grav_stick);	
/*	ecore_window_gravity_set(b->win.main, grav_stick);*/
     }   
   ecore_window_move_resize(desk->win.container, 0, 0, screen_w, screen_h);
   for (l = desk->windows; l; l = l->next)
     {
	E_Border *b;
	
	b = l->data;
	ecore_window_gravity_reset(b->win.main);
	if ((!b->client.sticky) && (!b->mode.move))	  
	  {
	     b->current.requested.x += dx;
	     b->current.requested.y += dy;
	     b->current.x = b->current.requested.x;
	     b->current.y = b->current.requested.y;
	     b->previous.requested.x = b->current.requested.x;
	     b->previous.requested.y = b->current.requested.y;
	     b->previous.x = b->current.x;
	     b->previous.y = b->current.y;
	     b->changed = 1;
	  }
     }

   D_RETURN;
}

void
e_desktops_cleanup(E_Desktop *desk)
{
   Evas_List l;
   D_ENTER;

   for (l = desk->windows; l; l = l->next)
     {
{'fraction_non_alphanumeric': 0.1579608938547486, 'fraction_numerical': 0.008659217877094972, 'mean_word_length': 2.9238356164383563, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 92, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '56048', 'n_tokens_mistral': 3209, 'n_tokens_neox': 3065, 'n_words': 602}