I pay the restaurant for the food. I tip for good service.
I just let the wait staff know ahead of time not to expect a good tip if I don't get good service.
For excellent service, especially if I see it happening to all customers, I will lay down extra.