<commit_before>
#include "oslib/wimp.h"

#include "appengine/wimp/window.h"

#include "appengine/wimp/window/open.h" /* private header */

/* ----------------------------------------------------------------------- */

enum
{
  StaggerOffset = 48
};

/* ----------------------------------------------------------------------- */

void window_open_with_callback(wimp_w w,
                               void (*cb)(CallbackArgs *, void *),
                               void  *opaque)
{
  static const os_VDU_VAR_LIST(5) var_list =
  {{
    os_MODEVAR_XEIG_FACTOR,
    os_MODEVAR_YEIG_FACTOR,
    os_MODEVAR_XWIND_LIMIT,
    os_MODEVAR_YWIND_LIMIT,
    -1,
  }};

  int          vdu_vars[4];
  CallbackArgs args;

  os_read_vdu_variables((const os_vdu_var_list *) &var_list, vdu_vars);

  args.screen_w = (vdu_vars[2] + 1) << vdu_vars[0];
  args.screen_h = (vdu_vars[3] + 1) << vdu_vars[1];

  args.info.w = w;
  wimp_get_window_info_header_only(&args.info);

  args.outline.w = w;
  wimp_get_window_outline(&args.outline);

  args.left   = args.info.visible.x0 - args.outline.outline.x0;
  args.bottom = args.info.visible.y0 - args.outline.outline.y0;
  args.right  = args.outline.outline.x1 - args.info.visible.x1;
  args.top    = args.outline.outline.y1 - args.info.visible.y1;

  /* fprintf(stderr, "%d %d %d %d\n", args.left, args.bottom, args.right, args.top); */

  cb(&args, opaque);

  wimp_open_window((wimp_open *) &args.info);
}

/* ----------------------------------------------------------------------- */
<commit_msg>appengine/wimp/window: Avoid Wimp_GetWindowOutline where it returns broken values<commit_after>// #include <stdio.h>

#include "oslib/wimp.h"
#include "oslib/wimpreadsysinfo.h"

#include "appengine/wimp/window.h"

#include "appengine/wimp/window/open.h" /* private header */

/* ----------------------------------------------------------------------- */

enum
{
  StaggerOffset = 48
};

/* ----------------------------------------------------------------------- */

void window_open_with_callback(wimp_w w,
                               void (*cb)(CallbackArgs *, void *),
                               void  *opaque)
{
  static const os_VDU_VAR_LIST(5) var_list =
  {{
    os_MODEVAR_XEIG_FACTOR,
    os_MODEVAR_YEIG_FACTOR,
    os_MODEVAR_XWIND_LIMIT,
    os_MODEVAR_YWIND_LIMIT,
    -1,
  }};

  int          vdu_vars[4];
  CallbackArgs args;

  os_read_vdu_variables((const os_vdu_var_list *) &var_list, vdu_vars);

  args.screen_w = (vdu_vars[2] + 1) << vdu_vars[0];
  args.screen_h = (vdu_vars[3] + 1) << vdu_vars[1];

  args.info.w = w;
  wimp_get_window_info_header_only(&args.info);

  /* calculate furniture sizes */

  /* avoid calling wimp_get_window_outline() on unopened windows if we're
   * on Wimps earlier than the nested Wimp */
  if ((args.info.flags & wimp_WINDOW_OPEN) != 0 ||
      (wimpreadsysinfo_version() >= wimp_VERSION_RO38))
  {
    args.outline.w = w;
    wimp_get_window_outline(&args.outline);

    args.left   = args.info.visible.x0 - args.outline.outline.x0;
    args.bottom = args.info.visible.y0 - args.outline.outline.y0;
    args.right  = args.outline.outline.x1 - args.info.visible.x1;
    args.top    = args.outline.outline.y1 - args.info.visible.y1;
  }
  else
  {
    // newlook: 12x11 at 45x45dpi,  22x11 at 90x45dpi, 20x20 at 90x90dpi
    // RO3.1: 21x11 on RO3.1 at 90x45dpi

    /* assuming 40 OS units */
    const int StandardToolSpriteWidth  = 40;
    const int StandardToolSpriteHeight = 40;

    args.left   = args.right = 1 << vdu_vars[0];
    args.bottom = args.top   = 1 << vdu_vars[1];

    if (args.info.flags & wimp_WINDOW_TITLE_ICON)
      args.top = StandardToolSpriteHeight;
    if (args.info.flags & wimp_WINDOW_VSCROLL)
      args.right = StandardToolSpriteWidth;
    if (args.info.flags & wimp_WINDOW_HSCROLL)
      args.bottom = StandardToolSpriteHeight;
  }

  // fprintf(stderr, "furn: %d %d %d %d\n", args.left, args.bottom, args.right, args.top);

  cb(&args, opaque);

  wimp_open_window((wimp_open *) &args.info);
}

/* ----------------------------------------------------------------------- */

{'fraction_non_alphanumeric': 0.22742801366520254, 'fraction_numerical': 0.0212298682284041, 'mean_word_length': 2.0161883738042676, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 5, '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': '7540696', 'n_tokens_mistral': 1528, 'n_tokens_neox': 1464, 'n_words': 240}