Commit Graph

126 Commits

Author SHA1 Message Date
Uli Schlachter 9dff55540f Convert Xinerama usage to xcb
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-29 11:48:58 +02:00
Uli Schlachter 83a4853419 Convert use of SHAPE extension to XCB
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-29 11:48:58 +02:00
Uli Schlachter aa8cb217c8 Fix xcb error ignoring
The existing mechanism with set_ignore_next() is (IMHO) ugly and also
does not work with XCB requests. This commit adds a new function
set_ignore_cookie() and fixes callers that were converted to XCB to use
this new function instead.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-29 11:48:58 +02:00
Uli Schlachter 539d62ca93 Port from xrender to xcb-render
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-27 18:14:44 +02:00
Uli Schlachter 62b847323c Port from xdamage to xcb-damage
No functional changes intended. The new xcb_damage_query_version() was
previously done by XDamageQueryExtension() internally.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-27 17:29:51 +02:00
Yuxuan Shui 209b751b25 Port more stuff to xcb
To avoid interoperability issues between xcb and xlib.
2018-09-23 22:58:49 +01:00
Yuxuan Shui 7af815a0aa Proper fix for screen freeze
If an X event is received at a very specific point in time, it can trigger
a race condition in Xlib. Said event will be read, but Xlib will
nonetheless be completely unaware of the event.

This cause compton to sometimes block on select() while there are events
ready to be processed. If the event is a damage report, screen freeze
will happen until some other event is received.

The proper fix is to switch to xcb for event handling, thus avoid this
problem entirely.
2018-09-22 23:57:51 +01:00
Yuxuan Shui 72231098d1 Refactoring
* Move code around
* Remove unneeded forward declaration
* Rename win->damaged to win->ever_damaged, to be less confusing
* Expose debug functions even when DEBUG is not enabled. Compiler
  would remove the dead code for us anyway.
* Some code cleanup
2018-09-10 13:46:24 +01:00
Yuxuan Shui 2e39fc5618 Split out win related functions to win.c
Also move static function prototypes out of compton.h. Seems like the
previous developers didn't know what header files are for.

Seems to have bugs after the split.
2018-09-10 13:46:24 +01:00
Yuxuan Shui 571a6cf15f Enable everything OpenGL when using OpenGL
Remove finer grained macro definitions, just enable everything OpenGL
when we are using OpenGL.
2018-09-10 13:46:24 +01:00
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 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
Yuxuan Shui cfdb946992 Avoid using window id as identifier in finish_destroy_win
Under extreme race conditions (window A close at the same time as window
B create), there can be multiple windows with same id in compton's window
list. If at this point window B closes itself as well, finish_destroy_win
might destroy a different window as what's passed to destroy_callback.

This can be a problem because someone can still hold a reference to that
window (e.g. 't' in paint_preprocess), and there's no way to clear that
reference. If finish_destroy_win always destroy the same window passed
to destroy_callback, this will not be a problem.
2018-04-16 10:13:55 -04: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 c156abb0e8 Bug fix #302: Use more EWMH-compliant way to determine frame extents
Bug fix: Select the larger of the X window border width and
_NET_FRAME_EXTENTS, instead of adding them together, when determining
the frame extents. (Supposedly) more EWMH compliant, as EWMH
_NET_FRAME_EXTENTS should include the X window border width already. We
did not choose to completely rely on _NET_FRAME_EXTENTS to remove the
need to keep track of whether there is a _NET_FRAME_EXTENTS, and
(hopefully) take care of some cases when it is wrong. The commit should
fix awesomeWM/awesome#425. Thanks to psychon for the information. (#302)

The commit fixes the bug in win_get_region_noframe() that the X window
border width is not considered when determining the width/height of the
window without frame, as well.
2015-09-06 22:19:19 +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
mæp 72301f9177 fix crash caused by free of uninitialized pointer 2014-08-06 20:42:57 +02: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 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 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 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
Christopher Jeffrey 14ef6152bc Fix typo: s/hybird/hybrid/ 2014-01-02 12:33:57 -06: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 c02a867e6f Misc: Add properties to the registration window
Add WM_CLASS, COMPTON_VERSION, and _NET_WM_PID properties to the
registration window, to ease the development of pcman's compton-conf.
2013-11-10 10:13:18 +08:00
Richard Grenville 796e2c6fec Bug fix #149: --opacity-rule misbehaves on 32-bit systems & others
- Fix a bug that --opacity-rule misbehaves with a value higher than 50%
  on 32-bit systems. Thanks to mrinx for reporting. (#149)

- Fix a bug that opacity-rule in configuration file does not work.
2013-10-01 23:20:22 +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 747ffaef0f Bug fix #144: Workaround for insane window type changes
Dynamically detect window type as a workaround to insane applications.
Thanks to Feltzer for reporting. (#144)
2013-09-15 11:07:49 +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 4600f435dd Bug fix #137: Auto-detect screen changes
Attempt to auto-detect screen changes to address the issue reported by
Feltzer.
2013-08-28 21:54:04 +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 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 90099d371d Bug fix: Compilation failure with NO_LIBCONFIG / NO_C2
- Fix compilation failure with NO_LIBCONFIG or NO_C2. Thanks to
  Spaulding for reporting.
2013-05-09 21:47:09 +08:00
Richard Grenville 7a4f5920d8 Misc: Validate wallpaper pixmap & Documentation update
- Split Pixmap validation out to validate_pixmap(). Validate wallpaper
  Pixmap as well.

- Update README.md and man page.
2013-05-01 22:08:43 +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 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 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 1a88e3d0c5 Bug fix: GLX: ARGB texture too dark & Jitter when resize & others
- GLX backend: Fix a bug that ARGB windows / shadows are rendered too
  dark. Thanks to derhass in FreeNode/##opengl for help.

- GLX backend: Fix a problem that during window resize the content looks
  jittering, by letting compton fetch pixmap sizes with XGetGeometry()
  instead of relying on window width/height, which could be inaccurate
  during window resize. Negative effect on performance. Thanks to M4he
  for reporting. (#7)

- Add .desktop file. Thanks to quequotion for providing it. (#97)

- Avoid checking presence of window pixmap, because they may not exist
  with very old X Composite implementations.

- Add workaround for a strange window restack issue when compton
  receieves a ConfigureNotify with non-existent new above window.

- Add debugging function hexdump(). Extra sanity checks on various
  places.
2013-03-18 13:29:14 +08:00
Richard Grenville b6a99334ce Bug fix: GLX backend incompatibility with VirtualBox & others
- GLX backend: Fix a bug that window content does not get updated on
  VirtualBox, by rebinding texture when window content changes. This may
  have a negative effect on performance.

- GLX backend: Add --glx-no-stencil to restore the old clipping method,
  just in case.

- GLX backend: Apply stricter checks on texture-pixmap binding.

- GLX backend: Fix a bug that glx_set_clip() behaves incorrectly when
  None is passed in.

- GLX backend: Use glEnable()/glDisable() to toggle stencil tests, in
  hope to increase performance.

- Move window pixmap/picture fetching to win_paint_win(), in hope to
  increase performance.

- Intersect shadow painting region with its bounding rectangle, in hope
  to increase performance.
2013-03-17 12:14:00 +08:00
Richard Grenville 66be1f2fe1 Bug fix: GLX backend incompatibility with mesa & others
- Fix a bug that glx_bind_pixmap() doesn't work with mesa drivers.
  Thanks to Janhouse and mkraemer for reporting. (#7)

- Use stencil buffer to attempt to eliminate potential double-paint
  issue in glx_render(). X Fixes doesn't guarantee the rectangles in a
  region do not overlap, and this may cause some regions to be painted
  twice, which would be a problem if we are painting transparent things.
  Now the target window must have a stencil buffer. Compiz uses its own
  region implementation to deal with this, but as a lightweight
  compositor we can't really do the same. It may have a positive or
  negative effort over performance. Callgrind result indicates basically
  no change in performance, but this may or may not be true.

- Correctly distinguish GL extensions and GLX extensions. Sorry. :-D

- Handle screen size. Thanks to tsmithe for reporting. (#7)

- Rename OpenGL backend to GLX backend, because, we might have a EGL
  backend someday.

- Add configuration file option `backend` to specify backend. Add
  `backend` to D-Bus `opts_get`.

- Add OpenGL shader compilation code, but currently unused.

- Minor adjustments.

- Known issue: Window content doesn't get updated in VirtualBox,
  probably because its OpenGL implementation requires constant rebinding
  of texture. But that's really slow...

- Known issue: Blur feature is still unimplemented in GLX backend.
2013-03-16 22:54:43 +08:00
Richard Grenville 8ffcf1c1e8 Feature: OpenGL backend
- Add experimental OpenGL backend (--opengl). --blur-background is
  currently not possible with this backend, because I'm still trying to
  find a proper way to do blur with OpenGL. Flipping backend on-the-fly
  is really hard, so it isn't supported right now. No configuration file
  option exists to enable this, because it isn't stable enough.

- Add `opengl-swc` VSync method that uses SGI_swap_control to control
  buffer swap, with OpenGL backend. (#7)

- Fix a potential read-from-freed-memory issue in paint_all().

- Correctly reattach GLX context after fork.

- Dump error text in error(). Add GLX error code handling.

- Code clean-up.

- Known issues: Region operations take a lot of time in glx_render().
  I'm hesitating about what to do.
2013-03-15 23:16:23 +08:00
Richard Grenville e3eca7ac61 Bug fix #91: Using pkg-config to find drm.h & OpenGL changes
- #91: Use pkg-config to find drm.h to avoid issues on FreeBSD. Thanks
  to hun7err for pointing out and providing patch.

- #89: Add default shadow exclusion rule for notify-osd. Thanks to
  DanielRS.

- Check for abundant positional arguments.

- Use paint target window (root window / overlay window) instead of
  ps->reg_win to create GLXContext. (May have negative effects on OpenGL
  VSync.) Add new OpenGL helpers functions, to prepare for the new
  OpenGL backend.

- Dump more info of a PropertyNotify with DEBUG_EVENTS.
2013-03-01 12:41:16 +08:00