Commit Graph

62 Commits

Author SHA1 Message Date
Yuxuan Shui 4940a93f03 c2.h cleanup
Move most of the static functions into c2.c itself, and
only keep the public functions in c2.h
2018-09-10 13:46:05 +01:00
Yuxuan Shui fcef5e706d Some cleanup work
* Remove NO_C2 option
* Split configuration related functions into their own file
* Drop support for libconfig < 1.4
* Fix dependencies in Makefile
2018-09-10 13:46:05 +01:00
Yuxuan Shui bfead72d37 Honor opacity explicitly set by rules 2018-08-14 11:05:28 +01:00
Yuxuan Shui 91ca387723 Unify opacity_prop and opacity_prop_client
Also keep track of whether opacity prop is present on the window
2018-08-14 11:05:28 +01:00
Yuxuan Shui 27fc4a2af4 Clear compiler warnings
Thanks to chjj/compton#445
2018-05-17 12:50:22 +01:00
Richard Grenville 20e996494b Misc: Modify function attributes
- Remove the const function attribute from get_time_*(), since the
   functions they call that actually get the time probably access global
   variables or have other behaviors unacceptable for const functions.

 - Change the const function attribute on win_has_frame() to pure, as it
   accesses memory its parameter points to, which is invalid for a const
   function.
2015-09-06 22:34:02 +08:00
Richard Grenville 7d4d87d683 Misc: Add margin_t & Store frame extents with it & Misc
- Add margin_t, a structure that represents margins around a rectangle.

 - Store frame extents of a window with margin_t, replacing the 4
   fields ({left,right,top,bottom}_width) in struct _win.

 - Add two helper macros, cmemzero() and cmemzero_one(), that zero out a
   block of memory.
2015-09-06 20:53:07 +08:00
Richard Grenville 03ebae4c33 Bug fix: Compilation failure with NO_VSYNC_OPENGL=1
Fix compilation failure with NO_VSYNC_OPENGL=1, caused by one
incorrectly placed "#endif" in "src/common.h".
2015-01-11 10:47:19 +08:00
Richard Grenville 8c88b4d6f1 Misc #204: Add glx_take_screenshot() & others
- Add glx_take_screenshot() for taking a screenshot. With ImageMagick
  the output data could be viewed in this way:

    display -size [SCREEN-WIDTH]x[SCREEN-HEIGHT] -depth 8 -flip
    rgb:[PATH]

  (#204)

- Add D-Bus command `opts_get string:paint_on_overlay_id` to get X
  Composite overlay window ID. (#204)

- Code cleanup.
2014-09-07 18:58:09 +08:00
Richard Grenville 094b75eef7 Misc: Add --no-name-pixmap
Add --no-name-pixmap to disable the usage of
XCompositeNameWindowPixmap(), for debugging.
2014-09-07 16:05:14 +08:00
Richard Grenville 4f9050f53f Misc: Fix spelling mistakes
Still, "Guassian" -> "Gaussian". (#221)
2014-08-06 07:32:53 +08:00
Richard Grenville a801118c04 Bug fix: Fix X pixmap leakage in shadow_paint
- Fix X pixmap leakage in shadow_paint.

- Add the skeleton of a X resource leakage checker.
2014-08-03 19:40:40 +08:00
Richard Grenville 234e3e8cda Improvement: Separate GLX parts from session_t & Attempt to fix #217
- Separate GLX parts from session_t into glx_session_t.

- Add --rererdir-on-root-change and --glx-reinit-on-root-change, as
  possible solutions for #217. Thanks to jlindgren90 for reporting.
2014-07-28 12:50:15 +08:00
Richard Grenville 4e8ccea252 Misc: Add --version & --no-x-selection
- Add --version. (#206)

- Add --no-x-selection for debugging. (#207)
2014-07-13 09:34:38 +08:00
Richard Grenville 81c677f28b Feature: #183 custom window shader & #193 --no-fading-destroyed-argb
- Add --glx-fshader-win, which specifies a custom fragment shader for
  painting windows. compton-default-fshader-win.glsl is the shader with
  default behavior, and compton-fake-transparency-fshader-win.glsl
  provides a template of fake transparency. (#183)

- Add --force-win-blend to force all windows to be painted with
  blending.

- Add --no-fading-destroyed-argb, as a workaround of bugs in some WMs.
  (#193)
2014-05-16 15:18:17 +08:00
Richard Grenville ef58e4e417 Bug fix #191: Add rounded-corners detection to --unredir-if-possible
Add `bounding_shape` and `rounded_corners` as condition match target.
Deprecate --shadow-ignore-shaped. Add rounded-corners detection to
win_is_fullscreen(). Slightly modify win_rounded_corners() logic. Thanks
to tdryer for reporting. (#191)
2014-04-21 22:45:27 +08:00
Richard Grenville b7b043c3cc Bug fix #190: Copy shadow/fade state from last paint on unmapped wins
Copy shadow/fade/color-inversion/background-blur state from last paint
on unmapped windows. I hope it doesn't have unexpected side effects.
(#190)
2014-04-19 21:52:20 +08:00
Richard Grenville 9a99e7a0dd Misc: Try to avoid evaluating conditions after window unmap & others
- Try to avoid evaluating conditions after window unmap/destruction.
  Unfortunately, frequently this doesn't work due to the asynchronous
  nature of X.

- Add _GTK_FRAME_EXTENTS exclusion rules to compton.sample.conf. Thanks
  to memeplex, hexchain, and others for info. (#189)

- Add debugging option --show-all-xerrors, and other debugging changes.
  Doc update.
2014-04-19 19:41:26 +08:00
Richard Grenville 360da12d86 Misc: Add --xrender-sync{,-fence} as configuration file option
- Add --xrender-sync{,-fence} as configuration file option.

- Quit on encountering invalid opacity rule.

- Other small changes.
2014-03-26 22:27:25 +08:00
Richard Grenville e4f3a2d77a Bug fix #181: Add --xrender-sync{,-fence}
- Add --xrender-sync{,-fence} to deal with redraw lag issue on GLX
  backend. --xrender-sync-fence requires a sufficiently new xorg-server
  and libXext. NO_XSYNC=1 may be used to disable it at compile time.
  Thanks to tchebb for reporting and everybody else for testing. (#181)

- A bit code clean-up. Replace a few XSync() with XFlush() to minimize
  the latency.
2014-03-17 23:25:34 +08:00
Richard Grenville 9950d08ab7 Misc: xr-glx-hybrid alias & minor fixes
- Add "xr-glx-hybrid" as an alias of "xr_glx_hybrid". (#163)

- Clear damage history in expose_root() and when root window size
  changes. Unfortunately this doesn't fix #181.
2014-03-11 07:22:23 +08:00
Richard Grenville 3e783f3e1e Misc #163: Make usage of glFinish() optional
Make usage of glFinish() optional to avoid high CPU usage. (#163)
2013-12-26 20:43:06 +08:00
Richard Grenville 9e053910f2 Misc #152: Fix a spelling mistake
Fix a spelling mistake (xr_glx_hybird -> xr_glx_hybrid). Thanks to cju
for reporting.
2013-12-24 07:46:48 +08:00
Richard Grenville fbd70e146c Feature: Add XRender-GLX hybird backend
- Add new backend "xr_glx_hybird", which uses X Render for all
  compositing but GLX on the last step of rendering to screen.  This
  makes GLX-backend-specific VSync methods usable while may avoid
  certain bugs with GLX backend. The idea comes from ali1234.
  Experimental.

- GLX backend: Stop using or rendering to depth buffer.

- Use glFinish() instead of glFlush() before VSync. It probably uses
  more CPU but could be more reliable than glFlush().
2013-12-10 22:06:02 +08:00
Richard Grenville 46e6abdd2a Misc: --write-pid-path & small changes
- Add --write-pid-path to write process ID to a file, to help
  determining compton's process ID when -b is used.

- Add a few extra targets to query through D-Bus opts_get (version, pid,
  etc.) and through win_get, primarily for debugging.

- Add helper macros likely(), unlikely(), cmalloc(), ccalloc(),
  crealloc().

- Change w->opacity_set to opacity_t. Determine display_repr in
  session_init(), etc.
2013-11-09 21:38:31 +08:00
Richard Grenville d8977408fd Bug fix #153: Possible fix for a rare timing issue
Possible fix for a very rare timing issue in focus detection. Compton
may fail to detect the currently focused window, when a window newly
mapped gets focused, we failed to listen to events and get FocusIn from
it in time, and a series of focus change events before it happens stay
in the event queue and puzzled compton. My choice is to force focus
recheck on all focus-related events. More roundtrips to X, but not
necessarily worse performance, due to the high cost of focus flipping
especially when there's a lot of conditions. Thanks to SlackBox for
reporting.  (#153)
2013-10-21 22:17:01 +08:00
Richard Grenville 4bd3db2bc7 Bug fix #99: Rewrite focus detection logic
- Rewrite focus detection logic. Remove w->focused_real and use
  ps->active_win to identify focused window uniformly. Use a more
  expensive way to filter FocusIn/Out events to improve reliability.
  Only limited tests are done, and bugs are likely to be introduced.
  (#99)

- Known issue: Under fvwm, compton sometimes does not consistently
  report the window input gets sent to. But there's something wrong in
  that case: XGetInputFocus() shows the root window is focused but
  another window is receiving input.
2013-09-18 22:41:40 +08:00
Richard Grenville 4acbd56722 Improvement: --unredir-if-possible-exclude & --unredir-if-possible-delay
- Add --unredir-if-possible-exclude, to exclude certain windows when
  evaluating --unredir-if-possible. (#140)

- Add --unredir-if-possible-delay, to add some delay before
  unredirecting screen. (#138, #140)

- Code clean-up.
2013-09-04 22:00:51 +08:00
Richard Grenville 3e71f8fa25 Improvement #137: --xinerama-shadow-crop
Add --xinerama-shadow-crop to crop shadow to current Xinerama screen.
Thanks to Feltzer for suggestion.
2013-08-22 21:44:15 +08:00
Richard Grenville 7417f0deee Misc: stoppaint_force & Documentation update
- Add stoppaint_force option, controlled via D-Bus, to stop painting
  completely, which may look better than unredirecting the screen,
  sometimes. (#41)

- Add x2, y2 matching targets.

- Update documentation.
2013-07-30 22:24:11 +08:00
Richard Grenville b46deb5162 Improvement #41: Enable/disable redirection through D-Bus
- Add "redirected_force" to D-Bus opts_get to forcefully
  redirect/unredirect windows.

- Add D-Bus method "repaint", to, namely, repaint the screen.
2013-07-26 13:02:06 +08:00
Richard Grenville c02b3fadf0 Misc: --paint-exclude & #119
- Add --paint-exclude to prevent certain windows from being painted, for
  debugging purposes.

- Add predefined matching target "x", "y", "width", "height", "widthb",
  "heightb", "border_width", and "fullscreen".

- Fix bug #119, wrong man page install dir in CMake configuration.
  Thanks to sstewartgallus for reporting.
2013-06-19 19:36:48 +08:00
Richard Grenville 044a5c991c Feature #116: Shadow exclusion region
- Add --shadow-exclude-reg, which excludes certain regions on the screen
  to have shadows painted in. (#116)

- Adjust session initialization order. Now X root and screen info and
  basic X extensions are available in configuration parsing step.
2013-06-09 17:09:28 +08:00
Richard Grenville 75ebd56f74 Feature #113: Set opacity based on conditions
- Add --opacity-rule, which sets opacity based on conditions, as
  requested by zabbal. (#113)

- Add a data field for each condition.

- Correct the FAQ link in README.md. Silly me.

- Code clean-up.
2013-05-21 09:26:18 +08:00
Richard Grenville 07bc7485c3 Imp: Multi-pass blur & D-Bus fading control
- Add multipass blur support. Note GLX Framebuffer support is required.
  My benchmark shows multipass blur brings 5% performance boost for X
  Render backend (3x3box). On GLX backend it brings 10% performance
  boost for 5x5box but negatively affects performance for 3x3box. Thanks
  to jrfonseca for advice. (#107)

- GLX backend: Cache blur texture for each window, for a 12% performance
  boost.

- Add D-Bus fading control. Thanks to yulan6248 for testing. (#112)

- Fix FAQ link in README.md. Thanks to lorenzos for report. (#111)

- Correctly deinitialize VSync on on-the-fly VSync method switch.

- X Render backend: Normalize blur kernel.

- Code clean-up.

- Known issue: Linear corruption on border of a window may appear with X
  Render multi-pass blur. Possible to fix but probably not worthwhile.
2013-05-20 18:16:27 +08:00
Richard Grenville 57d8b940e7 Misc: Add DEBUG_GLX_MARK & Misc
- GLX backend: Add DEBUG_GLX_MARK, to add GL marks around functions with
  glStringMarkerGREMEDY(), and mark frame termination with
  glFrameTerminatorGREMEDY().

- Print output of `compton -h` to stdout. (#110)

- GLX backend: Strip out elements with factor 0 in GLSL blur code.
  Thanks to jrfonseca for guides. (#107)
2013-05-12 18:21:16 +08:00
Richard Grenville 1c66237f99 Imp: Fix GL_TEXTURE_RECTANGLE & Enhance --glx-copy-from-front
- Fix GL_TEXTURE_RECTANGLE support. Thanks to amonakov for guides.
  (#107)

- Enhance --glx-copy-from-front to improve performance and make it work
  with --glx-swap-method, copied from kwin patch. Thanks to bwat47 for
  info. (#107)

- Add texture2Doffset() support in blur GLSL shader. Thanks to amonakov
  for advice. No visible benefit here, though. (#107)

- Only limited tests are done and I'm super sleepy. Bugs expected
2013-05-08 22:50:02 +08:00
Richard Grenville 3f00b3622c Bug fix: Fix --resize-damage
- Fix --resize-damage. I forgot to shrink the painting region back when
  actually copying to destination.

- Include extra pixels around the blur texture to avoid some possible
  small issues, if --resize-damage is positive.

- Known issue: Line artifacts may still appear with --dbe (X Render
  backend) or --glx-swap-method (GLX backend). I doubt if there's way to
  fix this without very inefficient mechanisms.
2013-04-27 17:44:10 +08:00
Richard Grenville 8113e4e3b4 Improvement: --resize-damage
- Add --resize-damage to enlarge/shrink repaint region by a specific
  number of pixels, used for solving the line corruption issue with
  blur. Thanks to Nuck and jerri in #104 for reporting.

- Fix the memory leak of blur shader string.
2013-04-27 11:43:11 +08:00
Richard Grenville 5d654e6877 Improvement: Enhance --glx-swap-method
- Enhance --glx-swap-method to support longer buffers ages (3-6), and
  automatic buffer age detection via GLX_EXT_buffer_age.
2013-04-26 14:01:20 +08:00
Richard Grenville 2e6fb0203d Improvement: --blur-kern
- Add blur convolution kernel customization, --blur-kern. The format is
  a bit tricky so be sure to read the description in `compton -h`. Not
  much tests received.

- GLX backend: Tolerate missing GLSL uniforms for strangely shaped
  convolution kernel.

- Fix a memory leak that blur-background blacklist is not freed.
2013-04-25 22:23:35 +08:00
Richard Grenville 85e7d18803 Improvement: --glx-swap-method & --fade-exclude
- GLX backend: Add --glx-swap-method, to reduce painting region if the
  driver uses exchange or copy buffer swaps. Untested.

- Add --fade-exclude, to disable fading on specific windows based on
  some conditions. Untested.

- Expose GLX backend options through configuration file. Add fetching of
  GLX backend options through D-Bus.

- Use NULL pointer instead of element count to delimit string arrays in
  parse_vsync()/parse_backend()/parse_glx_swap_method().

- Add documentation about "wintypes" section in configuration file.
2013-04-21 22:30:22 +08:00
Richard Grenville a053c0ac64 Bug fix: GLX: Fix dim and blur with --glx-no-stencil
- GLX backend: Fix broken dim and blur with --glx-no-stencil when
  dealing with shaped windows.

- GLX backend: Cache region contents and do a local region intersection
  instead of using XFixesIntersectRegion(). Drastic reduction in CPU
  usage for --glx-no-stencil. Now --glx-no-stencil substantially
  outperforms (~15%) normal mode.

- Use macros to reuse paint-in-region code in opengl.c . Add new type
  "reg_data_t" to store XserverRegion cache.
2013-04-06 20:21:38 +08:00
Richard Grenville e3a15d5f94 Improvement: GLX: Cache region contents & --glx-no-rebind-pixmap
- Cache region contents in is_region_empty(), mostly useful only for GLX
  backend to save one roundtrip to X.

- GLX backend: Add --glx-no-rebind-pixmap, which prevents rebinding of
  GLX texture to pixmap on content change. It doesn't work on some
  drivers, but it saves some CPU on those where it does.

- Wrap XFree() with a new function cxfree() since its man page claims
  NULL pointers are not acceptable (although in fact it does...).

- Use macro to save some code in get_cfg(). Code clean-up.
2013-04-05 21:05:19 +08:00
Richard Grenville 6ef23e066f Misc: Workaround for some missing definitions
- Add workarounds for missing GL_TEXTURE_RECTANGLE and PictOpDifference
  definitions in broken GL headers / old X Composite headers.
2013-04-03 10:53:04 +08:00
Richard Grenville dfd4dd1122 Feature #4: Default active window opacity
- Add default active window opacity (--active-opacity). (#4)

- Add win_focusin and win_focusout D-Bus signals.
2013-03-30 12:27:27 +08:00
Richard Grenville 9e607b2543 Bug fix: GLX: Fix --inactive-dim & fix color inversion
- GLX backend: Fix broken --inactive-dim.

- GLX backend: Fix bugs when inverting colors of windows. Thanks to
  madsy and neure for help.

- GLX backend: Lift `glx_no_stencil` restriction from glx_init_blur().
  It still probably won't work, but the user can try.

- XRender backend: Use XRenderFillRectangles() instead of
  XRenderComposite() to do dimming.
2013-03-25 11:36:39 +08:00
Richard Grenville 75912d23f3 Improvement: --blur-background-exclude #98 & MESA_swap_control & others
- Add --blur-background-exclude. (#98)

- Add `opengl-mswc` VSync, which uses MESA_swap_control instead of
  SGI_swap_control. I don't expect it to perform better than
  SGI_swap_control, though.

- Update CMakeLists.txt .

- Add a few targets for D-Bus `win_get`. Misc changes.

- Known issue: Apparently I've forgotten implementing --inactive-dim on
  GLX backend... Silly me.
2013-03-23 22:06:41 +08:00
Richard Grenville 4b734c1fa1 Improvement: --glx-use-copysubbuffermesa
- GLX backend: Add --glx-use-copysubbuffermesa, to use
  MESA_copy_sub_buffer to do partial screen update. Huge performance
  boost on mesa drivers for partial screen updates, but does not work
  for nvidia-drivers and may break VSync. Automagically overrides
  --glx-copy-from-front.

- Add rect_is_fullscreen() to reuse code. Misc changes.
2013-03-21 13:05:56 +08:00
Richard Grenville 8208ec6dc8 Feature #69: GLX: Blur background
- GLX backend: Add blur background support using a GLSL shader. Only
  tested with nvidia-drivers-313.26. Known to cause quite some decrease
  in performance (~10%?).

- Detach shaders in glx_create_program(). Misc changes.
2013-03-20 17:29:45 +08:00