winop(n)

πŸ“¦ version 2.5.3, in nixpkgs unstable

πŸ’– NAME πŸ’–

winop(n) from BLT Built-In Commands β€” winop performs assorted window and image operations. Bestie, this is the low-level window-manipulation page, and it is so useful when the window manager is being extra. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

winop changes window

winop gradients leftcolor rightcolor gradients

winop image subcommand ...

winop image alpha srcImage destImage color

winop image colors ?-alpha? srcImage

winop image convolve srcImage destImage filter

winop image gradient image leftcolor rightcolor ...

winop image merge srcImage1 srcImage2 destImage ?alpha? ?...?

winop image mirror srcImage1 destImage ?x|y|xy|tile|outer|inner?

winop image quantize srcImage destImage ?nColors?

winop image readjpeg filename photoname

winop image resample srcImage destImage ?horizFilter?
?vertFilter?

winop image rotate srcImage destImage angle

winop image subsample srcImage destImage x y width height
?horizFilter? ?vertFilter?

winop lower ?window?...

winop map ?window?...

winop move window x y

winop query

winop raise ?window?...

winop snap window photoName ?width height ?

winop unmap ?window?...

winop warpto ?window?

✨ DESCRIPTION ✨

The winop command does various window and image operations on Tk windows using low-level Xlib function calls, specifically so it can work around window-manager weirdness. It's giving "I'll do it myself" energy, and honestly? Iconic. πŸ”₯


🌈 INTRODUCTION 🌈

Tk already has a bunch of commands for manipulating its windows: raise, lower, wm, etc. The catch is that those commands ask the window manager to perform operations on Tk windows, and sometimes a particular window manager just won't do the thing as expected. Rude, but real.

For example, if you position a toplevel window using wm geometry, the window may not actually be at those exact coordinates. The position may be offset by the dimensions of the title bar that the window manager adds. So you asked for +100+100 and the window manager said "sure, bestie" and then gave you something slightly to the left. 😭

In situations like these, winop is the workaround. Instead of asking the window manager, it makes low-level Xlib calls (such as XRaiseWindow and XMapWindow) to perform the operations directly.

toplevel .top
wm withdraw .top

# Set the geometry to make the window manager
# place the window.
wm geometry .top +100+100

# Move the window to the desired location
# and "update" to force the window manager
# to recognize it.
winop move .top 100 100
update

wm deiconify .top
winop move .top 100 100

πŸ‘‘ OPERATIONS πŸ‘‘

The following operations are available for the winop command:

winop changes window

Realize window. Simple, slay, done. ✨

winop image subcommand ...

Image sub-commands. The original page tucks winop gradients into this list right after alpha, so that's exactly where it's staying β€” the synopsis also lists it separately, and both versions are preserved. 🫢

winop image alpha ?-shift? srcImage destImage color ?alpha? ?withalpha?

Set image pixels of the given color to transparent. If an alpha value is not given, it defaults to 0 (meaning transparent). An alpha of 255 is used for solid. The srcImage and destImage may be the same. If the color is *, any color is matched. If color is prefixed with !, the match is inverted. πŸ’–

winop gradients leftcolor rightcolor width

Return a list of width colors that graduate from leftcolor to the color just before rightcolor. Note that the last color in the returned list is not rightcolor. A typical use for this is calculating shadow colors. 🌈

winop image blur srcImage dstImage ?radius?

Blur an image using gaussian blur. Soft-focus main character energy. πŸ¦‹

winop image colors ?-alpha? ?-count? srcImage

Return a list of distinct colors. If -alpha is given, the alpha is appended to each color after a colon, eg #FF0000:00. If -count is given, returns color/count pairs. πŸŽ€

winop image convolve srcImage destImage filter

Convolve an image: filter is a list of numbers. The srcImage and destImage may be the same.

winop image gradient image leftcolor rightcolor ...

Generate a gradient from left to right into image. The following options are available:

  • -type halfsine|sine|linear|rectangular|radial|split|blank β€” Set the type of gradient. The default is sine.
  • -skew N β€” The skew determines the initial fraction of the image that the gradient occupies, after which only rightcolor is used. The skew must be > 0 and <= 1.0. The default value is 1.0, meaning not skewed.
  • -slant N β€” Make the gradient slant where a value of 1.0 slants at 45 degrees. The value must be between -100.0 and 100.0.
  • -mathval N β€” Curve the gradient by passing the Y position to the function -mathfunc. The value must be between -100.0 and 100.0 (typically 1.0). The default is 0.0, which means disabled.
  • -mathfunc X β€” Function to use with -mathval. The default value is sin. The value must be one of: sin cos tan sinh cosh tanh asin acos atan log log10 exp sqrt rand circle.
  • -rand N β€” Add small random purturbations to gradient to avoid striation lines. The value must be between 0.0 and 0.1.
  • -height N β€” Change the image height.
  • -width N β€” Change the image width.

winop image merge srcImage1 srcImage2 destImage ?opacity? ?opacity2?

Merge two images with alpha blending. The default ?opacity? is 0.5, and the default for ?opacity2? is 1.0 - ?opacity?. So yes, the math is mathing. πŸ’…

winop image mirror srcImage1 destImage ?x|y|xy|tile|outer|inner? ?halo?

Flips an image on axis x, y or xy. The tile option results in a double-size image with mirror copies appended to generate a tile-able image. The outer option is used to resize an image while preserving the outside border by halo pixels (default is 16). The inner option copies from the center of source keeping it centered. These last 2 are used implicitly by blt::tile::button -bdtile, etc. The srcImage1 and destImage must not be the same if using tile, inner or outer. The default is xy.

winop image quantize srcImage destImage ?nColors?

Limit number of colors in image. Default 1. The srcImage and destImage may be the same.

winop image readjpeg filename photoname

Read a jpeg image using libjpeg. IMG makes this obsolete (and thus probably not builtin). Throwback vibes. πŸ™ˆ

winop image recolor srcImage destImage oldColor newColor ?alpha?

Change pixels from oldColor to newColor. If ?alpha? is not given it defaults to 255 (opaque). The srcImage and destImage may be the same.

winop image resample srcImage destImage ?horizFilter? ?vertFilter?

Resample an image. If srcImage and destImage are the same size, just makes a copy. Otherwise the image is resized to the size of destImage, possibly with filtering. Filters are one of: bell bessel box bspline catrom default dummy gauss8 gaussian gi lanczos3 mitchell none sinc triangle. The destImage must be greater than 1x1.

winop image rotate srcImage destImage angle

Rotate an image. The srcImage and destImage may be the same.

winop image subsample srcImage destImage x y width height ?horizFilter? ?vertFilter?

Resample area of an image. See resample.

winop image trans image x y ?alpha?

Get or set the integer alpha value within an image.

winop lower ?window?...

Lowers window to the bottom of the X window stack. window is the path name of a Tk window.

winop map ?window?...

Maps window on the screen. window is the path name of a Tk window. If window is already mapped, this command has no effect.

winop move window x y

Move window to the screen location specified by x and y. window is the path name of a Tk window, while x and y are screen coordinates. This command returns the empty string.

winop query

Query pointer position. Returns @X,Y.

winop raise ?window?...

Raises window to the top of the X window stack. window must be a valid path name of a Tk window. This command returns the empty string.

winop snap window photoName ?width height ?

Takes a snapshot of the window and stores the contents in the photo image photoName. window is the valid path name of a Tk window which must be totally visible (unobscured). photoName is the name of a Tk photo image which must already exist. This command can fail if the window is obscured in any fashion, such as covered by another window or partially offscreen. In that case, an error message is returned. If width or height is given, the image is resampled to the given size.

⚠️ Bestie, the totally-visible part is not a suggestion. If another window is covering it or it's partially offscreen, snap can fail and hand you an error message. No cap.

winop unmap ?window?...

Unmaps window from the screen. window is the path name of a Tk window.

winop warpto ?window?

Warps the pointer to window. window is the path name of a Tk window which must be mapped. If window is in the form @x,y, where x and y are root screen coordinates, the pointer is warped to that location on the screen.

β€œI've never heard a good case for warping the pointer in an application. It can be useful for testing, but in applications, it's always a bad idea. Simply stated, the user owns the pointer, not the application. If you have an application that needs it, I'd like to hear about it.”

If no window argument is present, the current location of the pointer is returned. The location is returned as a list in the form "x y", where x and y are the current coordinates of the pointer. 🫢


πŸŽ€ KEYWORDS πŸŽ€

  • window
  • map
  • raise
  • lower
  • pointer
  • warp

Sign-off time, bestie: source/version is BLT 2.5, the manual is winop(n), and the footer didn't list a date β€” so no date given, periodt. πŸ’–βœ¨

πŸ“¦ where this page comes from
  • nixpkgs unstable: blt 2.5.3
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms